| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 6 |
| 7 /** @const */ var MenuItem = cr.ui.MenuItem; | 7 /** @const */ var MenuItem = cr.ui.MenuItem; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Creates a new menu element. | 10 * Creates a new menu element. |
| 11 * @param {Object=} opt_propertyBag Optional properties. | 11 * @param {Object=} opt_propertyBag Optional properties. |
| 12 * @constructor | 12 * @constructor |
| 13 * @extends {HTMLMenuElement} | 13 * @extends {HTMLMenuElement} |
| 14 */ | 14 */ |
| 15 var Menu = cr.ui.define('menu'); | 15 var Menu = cr.ui.define('menu'); |
| 16 | 16 |
| 17 Menu.prototype = { | 17 Menu.prototype = { |
| 18 __proto__: HTMLMenuElement.prototype, | 18 __proto__: HTMLMenuElement.prototype, |
| 19 | 19 |
| 20 selectedIndex_: -1, | 20 selectedIndex_: -1, |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Initializes the menu element. | 23 * Initializes the menu element. |
| 24 */ | 24 */ |
| 25 decorate: function() { | 25 decorate: function() { |
| 26 this.addEventListener('mouseover', this.handleMouseOver_); | 26 this.addEventListener('mouseover', this.handleMouseOver_); |
| 27 this.addEventListener('mouseout', this.handleMouseOut_); | 27 this.addEventListener('mouseout', this.handleMouseOut_); |
| 28 | 28 |
| 29 this.hidden = true; // Hide the menu by default. |
| 30 |
| 29 // Decorate the children as menu items. | 31 // Decorate the children as menu items. |
| 30 var children = this.children; | 32 var children = this.children; |
| 31 for (var i = 0, child; child = children[i]; i++) { | 33 for (var i = 0, child; child = children[i]; i++) { |
| 32 cr.ui.decorate(child, MenuItem); | 34 cr.ui.decorate(child, MenuItem); |
| 33 } | 35 } |
| 34 }, | 36 }, |
| 35 | 37 |
| 36 /** | 38 /** |
| 37 * Walks up the ancestors of |el| until a menu item belonging to this menu | 39 * Walks up the ancestors of |el| until a menu item belonging to this menu |
| 38 * is found. | 40 * is found. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 * @type {number} | 143 * @type {number} |
| 142 */ | 144 */ |
| 143 cr.defineProperty(Menu, 'selectedIndex', cr.PropertyKind.JS, | 145 cr.defineProperty(Menu, 'selectedIndex', cr.PropertyKind.JS, |
| 144 selectedIndexChanged); | 146 selectedIndexChanged); |
| 145 | 147 |
| 146 // Export | 148 // Export |
| 147 return { | 149 return { |
| 148 Menu: Menu | 150 Menu: Menu |
| 149 }; | 151 }; |
| 150 }); | 152 }); |
| OLD | NEW |