]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/layout/_TabContainerBase.js.uncompressed.js
upgrade dojo to 1.8.3 (refs #570)
[tt-rss.git] / lib / dijit / layout / _TabContainerBase.js.uncompressed.js
1 require({cache:{
2 'url:dijit/layout/templates/TabContainer.html':"<div class=\"dijitTabContainer\">\n\t<div class=\"dijitTabListWrapper\" data-dojo-attach-point=\"tablistNode\"></div>\n\t<div data-dojo-attach-point=\"tablistSpacer\" class=\"dijitTabSpacer ${baseClass}-spacer\"></div>\n\t<div class=\"dijitTabPaneWrapper ${baseClass}-container\" data-dojo-attach-point=\"containerNode\"></div>\n</div>\n"}});
3 define("dijit/layout/_TabContainerBase", [
4 "dojo/text!./templates/TabContainer.html",
5 "./StackContainer",
6 "./utils", // marginBox2contextBox, layoutChildren
7 "../_TemplatedMixin",
8 "dojo/_base/declare", // declare
9 "dojo/dom-class", // domClass.add
10 "dojo/dom-geometry", // domGeometry.contentBox
11 "dojo/dom-style" // domStyle.style
12 ], function(template, StackContainer, layoutUtils, _TemplatedMixin, declare, domClass, domGeometry, domStyle){
13
14 // module:
15 // dijit/layout/_TabContainerBase
16
17
18 return declare("dijit.layout._TabContainerBase", [StackContainer, _TemplatedMixin], {
19 // summary:
20 // Abstract base class for TabContainer. Must define _makeController() to instantiate
21 // and return the widget that displays the tab labels
22 // description:
23 // A TabContainer is a container that has multiple panes, but shows only
24 // one pane at a time. There are a set of tabs corresponding to each pane,
25 // where each tab has the name (aka title) of the pane, and optionally a close button.
26
27 // tabPosition: String
28 // Defines where tabs go relative to tab content.
29 // "top", "bottom", "left-h", "right-h"
30 tabPosition: "top",
31
32 baseClass: "dijitTabContainer",
33
34 // tabStrip: [const] Boolean
35 // Defines whether the tablist gets an extra class for layouting, putting a border/shading
36 // around the set of tabs. Not supported by claro theme.
37 tabStrip: false,
38
39 // nested: [const] Boolean
40 // If true, use styling for a TabContainer nested inside another TabContainer.
41 // For tundra etc., makes tabs look like links, and hides the outer
42 // border since the outer TabContainer already has a border.
43 nested: false,
44
45 templateString: template,
46
47 postMixInProperties: function(){
48 // set class name according to tab position, ex: dijitTabContainerTop
49 this.baseClass += this.tabPosition.charAt(0).toUpperCase() + this.tabPosition.substr(1).replace(/-.*/, "");
50
51 this.srcNodeRef && domStyle.set(this.srcNodeRef, "visibility", "hidden");
52
53 this.inherited(arguments);
54 },
55
56 buildRendering: function(){
57 this.inherited(arguments);
58
59 // Create the tab list that will have a tab (a.k.a. tab button) for each tab panel
60 this.tablist = this._makeController(this.tablistNode);
61
62 if(!this.doLayout){ domClass.add(this.domNode, "dijitTabContainerNoLayout"); }
63
64 if(this.nested){
65 /* workaround IE's lack of support for "a > b" selectors by
66 * tagging each node in the template.
67 */
68 domClass.add(this.domNode, "dijitTabContainerNested");
69 domClass.add(this.tablist.containerNode, "dijitTabContainerTabListNested");
70 domClass.add(this.tablistSpacer, "dijitTabContainerSpacerNested");
71 domClass.add(this.containerNode, "dijitTabPaneWrapperNested");
72 }else{
73 domClass.add(this.domNode, "tabStrip-" + (this.tabStrip ? "enabled" : "disabled"));
74 }
75 },
76
77 _setupChild: function(/*dijit/_WidgetBase*/ tab){
78 // Overrides StackContainer._setupChild().
79 domClass.add(tab.domNode, "dijitTabPane");
80 this.inherited(arguments);
81 },
82
83 startup: function(){
84 if(this._started){ return; }
85
86 // wire up the tablist and its tabs
87 this.tablist.startup();
88
89 this.inherited(arguments);
90 },
91
92 layout: function(){
93 // Overrides StackContainer.layout().
94 // Configure the content pane to take up all the space except for where the tabs are
95
96 if(!this._contentBox || typeof(this._contentBox.l) == "undefined"){return;}
97
98 var sc = this.selectedChildWidget;
99
100 if(this.doLayout){
101 // position and size the titles and the container node
102 var titleAlign = this.tabPosition.replace(/-h/, "");
103 this.tablist.layoutAlign = titleAlign;
104 var children = [this.tablist, {
105 domNode: this.tablistSpacer,
106 layoutAlign: titleAlign
107 }, {
108 domNode: this.containerNode,
109 layoutAlign: "client"
110 }];
111 layoutUtils.layoutChildren(this.domNode, this._contentBox, children);
112
113 // Compute size to make each of my children.
114 // children[2] is the margin-box size of this.containerNode, set by layoutChildren() call above
115 this._containerContentBox = layoutUtils.marginBox2contentBox(this.containerNode, children[2]);
116
117 if(sc && sc.resize){
118 sc.resize(this._containerContentBox);
119 }
120 }else{
121 // just layout the tab controller, so it can position left/right buttons etc.
122 if(this.tablist.resize){
123 //make the tabs zero width so that they don't interfere with width calc, then reset
124 var s = this.tablist.domNode.style;
125 s.width="0";
126 var width = domGeometry.getContentBox(this.domNode).w;
127 s.width="";
128 this.tablist.resize({w: width});
129 }
130
131 // and call resize() on the selected pane just to tell it that it's been made visible
132 if(sc && sc.resize){
133 sc.resize();
134 }
135 }
136 },
137
138 destroy: function(){
139 if(this.tablist){
140 this.tablist.destroy();
141 }
142 this.inherited(arguments);
143 }
144 });
145
146 });