root / trunk / web / dojo / dijit / layout / StackContainer.js @ 9
History | View | Annotate | Download (4.08 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dijit.layout.StackContainer"]){ |
9 |
dojo._hasResource["dijit.layout.StackContainer"]=true; |
10 |
dojo.provide("dijit.layout.StackContainer");
|
11 |
dojo.require("dijit._Templated");
|
12 |
dojo.require("dijit.layout._LayoutWidget");
|
13 |
dojo.requireLocalization("dijit","common",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); |
14 |
dojo.require("dojo.cookie");
|
15 |
dojo.declare("dijit.layout.StackContainer",dijit.layout._LayoutWidget,{doLayout:true,persist:false,baseClass:"dijitStackContainer",postCreate:function(){ |
16 |
this.inherited(arguments); |
17 |
dojo.addClass(this.domNode,"dijitLayoutContainer"); |
18 |
dijit.setWaiRole(this.containerNode,"tabpanel"); |
19 |
this.connect(this.domNode,"onkeypress",this._onKeyPress); |
20 |
},startup:function(){ |
21 |
if(this._started){ |
22 |
return;
|
23 |
} |
24 |
var _1=this.getChildren(); |
25 |
dojo.forEach(_1,this._setupChild,this); |
26 |
if(this.persist){ |
27 |
this.selectedChildWidget=dijit.byId(dojo.cookie(this.id+"_selectedChild")); |
28 |
}else{
|
29 |
dojo.some(_1,function(_2){
|
30 |
if(_2.selected){
|
31 |
this.selectedChildWidget=_2;
|
32 |
} |
33 |
return _2.selected;
|
34 |
},this);
|
35 |
} |
36 |
var _3=this.selectedChildWidget; |
37 |
if(!_3&&_1[0]){ |
38 |
_3=this.selectedChildWidget=_1[0]; |
39 |
_3.selected=true;
|
40 |
} |
41 |
dojo.publish(this.id+"-startup",[{children:_1,selected:_3}]); |
42 |
this.inherited(arguments); |
43 |
},resize:function(){ |
44 |
var _4=this.selectedChildWidget; |
45 |
if(_4&&!this._hasBeenShown){ |
46 |
this._hasBeenShown=true; |
47 |
this._showChild(_4);
|
48 |
} |
49 |
this.inherited(arguments); |
50 |
},_setupChild:function(_5){ |
51 |
this.inherited(arguments); |
52 |
dojo.removeClass(_5.domNode,"dijitVisible");
|
53 |
dojo.addClass(_5.domNode,"dijitHidden");
|
54 |
_5.domNode.title="";
|
55 |
},addChild:function(_6,_7){ |
56 |
this.inherited(arguments); |
57 |
if(this._started){ |
58 |
dojo.publish(this.id+"-addChild",[_6,_7]); |
59 |
this.layout();
|
60 |
if(!this.selectedChildWidget){ |
61 |
this.selectChild(_6);
|
62 |
} |
63 |
} |
64 |
},removeChild:function(_8){ |
65 |
this.inherited(arguments); |
66 |
if(this._started){ |
67 |
dojo.publish(this.id+"-removeChild",[_8]); |
68 |
} |
69 |
if(this._beingDestroyed){ |
70 |
return;
|
71 |
} |
72 |
if(this.selectedChildWidget===_8){ |
73 |
this.selectedChildWidget=undefined; |
74 |
if(this._started){ |
75 |
var _9=this.getChildren(); |
76 |
if(_9.length){
|
77 |
this.selectChild(_9[0]); |
78 |
} |
79 |
} |
80 |
} |
81 |
if(this._started){ |
82 |
this.layout();
|
83 |
} |
84 |
},selectChild:function(_a,_b){ |
85 |
_a=dijit.byId(_a); |
86 |
if(this.selectedChildWidget!=_a){ |
87 |
this._transition(_a,this.selectedChildWidget,_b); |
88 |
this.selectedChildWidget=_a;
|
89 |
dojo.publish(this.id+"-selectChild",[_a]); |
90 |
if(this.persist){ |
91 |
dojo.cookie(this.id+"_selectedChild",this.selectedChildWidget.id); |
92 |
} |
93 |
} |
94 |
},_transition:function(_c,_d){ |
95 |
if(_d){
|
96 |
this._hideChild(_d);
|
97 |
} |
98 |
this._showChild(_c);
|
99 |
if(_c.resize){
|
100 |
if(this.doLayout){ |
101 |
_c.resize(this._containerContentBox||this._contentBox); |
102 |
}else{
|
103 |
_c.resize(); |
104 |
} |
105 |
} |
106 |
},_adjacent:function(_e){ |
107 |
var _f=this.getChildren(); |
108 |
var _10=dojo.indexOf(_f,this.selectedChildWidget); |
109 |
_10+=_e?1:_f.length-1; |
110 |
return _f[_10%_f.length];
|
111 |
},forward:function(){ |
112 |
this.selectChild(this._adjacent(true),true); |
113 |
},back:function(){ |
114 |
this.selectChild(this._adjacent(false),true); |
115 |
},_onKeyPress:function(e){ |
116 |
dojo.publish(this.id+"-containerKeyPress",[{e:e,page:this}]); |
117 |
},layout:function(){ |
118 |
if(this.doLayout&&this.selectedChildWidget&&this.selectedChildWidget.resize){ |
119 |
this.selectedChildWidget.resize(this._containerContentBox||this._contentBox); |
120 |
} |
121 |
},_showChild:function(_11){ |
122 |
var _12=this.getChildren(); |
123 |
_11.isFirstChild=(_11==_12[0]);
|
124 |
_11.isLastChild=(_11==_12[_12.length-1]);
|
125 |
_11.selected=true;
|
126 |
dojo.removeClass(_11.domNode,"dijitHidden");
|
127 |
dojo.addClass(_11.domNode,"dijitVisible");
|
128 |
_11._onShow(); |
129 |
},_hideChild:function(_13){ |
130 |
_13.selected=false;
|
131 |
dojo.removeClass(_13.domNode,"dijitVisible");
|
132 |
dojo.addClass(_13.domNode,"dijitHidden");
|
133 |
_13.onHide(); |
134 |
},closeChild:function(_14){ |
135 |
var _15=_14.onClose(this,_14); |
136 |
if(_15){
|
137 |
this.removeChild(_14);
|
138 |
_14.destroyRecursive(); |
139 |
} |
140 |
},destroyDescendants:function(_16){ |
141 |
dojo.forEach(this.getChildren(),function(_17){ |
142 |
this.removeChild(_17);
|
143 |
_17.destroyRecursive(_16); |
144 |
},this);
|
145 |
}}); |
146 |
dojo.require("dijit.layout.StackController");
|
147 |
dojo.extend(dijit._Widget,{selected:false,closable:false,iconClass:"",showTitle:true}); |
148 |
} |