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 Public APIs to enable web applications to communicate | 6 * @fileoverview Public APIs to enable web applications to communicate |
7 * with ChromeVox. | 7 * with ChromeVox. |
8 */ | 8 */ |
9 if (typeof(goog) != 'undefined' && goog.provide) { | 9 if (typeof(goog) != 'undefined' && goog.provide) { |
10 goog.provide('cvox.Api'); | 10 goog.provide('cvox.Api'); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 */ | 121 */ |
122 function callSpeakAsync_(message, properties) { | 122 function callSpeakAsync_(message, properties) { |
123 var callback = null; | 123 var callback = null; |
124 /* Use the user supplied callback as callAsync_'s callback. */ | 124 /* Use the user supplied callback as callAsync_'s callback. */ |
125 if (properties && properties['endCallback']) { | 125 if (properties && properties['endCallback']) { |
126 callback = properties['endCallback']; | 126 callback = properties['endCallback']; |
127 } | 127 } |
128 callAsync_(message, callback); | 128 callAsync_(message, callback); |
129 }; | 129 }; |
130 | 130 |
| 131 /** |
| 132 * Gets an object given a dotted namespace object path. |
| 133 * @param {string} path |
| 134 * @return {*} |
| 135 */ |
| 136 function getObjectByName(path) { |
| 137 var pieces = path.split('.'); |
| 138 var resolved = window; |
| 139 for (var i = 0; i < pieces.length; i++) { |
| 140 resolved = resolved[pieces[i]]; |
| 141 if (!resolved) { |
| 142 return null; |
| 143 } |
| 144 } |
| 145 return resolved; |
| 146 } |
| 147 |
131 | 148 |
132 /** | 149 /** |
133 * Maybe enable MathJaX support. | 150 * Maybe enable MathJaX support. |
134 */ | 151 */ |
135 function maybeEnableMathJaX() { | 152 function maybeEnableMathJaX() { |
136 if (!MathJax || !MathJax.Hub || !MathJax.Hub.Register || | 153 if (!getObjectByName('MathJax.Hub.Register.LoadHook') || |
137 !MathJax.Hub.Register.LoadHook) | 154 !getObjectByName('MathJax.Ajax.Require')) { |
138 return; | 155 return; |
| 156 } |
139 | 157 |
140 MathJax.Hub.Register.LoadHook( | 158 MathJax.Hub.Register.LoadHook('[a11y]/explorer.js', function() { |
141 '[a11y]/explorer.js', | 159 // |explorer| is an object instance, so we get it to call an instance |
142 function() { | 160 // |method. |
143 MathJax.Extension.explorer.Enable(true, true); | 161 var explorer = getObjectByName('MathJax.Extension.explorer'); |
144 }); | 162 if (explorer.Enable) { |
| 163 explorer.Enable(true, true); |
| 164 } |
| 165 }); |
145 MathJax.Ajax.Require('[a11y]/explorer.js'); | 166 MathJax.Ajax.Require('[a11y]/explorer.js'); |
146 } | 167 } |
147 | 168 |
148 | 169 |
149 /* | 170 /* |
150 * Public API. | 171 * Public API. |
151 */ | 172 */ |
152 | 173 |
153 if (!window['cvox']) { | 174 if (!window['cvox']) { |
154 window['cvox'] = {}; | 175 window['cvox'] = {}; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 /** | 254 /** |
234 * This method is kept to keep Docs from throwing an error. | 255 * This method is kept to keep Docs from throwing an error. |
235 * | 256 * |
236 */ | 257 */ |
237 cvox.Api.stop = function() { | 258 cvox.Api.stop = function() { |
238 }; | 259 }; |
239 | 260 |
240 cvox.Api.internalEnable(); | 261 cvox.Api.internalEnable(); |
241 | 262 |
242 })(); | 263 })(); |
OLD | NEW |