OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
David Tseng
2015/01/29 18:48:38
nit: 2015
Also, I tried this a while ago and ran i
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 /** | |
6 * @fileoverview Objects used in spannables as annotations for ARIA values | |
7 * and selections. | |
8 */ | |
9 | |
10 goog.provide('cvox.ValueSelectionSpan'); | |
11 goog.provide('cvox.ValueSpan'); | |
12 | |
13 goog.require('cvox.Spannable'); | |
14 | |
15 /** | |
16 * Attached to the value region of a braille spannable. | |
17 * @param {number} offset The offset of the span into the value. | |
18 * @constructor | |
19 */ | |
20 cvox.ValueSpan = function(offset) { | |
21 /** | |
22 * The offset of the span into the value. | |
23 * @type {number} | |
24 */ | |
25 this.offset = offset; | |
26 }; | |
27 | |
28 | |
29 /** | |
30 * Creates a value span from a json serializable object. | |
31 * @param {!Object} obj The json serializable object to convert. | |
32 * @return {!cvox.ValueSpan} The value span. | |
33 */ | |
34 cvox.ValueSpan.fromJson = function(obj) { | |
35 return new cvox.ValueSpan(obj.offset); | |
36 }; | |
37 | |
38 | |
39 /** | |
40 * Converts this object to a json serializable object. | |
41 * @return {!Object} The JSON representation. | |
42 */ | |
43 cvox.ValueSpan.prototype.toJson = function() { | |
44 return this; | |
45 }; | |
46 | |
47 | |
48 cvox.Spannable.registerSerializableSpan( | |
49 cvox.ValueSpan, | |
50 'cvox.ValueSpan', | |
51 cvox.ValueSpan.fromJson, | |
52 cvox.ValueSpan.prototype.toJson); | |
53 | |
54 | |
55 /** | |
56 * Attached to the selected text within a value. | |
57 * @constructor | |
58 */ | |
59 cvox.ValueSelectionSpan = function() { | |
60 }; | |
61 | |
62 | |
63 cvox.Spannable.registerStatelessSerializableSpan( | |
64 cvox.ValueSelectionSpan, | |
65 'cvox.ValueSelectionSpan'); | |
OLD | NEW |