]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/_base/place.js.uncompressed.js
update dojo to 1.7.3
[tt-rss.git] / lib / dijit / _base / place.js.uncompressed.js
1 define("dijit/_base/place", [
2 "dojo/_base/array", // array.forEach
3 "dojo/_base/lang", // lang.isArray
4 "dojo/window", // windowUtils.getBox
5 "../place",
6 ".." // export to dijit namespace
7 ], function(array, lang, windowUtils, place, dijit){
8
9 // module:
10 // dijit/_base/place
11 // summary:
12 // Back compatibility module, new code should use dijit/place directly instead of using this module.
13
14 dijit.getViewport = function(){
15 // summary:
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()
18
19 return windowUtils.getBox();
20 };
21
22 /*=====
23 dijit.placeOnScreen = function(node, pos, corners, padding){
24 // summary:
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.
28 };
29 =====*/
30 dijit.placeOnScreen = place.at;
31
32 /*=====
33 dijit.placeOnScreenAroundElement = function(node, aroundElement, aroundCorners, layoutNode){
34 // summary:
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.
38 };
39 ====*/
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:
43 // [
44 // {aroundCorner: "BL", corner: "TL" },
45 // {aroundCorner: "BR", corner: "TR" }
46 // ]
47 var positions;
48 if(lang.isArray(aroundCorners)){
49 positions = aroundCorners;
50 }else{
51 positions = [];
52 for(var key in aroundCorners){
53 positions.push({aroundCorner: key, corner: aroundCorners[key]});
54 }
55 }
56
57 return place.around(node, aroundNode, positions, true, layoutNode);
58 };
59
60 /*=====
61 dijit.placeOnScreenAroundNode = function(node, aroundNode, aroundCorners, layoutNode){
62 // summary:
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.
66 };
67 =====*/
68 dijit.placeOnScreenAroundNode = dijit.placeOnScreenAroundElement;
69
70 /*=====
71 dijit.placeOnScreenAroundRectangle = function(node, aroundRect, aroundCorners, layoutNode){
72 // summary:
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.
77 };
78 =====*/
79 dijit.placeOnScreenAroundRectangle = dijit.placeOnScreenAroundElement;
80
81 dijit.getPopupAroundAlignment = function(/*Array*/ position, /*Boolean*/ leftToRight){
82 // summary:
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.
86 //
87 // position: String[]
88 // This variable controls the position of the drop down.
89 // It's an array of strings with the following values:
90 //
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
97 //
98 // The list is positions is tried, in order, until a position is found where the drop down fits
99 // within the viewport.
100 //
101 // leftToRight: Boolean
102 // Whether the popup will be displaying in leftToRight mode.
103 //
104 var align = {};
105 array.forEach(position, function(pos){
106 var ltr = leftToRight;
107 switch(pos){
108 case "after":
109 align[leftToRight ? "BR" : "BL"] = leftToRight ? "BL" : "BR";
110 break;
111 case "before":
112 align[leftToRight ? "BL" : "BR"] = leftToRight ? "BR" : "BL";
113 break;
114 case "below-alt":
115 ltr = !ltr;
116 // fall through
117 case "below":
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";
121 break;
122 case "above-alt":
123 ltr = !ltr;
124 // fall through
125 case "above":
126 default:
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";
130 break;
131 }
132 });
133 return align;
134 };
135
136 return dijit;
137 });