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

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

Issue 1772293004: Improve ChromeVox incremental search experience. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19 matching lines...) Expand all
30 /** @type {Element} @private */ 30 /** @type {Element} @private */
31 this.speechContainer_ = $('speech-container'); 31 this.speechContainer_ = $('speech-container');
32 32
33 /** @type {Element} @private */ 33 /** @type {Element} @private */
34 this.speechElement_ = $('speech'); 34 this.speechElement_ = $('speech');
35 35
36 /** @type {Element} @private */ 36 /** @type {Element} @private */
37 this.brailleContainer_ = $('braille-container'); 37 this.brailleContainer_ = $('braille-container');
38 38
39 /** @type {Element} @private */ 39 /** @type {Element} @private */
40 this.searchContainer_ = $('search-container');
41
42 /** @type {Element} @private */
43 this.searchInput_ = $('search');
44
45 /** @type {Element} @private */
40 this.brailleTextElement_ = $('braille-text'); 46 this.brailleTextElement_ = $('braille-text');
41 47
42 /** @type {Element} @private */ 48 /** @type {Element} @private */
43 this.brailleCellsElement_ = $('braille-cells'); 49 this.brailleCellsElement_ = $('braille-cells');
44 50
45 /** 51 /**
46 * The array of top-level menus. 52 * The array of top-level menus.
47 * @type {!Array<PanelMenu>} 53 * @type {!Array<PanelMenu>}
48 * @private 54 * @private
49 */ 55 */
(...skipping 16 matching lines...) Expand all
66 72
67 /** 73 /**
68 * A callback function to be executed to perform the action from selecting 74 * A callback function to be executed to perform the action from selecting
69 * a menu item after the menu has been closed and focus has been restored 75 * a menu item after the menu has been closed and focus has been restored
70 * to the page or wherever it was previously. 76 * to the page or wherever it was previously.
71 * @type {?Function} 77 * @type {?Function}
72 * @private 78 * @private
73 */ 79 */
74 this.pendingCallback_ = null; 80 this.pendingCallback_ = null;
75 81
82 /**
83 * True if we're currently in incremental search mode.
84 * @type {boolean}
85 * @private
86 */
87 this.searching_ = false;
88
76 Panel.updateFromPrefs(); 89 Panel.updateFromPrefs();
77 90
78 Msgs.addTranslatedMessagesToDom(document); 91 Msgs.addTranslatedMessagesToDom(document);
79 92
80 window.addEventListener('storage', function(event) { 93 window.addEventListener('storage', function(event) {
81 if (event.key == 'brailleCaptions') { 94 if (event.key == 'brailleCaptions') {
82 Panel.updateFromPrefs(); 95 Panel.updateFromPrefs();
83 } 96 }
84 }, false); 97 }, false);
85 98
86 window.addEventListener('message', function(message) { 99 window.addEventListener('message', function(message) {
87 var command = JSON.parse(message.data); 100 var command = JSON.parse(message.data);
88 Panel.exec(/** @type {PanelCommand} */(command)); 101 Panel.exec(/** @type {PanelCommand} */(command));
89 }, false); 102 }, false);
90 103
91 $('menus_button').addEventListener('mousedown', Panel.onOpenMenus, false); 104 $('menus_button').addEventListener('mousedown', Panel.onOpenMenus, false);
92 $('options').addEventListener('click', Panel.onOptions, false); 105 $('options').addEventListener('click', Panel.onOptions, false);
93 $('close').addEventListener('click', Panel.onClose, false); 106 $('close').addEventListener('click', Panel.onClose, false);
94 107
95 document.addEventListener('keydown', Panel.onKeyDown, false); 108 document.addEventListener('keydown', Panel.onKeyDown, false);
96 document.addEventListener('mouseup', Panel.onMouseUp, false); 109 document.addEventListener('mouseup', Panel.onMouseUp, false);
110
111 Panel.searchInput_.addEventListener('blur', Panel.onSearchInputBlur, false);
97 }; 112 };
98 113
99 /** 114 /**
100 * Update the display based on prefs. 115 * Update the display based on prefs.
101 */ 116 */
102 Panel.updateFromPrefs = function() { 117 Panel.updateFromPrefs = function() {
118 if (Panel.searching_) {
119 this.speechContainer_.style.display = 'none';
120 this.brailleContainer_.style.display = 'none';
121 this.searchContainer_.style.display = 'block';
122 return;
123 }
124
125 this.speechContainer_.style.display = 'block';
126 this.brailleContainer_.style.display = 'block';
127 this.searchContainer_.style.display = 'none';
128
103 if (localStorage['brailleCaptions'] === String(true)) { 129 if (localStorage['brailleCaptions'] === String(true)) {
104 this.speechContainer_.style.visibility = 'hidden'; 130 this.speechContainer_.style.visibility = 'hidden';
105 this.brailleContainer_.style.visibility = 'visible'; 131 this.brailleContainer_.style.visibility = 'visible';
106 } else { 132 } else {
107 this.speechContainer_.style.visibility = 'visible'; 133 this.speechContainer_.style.visibility = 'visible';
108 this.brailleContainer_.style.visibility = 'hidden'; 134 this.brailleContainer_.style.visibility = 'hidden';
109 } 135 }
110 }; 136 };
111 137
112 /** 138 /**
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 }); 327 });
302 328
303 // Activate the first menu. 329 // Activate the first menu.
304 Panel.activateMenu(Panel.menus_[0]); 330 Panel.activateMenu(Panel.menus_[0]);
305 }; 331 };
306 332
307 /** Open incremental search. */ 333 /** Open incremental search. */
308 Panel.onSearch = function() { 334 Panel.onSearch = function() {
309 Panel.clearMenus(); 335 Panel.clearMenus();
310 Panel.pendingCallback_ = null; 336 Panel.pendingCallback_ = null;
337 Panel.searching_ = true;
338 Panel.updateFromPrefs();
311 339
312 window.location = '#focus'; 340 window.location = '#focus';
313 341
314 ISearchUI.get($('search')); 342 ISearchUI.get(Panel.searchInput_);
315 }; 343 };
316 344
317 /** 345 /**
318 * Clear any previous menus. The menus are all regenerated each time the 346 * Clear any previous menus. The menus are all regenerated each time the
319 * menus are opened. 347 * menus are opened.
320 */ 348 */
321 Panel.clearMenus = function() { 349 Panel.clearMenus = function() {
322 while (this.menus_.length) { 350 while (this.menus_.length) {
323 var menu = this.menus_.pop(); 351 var menu = this.menus_.pop();
324 $('menu-bar').removeChild(menu.menuBarItemElement); 352 $('menu-bar').removeChild(menu.menuBarItemElement);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 default: 484 default:
457 // Don't mark this event as handled. 485 // Don't mark this event as handled.
458 return; 486 return;
459 } 487 }
460 488
461 event.preventDefault(); 489 event.preventDefault();
462 event.stopPropagation(); 490 event.stopPropagation();
463 }; 491 };
464 492
465 /** 493 /**
494 * Called when focus leaves the search input.
495 */
496 Panel.onSearchInputBlur = function() {
497 if (Panel.searching_) {
498 if (document.activeElement != Panel.searchInput_ || !document.hasFocus()) {
499 Panel.searching_ = false;
500 if (window.location == '#focus')
501 window.location = '#';
502 Panel.updateFromPrefs();
503 Panel.searchInput_.value = '';
David Tseng 2016/03/08 21:28:51 I thought it was kind of interesting to have the p
dmazzoni 2016/03/08 21:34:21 Yeah, we might want to make it more nuanced, but a
504 }
505 }
506 };
507
508 /**
466 * Open the ChromeVox Options. 509 * Open the ChromeVox Options.
467 */ 510 */
468 Panel.onOptions = function() { 511 Panel.onOptions = function() {
469 var bkgnd = 512 var bkgnd =
470 chrome.extension.getBackgroundPage()['global']['backgroundObj']; 513 chrome.extension.getBackgroundPage()['global']['backgroundObj'];
471 bkgnd['showOptionsPage'](); 514 bkgnd['showOptionsPage']();
472 window.location = '#'; 515 window.location = '#';
473 }; 516 };
474 517
475 /** 518 /**
(...skipping 24 matching lines...) Expand all
500 var bkgnd = 543 var bkgnd =
501 chrome.extension.getBackgroundPage()['global']['backgroundObj']; 544 chrome.extension.getBackgroundPage()['global']['backgroundObj'];
502 bkgnd['endExcursion'](); 545 bkgnd['endExcursion']();
503 if (Panel.pendingCallback_) 546 if (Panel.pendingCallback_)
504 Panel.pendingCallback_(); 547 Panel.pendingCallback_();
505 }; 548 };
506 549
507 window.addEventListener('load', function() { 550 window.addEventListener('load', function() {
508 Panel.init(); 551 Panel.init();
509 }, false); 552 }, false);
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/chromevox/cvox2/background/panel.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698