/** * @AUTHOR: Alexandre Correia - alexandrecorreia [.at.] celepar [.dot.] pr [.dot.] gov [.dot.] br * @AUTHOR: Rodrigo Souza - rodrigosouzadossantos [.at.] gmail [.dot.] com * @COPYLEFT: GPL - http://www.gnu.org/copyleft/gpl.html * @DATE: 07/11/2007 * @LAST CHANGE: * @BRIEF: **/ function build_win() { this.window = []; this.position = {"x":10, "y":10}; this.focus = 100; this.xtools = new XTools(); } build_win.prototype = { "elementB" : function(pId) { return document.getElementById(pId + '_window_body'); }, "elementC" : function(pId) { return document.getElementById(pId + '_window_body_content'); }, "elementM" : function(pId) { return document.getElementById(pId + '_window_master'); }, "load" : function(pId, pParentId, pXml, pXsl, pSize, pButMin, pButMax, pButClose) { try{ if( document.getElementById(pId + '_window_master') == null) { pXml = '' + pXml ; pXml += '' + pId + ''; pXml += (pSize) ? '' + pSize + 'px' : '200px' ; pXml += (pButMin) ? 'block' : 'none'; pXml += (pButMax) ? 'block' : 'none'; pXml += (pButClose) ? 'block' : 'none'; pXml += ''; var div = document.createElement("div"); div.innerHTML = this.xtools.parse(pXml,pXsl); document.getElementById(pParentId).appendChild(div); this.window_position(pId, this.elementM(pId)); this.window_state(pId, 'nm'); this.window_focus(this.elementM(pId)); } else { this.window_visible(pId); this.window_state(pId, 'nm'); } } catch(e) { alert("Error : \n\n" + e + "\n\n" + e.description); } }, "window_close" : function(pId) { this.window_state(pId, 'cl'); this.elementM(pId).parentNode.removeChild(this.elementM(pId)); }, "window_focus" : function(pElement) { pElement.style.zIndex = ++this.focus; }, "window_maximize" : function(pId) { this.window_state(pId, 'max'); // _button_maximize var button_maximize = document.getElementById(pId + '_button_maximize'); button_maximize.onclick = function(){buildIM.window_normal(button_maximize, pId, 'window_maximize');}; // _window_master this.elementM(pId).style.top = "0px"; this.elementM(pId).style.left = "0px"; this.elementM(pId).style.width = 'auto'; this.elementM(pId).style.height = '100%'; // _window_body this.elementB(pId).style.width = 'auto'; this.elementB(pId).style.height = '100%'; // _window_body_content this.elementC(pId).style.height = '100%'; }, "window_minimize" : function(pId) { this.window_state(pId, 'min'); // _window_master this.elementM(pId).style.display = 'none'; }, "window_normal" : function(pButton, pId, pFunction) { this.elementM(pId).style.top = this.window[pId].y; this.elementM(pId).style.left = this.window[pId].x; this.elementM(pId).style.width = this.window[pId].w; this.elementM(pId).style.height = 'auto'; pButton.onclick = function(){eval('buildIM.' + pFunction + '("' + pId + '")');}; this.window_state(pId, 'max'); }, "window_object" : function( pId, pState) { this.window[pId] = { "x": this.elementM(pId).offsetLeft, "y": this.elementM(pId).offsetTop, "w": this.elementM(pId).clientWidth, "h": this.elementM(pId).clientHeight, "s": pState }; }, "window_position" : function( pId, pElement ) { pElement.style.position = 'absolute'; if ( this.window[pId] ) { pElement.style.left = this.window[pId].x + "px"; pElement.style.top = this.window[pId].y + "px"; } else { pElement.style.left = parseInt( this.position.x += 10 ) + "px"; pElement.style.top = parseInt( this.position.y += 10 ) + "px"; } }, "window_state" : function(pId, pState) { if(this.window[pId]) { if(pState == 'max') { if(this.window[pId].s == 'max') this.window_object( pId, pState); else this.window_object( pId, pState); } else if( pState == 'cl') this.window_object( pId, pState); } else this.window_object( pId, pState); }, "window_visible" : function(pId) { if ( this.elementM(pId).style.display == 'none' ) this.elementM(pId).style.display = 'block'; } }; var buildIM = new build_win();