2150 |
mathias |
1 |
if(!dojo._hasResource["dijit.layout.TabContainer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
|
|
|
2 |
dojo._hasResource["dijit.layout.TabContainer"] = true;
|
|
|
3 |
dojo.provide("dijit.layout.TabContainer");
|
|
|
4 |
|
|
|
5 |
dojo.require("dijit.layout.StackContainer");
|
|
|
6 |
dojo.require("dijit._Templated");
|
|
|
7 |
|
|
|
8 |
dojo.declare("dijit.layout.TabContainer",
|
|
|
9 |
[dijit.layout.StackContainer, dijit._Templated],
|
|
|
10 |
{
|
|
|
11 |
// summary:
|
|
|
12 |
// A Container with Title Tabs, each one pointing at a pane in the container.
|
|
|
13 |
// description:
|
|
|
14 |
// A TabContainer is a container that has multiple panes, but shows only
|
|
|
15 |
// one pane at a time. There are a set of tabs corresponding to each pane,
|
|
|
16 |
// where each tab has the title (aka title) of the pane, and optionally a close button.
|
|
|
17 |
//
|
|
|
18 |
// Publishes topics <widgetId>-addChild, <widgetId>-removeChild, and <widgetId>-selectChild
|
|
|
19 |
// (where <widgetId> is the id of the TabContainer itself.
|
|
|
20 |
//
|
|
|
21 |
// tabPosition: String
|
|
|
22 |
// Defines where tabs go relative to tab content.
|
|
|
23 |
// "top", "bottom", "left-h", "right-h"
|
|
|
24 |
tabPosition: "top",
|
|
|
25 |
|
|
|
26 |
templateString: null, // override setting in StackContainer
|
|
|
27 |
templateString:"<div class=\"dijitTabContainer\">\n\t<div dojoAttachPoint=\"tablistNode\"></div>\n\t<div class=\"dijitTabPaneWrapper\" dojoAttachPoint=\"containerNode\"></div>\n</div>\n",
|
|
|
28 |
|
|
|
29 |
postCreate: function(){
|
|
|
30 |
dijit.layout.TabContainer.superclass.postCreate.apply(this, arguments);
|
|
|
31 |
// create the tab list that will have a tab (a.k.a. tab button) for each tab panel
|
|
|
32 |
this.tablist = new dijit.layout.TabController(
|
|
|
33 |
{
|
|
|
34 |
id: this.id + "_tablist",
|
|
|
35 |
tabPosition: this.tabPosition,
|
|
|
36 |
doLayout: this.doLayout,
|
|
|
37 |
containerId: this.id
|
|
|
38 |
}, this.tablistNode);
|
|
|
39 |
},
|
|
|
40 |
|
|
|
41 |
_setupChild: function(/* Widget */tab){
|
|
|
42 |
dojo.addClass(tab.domNode, "dijitTabPane");
|
|
|
43 |
this.inherited("_setupChild",arguments);
|
|
|
44 |
return tab; // Widget
|
|
|
45 |
},
|
|
|
46 |
|
|
|
47 |
startup: function(){
|
|
|
48 |
if(this._started){ return; }
|
|
|
49 |
|
|
|
50 |
// wire up the tablist and its tabs
|
|
|
51 |
this.tablist.startup();
|
|
|
52 |
this.inherited("startup",arguments);
|
|
|
53 |
|
|
|
54 |
if(dojo.isSafari){
|
|
|
55 |
// sometimes safari 3.0.3 miscalculates the height of the tab labels, see #4058
|
|
|
56 |
setTimeout(dojo.hitch(this, "layout"), 0);
|
|
|
57 |
}
|
|
|
58 |
},
|
|
|
59 |
|
|
|
60 |
layout: function(){
|
|
|
61 |
// Summary: Configure the content pane to take up all the space except for where the tabs are
|
|
|
62 |
if(!this.doLayout){ return; }
|
|
|
63 |
|
|
|
64 |
// position and size the titles and the container node
|
|
|
65 |
var titleAlign=this.tabPosition.replace(/-h/,"");
|
|
|
66 |
var children = [
|
|
|
67 |
{domNode: this.tablist.domNode, layoutAlign: titleAlign},
|
|
|
68 |
{domNode: this.containerNode, layoutAlign: "client"}
|
|
|
69 |
];
|
|
|
70 |
dijit.layout.layoutChildren(this.domNode, this._contentBox, children);
|
|
|
71 |
|
|
|
72 |
// Compute size to make each of my children.
|
|
|
73 |
// children[1] is the margin-box size of this.containerNode, set by layoutChildren() call above
|
|
|
74 |
this._containerContentBox = dijit.layout.marginBox2contentBox(this.containerNode, children[1]);
|
|
|
75 |
|
|
|
76 |
if(this.selectedChildWidget){
|
|
|
77 |
this._showChild(this.selectedChildWidget);
|
|
|
78 |
if(this.doLayout && this.selectedChildWidget.resize){
|
|
|
79 |
this.selectedChildWidget.resize(this._containerContentBox);
|
|
|
80 |
}
|
|
|
81 |
}
|
|
|
82 |
},
|
|
|
83 |
|
|
|
84 |
destroy: function(){
|
|
|
85 |
this.tablist.destroy();
|
|
|
86 |
this.inherited("destroy",arguments);
|
|
|
87 |
}
|
|
|
88 |
});
|
|
|
89 |
|
|
|
90 |
//TODO: make private?
|
|
|
91 |
dojo.declare("dijit.layout.TabController",
|
|
|
92 |
dijit.layout.StackController,
|
|
|
93 |
{
|
|
|
94 |
// summary:
|
|
|
95 |
// Set of tabs (the things with titles and a close button, that you click to show a tab panel).
|
|
|
96 |
// description:
|
|
|
97 |
// Lets the user select the currently shown pane in a TabContainer or StackContainer.
|
|
|
98 |
// TabController also monitors the TabContainer, and whenever a pane is
|
|
|
99 |
// added or deleted updates itself accordingly.
|
|
|
100 |
|
|
|
101 |
templateString: "<div wairole='tablist' dojoAttachEvent='onkeypress:onkeypress'></div>",
|
|
|
102 |
|
|
|
103 |
// tabPosition: String
|
|
|
104 |
// Defines where tabs go relative to the content.
|
|
|
105 |
// "top", "bottom", "left-h", "right-h"
|
|
|
106 |
tabPosition: "top",
|
|
|
107 |
|
|
|
108 |
// doLayout: Boolean
|
|
|
109 |
// TODOC: deprecate doLayout? not sure.
|
|
|
110 |
doLayout: true,
|
|
|
111 |
|
|
|
112 |
// buttonWidget: String
|
|
|
113 |
// the name of the tab widget to create to correspond to each page
|
|
|
114 |
buttonWidget: "dijit.layout._TabButton",
|
|
|
115 |
|
|
|
116 |
postMixInProperties: function(){
|
|
|
117 |
this["class"] = "dijitTabLabels-" + this.tabPosition + (this.doLayout ? "" : " dijitTabNoLayout");
|
|
|
118 |
this.inherited("postMixInProperties",arguments);
|
|
|
119 |
}
|
|
|
120 |
});
|
|
|
121 |
|
|
|
122 |
dojo.declare("dijit.layout._TabButton",
|
|
|
123 |
dijit.layout._StackButton,
|
|
|
124 |
{
|
|
|
125 |
// summary:
|
|
|
126 |
// A tab (the thing you click to select a pane).
|
|
|
127 |
// description:
|
|
|
128 |
// Contains the title of the pane, and optionally a close-button to destroy the pane.
|
|
|
129 |
// This is an internal widget and should not be instantiated directly.
|
|
|
130 |
|
|
|
131 |
baseClass: "dijitTab",
|
|
|
132 |
|
|
|
133 |
templateString:"<div dojoAttachEvent='onclick:onClick,onmouseenter:_onMouse,onmouseleave:_onMouse'>\n <div class='dijitTabInnerDiv' dojoAttachPoint='innerDiv'>\n <span dojoAttachPoint='containerNode,focusNode'>${!label}</span>\n <span dojoAttachPoint='closeButtonNode' class='closeImage' dojoAttachEvent='onmouseenter:_onMouse, onmouseleave:_onMouse, onclick:onClickCloseButton' stateModifier='CloseButton'>\n <span dojoAttachPoint='closeText' class='closeText'>x</span>\n </span>\n </div>\n</div>\n",
|
|
|
134 |
|
|
|
135 |
postCreate: function(){
|
|
|
136 |
if(this.closeButton){
|
|
|
137 |
dojo.addClass(this.innerDiv, "dijitClosable");
|
|
|
138 |
} else {
|
|
|
139 |
this.closeButtonNode.style.display="none";
|
|
|
140 |
}
|
|
|
141 |
this.inherited("postCreate",arguments);
|
|
|
142 |
dojo.setSelectable(this.containerNode, false);
|
|
|
143 |
}
|
|
|
144 |
});
|
|
|
145 |
|
|
|
146 |
}
|