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 /** | 5 /** |
6 * @fileoverview Keeps track of the current braille translators. | 6 * @fileoverview Keeps track of the current braille translators. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('cvox.BrailleTranslatorManager'); | 9 goog.provide('cvox.BrailleTranslatorManager'); |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 * @type {cvox.LibLouis.Translator} | 54 * @type {cvox.LibLouis.Translator} |
55 * @private | 55 * @private |
56 */ | 56 */ |
57 this.uncontractedTranslator_ = null; | 57 this.uncontractedTranslator_ = null; |
58 /** | 58 /** |
59 * @type {string?} | 59 * @type {string?} |
60 * @private | 60 * @private |
61 */ | 61 */ |
62 this.uncontractedTableId_ = null; | 62 this.uncontractedTableId_ = null; |
63 | 63 |
64 this.fetchTables_(); | 64 if (!opt_liblouisForTest) { |
65 document.addEventListener('DOMContentLoaded', this.loadLiblouis_.bind(this), | 65 document.addEventListener('DOMContentLoaded', |
66 false); | 66 this.loadLiblouis_.bind(this), |
| 67 false); |
| 68 } |
67 }; | 69 }; |
68 | 70 |
69 cvox.BrailleTranslatorManager.prototype = { | 71 cvox.BrailleTranslatorManager.prototype = { |
70 /** | 72 /** |
71 * Adds a listener to be called whenever there is a change in the | 73 * Adds a listener to be called whenever there is a change in the |
72 * translator(s) returned by other methods of this instance. | 74 * translator(s) returned by other methods of this instance. |
73 * @param {function()} listener The listener. | 75 * @param {function()} listener The listener. |
74 */ | 76 */ |
75 addChangeListener: function(listener) { | 77 addChangeListener: function(listener) { |
76 this.changeListeners_.push(listener); | 78 this.changeListeners_.push(listener); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 206 |
205 /** | 207 /** |
206 * Loads the liblouis instance by attaching it to the document. | 208 * Loads the liblouis instance by attaching it to the document. |
207 * @private | 209 * @private |
208 */ | 210 */ |
209 loadLiblouis_: function() { | 211 loadLiblouis_: function() { |
210 // Cast away nullability. When the document is loaded, it will always | 212 // Cast away nullability. When the document is loaded, it will always |
211 // have a body. | 213 // have a body. |
212 this.liblouis_.attachToElement( | 214 this.liblouis_.attachToElement( |
213 /** @type {!HTMLBodyElement} */ (document.body)); | 215 /** @type {!HTMLBodyElement} */ (document.body)); |
| 216 this.fetchTables_(); |
214 }, | 217 }, |
215 | 218 |
216 /** | 219 /** |
217 * @return {!cvox.LibLouis} The liblouis instance used by this object. | 220 * @return {!cvox.LibLouis} The liblouis instance used by this object. |
218 */ | 221 */ |
219 getLibLouisForTest: function() { | 222 getLibLouisForTest: function() { |
220 return this.liblouis_; | 223 return this.liblouis_; |
221 }, | 224 }, |
222 | 225 |
223 /** | 226 /** |
224 * @return {!Array<cvox.BrailleTable.Table>} The currently loaded braille | 227 * @return {!Array<cvox.BrailleTable.Table>} The currently loaded braille |
225 * tables, or an empty array if they are not yet loaded. | 228 * tables, or an empty array if they are not yet loaded. |
226 */ | 229 */ |
227 getTablesForTest: function() { | 230 getTablesForTest: function() { |
228 return this.tables_; | 231 return this.tables_; |
229 } | 232 } |
230 }; | 233 }; |
OLD | NEW |