OLD | NEW |
1 part of angular.directive; | 1 part of angular.directive; |
2 | 2 |
3 /** | 3 /** |
4 * The ngHide directive shows or hides the given HTML element based on the | 4 * The ngHide directive shows or hides the given HTML element based on the |
5 * expression provided to the ngHide attribute. The element is shown or hidden | 5 * expression provided to the ngHide attribute. The element is shown or hidden |
6 * by changing the removing or adding the ng-hide CSS class onto the element. | 6 * by changing the removing or adding the ng-hide CSS class onto the element. |
7 */ | 7 */ |
8 @NgDirective( | 8 @Decorator( |
9 selector: '[ng-hide]', | 9 selector: '[ng-hide]', |
10 map: const {'ng-hide': '=>hide'}) | 10 map: const {'ng-hide': '=>hide'}) |
11 class NgHideDirective { | 11 class NgHide { |
12 static String NG_HIDE_CLASS = 'ng-hide'; | 12 static String NG_HIDE_CLASS = 'ng-hide'; |
13 | 13 |
14 final dom.Element element; | 14 final dom.Element element; |
| 15 final Animate animate; |
15 | 16 |
16 NgHideDirective(this.element); | 17 NgHide(this.element, this.animate); |
17 | 18 |
18 set hide(value) { | 19 set hide(value) { |
19 if (toBool(value)) { | 20 if (toBool(value)) { |
20 element.classes.add(NG_HIDE_CLASS); | 21 animate.addClass(element, NG_HIDE_CLASS); |
21 } else { | 22 } else { |
22 element.classes.remove(NG_HIDE_CLASS); | 23 animate.removeClass(element, NG_HIDE_CLASS); |
23 } | 24 } |
24 } | 25 } |
25 } | 26 } |
26 | 27 |
27 /** | 28 /** |
28 * The ngShow directive shows or hides the given HTML element based on the | 29 * The ngShow directive shows or hides the given HTML element based on the |
29 * expression provided to the ngHide attribute. The element is shown or hidden | 30 * expression provided to the ngHide attribute. The element is shown or hidden |
30 * by changing the removing or adding the ng-hide CSS class onto the element. | 31 * by changing the removing or adding the ng-hide CSS class onto the element. |
31 */ | 32 */ |
32 @NgDirective( | 33 @Decorator( |
33 selector: '[ng-show]', | 34 selector: '[ng-show]', |
34 map: const {'ng-show': '=>show'}) | 35 map: const {'ng-show': '=>show'}) |
35 class NgShowDirective { | 36 class NgShow { |
36 final dom.Element element; | 37 final dom.Element element; |
| 38 final Animate animate; |
37 | 39 |
38 NgShowDirective(this.element); | 40 NgShow(this.element, this.animate); |
39 | 41 |
40 set show(value) { | 42 set show(value) { |
41 if (toBool(value)) { | 43 if (toBool(value)) { |
42 element.classes.remove(NgHideDirective.NG_HIDE_CLASS); | 44 animate.removeClass(element, NgHide.NG_HIDE_CLASS); |
43 } else { | 45 } else { |
44 element.classes.add(NgHideDirective.NG_HIDE_CLASS); | 46 animate.addClass(element, NgHide.NG_HIDE_CLASS); |
45 } | 47 } |
46 } | 48 } |
47 } | 49 } |
48 | 50 |
OLD | NEW |