c58a1abe81bf227179183c01f527f812f2b7032f33aad56a100a6ae138b2b669

Source Code:

// Gaia Ajax Copyright (C) 2008 - 2011 Gaiaware AS. details at http://gaiaware.net/
if(!Gaia.Extensions)
Gaia.Extensions=Class.create();Gaia.Extensions.Window=Class.create(Gaia.Panel,{initialize:function(element,options){this.initializeWindow(element,options);},initializeWindow:function(element,options){this.initializeWindowEffects(options);this.initializePanel(element,options);this.initializeWindowDimensions();var properties=options.p;if(Object.isNumber(properties)){if((properties&8)===8){this.options.center=true;var canCenter=!Object.isNumber(options.nested)||$G(this.element.id.substr(0,this.options.nested))!==null;if(canCenter)
this.center();}
if((properties&1)===1)
this.setMinimized(1);if((properties&2)===2)
this.setMaximized(1);if((properties&4)===4)
this.bringWindowToFront();}
Element.setStyle(this.element,{'visibility':'visible','display':'none'});Element.fire(this.element,"gaia:appearing");Element.observe(element,'click',Gaia.Extensions.Window.clickHandler.bindAsEventListener(this));},initializeWindowEffects:function(options){options.effects=Object.extend({gaiaminimizing:function(e){this.defaultMinimize();},gaiarestoring:function(e){this.defaultRestore();},gaiarestoreafterminimize:function(e){this.defaultRestore();},gaiaclosing:function(e){this._setVisibleImpl(false);},gaiaappearing:function(e){Element.show(Event.element(e));}},options.effects);},initializeWindowDimensions:function(){var elementStyle=this.element.style;if(Prototype.Browser.IE){if(Object.isUndefined(elementStyle.width))
elementStyle.width=Element.getWidth(this.element)+'px';if(Object.isUndefined(elementStyle.height))
elementStyle.height=Element.getHeight(this.element)+'px';}
this.options.widthOfBorders=Element.getWidth(this.element)-Element.getWidth(this.getContent());this.options.heightOfBorders=Element.getHeight(this.getCaption())+Element.getHeight(this.getBottom());if(elementStyle.height&&!this.options.maximized)
this.setHeight(parseInt(elementStyle.height,10)||0);},setBars:function(value){this.setScrollBars(value,this.getContent());var overflowValue=value!=='None'?'hidden':'visible';Element.setStyle(this.getMiddle().up(),{'overflow':overflowValue});return this;},setCCH:function(value){$(this.element.id+'_h').className=value;return this;},setSkinCssClass:function(current,value){this.options.className=value;return this.setSkinCssClassRoot(current,value,this.element);},setMinimized:function(value){this.options.minimized=value;if(value){if(this.options.maximized)
this.setMaximized(0);this._storeOldPositionAndHeight();Element.fire(this.element,"gaia:minimizing");}else
this.restore("gaia:restoreafterminimize");return this;},setMaximized:function(value){this.options.maximized=value;var maximizeCssClass=this.options.className+"-window-maximized";if(value){if(this.options.minimized)
this.setMinimized(0);Element.addClassName(this.element,maximizeCssClass);this._storeOldPositionAndHeight();var container=this.getOuterContainerBody();if(container!==null){this.element.clonePosition(container);this.sync();}else{var positionOffset=this.element.getOffsetParent().viewportOffset();this.element.setStyle({left:-positionOffset.left+'px',top:-positionOffset.top+'px'});var dimensions=document.viewport.getDimensions();this.setWidth(dimensions.width);this.setHeight(dimensions.height);}}else{Element.removeClassName(this.element,maximizeCssClass);this.restore('gaia:restoring');}
return this;},restore:function(evtName){Element.fire(this.element,evtName,{w:this._oldSizePos.width,h:this._oldSizePos.height,t:this._oldSizePos.top,l:this._oldSizePos.left,widthInner:this._oldSizePos.widthInner,heightInner:this._oldSizePos.heightInner,afterFinish:this.sync.bind(this)});},defaultMinimize:function(){var content=this.getContent();if(!Element.visible(content))return;Element.toggle(content);Element.setStyle(this.element,{width:'300px'});},defaultRestore:function(){Element.setStyle(this.element,{top:this._oldSizePos.top,left:this._oldSizePos.left,width:this._oldSizePos.width,height:this._oldSizePos.height});var content=this.getContent();Element.show(content);Element.setStyle(content,{width:this._oldSizePos.widthInner,height:this._oldSizePos.heightInner});},_storeOldPositionAndHeight:function(){var content=this.getContent();this._oldSizePos={top:this.element.style.top,left:this.element.style.left,width:this.element.style.width,height:this.element.style.height,widthInner:content.style.width||(Element.getWidth(content)+'px'),heightInner:content.style.height||(Element.getHeight(content)+'px')};},sync:function(){var dimensions=Element.getDimensions(this.element);this.setWidth(dimensions.width);this.setHeight(dimensions.height);},setHeight:function(value){Element.setStyle(this.element,{height:value+"px"});var content=this.getContent();var expectedHeight=(Element.getHeight(this.element)||value)-this.options.heightOfBorders;Element.setStyle(content,{height:expectedHeight+'px'});var difference=Element.getHeight(this.getMiddle())-expectedHeight;if(difference>0){Element.setStyle(content,{height:(expectedHeight-difference)+'px'});}
return this;},setWidth:function(value){Element.setStyle(this.element,{width:value+'px'});var content=this.getContent();var expectedWidth=(Element.getWidth(this.element)||0)-this.options.widthOfBorders;Element.setStyle(content,{width:expectedWidth+'px'});var contentWidth=Element.getWidth(content);var difference=contentWidth-expectedWidth;if(difference>0){Element.setStyle(content,{width:(value-this.options.widthOfBorders-difference)+'px'});}
return this;},reInit:function(){this._reInit();this.initializeWindowDimensions();},getOuterContainerBody:function(){for(var node=this.element.parentNode;node!==null;node=node.parentNode){if(!Gaia.Control.isGaiaControlRootNode(node))continue;var control=$G(node.id);if(control.isAjaxContainer())
return control.getBody();}
return null;},setVisible:function(value){if(value)
this._setVisibleImpl(value);else
Element.fire(this.element,"gaia:closing",{afterFinish:this.destroy.bind(this)});},getCaption:function(){return $(this.element.id+'_header');},getBottom:function(){return $(this.element.id+'_bottom');},getContent:function(){return $(this.element.id+'_content');},getMiddle:function(){return $(this.element.id+'_middle');},center:function(skipChildren){var scr=document.viewport.getScrollOffsets();var size=document.viewport.getDimensions();var dimensions=Element.getDimensions(this.element);var posLeft=Math.round(Math.max((size.width/2)-(dimensions.width/2),0));var posTop=Math.round(Math.max((size.height/2)-(dimensions.height/2),0));posTop+=scr.top;posLeft+=scr.left;Element.setStyle(this.element,{top:posTop+'px',left:posLeft+'px'});var cumOff=Element.cumulativeOffset(this.element);if(cumOff.left!==posLeft){posLeft-=cumOff.left-posLeft;Element.setStyle(this.element,{left:posLeft+'px'});}
if(cumOff.top!==posTop){posTop-=cumOff.top-posTop;Element.setStyle(this.element,{top:posTop+'px'});}
if(skipChildren)return;this._centerChildWindows();},_centerChildWindows:function(){var childWindows=[];this.eachGaiaChild(function(windowArray,control,key){if(Object.isFunction(control.initializeWindow)&&control.options.center)
windowArray.push(control);}.curry(childWindows));childWindows.sort(function(x,y){return x.element.id.length-y.element.id.length;}).invoke('center',true);},_getElementPostValue:function(){return'';},bringWindowToFront:function(){var id=this.element.id;var wnd=Gaia.Extensions.Window;if(wnd._topMostWindow===id)return;wnd._topMostWindow=id;this.bringToFront();},destroy:function(){Element.stopObserving(this.element,'click');var wnd=Gaia.Extensions.Window;if(wnd._topMostWindow===this.element.id)
wnd._topMostWindow=null;this._panelDestroy();}});Gaia.Extensions.Window._topMostWindow=null;Gaia.Extensions.Window.clickHandler=function(evt){if(!!evt.$stopPropagation$)return;evt.$stopPropagation$=true;this.bringWindowToFront();};Gaia.Extensions.Window.browserFinishedLoading=true;