Chromium Code Reviews| 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_common; |
| 6 | 6 |
| 7 /** A Set that stores the CSS class names for an element. */ | |
| 7 abstract class CssClassSet implements Set<String> { | 8 abstract class CssClassSet implements Set<String> { |
|
blois
2013/05/03 23:20:18
The public interface should remain in dart:html, n
| |
| 8 | 9 |
| 10 /** | |
| 11 * Adds the class [value] to the element if it is not on it, removes it if it | |
| 12 * is. | |
| 13 */ | |
| 14 bool toggle(String value); | |
| 15 | |
| 16 /** | |
| 17 * Returns [:true:] if classes cannot be added or removed from this | |
| 18 * [:CssClassSet:]. | |
| 19 */ | |
| 20 bool get frozen; | |
| 21 | |
| 22 /** | |
| 23 * Determine if this element contains the class [value]. | |
| 24 * | |
| 25 * This is the Dart equivalent of jQuery's | |
| 26 * [hasClass](http://api.jquery.com/hasClass/). | |
| 27 */ | |
| 28 bool contains(String value); | |
| 29 | |
| 30 /** | |
| 31 * Add the class [value] to element. | |
| 32 * | |
| 33 * This is the Dart equivalent of jQuery's | |
| 34 * [addClass](http://api.jquery.com/addClass/). | |
| 35 */ | |
| 36 void add(String value); | |
| 37 | |
| 38 /** | |
| 39 * Remove the class [value] from element, and return true on successful | |
| 40 * removal. | |
| 41 * | |
| 42 * This is the Dart equivalent of jQuery's | |
| 43 * [removeClass](http://api.jquery.com/removeClass/). | |
| 44 */ | |
| 45 bool remove(Object value); | |
| 46 | |
| 47 /** | |
| 48 * Add all classes specified in [iterable] to element. | |
| 49 * | |
| 50 * This is the Dart equivalent of jQuery's | |
| 51 * [addClass](http://api.jquery.com/addClass/). | |
| 52 */ | |
| 53 void addAll(Iterable<String> iterable); | |
| 54 | |
| 55 /** | |
| 56 * Remove all classes specified in [iterable] from element. | |
| 57 * | |
| 58 * This is the Dart equivalent of jQuery's | |
| 59 * [removeClass](http://api.jquery.com/removeClass/). | |
| 60 */ | |
| 61 void removeAll(Iterable<String> iterable); | |
| 62 | |
| 63 /** | |
| 64 * Toggles all classes specified in [iterable] on element. | |
| 65 * | |
| 66 * Iterate through [iterable]'s items, and add it if it is not on it, or | |
| 67 * remove it if it is. This is the Dart equivalent of jQuery's | |
| 68 * [toggleClass](http://api.jquery.com/toggleClass/). | |
| 69 */ | |
| 70 void toggleAll(Iterable<String> iterable); | |
| 71 } | |
| 72 | |
| 73 abstract class CssClassSetImpl implements CssClassSet { | |
| 74 | |
| 9 String toString() { | 75 String toString() { |
| 10 return readClasses().join(' '); | 76 return readClasses().join(' '); |
| 11 } | 77 } |
| 12 | 78 |
| 13 /** | 79 /** |
| 14 * Adds the class [value] to the element if it is not on it, removes it if it | 80 * Adds the class [value] to the element if it is not on it, removes it if it |
| 15 * is. | 81 * is. |
| 16 */ | 82 */ |
| 17 bool toggle(String value) { | 83 bool toggle(String value) { |
| 18 Set<String> s = readClasses(); | 84 Set<String> s = readClasses(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 */ | 273 */ |
| 208 Set<String> readClasses(); | 274 Set<String> readClasses(); |
| 209 | 275 |
| 210 /** | 276 /** |
| 211 * Join all the elements of a set into one string and write | 277 * Join all the elements of a set into one string and write |
| 212 * back to the element. | 278 * back to the element. |
| 213 * This is intended to be overridden by specific implementations. | 279 * This is intended to be overridden by specific implementations. |
| 214 */ | 280 */ |
| 215 void writeClasses(Set<String> s); | 281 void writeClasses(Set<String> s); |
| 216 } | 282 } |
| OLD | NEW |