root / trunk / web / dojo / dijit / _base / place.js @ 13
History | View | Annotate | Download (3.23 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._base.place"]){ |
9 |
dojo._hasResource["dijit._base.place"]=true; |
10 |
dojo.provide("dijit._base.place");
|
11 |
dojo.require("dojo.window");
|
12 |
dojo.require("dojo.AdapterRegistry");
|
13 |
dijit.getViewport=function(){ |
14 |
return dojo.window.getBox();
|
15 |
}; |
16 |
dijit.placeOnScreen=function(_1,_2,_3,_4){ |
17 |
var _5=dojo.map(_3,function(_6){ |
18 |
var c={corner:_6,pos:{x:_2.x,y:_2.y}}; |
19 |
if(_4){
|
20 |
c.pos.x+=_6.charAt(1)=="L"?_4.x:-_4.x; |
21 |
c.pos.y+=_6.charAt(0)=="T"?_4.y:-_4.y; |
22 |
} |
23 |
return c;
|
24 |
}); |
25 |
return dijit._place(_1,_5);
|
26 |
}; |
27 |
dijit._place=function(_7,_8,_9){ |
28 |
var _a=dojo.window.getBox();
|
29 |
if(!_7.parentNode||String(_7.parentNode.tagName).toLowerCase()!="body"){ |
30 |
dojo.body().appendChild(_7); |
31 |
} |
32 |
var _b=null; |
33 |
dojo.some(_8,function(_c){
|
34 |
var _d=_c.corner;
|
35 |
var _e=_c.pos;
|
36 |
if(_9){
|
37 |
_9(_7,_c.aroundCorner,_d); |
38 |
} |
39 |
var _f=_7.style;
|
40 |
var _10=_f.display;
|
41 |
var _11=_f.visibility;
|
42 |
_f.visibility="hidden";
|
43 |
_f.display="";
|
44 |
var mb=dojo.marginBox(_7);
|
45 |
_f.display=_10; |
46 |
_f.visibility=_11; |
47 |
var _12=Math.max(_a.l,_d.charAt(1)=="L"?_e.x:(_e.x-mb.w)),_13=Math.max(_a.t,_d.charAt(0)=="T"?_e.y:(_e.y-mb.h)),_14=Math.min(_a.l+_a.w,_d.charAt(1)=="L"?(_12+mb.w):_e.x),_15=Math.min(_a.t+_a.h,_d.charAt(0)=="T"?(_13+mb.h):_e.y),_16=_14-_12,_17=_15-_13,_18=(mb.w-_16)+(mb.h-_17); |
48 |
if(_b==null||_18<_b.overflow){ |
49 |
_b={corner:_d,aroundCorner:_c.aroundCorner,x:_12,y:_13,w:_16,h:_17,overflow:_18}; |
50 |
} |
51 |
return !_18;
|
52 |
}); |
53 |
_7.style.left=_b.x+"px";
|
54 |
_7.style.top=_b.y+"px";
|
55 |
if(_b.overflow&&_9){
|
56 |
_9(_7,_b.aroundCorner,_b.corner); |
57 |
} |
58 |
return _b;
|
59 |
}; |
60 |
dijit.placeOnScreenAroundNode=function(_19,_1a,_1b,_1c){ |
61 |
_1a=dojo.byId(_1a); |
62 |
var _1d=_1a.style.display;
|
63 |
_1a.style.display="";
|
64 |
var _1e=dojo.position(_1a,true); |
65 |
_1a.style.display=_1d; |
66 |
return dijit._placeOnScreenAroundRect(_19,_1e.x,_1e.y,_1e.w,_1e.h,_1b,_1c);
|
67 |
}; |
68 |
dijit.placeOnScreenAroundRectangle=function(_1f,_20,_21,_22){ |
69 |
return dijit._placeOnScreenAroundRect(_1f,_20.x,_20.y,_20.width,_20.height,_21,_22);
|
70 |
}; |
71 |
dijit._placeOnScreenAroundRect=function(_23,x,y,_24,_25,_26,_27){ |
72 |
var _28=[];
|
73 |
for(var _29 in _26){ |
74 |
_28.push({aroundCorner:_29,corner:_26[_29],pos:{x:x+(_29.charAt(1)=="L"?0:_24),y:y+(_29.charAt(0)=="T"?0:_25)}}); |
75 |
} |
76 |
return dijit._place(_23,_28,_27);
|
77 |
}; |
78 |
dijit.placementRegistry=new dojo.AdapterRegistry();
|
79 |
dijit.placementRegistry.register("node",function(n,x){ |
80 |
return typeof x=="object"&&typeof x.offsetWidth!="undefined"&&typeof x.offsetHeight!="undefined"; |
81 |
},dijit.placeOnScreenAroundNode); |
82 |
dijit.placementRegistry.register("rect",function(n,x){ |
83 |
return typeof x=="object"&&"x" in x&&"y" in x&&"width" in x&&"height" in x; |
84 |
},dijit.placeOnScreenAroundRectangle); |
85 |
dijit.placeOnScreenAroundElement=function(_2a,_2b,_2c,_2d){ |
86 |
return dijit.placementRegistry.match.apply(dijit.placementRegistry,arguments); |
87 |
}; |
88 |
dijit.getPopupAroundAlignment=function(_2e,_2f){ |
89 |
var _30={};
|
90 |
dojo.forEach(_2e,function(pos){
|
91 |
switch(pos){
|
92 |
case "after": |
93 |
_30[_2f?"BR":"BL"]=_2f?"BL":"BR"; |
94 |
break;
|
95 |
case "before": |
96 |
_30[_2f?"BL":"BR"]=_2f?"BR":"BL"; |
97 |
break;
|
98 |
case "below": |
99 |
_30[_2f?"BL":"BR"]=_2f?"TL":"TR"; |
100 |
_30[_2f?"BR":"BL"]=_2f?"TR":"TL"; |
101 |
break;
|
102 |
case "above": |
103 |
default:
|
104 |
_30[_2f?"TL":"TR"]=_2f?"BL":"BR"; |
105 |
_30[_2f?"TR":"TL"]=_2f?"BR":"BL"; |
106 |
break;
|
107 |
} |
108 |
}); |
109 |
return _30;
|
110 |
}; |
111 |
} |