OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of html; | 5 part of html; |
6 | 6 |
7 /** A Set that stores the CSS class names for an element. */ | 7 /** A Set that stores the CSS class names for an element. */ |
8 abstract class CssClassSet implements Set<String> { | 8 abstract class CssClassSet implements Set<String> { |
9 | 9 |
10 /** | 10 /** |
11 * Adds the class [value] to the element if it is not on it, removes it if it | 11 * Adds the class [value] to the element if it is not on it, removes it if it |
12 * is. | 12 * is. |
13 * | 13 * |
14 * If [shouldAdd] is true, then we always add that [value] to the element. If | 14 * If [shouldAdd] is true, then we always add that [value] to the element. If |
15 * [shouldAdd] is false then we always remove [value] from the element. | 15 * [shouldAdd] is false then we always remove [value] from the element. |
16 * | 16 * |
17 * If this corresponds to one element, returns `true` if [value] is present | 17 * If this corresponds to one element, returns `true` if [value] is present |
18 * after the operation, and returns `false` if [value] is absent after the | 18 * after the operation, and returns `false` if [value] is absent after the |
19 * operation. | 19 * operation. |
20 * | 20 * |
21 * If this corresponds to many elements, `null` is always returned. | 21 * If this corresponds to many elements, `null` is always returned. |
22 * | |
23 * [value] must be a valid 'token' representing a single class, i.e. a | |
24 * non-empty string containing no whitespace. To toggle multiple classes, use | |
25 * [toggleAll]. | |
26 */ | 22 */ |
27 bool toggle(String value, [bool shouldAdd]); | 23 bool toggle(String value, [bool shouldAdd]); |
28 | 24 |
29 /** | 25 /** |
30 * Returns [:true:] if classes cannot be added or removed from this | 26 * Returns [:true:] if classes cannot be added or removed from this |
31 * [:CssClassSet:]. | 27 * [:CssClassSet:]. |
32 */ | 28 */ |
33 bool get frozen; | 29 bool get frozen; |
34 | 30 |
35 /** | 31 /** |
36 * Determine if this element contains the class [value]. | 32 * Determine if this element contains the class [value]. |
37 * | 33 * |
38 * This is the Dart equivalent of jQuery's | 34 * This is the Dart equivalent of jQuery's |
39 * [hasClass](http://api.jquery.com/hasClass/). | 35 * [hasClass](http://api.jquery.com/hasClass/). |
40 * | |
41 * [value] must be a valid 'token' representing a single class, i.e. a | |
42 * non-empty string containing no whitespace. | |
43 */ | 36 */ |
44 bool contains(String value); | 37 bool contains(String value); |
45 | 38 |
46 /** | 39 /** |
47 * Add the class [value] to element. | 40 * Add the class [value] to element. |
48 * | 41 * |
49 * [add] and [addAll] are the Dart equivalent of jQuery's | 42 * This is the Dart equivalent of jQuery's |
50 * [addClass](http://api.jquery.com/addClass/). | 43 * [addClass](http://api.jquery.com/addClass/). |
51 * | 44 * |
52 * If this CssClassSet corresponds to one element. Returns true if [value] was | 45 * If this corresponds to one element. Returns true if [value] was added to |
53 * added to the set, otherwise false. | 46 * the set, otherwise false. |
54 * | 47 * |
55 * If this corresponds to many elements, `null` is always returned. | 48 * If this corresponds to many elements, `null` is always returned. |
56 * | |
57 * [value] must be a valid 'token' representing a single class, i.e. a | |
58 * non-empty string containing no whitespace. To add multiple classes use | |
59 * [addAll]. | |
60 */ | 49 */ |
61 bool add(String value); | 50 bool add(String value); |
62 | 51 |
63 /** | 52 /** |
64 * Remove the class [value] from element, and return true on successful | 53 * Remove the class [value] from element, and return true on successful |
65 * removal. | 54 * removal. |
66 * | 55 * |
67 * [remove] and [removeAll] are the Dart equivalent of jQuery's | 56 * This is the Dart equivalent of jQuery's |
68 * [removeClass](http://api.jquery.com/removeClass/). | 57 * [removeClass](http://api.jquery.com/removeClass/). |
69 * | |
70 * [value] must be a valid 'token' representing a single class, i.e. a | |
71 * non-empty string containing no whitespace. To remove multiple classes, use | |
72 * [removeAll]. | |
73 */ | 58 */ |
74 bool remove(Object value); | 59 bool remove(Object value); |
75 | 60 |
76 /** | 61 /** |
77 * Add all classes specified in [iterable] to element. | 62 * Add all classes specified in [iterable] to element. |
78 * | 63 * |
79 * [add] and [addAll] are the Dart equivalent of jQuery's | 64 * This is the Dart equivalent of jQuery's |
80 * [addClass](http://api.jquery.com/addClass/). | 65 * [addClass](http://api.jquery.com/addClass/). |
81 * | |
82 * Each element of [iterable] must be a valid 'token' representing a single | |
83 * class, i.e. a non-empty string containing no whitespace. | |
84 */ | 66 */ |
85 void addAll(Iterable<String> iterable); | 67 void addAll(Iterable<String> iterable); |
86 | 68 |
87 /** | 69 /** |
88 * Remove all classes specified in [iterable] from element. | 70 * Remove all classes specified in [iterable] from element. |
89 * | 71 * |
90 * [remove] and [removeAll] are the Dart equivalent of jQuery's | 72 * This is the Dart equivalent of jQuery's |
91 * [removeClass](http://api.jquery.com/removeClass/). | 73 * [removeClass](http://api.jquery.com/removeClass/). |
92 * | |
93 * Each element of [iterable] must be a valid 'token' representing a single | |
94 * class, i.e. a non-empty string containing no whitespace. | |
95 */ | 74 */ |
96 void removeAll(Iterable<String> iterable); | 75 void removeAll(Iterable<String> iterable); |
97 | 76 |
98 /** | 77 /** |
99 * Toggles all classes specified in [iterable] on element. | 78 * Toggles all classes specified in [iterable] on element. |
100 * | 79 * |
101 * Iterate through [iterable]'s items, and add it if it is not on it, or | 80 * Iterate through [iterable]'s items, and add it if it is not on it, or |
102 * remove it if it is. This is the Dart equivalent of jQuery's | 81 * remove it if it is. This is the Dart equivalent of jQuery's |
103 * [toggleClass](http://api.jquery.com/toggleClass/). | 82 * [toggleClass](http://api.jquery.com/toggleClass/). |
104 * If [shouldAdd] is true, then we always add all the classes in [iterable] | 83 * If [shouldAdd] is true, then we always add all the classes in [iterable] |
105 * element. If [shouldAdd] is false then we always remove all the classes in | 84 * element. If [shouldAdd] is false then we always remove all the classes in |
106 * [iterable] from the element. | 85 * [iterable] from the element. |
107 * | |
108 * Each element of [iterable] must be a valid 'token' representing a single | |
109 * class, i.e. a non-empty string containing no whitespace. | |
110 */ | 86 */ |
111 void toggleAll(Iterable<String> iterable, [bool shouldAdd]); | 87 void toggleAll(Iterable<String> iterable, [bool shouldAdd]); |
112 } | 88 } |
OLD | NEW |