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

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

Issue 604423002: Use an enum for ChromeVox queue mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 ChromeVox options page. 6 * @fileoverview ChromeVox options page.
7 * 7 *
8 */ 8 */
9 9
10 goog.provide('cvox.OptionsPage'); 10 goog.provide('cvox.OptionsPage');
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 // TODO(dtseng): Only basic conflict detection; it does not speak the 180 // TODO(dtseng): Only basic conflict detection; it does not speak the
181 // conflicting command. Nor does it detect prefix conflicts like Cvox+L vs 181 // conflicting command. Nor does it detect prefix conflicts like Cvox+L vs
182 // Cvox+L>L. 182 // Cvox+L>L.
183 if (cvox.OptionsPage.prefs.setKey(document.activeElement.id, 183 if (cvox.OptionsPage.prefs.setKey(document.activeElement.id,
184 this.keySequence)) { 184 this.keySequence)) {
185 document.activeElement.value = keySeqStr; 185 document.activeElement.value = keySeqStr;
186 } else { 186 } else {
187 announce = cvox.ChromeVox.msgs.getMsg('key_conflict', [announce]); 187 announce = cvox.ChromeVox.msgs.getMsg('key_conflict', [announce]);
188 } 188 }
189 cvox.OptionsPage.speak(announce); 189 cvox.OptionsPage.speak(announce, cvox.QueueMode.QUEUE);
190 this.prevTime = currentTime; 190 this.prevTime = currentTime;
191 191
192 evt.preventDefault(); 192 evt.preventDefault();
193 evt.stopPropagation(); 193 evt.stopPropagation();
194 }, cvox.OptionsPage), true); 194 }, cvox.OptionsPage), true);
195 195
196 var categories = cvox.CommandStore.categories(); 196 var categories = cvox.CommandStore.categories();
197 for (var i = 0; i < categories.length; i++) { 197 for (var i = 0; i < categories.length; i++) {
198 // Braille bindings can't be customized, so don't include them. 198 // Braille bindings can't be customized, so don't include them.
199 if (categories[i] == 'braille') { 199 if (categories[i] == 'braille') {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 this.modifierSeq_ = new cvox.KeySequence(evt, false); 282 this.modifierSeq_ = new cvox.KeySequence(evt, false);
283 } else { 283 } else {
284 this.modifierSeq_.addKeyEvent(evt); 284 this.modifierSeq_.addKeyEvent(evt);
285 } 285 }
286 286
287 // Never allow non-modified keys. 287 // Never allow non-modified keys.
288 if (!this.modifierSeq_.isAnyModifierActive()) { 288 if (!this.modifierSeq_.isAnyModifierActive()) {
289 // Indicate error and instructions excluding tab. 289 // Indicate error and instructions excluding tab.
290 if (evt.keyCode != 9) { 290 if (evt.keyCode != 9) {
291 cvox.OptionsPage.speak( 291 cvox.OptionsPage.speak(
292 cvox.ChromeVox.msgs.getMsg('modifier_entry_error'), 0, {}); 292 cvox.ChromeVox.msgs.getMsg('modifier_entry_error'),
293 cvox.QueueMode.FLUSH, {});
293 } 294 }
294 this.modifierSeq_ = null; 295 this.modifierSeq_ = null;
295 } else { 296 } else {
296 this.modifierCount_++; 297 this.modifierCount_++;
297 } 298 }
298 299
299 // Don't trap tab or shift. 300 // Don't trap tab or shift.
300 if (!evt.shiftKey && evt.keyCode != 9) { 301 if (!evt.shiftKey && evt.keyCode != 9) {
301 evt.preventDefault(); 302 evt.preventDefault();
302 evt.stopPropagation(); 303 evt.stopPropagation();
303 } 304 }
304 }, true); 305 }, true);
305 306
306 cvoxKey.addEventListener('keyup', function(evt) { 307 cvoxKey.addEventListener('keyup', function(evt) {
307 if (this.modifierSeq_) { 308 if (this.modifierSeq_) {
308 this.modifierCount_--; 309 this.modifierCount_--;
309 310
310 if (this.modifierCount_ == 0) { 311 if (this.modifierCount_ == 0) {
311 var modifierStr = 312 var modifierStr =
312 cvox.KeyUtil.keySequenceToString(this.modifierSeq_, true, true); 313 cvox.KeyUtil.keySequenceToString(this.modifierSeq_, true, true);
313 evt.target.value = modifierStr; 314 evt.target.value = modifierStr;
314 cvox.OptionsPage.speak( 315 cvox.OptionsPage.speak(
315 cvox.ChromeVox.msgs.getMsg('modifier_entry_set', [modifierStr])); 316 cvox.ChromeVox.msgs.getMsg('modifier_entry_set', [modifierStr]),
317 cvox.QueueMode.QUEUE);
316 localStorage['cvoxKey'] = modifierStr; 318 localStorage['cvoxKey'] = modifierStr;
317 this.modifierSeq_ = null; 319 this.modifierSeq_ = null;
318 } 320 }
319 evt.preventDefault(); 321 evt.preventDefault();
320 evt.stopPropagation(); 322 evt.stopPropagation();
321 } 323 }
322 }, true); 324 }, true);
323 } 325 }
324 }; 326 };
325 327
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 el.style.display = 'none'; 550 el.style.display = 'none';
549 } 551 }
550 } 552 }
551 }; 553 };
552 554
553 555
554 /** 556 /**
555 * Calls a {@code cvox.TtsInterface.speak} method in the background page to 557 * Calls a {@code cvox.TtsInterface.speak} method in the background page to
556 * speak an utterance. See that method for further details. 558 * speak an utterance. See that method for further details.
557 * @param {string} textString The string of text to be spoken. 559 * @param {string} textString The string of text to be spoken.
558 * @param {number=} queueMode The queue mode to use. 560 * @param {cvox.QueueMode} queueMode The queue mode to use.
559 * @param {Object=} properties Speech properties to use for this utterance. 561 * @param {Object=} properties Speech properties to use for this utterance.
560 */ 562 */
561 cvox.OptionsPage.speak = function(textString, queueMode, properties) { 563 cvox.OptionsPage.speak = function(textString, queueMode, properties) {
562 var speak = 564 var speak =
563 /** @type Function} */ (chrome.extension.getBackgroundPage()['speak']); 565 /** @type Function} */ (chrome.extension.getBackgroundPage()['speak']);
564 speak.apply(null, arguments); 566 speak.apply(null, arguments);
565 }; 567 };
566 568
567 document.addEventListener('DOMContentLoaded', function() { 569 document.addEventListener('DOMContentLoaded', function() {
568 cvox.OptionsPage.init(); 570 cvox.OptionsPage.init();
569 }, false); 571 }, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698