| OLD | NEW |
| 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 UI.SwatchPopoverHelper = class extends Common.Object { | 7 UI.SwatchPopoverHelper = class extends Common.Object { |
| 8 constructor() { | 8 constructor() { |
| 9 super(); | 9 super(); |
| 10 this._popover = new UI.Popover(); | 10 this._popover = new UI.Popover(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 49 } | 49 } |
| 50 | 50 |
| 51 delete this._isHidden; | 51 delete this._isHidden; |
| 52 this._anchorElement = anchorElement; | 52 this._anchorElement = anchorElement; |
| 53 this._view = view; | 53 this._view = view; |
| 54 this._hiddenCallback = hiddenCallback; | 54 this._hiddenCallback = hiddenCallback; |
| 55 this.reposition(); | 55 this.reposition(); |
| 56 view.focus(); |
| 56 | 57 |
| 57 var document = this._popover.element.ownerDocument; | 58 var document = this._popover.element.ownerDocument; |
| 58 document.addEventListener('mousedown', this._hideProxy, false); | 59 document.addEventListener('mousedown', this._hideProxy, false); |
| 59 document.defaultView.addEventListener('resize', this._hideProxy, false); | 60 document.defaultView.addEventListener('resize', this._hideProxy, false); |
| 60 this._view.contentElement.addEventListener('keydown', this._boundOnKeyDown,
false); | 61 this._view.contentElement.addEventListener('keydown', this._boundOnKeyDown,
false); |
| 61 } | 62 } |
| 62 | 63 |
| 63 reposition() { | 64 reposition() { |
| 64 // Unbind "blur" listener to avoid reenterability: |popover.showView| will h
ide the popover and trigger it synchronously. | 65 // 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); | 66 this._view.contentElement.removeEventListener('focusout', this._boundFocusOu
t, false); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 this.hide(true); | 104 this.hide(true); |
| 104 event.consume(true); | 105 event.consume(true); |
| 105 return; | 106 return; |
| 106 } | 107 } |
| 107 if (event.key === 'Escape') { | 108 if (event.key === 'Escape') { |
| 108 this.hide(false); | 109 this.hide(false); |
| 109 event.consume(true); | 110 event.consume(true); |
| 110 } | 111 } |
| 111 } | 112 } |
| 112 }; | 113 }; |
| OLD | NEW |