| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 | <title>dijit/layout/BorderContainer Test</title> |
| 6 | |
| 7 | <script src="../boilerplate.js"></script> |
| 8 | |
| 9 | <style type="text/css"> |
| 10 | /* styles for this test */ |
| 11 | .dijitContentPane:focus { color: cyan; font-weight: bold } |
| 12 | body { margin-left: 20px } |
| 13 | #mondrian .dijitSplitter { border: 0; background: black !important } |
| 14 | #mondrian .dijitSplitterH { height: 10px } |
| 15 | #mondrian .dijitSplitterV { width: 10px } |
| 16 | #mondrian .dijitSplitterThumb { display: none } |
| 17 | #mondrian .dijitSplitterActive { background-color: blue } |
| 18 | .dj_webkit #mondrian .dijitSplitter:focus { |
| 19 | /* override orange focus border w/something easier to see (response to a11y bug report) */ |
| 20 | outline: 5px blue; |
| 21 | } |
| 22 | #mondrian SPAN { display: none } |
| 23 | #mondrian:hover SPAN { display: inline } |
| 24 | #mondrian .dijitContentPane { padding: 0 } |
| 25 | |
| 26 | </style> |
| 27 | |
| 28 | <script type="text/javascript"> |
| 29 | var bc, cp1, cp2, cp3; |
| 30 | |
| 31 | require([ |
| 32 | "dojo/_base/array", |
| 33 | "dojo/aspect", |
| 34 | "dojo/dom", |
| 35 | "dojo/dom-style", |
| 36 | "dojo/json", |
| 37 | "dojo/on", |
| 38 | "dojo/parser", |
| 39 | "dijit/registry", |
| 40 | "dijit/layout/BorderContainer", |
| 41 | "dijit/layout/ContentPane", |
| 42 | "dijit/form/FilteringSelect", |
| 43 | "dojo/domReady!" |
| 44 | ], function(array, aspect, dom, domStyle, json, on, parser, registry, BorderContainer, ContentPane, FilteringSelect){ |
| 45 | |
| 46 | togglePanel = function(button, id){ |
| 47 | var leftPanel = registry.byId(id); |
| 48 | if(leftPanel){ |
| 49 | registry.byId('border1').removeChild(leftPanel); |
| 50 | leftPanel.destroy(); |
| 51 | button.innerHTML='Add left panel'; |
| 52 | }else{ |
| 53 | var container = registry.byId('border1'); |
| 54 | var div = document.createElement('div'); |
| 55 | div.innerHTML='left'; |
| 56 | container.domNode.appendChild(div); |
| 57 | leftPanel = new ContentPane({id: id, region:'left', style:'background-color: #acb386; width:200px', splitter:true, minSize:150, maxSize:250}, div); |
| 58 | registry.byId('border1').addChild(leftPanel); |
| 59 | button.innerHTML='Remove left panel'; |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | function watchSplitters(bc){ |
| 64 | var out = dom.byId("watchedOutput"); |
| 65 | var moveConnects = {}; |
| 66 | array.forEach(["top", "left"], function(region){ |
| 67 | var spl = bc.getSplitter(region); |
| 68 | |
| 69 | aspect.after(spl, "_startDrag", function(){ |
| 70 | |
| 71 | domStyle.set(spl.child.domNode, "opacity", "0.4"); |
| 72 | moveConnects[spl.widgetId] = on(spl.domNode, "mousemove", function(evt){ |
| 73 | |
| 74 | out.innerHTML = spl.region + ": " + json.stringify({ |
| 75 | x: !spl.horizontal ? spl.domNode.style[spl.region] : 0, |
| 76 | y: spl.horizontal ? spl.domNode.style[spl.region] : 0 |
| 77 | }); |
| 78 | }) |
| 79 | |
| 80 | }); |
| 81 | aspect.after(spl, "_stopDrag", function(evt){ |
| 82 | domStyle.set(spl.child.domNode, "opacity", 1); |
| 83 | moveConnects[spl.widgetId].remove(); |
| 84 | delete moveConnects[spl.widgetId]; |
| 85 | }); |
| 86 | }) |
| 87 | } |
| 88 | |
| 89 | parser.parse(); |
| 90 | |
| 91 | watchSplitters( registry.byId("watchedBC") ); |
| 92 | |
| 93 | bc = new BorderContainer({style:'height:400px;width:500px;border:1px solid black'}, dom.byId('main')); |
| 94 | |
| 95 | cp1 = new ContentPane({region:'top',style:'height:100px;background-color:red',splitter:true, id:"cp1"}); |
| 96 | cp1.domNode.innerHTML = "top pane"; |
| 97 | bc.addChild(cp1); |
| 98 | |
| 99 | cp2 = new ContentPane({region:'center',style:'background-color:green', id:'cp2'}); |
| 100 | cp2.domNode.innerHTML = "center pane"; |
| 101 | bc.addChild(cp2); |
| 102 | |
| 103 | cp3 = new ContentPane({region:'left', splitter: true, style:'width: 100px;', id:'cp3'}); |
| 104 | cp3.domNode.innerHTML = "left pane"; |
| 105 | |
| 106 | bc.startup(); |
| 107 | }); |
| 108 | |
| 109 | </script> |
| 110 | </head> |
| 111 | <body class="claro" role="region" aria-label="main"> |
| 112 | <h2 class="testTitle">dijit/layout/BorderContainer tests</h2> |
| 113 | <p>Headline layout (default), left is constrained - min:150, max:250</p> |
| 114 | <div id="border1" data-dojo-type="dijit/layout/BorderContainer" |
| 115 | data-dojo-props='style:"width: 1000px; height: 300px; border: 2px solid blue;"'> |
| 116 | <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'> |
| 117 | top bar (resizable) |
| 118 | </div> |
| 119 | <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;", |
| 120 | splitter:true, minSize:150, maxSize:250'> |
| 121 | left (resizable b/w 150 → 250) |
| 122 | </div> |
| 123 | <div role="main" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border1-center", region:"center", style:"background-color: #f5ffbf; padding: 10px;"'> |
| 124 | main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br /> |
| 125 | (to check we're copying children around properly).<br /> |
| 126 | <select aria-label="select" data-dojo-type="dijit/form/FilteringSelect"> |
| 127 | <option value="1">foo</option> |
| 128 | <option value="2">bar</option> |
| 129 | <option value="3">baz</option> |
| 130 | </select> |
| 131 | Here's some text that comes AFTER the combo box. |
| 132 | </div> |
| 133 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border1-right", region:"right", style:"background-color: #acb386; width: 100px;"'> |
| 134 | right (fixed size) |
| 135 | </div> |
| 136 | <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'> |
| 137 | bottom bar (resizable) |
| 138 | </div> |
| 139 | </div> |
| 140 | |
| 141 | <button id="toggleLeftButton" onClick="togglePanel(this, 'border1-left')">Remove left panel</button> |
| 142 | <br /> |
| 143 | |
| 144 | <p>Sidebar layout, BiDi sensitive, liveSplitters: false</p> |
| 145 | <div id="border2" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='design:"sidebar", liveSplitters:false, |
| 146 | style:"border: 20px solid black; width: 1000px; height: 300px;"'> |
| 147 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-leading", region:"leading", style:"background-color: #acb386; width: 100px;"'> |
| 148 | leading (fixed size) |
| 149 | </div> |
| 150 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-top", region:"top", style:"background-color: #b39b86; height: 80px;"'> |
| 151 | top bar (fixed size) |
| 152 | </div> |
| 153 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-center", region:"center", style:"background-color: #f5ffbf; padding: 10px;"'> |
| 154 | main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br /> |
| 155 | (to check we're copying children around properly).<br /> |
| 156 | <select aria-label="select" data-dojo-type="dijit/form/FilteringSelect"> |
| 157 | <option value="1">foo</option> |
| 158 | <option value="2">bar</option> |
| 159 | <option value="3">baz</option> |
| 160 | </select> |
| 161 | Here's some text that comes AFTER the combo box. |
| 162 | </div> |
| 163 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-bottom", region:"bottom", style:"background-color: #b39b86; height: 80px;", splitter:true'> |
| 164 | bottom bar (resizable) |
| 165 | </div> |
| 166 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='id:"border2-trailing", region:"trailing", style:"background-color: #acb386; width: 100px;", splitter:true'> |
| 167 | trailing (resizable) |
| 168 | </div> |
| 169 | </div> |
| 170 | |
| 171 | <p>gutters=false layout</p> |
| 172 | |
| 173 | <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='design:"sidebar", gutters:false, |
| 174 | style:"border: 20px solid black; width: 1000px; height: 300px;"'> |
| 175 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"leading", style:"background-color: #acb386; width: 100px;"'> |
| 176 | leading |
| 177 | </div> |
| 178 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"top", style:"background-color: #b39b86; height: 80px;"'> |
| 179 | top bar |
| 180 | </div> |
| 181 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"center", style:"background-color: #f5ffbf; padding: 10px;"'> |
| 182 | main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br /> |
| 183 | (to check we're copying children around properly).<br /> |
| 184 | <select aria-label="select" data-dojo-type="dijit/form/FilteringSelect"> |
| 185 | <option value="1">foo</option> |
| 186 | <option value="2">bar</option> |
| 187 | <option value="3">baz</option> |
| 188 | </select> |
| 189 | Here's some text that comes AFTER the combo box. |
| 190 | </div> |
| 191 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"bottom", style:"background-color: #b39b86; height: 80px;"'> |
| 192 | bottom bar |
| 193 | </div> |
| 194 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"trailing", style:"background-color: #acb386; width: 100px;"'> |
| 195 | trailing |
| 196 | </div> |
| 197 | </div> |
| 198 | |
| 199 | <p>Vertical panels only with splitters</p> |
| 200 | |
| 201 | <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='design:"sidebar", |
| 202 | style:"border: 2px solid black; width: 1000px; height: 300px; padding: 10px;"'> |
| 203 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"top", style:"background-color: #b39b86; height: 80px;", splitter:true'> |
| 204 | top bar |
| 205 | </div> |
| 206 | |
| 207 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"center", style:"background-color: #f5ffbf; padding: 10px;"'> |
| 208 | main panel with <a href="http://www.dojotoolkit.org/">a link</a>.<br /> |
| 209 | (to check we're copying children around properly).<br /> |
| 210 | <select aria-label="select" data-dojo-type="dijit/form/FilteringSelect"> |
| 211 | <option value="1">foo</option> |
| 212 | <option value="2">bar</option> |
| 213 | <option value="3">baz</option> |
| 214 | </select> |
| 215 | Here's some text that comes AFTER the combo box. |
| 216 | </div> |
| 217 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"bottom", style:"background-color: #b39b86; height: 80px;", splitter:true'> |
| 218 | bottom bar |
| 219 | </div> |
| 220 | </div> |
| 221 | |
| 222 | <br /> |
| 223 | <p>More fun with layouts</p> |
| 224 | |
| 225 | <div id="mondrian" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='design:"sidebar", gutters:false, persist:true, style:"height: 300px; width: 400px;"'> |
| 226 | <div id="mondrian_top" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"top", style:"height: 100px", splitter:true'> |
| 227 | <div id="mondrian_top_bc" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='persist:true, gutters:false, style:"height: 100px; width: 100%"'> |
| 228 | <div id="top_a" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"leading", style:"width: 125px", splitter:true'><span>top a</span></div> |
| 229 | <div id="top_b" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"center", style:"background-color: yellow", splitter:true'><span>top b</span></div> |
| 230 | </div> |
| 231 | </div> |
| 232 | <div id="mondrian_bottom" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"bottom", style:"height: 100px", splitter:true'> |
| 233 | <div id="mondrian_bottom_bc" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='persist:true, gutters:false, style:"height: 100px; width: 100%"'> |
| 234 | <div id="bottom_c" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"top", style:"height: 40px; background-color: blue;", splitter:true'><span>bottom c</span></div> |
| 235 | <div id="bottom_d" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"center"'><span>bottom d</span></div> |
| 236 | </div> |
| 237 | </div> |
| 238 | <div id="mondrian_leading" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"leading", style:"width: 100px", splitter:true'> |
| 239 | <div id="mondrian_leading_bc" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='persist:true, gutters:false, style:"height: 300px; width: 100%"'> |
| 240 | <div id="leading_e" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"center"'><span>leading e</span></div> |
| 241 | <div id="leading_f" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"bottom", style:"height: 100px; background-color: red", splitter:true'><span>leading f</span></div> |
| 242 | </div> |
| 243 | </div> |
| 244 | <div id="trailing_g" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"center", splitter:true'><span>trailing g</span></div> |
| 245 | <div id="trailing_h" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"trailing", style:"width: 100px", splitter:true'><span>trailing g</span></div> |
| 246 | </div> |
| 247 | |
| 248 | <br /> |
| 249 | <p>Watching the splitter events</p> |
| 250 | <div id="watchedBC" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='persist:false, gutters:false, style:"height: 200px; width: 100%"'> |
| 251 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"top", splitter:true, style:"background-color: #ccffcc; height: 50px;"'>Top:</div> |
| 252 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"left", style:"background-color: #ccccff; width: 40px", splitter:true'><span>Left</span></div> |
| 253 | <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props='region:"center", style:"background-color: #ffffcc"'><span>Center</span></div> |
| 254 | </div> |
| 255 | |
| 256 | <p>Splitter coords output:</p> |
| 257 | <div id="watchedOutput" style="border: 1px solid #999">nothing moving</div> |
| 258 | |
| 259 | |
| 260 | <h2 class="testTitle">dijit/layout/BorderContainer programmatic test</h2> |
| 261 | <div id='main'></div> |
| 262 | |
| 263 | <button id="addLeft" onclick="bc.addChild(cp3);">add left pane</button> |
| 264 | <button id="removeLeft" onclick="bc.removeChild(cp3);">remove left pane</button> |
| 265 | <button id="addTop" onclick="bc.addChild(cp1);">add top pane</button> |
| 266 | <button id="removeTop" onclick="bc.removeChild(cp1);">remove top pane</button> |
| 267 | </body> |
| 268 | </html> |