| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.StylesSidebarPane.BaseToolbarPaneWidget} | 7 * @extends {WebInspector.StylesSidebarPane.BaseToolbarPaneWidget} |
| 8 * @param {!WebInspector.ToolbarItem} toolbarItem | 8 * @param {!WebInspector.ToolbarItem} toolbarItem |
| 9 */ | 9 */ |
| 10 WebInspector.ElementStatePaneWidget = function(toolbarItem) | 10 WebInspector.ElementStatePaneWidget = function(toolbarItem) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 this._updateInputs(node); | 85 this._updateInputs(node); |
| 86 }, | 86 }, |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @override | 89 * @override |
| 90 * @param {?WebInspector.DOMNode} newNode | 90 * @param {?WebInspector.DOMNode} newNode |
| 91 */ | 91 */ |
| 92 onNodeChanged: function(newNode) | 92 onNodeChanged: function(newNode) |
| 93 { | 93 { |
| 94 this._updateTarget(newNode? newNode.target() : null); | 94 this._updateTarget(newNode? newNode.target() : null); |
| 95 this.toolbarItem().setEnabled(!!newNode); | 95 if (newNode) |
| 96 if (!newNode) { | 96 this._updateInputs(newNode); |
| 97 if (this.isShowing()) | |
| 98 this.detach(); | |
| 99 return; | |
| 100 } | |
| 101 this._updateInputs(newNode); | |
| 102 }, | 97 }, |
| 103 | 98 |
| 104 /** | 99 /** |
| 105 * @param {!WebInspector.DOMNode} node | 100 * @param {!WebInspector.DOMNode} node |
| 106 */ | 101 */ |
| 107 _updateInputs: function(node) | 102 _updateInputs: function(node) |
| 108 { | 103 { |
| 109 var nodePseudoState = node.getUserProperty(WebInspector.CSSStyleModel.Ps
eudoStatePropertyName) || []; | 104 var nodePseudoState = node.getUserProperty(WebInspector.CSSStyleModel.Ps
eudoStatePropertyName) || []; |
| 110 var inputs = this._inputs; | 105 var inputs = this._inputs; |
| 111 for (var i = 0; i < inputs.length; ++i) { | 106 for (var i = 0; i < inputs.length; ++i) { |
| 112 inputs[i].disabled = !!node.pseudoType(); | 107 inputs[i].disabled = !!node.pseudoType(); |
| 113 inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0; | 108 inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0; |
| 114 } | 109 } |
| 115 }, | 110 }, |
| 116 | 111 |
| 117 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype | 112 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype |
| 118 } | 113 } |
| 119 | 114 |
| 120 /** | 115 /** |
| 121 * @constructor | 116 * @constructor |
| 122 * @implements {WebInspector.ToolbarItem.Provider} | 117 * @implements {WebInspector.ToolbarItem.Provider} |
| 123 */ | 118 */ |
| 124 WebInspector.ElementStatePaneWidget.ButtonProvider = function() | 119 WebInspector.ElementStatePaneWidget.ButtonProvider = function() |
| 125 { | 120 { |
| 126 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle
Element State"), "pin-toolbar-item"); | 121 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle
Element State"), "pin-toolbar-item"); |
| 127 this._button.addEventListener("click", this._clicked, this); | 122 this._button.addEventListener("click", this._clicked, this); |
| 128 this._view = new WebInspector.ElementStatePaneWidget(this.item()); | 123 this._view = new WebInspector.ElementStatePaneWidget(this.item()); |
| 124 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._nod
eChanged, this); |
| 125 this._nodeChanged(); |
| 129 } | 126 } |
| 130 | 127 |
| 131 WebInspector.ElementStatePaneWidget.ButtonProvider.prototype = { | 128 WebInspector.ElementStatePaneWidget.ButtonProvider.prototype = { |
| 132 _clicked: function() | 129 _clicked: function() |
| 133 { | 130 { |
| 134 var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPan
es.styles; | 131 var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPan
es.styles; |
| 135 stylesSidebarPane.showToolbarPane(!this._view.isShowing() ? this._view :
null); | 132 stylesSidebarPane.showToolbarPane(!this._view.isShowing() ? this._view :
null); |
| 136 }, | 133 }, |
| 137 | 134 |
| 138 /** | 135 /** |
| 139 * @override | 136 * @override |
| 140 * @return {!WebInspector.ToolbarItem} | 137 * @return {!WebInspector.ToolbarItem} |
| 141 */ | 138 */ |
| 142 item: function() | 139 item: function() |
| 143 { | 140 { |
| 144 return this._button; | 141 return this._button; |
| 142 }, |
| 143 |
| 144 _nodeChanged: function() |
| 145 { |
| 146 var enabled = !!WebInspector.context.flavor(WebInspector.DOMNode); |
| 147 this._button.setEnabled(enabled); |
| 148 if (!enabled && this._button.toggled()) |
| 149 WebInspector.ElementsPanel.instance().sidebarPanes.styles.showToolba
rPane(null); |
| 145 } | 150 } |
| 146 } | 151 } |
| OLD | NEW |