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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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.SwatchPopoverHelper = class extends WebInspector.Object { 7 UI.SwatchPopoverHelper = class extends Common.Object {
8 constructor() { 8 constructor() {
9 super(); 9 super();
10 this._popover = new WebInspector.Popover(); 10 this._popover = new UI.Popover();
11 this._popover.setCanShrink(false); 11 this._popover.setCanShrink(false);
12 this._popover.setNoPadding(true); 12 this._popover.setNoPadding(true);
13 this._popover.element.addEventListener('mousedown', (e) => e.consume(), fals e); 13 this._popover.element.addEventListener('mousedown', (e) => e.consume(), fals e);
14 14
15 this._hideProxy = this.hide.bind(this, true); 15 this._hideProxy = this.hide.bind(this, true);
16 this._boundOnKeyDown = this._onKeyDown.bind(this); 16 this._boundOnKeyDown = this._onKeyDown.bind(this);
17 this._boundFocusOut = this._onFocusOut.bind(this); 17 this._boundFocusOut = this._onFocusOut.bind(this);
18 this._isHidden = true; 18 this._isHidden = true;
19 } 19 }
20 20
21 /** 21 /**
22 * @param {!Event} event 22 * @param {!Event} event
23 */ 23 */
24 _onFocusOut(event) { 24 _onFocusOut(event) {
25 if (!event.relatedTarget || event.relatedTarget.isSelfOrDescendant(this._vie w.contentElement)) 25 if (!event.relatedTarget || event.relatedTarget.isSelfOrDescendant(this._vie w.contentElement))
26 return; 26 return;
27 this._hideProxy(); 27 this._hideProxy();
28 } 28 }
29 29
30 /** 30 /**
31 * @return {boolean} 31 * @return {boolean}
32 */ 32 */
33 isShowing() { 33 isShowing() {
34 return this._popover.isShowing(); 34 return this._popover.isShowing();
35 } 35 }
36 36
37 /** 37 /**
38 * @param {!WebInspector.Widget} view 38 * @param {!UI.Widget} view
39 * @param {!Element} anchorElement 39 * @param {!Element} anchorElement
40 * @param {function(boolean)=} hiddenCallback 40 * @param {function(boolean)=} hiddenCallback
41 */ 41 */
42 show(view, anchorElement, hiddenCallback) { 42 show(view, anchorElement, hiddenCallback) {
43 if (this._popover.isShowing()) { 43 if (this._popover.isShowing()) {
44 if (this._anchorElement === anchorElement) 44 if (this._anchorElement === anchorElement)
45 return; 45 return;
46 46
47 // Reopen the picker for another anchor element. 47 // Reopen the picker for another anchor element.
48 this.hide(true); 48 this.hide(true);
(...skipping 10 matching lines...) Expand all
59 document.defaultView.addEventListener('resize', this._hideProxy, false); 59 document.defaultView.addEventListener('resize', this._hideProxy, false);
60 this._view.contentElement.addEventListener('keydown', this._boundOnKeyDown, false); 60 this._view.contentElement.addEventListener('keydown', this._boundOnKeyDown, false);
61 } 61 }
62 62
63 reposition() { 63 reposition() {
64 // Unbind "blur" listener to avoid reenterability: |popover.showView| will h ide the popover and trigger it synchronously. 64 // Unbind "blur" listener to avoid reenterability: |popover.showView| will h ide the popover and trigger it synchronously.
65 this._view.contentElement.removeEventListener('focusout', this._boundFocusOu t, false); 65 this._view.contentElement.removeEventListener('focusout', this._boundFocusOu t, false);
66 this._popover.showView(this._view, this._anchorElement); 66 this._popover.showView(this._view, this._anchorElement);
67 this._view.contentElement.addEventListener('focusout', this._boundFocusOut, false); 67 this._view.contentElement.addEventListener('focusout', this._boundFocusOut, false);
68 if (!this._focusRestorer) 68 if (!this._focusRestorer)
69 this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._view); 69 this._focusRestorer = new UI.WidgetFocusRestorer(this._view);
70 } 70 }
71 71
72 /** 72 /**
73 * @param {boolean=} commitEdit 73 * @param {boolean=} commitEdit
74 */ 74 */
75 hide(commitEdit) { 75 hide(commitEdit) {
76 if (this._isHidden) 76 if (this._isHidden)
77 return; 77 return;
78 var document = this._popover.element.ownerDocument; 78 var document = this._popover.element.ownerDocument;
79 this._isHidden = true; 79 this._isHidden = true;
(...skipping 23 matching lines...) Expand all
103 this.hide(true); 103 this.hide(true);
104 event.consume(true); 104 event.consume(true);
105 return; 105 return;
106 } 106 }
107 if (event.key === 'Escape') { 107 if (event.key === 'Escape') {
108 this.hide(false); 108 this.hide(false);
109 event.consume(true); 109 event.consume(true);
110 } 110 }
111 } 111 }
112 }; 112 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698