User:Gerbrant/gui/window.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.

new function()
{
 
var docLoaded = false;
 
document.write("\
<style>\
.gerbrant-window\
{\
	position:absolute;\
	z-index:15;\
  	left:1em;top:3em;\
	padding:1px;\
	border:1px solid #888;\
	background:#fff;\
}\
.gerbrant-titlebar\
{\
	border:1px solid #88f;\
	background:#ddf;\
	color:#000;\
}\
.gerbrant-windowcontent\
{\
	padding:1em;\
	background:#eee;\
	color:#000;\
}\
</style>");
 
hookEvent("load", function()
{
	docLoaded = true;
});
 
loadModule("Gerbrant.gui.taskbar", function(tb)
{
 
module("Gerbrant.gui.window", function(t)
{
	var s;
	var divWindow = document.createElement("DIV");
	var divTitle = document.createElement("DIV");
	var divContent = document.createElement("DIV");
	var visible = true;
 
	divTitle.className = "gerbrant-titlebar";
	divContent.className = "gerbrant-windowcontent";
	divWindow.className = "gerbrant-window";
	divWindow.appendChild(divTitle);
	divWindow.appendChild(divContent);
 
	this.getCaption = function(){return divTitle.innerHTML;};
	this.setCaption = function(t){divTitle.innerHTML = t;};
 
	this.getVisible = function(){return visible;};
	this.setVisible = function(b){divWindow.style.display =
		((visible = b) ? "" : "none");};
 
	this.getContent = function(){return divContent;};
	this.getContentHTML = function(){return divContent.innerHTML;};
	this.setContentHTML = function(t){divContent.innerHTML = t;};
 
	this.setCaption(t);
 
	function show()
	{
		document.getElementById("column-one").appendChild(divWindow);
	}
	if(docLoaded) show();
	else hookEvent("load", show);
 
	tb.addWindow(this);
});
 
});
 
}