Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> |
michael@0 | 8 | <?xml-stylesheet href="gridsample.css" type="text/css"?> |
michael@0 | 9 | |
michael@0 | 10 | <!DOCTYPE window> |
michael@0 | 11 | |
michael@0 | 12 | |
michael@0 | 13 | <window orient="vertical" |
michael@0 | 14 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 15 | onload="start()"> |
michael@0 | 16 | |
michael@0 | 17 | <script> |
michael@0 | 18 | |
michael@0 | 19 | var selected; |
michael@0 | 20 | var count = 0; |
michael@0 | 21 | |
michael@0 | 22 | function isCell(box) |
michael@0 | 23 | { |
michael@0 | 24 | if (box.localName == "row" || |
michael@0 | 25 | box.localName == "column" || |
michael@0 | 26 | box.localName == "rows" || |
michael@0 | 27 | box.localName == "columns" || |
michael@0 | 28 | box.localName == "grid") |
michael@0 | 29 | return false; |
michael@0 | 30 | |
michael@0 | 31 | return true; |
michael@0 | 32 | } |
michael@0 | 33 | |
michael@0 | 34 | function start() |
michael@0 | 35 | { |
michael@0 | 36 | selectIt(window.document.getElementById("rows")); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function selectIt(box) |
michael@0 | 40 | { |
michael@0 | 41 | if (!box) |
michael@0 | 42 | return; |
michael@0 | 43 | |
michael@0 | 44 | var a = box.getAttribute("selected"); |
michael@0 | 45 | if (a != "true") { |
michael@0 | 46 | box.setAttribute("selected","true"); |
michael@0 | 47 | if (selected) |
michael@0 | 48 | selected.setAttribute("selected","false"); |
michael@0 | 49 | |
michael@0 | 50 | selected = box; |
michael@0 | 51 | } |
michael@0 | 52 | } |
michael@0 | 53 | |
michael@0 | 54 | function addCellSelectionHandle(box) |
michael@0 | 55 | { |
michael@0 | 56 | box.setAttribute("oncommand", "selectIt(this);"); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | function addRowColumnSelectionHandle(box) |
michael@0 | 60 | { |
michael@0 | 61 | box.setAttribute("onclick", "selectIt(this);"); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function createButton(str) |
michael@0 | 65 | { |
michael@0 | 66 | var b = document.createElement("button"); |
michael@0 | 67 | b.setAttribute("label", str+count); |
michael@0 | 68 | count++; |
michael@0 | 69 | addCellSelectionHandle(b); |
michael@0 | 70 | return b; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | function createRow() |
michael@0 | 74 | { |
michael@0 | 75 | var b = document.createElement("row"); |
michael@0 | 76 | b.setAttribute("dynamic","true"); |
michael@0 | 77 | |
michael@0 | 78 | addRowColumnSelectionHandle(b); |
michael@0 | 79 | return b; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | function createColumn() |
michael@0 | 83 | { |
michael@0 | 84 | var b = document.createElement("column"); |
michael@0 | 85 | b.setAttribute("dynamic","true"); |
michael@0 | 86 | addRowColumnSelectionHandle(b); |
michael@0 | 87 | return b; |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | function createText(str) |
michael@0 | 91 | { |
michael@0 | 92 | var text = document.createElement("text"); |
michael@0 | 93 | text.setAttribute("value", str+count); |
michael@0 | 94 | count++; |
michael@0 | 95 | text.setAttribute("style", "font-size: 40pt"); |
michael@0 | 96 | addCellSelectionHandle(text); |
michael@0 | 97 | return text; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | function appendElement(element, prepend) |
michael@0 | 101 | { |
michael@0 | 102 | if (!selected) |
michael@0 | 103 | return; |
michael@0 | 104 | |
michael@0 | 105 | setUserAttribute(element); |
michael@0 | 106 | |
michael@0 | 107 | if (selected.localName == "rows") |
michael@0 | 108 | appendRow(false); |
michael@0 | 109 | else if (selected.localName == "columns") |
michael@0 | 110 | appendColumn(false); |
michael@0 | 111 | |
michael@0 | 112 | if (selected.localName == "row" || selected.localName == "column" ) { // is row or column |
michael@0 | 113 | selected.appendChild(element); |
michael@0 | 114 | } else { |
michael@0 | 115 | var parent = selected.parentNode; |
michael@0 | 116 | if (prepend) |
michael@0 | 117 | parent.insertBefore(element, selected); |
michael@0 | 118 | else { |
michael@0 | 119 | var next = selected.nextSibling; |
michael@0 | 120 | if (next) |
michael@0 | 121 | parent.insertBefore(element,next); |
michael@0 | 122 | else |
michael@0 | 123 | parent.appendChild(element); |
michael@0 | 124 | } |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | selectIt(element); |
michael@0 | 128 | } |
michael@0 | 129 | |
michael@0 | 130 | function getRows(box) |
michael@0 | 131 | { |
michael@0 | 132 | return window.document.getElementById("rows"); |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | function getColumns(box) |
michael@0 | 136 | { |
michael@0 | 137 | return window.document.getElementById("columns"); |
michael@0 | 138 | } |
michael@0 | 139 | |
michael@0 | 140 | function setUserAttribute(element) |
michael@0 | 141 | { |
michael@0 | 142 | var attributeBox = document.getElementById("attributebox"); |
michael@0 | 143 | var valueBox = document.getElementById("valuebox"); |
michael@0 | 144 | var attribute = attributeBox.value; |
michael@0 | 145 | var value = valueBox.value; |
michael@0 | 146 | if (attribute != "") |
michael@0 | 147 | element.setAttribute(attribute,value); |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | function appendRowColumn(rowColumn, prepend) |
michael@0 | 151 | { |
michael@0 | 152 | if (!selected) |
michael@0 | 153 | return; |
michael@0 | 154 | |
michael@0 | 155 | setUserAttribute(rowColumn); |
michael@0 | 156 | |
michael@0 | 157 | var row = rowColumn; |
michael@0 | 158 | |
michael@0 | 159 | // first see what we are adding. |
michael@0 | 160 | |
michael@0 | 161 | if (isCell(selected)) { // if cell then select row/column |
michael@0 | 162 | selectIt(selected.parentNode); |
michael@0 | 163 | } |
michael@0 | 164 | |
michael@0 | 165 | if (selected.localName == "row" || selected.localName == "rows") |
michael@0 | 166 | if (row.localName == "column") { |
michael@0 | 167 | selectIt(getColumns(selected)); |
michael@0 | 168 | dump("Selecting the column") |
michael@0 | 169 | dump("Selected="+selected.localName); |
michael@0 | 170 | } |
michael@0 | 171 | |
michael@0 | 172 | if (selected.localName == "column" || selected.localName == "columns") |
michael@0 | 173 | if (row.localName == "row") |
michael@0 | 174 | selectIt(getRows(selected)); |
michael@0 | 175 | |
michael@0 | 176 | if (selected.localName == "rows" || selected.localName == "columns" ) |
michael@0 | 177 | { // if rows its easy |
michael@0 | 178 | selected.appendChild(row); |
michael@0 | 179 | } else { |
michael@0 | 180 | var parent = selected.parentNode; |
michael@0 | 181 | if (prepend) |
michael@0 | 182 | parent.insertBefore(row, selected); |
michael@0 | 183 | else { |
michael@0 | 184 | var next = selected.nextSibling; |
michael@0 | 185 | if (next) |
michael@0 | 186 | parent.insertBefore(row,next); |
michael@0 | 187 | else |
michael@0 | 188 | parent.appendChild(row); |
michael@0 | 189 | } |
michael@0 | 190 | } |
michael@0 | 191 | |
michael@0 | 192 | selectIt(row); |
michael@0 | 193 | } |
michael@0 | 194 | |
michael@0 | 195 | function appendRow(prepend) |
michael@0 | 196 | { |
michael@0 | 197 | var row = createRow(); |
michael@0 | 198 | appendRowColumn(row,prepend); |
michael@0 | 199 | } |
michael@0 | 200 | |
michael@0 | 201 | |
michael@0 | 202 | function appendColumn(prepend) |
michael@0 | 203 | { |
michael@0 | 204 | var column = createColumn(); |
michael@0 | 205 | appendRowColumn(column,prepend); |
michael@0 | 206 | } |
michael@0 | 207 | |
michael@0 | 208 | |
michael@0 | 209 | function selectRows() |
michael@0 | 210 | { |
michael@0 | 211 | var rows = getRows(); |
michael@0 | 212 | if (rows.firstChild) |
michael@0 | 213 | selectIt(rows.firstChild); |
michael@0 | 214 | else |
michael@0 | 215 | selectIt(rows); |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | |
michael@0 | 219 | function selectColumns() |
michael@0 | 220 | { |
michael@0 | 221 | var columns = getColumns(); |
michael@0 | 222 | if (columns.firstChild) |
michael@0 | 223 | selectIt(columns.firstChild); |
michael@0 | 224 | else |
michael@0 | 225 | selectIt(columns); |
michael@0 | 226 | } |
michael@0 | 227 | |
michael@0 | 228 | function nextElement() |
michael@0 | 229 | { |
michael@0 | 230 | if (!selected) |
michael@0 | 231 | return; |
michael@0 | 232 | |
michael@0 | 233 | selectIt(selected.nextSibling); |
michael@0 | 234 | } |
michael@0 | 235 | |
michael@0 | 236 | function previousElement() |
michael@0 | 237 | { |
michael@0 | 238 | if (!selected) |
michael@0 | 239 | return; |
michael@0 | 240 | |
michael@0 | 241 | selectIt(selected.previousSibling); |
michael@0 | 242 | } |
michael@0 | 243 | |
michael@0 | 244 | function selectRow() |
michael@0 | 245 | { |
michael@0 | 246 | if (!selected) |
michael@0 | 247 | return; |
michael@0 | 248 | |
michael@0 | 249 | if (selected.localName == "row") |
michael@0 | 250 | return; |
michael@0 | 251 | |
michael@0 | 252 | if (isCell(selected)) { |
michael@0 | 253 | if (selected.parentNode.localName == "row") |
michael@0 | 254 | selectIt(selected.parentNode); |
michael@0 | 255 | } |
michael@0 | 256 | } |
michael@0 | 257 | |
michael@0 | 258 | function selectColumn() |
michael@0 | 259 | { |
michael@0 | 260 | if (!selected) |
michael@0 | 261 | return; |
michael@0 | 262 | |
michael@0 | 263 | if (selected.localName == "column") |
michael@0 | 264 | return; |
michael@0 | 265 | |
michael@0 | 266 | if (isCell(selected)) { |
michael@0 | 267 | if (selected.parentNode.localName == "column") |
michael@0 | 268 | selectIt(selected.parentNode); |
michael@0 | 269 | } |
michael@0 | 270 | } |
michael@0 | 271 | |
michael@0 | 272 | function collapseGrid() |
michael@0 | 273 | { |
michael@0 | 274 | var grid = document.getElementById("grid"); |
michael@0 | 275 | var collapsed = grid.getAttribute("collapsed"); |
michael@0 | 276 | |
michael@0 | 277 | if (collapsed == "") |
michael@0 | 278 | grid.setAttribute("collapsed","true"); |
michael@0 | 279 | else |
michael@0 | 280 | grid.setAttribute("collapsed",""); |
michael@0 | 281 | |
michael@0 | 282 | } |
michael@0 | 283 | |
michael@0 | 284 | function collapseElement() |
michael@0 | 285 | { |
michael@0 | 286 | if (selected) { |
michael@0 | 287 | var collapsed = selected.getAttribute("collapsed"); |
michael@0 | 288 | |
michael@0 | 289 | if (collapsed == "") |
michael@0 | 290 | selected.setAttribute("collapsed","true"); |
michael@0 | 291 | else |
michael@0 | 292 | selected.setAttribute("collapsed",""); |
michael@0 | 293 | } |
michael@0 | 294 | } |
michael@0 | 295 | |
michael@0 | 296 | </script> |
michael@0 | 297 | |
michael@0 | 298 | <hbox flex="1" style="border: 2px inset gray; overflow: auto"> |
michael@0 | 299 | <vbox flex="1"> |
michael@0 | 300 | <hbox> |
michael@0 | 301 | <grid id="grid" style="border: 2px solid red;"> |
michael@0 | 302 | <columns id="columns"> |
michael@0 | 303 | </columns> |
michael@0 | 304 | |
michael@0 | 305 | <rows start="true" id="rows"> |
michael@0 | 306 | </rows> |
michael@0 | 307 | </grid> |
michael@0 | 308 | <spacer flex="1"/> |
michael@0 | 309 | </hbox> |
michael@0 | 310 | <spacer flex="1"/> |
michael@0 | 311 | </vbox> |
michael@0 | 312 | </hbox> |
michael@0 | 313 | |
michael@0 | 314 | <grid style="background-color: blue"> |
michael@0 | 315 | <columns> |
michael@0 | 316 | <column flex="1"/> |
michael@0 | 317 | <column flex="1"/> |
michael@0 | 318 | <column flex="1"/> |
michael@0 | 319 | <column flex="1"/> |
michael@0 | 320 | </columns> |
michael@0 | 321 | <rows> |
michael@0 | 322 | |
michael@0 | 323 | <row> |
michael@0 | 324 | <button label="append row" oncommand="appendRow(false);"/> |
michael@0 | 325 | <button label="prepend row" oncommand="appendRow(true);"/> |
michael@0 | 326 | |
michael@0 | 327 | <button label="append column" oncommand="appendColumn(false);"/> |
michael@0 | 328 | <button label="prepend column" oncommand="appendColumn(true);"/> |
michael@0 | 329 | </row> |
michael@0 | 330 | |
michael@0 | 331 | <row> |
michael@0 | 332 | |
michael@0 | 333 | <button label="append button" oncommand="appendElement(createButton('button'),false);"/> |
michael@0 | 334 | <button label="prepend button" oncommand="appendElement(createButton('button'),true);"/> |
michael@0 | 335 | |
michael@0 | 336 | <button label="append text" oncommand="appendElement(createText('text'),false);"/> |
michael@0 | 337 | <button label="prepend text" oncommand="appendElement(createText('text'),true);"/> |
michael@0 | 338 | |
michael@0 | 339 | </row> |
michael@0 | 340 | |
michael@0 | 341 | <row> |
michael@0 | 342 | |
michael@0 | 343 | <button label="select rows" oncommand="selectRows()"/> |
michael@0 | 344 | <button label="select columns" oncommand="selectColumns()"/> |
michael@0 | 345 | |
michael@0 | 346 | <button label="next" oncommand="nextElement()"/> |
michael@0 | 347 | <button label="previous" oncommand="previousElement()"/> |
michael@0 | 348 | |
michael@0 | 349 | </row> |
michael@0 | 350 | |
michael@0 | 351 | <hbox align="center"> |
michael@0 | 352 | <button label="collapse/uncollapse grid" flex="1" oncommand="collapseGrid()"/> |
michael@0 | 353 | <button label="collapse/uncollapse element" flex="1" oncommand="collapseElement()"/> |
michael@0 | 354 | </hbox> |
michael@0 | 355 | |
michael@0 | 356 | |
michael@0 | 357 | |
michael@0 | 358 | <hbox> |
michael@0 | 359 | |
michael@0 | 360 | <text value="attribute"/> |
michael@0 | 361 | <textbox id="attributebox" value="" flex="1"/> |
michael@0 | 362 | <text value="value"/> |
michael@0 | 363 | <textbox id="valuebox" value="" flex="2"/> |
michael@0 | 364 | </hbox> |
michael@0 | 365 | |
michael@0 | 366 | |
michael@0 | 367 | </rows> |
michael@0 | 368 | </grid> |
michael@0 | 369 | |
michael@0 | 370 | </window> |