OLD | NEW |
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 (function() { | 5 (function() { |
6 | 6 |
7 // Correspond to steps in the hotword opt-in flow. | 7 // Correspond to steps in the hotword opt-in flow. |
8 /** @const */ var START = 'start-container'; | 8 /** @const */ var START = 'start-container'; |
9 /** @const */ var AUDIO_HISTORY = 'audio-history-container'; | 9 /** @const */ var AUDIO_HISTORY = 'audio-history-container'; |
10 /** @const */ var SPEECH_TRAINING = 'speech-training-container'; | 10 /** @const */ var SPEECH_TRAINING = 'speech-training-container'; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 * Shows an error if the audio history setting was not enabled successfully. | 203 * Shows an error if the audio history setting was not enabled successfully. |
204 * @private | 204 * @private |
205 */ | 205 */ |
206 Flow.prototype.handleAudioHistoryError_ = function() { | 206 Flow.prototype.handleAudioHistoryError_ = function() { |
207 $('audio-history-agree').disabled = false; | 207 $('audio-history-agree').disabled = false; |
208 $('audio-history-cancel').disabled = false; | 208 $('audio-history-cancel').disabled = false; |
209 | 209 |
210 $('audio-history-wait').hidden = true; | 210 $('audio-history-wait').hidden = true; |
211 $('audio-history-error').hidden = false; | 211 $('audio-history-error').hidden = false; |
212 | 212 |
213 $('audio-history-agree').focus(); | 213 // Set a timeout before focusing the Enable button so that screenreaders |
| 214 // have time to announce the error first. |
| 215 this.setTimeout_(function() { |
| 216 $('audio-history-agree').focus(); |
| 217 }.bind(this), 50); |
214 }; | 218 }; |
215 | 219 |
216 /** | 220 /** |
217 * Callback for when an audio history request completes. | 221 * Callback for when an audio history request completes. |
218 * @param {chrome.hotwordPrivate.AudioHistoryState} state The audio history | 222 * @param {chrome.hotwordPrivate.AudioHistoryState} state The audio history |
219 * request state. | 223 * request state. |
220 * @private | 224 * @private |
221 */ | 225 */ |
222 Flow.prototype.onAudioHistoryRequestCompleted_ = function(state) { | 226 Flow.prototype.onAudioHistoryRequestCompleted_ = function(state) { |
223 if (!state.success || !state.enabled) { | 227 if (!state.success || !state.enabled) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 $(this.trainingPagePrefix_ + '-processing').hidden = true; | 438 $(this.trainingPagePrefix_ + '-processing').hidden = true; |
435 $(this.trainingPagePrefix_ + '-wait').hidden = false; | 439 $(this.trainingPagePrefix_ + '-wait').hidden = false; |
436 $(this.trainingPagePrefix_ + '-error').hidden = true; | 440 $(this.trainingPagePrefix_ + '-error').hidden = true; |
437 $(this.trainingPagePrefix_ + '-retry').hidden = true; | 441 $(this.trainingPagePrefix_ + '-retry').hidden = true; |
438 } else if (this.trainingState_ == TrainingState.TIMEOUT) { | 442 } else if (this.trainingState_ == TrainingState.TIMEOUT) { |
439 var curStep = trainingSteps.current; | 443 var curStep = trainingSteps.current; |
440 if (curStep) { | 444 if (curStep) { |
441 curStep.classList.remove('listening'); | 445 curStep.classList.remove('listening'); |
442 curStep.classList.add('not-started'); | 446 curStep.classList.add('not-started'); |
443 } | 447 } |
444 $(this.trainingPagePrefix_ + '-toast').children[1].focus(); | 448 |
| 449 // Set a timeout before focusing the Retry button so that screenreaders |
| 450 // have time to announce the timeout first. |
| 451 this.setTimeout_(function() { |
| 452 $(this.trainingPagePrefix_ + '-toast').children[1].focus(); |
| 453 }.bind(this), 50); |
445 } else if (this.trainingState_ == TrainingState.ERROR) { | 454 } else if (this.trainingState_ == TrainingState.ERROR) { |
446 // Update the buttonbar. | 455 // Update the buttonbar. |
447 $(this.trainingPagePrefix_ + '-wait').hidden = true; | 456 $(this.trainingPagePrefix_ + '-wait').hidden = true; |
448 $(this.trainingPagePrefix_ + '-error').hidden = false; | 457 $(this.trainingPagePrefix_ + '-error').hidden = false; |
449 $(this.trainingPagePrefix_ + '-retry').hidden = false; | 458 $(this.trainingPagePrefix_ + '-retry').hidden = false; |
450 $(this.trainingPagePrefix_ + '-processing').hidden = false; | 459 $(this.trainingPagePrefix_ + '-processing').hidden = false; |
451 | 460 |
452 // Focus the retry button. | 461 // Set a timeout before focusing the Retry button so that screenreaders |
453 $(this.trainingPagePrefix_ + '-retry').children[0].focus(); | 462 // have time to announce the error first. |
| 463 this.setTimeout_(function() { |
| 464 $(this.trainingPagePrefix_ + '-retry').children[0].focus(); |
| 465 }.bind(this), 50); |
454 } | 466 } |
455 }; | 467 }; |
456 | 468 |
457 /** | 469 /** |
458 * Handles a hotword trigger event and updates the training UI. | 470 * Handles a hotword trigger event and updates the training UI. |
459 * @private | 471 * @private |
460 */ | 472 */ |
461 Flow.prototype.handleHotwordTrigger_ = function() { | 473 Flow.prototype.handleHotwordTrigger_ = function() { |
462 var trainingSteps = this.getCurrentTrainingStep_('listening'); | 474 var trainingSteps = this.getCurrentTrainingStep_('listening'); |
463 | 475 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 previousStep = this.currentFlow_[this.currentStepIndex_ - 1]; | 557 previousStep = this.currentFlow_[this.currentStepIndex_ - 1]; |
546 | 558 |
547 if (previousStep) | 559 if (previousStep) |
548 document.getElementById(previousStep).hidden = true; | 560 document.getElementById(previousStep).hidden = true; |
549 | 561 |
550 chrome.app.window.current().show(); | 562 chrome.app.window.current().show(); |
551 }; | 563 }; |
552 | 564 |
553 window.Flow = Flow; | 565 window.Flow = Flow; |
554 })(); | 566 })(); |
OLD | NEW |