Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.js

Issue 2462483002: Support multi-line braille in the virtual braille display. (Closed)
Patch Set: Addressed Review comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 += '&nbsp;&nbsp;'; 183 this.speechElement_.innerHTML += '&nbsp;&nbsp;';
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
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) {
dmazzoni 2016/10/28 20:19:18 Note that you'll also need to edit cvox.BrailleCap
ultimatedbz 2016/10/28 23:51:43 Acknowledged.
411 var groups = data.groups;
dmazzoni 2016/10/28 20:19:18 Fix indentation here
ultimatedbz 2016/10/28 23:51:43 Done.
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
dmazzoni 2016/10/28 20:19:18 No blank line
ultimatedbz 2016/10/28 23:51:43 Done.
424 }
425 };
426
427 var removeBorders = function(event) {
428 var cell = event.target;
429 if (cell.tagName == 'TD') {
430 cell.className = 'unhighlighted-cell';
431 var companionID = cell.getAttribute('companionID');
432 var companion = $(companionID);
433 companion.className = 'unhighlighted-cell';
434 }
435 };
436
437 this.brailleContainer_.addEventListener('mouseover', addBorders);
438 this.brailleContainer_.addEventListener('mouseout', removeBorders);
439
440 // Clear the tables.
441 var rowCount = this.brailleTableElement_.rows.length;
442 for (var i = 0; i < rowCount; i++) {
443 this.brailleTableElement_.deleteRow(0);
444 }
445 rowCount = this.brailleTableElement2_.rows.length;
446 for (var i = 0; i < rowCount; i++) {
447 this.brailleTableElement2_.deleteRow(0);
448 }
449
450 var row1, row2;
451 rowCount = 0;
452 for (var i = 0; i < groups.length; i++) {
453 if (i % cols == 0) {
454 // Check if we reached the limit on the number of rows we can have.
455 if (rowCount == rows)
456 break;
457 rowCount++;
458 row1 = this.brailleTableElement_.insertRow(-1);
459 if (sideBySide) {
460 // Side by side.
461 row2 = this.brailleTableElement2_.insertRow(-1);
462 } else {
463 // Interleaved.
464 row2 = this.brailleTableElement_.insertRow(-1);
465 }
466 }
467
468 var topCell = row1.insertCell(-1);
469 topCell.innerHTML = groups[i][0];
470 topCell.id = i + '-textCell';
471 topCell.setAttribute('companionID', i + '-brailleCell');
472 topCell.style.fontSize = '80%';
473 topCell.className = 'unhighlighted-cell';
474
475 var bottomCell = row2.insertCell(-1);
476 bottomCell.innerHTML = groups[i][1];
477 bottomCell.id = i + '-brailleCell';
478 bottomCell.setAttribute('companionID', i + '-textCell');
479 bottomCell.className = 'unhighlighted-cell';
480 }
481 };
482
483
417 484
418 /** 485 /**
419 * Create a new node menu with the given name and add it to the menu bar. 486 * 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. 487 * @param {string} menuMsg The msg id of the new menu to add.
421 * @param {chrome.automation.AutomationNode} node 488 * @param {chrome.automation.AutomationNode} node
422 * @param {AutomationPredicate.Unary} pred 489 * @param {AutomationPredicate.Unary} pred
423 * @return {PanelMenu} The menu just created. 490 * @return {PanelMenu} The menu just created.
424 */ 491 */
425 Panel.addNodeMenu = function(menuMsg, node, pred) { 492 Panel.addNodeMenu = function(menuMsg, node, pred) {
426 var menu = new PanelNodeMenu(menuMsg, node, pred); 493 var menu = new PanelNodeMenu(menuMsg, node, pred);
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 }, false); 768 }, false);
702 769
703 window.addEventListener('hashchange', function() { 770 window.addEventListener('hashchange', function() {
704 if (location.hash == '#fullscreen' || location.hash == '#focus') { 771 if (location.hash == '#fullscreen' || location.hash == '#focus') {
705 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn; 772 this.originalStickyState_ = cvox.ChromeVox.isStickyPrefOn;
706 cvox.ChromeVox.isStickyPrefOn = false; 773 cvox.ChromeVox.isStickyPrefOn = false;
707 } else { 774 } else {
708 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_; 775 cvox.ChromeVox.isStickyPrefOn = this.originalStickyState_;
709 } 776 }
710 }, false); 777 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698