| 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 {Function} callback The function to call if this item is selected. | 15 * @param {Function} callback The function to call if this item is selected. |
| 15 * @constructor | 16 * @constructor |
| 16 */ | 17 */ |
| 17 PanelMenuItem = function(menuItemTitle, menuItemShortcut, callback) { | 18 PanelMenuItem = function( |
| 19 menuItemTitle, menuItemShortcut, menuItemBraille, callback) { |
| 18 this.callback = callback; | 20 this.callback = callback; |
| 19 | 21 |
| 20 this.element = document.createElement('tr'); | 22 this.element = document.createElement('tr'); |
| 21 this.element.className = 'menu-item'; | 23 this.element.className = 'menu-item'; |
| 22 this.element.tabIndex = -1; | 24 this.element.tabIndex = -1; |
| 23 this.element.setAttribute('role', 'menuitem'); | 25 this.element.setAttribute('role', 'menuitem'); |
| 24 | 26 |
| 25 this.element.addEventListener('mouseover', (function(evt) { | 27 this.element.addEventListener('mouseover', (function(evt) { |
| 26 this.element.focus(); | 28 this.element.focus(); |
| 27 }).bind(this), false); | 29 }).bind(this), false); |
| 28 | 30 |
| 29 var title = document.createElement('td'); | 31 var title = document.createElement('td'); |
| 30 title.className = 'menu-item-title'; | 32 title.className = 'menu-item-title'; |
| 31 title.textContent = menuItemTitle; | 33 title.textContent = menuItemTitle; |
| 32 this.element.appendChild(title); | 34 this.element.appendChild(title); |
| 33 | 35 |
| 34 var shortcut = document.createElement('td'); | 36 var shortcut = document.createElement('td'); |
| 35 shortcut.className = 'menu-item-shortcut'; | 37 shortcut.className = 'menu-item-shortcut'; |
| 36 shortcut.textContent = menuItemShortcut; | 38 shortcut.textContent = menuItemShortcut; |
| 37 this.element.appendChild(shortcut); | 39 this.element.appendChild(shortcut); |
| 40 |
| 41 if (localStorage['brailleCaptions'] === String(true)) { |
| 42 var braille = document.createElement('td'); |
| 43 braille.className = 'menu-item-shortcut'; |
| 44 braille.textContent = menuItemBraille; |
| 45 this.element.appendChild(braille); |
| 46 } |
| 38 }; | 47 }; |
| 39 | 48 |
| 40 PanelMenuItem.prototype = { | 49 PanelMenuItem.prototype = { |
| 41 get text() { | 50 get text() { |
| 42 return this.element.textContent; | 51 return this.element.textContent; |
| 43 } | 52 } |
| 44 }; | 53 }; |
| OLD | NEW |