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 A utility class for general braille functionality. | 6 * @fileoverview A utility class for general braille functionality. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 goog.provide('cvox.BrailleUtil'); | 10 goog.provide('cvox.BrailleUtil'); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 * Gets the braille state of a node. | 185 * Gets the braille state of a node. |
186 * @param {Node} node The node. | 186 * @param {Node} node The node. |
187 * @return {string} The string representation. | 187 * @return {string} The string representation. |
188 */ | 188 */ |
189 cvox.BrailleUtil.getState = function(node) { | 189 cvox.BrailleUtil.getState = function(node) { |
190 if (!node) { | 190 if (!node) { |
191 return ''; | 191 return ''; |
192 } | 192 } |
193 return cvox.NodeStateUtil.expand( | 193 return cvox.NodeStateUtil.expand( |
194 cvox.DomUtil.getStateMsgs(node, true).map(function(state) { | 194 cvox.DomUtil.getStateMsgs(node, true).map(function(state) { |
195 if (cvox.ChromeVox.msgs.getMsg(state[0] + '_brl')) { | 195 // Check to see if a variant of the message with '_brl' exists, |
| 196 // and use it if so. |
| 197 // |
| 198 // Note: many messages are templatized, and if we don't pass any |
| 199 // argument to substitute, getMsg might throw an error if the |
| 200 // resulting string is empty. To avoid this, we pass a dummy |
| 201 // substitution string array here. |
| 202 var dummySubs = ['dummy', 'dummy', 'dummy']; |
| 203 if (cvox.ChromeVox.msgs.getMsg(state[0] + '_brl', dummySubs)) { |
196 state[0] += '_brl'; | 204 state[0] += '_brl'; |
197 } | 205 } |
198 return state; | 206 return state; |
199 })); | 207 })); |
200 }; | 208 }; |
201 | 209 |
202 | 210 |
203 /** | 211 /** |
204 * Gets the braille container role of a node. | 212 * Gets the braille container role of a node. |
205 * @param {Node} prev The previous node in navigation. | 213 * @param {Node} prev The previous node in navigation. |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 * @param {number} number The number to clamp. | 414 * @param {number} number The number to clamp. |
407 * @param {number} min The minimum value to return. | 415 * @param {number} min The minimum value to return. |
408 * @param {number} max The maximum value to return. | 416 * @param {number} max The maximum value to return. |
409 * @return {number} {@code number} if it is within the bounds, or the nearest | 417 * @return {number} {@code number} if it is within the bounds, or the nearest |
410 * number within the bounds otherwise. | 418 * number within the bounds otherwise. |
411 * @private | 419 * @private |
412 */ | 420 */ |
413 cvox.BrailleUtil.clamp_ = function(number, min, max) { | 421 cvox.BrailleUtil.clamp_ = function(number, min, max) { |
414 return Math.min(Math.max(number, min), max); | 422 return Math.min(Math.max(number, min), max); |
415 }; | 423 }; |
OLD | NEW |