| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @extends {WebInspector.VBox} |
| 8 * @param {!WebInspector.View} view |
| 9 */ |
| 10 WebInspector.View._ContainerWidget = function(view) |
| 11 { |
| 12 WebInspector.VBox.call(this); |
| 13 this.element.classList.add("flex-auto", "view-container", "overflow-auto"); |
| 14 |
| 15 var toolbarItems = view.toolbarItems(); |
| 16 if (toolbarItems.length) { |
| 17 var toolbar = new WebInspector.Toolbar("", this.element); |
| 18 for (var item of toolbarItems) |
| 19 toolbar.appendToolbarItem(item); |
| 20 } |
| 21 |
| 22 view.show(this.element); |
| 23 } |
| 24 |
| 25 WebInspector.View._ContainerWidget.prototype = { |
| 26 __proto__: WebInspector.VBox.prototype |
| 27 } |
| 28 |
| 29 /** |
| 30 * @constructor |
| 31 * @extends {WebInspector.VBox} |
| 32 * @param {!WebInspector.View} view |
| 33 * @param {boolean} expanded |
| 34 */ |
| 35 WebInspector.View._ExpandableContainerWidget = function(view, expanded) |
| 36 { |
| 37 WebInspector.VBox.call(this, true); |
| 38 this.element.classList.add("flex-none"); |
| 39 this.registerRequiredCSS("ui/viewContainers.css"); |
| 40 |
| 41 this._titleElement = createElementWithClass("div", "expandable-view-title"); |
| 42 this._titleElement.textContent = view.title(); |
| 43 this._titleElement.tabIndex = 0; |
| 44 this._titleElement.addEventListener("click", this._toggleExpanded.bind(this)
, false); |
| 45 this._titleElement.addEventListener("keydown", this._onTitleKeyDown.bind(thi
s), false); |
| 46 this.contentElement.insertBefore(this._titleElement, this.contentElement.fir
stChild); |
| 47 var toolbarElement = this.contentElement.createChild("div"); |
| 48 var toolbarItems = view.toolbarItems(); |
| 49 if (toolbarItems.length) { |
| 50 var toolbar = new WebInspector.Toolbar("", this._titleElement); |
| 51 for (var item of toolbarItems) |
| 52 toolbar.appendToolbarItem(item); |
| 53 } |
| 54 |
| 55 this.contentElement.createChild("content"); |
| 56 this._view = view; |
| 57 this._view.attach(this); |
| 58 this._view[WebInspector.View._ExpandableContainerWidget._elementSymbol] = th
is.element; |
| 59 if (expanded) |
| 60 this.revealChild(this._view); |
| 61 } |
| 62 |
| 63 WebInspector.View._ExpandableContainerWidget._elementSymbol = Symbol("container-
widget-element"); |
| 64 |
| 65 WebInspector.View._ExpandableContainerWidget.prototype = { |
| 66 /** |
| 67 * @override |
| 68 * @param {!WebInspector.Widget} child |
| 69 * @return {boolean} |
| 70 */ |
| 71 revealChild: function(child) |
| 72 { |
| 73 if (this._titleElement.classList.contains("expanded")) |
| 74 return true; |
| 75 this._titleElement.classList.add("expanded"); |
| 76 this._view.showWidget(this.element); |
| 77 return true; |
| 78 }, |
| 79 |
| 80 _collapse: function() |
| 81 { |
| 82 if (!this._titleElement.classList.contains("expanded")) |
| 83 return; |
| 84 this._titleElement.classList.remove("expanded"); |
| 85 this._view.hideWidget(); |
| 86 }, |
| 87 |
| 88 _toggleExpanded: function() |
| 89 { |
| 90 if (this._titleElement.classList.contains("expanded")) |
| 91 this._collapse(); |
| 92 else |
| 93 this.revealChild(this._view); |
| 94 }, |
| 95 |
| 96 /** |
| 97 * @param {!Event} event |
| 98 */ |
| 99 _onTitleKeyDown: function(event) |
| 100 { |
| 101 if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut
.Keys.Space.code) |
| 102 this._toggleExpanded(); |
| 103 }, |
| 104 |
| 105 /** |
| 106 * @param {!WebInspector.Widget} widget |
| 107 * @override |
| 108 */ |
| 109 childWasDetached: function(widget) |
| 110 { |
| 111 WebInspector.VBox.prototype.childWasDetached.call(this, widget); |
| 112 delete this._view[WebInspector.View._ExpandableContainerWidget._elementS
ymbol]; |
| 113 }, |
| 114 |
| 115 __proto__: WebInspector.VBox.prototype |
| 116 } |
| 117 |
| 118 /** |
| 119 * @interface {WebInspector.TabbedPane} |
| 120 */ |
| 121 WebInspector.View.Container = function() |
| 122 { |
| 123 } |
| 124 |
| 125 WebInspector.View.Container.prototype = { |
| 126 /** |
| 127 * @param {!WebInspector.View} view |
| 128 * @param {boolean=} reveal |
| 129 */ |
| 130 appendView: function(view, reveal) { }, |
| 131 |
| 132 /** |
| 133 * @param {!WebInspector.View} view |
| 134 * @param {?WebInspector.View} insertBefore |
| 135 * @param {boolean=} reveal |
| 136 */ |
| 137 insertViewBefore: function(view, insertBefore, reveal) { } |
| 138 } |
| 139 |
| 140 /** |
| 141 * @constructor |
| 142 * @extends {WebInspector.TabbedPane} |
| 143 * @implements {WebInspector.View.Container} |
| 144 */ |
| 145 WebInspector.View.TabbedPaneContainer = function() |
| 146 { |
| 147 WebInspector.TabbedPane.call(this); |
| 148 } |
| 149 |
| 150 WebInspector.View.TabbedPaneContainer.prototype = { |
| 151 /** |
| 152 * @param {!WebInspector.View} view |
| 153 * @param {boolean=} reveal |
| 154 * @override |
| 155 */ |
| 156 appendView: function(view, reveal) |
| 157 { |
| 158 this.insertViewBefore(view, null, reveal); |
| 159 }, |
| 160 |
| 161 /** |
| 162 * @param {!WebInspector.View} view |
| 163 * @param {?WebInspector.View} insertBefore |
| 164 * @param {boolean=} reveal |
| 165 * @override |
| 166 */ |
| 167 insertViewBefore: function(view, insertBefore, reveal) |
| 168 { |
| 169 var widgets = this.tabViews(); |
| 170 var index = 0; |
| 171 for (var i = 0; insertBefore && i < widgets.length; ++i) { |
| 172 if (widgets[i]._view === insertBefore) { |
| 173 index = i; |
| 174 break; |
| 175 } |
| 176 } |
| 177 this.appendTab(view.title(), view.title(), new WebInspector.View._Contai
nerWidget(view), undefined, false, false, insertBefore ? index : undefined); |
| 178 if (reveal) |
| 179 this.selectTab(view.title()); |
| 180 }, |
| 181 |
| 182 __proto__: WebInspector.TabbedPane.prototype |
| 183 } |
| 184 |
| 185 /** |
| 186 * @constructor |
| 187 * @extends {WebInspector.VBox} |
| 188 * @implements {WebInspector.View.Container} |
| 189 */ |
| 190 WebInspector.View.ExpandableStackContainer = function() |
| 191 { |
| 192 WebInspector.VBox.call(this); |
| 193 this.element.classList.add("flex-auto", "overflow-auto"); |
| 194 } |
| 195 |
| 196 WebInspector.View.ExpandableStackContainer.prototype = { |
| 197 |
| 198 /** |
| 199 * @param {!WebInspector.View} view |
| 200 * @param {boolean=} reveal |
| 201 * @override |
| 202 */ |
| 203 appendView: function(view, reveal) |
| 204 { |
| 205 this.insertViewBefore(view, null, reveal); |
| 206 }, |
| 207 |
| 208 /** |
| 209 * @param {!WebInspector.View} view |
| 210 * @param {?WebInspector.View} insertBefore |
| 211 * @param {boolean=} reveal |
| 212 * @override |
| 213 */ |
| 214 insertViewBefore: function(view, insertBefore, reveal) |
| 215 { |
| 216 new WebInspector.View._ExpandableContainerWidget(view, reveal || false).
show(this.contentElement, insertBefore ? insertBefore[WebInspector.View._Expanda
bleContainerWidget._elementSymbol] : null); |
| 217 }, |
| 218 |
| 219 __proto__: WebInspector.VBox.prototype |
| 220 } |
| OLD | NEW |