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_common; | 5 part of html_common; |
6 | 6 |
7 abstract class CssClassSetImpl implements CssClassSet { | 7 abstract class CssClassSetImpl implements CssClassSet { |
8 | 8 |
9 String toString() { | 9 String toString() { |
10 return readClasses().join(' '); | 10 return readClasses().join(' '); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // TODO - see comment above about validation. | 123 // TODO - see comment above about validation. |
124 modify((s) => s.addAll(iterable)); | 124 modify((s) => s.addAll(iterable)); |
125 } | 125 } |
126 | 126 |
127 /** | 127 /** |
128 * Remove all classes specified in [iterable] from element. | 128 * Remove all classes specified in [iterable] from element. |
129 * | 129 * |
130 * This is the Dart equivalent of jQuery's | 130 * This is the Dart equivalent of jQuery's |
131 * [removeClass](http://api.jquery.com/removeClass/). | 131 * [removeClass](http://api.jquery.com/removeClass/). |
132 */ | 132 */ |
133 void removeAll(Iterable<String> iterable) { | 133 void removeAll(Iterable<Object> iterable) { |
134 modify((s) => s.removeAll(iterable)); | 134 modify((s) => s.removeAll(iterable)); |
135 } | 135 } |
136 | 136 |
137 /** | 137 /** |
138 * Toggles all classes specified in [iterable] on element. | 138 * Toggles all classes specified in [iterable] on element. |
139 * | 139 * |
140 * Iterate through [iterable]'s items, and add it if it is not on it, or | 140 * Iterate through [iterable]'s items, and add it if it is not on it, or |
141 * remove it if it is. This is the Dart equivalent of jQuery's | 141 * remove it if it is. This is the Dart equivalent of jQuery's |
142 * [toggleClass](http://api.jquery.com/toggleClass/). | 142 * [toggleClass](http://api.jquery.com/toggleClass/). |
143 * If [shouldAdd] is true, then we always add all the classes in [iterable] | 143 * If [shouldAdd] is true, then we always add all the classes in [iterable] |
144 * element. If [shouldAdd] is false then we always remove all the classes in | 144 * element. If [shouldAdd] is false then we always remove all the classes in |
145 * [iterable] from the element. | 145 * [iterable] from the element. |
146 */ | 146 */ |
147 void toggleAll(Iterable<String> iterable, [bool shouldAdd]) { | 147 void toggleAll(Iterable<String> iterable, [bool shouldAdd]) { |
148 iterable.forEach((e) => toggle(e, shouldAdd)); | 148 iterable.forEach((e) => toggle(e, shouldAdd)); |
149 } | 149 } |
150 | 150 |
151 void retainAll(Iterable<String> iterable) { | 151 void retainAll(Iterable<Object> iterable) { |
152 modify((s) => s.retainAll(iterable)); | 152 modify((s) => s.retainAll(iterable)); |
153 } | 153 } |
154 | 154 |
155 void removeWhere(bool test(String name)) { | 155 void removeWhere(bool test(String name)) { |
156 modify((s) => s.removeWhere(test)); | 156 modify((s) => s.removeWhere(test)); |
157 } | 157 } |
158 | 158 |
159 void retainWhere(bool test(String name)) { | 159 void retainWhere(bool test(String name)) { |
160 modify((s) => s.retainWhere(test)); | 160 modify((s) => s.retainWhere(test)); |
161 } | 161 } |
162 | 162 |
163 bool containsAll(Iterable<String> collection) => | 163 bool containsAll(Iterable<Object> collection) => |
164 readClasses().containsAll(collection); | 164 readClasses().containsAll(collection); |
165 | 165 |
166 Set<String> intersection(Set<String> other) => | 166 Set<String> intersection(Set<Object> other) => |
167 readClasses().intersection(other); | 167 readClasses().intersection(other); |
168 | 168 |
169 Set<String> union(Set<String> other) => | 169 Set<String> union(Set<String> other) => |
170 readClasses().union(other); | 170 readClasses().union(other); |
171 | 171 |
172 Set<String> difference(Set<String> other) => | 172 Set<String> difference(Set<String> other) => |
173 readClasses().difference(other); | 173 readClasses().difference(other); |
174 | 174 |
175 String get first => readClasses().first; | 175 String get first => readClasses().first; |
176 String get last => readClasses().last; | 176 String get last => readClasses().last; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 */ | 220 */ |
221 Set<String> readClasses(); | 221 Set<String> readClasses(); |
222 | 222 |
223 /** | 223 /** |
224 * Join all the elements of a set into one string and write | 224 * Join all the elements of a set into one string and write |
225 * back to the element. | 225 * back to the element. |
226 * This is intended to be overridden by specific implementations. | 226 * This is intended to be overridden by specific implementations. |
227 */ | 227 */ |
228 void writeClasses(Set<String> s); | 228 void writeClasses(Set<String> s); |
229 } | 229 } |
OLD | NEW |