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 26 matching lines...) Expand all Loading... | |
37 | 37 |
38 MenuButton.prototype = { | 38 MenuButton.prototype = { |
39 __proto__: HTMLButtonElement.prototype, | 39 __proto__: HTMLButtonElement.prototype, |
40 | 40 |
41 /** | 41 /** |
42 * Initializes the menu button. | 42 * Initializes the menu button. |
43 */ | 43 */ |
44 decorate: function() { | 44 decorate: function() { |
45 this.addEventListener('mousedown', this); | 45 this.addEventListener('mousedown', this); |
46 this.addEventListener('keydown', this); | 46 this.addEventListener('keydown', this); |
47 this.addEventListener('dblclick', this); | |
47 | 48 |
48 // Adding the 'custom-appearance' class prevents widgets.css from changing | 49 // Adding the 'custom-appearance' class prevents widgets.css from changing |
49 // the appearance of this element. | 50 // the appearance of this element. |
50 this.classList.add('custom-appearance'); | 51 this.classList.add('custom-appearance'); |
51 this.classList.add('menu-button'); // For styles in menu_button.css. | 52 this.classList.add('menu-button'); // For styles in menu_button.css. |
52 | 53 |
53 var menu; | 54 var menu; |
54 if ((menu = this.getAttribute('menu'))) | 55 if ((menu = this.getAttribute('menu'))) |
55 this.menu = menu; | 56 this.menu = menu; |
56 | 57 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 this.hideMenu(hideDelayed ? HideType.DELAYED : HideType.INSTANT); | 148 this.hideMenu(hideDelayed ? HideType.DELAYED : HideType.INSTANT); |
148 break; | 149 break; |
149 case 'scroll': | 150 case 'scroll': |
150 if (!(e.target == this.menu || this.menu.contains(e.target))) | 151 if (!(e.target == this.menu || this.menu.contains(e.target))) |
151 this.hideMenu(); | 152 this.hideMenu(); |
152 break; | 153 break; |
153 case 'popstate': | 154 case 'popstate': |
154 case 'resize': | 155 case 'resize': |
155 this.hideMenu(); | 156 this.hideMenu(); |
156 break; | 157 break; |
158 case 'dblclick': | |
Bernhard Bauer
2015/04/21 15:54:47
Can you add a comment like "Don't allow double cli
Deepak
2015/04/22 04:14:25
Done.
| |
159 e.preventDefault(); | |
160 e.stopPropagation(); | |
161 break; | |
157 } | 162 } |
158 }, | 163 }, |
159 | 164 |
160 /** | 165 /** |
161 * Shows the menu. | 166 * Shows the menu. |
162 * @param {boolean} shouldSetFocus Whether to set focus on the | 167 * @param {boolean} shouldSetFocus Whether to set focus on the |
163 * selected menu item. | 168 * selected menu item. |
164 */ | 169 */ |
165 showMenu: function(shouldSetFocus) { | 170 showMenu: function(shouldSetFocus) { |
166 this.hideMenu(); | 171 this.hideMenu(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, opt_hoverColor); | 304 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, opt_hoverColor); |
300 createDropDownArrowCanvas( | 305 createDropDownArrowCanvas( |
301 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, opt_activeColor); | 306 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, opt_activeColor); |
302 }; | 307 }; |
303 | 308 |
304 // Export | 309 // Export |
305 return { | 310 return { |
306 MenuButton: MenuButton, | 311 MenuButton: MenuButton, |
307 }; | 312 }; |
308 }); | 313 }); |
OLD | NEW |