| 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 | |
| 48 var toolbarElement = this.contentElement.createChild("div"); | |
| 49 var toolbarItems = view.toolbarItems(); | |
| 50 if (toolbarItems.length) { | |
| 51 this._toolbar = new WebInspector.Toolbar(""); | |
| 52 for (var item of toolbarItems) | |
| 53 this._toolbar.appendToolbarItem(item); | |
| 54 } | |
| 55 | |
| 56 this.contentElement.createChild("content"); | |
| 57 this._view = view; | |
| 58 this._view.attach(this); | |
| 59 this._view[WebInspector.View._ExpandableContainerWidget._elementSymbol] = th
is.element; | |
| 60 if (expanded) | |
| 61 this.revealChild(this._view); | |
| 62 } | |
| 63 | |
| 64 WebInspector.View._ExpandableContainerWidget._elementSymbol = Symbol("container-
widget-element"); | |
| 65 | |
| 66 WebInspector.View._ExpandableContainerWidget.prototype = { | |
| 67 /** | |
| 68 * @override | |
| 69 * @param {!WebInspector.Widget} child | |
| 70 * @return {boolean} | |
| 71 */ | |
| 72 revealChild: function(child) | |
| 73 { | |
| 74 if (this._titleElement.classList.contains("expanded")) | |
| 75 return true; | |
| 76 if (this._toolbar) | |
| 77 this._titleElement.appendChild(this._toolbar.element); | |
| 78 this._titleElement.classList.add("expanded"); | |
| 79 this._view.showWidget(this.element); | |
| 80 return true; | |
| 81 }, | |
| 82 | |
| 83 _collapse: function() | |
| 84 { | |
| 85 if (!this._titleElement.classList.contains("expanded")) | |
| 86 return; | |
| 87 if (this._toolbar) | |
| 88 this._toolbar.element.remove(); | |
| 89 this._titleElement.classList.remove("expanded"); | |
| 90 this._view.hideWidget(); | |
| 91 }, | |
| 92 | |
| 93 _toggleExpanded: function() | |
| 94 { | |
| 95 if (this._titleElement.classList.contains("expanded")) | |
| 96 this._collapse(); | |
| 97 else | |
| 98 this.revealChild(this._view); | |
| 99 }, | |
| 100 | |
| 101 /** | |
| 102 * @param {!Event} event | |
| 103 */ | |
| 104 _onTitleKeyDown: function(event) | |
| 105 { | |
| 106 if (isEnterKey(event) || event.keyCode === WebInspector.KeyboardShortcut
.Keys.Space.code) | |
| 107 this._toggleExpanded(); | |
| 108 }, | |
| 109 | |
| 110 /** | |
| 111 * @param {!WebInspector.Widget} widget | |
| 112 * @override | |
| 113 */ | |
| 114 childWasDetached: function(widget) | |
| 115 { | |
| 116 WebInspector.VBox.prototype.childWasDetached.call(this, widget); | |
| 117 delete this._view[WebInspector.View._ExpandableContainerWidget._elementS
ymbol]; | |
| 118 }, | |
| 119 | |
| 120 __proto__: WebInspector.VBox.prototype | |
| 121 } | |
| 122 | |
| 123 /** | |
| 124 * @interface {WebInspector.TabbedPane} | |
| 125 */ | |
| 126 WebInspector.View.Container = function() | |
| 127 { | |
| 128 } | |
| 129 | |
| 130 WebInspector.View.Container.prototype = { | |
| 131 /** | |
| 132 * @param {!WebInspector.View} view | |
| 133 * @param {boolean=} reveal | |
| 134 */ | |
| 135 appendView: function(view, reveal) { }, | |
| 136 | |
| 137 /** | |
| 138 * @param {!WebInspector.View} view | |
| 139 * @param {?WebInspector.View} insertBefore | |
| 140 * @param {boolean=} reveal | |
| 141 */ | |
| 142 insertViewBefore: function(view, insertBefore, reveal) { } | |
| 143 } | |
| 144 | |
| 145 /** | |
| 146 * @constructor | |
| 147 * @extends {WebInspector.TabbedPane} | |
| 148 * @implements {WebInspector.View.Container} | |
| 149 */ | |
| 150 WebInspector.View.TabbedPaneContainer = function() | |
| 151 { | |
| 152 WebInspector.TabbedPane.call(this); | |
| 153 } | |
| 154 | |
| 155 WebInspector.View.TabbedPaneContainer.prototype = { | |
| 156 /** | |
| 157 * @param {!WebInspector.View} view | |
| 158 * @param {boolean=} reveal | |
| 159 * @override | |
| 160 */ | |
| 161 appendView: function(view, reveal) | |
| 162 { | |
| 163 this.insertViewBefore(view, null, reveal); | |
| 164 }, | |
| 165 | |
| 166 /** | |
| 167 * @param {!WebInspector.View} view | |
| 168 * @param {?WebInspector.View} insertBefore | |
| 169 * @param {boolean=} reveal | |
| 170 * @override | |
| 171 */ | |
| 172 insertViewBefore: function(view, insertBefore, reveal) | |
| 173 { | |
| 174 var widgets = this.tabViews(); | |
| 175 var index = 0; | |
| 176 for (var i = 0; insertBefore && i < widgets.length; ++i) { | |
| 177 if (widgets[i]._view === insertBefore) { | |
| 178 index = i; | |
| 179 break; | |
| 180 } | |
| 181 } | |
| 182 this.appendTab(view.title(), view.title(), new WebInspector.View._Contai
nerWidget(view), undefined, false, false, insertBefore ? index : undefined); | |
| 183 if (reveal) | |
| 184 this.selectTab(view.title()); | |
| 185 }, | |
| 186 | |
| 187 __proto__: WebInspector.TabbedPane.prototype | |
| 188 } | |
| 189 | |
| 190 /** | |
| 191 * @constructor | |
| 192 * @extends {WebInspector.VBox} | |
| 193 * @implements {WebInspector.View.Container} | |
| 194 */ | |
| 195 WebInspector.View.ExpandableStackContainer = function() | |
| 196 { | |
| 197 WebInspector.VBox.call(this); | |
| 198 this.element.classList.add("flex-auto", "overflow-auto"); | |
| 199 } | |
| 200 | |
| 201 WebInspector.View.ExpandableStackContainer.prototype = { | |
| 202 | |
| 203 /** | |
| 204 * @param {!WebInspector.View} view | |
| 205 * @param {boolean=} reveal | |
| 206 * @override | |
| 207 */ | |
| 208 appendView: function(view, reveal) | |
| 209 { | |
| 210 this.insertViewBefore(view, null, reveal); | |
| 211 }, | |
| 212 | |
| 213 /** | |
| 214 * @param {!WebInspector.View} view | |
| 215 * @param {?WebInspector.View} insertBefore | |
| 216 * @param {boolean=} reveal | |
| 217 * @override | |
| 218 */ | |
| 219 insertViewBefore: function(view, insertBefore, reveal) | |
| 220 { | |
| 221 new WebInspector.View._ExpandableContainerWidget(view, reveal || false).
show(this.contentElement, insertBefore ? insertBefore[WebInspector.View._Expanda
bleContainerWidget._elementSymbol] : null); | |
| 222 }, | |
| 223 | |
| 224 __proto__: WebInspector.VBox.prototype | |
| 225 } | |
| OLD | NEW |