Index: third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js b/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js |
index 43f4be387f77ac056999e6cb019095ccee5ac979..24cc48044a0de40116539ae16c4329476088b749 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js |
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SwatchPopoverHelper.js |
@@ -1,122 +1,112 @@ |
// Copyright 2016 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.Object} |
+ * @unrestricted |
*/ |
-WebInspector.SwatchPopoverHelper = function() |
-{ |
+WebInspector.SwatchPopoverHelper = class extends WebInspector.Object { |
+ constructor() { |
+ super(); |
this._popover = new WebInspector.Popover(); |
this._popover.setCanShrink(false); |
this._popover.setNoPadding(true); |
- this._popover.element.addEventListener("mousedown", (e) => e.consume(), false); |
+ this._popover.element.addEventListener('mousedown', (e) => e.consume(), false); |
this._hideProxy = this.hide.bind(this, true); |
this._boundOnKeyDown = this._onKeyDown.bind(this); |
this._boundFocusOut = this._onFocusOut.bind(this); |
this._isHidden = true; |
-}; |
+ } |
-WebInspector.SwatchPopoverHelper.prototype = { |
- /** |
- * @param {!Event} event |
- */ |
- _onFocusOut: function(event) |
- { |
- if (!event.relatedTarget || event.relatedTarget.isSelfOrDescendant(this._view.contentElement)) |
- return; |
- this._hideProxy(); |
- }, |
+ /** |
+ * @param {!Event} event |
+ */ |
+ _onFocusOut(event) { |
+ if (!event.relatedTarget || event.relatedTarget.isSelfOrDescendant(this._view.contentElement)) |
+ return; |
+ this._hideProxy(); |
+ } |
- /** |
- * @return {boolean} |
- */ |
- isShowing: function() |
- { |
- return this._popover.isShowing(); |
- }, |
+ /** |
+ * @return {boolean} |
+ */ |
+ isShowing() { |
+ return this._popover.isShowing(); |
+ } |
- /** |
- * @param {!WebInspector.Widget} view |
- * @param {!Element} anchorElement |
- * @param {function(boolean)=} hiddenCallback |
- */ |
- show: function(view, anchorElement, hiddenCallback) |
- { |
- if (this._popover.isShowing()) { |
- if (this._anchorElement === anchorElement) |
- return; |
+ /** |
+ * @param {!WebInspector.Widget} view |
+ * @param {!Element} anchorElement |
+ * @param {function(boolean)=} hiddenCallback |
+ */ |
+ show(view, anchorElement, hiddenCallback) { |
+ if (this._popover.isShowing()) { |
+ if (this._anchorElement === anchorElement) |
+ return; |
- // Reopen the picker for another anchor element. |
- this.hide(true); |
- } |
+ // Reopen the picker for another anchor element. |
+ this.hide(true); |
+ } |
- delete this._isHidden; |
- this._anchorElement = anchorElement; |
- this._view = view; |
- this._hiddenCallback = hiddenCallback; |
- this.reposition(); |
+ delete this._isHidden; |
+ this._anchorElement = anchorElement; |
+ this._view = view; |
+ this._hiddenCallback = hiddenCallback; |
+ this.reposition(); |
- var document = this._popover.element.ownerDocument; |
- document.addEventListener("mousedown", this._hideProxy, false); |
- document.defaultView.addEventListener("resize", this._hideProxy, false); |
- this._view.contentElement.addEventListener("keydown", this._boundOnKeyDown, false); |
- }, |
+ var document = this._popover.element.ownerDocument; |
+ document.addEventListener('mousedown', this._hideProxy, false); |
+ document.defaultView.addEventListener('resize', this._hideProxy, false); |
+ this._view.contentElement.addEventListener('keydown', this._boundOnKeyDown, false); |
+ } |
- reposition: function() |
- { |
- // Unbind "blur" listener to avoid reenterability: |popover.showView| will hide the popover and trigger it synchronously. |
- this._view.contentElement.removeEventListener("focusout", this._boundFocusOut, false); |
- this._popover.showView(this._view, this._anchorElement); |
- this._view.contentElement.addEventListener("focusout", this._boundFocusOut, false); |
- if (!this._focusRestorer) |
- this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._view); |
- }, |
+ reposition() { |
+ // Unbind "blur" listener to avoid reenterability: |popover.showView| will hide the popover and trigger it synchronously. |
+ this._view.contentElement.removeEventListener('focusout', this._boundFocusOut, false); |
+ this._popover.showView(this._view, this._anchorElement); |
+ this._view.contentElement.addEventListener('focusout', this._boundFocusOut, false); |
+ if (!this._focusRestorer) |
+ this._focusRestorer = new WebInspector.WidgetFocusRestorer(this._view); |
+ } |
- /** |
- * @param {boolean=} commitEdit |
- */ |
- hide: function(commitEdit) |
- { |
- if (this._isHidden) |
- return; |
- var document = this._popover.element.ownerDocument; |
- this._isHidden = true; |
- this._popover.hide(); |
- |
- document.removeEventListener("mousedown", this._hideProxy, false); |
- document.defaultView.removeEventListener("resize", this._hideProxy, false); |
+ /** |
+ * @param {boolean=} commitEdit |
+ */ |
+ hide(commitEdit) { |
+ if (this._isHidden) |
+ return; |
+ var document = this._popover.element.ownerDocument; |
+ this._isHidden = true; |
+ this._popover.hide(); |
- if (this._hiddenCallback) |
- this._hiddenCallback.call(null, !!commitEdit); |
+ document.removeEventListener('mousedown', this._hideProxy, false); |
+ document.defaultView.removeEventListener('resize', this._hideProxy, false); |
- this._focusRestorer.restore(); |
- delete this._anchorElement; |
- if (this._view) { |
- this._view.detach(); |
- this._view.contentElement.removeEventListener("keydown", this._boundOnKeyDown, false); |
- this._view.contentElement.removeEventListener("focusout", this._boundFocusOut, false); |
- delete this._view; |
- } |
- }, |
+ if (this._hiddenCallback) |
+ this._hiddenCallback.call(null, !!commitEdit); |
- /** |
- * @param {!Event} event |
- */ |
- _onKeyDown: function(event) |
- { |
- if (event.key === "Enter") { |
- this.hide(true); |
- event.consume(true); |
- return; |
- } |
- if (event.key === "Escape") { |
- this.hide(false); |
- event.consume(true); |
- } |
- }, |
+ this._focusRestorer.restore(); |
+ delete this._anchorElement; |
+ if (this._view) { |
+ this._view.detach(); |
+ this._view.contentElement.removeEventListener('keydown', this._boundOnKeyDown, false); |
+ this._view.contentElement.removeEventListener('focusout', this._boundFocusOut, false); |
+ delete this._view; |
+ } |
+ } |
- __proto__: WebInspector.Object.prototype |
+ /** |
+ * @param {!Event} event |
+ */ |
+ _onKeyDown(event) { |
+ if (event.key === 'Enter') { |
+ this.hide(true); |
+ event.consume(true); |
+ return; |
+ } |
+ if (event.key === 'Escape') { |
+ this.hide(false); |
+ event.consume(true); |
+ } |
+ } |
}; |