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 An item in a drop-down menu in the ChromeVox panel. | 6 * @fileoverview An item in a drop-down menu in the ChromeVox panel. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('PanelMenuItem'); | 9 goog.provide('PanelMenuItem'); |
10 | 10 |
11 /** | 11 /** |
12 * @param {string} menuItemTitle The title of the menu item. | 12 * @param {string} menuItemTitle The title of the menu item. |
13 * @param {string} menuItemShortcut The keystrokes to select this item. | 13 * @param {string} menuItemShortcut The keystrokes to select this item. |
14 * @param {string} menuItemBraille The braille keystrokes to select this item. | 14 * @param {string} menuItemBraille The braille keystrokes to select this item. |
15 * @param {Function} callback The function to call if this item is selected. | 15 * @param {Function} callback The function to call if this item is selected. |
16 * @constructor | 16 * @constructor |
17 */ | 17 */ |
18 PanelMenuItem = function( | 18 PanelMenuItem = function( |
19 menuItemTitle, menuItemShortcut, menuItemBraille, callback) { | 19 menuItemTitle, menuItemShortcut, menuItemBraille, callback) { |
20 this.callback = callback; | 20 this.callback = callback; |
21 | 21 |
22 this.element = document.createElement('tr'); | 22 this.element = document.createElement('tr'); |
23 this.element.className = 'menu-item'; | 23 this.element.className = 'menu-item'; |
24 this.element.tabIndex = -1; | 24 this.element.tabIndex = -1; |
25 this.element.setAttribute('role', 'menuitem'); | 25 this.element.setAttribute('role', 'menuitem'); |
26 | 26 |
27 this.element.addEventListener('mouseover', (function(evt) { | 27 this.element.addEventListener( |
28 this.element.focus(); | 28 'mouseover', (function(evt) { |
29 }).bind(this), false); | 29 this.element.focus(); |
| 30 }).bind(this), |
| 31 false); |
30 | 32 |
31 var title = document.createElement('td'); | 33 var title = document.createElement('td'); |
32 title.className = 'menu-item-title'; | 34 title.className = 'menu-item-title'; |
33 title.textContent = menuItemTitle; | 35 title.textContent = menuItemTitle; |
34 | 36 |
35 // Tooltip in case the menu item is cut off. | 37 // Tooltip in case the menu item is cut off. |
36 title.title = menuItemTitle; | 38 title.title = menuItemTitle; |
37 this.element.appendChild(title); | 39 this.element.appendChild(title); |
38 | 40 |
39 var shortcut = document.createElement('td'); | 41 var shortcut = document.createElement('td'); |
40 shortcut.className = 'menu-item-shortcut'; | 42 shortcut.className = 'menu-item-shortcut'; |
41 shortcut.textContent = menuItemShortcut; | 43 shortcut.textContent = menuItemShortcut; |
42 this.element.appendChild(shortcut); | 44 this.element.appendChild(shortcut); |
43 | 45 |
44 if (localStorage['brailleCaptions'] === String(true)) { | 46 if (localStorage['brailleCaptions'] === String(true)) { |
45 var braille = document.createElement('td'); | 47 var braille = document.createElement('td'); |
46 braille.className = 'menu-item-shortcut'; | 48 braille.className = 'menu-item-shortcut'; |
47 braille.textContent = menuItemBraille; | 49 braille.textContent = menuItemBraille; |
48 this.element.appendChild(braille); | 50 this.element.appendChild(braille); |
49 } | 51 } |
50 }; | 52 }; |
51 | 53 |
52 PanelMenuItem.prototype = { | 54 PanelMenuItem.prototype = { |
53 get text() { | 55 get text() { |
54 return this.element.textContent; | 56 return this.element.textContent; |
55 } | 57 } |
56 }; | 58 }; |
OLD | NEW |