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 Polymer({ | 5 Polymer({ |
6 is: 'cr-action-menu', | 6 is: 'cr-action-menu', |
7 extends: 'dialog', | 7 extends: 'dialog', |
8 | 8 |
9 /** | 9 /** |
10 * List of all options in this action menu. | 10 * List of all options in this action menu. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } while (!nextOption && counter < numOptions); | 144 } while (!nextOption && counter < numOptions); |
145 | 145 |
146 return nextOption; | 146 return nextOption; |
147 }, | 147 }, |
148 | 148 |
149 /** @override */ | 149 /** @override */ |
150 close: function() { | 150 close: function() { |
151 // Removing 'resize' and 'popstate' listeners when dialog is closed. | 151 // Removing 'resize' and 'popstate' listeners when dialog is closed. |
152 this.removeListeners_(); | 152 this.removeListeners_(); |
153 HTMLDialogElement.prototype.close.call(this); | 153 HTMLDialogElement.prototype.close.call(this); |
154 this.anchorElement_.focus(); | 154 cr.ui.focusWithoutInk(assert(this.anchorElement_)); |
155 this.anchorElement_ = null; | 155 this.anchorElement_ = null; |
156 }, | 156 }, |
157 | 157 |
158 /** | 158 /** |
159 * Shows the menu anchored to the given element. | 159 * Shows the menu anchored to the given element. |
160 * @param {!Element} anchorElement | 160 * @param {!Element} anchorElement |
161 */ | 161 */ |
162 showAt: function(anchorElement) { | 162 showAt: function(anchorElement) { |
163 this.anchorElement_ = anchorElement; | 163 this.anchorElement_ = anchorElement; |
164 this.boundClose_ = this.boundClose_ || function() { | 164 this.boundClose_ = this.boundClose_ || function() { |
(...skipping 23 matching lines...) Expand all Loading... |
188 // Attempt to show the menu starting from the top of the rectangle and | 188 // Attempt to show the menu starting from the top of the rectangle and |
189 // extending downwards. If that does not fit within the window, fallback to | 189 // extending downwards. If that does not fit within the window, fallback to |
190 // starting from the bottom and extending upwards. | 190 // starting from the bottom and extending upwards. |
191 var top = rect.top + this.offsetHeight <= window.innerHeight ? rect.top : | 191 var top = rect.top + this.offsetHeight <= window.innerHeight ? rect.top : |
192 rect.bottom - | 192 rect.bottom - |
193 this.offsetHeight - Math.max(rect.bottom - window.innerHeight, 0); | 193 this.offsetHeight - Math.max(rect.bottom - window.innerHeight, 0); |
194 | 194 |
195 this.style.top = top + 'px'; | 195 this.style.top = top + 'px'; |
196 }, | 196 }, |
197 }); | 197 }); |
OLD | NEW |