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 // <include src="../../assert.js"> | 5 // <include src="../../assert.js"> |
6 | 6 |
7 cr.exportPath('cr.ui'); | 7 cr.exportPath('cr.ui'); |
8 | 8 |
9 /** | 9 /** |
10 * Enum for type of hide. Delayed is used when called by clicking on a | 10 * Enum for type of hide. Delayed is used when called by clicking on a |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 this.showingEvents_ = new EventTracker(); | 60 this.showingEvents_ = new EventTracker(); |
61 | 61 |
62 this.anchorType = cr.ui.AnchorType.BELOW; | 62 this.anchorType = cr.ui.AnchorType.BELOW; |
63 this.invertLeftRight = false; | 63 this.invertLeftRight = false; |
64 }, | 64 }, |
65 | 65 |
66 /** | 66 /** |
67 * The menu associated with the menu button. | 67 * The menu associated with the menu button. |
68 * @type {cr.ui.Menu} | 68 * @type {cr.ui.Menu} |
69 */ | 69 */ |
70 get menu() { return this.menu_; }, | 70 get menu() { |
| 71 return this.menu_; |
| 72 }, |
71 set menu(menu) { | 73 set menu(menu) { |
72 if (typeof menu == 'string' && menu[0] == '#') { | 74 if (typeof menu == 'string' && menu[0] == '#') { |
73 menu = assert(this.ownerDocument.getElementById(menu.slice(1))); | 75 menu = assert(this.ownerDocument.getElementById(menu.slice(1))); |
74 cr.ui.decorate(menu, Menu); | 76 cr.ui.decorate(menu, Menu); |
75 } | 77 } |
76 | 78 |
77 this.menu_ = menu; | 79 this.menu_ = menu; |
78 if (menu) { | 80 if (menu) { |
79 if (menu.id) | 81 if (menu.id) |
80 this.setAttribute('menu', '#' + menu.id); | 82 this.setAttribute('menu', '#' + menu.id); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 235 |
234 // On windows we might hide the menu in a right mouse button up and if | 236 // On windows we might hide the menu in a right mouse button up and if |
235 // that is the case we wait some short period before we allow the menu | 237 // that is the case we wait some short period before we allow the menu |
236 // to be shown again. | 238 // to be shown again. |
237 this.hideTimestamp_ = cr.isWindows ? Date.now() : 0; | 239 this.hideTimestamp_ = cr.isWindows ? Date.now() : 0; |
238 }, | 240 }, |
239 | 241 |
240 /** | 242 /** |
241 * Whether the menu is shown. | 243 * Whether the menu is shown. |
242 */ | 244 */ |
243 isMenuShown: function() { return this.hasAttribute('menu-shown'); }, | 245 isMenuShown: function() { |
| 246 return this.hasAttribute('menu-shown'); |
| 247 }, |
244 | 248 |
245 /** | 249 /** |
246 * Positions the menu below the menu button. At this point we do not use any | 250 * Positions the menu below the menu button. At this point we do not use any |
247 * advanced positioning logic to ensure the menu fits in the viewport. | 251 * advanced positioning logic to ensure the menu fits in the viewport. |
248 * @private | 252 * @private |
249 */ | 253 */ |
250 positionMenu_: function() { | 254 positionMenu_: function() { |
251 positionPopupAroundElement( | 255 positionPopupAroundElement( |
252 this, this.menu, this.anchorType, this.invertLeftRight); | 256 this, this.menu, this.anchorType, this.invertLeftRight); |
253 }, | 257 }, |
(...skipping 19 matching lines...) Expand all Loading... |
273 break; | 277 break; |
274 } | 278 } |
275 } | 279 } |
276 }; | 280 }; |
277 | 281 |
278 // Export | 282 // Export |
279 return { | 283 return { |
280 MenuButton: MenuButton, | 284 MenuButton: MenuButton, |
281 }; | 285 }; |
282 }); | 286 }); |
OLD | NEW |