| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('cr.ui', function() { | 5 cr.define('cr.ui', function() { |
| 6 const Menu = cr.ui.Menu; | 6 const Menu = cr.ui.Menu; |
| 7 const positionPopupAroundElement = cr.ui.positionPopupAroundElement; | 7 const positionPopupAroundElement = cr.ui.positionPopupAroundElement; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Creates a new menu button element. | 10 * Creates a new menu button element. |
| 11 * @param {Object=} opt_propertyBag Optional properties. | 11 * @param {Object=} opt_propertyBag Optional properties. |
| 12 * @constructor | 12 * @constructor |
| 13 * @extends {HTMLButtonElement} | 13 * @extends {HTMLButtonElement} |
| 14 */ | 14 */ |
| 15 var MenuButton = cr.ui.define('button'); | 15 var MenuButton = cr.ui.define('button'); |
| 16 | 16 |
| 17 MenuButton.prototype = { | 17 MenuButton.prototype = { |
| 18 __proto__: HTMLButtonElement.prototype, | 18 __proto__: HTMLButtonElement.prototype, |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Initializes the menu button. | 21 * Initializes the menu button. |
| 22 */ | 22 */ |
| 23 decorate: function() { | 23 decorate: function() { |
| 24 this.addEventListener('mousedown', this); | 24 this.addEventListener('mousedown', this); |
| 25 this.addEventListener('keydown', this); | 25 this.addEventListener('keydown', this); |
| 26 | 26 |
| 27 // Adding the 'custom-appearance' class prevents button.css from changing | 27 // Adding the 'custom-appearance' class prevents widgets.css from changing |
| 28 // the appearance of this element. | 28 // the appearance of this element. |
| 29 this.classList.add('custom-appearance'); | 29 this.classList.add('custom-appearance'); |
| 30 | 30 |
| 31 var menu; | 31 var menu; |
| 32 if ((menu = this.getAttribute('menu'))) | 32 if ((menu = this.getAttribute('menu'))) |
| 33 this.menu = menu; | 33 this.menu = menu; |
| 34 | 34 |
| 35 // An event tracker for events we only connect to while the menu is | 35 // An event tracker for events we only connect to while the menu is |
| 36 // displayed. | 36 // displayed. |
| 37 this.showingEvents_ = new EventTracker(); | 37 this.showingEvents_ = new EventTracker(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 break; | 175 break; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 // Export | 180 // Export |
| 181 return { | 181 return { |
| 182 MenuButton: MenuButton | 182 MenuButton: MenuButton |
| 183 }; | 183 }; |
| 184 }); | 184 }); |
| OLD | NEW |