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
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();
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
}};
20 c
.pos
.x
+=_6
.charAt(1)=="L"?_4
.x
:-_4
.x
;
21 c
.pos
.y
+=_6
.charAt(0)=="T"?_4
.y
:-_4
.y
;
25 return dijit
._place(_1
,_5
);
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
);
33 dojo
.some(_8
,function(_c
){
37 _9(_7
,_c
.aroundCorner
,_d
);
41 var _11
=_f
.visibility
;
42 _f
.visibility
="hidden";
44 var mb
=dojo
.marginBox(_7
);
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
};
53 _7
.style
.left
=_b
.x
+"px";
54 _7
.style
.top
=_b
.y
+"px";
56 _9(_7
,_b
.aroundCorner
,_b
.corner
);
60 dijit
.placeOnScreenAroundNode=function(_19
,_1a
,_1b
,_1c
){
62 var _1d
=_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
);
68 dijit
.placeOnScreenAroundRectangle=function(_1f
,_20
,_21
,_22
){
69 return dijit
._placeOnScreenAroundRect(_1f
,_20
.x
,_20
.y
,_20
.width
,_20
.height
,_21
,_22
);
71 dijit
._placeOnScreenAroundRect=function(_23
,x
,y
,_24
,_25
,_26
,_27
){
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
)}});
76 return dijit
._place(_23
,_28
,_27
);
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
);
88 dijit
.getPopupAroundAlignment=function(_2e
,_2f
){
90 dojo
.forEach(_2e
,function(pos
){
93 _30
[_2f
?"BR":"BL"]=_2f
?"BL":"BR";
96 _30
[_2f
?"BL":"BR"]=_2f
?"BR":"BL";
99 _30
[_2f
?"BL":"BR"]=_2f
?"TL":"TR";
100 _30
[_2f
?"BR":"BL"]=_2f
?"TR":"TL";
104 _30
[_2f
?"TL":"TR"]=_2f
?"BL":"BR";
105 _30
[_2f
?"TR":"TL"]=_2f
?"BR":"BL";