summaryrefslogtreecommitdiff
path: root/swat2/style/qooxdoo/widgets/widgets/QxTabBar.js
blob: 4370d8c7f107cba29b9a873e8ee537d3605ae4e4 (plain)
1
2
/* Copyright (c): 2002-2005 (Germany): United Internet, 1&1, GMX, Schlund+Partner, Alturo */
function QxTabBar(){QxWidget.call(this);this.setLeft(0);this.setRight(0);this.setHeight("auto");this._updatePlacement();this._j3();this._manager=new QxRadioButtonManager();this._manager.addEventListener("changeSelected",this._onchange,this);};QxTabBar.extend(QxWidget,"QxTabBar");QxTabBar.addProperty({name:"placeOnTop",type:Boolean,defaultValue:true});QxTabBar.addProperty({name:"alignTabsToLeft",type:Boolean,defaultValue:true});QxTabBar.addProperty({name:"activeTabHeightDiff",type:Number,defaultValue:2});QxTabBar.addProperty({name:"activeTabOverlap",type:Number,defaultValue:2});proto.getManager=function(){return this._manager;};proto._modifyPlaceOnTop=function(_b1,_b2,_b3,_b4){this.getParent().setPlaceBarOnTop(_b1,_b4);this._updatePlacement();return true;};proto._modifyAlignTabsToLeft=function(_b1,_b2,_b3,_b4){this._j3();return true;};proto._onchange=function(e){this._layoutInternalWidgets("change-active-tab");};proto._updatePlacement=function(){if(this.getPlaceOnTop()){this.setBottom(null);this.setTop(0);}else {this.setTop(null);this.setBottom(0);};this._j3();};proto._j3=function(){this.setState((this.getPlaceOnTop()?"top":"bottom")+(this.getAlignTabsToLeft()?"Left":"Right"));};proto._layoutInternalWidgets=function(_e5){this._d1(_e5);this._d2(_e5);};proto._d1=function(_e5){if(!isValidString(_e5)||_e5=="position"){return;};var vPane=this.getParent().getPane();if(!this.isCreated()||!vPane.isCreated()){return true;};if(this.getAlignTabsToLeft()){var vReset="setRight";var vSet="setLeft";var vLastLeft=vPane.getComputedBorderLeft();}else {var vReset="setLeft";var vSet="setRight";var vLastLeft=vPane.getComputedBorderRight();};var ch=this.getChildren();var chl=ch.length;var chc;var vPref;var vLeft;var vIndex;for(var i=0;i<chl;i++){chc=ch[i];if(chc instanceof QxTab&&chc.getVisible()){vPref=chc.getPreferredWidth();if(vPref==null){return true;};chc[vReset](null);if(chc.getChecked()){vLeft=vLastLeft-this.getActiveTabOverlap();vLastLeft+=vPref-(2*this.getActiveTabOverlap());vIndex=2;}else {vLeft=vLastLeft;vLastLeft+=vPref;vIndex=1;};chc[vSet](vLeft);chc.setZIndex(vIndex);};};};proto._d2=function(_e5){var vPane=this.getParent().getPane();if(!this.isCreated()||!vPane.isCreated()){return true;};var vActiveDiff=this.getActiveTabHeightDiff();var vMax=this._maxHeight;var vActiveMax=this._maxActiveHeight;if(this.getPlaceOnTop()){var vReset="setBottom";var vSet="setTop";var vPaneBorder=vPane.getComputedBorderTop();}else {var vReset="setTop";var vSet="setBottom";var vPaneBorder=vPane.getComputedBorderBottom();};var ch=this.getChildren();var chl=ch.length;var chc;for(var i=0;i<chl;i++){chc=ch[i];if(chc instanceof QxTab&&chc.getVisible()){chc[vReset](null);if(chc.getChecked()){chc[vSet](0);chc.setHeight(vActiveMax);}else {chc[vSet](vActiveDiff);chc.setHeight("auto");chc.setMinHeight(vMax);};};};};proto._onnewchild=function(otherObject){this._d1("append-child");};proto._onremovechild=function(otherObject){this._d1("remove-child");};proto._innerHeightChanged=function(){this._d4Height();this._d2("inner-height");};proto._innerWidthChanged=function(){this._d4Width();this._d1("inner-width");var ch=this._a2;var chl=ch.length;for(var i=0;i<chl;i++){ch[i]._renderHorizontal("parent");};};proto._childOuterWidthChanged=function(vModifiedChild,_e5){return !this._wasVisible?true:this.getWidth()=="auto"?this._setChildrenDependWidth(vModifiedChild,_e5):this._d1(_e5);};proto._childOuterHeightChanged=function(vModifiedChild,_e5){return !this._wasVisible?true:this.getHeight()=="auto"?this._setChildrenDependHeight(vModifiedChild,_e5):this._d2(_e5);};proto._maxHeight=0;proto._maxActiveHeight=0;proto._d5Height=function(_e4,_e5){var vPane=this.getParent().getPane();if(!vPane.isCreated()){return null;};var ch=this.getChildren();var chl=ch.length;var maxHeight=0;for(var i=0;i<chl;i++){maxHeight=Math.max(ch[i].getPreferredHeight(),maxHeight)};this._maxHeight=maxHeight;return this._maxActiveHeight=maxHeight+this.getActiveTabHeightDiff()+(this.getPlaceOnTop()?vPane.getComputedBorderTop():vPane.getComputedBorderBottom());};proto.dispose=function(){if(this.getDisposed()){return;};if(this._manager){this._manager.dispose();this._manager=null;};this._maxHeight=this._maxActiveHeight=null;QxWidget.prototype.dispose.call(this);};