| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 | <title>BorderContainer DOH Test</title> |
| 6 | |
| 7 | <script type="text/javascript" src="../boilerplate.js"></script> |
| 8 | |
| 9 | <script type="text/javascript"> |
| 10 | require([ |
| 11 | "doh/runner", |
| 12 | "dojo/dom", "dojo/dom-geometry", "dojo/dom-style", "dojo/json", "dojo/parser", "dojo/query", |
| 13 | "dijit/registry", "dijit/tests/helpers", |
| 14 | "dijit/tests/layout/robot/borderContainerTestFunctions", |
| 15 | "dijit/layout/BorderContainer", |
| 16 | "dijit/layout/ContentPane", |
| 17 | |
| 18 | // used by parser |
| 19 | "dijit/form/FilteringSelect", |
| 20 | "dijit/MenuBar", |
| 21 | "dijit/PopupMenuBarItem", |
| 22 | "dijit/Menu", |
| 23 | "dijit/MenuItem", |
| 24 | |
| 25 | "dojo/domReady!" |
| 26 | |
| 27 | ], function(doh, dom, geom, style, json, parser, query, registry, helpers, bcTest, |
| 28 | BorderContainer, ContentPane){ |
| 29 | |
| 30 | var bc, cp1, cp2, cp3; |
| 31 | |
| 32 | doh.register("markup", [ |
| 33 | function parse(){ |
| 34 | parser.parse(); |
| 35 | }, |
| 36 | |
| 37 | function initialConditions(){ |
| 38 | bcTest.checkBCpanes(registry.byId("border1")); |
| 39 | bcTest.checkBCpanes(registry.byId("border2")); |
| 40 | doh.is("auto", style.get("border1-left", "overflow"), "overflow on ContentPane should be auto"); |
| 41 | doh.t("layoutPriority" in registry.byId("menu"), |
| 42 | "make sure layoutPriority flag added to _WidgetBase is visible in MenuBar"); |
| 43 | }, |
| 44 | |
| 45 | function tabOrder(){ |
| 46 | // The tab order between panes and splitters should match the visual layout, so that (in LTR mode) |
| 47 | // you tab to the left pane before its corresponding splitter, but tab to the right splitter before |
| 48 | // its corresponding pane. |
| 49 | var children = query("> *", registry.byId("border1").domNode).map(function(node){ |
| 50 | return node.id; |
| 51 | }); |
| 52 | doh.is("border1-top, border1-top_splitter, border1-left, border1-left_splitter, border1-center, " + |
| 53 | "border1-right_splitter, border1-right, border1-bottom_splitter, border1-bottom", |
| 54 | children.join(", ")); |
| 55 | }, |
| 56 | |
| 57 | function resize(){ |
| 58 | // current size of panes |
| 59 | var oTop = geom.position(dom.byId("border1-top")), |
| 60 | oLeft = geom.position(dom.byId("border1-left")), |
| 61 | oCenter = geom.position(dom.byId("border1-center")), |
| 62 | oRight = geom.position(dom.byId("border1-right")), |
| 63 | oBottom = geom.position(dom.byId("border1-bottom")); |
| 64 | |
| 65 | // make whole BorderContainer 100px bigger (width and height) |
| 66 | var mb = geom.getMarginBox("border1"); |
| 67 | registry.byId("border1").resize({w: mb.w + 100, h: mb.h + 100}); |
| 68 | |
| 69 | // new size of panes |
| 70 | var nTop = geom.position(dom.byId("border1-top")), |
| 71 | nLeft = geom.position(dom.byId("border1-left")), |
| 72 | nCenter = geom.position(dom.byId("border1-center")), |
| 73 | nRight = geom.position(dom.byId("border1-right")), |
| 74 | nBottom = geom.position(dom.byId("border1-bottom")); |
| 75 | |
| 76 | doh.is(oTop.w + 100, nTop.w, "top width + 100"); |
| 77 | doh.is(oTop.h, nTop.h, "top height unchanged"); |
| 78 | doh.is(oCenter.w + 100, nCenter.w, "center width + 100"); |
| 79 | doh.is(oCenter.h + 100, nCenter.h, "center height + 100"); |
| 80 | doh.is(oBottom.w + 100, nBottom.w, "bottom width + 100"); |
| 81 | doh.is(oBottom.h, nBottom.h, "bottom height unchanged"); |
| 82 | doh.is(oLeft.w, nLeft.w, "left width unchanged"); |
| 83 | doh.is(oLeft.h + 100, nLeft.h, "left height + 100"); |
| 84 | doh.is(oRight.w, nRight.w, "right width unchanged"); |
| 85 | doh.is(oRight.h + 100, nRight.h, "right height + 100"); |
| 86 | |
| 87 | // size BorderContainer back to original size |
| 88 | registry.byId("border1").resize({w: mb.w, h: mb.h}); |
| 89 | |
| 90 | var nnTop = geom.position(dom.byId("border1-top")), |
| 91 | nnLeft = geom.position(dom.byId("border1-left")), |
| 92 | nnCenter = geom.position(dom.byId("border1-center")), |
| 93 | nnRight = geom.position(dom.byId("border1-right")), |
| 94 | nnBottom = geom.position(dom.byId("border1-bottom")); |
| 95 | |
| 96 | doh.is(json.stringify(oTop), json.stringify(nnTop), "top after second resize"); |
| 97 | doh.is(json.stringify(oCenter), json.stringify(nnCenter), "center after second resize"); |
| 98 | doh.is(json.stringify(oBottom), json.stringify(nnBottom), "bottom after second resize"); |
| 99 | doh.is(json.stringify(oLeft), json.stringify(nnLeft), "left after second resize"); |
| 100 | doh.is(json.stringify(oRight), json.stringify(nnRight), "right after second resize"); |
| 101 | }, |
| 102 | |
| 103 | function addRemovePanes(){ |
| 104 | // current size of panes |
| 105 | var oLeft = geom.position(dom.byId("border1-left")), |
| 106 | oCenter = geom.position(dom.byId("border1-center")), |
| 107 | oRight = geom.position(dom.byId("border1-right")), |
| 108 | oBottom = geom.position(dom.byId("border1-bottom")); |
| 109 | |
| 110 | // remove top pane... should expand left/center/right |
| 111 | registry.byId("border1").removeChild(registry.byId("border1-top")); |
| 112 | doh.is("auto", registry.byId("border1-top").domNode.style.top, "border1-topremove, style.top-->auto"); |
| 113 | doh.is("auto", registry.byId("border1-top").domNode.style.left, "border1-topremove, style.left-->auto"); |
| 114 | doh.is("static", registry.byId("border1-top").domNode.style.position, "border1-topremove, style.position"); |
| 115 | |
| 116 | // new size of panes |
| 117 | var nLeft = geom.position(dom.byId("border1-left")), |
| 118 | nCenter = geom.position(dom.byId("border1-center")), |
| 119 | nRight = geom.position(dom.byId("border1-right")), |
| 120 | nBottom = geom.position(dom.byId("border1-bottom")); |
| 121 | |
| 122 | doh.t(nLeft.h > oLeft.h, "left height increased"); |
| 123 | doh.t(nCenter.h > oCenter.h, "center height increased"); |
| 124 | doh.t(nRight.h > oRight.h, "left height increased"); |
| 125 | doh.is(oBottom.h, nBottom.h, "bottom height didn't change"); |
| 126 | |
| 127 | // remove left pane... should just expand center pane |
| 128 | registry.byId("border1").removeChild(registry.byId("border1-left")); |
| 129 | |
| 130 | // new size of panes |
| 131 | var nnCenter = geom.position(dom.byId("border1-center")), |
| 132 | nnRight = geom.position(dom.byId("border1-right")), |
| 133 | nnBottom = geom.position(dom.byId("border1-bottom")); |
| 134 | |
| 135 | doh.t(nnCenter.w > nCenter.w, "center width increased"); |
| 136 | doh.is(json.stringify(nRight), json.stringify(nnRight), "right stayed same"); |
| 137 | doh.is(json.stringify(nBottom), json.stringify(nnBottom), "bottom stayed same"); |
| 138 | |
| 139 | // check that all panes sane |
| 140 | bcTest.checkBCpanes(registry.byId("border1")); |
| 141 | |
| 142 | // put back left pane as the top pane |
| 143 | registry.byId("border1").addChild(registry.byId("border1-left")); |
| 144 | |
| 145 | // check that all panes sane |
| 146 | bcTest.checkBCpanes(registry.byId("border1")); |
| 147 | } |
| 148 | ]); |
| 149 | |
| 150 | doh.register("programmatic creation", [ |
| 151 | function createProgramatically(){ |
| 152 | originalWidgetCnt = registry.length; |
| 153 | |
| 154 | bc = new BorderContainer({style:'height:400px;width:500px;border:1px solid black'}). |
| 155 | placeAt("programmatic", "after"); |
| 156 | |
| 157 | cp1 = new ContentPane({region:'top',style:'height:100px;background-color:red',splitter:true, id:"cp1"}); |
| 158 | cp1.domNode.innerHTML = "top pane"; |
| 159 | bc.addChild(cp1); |
| 160 | |
| 161 | cp2 = new ContentPane({region:'center',style:'background-color:green', id:'cp2'}); |
| 162 | cp2.domNode.innerHTML = "center pane"; |
| 163 | bc.addChild(cp2); |
| 164 | |
| 165 | cp3 = new ContentPane({region:'left', splitter: true, style:'width: 100px;', id:'cp3'}); |
| 166 | cp3.domNode.innerHTML = "left pane"; |
| 167 | |
| 168 | bc.startup(); |
| 169 | |
| 170 | bcTest.checkBCpanes(bc); |
| 171 | }, |
| 172 | function addLeftPane(){ |
| 173 | var nWidgetsBefore = registry.length; |
| 174 | bc.addChild(cp3); |
| 175 | bcTest.checkBCpanes(bc); |
| 176 | doh.t(helpers.isVisible(cp3)); |
| 177 | doh.is(nWidgetsBefore + 1, registry.length, "splitter widget created"); |
| 178 | }, |
| 179 | function removeTopPane(){ |
| 180 | var nWidgetsBefore = registry.length; |
| 181 | bc.removeChild(cp1); |
| 182 | bcTest.checkBCpanes(bc); |
| 183 | doh.f(helpers.isVisible(cp1)); |
| 184 | doh.is(nWidgetsBefore - 1, registry.length, "splitter widget destroyed"); |
| 185 | }, |
| 186 | function removeLeftPane(){ |
| 187 | bc.removeChild(cp3); |
| 188 | bcTest.checkBCpanes(bc); |
| 189 | doh.f(helpers.isVisible(cp3)); |
| 190 | }, |
| 191 | function addLeftPane2(){ |
| 192 | bc.addChild(cp3); |
| 193 | bcTest.checkBCpanes(bc); |
| 194 | doh.t(helpers.isVisible(cp3)); |
| 195 | }, |
| 196 | function addTopPane(){ |
| 197 | bc.addChild(cp1); |
| 198 | bcTest.checkBCpanes(bc); |
| 199 | doh.t(helpers.isVisible(cp3)); |
| 200 | }, |
| 201 | function destroyAll(){ |
| 202 | bc.destroyRecursive(); |
| 203 | doh.is(originalWidgetCnt, registry.length, "BorderContainer and all contained widgets destroyed"); |
| 204 | } |
| 205 | ]); |
| 206 | |
| 207 | doh.register("exceptions", [ |
| 208 | function createProgramatically(){ |
| 209 | bc = new BorderContainer({style:'height:400px;width:500px;border:1px solid black'}, dom.byId('main')); |
| 210 | doh.isNot(null, bc.domNode.parentNode, "has parent"); |
| 211 | |
| 212 | cp1 = new ContentPane({region:'top',style:'height:100px;background-color:red',splitter:true, id:"cp1"}); |
| 213 | cp1.domNode.innerHTML = "top pane"; |
| 214 | bc.addChild(cp1); |
| 215 | |
| 216 | cp2 = new ContentPane({region:'center',style:'background-color:green', id:'cp2'}); |
| 217 | cp2.domNode.innerHTML = "center pane"; |
| 218 | bc.addChild(cp2); |
| 219 | |
| 220 | var exception; |
| 221 | try{ |
| 222 | cp3 = new ContentPane({splitter: true, style:'width: 100px;', id:'cp3'}); |
| 223 | cp3.domNode.innerHTML = "left pane"; |
| 224 | bc.addChild(cp3); |
| 225 | bc.startup(); |
| 226 | }catch(e){ |
| 227 | doh.t(/No region setting for cp3/.test(e.message), "check exception: " + e); |
| 228 | exception = true; |
| 229 | } |
| 230 | doh.t(exception, "exception was fired"); |
| 231 | } |
| 232 | ]); |
| 233 | |
| 234 | doh.run(); |
| 235 | }); |
| 236 | |
| 237 | </script> |
| 238 | </head> |
| 239 | <body class="claro" role="main" aria-label="body"> |
| 240 | <p>Headline layout (default), left is constrained - min:150, max:250</p> |
| 241 | <div id="border1" data-dojo-type="dijit/layout/BorderContainer" |
| 242 | data-dojo-props='style:"width: 1000px; height: 300px; border: 2px solid blue;"'> |
| 243 | <div role="banner" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border1-top", region:"top", style:"background-color: #b39b86; border: 15px black solid; height: 50px;", splitter:true'> |
| 244 | top bar (resizable) |
| 245 | </div> |
| 246 | <div role="navigation" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border1-left", region:"left", style:"background-color: #acb386; border: 10px green solid; width: 100px;", |
| 247 | splitter:true, minSize:150, maxSize:250'> |
| 248 | left (resizable b/w 150 → 250) |
| 249 | </div> |
| 250 | <div role="main" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border1-center", region:"center", style:"background-color: #f5ffbf; padding: 30px;"' aria-labelledby="mylabel"> |
| 251 | <label id="mylabel">main panel</label> with <a href="http://www.dojotoolkit.org/">a link</a>.<br /> |
| 252 | (to check we're copying children around properly).<br /> |
| 253 | <select aria-label="select" data-dojo-type="dijit/form/FilteringSelect"> |
| 254 | <option value="1">foo</option> |
| 255 | <option value="2">bar</option> |
| 256 | <option value="3">baz</option> |
| 257 | </select> |
| 258 | Here's some text that comes AFTER the combo box. |
| 259 | </div> |
| 260 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border1-right", region:"right", style:"background-color: #acb386; width: 100px;"'> |
| 261 | right (fixed size) |
| 262 | </div> |
| 263 | <div role="contentinfo" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border1-bottom", region:"bottom", style:"background-color: #b39b86; height: 50px;", splitter:true'> |
| 264 | bottom bar (resizable) |
| 265 | </div> |
| 266 | </div> |
| 267 | |
| 268 | <p>Sidebar layout, BiDi sensitive, liveSplitters: false</p> |
| 269 | <div id="border2" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='design:"sidebar", liveSplitters:false, |
| 270 | style:"border: 20px solid black; width: 1000px; height: 300px;"'> |
| 271 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-leading", region:"leading", style:"background-color: #acb386; width: 100px;"'> |
| 272 | leading (fixed size) |
| 273 | </div> |
| 274 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-top", region:"top", style:"background-color: #b39b86; height: 80px;"'> |
| 275 | top bar (fixed size) |
| 276 | </div> |
| 277 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-center", region:"center", style:"background-color: #f5ffbf; 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 aria-label="select2" data-dojo-type="dijit/form/FilteringSelect"> |
| 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 data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-bottom", region:"bottom", style:"background-color: #b39b86; height: 80px;", splitter:true'> |
| 288 | bottom bar (resizable) |
| 289 | </div> |
| 290 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-trailing", region:"trailing", style:"background-color: #acb386; width: 100px;", splitter:true'> |
| 291 | trailing (resizable) |
| 292 | </div> |
| 293 | </div> |
| 294 | |
| 295 | <p id="programmatic">Programatically created, then destroyed</p> |
| 296 | <div id='main'></div> |
| 297 | |
| 298 | <p>BorderContainer with MenuBar</p> |
| 299 | <div id="menuBorder" data-dojo-type="dijit/layout/BorderContainer" |
| 300 | data-dojo-props='style:"width: 1000px; height: 300px; border: 2px solid blue;"'> |
| 301 | <div id="menu" data-dojo-type="dijit/MenuBar" data-dojo-props='region:"top", splitter:true'> |
| 302 | <div id="file" data-dojo-type="dijit/PopupMenuBarItem" > |
| 303 | <span>File</span> |
| 304 | <div id="fileMenu" data-dojo-type="dijit/Menu" > |
| 305 | <div id="new" data-dojo-type="dijit/MenuItem" >New</div> |
| 306 | <div id="open" data-dojo-type="dijit/MenuItem" >Open</div> |
| 307 | </div> |
| 308 | </div> |
| 309 | <div id="edit" data-dojo-type="dijit/PopupMenuBarItem" > |
| 310 | <span>Edit</span> |
| 311 | <div id="editMenu" data-dojo-type="dijit/Menu" > |
| 312 | <div id="cut" data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconCut", |
| 313 | onClick:function(){ console.log("not actually cutting anything, just a test!"); }, accelKey:"Ctrl+X"'>Cut</div> |
| 314 | <div id="copy" data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconCopy", |
| 315 | onClick:function(){ console.log("not actually copying anything, just a test!") }, accelKey:"Ctrl+C"'>Copy</div> |
| 316 | <div id="paste" data-dojo-type="dijit/MenuItem" data-dojo-props='iconClass:"dijitEditorIcon dijitEditorIconPaste", |
| 317 | onClick:function(){ console.log("not actually pasting anything, just a test!") }, accelKey:"Ctrl+V"'>Paste</div> |
| 318 | </div> |
| 319 | </div> |
| 320 | </div> |
| 321 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region: "center", splitter:true'> |
| 322 | content pane under menu |
| 323 | </div> |
| 324 | </div> |
| 325 | |
| 326 | </body> |
| 327 | </html> |