| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 The ChromeVox panel and menus. | 6 * @fileoverview The ChromeVox panel and menus. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('Panel'); | 9 goog.provide('Panel'); |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 this.brailleContainer_ = $('braille-container'); | 38 this.brailleContainer_ = $('braille-container'); |
| 39 | 39 |
| 40 /** @type {Element} @private */ | 40 /** @type {Element} @private */ |
| 41 this.searchContainer_ = $('search-container'); | 41 this.searchContainer_ = $('search-container'); |
| 42 | 42 |
| 43 /** @type {Element} @private */ | 43 /** @type {Element} @private */ |
| 44 this.searchInput_ = $('search'); | 44 this.searchInput_ = $('search'); |
| 45 | 45 |
| 46 /** @type {Element} @private */ | 46 /** @type {Element} @private */ |
| 47 this.brailleTableElement_ = $('braille-table'); | 47 this.brailleTableElement_ = $('braille-table'); |
| 48 this.brailleTableElement2_ = $('braille-table2'); |
| 48 | 49 |
| 49 /** | 50 /** |
| 50 * The array of top-level menus. | 51 * The array of top-level menus. |
| 51 * @type {!Array<PanelMenu>} | 52 * @type {!Array<PanelMenu>} |
| 52 * @private | 53 * @private |
| 53 */ | 54 */ |
| 54 this.menus_ = []; | 55 this.menus_ = []; |
| 55 | 56 |
| 56 /** | 57 /** |
| 57 * The currently active menu, if any. | 58 * The currently active menu, if any. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 escapeForHtml(command.data) + | 178 escapeForHtml(command.data) + |
| 178 '</span>'; | 179 '</span>'; |
| 179 break; | 180 break; |
| 180 case PanelCommandType.ADD_ANNOTATION_SPEECH: | 181 case PanelCommandType.ADD_ANNOTATION_SPEECH: |
| 181 if (this.speechElement_.innerHTML != '') { | 182 if (this.speechElement_.innerHTML != '') { |
| 182 this.speechElement_.innerHTML += ' '; | 183 this.speechElement_.innerHTML += ' '; |
| 183 } | 184 } |
| 184 this.speechElement_.innerHTML += escapeForHtml(command.data); | 185 this.speechElement_.innerHTML += escapeForHtml(command.data); |
| 185 break; | 186 break; |
| 186 case PanelCommandType.UPDATE_BRAILLE: | 187 case PanelCommandType.UPDATE_BRAILLE: |
| 187 var groups = command.data.groups; | 188 Panel.onUpdateBraille(command.data); |
| 188 this.brailleTableElement_.deleteRow(0); | |
| 189 this.brailleTableElement_.deleteRow(0); | |
| 190 var row1 = this.brailleTableElement_.insertRow(-1); | |
| 191 var row2 = this.brailleTableElement_.insertRow(-1); | |
| 192 | |
| 193 for (var i = 0; i < groups.length; i++) { | |
| 194 var topCell = row1.insertCell(-1); | |
| 195 var bottomCell = row2.insertCell(-1); | |
| 196 topCell.innerHTML = groups[i][0]; | |
| 197 bottomCell.innerHTML = groups[i][1]; | |
| 198 } | |
| 199 | |
| 200 break; | 189 break; |
| 201 case PanelCommandType.ENABLE_MENUS: | 190 case PanelCommandType.ENABLE_MENUS: |
| 202 Panel.onEnableMenus(); | 191 Panel.onEnableMenus(); |
| 203 break; | 192 break; |
| 204 case PanelCommandType.DISABLE_MENUS: | 193 case PanelCommandType.DISABLE_MENUS: |
| 205 Panel.onDisableMenus(); | 194 Panel.onDisableMenus(); |
| 206 break; | 195 break; |
| 207 case PanelCommandType.OPEN_MENUS: | 196 case PanelCommandType.OPEN_MENUS: |
| 208 Panel.onOpenMenus(undefined, command.data); | 197 Panel.onOpenMenus(undefined, command.data); |
| 209 break; | 198 break; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 $('menu-bar').appendChild(menu.menuBarItemElement); | 396 $('menu-bar').appendChild(menu.menuBarItemElement); |
| 408 menu.menuBarItemElement.addEventListener('mouseover', function() { | 397 menu.menuBarItemElement.addEventListener('mouseover', function() { |
| 409 Panel.activateMenu(menu); | 398 Panel.activateMenu(menu); |
| 410 }, false); | 399 }, false); |
| 411 | 400 |
| 412 $('menus_background').appendChild(menu.menuContainerElement); | 401 $('menus_background').appendChild(menu.menuContainerElement); |
| 413 this.menus_.push(menu); | 402 this.menus_.push(menu); |
| 414 return menu; | 403 return menu; |
| 415 }; | 404 }; |
| 416 | 405 |
| 406 /** |
| 407 * Updates the content shown on the virtual braille display. |
| 408 * @param {*=} data The data sent through the PanelCommand. |
| 409 */ |
| 410 Panel.onUpdateBraille = function(data) { |
| 411 var groups = data.groups; |
| 412 var cols = parseInt(localStorage['virtualBrailleColumns'], 10); |
| 413 var rows = parseInt(localStorage['virtualBrailleRows'], 10); |
| 414 var sideBySide = localStorage['brailleSideBySide'] === 'true'; |
| 415 |
| 416 var addBorders = function(event) { |
| 417 var cell = event.target; |
| 418 if (cell.tagName == 'TD') { |
| 419 cell.className = 'highlighted-cell'; |
| 420 var companionID = cell.getAttribute('companionID'); |
| 421 var companion = $(companionID); |
| 422 companion.className = 'highlighted-cell'; |
| 423 } |
| 424 }; |
| 425 |
| 426 var removeBorders = function(event) { |
| 427 var cell = event.target; |
| 428 if (cell.tagName == 'TD') { |
| 429 cell.className = 'unhighlighted-cell'; |
| 430 var companionID = cell.getAttribute('companionID'); |
| 431 var companion = $(companionID); |
| 432 companion.className = 'unhighlighted-cell'; |
| 433 } |
| 434 }; |
| 435 |
| 436 this.brailleContainer_.addEventListener('mouseover', addBorders); |
| 437 this.brailleContainer_.addEventListener('mouseout', removeBorders); |
| 438 |
| 439 // Clear the tables. |
| 440 var rowCount = this.brailleTableElement_.rows.length; |
| 441 for (var i = 0; i < rowCount; i++) { |
| 442 this.brailleTableElement_.deleteRow(0); |
| 443 } |
| 444 rowCount = this.brailleTableElement2_.rows.length; |
| 445 for (var i = 0; i < rowCount; i++) { |
| 446 this.brailleTableElement2_.deleteRow(0); |
| 447 } |
| 448 |
| 449 var row1, row2; |
| 450 rowCount = 0; |
| 451 for (var i = 0; i < groups.length; i++) { |
| 452 if (i % cols == 0) { |
| 453 // Check if we reached the limit on the number of rows we can have. |
| 454 if (rowCount == rows) |
| 455 break; |
| 456 rowCount++; |
| 457 row1 = this.brailleTableElement_.insertRow(-1); |
| 458 if (sideBySide) { |
| 459 // Side by side. |
| 460 row2 = this.brailleTableElement2_.insertRow(-1); |
| 461 } else { |
| 462 // Interleaved. |
| 463 row2 = this.brailleTableElement_.insertRow(-1); |
| 464 } |
| 465 } |
| 466 |
| 467 var topCell = row1.insertCell(-1); |
| 468 topCell.innerHTML = groups[i][0]; |
| 469 topCell.id = i + '-textCell'; |
| 470 topCell.setAttribute('companionID', i + '-brailleCell'); |
| 471 topCell.className = 'unhighlighted-cell'; |
| 472 |
| 473 var bottomCell = row2.insertCell(-1); |
| 474 bottomCell.innerHTML = groups[i][1]; |
| 475 bottomCell.id = i + '-brailleCell'; |
| 476 bottomCell.setAttribute('companionID', i + '-textCell'); |
| 477 bottomCell.className = 'unhighlighted-cell'; |
| 478 } |
| 479 }; |
| 480 |
| 481 |
| 417 | 482 |
| 418 /** | 483 /** |
| 419 * Create a new node menu with the given name and add it to the menu bar. | 484 * Create a new node menu with the given name and add it to the menu bar. |
| 420 * @param {string} menuMsg The msg id of the new menu to add. | 485 * @param {string} menuMsg The msg id of the new menu to add. |
| 421 * @param {chrome.automation.AutomationNode} node | 486 * @param {chrome.automation.AutomationNode} node |
| 422 * @param {AutomationPredicate.Unary} pred | 487 * @param {AutomationPredicate.Unary} pred |
| 423 * @return {PanelMenu} The menu just created. | 488 * @return {PanelMenu} The menu just created. |
| 424 */ | 489 */ |
| 425 Panel.addNodeMenu = function(menuMsg, node, pred) { | 490 Panel.addNodeMenu = function(menuMsg, node, pred) { |
| 426 var menu = new PanelNodeMenu(menuMsg, node, pred); | 491 var menu = new PanelNodeMenu(menuMsg, node, pred); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 }, false); | 766 }, false); |
| 702 | 767 |
| 703 window.addEventListener('hashchange', function() { | 768 window.addEventListener('hashchange', function() { |
| 704 if (location.hash == '#fullscreen' || location.hash == '#focus') { | 769 if (location.hash == '#fullscreen' || location.hash == '#focus') { |
| 705 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; | 770 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; |
| 706 cvox.ChromeVox.isStickyPrefOn = false; | 771 cvox.ChromeVox.isStickyPrefOn = false; |
| 707 } else { | 772 } else { |
| 708 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; | 773 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; |
| 709 } | 774 } |
| 710 }, false); | 775 }, false); |
| OLD | NEW |