Debian Codegraph @

dijit/tests/layout/LayoutContainer_v1.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html lang="en">
3 <head>
4 <title>dijit/layout/LayoutContainer Test</title>
5
6 <script type="text/javascript" src="../boilerplate.js"></script>
7
8 <script type="text/javascript">
9 require([
10 "doh/runner",
11 "dojo/_base/array",
12 "dojo/dom-geometry",
13 "dojo/json",
14 "dojo/parser",
15 "dijit/registry",
16 "dijit/layout/ContentPane",
17 "dijit/layout/LayoutContainer",
18 "dijit/tests/helpers",
19 "dijit/form/FilteringSelect",
20 "dojo/domReady!"
21 ], function(doh, array,domGeom, json, parser,
22 registry, ContentPane, LayoutContainer, helpers){
23
24 function checkInside(/*Widget*/ child, /*Widget*/ parent){
25 // summary:
26 // Test that child is fully inside of parent
27 var cp = domGeom.position(child.domNode, true),
28 pp = domGeom.position(parent.domNode, true);
29
30 doh.t(
31 cp.y > pp.y && cp.y+cp.h < pp.y+pp.h &&
32 cp.x > pp.x && cp.x+cp.w < pp.x+pp.w,
33 child.layoutAlign + " inside " + parent.id + json.stringify(cp) + json.stringify(pp)
34 );
35 }
36 function checkAbove(/*String*/ comment, /*Widget*/ above, /*Widget*/ below){
37 // summary:
38 // Test that "above" widget is above "below" widget
39
40 var ap = domGeom.position(above.domNode, true),
41 bp = domGeom.position(below.domNode, true);
42
43 doh.t(Math.round(ap.y+ap.h) <= Math.round(bp.y),
44 comment + " " + above.layoutAlign + " above " + below.layoutAlign + json.stringify(ap) + json.stringify(bp)
45 );
46 }
47 function checkLeft(/*String*/ comment, /*Widget*/ left, /*Widget*/ right){
48 // summary:
49 // Test that "left" widget is to left of "right" widget
50
51 var lp = domGeom.position(left.domNode, true),
52 rp = domGeom.position(right.domNode, true);
53
54 doh.t(lp.x+lp.w <= rp.x,
55 comment + " " + left.layoutAlign + " to left of " + right.layoutAlign + json.stringify(lp) + json.stringify(rp)
56 );
57 }
58
59 doh.register("parse", function(){
60 return parser.parse();
61 });
62
63 doh.register("LayoutContainer", [
64 function basic(){
65 var lc = registry.byId("basic");
66 array.forEach(lc.getChildren(), function(child){
67 checkInside(child, lc);
68 });
69
70 var left = registry.byId("leftcp_layout1"),
71 top = registry.byId("topcp_layout1"),
72 right = registry.byId("rightcp_layout1"),
73 center = registry.byId("centercp_layout1"),
74 bottom = registry.byId("bottomcp_layout1");
75
76 // Check positions
77 checkLeft("left vs top", left, top);
78 checkLeft("left vs center", left, center);
79 checkLeft("bottom vs right", bottom, right);
80 checkAbove("top vs center", top, center);
81 checkAbove("center vs bottom", center, bottom);
82
83 // Check tab order
84 var tabbable = helpers.tabOrder(lc.domNode);
85 doh.is(7, tabbable.length, "each pane plus link and select");
86 doh.is(left.id, tabbable[0].id, "left");
87 doh.is(right.id, tabbable[1].id, "right");
88 doh.is(top.id, tabbable[2].id, "top");
89 doh.is(center.id, tabbable[3].id, "center");
90 doh.is(bottom.id, tabbable[6].id, "bottom");
91 },
92
93 function advanced(){
94 var lc = registry.byId("advanced");
95 array.forEach(lc.getChildren(), function(child){
96 checkInside(child, lc);
97 });
98
99 var left = registry.byId("leftcp_layout2"),
100 top = registry.byId("topcp_layout2"),
101 right = registry.byId("rightcp_layout2"),
102 centerLeft = registry.byId("centerLeftcp_layout2"),
103 center = registry.byId("centercp_layout2"),
104 centerRight = registry.byId("centerRightcp_layout2"),
105 bottom = registry.byId("bottomcp_layout2");
106
107 // Check positions
108 checkLeft("left vs top", left, top);
109 checkLeft("left vs centerLeft", left, centerLeft);
110 checkLeft("centerLeft vs center", centerLeft, center);
111 checkLeft("center vs centerRight", center, centerRight);
112 checkAbove("top vs center", top, center);
113 checkAbove("top vs inner right", top, centerRight);
114 checkAbove("centerLeft vs bottom", centerLeft, bottom);
115
116 // Check tab order
117 var tabbable = helpers.tabOrder(lc.domNode);
118 doh.is(8, tabbable.length, "each pane plus link and select");
119 doh.is(left.id, tabbable[0].id, "left");
120 doh.is(top.id, tabbable[1].id, "top");
121 doh.is(bottom.id, tabbable[2].id, "bottom");
122 doh.is(centerLeft.id, tabbable[3].id, "center left");
123 doh.is(center.id, tabbable[4].id, "center");
124 doh.is(centerRight.id, tabbable[7].id, "center right");
125 }
126 ]);
127
128 doh.run();
129 });
130 </script>
131
132 </head>
133 <body class="claro" role="main">
134 <h2 id="heading" >Dijit layout.LayoutContainer Old API tests</h2>
135 <p>
136 Tests for using layoutAlign property rather than region, so design setting (headline or sidebar) has no effect.
137 Remove for 2.0.
138 </p>
139
140 <p>Basic layout. Tabindex=&quot;0&quot; added to each pane to test for tab order matching source code order. Tab order
141 should be: left, right, top, middle/main, bottom</p>
142
143 <div id="basic" data-dojo-type="dijit/layout/LayoutContainer"
144 style="border: 2px solid black; width: 90%; height: 300px; padding: 10px;"
145 >
146 <div data-dojo-type="dijit/layout/ContentPane" id="leftcp_layout1" layoutAlign="left" style="background-color: #acb386; width: 100px;" tabindex="0">
147 left
148 </div>
149 <div data-dojo-type="dijit/layout/ContentPane" id="rightcp_layout1" layoutAlign="right" style="background-color: #acb386;" tabindex="0">
150 right
151 </div>
152 <div data-dojo-type="dijit/layout/ContentPane" id="topcp_layout1" layoutAlign="top" style="background-color: #b39b86; " tabindex="0">
153 top bar
154 </div>
155 <div data-dojo-type="dijit/layout/ContentPane" id="centercp_layout1" layoutAlign="client" style="background-color: #f5ffbf; padding: 10px;" tabindex="0">
156 main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br />
157 (to check we're copying children around properly).<br />
158 <select data-dojo-type="dijit/form/FilteringSelect" aria-label="select">
159 <option value="1">foo</option>
160 <option value="2">bar</option>
161 <option value="3">baz</option>
162 </select>
163 Here's some text that comes AFTER the combo box.
164 </div>
165
166 <div data-dojo-type="dijit/layout/ContentPane" id="bottomcp_layout1" layoutAlign="bottom" style="background-color: #b39b86;" tabindex="0">
167 bottom bar
168 </div>
169
170 </div>
171
172 <p>Advanced layout. Tabindex=&quot;0&quot; added to each pane to test for tab order matching source code order. Tab order
173 should be: left, top, bottom, inner left, inner middle, inner right. This is not an ideal tab order. See below to use nested
174 layout containers to achieve a tab order which matches presentation and source code order.</p>
175 <div id="advanced" data-dojo-type="dijit/layout/LayoutContainer"
176 style="border: 2px solid black; width: 90%; height: 300px; padding: 10px;"
177 >
178 <div data-dojo-type="dijit/layout/ContentPane" id="leftcp_layout2" layoutAlign="left" style="background-color: #acb386; width: 100px; margin: 5px;" tabindex="0">
179 left
180 </div>
181 <div data-dojo-type="dijit/layout/ContentPane" id="topcp_layout2" layoutAlign="top" style="background-color: #b39b86; margin: 5px;" tabindex="0">
182 top bar
183 </div>
184 <div data-dojo-type="dijit/layout/ContentPane" id="bottomcp_layout2" layoutAlign="bottom" style="background-color: #b39b86; margin: 5px;" tabindex="0">
185
186 bottom bar
187 </div>
188 <div data-dojo-type="dijit/layout/ContentPane" id="centerLeftcp_layout2" layoutAlign="left" style="background-color: #eeeeee; width: 100px; margin: 5px;" tabindex="0">
189 inner left
190 </div>
191
192 <div data-dojo-type="dijit/layout/ContentPane" id="centercp_layout2" layoutAlign="client" style="background-color: #f5ffbf; padding: 10px; margin: 5px;" tabindex="0">
193 main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br />
194
195 (to check we're copying children around properly).<br />
196 <select data-dojo-type="dijit/form/FilteringSelect" aria-label="select">
197 <option value="1">foo</option>
198 <option value="2">bar</option>
199 <option value="3">baz</option>
200 </select>
201 Here's some text that comes AFTER the combo box.
202 </div>
203 <div data-dojo-type="dijit/layout/ContentPane" id="centerRightcp_layout2" layoutAlign="right" style="background-color: #eeeeee; width: 100px; margin: 5px;" tabindex="0">
204 inner right
205 </div>
206 </div>
207
208 <p>Advanced layout with nested containers. Tabindex=&quot;0&quot; added to content panes to show tab order. Order should be:
209 left, top, inner left, inner middle, inner right, bottom. This is the preferred tab order for this type of layout.</p>
210 <div data-dojo-type="dijit/layout/LayoutContainer"
211 style="border: 2px solid black; width: 90%; height: 300px; padding: 10px;"
212 >
213 <div data-dojo-type="dijit/layout/ContentPane" id="leftcp_layout3" layoutAlign="left" style="background-color: #acb386; width: 100px; margin: 5px;" tabindex="0">
214 left
215 </div>
216 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="client" style="margin: 5px;" >
217 <div data-dojo-type="dijit/layout/LayoutContainer" style="height:90%;border: 2px solid black;padding: 10px;">
218
219 <div data-dojo-type="dijit/layout/ContentPane" id="topcp_layout3" layoutAlign="top" style="background-color: #b39b86; margin: 5px;" tabindex="0">
220 top bar
221 </div>
222 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="client" style="margin: 5px;">
223 <div data-dojo-type="dijit/layout/LayoutContainer" style="height:80%;border: 2px solid black;padding: 10px;">
224 <div data-dojo-type="dijit/layout/ContentPane" id="centerLeftcp_layout3" layoutAlign="left" style="background-color: #eeeeee; width: 100px; margin: 5px;" tabindex="0">
225 inner left
226 </div>
227 <div data-dojo-type="dijit/layout/ContentPane" id="centercp_layout3" layoutAlign="client" style="background-color: #f5ffbf; padding: 10px; margin: 5px;" tabindex="0">
228 main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br />
229 (to check we're copying children around properly).<br />
230 <select data-dojo-type="dijit/form/FilteringSelect" aria-label="select">
231 <option value="1">foo</option>
232 <option value="2">bar</option>
233 <option value="3">baz</option>
234 </select>
235 Here's some text that comes AFTER the combo box.
236 </div>
237 <div data-dojo-type="dijit/layout/ContentPane" id="centerRightcp_layout3" layoutAlign="right" style="background-color: #eeeeee; width: 100px; margin: 5px;" tabindex="0">
238 inner right
239 </div>
240 </div>
241 </div>
242 <div data-dojo-type="dijit/layout/ContentPane" id="bottomcp_layout3" layoutAlign="bottom" style="background-color: #b39b86; margin: 5px;" tabindex="0" >
243 bottom bar
244 </div>
245 </div>
246 </div>
247 </div>
248
249 <p>Goofy spiral layout. Match of source code order to tab order can not be achieved with this type of layout.</p>
250 <div data-dojo-type="dijit/layout/LayoutContainer"
251 style="border: 2px solid black; width: 90%; height: 300px; padding: 10px;"
252 >
253 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="left" style="background-color: #663333; color: white; width: 100px;">
254 outer left
255 </div>
256 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="top" style="background-color: #333366; color: white; height: 50px;">
257 outer top
258 </div>
259 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="right" style="background-color: #663333; color: white; width: 100px;">
260 outer right
261 </div>
262 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="bottom" style="background-color: #333366; color: white; height: 50px;">
263 outer bottom
264 </div>
265 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="left" style="background-color: #99CC99; width: 100px;">
266 inner left
267 </div>
268 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="top" style="background-color: #999966; height: 50px;">
269 inner top
270 </div>
271 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="right" style="background-color: #99CC99; width: 100px;">
272 inner right
273 </div>
274 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="bottom" style="background-color: #999966; height: 50px;">
275 inner bottom
276 </div>
277 <div data-dojo-type="dijit/layout/ContentPane" layoutAlign="client" style="padding: 10px;">
278 main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br />
279 (to check we're copying children around properly).<br />
280 <select data-dojo-type="dijit/form/FilteringSelect" aria-label="select">
281 <option value="1">foo</option>
282 <option value="2">bar</option>
283 <option value="3">baz</option>
284 </select>
285 Here's some text that comes AFTER the combo box.
286 </div>
287 </div>
288
289 </body>
290 </html>