| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @param {string} className | 33 * @param {string} className |
| 34 * @param {!Element=} parentElement | 34 * @param {!Element=} parentElement |
| 35 */ | 35 */ |
| 36 WebInspector.Toolbar = function(className, parentElement) | 36 WebInspector.Toolbar = function(className, parentElement) |
| 37 { | 37 { |
| 38 /** @type {!Array.<!WebInspector.ToolbarItem>} */ | 38 /** @type {!Array.<!WebInspector.ToolbarItem>} */ |
| 39 this._items = []; | 39 this._items = []; |
| 40 this._reverse = false; |
| 40 this.element = parentElement ? parentElement.createChild("div") : createElem
ent("div"); | 41 this.element = parentElement ? parentElement.createChild("div") : createElem
ent("div"); |
| 41 this.element.className = className; | 42 this.element.className = className; |
| 42 this.element.classList.add("toolbar"); | 43 this.element.classList.add("toolbar"); |
| 43 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
"ui/toolbar.css"); | 44 this._shadowRoot = WebInspector.createShadowRootWithCoreStyles(this.element,
"ui/toolbar.css"); |
| 44 this._contentElement = this._shadowRoot.createChild("div", "toolbar-shadow")
; | 45 this._contentElement = this._shadowRoot.createChild("div", "toolbar-shadow")
; |
| 45 this._contentElement.createChild("content"); | 46 this._insertionPoint = this._contentElement.createChild("content"); |
| 46 } | 47 } |
| 47 | 48 |
| 48 WebInspector.Toolbar.prototype = { | 49 WebInspector.Toolbar.prototype = { |
| 49 makeWrappable: function() | 50 /** |
| 51 * @param {boolean=} reverse |
| 52 */ |
| 53 makeWrappable: function(reverse) |
| 50 { | 54 { |
| 51 this._contentElement.classList.add("wrappable"); | 55 this._contentElement.classList.add("wrappable"); |
| 56 this._reverse = !!reverse; |
| 57 if (reverse) |
| 58 this._contentElement.classList.add("wrappable-reverse"); |
| 52 }, | 59 }, |
| 53 | 60 |
| 54 makeVertical: function() | 61 makeVertical: function() |
| 55 { | 62 { |
| 56 this._contentElement.classList.add("vertical"); | 63 this._contentElement.classList.add("vertical"); |
| 57 }, | 64 }, |
| 58 | 65 |
| 59 makeBlueOnHover: function() | 66 makeBlueOnHover: function() |
| 60 { | 67 { |
| 61 this._contentElement.classList.add("toolbar-blue-on-hover"); | 68 this._contentElement.classList.add("toolbar-blue-on-hover"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 75 item.setEnabled(enabled); | 82 item.setEnabled(enabled); |
| 76 }, | 83 }, |
| 77 | 84 |
| 78 /** | 85 /** |
| 79 * @param {!WebInspector.ToolbarItem} item | 86 * @param {!WebInspector.ToolbarItem} item |
| 80 */ | 87 */ |
| 81 appendToolbarItem: function(item) | 88 appendToolbarItem: function(item) |
| 82 { | 89 { |
| 83 this._items.push(item); | 90 this._items.push(item); |
| 84 item._toolbar = this; | 91 item._toolbar = this; |
| 85 this._contentElement.insertBefore(item.element, this._contentElement.las
tChild); | 92 if (this._reverse) |
| 93 this._contentElement.insertBefore(item.element, this._insertionPoint
.nextSibling); |
| 94 else |
| 95 this._contentElement.insertBefore(item.element, this._insertionPoint
); |
| 86 this._hideSeparatorDupes(); | 96 this._hideSeparatorDupes(); |
| 87 }, | 97 }, |
| 88 | 98 |
| 89 appendSeparator: function() | 99 appendSeparator: function() |
| 90 { | 100 { |
| 91 this.appendToolbarItem(new WebInspector.ToolbarSeparator()); | 101 this.appendToolbarItem(new WebInspector.ToolbarSeparator()); |
| 92 }, | 102 }, |
| 93 | 103 |
| 94 /** | 104 /** |
| 95 * @param {string} text | 105 * @param {string} text |
| 96 */ | 106 */ |
| 97 appendText: function(text) | 107 appendText: function(text) |
| 98 { | 108 { |
| 99 var item = new WebInspector.ToolbarTextGlyphItem(); | 109 var item = new WebInspector.ToolbarTextGlyphItem(); |
| 100 item.setText(text); | 110 item.setText(text); |
| 101 this.appendToolbarItem(item); | 111 this.appendToolbarItem(item); |
| 102 }, | 112 }, |
| 103 | 113 |
| 104 removeToolbarItems: function() | 114 removeToolbarItems: function() |
| 105 { | 115 { |
| 106 for (var item of this._items) | 116 for (var item of this._items) |
| 107 delete item._toolbar; | 117 delete item._toolbar; |
| 108 this._items = []; | 118 this._items = []; |
| 109 this._contentElement.removeChildren(); | 119 this._contentElement.removeChildren(); |
| 110 this._contentElement.createChild("content"); | 120 this._insertionPoint = this._contentElement.createChild("content"); |
| 111 }, | 121 }, |
| 112 | 122 |
| 113 /** | 123 /** |
| 114 * @param {string} color | 124 * @param {string} color |
| 115 */ | 125 */ |
| 116 setColor: function(color) | 126 setColor: function(color) |
| 117 { | 127 { |
| 118 var style = createElement("style"); | 128 var style = createElement("style"); |
| 119 style.textContent = ".toolbar-glyph { background-color: " + color + " !i
mportant }"; | 129 style.textContent = ".toolbar-glyph { background-color: " + color + " !i
mportant }"; |
| 120 this._shadowRoot.appendChild(style); | 130 this._shadowRoot.appendChild(style); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 }, | 318 }, |
| 309 | 319 |
| 310 /** | 320 /** |
| 311 * @param {boolean} bold | 321 * @param {boolean} bold |
| 312 */ | 322 */ |
| 313 setBold: function(bold) | 323 setBold: function(bold) |
| 314 { | 324 { |
| 315 this.element.classList.toggle("toolbar-bold", bold); | 325 this.element.classList.toggle("toolbar-bold", bold); |
| 316 }, | 326 }, |
| 317 | 327 |
| 328 /** |
| 329 * @param {boolean} dimmed |
| 330 */ |
| 331 setDimmed: function(dimmed) |
| 332 { |
| 333 this.element.classList.toggle("toolbar-dimmed", dimmed); |
| 334 }, |
| 335 |
| 318 __proto__: WebInspector.ToolbarItem.prototype | 336 __proto__: WebInspector.ToolbarItem.prototype |
| 319 } | 337 } |
| 320 | 338 |
| 321 /** | 339 /** |
| 322 * @constructor | 340 * @constructor |
| 323 * @extends {WebInspector.ToolbarTextGlyphItem} | 341 * @extends {WebInspector.ToolbarTextGlyphItem} |
| 324 * @param {string} title | 342 * @param {string} title |
| 325 * @param {string} glyph | 343 * @param {string} glyph |
| 326 */ | 344 */ |
| 327 WebInspector.ToolbarButton = function(title, glyph) | 345 WebInspector.ToolbarButton = function(title, glyph) |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 for (var i = 0; i < items.length; ++i) { | 927 for (var i = 0; i < items.length; ++i) { |
| 910 var item = items[i]; | 928 var item = items[i]; |
| 911 if (item) | 929 if (item) |
| 912 this.appendToolbarItem(item); | 930 this.appendToolbarItem(item); |
| 913 } | 931 } |
| 914 } | 932 } |
| 915 }, | 933 }, |
| 916 | 934 |
| 917 __proto__: WebInspector.Toolbar.prototype | 935 __proto__: WebInspector.Toolbar.prototype |
| 918 } | 936 } |
| OLD | NEW |