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. Menu dispatches all commands on the element it | 10 * Creates a new menu element. Menu dispatches all commands on the element it |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 }, | 81 }, |
82 | 82 |
83 /** | 83 /** |
84 * Walks up the ancestors of |node| until a menu item belonging to this menu | 84 * Walks up the ancestors of |node| until a menu item belonging to this menu |
85 * is found. | 85 * is found. |
86 * @param {Node} node The node to start searching from. | 86 * @param {Node} node The node to start searching from. |
87 * @return {cr.ui.MenuItem} The found menu item or null. | 87 * @return {cr.ui.MenuItem} The found menu item or null. |
88 * @private | 88 * @private |
89 */ | 89 */ |
90 findMenuItem_: function(node) { | 90 findMenuItem_: function(node) { |
91 while (node && node.parentNode != this) { | 91 while (node && node.parentNode != this && !(node instanceof MenuItem)) { |
92 node = node.parentNode; | 92 node = node.parentNode; |
93 } | 93 } |
94 return node ? assertInstanceof(node, MenuItem) : null; | 94 return node ? assertInstanceof(node, MenuItem) : null; |
95 }, | 95 }, |
96 | 96 |
97 /** | 97 /** |
98 * Handles mouseover events and selects the hovered item. | 98 * Handles mouseover events and selects the hovered item. |
99 * @param {Event} e The mouseover event. | 99 * @param {Event} e The mouseover event. |
100 * @private | 100 * @private |
101 */ | 101 */ |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 /** | 273 /** |
274 * Selector for children which are menu items. | 274 * Selector for children which are menu items. |
275 */ | 275 */ |
276 cr.defineProperty(Menu, 'menuItemSelector', cr.PropertyKind.ATTR); | 276 cr.defineProperty(Menu, 'menuItemSelector', cr.PropertyKind.ATTR); |
277 | 277 |
278 // Export | 278 // Export |
279 return { | 279 return { |
280 Menu: Menu | 280 Menu: Menu |
281 }; | 281 }; |
282 }); | 282 }); |
OLD | NEW |