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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * @constructor
7 * @extends {WebInspector.StylesSidebarPane.BaseToolbarPaneWidget}
8 * @param {!WebInspector.ToolbarItem} toolbarItem
9 */
10 WebInspector.ElementStatePaneWidget = function(toolbarItem)
11 {
12 WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.call(this, toolbarItem) ;
13 this.element.className = "styles-element-state-pane source-code";
14 var table = createElement("table");
15
16 var inputs = [];
17 this._inputs = inputs;
18
19 /**
20 * @param {!Event} event
21 */
22 function clickListener(event)
23 {
24 var node = WebInspector.context.flavor(WebInspector.DOMNode);
25 if (!node)
26 return;
27 WebInspector.CSSStyleModel.fromNode(node).forcePseudoState(node, event.t arget.state, event.target.checked);
28 }
29
30 /**
31 * @param {string} state
32 * @return {!Element}
33 */
34 function createCheckbox(state)
35 {
36 var td = createElement("td");
37 var label = createCheckboxLabel(":" + state);
38 var input = label.checkboxElement;
39 input.state = state;
40 input.addEventListener("click", clickListener, false);
41 inputs.push(input);
42 td.appendChild(label);
43 return td;
44 }
45
46 var tr = table.createChild("tr");
47 tr.appendChild(createCheckbox.call(null, "active"));
48 tr.appendChild(createCheckbox.call(null, "hover"));
49
50 tr = table.createChild("tr");
51 tr.appendChild(createCheckbox.call(null, "focus"));
52 tr.appendChild(createCheckbox.call(null, "visited"));
53
54 this.element.appendChild(table);
55 }
56
57 WebInspector.ElementStatePaneWidget.prototype = {
58 /**
59 * @override
60 * @param {?WebInspector.DOMNode} newNode
61 */
62 onNodeChanged: function(newNode)
63 {
64 this.toolbarItem().setEnabled(!!newNode);
65 if (!newNode && this.isShowing()) {
66 this.detach();
67 return;
68 }
69
70 var nodePseudoState = newNode.getUserProperty(WebInspector.CSSStyleModel .PseudoStatePropertyName) || [];
71 var inputs = this._inputs;
72 for (var i = 0; i < inputs.length; ++i) {
73 inputs[i].disabled = !!newNode.pseudoType();
74 inputs[i].checked = nodePseudoState.indexOf(inputs[i].state) >= 0;
75 }
76 },
77
78 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype
79 }
80
81 /**
82 * @constructor
83 * @implements {WebInspector.ToolbarItem.Provider}
84 */
85 WebInspector.ElementStatePaneWidget.ButtonProvider = function()
86 {
87 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Toggle Element State"), "element-state-toolbar-item");
88 this._button.addEventListener("click", this._clicked, this);
89 this._view = new WebInspector.ElementStatePaneWidget(this.item());
90 }
91
92 WebInspector.ElementStatePaneWidget.ButtonProvider.prototype = {
93 _clicked: function()
94 {
95 var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPan es.styles;
96 stylesSidebarPane.showToolbarPane(!this._view.isShowing() ? this._view : null);
97 },
98
99 /**
100 * @override
101 * @return {!WebInspector.ToolbarItem}
102 */
103 item: function()
104 {
105 return this._button;
106 }
107 }
OLDNEW
« 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