| 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 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * This is the Dart equivalent of jQuery's | 28 * This is the Dart equivalent of jQuery's |
| 29 * [hasClass](http://api.jquery.com/hasClass/). | 29 * [hasClass](http://api.jquery.com/hasClass/). |
| 30 */ | 30 */ |
| 31 bool contains(String value); | 31 bool contains(String value); |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * Add the class [value] to element. | 34 * Add the class [value] to element. |
| 35 * | 35 * |
| 36 * This is the Dart equivalent of jQuery's | 36 * This is the Dart equivalent of jQuery's |
| 37 * [addClass](http://api.jquery.com/addClass/). | 37 * [addClass](http://api.jquery.com/addClass/). |
| 38 * |
| 39 * If this corresponds to one element. Returns `true` if [value] was added to |
| 40 * the set, otherwise `false`. |
| 41 * |
| 42 * If this corresponds to many elements, `null` is always returned. |
| 38 */ | 43 */ |
| 39 void add(String value); | 44 bool add(String value); |
| 40 | 45 |
| 41 /** | 46 /** |
| 42 * Remove the class [value] from element, and return true on successful | 47 * Remove the class [value] from element, and return true on successful |
| 43 * removal. | 48 * removal. |
| 44 * | 49 * |
| 45 * This is the Dart equivalent of jQuery's | 50 * This is the Dart equivalent of jQuery's |
| 46 * [removeClass](http://api.jquery.com/removeClass/). | 51 * [removeClass](http://api.jquery.com/removeClass/). |
| 47 */ | 52 */ |
| 48 bool remove(Object value); | 53 bool remove(Object value); |
| 49 | 54 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 109 |
| 105 /** | 110 /** |
| 106 * Helper method used to modify the set of css classes on this element. | 111 * Helper method used to modify the set of css classes on this element. |
| 107 * | 112 * |
| 108 * f - callback with: | 113 * f - callback with: |
| 109 * s - a Set of all the css class name currently on this element. | 114 * s - a Set of all the css class name currently on this element. |
| 110 * | 115 * |
| 111 * After f returns, the modified set is written to the | 116 * After f returns, the modified set is written to the |
| 112 * className property of this element. | 117 * className property of this element. |
| 113 */ | 118 */ |
| 114 void modify( f(Set<String> s)) { | 119 modify( f(Set<String> s)) { |
| 115 _elementCssClassSetIterable.forEach((e) => e.modify(f)); | 120 _elementCssClassSetIterable.forEach((e) => e.modify(f)); |
| 116 } | 121 } |
| 117 | 122 |
| 118 /** | 123 /** |
| 119 * Adds the class [value] to the element if it is not on it, removes it if it | 124 * Adds the class [value] to the element if it is not on it, removes it if it |
| 120 * is. | 125 * is. |
| 121 */ | 126 */ |
| 122 bool toggle(String value, [bool shouldAdd]) => | 127 bool toggle(String value, [bool shouldAdd]) => |
| 123 _modifyWithReturnValue((e) => e.toggle(value, shouldAdd)); | 128 _modifyWithReturnValue((e) => e.toggle(value, shouldAdd)); |
| 124 | 129 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 152 } | 157 } |
| 153 } | 158 } |
| 154 return s; | 159 return s; |
| 155 } | 160 } |
| 156 | 161 |
| 157 void writeClasses(Set<String> s) { | 162 void writeClasses(Set<String> s) { |
| 158 List list = new List.from(s); | 163 List list = new List.from(s); |
| 159 _element.className = s.join(' '); | 164 _element.className = s.join(' '); |
| 160 } | 165 } |
| 161 } | 166 } |
| OLD | NEW |