| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/dom-class", |
| 4 |
"dojo/dom-geometry", |
| 5 |
"dojo/dom-style", |
| 6 |
"./StackContainer", |
| 7 |
"./utils", |
| 8 |
"../_TemplatedMixin", |
| 9 |
"dojo/text!./templates/TabContainer.html" |
| 10 |
], function(declare, domClass, domGeometry, domStyle, StackContainer, layoutUtils, _TemplatedMixin, template){ |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
return declare("dijit.layout._TabContainerBase", [StackContainer, _TemplatedMixin], { |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
tabPosition: "top", |
| 28 |
|
| 29 |
baseClass: "dijitTabContainer", |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
tabStrip: false, |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
nested: false, |
| 41 |
|
| 42 |
templateString: template, |
| 43 |
|
| 44 |
postMixInProperties: function(){ |
| 45 |
|
| 46 |
this.baseClass += this.tabPosition.charAt(0).toUpperCase() + this.tabPosition.substr(1).replace(/-.*/, ""); |
| 47 |
|
| 48 |
this.srcNodeRef && domStyle.set(this.srcNodeRef, "visibility", "hidden"); |
| 49 |
|
| 50 |
this.inherited(arguments); |
| 51 |
}, |
| 52 |
|
| 53 |
buildRendering: function(){ |
| 54 |
this.inherited(arguments); |
| 55 |
|
| 56 |
|
| 57 |
this.tablist = this._makeController(this.tablistNode); |
| 58 |
|
| 59 |
if(!this.doLayout){ |
| 60 |
domClass.add(this.domNode, "dijitTabContainerNoLayout"); |
| 61 |
} |
| 62 |
|
| 63 |
if(this.nested){ |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
domClass.add(this.domNode, "dijitTabContainerNested"); |
| 68 |
domClass.add(this.tablist.containerNode, "dijitTabContainerTabListNested"); |
| 69 |
domClass.add(this.tablistSpacer, "dijitTabContainerSpacerNested"); |
| 70 |
domClass.add(this.containerNode, "dijitTabPaneWrapperNested"); |
| 71 |
}else{ |
| 72 |
domClass.add(this.domNode, "tabStrip-" + (this.tabStrip ? "enabled" : "disabled")); |
| 73 |
} |
| 74 |
}, |
| 75 |
|
| 76 |
_setupChild: function( tab){ |
| 77 |
|
| 78 |
domClass.add(tab.domNode, "dijitTabPane"); |
| 79 |
this.inherited(arguments); |
| 80 |
}, |
| 81 |
|
| 82 |
removeChild: function( child) { |
| 83 |
|
| 84 |
domClass.remove(child.domNode, "dijitTabPane"); |
| 85 |
this.inherited(arguments); |
| 86 |
}, |
| 87 |
|
| 88 |
startup: function(){ |
| 89 |
if(this._started){ |
| 90 |
return; |
| 91 |
} |
| 92 |
|
| 93 |
|
| 94 |
this.tablist.startup(); |
| 95 |
|
| 96 |
this.inherited(arguments); |
| 97 |
}, |
| 98 |
|
| 99 |
layout: function(){ |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
if(!this._contentBox || typeof(this._contentBox.l) == "undefined"){ |
| 104 |
return; |
| 105 |
} |
| 106 |
|
| 107 |
var sc = this.selectedChildWidget; |
| 108 |
|
| 109 |
if(this.doLayout){ |
| 110 |
|
| 111 |
var titleAlign = this.tabPosition.replace(/-h/, ""); |
| 112 |
this.tablist.region = titleAlign; |
| 113 |
var children = [this.tablist, { |
| 114 |
domNode: this.tablistSpacer, |
| 115 |
region: titleAlign |
| 116 |
}, { |
| 117 |
domNode: this.containerNode, |
| 118 |
region: "center" |
| 119 |
}]; |
| 120 |
layoutUtils.layoutChildren(this.domNode, this._contentBox, children); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
this._containerContentBox = layoutUtils.marginBox2contentBox(this.containerNode, children[2]); |
| 125 |
|
| 126 |
if(sc && sc.resize){ |
| 127 |
sc.resize(this._containerContentBox); |
| 128 |
} |
| 129 |
}else{ |
| 130 |
|
| 131 |
if(this.tablist.resize){ |
| 132 |
|
| 133 |
var s = this.tablist.domNode.style; |
| 134 |
s.width = "0"; |
| 135 |
var width = domGeometry.getContentBox(this.domNode).w; |
| 136 |
s.width = ""; |
| 137 |
this.tablist.resize({w: width}); |
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
if(sc && sc.resize){ |
| 142 |
sc.resize(); |
| 143 |
} |
| 144 |
} |
| 145 |
}, |
| 146 |
|
| 147 |
destroy: function(preserveDom){ |
| 148 |
if(this.tablist){ |
| 149 |
this.tablist.destroy(preserveDom); |
| 150 |
} |
| 151 |
this.inherited(arguments); |
| 152 |
} |
| 153 |
}); |
| 154 |
}); |