1 define("dijit/_base/place", [
2 "dojo/_base/array", // array.forEach
3 "dojo/_base/lang", // lang.isArray, lang.mixin
4 "dojo/window", // windowUtils.getBox
6 "../main" // export to dijit namespace
7 ], function(array
, lang
, windowUtils
, place
, dijit
){
15 // Deprecated back compatibility module, new code should use dijit/place directly instead of using this module.
18 exports
.getViewport = function(){
20 // Deprecated method to return the dimensions and scroll position of the viewable area of a browser window.
21 // New code should use windowUtils.getBox()
23 return windowUtils
.getBox();
26 exports
.placeOnScreen
= place
.at
;
28 exports
.placeOnScreenAroundElement = function(node
, aroundNode
, aroundCorners
, layoutNode
){
30 // Like dijit.placeOnScreenAroundNode(), except it accepts an arbitrary object
31 // for the "around" argument and finds a proper processor to place a node.
32 // Deprecated, new code should use dijit/place.around() instead.
34 // Convert old style {"BL": "TL", "BR": "TR"} type argument
35 // to style needed by dijit.place code:
37 // {aroundCorner: "BL", corner: "TL" },
38 // {aroundCorner: "BR", corner: "TR" }
41 if(lang
.isArray(aroundCorners
)){
42 positions
= aroundCorners
;
45 for(var key
in aroundCorners
){
46 positions
.push({aroundCorner
: key
, corner
: aroundCorners
[key
]});
50 return place
.around(node
, aroundNode
, positions
, true, layoutNode
);
53 exports
.placeOnScreenAroundNode
= exports
.placeOnScreenAroundElement
;
55 exports.placeOnScreenAroundNode = function(node, aroundNode, aroundCorners, layoutNode){
57 // Position node adjacent or kitty-corner to aroundNode
58 // such that it's fully visible in viewport.
59 // Deprecated, new code should use dijit/place.around() instead.
63 exports
.placeOnScreenAroundRectangle
= exports
.placeOnScreenAroundElement
;
65 exports.placeOnScreenAroundRectangle = function(node, aroundRect, aroundCorners, layoutNode){
67 // Like dijit.placeOnScreenAroundNode(), except that the "around"
68 // parameter is an arbitrary rectangle on the screen (x, y, width, height)
69 // instead of a dom node.
70 // Deprecated, new code should use dijit/place.around() instead.
74 exports
.getPopupAroundAlignment = function(/*Array*/ position
, /*Boolean*/ leftToRight
){
76 // Deprecated method, unneeded when using dijit/place directly.
77 // Transforms the passed array of preferred positions into a format suitable for
78 // passing as the aroundCorners argument to dijit/place.placeOnScreenAroundElement.
80 // This variable controls the position of the drop down.
81 // It's an array of strings with the following values:
83 // - before: places drop down to the left of the target node/widget, or to the right in
84 // the case of RTL scripts like Hebrew and Arabic
85 // - after: places drop down to the right of the target node/widget, or to the left in
86 // the case of RTL scripts like Hebrew and Arabic
87 // - above: drop down goes above target node
88 // - below: drop down goes below target node
90 // The list is positions is tried, in order, until a position is found where the drop down fits
91 // within the viewport.
92 // leftToRight: Boolean
93 // Whether the popup will be displaying in leftToRight mode.
96 array
.forEach(position
, function(pos
){
97 var ltr
= leftToRight
;
100 align
[leftToRight
? "BR" : "BL"] = leftToRight
? "BL" : "BR";
103 align
[leftToRight
? "BL" : "BR"] = leftToRight
? "BR" : "BL";
109 // first try to align left borders, next try to align right borders (or reverse for RTL mode)
110 align
[ltr
? "BL" : "BR"] = ltr
? "TL" : "TR";
111 align
[ltr
? "BR" : "BL"] = ltr
? "TR" : "TL";
118 // first try to align left borders, next try to align right borders (or reverse for RTL mode)
119 align
[ltr
? "TL" : "TR"] = ltr
? "BL" : "BR";
120 align
[ltr
? "TR" : "TL"] = ltr
? "BR" : "BL";
127 lang
.mixin(dijit
, exports
);
129 /*===== return exports; =====*/
130 return dijit
; // for back compat :-(