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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Class representing a menu button and its associated menu items. | 7 * Class representing a menu button and its associated menu items. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 }; | 63 }; |
64 | 64 |
65 /** | 65 /** |
66 * @type {function(Event):void} | 66 * @type {function(Event):void} |
67 * @private | 67 * @private |
68 */ | 68 */ |
69 var onClick = function(event) { | 69 var onClick = function(event) { |
70 if (that.onShow_) { | 70 if (that.onShow_) { |
71 that.onShow_(); | 71 that.onShow_(); |
72 } | 72 } |
73 that.button_.classList.toggle(remoting.MenuButton.BUTTON_ACTIVE_CLASS_); | 73 that.button_.classList.add(remoting.MenuButton.BUTTON_ACTIVE_CLASS_); |
74 document.body.addEventListener('click', closeHandler, false); | 74 document.body.addEventListener('click', closeHandler, false); |
75 event.stopPropagation(); | 75 event.stopPropagation(); |
76 }; | 76 }; |
77 | 77 |
78 this.button_.addEventListener('click', onClick, false); | 78 this.button_.addEventListener('click', onClick, false); |
79 }; | 79 }; |
80 | 80 |
81 /** | 81 /** |
82 * @return {HTMLElement} The button that activates the menu. | 82 * @return {HTMLElement} The button that activates the menu. |
83 */ | 83 */ |
(...skipping 17 matching lines...) Expand all Loading... |
101 remoting.MenuButton.select = function(item, selected) { | 101 remoting.MenuButton.select = function(item, selected) { |
102 if (selected) { | 102 if (selected) { |
103 /** @type {DOMTokenList} */(item.classList).add('selected'); | 103 /** @type {DOMTokenList} */(item.classList).add('selected'); |
104 } else { | 104 } else { |
105 /** @type {DOMTokenList} */(item.classList).remove('selected'); | 105 /** @type {DOMTokenList} */(item.classList).remove('selected'); |
106 } | 106 } |
107 }; | 107 }; |
108 | 108 |
109 /** @const @private */ | 109 /** @const @private */ |
110 remoting.MenuButton.BUTTON_ACTIVE_CLASS_ = 'active'; | 110 remoting.MenuButton.BUTTON_ACTIVE_CLASS_ = 'active'; |
OLD | NEW |