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 simple container object for the brailling of a | 6 * @fileoverview A simple container object for the brailling of a |
7 * navigation from one object to another. | 7 * navigation from one object to another. |
8 * | 8 * |
9 */ | 9 */ |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 * titles, labels, etc. | 23 * titles, labels, etc. |
24 * startIndex The beginning of a selection within text. | 24 * startIndex The beginning of a selection within text. |
25 * endIndex The end of a selection within text. | 25 * endIndex The end of a selection within text. |
26 * @constructor | 26 * @constructor |
27 */ | 27 */ |
28 cvox.NavBraille = function(kwargs) { | 28 cvox.NavBraille = function(kwargs) { |
29 /** | 29 /** |
30 * Text, annotated with DOM nodes. | 30 * Text, annotated with DOM nodes. |
31 * @type {!Spannable} | 31 * @type {!Spannable} |
32 */ | 32 */ |
33 this.text = (kwargs.text instanceof Spannable) ? | 33 this.text = (kwargs.text instanceof Spannable) ? kwargs.text : |
34 kwargs.text : new Spannable(kwargs.text); | 34 new Spannable(kwargs.text); |
35 | 35 |
36 /** | 36 /** |
37 * Selection start index. | 37 * Selection start index. |
38 * @type {number} | 38 * @type {number} |
39 */ | 39 */ |
40 this.startIndex = goog.isDef(kwargs.startIndex) ? kwargs.startIndex : -1; | 40 this.startIndex = goog.isDef(kwargs.startIndex) ? kwargs.startIndex : -1; |
41 | 41 |
42 /** | 42 /** |
43 * Selection end index. | 43 * Selection end index. |
44 * @type {number} | 44 * @type {number} |
45 */ | 45 */ |
46 this.endIndex = goog.isDef(kwargs.endIndex) ? | 46 this.endIndex = |
47 kwargs.endIndex : this.startIndex; | 47 goog.isDef(kwargs.endIndex) ? kwargs.endIndex : this.startIndex; |
48 }; | 48 }; |
49 | 49 |
50 /** | 50 /** |
51 * Convenience for creating simple braille output. | 51 * Convenience for creating simple braille output. |
52 * @param {string|!Spannable} text Text to represent in braille. | 52 * @param {string|!Spannable} text Text to represent in braille. |
53 * @return {!cvox.NavBraille} Braille output without a cursor. | 53 * @return {!cvox.NavBraille} Braille output without a cursor. |
54 */ | 54 */ |
55 cvox.NavBraille.fromText = function(text) { | 55 cvox.NavBraille.fromText = function(text) { |
56 return new cvox.NavBraille({'text': text}); | 56 return new cvox.NavBraille({'text': text}); |
57 }; | 57 }; |
(...skipping 24 matching lines...) Expand all Loading... |
82 cvox.NavBraille.prototype.isEmpty = function() { | 82 cvox.NavBraille.prototype.isEmpty = function() { |
83 return this.text.length == 0; | 83 return this.text.length == 0; |
84 }; | 84 }; |
85 | 85 |
86 | 86 |
87 /** | 87 /** |
88 * @return {string} A string representation of this object. | 88 * @return {string} A string representation of this object. |
89 */ | 89 */ |
90 cvox.NavBraille.prototype.toString = function() { | 90 cvox.NavBraille.prototype.toString = function() { |
91 return 'NavBraille(text="' + this.text.toString() + '" ' + | 91 return 'NavBraille(text="' + this.text.toString() + '" ' + |
92 ' startIndex="' + this.startIndex + '" ' + | 92 ' startIndex="' + this.startIndex + '" ' + |
93 ' endIndex="' + this.endIndex + '")'; | 93 ' endIndex="' + this.endIndex + '")'; |
94 }; | 94 }; |
95 | 95 |
96 | 96 |
97 /** | 97 /** |
98 * Returns a plain old data object with the same data. | 98 * Returns a plain old data object with the same data. |
99 * Suitable for JSON encoding. | 99 * Suitable for JSON encoding. |
100 * | 100 * |
101 * @return {{spannable: Object, | 101 * @return {{spannable: Object, |
102 * startIndex: number, | 102 * startIndex: number, |
103 * endIndex: number}} JSON equivalent. | 103 * endIndex: number}} JSON equivalent. |
104 */ | 104 */ |
105 cvox.NavBraille.prototype.toJson = function() { | 105 cvox.NavBraille.prototype.toJson = function() { |
106 return { | 106 return { |
107 spannable: this.text.toJson(), | 107 spannable: this.text.toJson(), |
108 startIndex: this.startIndex, | 108 startIndex: this.startIndex, |
109 endIndex: this.endIndex | 109 endIndex: this.endIndex |
110 }; | 110 }; |
111 }; | 111 }; |
OLD | NEW |