1 define("dijit/_base/place", [
2 "dojo/_base/array", // array.forEach
3 "dojo/_base/lang", // lang.isArray
4 "dojo/window", // windowUtils.getBox
6 ".." // export to dijit namespace
7 ], function(array
, lang
, windowUtils
, place
, dijit
){
12 // Back compatibility module, new code should use dijit/place directly instead of using this module.
14 dijit
.getViewport = function(){
16 // Deprecated method to return the dimensions and scroll position of the viewable area of a browser window.
17 // New code should use windowUtils.getBox()
19 return windowUtils
.getBox();
23 dijit.placeOnScreen = function(node, pos, corners, padding){
25 // Positions one of the node's corners at specified position
26 // such that node is fully visible in viewport.
27 // Deprecated, new code should use dijit.place.at() instead.
30 dijit
.placeOnScreen
= place
.at
;
33 dijit.placeOnScreenAroundElement = function(node, aroundElement, aroundCorners, layoutNode){
35 // Like dijit.placeOnScreenAroundNode(), except it accepts an arbitrary object
36 // for the "around" argument and finds a proper processor to place a node.
37 // Deprecated, new code should use dijit.place.around() instead.
40 dijit
.placeOnScreenAroundElement = function(node
, aroundNode
, aroundCorners
, layoutNode
){
41 // Convert old style {"BL": "TL", "BR": "TR"} type argument
42 // to style needed by dijit.place code:
44 // {aroundCorner: "BL", corner: "TL" },
45 // {aroundCorner: "BR", corner: "TR" }
48 if(lang
.isArray(aroundCorners
)){
49 positions
= aroundCorners
;
52 for(var key
in aroundCorners
){
53 positions
.push({aroundCorner
: key
, corner
: aroundCorners
[key
]});
57 return place
.around(node
, aroundNode
, positions
, true, layoutNode
);
61 dijit.placeOnScreenAroundNode = function(node, aroundNode, aroundCorners, layoutNode){
63 // Position node adjacent or kitty-corner to aroundNode
64 // such that it's fully visible in viewport.
65 // Deprecated, new code should use dijit.place.around() instead.
68 dijit
.placeOnScreenAroundNode
= dijit
.placeOnScreenAroundElement
;
71 dijit.placeOnScreenAroundRectangle = function(node, aroundRect, aroundCorners, layoutNode){
73 // Like dijit.placeOnScreenAroundNode(), except that the "around"
74 // parameter is an arbitrary rectangle on the screen (x, y, width, height)
75 // instead of a dom node.
76 // Deprecated, new code should use dijit.place.around() instead.
79 dijit
.placeOnScreenAroundRectangle
= dijit
.placeOnScreenAroundElement
;
81 dijit
.getPopupAroundAlignment = function(/*Array*/ position
, /*Boolean*/ leftToRight
){
83 // Deprecated method, unneeded when using dijit/place directly.
84 // Transforms the passed array of preferred positions into a format suitable for
85 // passing as the aroundCorners argument to dijit.placeOnScreenAroundElement.
88 // This variable controls the position of the drop down.
89 // It's an array of strings with the following values:
91 // * before: places drop down to the left of the target node/widget, or to the right in
92 // the case of RTL scripts like Hebrew and Arabic
93 // * after: places drop down to the right of the target node/widget, or to the left in
94 // the case of RTL scripts like Hebrew and Arabic
95 // * above: drop down goes above target node
96 // * below: drop down goes below target node
98 // The list is positions is tried, in order, until a position is found where the drop down fits
99 // within the viewport.
101 // leftToRight: Boolean
102 // Whether the popup will be displaying in leftToRight mode.
105 array
.forEach(position
, function(pos
){
106 var ltr
= leftToRight
;
109 align
[leftToRight
? "BR" : "BL"] = leftToRight
? "BL" : "BR";
112 align
[leftToRight
? "BL" : "BR"] = leftToRight
? "BR" : "BL";
118 // first try to align left borders, next try to align right borders (or reverse for RTL mode)
119 align
[ltr
? "BL" : "BR"] = ltr
? "TL" : "TR";
120 align
[ltr
? "BR" : "BL"] = ltr
? "TR" : "TL";
127 // first try to align left borders, next try to align right borders (or reverse for RTL mode)
128 align
[ltr
? "TL" : "TR"] = ltr
? "BL" : "BR";
129 align
[ltr
? "TR" : "TL"] = ltr
? "BR" : "BL";