r9133: a huge import of the qooxdoo infrastructure. I decided to import all the widge...
[sfrench/samba-autobuild/.git] / swat / style / qooxdoo / widgets / widgets / QxFieldSet.js
1 /* Copyright (c): 2002-2005 (Germany): United Internet, 1&1, GMX, Schlund+Partner, Alturo */
2 function QxFieldSet(vLegend){QxWidget.call(this);if(isValid(vLegend)){this.setLegend(vLegend);};this._minWidth=100;this._minHeight=50;this.setMinWidth(this._minWidth);this.setMinHeight(this._minHeight);this._dim={};};QxFieldSet.extend(QxWidget,"QxFieldSet");QxFieldSet.addProperty({name:"legend",type:String});proto._modifyElement=function(_b1,_b2,_b3,_b4){if(_b1){if(!this._frame){this._frame=QxFieldSet._h3.cloneNode(true);this._legend=this._frame.firstChild;this._content=this._frame.lastChild;};_b1.appendChild(this._frame);}else if(_b2&&this._frame){_b2.removeChild(this._frame);};QxWidget.prototype._modifyElement.call(this,_b1,_b2,_b3,_b4);return true;};proto._beforeShow=function(){this._renderLegend();this._renderWidth();this._renderHeight();};if((new QxClient).isGecko()){proto._renderLegend=function(){if(!this.isCreated()){return;};var oldWidth1=this.getElement().style.width;var oldWidth2=this._frame.style.width;var newWidth;this.getElement().style.width=this._frame.style.width="10000px";this._legend.style.width="";var l=this.getLegend();if(isValid(l)){this._legend.firstChild.nodeValue=l;this._legend.style.display="block";newWidth=this._legend.scrollWidth;}else {this._legend.style.display="none";newWidth=0;};this.getElement().style.width=oldWidth1;this._frame.style.width=oldWidth2;this._legend.style.width=newWidth+"px";if(this.getMinWidth()==this._minWidth){this._minWidth=newWidth+QxDOM.getComputedMarginLeft(this._legend)+QxDOM.getComputedMarginRight(this._legend);this.setMinWidth(this._minWidth);};};}else {proto._renderLegend=function(){if(!this.isCreated()){return;};var l=this.getLegend();if(isValid(l)){this._legend.firstChild.nodeValue=l;this._legend.style.display="block";}else {this._legend.style.display="none";};if(this.getMinWidth()==this._minWidth){this._minWidth=this._legend.scrollWidth+QxDOM.getComputedMarginLeft(this._legend)+QxDOM.getComputedMarginRight(this._legend);this.setMinWidth(this._minWidth);};};};proto._modifyLegend=function(_b1,_b2,_b3,_b4){this._renderLegend();return true;};proto._getParentNodeForChild=function(){return this._content;};proto._renderWidth=function(size){if(!this.isCreated()){return true;};var wFrame=Math.max(0,this.getElement().offsetWidth-QxDOM.getComputedMarginLeft(this._frame)-QxDOM.getComputedMarginRight(this._frame));var wContent=wFrame>0?Math.max(0,wFrame-QxDOM.getComputedInsetLeft(this._frame)-QxDOM.getComputedInsetRight(this._frame)-QxDOM.getComputedMarginLeft(this._content)-QxDOM.getComputedMarginRight(this._content)):0;this._frame.style.width=wFrame+"px";this._content.style.width=wContent+"px";return true;};proto._renderHeight=function(size){if(!this.isCreated()){return true;};var hFrame=Math.max(0,this.getElement().offsetHeight-QxDOM.getComputedMarginTop(this._frame)-QxDOM.getComputedMarginBottom(this._frame));var hContent=hFrame>0?Math.max(0,hFrame-QxDOM.getComputedInsetTop(this._frame)-QxDOM.getComputedInsetBottom(this._frame)-QxDOM.getComputedMarginTop(this._content)-QxDOM.getComputedMarginBottom(this._content)):0;this._frame.style.height=hFrame+"px";this._content.style.height=hContent+"px";return true;};proto.getComputedBorderLeft=proto.getComputedInsetLeft=function(){return QxDOM.getComputedMarginLeft(this._frame)+QxDOM.getComputedInsetLeft(this._frame)+QxDOM.getComputedMarginLeft(this._content);};proto.getComputedBorderRight=proto.getComputedInsetRight=function(){return QxDOM.getComputedMarginRight(this._frame)+QxDOM.getComputedInsetRight(this._frame)+QxDOM.getComputedMarginRight(this._content);};proto.getComputedBorderTop=proto.getComputedInsetTop=function(){return QxDOM.getComputedMarginTop(this._frame)+QxDOM.getComputedInsetTop(this._frame)+QxDOM.getComputedMarginTop(this._content);};proto.getComputedBorderBottom=proto.getComputedInsetBottom=function(){return QxDOM.getComputedMarginBottom(this._frame)+QxDOM.getComputedInsetBottom(this._frame)+QxDOM.getComputedMarginBottom(this._content);};proto.getComputedAreaWidth=function(){return this.getElement().offsetWidth-this.getComputedInsetLeft()-this.getComputedInsetRight();};proto.getComputedAreaHeight=function(){return this.getElement().offsetHeight-this.getComputedInsetTop()-this.getComputedInsetBottom();};proto.getComputedInnerWidth=function(){return this.getElement().offsetWidth-this.getComputedInsetLeft()-this.getComputedInsetRight()-this.getComputedPaddingLeft()-this.getComputedPaddingRight();};proto.getComputedInnerHeight=function(){return this.getElement().offsetHeight-this.getComputedInsetTop()-this.getComputedInsetBottom()-this.getComputedPaddingTop()-this.getComputedPaddingBottom();};proto._applySizeHorizontal=function(size){QxWidget.prototype._applySizeHorizontal.call(this,size);return this._renderWidth();};proto._applySizeVertical=function(size){QxWidget.prototype._applySizeVertical.call(this,size);return this._renderHeight();};QxFieldSet.init=function(){var frame=QxFieldSet._h3=document.createElement("div");var legend=document.createElement("div");var legendText=document.createTextNode("-");var content=document.createElement("div");frame.className="QxFieldSetFrame";legend.className="QxFieldSetLegend";content.className="QxFieldSetContent";legend.appendChild(legendText);frame.appendChild(legend);frame.appendChild(content);};QxFieldSet.init();