Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 18583004: Added boolean to toggle. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /// The Dart HTML library. 1 /// The Dart HTML library.
2 /// 2 ///
3 /// For examples, see 3 /// For examples, see
4 /// [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples) 4 /// [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples)
5 /// on Github. 5 /// on Github.
6 library dart.dom.html; 6 library dart.dom.html;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:collection'; 9 import 'dart:collection';
10 import 'dart:_collection-dev' hide Symbol, deprecated; 10 import 'dart:_collection-dev' hide Symbol, deprecated;
(...skipping 26517 matching lines...) Expand 10 before | Expand all | Expand 10 after
26528 // for details. All rights reserved. Use of this source code is governed by a 26528 // for details. All rights reserved. Use of this source code is governed by a
26529 // BSD-style license that can be found in the LICENSE file. 26529 // BSD-style license that can be found in the LICENSE file.
26530 26530
26531 26531
26532 /** A Set that stores the CSS class names for an element. */ 26532 /** A Set that stores the CSS class names for an element. */
26533 abstract class CssClassSet implements Set<String> { 26533 abstract class CssClassSet implements Set<String> {
26534 26534
26535 /** 26535 /**
26536 * Adds the class [value] to the element if it is not on it, removes it if it 26536 * Adds the class [value] to the element if it is not on it, removes it if it
26537 * is. 26537 * is.
26538 *
26539 * If [shouldAdd] is true, then we always add that [value] to the element. If
26540 * [shouldAdd] is false then we always remove [value] from the element.
26538 */ 26541 */
26539 bool toggle(String value); 26542 bool toggle(String value, [bool shouldAdd]);
26540 26543
26541 /** 26544 /**
26542 * Returns [:true:] if classes cannot be added or removed from this 26545 * Returns [:true:] if classes cannot be added or removed from this
26543 * [:CssClassSet:]. 26546 * [:CssClassSet:].
26544 */ 26547 */
26545 bool get frozen; 26548 bool get frozen;
26546 26549
26547 /** 26550 /**
26548 * Determine if this element contains the class [value]. 26551 * Determine if this element contains the class [value].
26549 * 26552 *
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
26584 * [removeClass](http://api.jquery.com/removeClass/). 26587 * [removeClass](http://api.jquery.com/removeClass/).
26585 */ 26588 */
26586 void removeAll(Iterable<String> iterable); 26589 void removeAll(Iterable<String> iterable);
26587 26590
26588 /** 26591 /**
26589 * Toggles all classes specified in [iterable] on element. 26592 * Toggles all classes specified in [iterable] on element.
26590 * 26593 *
26591 * Iterate through [iterable]'s items, and add it if it is not on it, or 26594 * Iterate through [iterable]'s items, and add it if it is not on it, or
26592 * remove it if it is. This is the Dart equivalent of jQuery's 26595 * remove it if it is. This is the Dart equivalent of jQuery's
26593 * [toggleClass](http://api.jquery.com/toggleClass/). 26596 * [toggleClass](http://api.jquery.com/toggleClass/).
26597 * If [shouldAdd] is true, then we always add all the classes in [iterable]
26598 * element. If [shouldAdd] is false then we always remove all the classes in
26599 * [iterable] from the element.
26594 */ 26600 */
26595 void toggleAll(Iterable<String> iterable); 26601 void toggleAll(Iterable<String> iterable, [bool shouldAdd]);
26596 } 26602 }
26597 26603
26598 /** 26604 /**
26599 * A set (union) of the CSS classes that are present in a set of elements. 26605 * A set (union) of the CSS classes that are present in a set of elements.
26600 * Implemented separately from _ElementCssClassSet for performance. 26606 * Implemented separately from _ElementCssClassSet for performance.
26601 */ 26607 */
26602 class _MultiElementCssClassSet extends CssClassSetImpl { 26608 class _MultiElementCssClassSet extends CssClassSetImpl {
26603 final Iterable<Element> _elementIterable; 26609 final Iterable<Element> _elementIterable;
26604 Iterable<_ElementCssClassSet> _elementCssClassSetIterable; 26610 Iterable<_ElementCssClassSet> _elementCssClassSetIterable;
26605 26611
(...skipping 25 matching lines...) Expand all
26631 * className property of this element. 26637 * className property of this element.
26632 */ 26638 */
26633 void modify( f(Set<String> s)) { 26639 void modify( f(Set<String> s)) {
26634 _elementCssClassSetIterable.forEach((e) => e.modify(f)); 26640 _elementCssClassSetIterable.forEach((e) => e.modify(f));
26635 } 26641 }
26636 26642
26637 /** 26643 /**
26638 * Adds the class [value] to the element if it is not on it, removes it if it 26644 * Adds the class [value] to the element if it is not on it, removes it if it
26639 * is. 26645 * is.
26640 */ 26646 */
26641 bool toggle(String value) => 26647 bool toggle(String value, [bool shouldAdd]) =>
26642 _modifyWithReturnValue((e) => e.toggle(value)); 26648 _modifyWithReturnValue((e) => e.toggle(value, shouldAdd));
26643 26649
26644 /** 26650 /**
26645 * Remove the class [value] from element, and return true on successful 26651 * Remove the class [value] from element, and return true on successful
26646 * removal. 26652 * removal.
26647 * 26653 *
26648 * This is the Dart equivalent of jQuery's 26654 * This is the Dart equivalent of jQuery's
26649 * [removeClass](http://api.jquery.com/removeClass/). 26655 * [removeClass](http://api.jquery.com/removeClass/).
26650 */ 26656 */
26651 bool remove(Object value) => _modifyWithReturnValue((e) => e.remove(value)); 26657 bool remove(Object value) => _modifyWithReturnValue((e) => e.remove(value));
26652 26658
(...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after
29441 _position = nextPosition; 29447 _position = nextPosition;
29442 return true; 29448 return true;
29443 } 29449 }
29444 _current = null; 29450 _current = null;
29445 _position = _array.length; 29451 _position = _array.length;
29446 return false; 29452 return false;
29447 } 29453 }
29448 29454
29449 T get current => _current; 29455 T get current => _current;
29450 } 29456 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698