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 /** @const */ | 6 /** @const */ |
7 var Menu = cr.ui.Menu; | 7 var Menu = cr.ui.Menu; |
8 /** @const */ | 8 /** @const */ |
9 var positionPopupAroundElement = cr.ui.positionPopupAroundElement; | 9 var positionPopupAroundElement = cr.ui.positionPopupAroundElement; |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 break; | 106 break; |
107 } | 107 } |
108 }, | 108 }, |
109 | 109 |
110 /** | 110 /** |
111 * Shows the menu. | 111 * Shows the menu. |
112 */ | 112 */ |
113 showMenu: function() { | 113 showMenu: function() { |
114 this.hideMenu(); | 114 this.hideMenu(); |
115 | 115 |
116 this.menu.style.display = 'block'; | 116 this.menu.hidden = false; |
117 this.setAttribute('menu-shown', ''); | 117 this.setAttribute('menu-shown', ''); |
118 | 118 |
119 // when the menu is shown we steal all keyboard events. | 119 // when the menu is shown we steal all keyboard events. |
120 var doc = this.ownerDocument; | 120 var doc = this.ownerDocument; |
121 var win = doc.defaultView; | 121 var win = doc.defaultView; |
122 this.showingEvents_.add(doc, 'keydown', this, true); | 122 this.showingEvents_.add(doc, 'keydown', this, true); |
123 this.showingEvents_.add(doc, 'mousedown', this, true); | 123 this.showingEvents_.add(doc, 'mousedown', this, true); |
124 this.showingEvents_.add(doc, 'blur', this, true); | 124 this.showingEvents_.add(doc, 'blur', this, true); |
125 this.showingEvents_.add(win, 'resize', this); | 125 this.showingEvents_.add(win, 'resize', this); |
126 this.showingEvents_.add(this.menu, 'activate', this); | 126 this.showingEvents_.add(this.menu, 'activate', this); |
127 this.positionMenu_(); | 127 this.positionMenu_(); |
128 }, | 128 }, |
129 | 129 |
130 /** | 130 /** |
131 * Hides the menu. If your menu can go out of scope, make sure to call this | 131 * Hides the menu. If your menu can go out of scope, make sure to call this |
132 * first. | 132 * first. |
133 */ | 133 */ |
134 hideMenu: function() { | 134 hideMenu: function() { |
135 if (!this.isMenuShown()) | 135 if (!this.isMenuShown()) |
136 return; | 136 return; |
137 | 137 |
138 this.removeAttribute('menu-shown'); | 138 this.removeAttribute('menu-shown'); |
139 this.menu.style.display = 'none'; | 139 this.menu.hidden = true; |
140 | 140 |
141 this.showingEvents_.removeAll(); | 141 this.showingEvents_.removeAll(); |
142 this.menu.selectedIndex = -1; | 142 this.menu.selectedIndex = -1; |
143 }, | 143 }, |
144 | 144 |
145 /** | 145 /** |
146 * Whether the menu is shown. | 146 * Whether the menu is shown. |
147 */ | 147 */ |
148 isMenuShown: function() { | 148 isMenuShown: function() { |
149 return this.hasAttribute('menu-shown'); | 149 return this.hasAttribute('menu-shown'); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, hoverColor); | 224 'drop-down-arrow-hover', ARROW_WIDTH, ARROW_HEIGHT, hoverColor); |
225 createDropDownArrowCanvas( | 225 createDropDownArrowCanvas( |
226 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, activeColor); | 226 'drop-down-arrow-active', ARROW_WIDTH, ARROW_HEIGHT, activeColor); |
227 } | 227 } |
228 | 228 |
229 // Export | 229 // Export |
230 return { | 230 return { |
231 MenuButton: MenuButton | 231 MenuButton: MenuButton |
232 }; | 232 }; |
233 }); | 233 }); |
OLD | NEW |