root / trunk / web / dojo / dijit / layout / _LayoutWidget.js
History | View | Annotate | Download (3.28 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._LayoutWidget"]){ |
9 |
dojo._hasResource["dijit.layout._LayoutWidget"]=true; |
10 |
dojo.provide("dijit.layout._LayoutWidget");
|
11 |
dojo.require("dijit._Widget");
|
12 |
dojo.require("dijit._Container");
|
13 |
dojo.require("dijit._Contained");
|
14 |
dojo.declare("dijit.layout._LayoutWidget",[dijit._Widget,dijit._Container,dijit._Contained],{baseClass:"dijitLayoutContainer",isLayoutContainer:true,postCreate:function(){ |
15 |
dojo.addClass(this.domNode,"dijitContainer"); |
16 |
this.inherited(arguments); |
17 |
},startup:function(){ |
18 |
if(this._started){ |
19 |
return;
|
20 |
} |
21 |
this.inherited(arguments); |
22 |
var _1=this.getParent&&this.getParent(); |
23 |
if(!(_1&&_1.isLayoutContainer)){
|
24 |
this.resize();
|
25 |
this.connect(dojo.isIE?this.domNode:dojo.global,"onresize",function(){ |
26 |
this.resize();
|
27 |
}); |
28 |
} |
29 |
},resize:function(_2,_3){ |
30 |
var _4=this.domNode; |
31 |
if(_2){
|
32 |
dojo.marginBox(_4,_2); |
33 |
if(_2.t){
|
34 |
_4.style.top=_2.t+"px";
|
35 |
} |
36 |
if(_2.l){
|
37 |
_4.style.left=_2.l+"px";
|
38 |
} |
39 |
} |
40 |
var mb=_3||{};
|
41 |
dojo.mixin(mb,_2||{}); |
42 |
if(!("h" in mb)||!("w" in mb)){ |
43 |
mb=dojo.mixin(dojo.marginBox(_4),mb); |
44 |
} |
45 |
var cs=dojo.getComputedStyle(_4);
|
46 |
var me=dojo._getMarginExtents(_4,cs);
|
47 |
var be=dojo._getBorderExtents(_4,cs);
|
48 |
var bb=(this._borderBox={w:mb.w-(me.w+be.w),h:mb.h-(me.h+be.h)}); |
49 |
var pe=dojo._getPadExtents(_4,cs);
|
50 |
this._contentBox={l:dojo._toPixelValue(_4,cs.paddingLeft),t:dojo._toPixelValue(_4,cs.paddingTop),w:bb.w-pe.w,h:bb.h-pe.h}; |
51 |
this.layout();
|
52 |
},layout:function(){ |
53 |
},_setupChild:function(_5){ |
54 |
dojo.addClass(_5.domNode,this.baseClass+"-child"); |
55 |
if(_5.baseClass){
|
56 |
dojo.addClass(_5.domNode,this.baseClass+"-"+_5.baseClass); |
57 |
} |
58 |
},addChild:function(_6,_7){ |
59 |
this.inherited(arguments); |
60 |
if(this._started){ |
61 |
this._setupChild(_6);
|
62 |
} |
63 |
},removeChild:function(_8){ |
64 |
dojo.removeClass(_8.domNode,this.baseClass+"-child"); |
65 |
if(_8.baseClass){
|
66 |
dojo.removeClass(_8.domNode,this.baseClass+"-"+_8.baseClass); |
67 |
} |
68 |
this.inherited(arguments); |
69 |
}}); |
70 |
dijit.layout.marginBox2contentBox=function(_9,mb){ |
71 |
var cs=dojo.getComputedStyle(_9);
|
72 |
var me=dojo._getMarginExtents(_9,cs);
|
73 |
var pb=dojo._getPadBorderExtents(_9,cs);
|
74 |
return {l:dojo._toPixelValue(_9,cs.paddingLeft),t:dojo._toPixelValue(_9,cs.paddingTop),w:mb.w-(me.w+pb.w),h:mb.h-(me.h+pb.h)}; |
75 |
}; |
76 |
(function(){
|
77 |
var _a=function(_b){ |
78 |
return _b.substring(0,1).toUpperCase()+_b.substring(1); |
79 |
}; |
80 |
var _c=function(_d,_e){ |
81 |
_d.resize?_d.resize(_e):dojo.marginBox(_d.domNode,_e); |
82 |
dojo.mixin(_d,dojo.marginBox(_d.domNode)); |
83 |
dojo.mixin(_d,_e); |
84 |
}; |
85 |
dijit.layout.layoutChildren=function(_f,dim,_10){ |
86 |
dim=dojo.mixin({},dim); |
87 |
dojo.addClass(_f,"dijitLayoutContainer");
|
88 |
_10=dojo.filter(_10,function(_11){
|
89 |
return _11.layoutAlign!="client"; |
90 |
}).concat(dojo.filter(_10,function(_12){
|
91 |
return _12.layoutAlign=="client"; |
92 |
})); |
93 |
dojo.forEach(_10,function(_13){
|
94 |
var elm=_13.domNode,pos=_13.layoutAlign;
|
95 |
var _14=elm.style;
|
96 |
_14.left=dim.l+"px";
|
97 |
_14.top=dim.t+"px";
|
98 |
_14.bottom=_14.right="auto";
|
99 |
dojo.addClass(elm,"dijitAlign"+_a(pos));
|
100 |
if(pos=="top"||pos=="bottom"){ |
101 |
_c(_13,{w:dim.w});
|
102 |
dim.h-=_13.h; |
103 |
if(pos=="top"){ |
104 |
dim.t+=_13.h; |
105 |
}else{
|
106 |
_14.top=dim.t+dim.h+"px";
|
107 |
} |
108 |
}else{
|
109 |
if(pos=="left"||pos=="right"){ |
110 |
_c(_13,{h:dim.h});
|
111 |
dim.w-=_13.w; |
112 |
if(pos=="left"){ |
113 |
dim.l+=_13.w; |
114 |
}else{
|
115 |
_14.left=dim.l+dim.w+"px";
|
116 |
} |
117 |
}else{
|
118 |
if(pos=="client"){ |
119 |
_c(_13,dim); |
120 |
} |
121 |
} |
122 |
} |
123 |
}); |
124 |
}; |
125 |
})(); |
126 |
} |