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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/elements/ElementStatePaneWidget.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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
OLDNEW
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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.ElementStatePaneWidget = class extends WebInspector.Widget { 7 Elements.ElementStatePaneWidget = class extends UI.Widget {
8 constructor() { 8 constructor() {
9 super(); 9 super();
10 this.element.className = 'styles-element-state-pane'; 10 this.element.className = 'styles-element-state-pane';
11 this.element.createChild('div').createTextChild(WebInspector.UIString('Force element state')); 11 this.element.createChild('div').createTextChild(Common.UIString('Force eleme nt state'));
12 var table = createElementWithClass('table', 'source-code'); 12 var table = createElementWithClass('table', 'source-code');
13 13
14 var inputs = []; 14 var inputs = [];
15 this._inputs = inputs; 15 this._inputs = inputs;
16 16
17 /** 17 /**
18 * @param {!Event} event 18 * @param {!Event} event
19 */ 19 */
20 function clickListener(event) { 20 function clickListener(event) {
21 var node = WebInspector.context.flavor(WebInspector.DOMNode); 21 var node = UI.context.flavor(SDK.DOMNode);
22 if (!node) 22 if (!node)
23 return; 23 return;
24 WebInspector.CSSModel.fromNode(node).forcePseudoState(node, event.target.s tate, event.target.checked); 24 SDK.CSSModel.fromNode(node).forcePseudoState(node, event.target.state, eve nt.target.checked);
25 } 25 }
26 26
27 /** 27 /**
28 * @param {string} state 28 * @param {string} state
29 * @return {!Element} 29 * @return {!Element}
30 */ 30 */
31 function createCheckbox(state) { 31 function createCheckbox(state) {
32 var td = createElement('td'); 32 var td = createElement('td');
33 var label = createCheckboxLabel(':' + state); 33 var label = createCheckboxLabel(':' + state);
34 var input = label.checkboxElement; 34 var input = label.checkboxElement;
35 input.state = state; 35 input.state = state;
36 input.addEventListener('click', clickListener, false); 36 input.addEventListener('click', clickListener, false);
37 inputs.push(input); 37 inputs.push(input);
38 td.appendChild(label); 38 td.appendChild(label);
39 return td; 39 return td;
40 } 40 }
41 41
42 var tr = table.createChild('tr'); 42 var tr = table.createChild('tr');
43 tr.appendChild(createCheckbox.call(null, 'active')); 43 tr.appendChild(createCheckbox.call(null, 'active'));
44 tr.appendChild(createCheckbox.call(null, 'hover')); 44 tr.appendChild(createCheckbox.call(null, 'hover'));
45 45
46 tr = table.createChild('tr'); 46 tr = table.createChild('tr');
47 tr.appendChild(createCheckbox.call(null, 'focus')); 47 tr.appendChild(createCheckbox.call(null, 'focus'));
48 tr.appendChild(createCheckbox.call(null, 'visited')); 48 tr.appendChild(createCheckbox.call(null, 'visited'));
49 49
50 this.element.appendChild(table); 50 this.element.appendChild(table);
51 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._upd ate, this); 51 UI.context.addFlavorChangeListener(SDK.DOMNode, this._update, this);
52 } 52 }
53 53
54 /** 54 /**
55 * @param {?WebInspector.Target} target 55 * @param {?SDK.Target} target
56 */ 56 */
57 _updateTarget(target) { 57 _updateTarget(target) {
58 if (this._target === target) 58 if (this._target === target)
59 return; 59 return;
60 60
61 if (this._target) { 61 if (this._target) {
62 var cssModel = WebInspector.CSSModel.fromTarget(this._target); 62 var cssModel = SDK.CSSModel.fromTarget(this._target);
63 cssModel.removeEventListener(WebInspector.CSSModel.Events.PseudoStateForce d, this._update, this); 63 cssModel.removeEventListener(SDK.CSSModel.Events.PseudoStateForced, this._ update, this);
64 } 64 }
65 this._target = target; 65 this._target = target;
66 if (target) { 66 if (target) {
67 var cssModel = WebInspector.CSSModel.fromTarget(target); 67 var cssModel = SDK.CSSModel.fromTarget(target);
68 cssModel.addEventListener(WebInspector.CSSModel.Events.PseudoStateForced, this._update, this); 68 cssModel.addEventListener(SDK.CSSModel.Events.PseudoStateForced, this._upd ate, this);
69 } 69 }
70 } 70 }
71 71
72 /** 72 /**
73 * @override 73 * @override
74 */ 74 */
75 wasShown() { 75 wasShown() {
76 this._update(); 76 this._update();
77 } 77 }
78 78
79 _update() { 79 _update() {
80 if (!this.isShowing()) 80 if (!this.isShowing())
81 return; 81 return;
82 82
83 var node = WebInspector.context.flavor(WebInspector.DOMNode); 83 var node = UI.context.flavor(SDK.DOMNode);
84 if (node) 84 if (node)
85 node = node.enclosingElementOrSelf(); 85 node = node.enclosingElementOrSelf();
86 86
87 this._updateTarget(node ? node.target() : null); 87 this._updateTarget(node ? node.target() : null);
88 if (node) { 88 if (node) {
89 var nodePseudoState = WebInspector.CSSModel.fromNode(node).pseudoState(nod e); 89 var nodePseudoState = SDK.CSSModel.fromNode(node).pseudoState(node);
90 for (var input of this._inputs) { 90 for (var input of this._inputs) {
91 input.disabled = !!node.pseudoType(); 91 input.disabled = !!node.pseudoType();
92 input.checked = nodePseudoState.indexOf(input.state) >= 0; 92 input.checked = nodePseudoState.indexOf(input.state) >= 0;
93 } 93 }
94 } else { 94 } else {
95 for (var input of this._inputs) { 95 for (var input of this._inputs) {
96 input.disabled = true; 96 input.disabled = true;
97 input.checked = false; 97 input.checked = false;
98 } 98 }
99 } 99 }
100 } 100 }
101 }; 101 };
102 102
103 /** 103 /**
104 * @implements {WebInspector.ToolbarItem.Provider} 104 * @implements {UI.ToolbarItem.Provider}
105 * @unrestricted 105 * @unrestricted
106 */ 106 */
107 WebInspector.ElementStatePaneWidget.ButtonProvider = class { 107 Elements.ElementStatePaneWidget.ButtonProvider = class {
108 constructor() { 108 constructor() {
109 this._button = new WebInspector.ToolbarToggle( 109 this._button = new UI.ToolbarToggle(
110 WebInspector.UIString('Toggle Element State'), ''); 110 Common.UIString('Toggle Element State'), '');
111 this._button.setText(WebInspector.UIString(':hov')); 111 this._button.setText(Common.UIString(':hov'));
112 this._button.addEventListener('click', this._clicked, this); 112 this._button.addEventListener('click', this._clicked, this);
113 this._button.element.classList.add('monospace'); 113 this._button.element.classList.add('monospace');
114 this._view = new WebInspector.ElementStatePaneWidget(); 114 this._view = new Elements.ElementStatePaneWidget();
115 } 115 }
116 116
117 _clicked() { 117 _clicked() {
118 WebInspector.ElementsPanel.instance().showToolbarPane(!this._view.isShowing( ) ? this._view : null, this._button); 118 Elements.ElementsPanel.instance().showToolbarPane(!this._view.isShowing() ? this._view : null, this._button);
119 } 119 }
120 120
121 /** 121 /**
122 * @override 122 * @override
123 * @return {!WebInspector.ToolbarItem} 123 * @return {!UI.ToolbarItem}
124 */ 124 */
125 item() { 125 item() {
126 return this._button; 126 return this._button;
127 } 127 }
128 }; 128 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698