Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1819)

Unified Diff: Source/devtools/front_end/elements/ElementStatePaneWidget.js

Issue 1149373004: Devtools: Extensible toolbar in SSP (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix test Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/elements/ElementStatePaneWidget.js
diff --git a/Source/devtools/front_end/elements/ElementStatePaneWidget.js b/Source/devtools/front_end/elements/ElementStatePaneWidget.js
new file mode 100644
index 0000000000000000000000000000000000000000..04dd551d3a51431ca61b772752eb1817f3441dc5
--- /dev/null
+++ b/Source/devtools/front_end/elements/ElementStatePaneWidget.js
@@ -0,0 +1,107 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @constructor
+ * @extends {WebInspector.StylesSidebarPane.BaseToolbarPaneWidget}
+ * @param {!WebInspector.ToolbarItem} toolbarItem
+ */
+WebInspector.ElementStatePaneWidget = function(toolbarItem)
+{
+ WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.call(this, toolbarItem);
+ this.element.className = "styles-element-state-pane source-code";
+ var table = createElement("table");
+
+ var inputs = [];
+ this._inputs = inputs;
+
+ /**
+ * @param {!Event} event
+ */
+ function clickListener(event)
+ {
+ var node = WebInspector.context.flavor(WebInspector.DOMNode);
+ if (!node)
+ return;
+ WebInspector.CSSStyleModel.fromNode(node).forcePseudoState(node, event.target.state, event.target.checked);
+ }
+
+ /**
+ * @param {string} state
+ * @return {!Element}
+ */
+ function createCheckbox(state)
+ {
+ var td = createElement("td");
+ var label = createCheckboxLabel(":" + state);
+ var input = label.checkboxElement;
+ input.state = state;
+ input.addEventListener("click", clickListener, false);
+ inputs.push(input);
+ td.appendChild(label);
+ return td;
+ }
+
+ var tr = table.createChild("tr");
+ tr.appendChild(createCheckbox.call(null, "active"));
+ tr.appendChild(createCheckbox.call(null, "hover"));
+
+ tr = table.createChild("tr");
+ tr.appendChild(createCheckbox.call(null, "focus"));
+ tr.appendChild(createCheckbox.call(null, "visited"));
+
+ this.element.appendChild(table);
+}
+
+WebInspector.ElementStatePaneWidget.prototype = {
+ /**
+ * @override
+ * @param {?WebInspector.DOMNode} newNode
+ */
+ onNodeChanged: function(newNode)
+ {
+ this.toolbarItem().setEnabled(!!newNode);
+ if (!newNode && this.isShowing()) {
+ this.detach();
+ return;
+ }
+
+ var nodePseudoState = newNode.getUserProperty(WebInspector.CSSStyleModel.PseudoStatePropertyName) || [];
+ var inputs = this._inputs;
+ for (var i = 0; i < inputs.length; ++i) {
+ inputs[i].disabled = !!newNode.pseudoType();
+ inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0;
+ }
+ },
+
+ __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype
+}
+
+/**
+ * @constructor
+ * @implements {WebInspector.ToolbarItem.Provider}
+ */
+WebInspector.ElementStatePaneWidget.ButtonProvider = function()
+{
+ this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle Element State"), "element-state-toolbar-item");
+ this._button.addEventListener("click", this._clicked, this);
+ this._view = new WebInspector.ElementStatePaneWidget(this.item());
+}
+
+WebInspector.ElementStatePaneWidget.ButtonProvider.prototype = {
+ _clicked: function()
+ {
+ var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPanes.styles;
+ stylesSidebarPane.showToolbarPane(!this._view.isShowing() ? this._view : null);
+ },
+
+ /**
+ * @override
+ * @return {!WebInspector.ToolbarItem}
+ */
+ item: function()
+ {
+ return this._button;
+ }
+}
« no previous file with comments | « Source/devtools/front_end/elements/AnimationControlPane.js ('k') | Source/devtools/front_end/elements/StylesSidebarPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698