| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 Panel.onUpdateBraille = function(data) { | 472 Panel.onUpdateBraille = function(data) { |
| 473 var groups = data.groups; | 473 var groups = data.groups; |
| 474 var cols = parseInt(localStorage['virtualBrailleColumns'], 10); | 474 var cols = parseInt(localStorage['virtualBrailleColumns'], 10); |
| 475 var rows = parseInt(localStorage['virtualBrailleRows'], 10); | 475 var rows = parseInt(localStorage['virtualBrailleRows'], 10); |
| 476 var sideBySide = localStorage['brailleSideBySide'] === 'true'; | 476 var sideBySide = localStorage['brailleSideBySide'] === 'true'; |
| 477 | 477 |
| 478 var addBorders = function(event) { | 478 var addBorders = function(event) { |
| 479 var cell = event.target; | 479 var cell = event.target; |
| 480 if (cell.tagName == 'TD') { | 480 if (cell.tagName == 'TD') { |
| 481 cell.className = 'highlighted-cell'; | 481 cell.className = 'highlighted-cell'; |
| 482 var companionID = cell.getAttribute('companionID'); | 482 var companionIDs = cell.getAttribute('data-companionIDs'); |
| 483 var companion = $(companionID); | 483 companionIDs.split(' ').map(function(companionID) { |
| 484 companion.className = 'highlighted-cell'; | 484 var companion = $(companionID); |
| 485 companion.className = 'highlighted-cell'; |
| 486 }); |
| 485 } | 487 } |
| 486 }; | 488 }; |
| 487 | 489 |
| 488 var removeBorders = function(event) { | 490 var removeBorders = function(event) { |
| 489 var cell = event.target; | 491 var cell = event.target; |
| 490 if (cell.tagName == 'TD') { | 492 if (cell.tagName == 'TD') { |
| 491 cell.className = 'unhighlighted-cell'; | 493 cell.className = 'unhighlighted-cell'; |
| 492 var companionID = cell.getAttribute('companionID'); | 494 var companionIDs = cell.getAttribute('data-companionIDs'); |
| 493 var companion = $(companionID); | 495 companionIDs.split(' ').map(function(companionID) { |
| 494 companion.className = 'unhighlighted-cell'; | 496 var companion = $(companionID); |
| 497 companion.className = 'unhighlighted-cell'; |
| 498 }); |
| 495 } | 499 } |
| 496 }; | 500 }; |
| 497 | 501 |
| 498 this.brailleContainer_.addEventListener('mouseover', addBorders); | 502 this.brailleContainer_.addEventListener('mouseover', addBorders); |
| 499 this.brailleContainer_.addEventListener('mouseout', removeBorders); | 503 this.brailleContainer_.addEventListener('mouseout', removeBorders); |
| 500 | 504 |
| 501 // Clear the tables. | 505 // Clear the tables. |
| 502 var rowCount = this.brailleTableElement_.rows.length; | 506 var rowCount = this.brailleTableElement_.rows.length; |
| 503 for (var i = 0; i < rowCount; i++) { | 507 for (var i = 0; i < rowCount; i++) { |
| 504 this.brailleTableElement_.deleteRow(0); | 508 this.brailleTableElement_.deleteRow(0); |
| 505 } | 509 } |
| 506 rowCount = this.brailleTableElement2_.rows.length; | 510 rowCount = this.brailleTableElement2_.rows.length; |
| 507 for (var i = 0; i < rowCount; i++) { | 511 for (var i = 0; i < rowCount; i++) { |
| 508 this.brailleTableElement2_.deleteRow(0); | 512 this.brailleTableElement2_.deleteRow(0); |
| 509 } | 513 } |
| 510 | 514 |
| 511 var row1, row2; | 515 var row1, row2; |
| 512 rowCount = 0; | 516 rowCount = 0; |
| 517 var cellCount = cols; |
| 513 for (var i = 0; i < groups.length; i++) { | 518 for (var i = 0; i < groups.length; i++) { |
| 514 if (i % cols == 0) { | 519 if (cellCount == cols) { |
| 520 cellCount = 0; |
| 515 // Check if we reached the limit on the number of rows we can have. | 521 // Check if we reached the limit on the number of rows we can have. |
| 516 if (rowCount == rows) | 522 if (rowCount == rows) |
| 517 break; | 523 break; |
| 518 rowCount++; | 524 rowCount++; |
| 519 row1 = this.brailleTableElement_.insertRow(-1); | 525 row1 = this.brailleTableElement_.insertRow(-1); |
| 520 if (sideBySide) { | 526 if (sideBySide) { |
| 521 // Side by side. | 527 // Side by side. |
| 522 row2 = this.brailleTableElement2_.insertRow(-1); | 528 row2 = this.brailleTableElement2_.insertRow(-1); |
| 523 } else { | 529 } else { |
| 524 // Interleaved. | 530 // Interleaved. |
| 525 row2 = this.brailleTableElement_.insertRow(-1); | 531 row2 = this.brailleTableElement_.insertRow(-1); |
| 526 } | 532 } |
| 527 } | 533 } |
| 528 | 534 |
| 529 var topCell = row1.insertCell(-1); | 535 var topCell = row1.insertCell(-1); |
| 530 topCell.innerHTML = groups[i][0]; | 536 topCell.innerHTML = groups[i][0]; |
| 531 topCell.id = i + '-textCell'; | 537 topCell.id = i + '-textCell'; |
| 532 topCell.setAttribute('companionID', i + '-brailleCell'); | 538 topCell.setAttribute('data-companionIDs', i + '-brailleCell'); |
| 533 topCell.className = 'unhighlighted-cell'; | 539 topCell.className = 'unhighlighted-cell'; |
| 534 | 540 |
| 535 var bottomCell = row2.insertCell(-1); | 541 var bottomCell = row2.insertCell(-1); |
| 536 bottomCell.innerHTML = groups[i][1]; | |
| 537 bottomCell.id = i + '-brailleCell'; | 542 bottomCell.id = i + '-brailleCell'; |
| 538 bottomCell.setAttribute('companionID', i + '-textCell'); | 543 bottomCell.setAttribute('data-companionIDs', i + '-textCell'); |
| 539 bottomCell.className = 'unhighlighted-cell'; | 544 bottomCell.className = 'unhighlighted-cell'; |
| 545 if (cellCount + groups[i][1].length > cols) { |
| 546 bottomCell.innerHTML = groups[i][1].substring(0, cols - cellCount); |
| 547 if (rowCount == rows) |
| 548 break; |
| 549 rowCount++; |
| 550 row1 = this.brailleTableElement_.insertRow(-1); |
| 551 if (sideBySide) { |
| 552 // Side by side. |
| 553 row2 = this.brailleTableElement2_.insertRow(-1); |
| 554 } else { |
| 555 // Interleaved. |
| 556 row2 = this.brailleTableElement_.insertRow(-1); |
| 557 } |
| 558 var bottomCell2 = row2.insertCell(-1); |
| 559 bottomCell2.id = i + '-brailleCell2'; |
| 560 bottomCell2.setAttribute('data-companionIDs', |
| 561 i + '-textCell ' + i + '-brailleCell'); |
| 562 bottomCell.setAttribute('data-companionIDs', |
| 563 bottomCell.getAttribute('data-companionIDs') + |
| 564 ' ' + i + '-brailleCell2'); |
| 565 topCell.setAttribute('data-companionID2', |
| 566 bottomCell.getAttribute('data-companionIDs') + |
| 567 ' ' + i + '-brailleCell2'); |
| 568 |
| 569 bottomCell2.className = 'unhighlighted-cell'; |
| 570 bottomCell2.innerHTML = groups[i][1].substring(cols - cellCount); |
| 571 cellCount = bottomCell2.innerHTML.length; |
| 572 } else { |
| 573 bottomCell.innerHTML = groups[i][1]; |
| 574 cellCount += groups[i][1].length; |
| 575 } |
| 540 } | 576 } |
| 541 }; | 577 }; |
| 542 | 578 |
| 543 | 579 |
| 544 | 580 |
| 545 /** | 581 /** |
| 546 * Create a new node menu with the given name and add it to the menu bar. | 582 * Create a new node menu with the given name and add it to the menu bar. |
| 547 * @param {string} menuMsg The msg id of the new menu to add. | 583 * @param {string} menuMsg The msg id of the new menu to add. |
| 548 * @param {!chrome.automation.AutomationNode} node | 584 * @param {!chrome.automation.AutomationNode} node |
| 549 * @param {AutomationPredicate.Unary} pred | 585 * @param {AutomationPredicate.Unary} pred |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 }, false); | 878 }, false); |
| 843 | 879 |
| 844 window.addEventListener('hashchange', function() { | 880 window.addEventListener('hashchange', function() { |
| 845 if (location.hash == '#fullscreen' || location.hash == '#focus') { | 881 if (location.hash == '#fullscreen' || location.hash == '#focus') { |
| 846 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; | 882 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; |
| 847 cvox.ChromeVox.isStickyPrefOn = false; | 883 cvox.ChromeVox.isStickyPrefOn = false; |
| 848 } else { | 884 } else { |
| 849 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; | 885 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; |
| 850 } | 886 } |
| 851 }, false); | 887 }, false); |
| OLD | NEW |