OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 A drop-down menu in the ChromeVox panel. | 6 * @fileoverview A drop-down menu in the ChromeVox panel. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('PanelMenu'); | 9 goog.provide('PanelMenu'); |
10 goog.provide('PanelNodeMenu'); | 10 goog.provide('PanelNodeMenu'); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 if (delta >= 0) | 162 if (delta >= 0) |
163 this.activeIndex_ = 0; | 163 this.activeIndex_ = 0; |
164 else | 164 else |
165 this.activeIndex_ = this.menus_.length - 1; | 165 this.activeIndex_ = this.menus_.length - 1; |
166 } | 166 } |
167 | 167 |
168 this.items_[this.activeIndex_].element.focus(); | 168 this.items_[this.activeIndex_].element.focus(); |
169 }, | 169 }, |
170 | 170 |
171 /** | 171 /** |
| 172 * Sets the active menu item index to be 0. |
| 173 */ |
| 174 scrollToTop: function() { |
| 175 this.activeIndex_ = 0; |
| 176 this.items_[this.activeIndex_].element.focus(); |
| 177 }, |
| 178 |
| 179 /** |
| 180 * Sets the active menu item index to be the last index. |
| 181 */ |
| 182 scrollToBottom: function() { |
| 183 this.activeIndex_ = this.items_.length - 1; |
| 184 this.items_[this.activeIndex_].element.focus(); |
| 185 }, |
| 186 |
| 187 /** |
172 * Get the callback for the active menu item. | 188 * Get the callback for the active menu item. |
173 * @return {Function} The callback. | 189 * @return {Function} The callback. |
174 */ | 190 */ |
175 getCallbackForCurrentItem: function() { | 191 getCallbackForCurrentItem: function() { |
176 if (this.activeIndex_ >= 0 && this.activeIndex_ < this.items_.length) { | 192 if (this.activeIndex_ >= 0 && this.activeIndex_ < this.items_.length) { |
177 return this.items_[this.activeIndex_].callback; | 193 return this.items_[this.activeIndex_].callback; |
178 } | 194 } |
179 return null; | 195 return null; |
180 }, | 196 }, |
181 | 197 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 PanelNodeMenu.prototype = { | 265 PanelNodeMenu.prototype = { |
250 __proto__: PanelMenu.prototype, | 266 __proto__: PanelMenu.prototype, |
251 | 267 |
252 /** @override */ | 268 /** @override */ |
253 activate: function() { | 269 activate: function() { |
254 var activeItem = this.activeIndex_; | 270 var activeItem = this.activeIndex_; |
255 PanelMenu.prototype.activate.call(this); | 271 PanelMenu.prototype.activate.call(this); |
256 this.activateItem(activeItem); | 272 this.activateItem(activeItem); |
257 } | 273 } |
258 }; | 274 }; |
OLD | NEW |