angular-gem 1.2.26 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +8 -8
  2. data/lib/angular-gem/version.rb +1 -1
  3. data/vendor/assets/javascripts/1.3.0/angular-animate.js +2112 -0
  4. data/vendor/assets/javascripts/1.3.0/angular-aria.js +250 -0
  5. data/vendor/assets/javascripts/1.3.0/angular-cookies.js +206 -0
  6. data/vendor/assets/javascripts/1.3.0/angular-loader.js +422 -0
  7. data/vendor/assets/javascripts/1.3.0/angular-messages.js +400 -0
  8. data/vendor/assets/javascripts/1.3.0/angular-mocks.js +2287 -0
  9. data/vendor/assets/javascripts/1.3.0/angular-resource.js +667 -0
  10. data/vendor/assets/javascripts/1.3.0/angular-route.js +978 -0
  11. data/vendor/assets/javascripts/1.3.0/angular-sanitize.js +647 -0
  12. data/vendor/assets/javascripts/1.3.0/angular-scenario.js +36944 -0
  13. data/vendor/assets/javascripts/1.3.0/angular-touch.js +622 -0
  14. data/vendor/assets/javascripts/1.3.0/angular.js +25584 -0
  15. data/vendor/assets/javascripts/angular-animate.js +879 -456
  16. data/vendor/assets/javascripts/angular-aria.js +250 -0
  17. data/vendor/assets/javascripts/angular-cookies.js +1 -1
  18. data/vendor/assets/javascripts/angular-loader.js +17 -10
  19. data/vendor/assets/javascripts/angular-messages.js +400 -0
  20. data/vendor/assets/javascripts/angular-mocks.js +220 -110
  21. data/vendor/assets/javascripts/angular-resource.js +287 -247
  22. data/vendor/assets/javascripts/angular-route.js +111 -54
  23. data/vendor/assets/javascripts/angular-sanitize.js +1 -1
  24. data/vendor/assets/javascripts/angular-scenario.js +11579 -8665
  25. data/vendor/assets/javascripts/angular-touch.js +49 -11
  26. data/vendor/assets/javascripts/angular.js +6660 -3106
  27. metadata +15 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjQ1NWVkOWE2NWYzMDM0NDUwM2M4ZDE1Y2U2Y2VmMWRiOTU1MTNhYw==
4
+ OTAwM2M4ZTI3MjIwNmZkZjk0YWZlMjU1N2M3NTQxYjNhZDJmMjdjNQ==
5
5
  data.tar.gz: !binary |-
6
- YWRjMGEwNDkxMTVhMjQ0OWYyOThhMjNiMzU5ODk1ZTA1NTI2OTA1OA==
6
+ NjcyMzIzNmM3OGE2MmViZjFmYzMzZGE1NDRjNGU4NGY4ODIzMWJlOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDg4ODcxMzQ3MTU3ZmRjM2M1Mzc0YmIwZGEwOTU3OTVkYWMwZjdiNTUyZDk4
10
- ZjEzM2ZmYzJjZjc2ZTlhOWUzZGVjZmE5OTcxNzI5ODUyN2YwNmM0ZjJkN2Jj
11
- NWNmMGZiMjU2MmQxMWJiNjY5MDQ4N2Q5MzA4ZDNiZTQxNmI4ODY=
9
+ ZjI5N2ZhNmFhNTVkYzY3YjVkOWJhZTBlYTcwZDFlYjMwMTQ1NjBkOTNlMGQ1
10
+ MjFhZTNjYWNjZTAyYjIxZmYzNTUxNzMwNjU1ZTBhZDk0N2ZhMWJlOTdkMGE1
11
+ MTlmMjU2ZDM5YmU5ODY3MjBkMDI3Yzg2MDZkM2IzMzlkMTc5M2E=
12
12
  data.tar.gz: !binary |-
13
- ZmQ0OTU4N2U1M2JjZDg1ZDU5NTM1ODg5NmJjZTRmZmE5ZjVmMWZjNjliZmJi
14
- NzZjYzI0MWY5YjM2NWFhZTg4MWJjZWEwYzZhYzQ2ZWNlYjhkYjk5OWNhZWI5
15
- ZDEyMDVkNzY2MmI4ZTQyYzQwYThjNWZkODYzZjIyYjg4NTZkNTM=
13
+ ODg0YjFmYWRlNWQwMWFiMzFkNjQwYTIyYTg2ZDRhMDI5NWNiOWMxZGVmNzQ4
14
+ ZmMxMmIxZDFiYjE5YTJhMTMyNDFiZjQ4Mzk5NDExMDU3ZWMxZTdmMmExZDg2
15
+ Njk5NzYyOWE1NDRkMmI4ZDNlN2U2ZDMxYjRiZWEzMjg4YjYwNjk=
@@ -1,3 +1,3 @@
1
1
  module AngularGem
2
- VERSION = "1.2.26"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -0,0 +1,2112 @@
1
+ /**
2
+ * @license AngularJS v1.3.0
3
+ * (c) 2010-2014 Google, Inc. http://angularjs.org
4
+ * License: MIT
5
+ */
6
+ (function(window, angular, undefined) {'use strict';
7
+
8
+ /* jshint maxlen: false */
9
+
10
+ /**
11
+ * @ngdoc module
12
+ * @name ngAnimate
13
+ * @description
14
+ *
15
+ * The `ngAnimate` module provides support for JavaScript, CSS3 transition and CSS3 keyframe animation hooks within existing core and custom directives.
16
+ *
17
+ * <div doc-module-components="ngAnimate"></div>
18
+ *
19
+ * # Usage
20
+ *
21
+ * To see animations in action, all that is required is to define the appropriate CSS classes
22
+ * or to register a JavaScript animation via the myModule.animation() function. The directives that support animation automatically are:
23
+ * `ngRepeat`, `ngInclude`, `ngIf`, `ngSwitch`, `ngShow`, `ngHide`, `ngView` and `ngClass`. Custom directives can take advantage of animation
24
+ * by using the `$animate` service.
25
+ *
26
+ * Below is a more detailed breakdown of the supported animation events provided by pre-existing ng directives:
27
+ *
28
+ * | Directive | Supported Animations |
29
+ * |----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
30
+ * | {@link ng.directive:ngRepeat#animations ngRepeat} | enter, leave and move |
31
+ * | {@link ngRoute.directive:ngView#animations ngView} | enter and leave |
32
+ * | {@link ng.directive:ngInclude#animations ngInclude} | enter and leave |
33
+ * | {@link ng.directive:ngSwitch#animations ngSwitch} | enter and leave |
34
+ * | {@link ng.directive:ngIf#animations ngIf} | enter and leave |
35
+ * | {@link ng.directive:ngClass#animations ngClass} | add and remove (the CSS class(es) present) |
36
+ * | {@link ng.directive:ngShow#animations ngShow} & {@link ng.directive:ngHide#animations ngHide} | add and remove (the ng-hide class value) |
37
+ * | {@link ng.directive:form#animation-hooks form} & {@link ng.directive:ngModel#animation-hooks ngModel} | add and remove (dirty, pristine, valid, invalid & all other validations) |
38
+ * | {@link module:ngMessages#animations ngMessages} | add and remove (ng-active & ng-inactive) |
39
+ * | {@link module:ngMessages#animations ngMessage} | enter and leave |
40
+ *
41
+ * You can find out more information about animations upon visiting each directive page.
42
+ *
43
+ * Below is an example of how to apply animations to a directive that supports animation hooks:
44
+ *
45
+ * ```html
46
+ * <style type="text/css">
47
+ * .slide.ng-enter, .slide.ng-leave {
48
+ * -webkit-transition:0.5s linear all;
49
+ * transition:0.5s linear all;
50
+ * }
51
+ *
52
+ * .slide.ng-enter { } /&#42; starting animations for enter &#42;/
53
+ * .slide.ng-enter.ng-enter-active { } /&#42; terminal animations for enter &#42;/
54
+ * .slide.ng-leave { } /&#42; starting animations for leave &#42;/
55
+ * .slide.ng-leave.ng-leave-active { } /&#42; terminal animations for leave &#42;/
56
+ * </style>
57
+ *
58
+ * <!--
59
+ * the animate service will automatically add .ng-enter and .ng-leave to the element
60
+ * to trigger the CSS transition/animations
61
+ * -->
62
+ * <ANY class="slide" ng-include="..."></ANY>
63
+ * ```
64
+ *
65
+ * Keep in mind that, by default, if an animation is running, any child elements cannot be animated
66
+ * until the parent element's animation has completed. This blocking feature can be overridden by
67
+ * placing the `ng-animate-children` attribute on a parent container tag.
68
+ *
69
+ * ```html
70
+ * <div class="slide-animation" ng-if="on" ng-animate-children>
71
+ * <div class="fade-animation" ng-if="on">
72
+ * <div class="explode-animation" ng-if="on">
73
+ * ...
74
+ * </div>
75
+ * </div>
76
+ * </div>
77
+ * ```
78
+ *
79
+ * When the `on` expression value changes and an animation is triggered then each of the elements within
80
+ * will all animate without the block being applied to child elements.
81
+ *
82
+ * ## Are animations run when the application starts?
83
+ * No they are not. When an application is bootstrapped Angular will disable animations from running to avoid
84
+ * a frenzy of animations from being triggered as soon as the browser has rendered the screen. For this to work,
85
+ * Angular will wait for two digest cycles until enabling animations. From there on, any animation-triggering
86
+ * layout changes in the application will trigger animations as normal.
87
+ *
88
+ * In addition, upon bootstrap, if the routing system or any directives or load remote data (via $http) then Angular
89
+ * will automatically extend the wait time to enable animations once **all** of the outbound HTTP requests
90
+ * are complete.
91
+ *
92
+ * ## CSS-defined Animations
93
+ * The animate service will automatically apply two CSS classes to the animated element and these two CSS classes
94
+ * are designed to contain the start and end CSS styling. Both CSS transitions and keyframe animations are supported
95
+ * and can be used to play along with this naming structure.
96
+ *
97
+ * The following code below demonstrates how to perform animations using **CSS transitions** with Angular:
98
+ *
99
+ * ```html
100
+ * <style type="text/css">
101
+ * /&#42;
102
+ * The animate class is apart of the element and the ng-enter class
103
+ * is attached to the element once the enter animation event is triggered
104
+ * &#42;/
105
+ * .reveal-animation.ng-enter {
106
+ * -webkit-transition: 1s linear all; /&#42; Safari/Chrome &#42;/
107
+ * transition: 1s linear all; /&#42; All other modern browsers and IE10+ &#42;/
108
+ *
109
+ * /&#42; The animation preparation code &#42;/
110
+ * opacity: 0;
111
+ * }
112
+ *
113
+ * /&#42;
114
+ * Keep in mind that you want to combine both CSS
115
+ * classes together to avoid any CSS-specificity
116
+ * conflicts
117
+ * &#42;/
118
+ * .reveal-animation.ng-enter.ng-enter-active {
119
+ * /&#42; The animation code itself &#42;/
120
+ * opacity: 1;
121
+ * }
122
+ * </style>
123
+ *
124
+ * <div class="view-container">
125
+ * <div ng-view class="reveal-animation"></div>
126
+ * </div>
127
+ * ```
128
+ *
129
+ * The following code below demonstrates how to perform animations using **CSS animations** with Angular:
130
+ *
131
+ * ```html
132
+ * <style type="text/css">
133
+ * .reveal-animation.ng-enter {
134
+ * -webkit-animation: enter_sequence 1s linear; /&#42; Safari/Chrome &#42;/
135
+ * animation: enter_sequence 1s linear; /&#42; IE10+ and Future Browsers &#42;/
136
+ * }
137
+ * @-webkit-keyframes enter_sequence {
138
+ * from { opacity:0; }
139
+ * to { opacity:1; }
140
+ * }
141
+ * @keyframes enter_sequence {
142
+ * from { opacity:0; }
143
+ * to { opacity:1; }
144
+ * }
145
+ * </style>
146
+ *
147
+ * <div class="view-container">
148
+ * <div ng-view class="reveal-animation"></div>
149
+ * </div>
150
+ * ```
151
+ *
152
+ * Both CSS3 animations and transitions can be used together and the animate service will figure out the correct duration and delay timing.
153
+ *
154
+ * Upon DOM mutation, the event class is added first (something like `ng-enter`), then the browser prepares itself to add
155
+ * the active class (in this case `ng-enter-active`) which then triggers the animation. The animation module will automatically
156
+ * detect the CSS code to determine when the animation ends. Once the animation is over then both CSS classes will be
157
+ * removed from the DOM. If a browser does not support CSS transitions or CSS animations then the animation will start and end
158
+ * immediately resulting in a DOM element that is at its final state. This final state is when the DOM element
159
+ * has no CSS transition/animation classes applied to it.
160
+ *
161
+ * ### Structural transition animations
162
+ *
163
+ * Structural transitions (such as enter, leave and move) will always apply a `0s none` transition
164
+ * value to force the browser into rendering the styles defined in the setup (.ng-enter, .ng-leave
165
+ * or .ng-move) class. This means that any active transition animations operating on the element
166
+ * will be cut off to make way for the enter, leave or move animation.
167
+ *
168
+ * ### Class-based transition animations
169
+ *
170
+ * Class-based transitions refer to transition animations that are triggered when a CSS class is
171
+ * added to or removed from the element (via `$animate.addClass`, `$animate.removeClass`,
172
+ * `$animate.setClass`, or by directives such as `ngClass`, `ngModel` and `form`).
173
+ * They are different when compared to structural animations since they **do not cancel existing
174
+ * animations** nor do they **block successive transitions** from rendering on the same element.
175
+ * This distinction allows for **multiple class-based transitions** to be performed on the same element.
176
+ *
177
+ * In addition to ngAnimate supporting the default (natural) functionality of class-based transition
178
+ * animations, ngAnimate also decorates the element with starting and ending CSS classes to aid the
179
+ * developer in further styling the element throughout the transition animation. Earlier versions
180
+ * of ngAnimate may have caused natural CSS transitions to break and not render properly due to
181
+ * $animate temporarily blocking transitions using `0s none` in order to allow the setup CSS class
182
+ * (the `-add` or `-remove` class) to be applied without triggering an animation. However, as of
183
+ * **version 1.3**, this workaround has been removed with ngAnimate and all non-ngAnimate CSS
184
+ * class transitions are compatible with ngAnimate.
185
+ *
186
+ * There is, however, one special case when dealing with class-based transitions in ngAnimate.
187
+ * When rendering class-based transitions that make use of the setup and active CSS classes
188
+ * (e.g. `.fade-add` and `.fade-add-active` for when `.fade` is added) be sure to define
189
+ * the transition value **on the active CSS class** and not the setup class.
190
+ *
191
+ * ```css
192
+ * .fade-add {
193
+ * /&#42; remember to place a 0s transition here
194
+ * to ensure that the styles are applied instantly
195
+ * even if the element already has a transition style &#42;/
196
+ * transition:0s linear all;
197
+ *
198
+ * /&#42; starting CSS styles &#42;/
199
+ * opacity:1;
200
+ * }
201
+ * .fade-add.fade-add-active {
202
+ * /&#42; this will be the length of the animation &#42;/
203
+ * transition:1s linear all;
204
+ * opacity:0;
205
+ * }
206
+ * ```
207
+ *
208
+ * The setup CSS class (in this case `.fade-add`) also has a transition style property, however, it
209
+ * has a duration of zero. This may not be required, however, incase the browser is unable to render
210
+ * the styling present in this CSS class instantly then it could be that the browser is attempting
211
+ * to perform an unnecessary transition.
212
+ *
213
+ * This workaround, however, does not apply to standard class-based transitions that are rendered
214
+ * when a CSS class containing a transition is applied to an element:
215
+ *
216
+ * ```css
217
+ * .fade {
218
+ * /&#42; this works as expected &#42;/
219
+ * transition:1s linear all;
220
+ * opacity:0;
221
+ * }
222
+ * ```
223
+ *
224
+ * Please keep this in mind when coding the CSS markup that will be used within class-based transitions.
225
+ * Also, try not to mix the two class-based animation flavors together since the CSS code may become
226
+ * overly complex.
227
+ *
228
+ * ### CSS Staggering Animations
229
+ * A Staggering animation is a collection of animations that are issued with a slight delay in between each successive operation resulting in a
230
+ * curtain-like effect. The ngAnimate module (versions >=1.2) supports staggering animations and the stagger effect can be
231
+ * performed by creating a **ng-EVENT-stagger** CSS class and attaching that class to the base CSS class used for
232
+ * the animation. The style property expected within the stagger class can either be a **transition-delay** or an
233
+ * **animation-delay** property (or both if your animation contains both transitions and keyframe animations).
234
+ *
235
+ * ```css
236
+ * .my-animation.ng-enter {
237
+ * /&#42; standard transition code &#42;/
238
+ * -webkit-transition: 1s linear all;
239
+ * transition: 1s linear all;
240
+ * opacity:0;
241
+ * }
242
+ * .my-animation.ng-enter-stagger {
243
+ * /&#42; this will have a 100ms delay between each successive leave animation &#42;/
244
+ * -webkit-transition-delay: 0.1s;
245
+ * transition-delay: 0.1s;
246
+ *
247
+ * /&#42; in case the stagger doesn't work then these two values
248
+ * must be set to 0 to avoid an accidental CSS inheritance &#42;/
249
+ * -webkit-transition-duration: 0s;
250
+ * transition-duration: 0s;
251
+ * }
252
+ * .my-animation.ng-enter.ng-enter-active {
253
+ * /&#42; standard transition styles &#42;/
254
+ * opacity:1;
255
+ * }
256
+ * ```
257
+ *
258
+ * Staggering animations work by default in ngRepeat (so long as the CSS class is defined). Outside of ngRepeat, to use staggering animations
259
+ * on your own, they can be triggered by firing multiple calls to the same event on $animate. However, the restrictions surrounding this
260
+ * are that each of the elements must have the same CSS className value as well as the same parent element. A stagger operation
261
+ * will also be reset if more than 10ms has passed after the last animation has been fired.
262
+ *
263
+ * The following code will issue the **ng-leave-stagger** event on the element provided:
264
+ *
265
+ * ```js
266
+ * var kids = parent.children();
267
+ *
268
+ * $animate.leave(kids[0]); //stagger index=0
269
+ * $animate.leave(kids[1]); //stagger index=1
270
+ * $animate.leave(kids[2]); //stagger index=2
271
+ * $animate.leave(kids[3]); //stagger index=3
272
+ * $animate.leave(kids[4]); //stagger index=4
273
+ *
274
+ * $timeout(function() {
275
+ * //stagger has reset itself
276
+ * $animate.leave(kids[5]); //stagger index=0
277
+ * $animate.leave(kids[6]); //stagger index=1
278
+ * }, 100, false);
279
+ * ```
280
+ *
281
+ * Stagger animations are currently only supported within CSS-defined animations.
282
+ *
283
+ * ## JavaScript-defined Animations
284
+ * In the event that you do not want to use CSS3 transitions or CSS3 animations or if you wish to offer animations on browsers that do not
285
+ * yet support CSS transitions/animations, then you can make use of JavaScript animations defined inside of your AngularJS module.
286
+ *
287
+ * ```js
288
+ * //!annotate="YourApp" Your AngularJS Module|Replace this or ngModule with the module that you used to define your application.
289
+ * var ngModule = angular.module('YourApp', ['ngAnimate']);
290
+ * ngModule.animation('.my-crazy-animation', function() {
291
+ * return {
292
+ * enter: function(element, done) {
293
+ * //run the animation here and call done when the animation is complete
294
+ * return function(cancelled) {
295
+ * //this (optional) function will be called when the animation
296
+ * //completes or when the animation is cancelled (the cancelled
297
+ * //flag will be set to true if cancelled).
298
+ * };
299
+ * },
300
+ * leave: function(element, done) { },
301
+ * move: function(element, done) { },
302
+ *
303
+ * //animation that can be triggered before the class is added
304
+ * beforeAddClass: function(element, className, done) { },
305
+ *
306
+ * //animation that can be triggered after the class is added
307
+ * addClass: function(element, className, done) { },
308
+ *
309
+ * //animation that can be triggered before the class is removed
310
+ * beforeRemoveClass: function(element, className, done) { },
311
+ *
312
+ * //animation that can be triggered after the class is removed
313
+ * removeClass: function(element, className, done) { }
314
+ * };
315
+ * });
316
+ * ```
317
+ *
318
+ * JavaScript-defined animations are created with a CSS-like class selector and a collection of events which are set to run
319
+ * a javascript callback function. When an animation is triggered, $animate will look for a matching animation which fits
320
+ * the element's CSS class attribute value and then run the matching animation event function (if found).
321
+ * In other words, if the CSS classes present on the animated element match any of the JavaScript animations then the callback function will
322
+ * be executed. It should be also noted that only simple, single class selectors are allowed (compound class selectors are not supported).
323
+ *
324
+ * Within a JavaScript animation, an object containing various event callback animation functions is expected to be returned.
325
+ * As explained above, these callbacks are triggered based on the animation event. Therefore if an enter animation is run,
326
+ * and the JavaScript animation is found, then the enter callback will handle that animation (in addition to the CSS keyframe animation
327
+ * or transition code that is defined via a stylesheet).
328
+ *
329
+ *
330
+ * ### Applying Directive-specific Styles to an Animation
331
+ * In some cases a directive or service may want to provide `$animate` with extra details that the animation will
332
+ * include into its animation. Let's say for example we wanted to render an animation that animates an element
333
+ * towards the mouse coordinates as to where the user clicked last. By collecting the X/Y coordinates of the click
334
+ * (via the event parameter) we can set the `top` and `left` styles into an object and pass that into our function
335
+ * call to `$animate.addClass`.
336
+ *
337
+ * ```js
338
+ * canvas.on('click', function(e) {
339
+ * $animate.addClass(element, 'on', {
340
+ * to: {
341
+ * left : e.client.x + 'px',
342
+ * top : e.client.y + 'px'
343
+ * }
344
+ * }):
345
+ * });
346
+ * ```
347
+ *
348
+ * Now when the animation runs, and a transition or keyframe animation is picked up, then the animation itself will
349
+ * also include and transition the styling of the `left` and `top` properties into its running animation. If we want
350
+ * to provide some starting animation values then we can do so by placing the starting animations styles into an object
351
+ * called `from` in the same object as the `to` animations.
352
+ *
353
+ * ```js
354
+ * canvas.on('click', function(e) {
355
+ * $animate.addClass(element, 'on', {
356
+ * from: {
357
+ * position: 'absolute',
358
+ * left: '0px',
359
+ * top: '0px'
360
+ * },
361
+ * to: {
362
+ * left : e.client.x + 'px',
363
+ * top : e.client.y + 'px'
364
+ * }
365
+ * }):
366
+ * });
367
+ * ```
368
+ *
369
+ * Once the animation is complete or cancelled then the union of both the before and after styles are applied to the
370
+ * element. If `ngAnimate` is not present then the styles will be applied immediately.
371
+ *
372
+ */
373
+
374
+ angular.module('ngAnimate', ['ng'])
375
+
376
+ /**
377
+ * @ngdoc provider
378
+ * @name $animateProvider
379
+ * @description
380
+ *
381
+ * The `$animateProvider` allows developers to register JavaScript animation event handlers directly inside of a module.
382
+ * When an animation is triggered, the $animate service will query the $animate service to find any animations that match
383
+ * the provided name value.
384
+ *
385
+ * Requires the {@link ngAnimate `ngAnimate`} module to be installed.
386
+ *
387
+ * Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
388
+ *
389
+ */
390
+ .directive('ngAnimateChildren', function() {
391
+ var NG_ANIMATE_CHILDREN = '$$ngAnimateChildren';
392
+ return function(scope, element, attrs) {
393
+ var val = attrs.ngAnimateChildren;
394
+ if (angular.isString(val) && val.length === 0) { //empty attribute
395
+ element.data(NG_ANIMATE_CHILDREN, true);
396
+ } else {
397
+ scope.$watch(val, function(value) {
398
+ element.data(NG_ANIMATE_CHILDREN, !!value);
399
+ });
400
+ }
401
+ };
402
+ })
403
+
404
+ //this private service is only used within CSS-enabled animations
405
+ //IE8 + IE9 do not support rAF natively, but that is fine since they
406
+ //also don't support transitions and keyframes which means that the code
407
+ //below will never be used by the two browsers.
408
+ .factory('$$animateReflow', ['$$rAF', '$document', function($$rAF, $document) {
409
+ var bod = $document[0].body;
410
+ return function(fn) {
411
+ //the returned function acts as the cancellation function
412
+ return $$rAF(function() {
413
+ //the line below will force the browser to perform a repaint
414
+ //so that all the animated elements within the animation frame
415
+ //will be properly updated and drawn on screen. This is
416
+ //required to perform multi-class CSS based animations with
417
+ //Firefox. DO NOT REMOVE THIS LINE.
418
+ var a = bod.offsetWidth + 1;
419
+ fn();
420
+ });
421
+ };
422
+ }])
423
+
424
+ .config(['$provide', '$animateProvider', function($provide, $animateProvider) {
425
+ var noop = angular.noop;
426
+ var forEach = angular.forEach;
427
+ var selectors = $animateProvider.$$selectors;
428
+ var isArray = angular.isArray;
429
+ var isString = angular.isString;
430
+ var isObject = angular.isObject;
431
+
432
+ var ELEMENT_NODE = 1;
433
+ var NG_ANIMATE_STATE = '$$ngAnimateState';
434
+ var NG_ANIMATE_CHILDREN = '$$ngAnimateChildren';
435
+ var NG_ANIMATE_CLASS_NAME = 'ng-animate';
436
+ var rootAnimateState = {running: true};
437
+
438
+ function extractElementNode(element) {
439
+ for(var i = 0; i < element.length; i++) {
440
+ var elm = element[i];
441
+ if (elm.nodeType == ELEMENT_NODE) {
442
+ return elm;
443
+ }
444
+ }
445
+ }
446
+
447
+ function prepareElement(element) {
448
+ return element && angular.element(element);
449
+ }
450
+
451
+ function stripCommentsFromElement(element) {
452
+ return angular.element(extractElementNode(element));
453
+ }
454
+
455
+ function isMatchingElement(elm1, elm2) {
456
+ return extractElementNode(elm1) == extractElementNode(elm2);
457
+ }
458
+
459
+ $provide.decorator('$animate',
460
+ ['$delegate', '$$q', '$injector', '$sniffer', '$rootElement', '$$asyncCallback', '$rootScope', '$document', '$templateRequest',
461
+ function($delegate, $$q, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document, $templateRequest) {
462
+
463
+ $rootElement.data(NG_ANIMATE_STATE, rootAnimateState);
464
+
465
+ // Wait until all directive and route-related templates are downloaded and
466
+ // compiled. The $templateRequest.totalPendingRequests variable keeps track of
467
+ // all of the remote templates being currently downloaded. If there are no
468
+ // templates currently downloading then the watcher will still fire anyway.
469
+ var deregisterWatch = $rootScope.$watch(
470
+ function() { return $templateRequest.totalPendingRequests; },
471
+ function(val, oldVal) {
472
+ if (val !== 0) return;
473
+ deregisterWatch();
474
+
475
+ // Now that all templates have been downloaded, $animate will wait until
476
+ // the post digest queue is empty before enabling animations. By having two
477
+ // calls to $postDigest calls we can ensure that the flag is enabled at the
478
+ // very end of the post digest queue. Since all of the animations in $animate
479
+ // use $postDigest, it's important that the code below executes at the end.
480
+ // This basically means that the page is fully downloaded and compiled before
481
+ // any animations are triggered.
482
+ $rootScope.$$postDigest(function() {
483
+ $rootScope.$$postDigest(function() {
484
+ rootAnimateState.running = false;
485
+ });
486
+ });
487
+ }
488
+ );
489
+
490
+ var globalAnimationCounter = 0;
491
+ var classNameFilter = $animateProvider.classNameFilter();
492
+ var isAnimatableClassName = !classNameFilter
493
+ ? function() { return true; }
494
+ : function(className) {
495
+ return classNameFilter.test(className);
496
+ };
497
+
498
+ function classBasedAnimationsBlocked(element, setter) {
499
+ var data = element.data(NG_ANIMATE_STATE) || {};
500
+ if (setter) {
501
+ data.running = true;
502
+ data.structural = true;
503
+ element.data(NG_ANIMATE_STATE, data);
504
+ }
505
+ return data.disabled || (data.running && data.structural);
506
+ }
507
+
508
+ function runAnimationPostDigest(fn) {
509
+ var cancelFn, defer = $$q.defer();
510
+ defer.promise.$$cancelFn = function() {
511
+ cancelFn && cancelFn();
512
+ };
513
+ $rootScope.$$postDigest(function() {
514
+ cancelFn = fn(function() {
515
+ defer.resolve();
516
+ });
517
+ });
518
+ return defer.promise;
519
+ }
520
+
521
+ function parseAnimateOptions(options) {
522
+ // some plugin code may still be passing in the callback
523
+ // function as the last param for the $animate methods so
524
+ // it's best to only allow string or array values for now
525
+ if (isObject(options)) {
526
+ if (options.tempClasses && isString(options.tempClasses)) {
527
+ options.tempClasses = options.tempClasses.split(/\s+/);
528
+ }
529
+ return options;
530
+ }
531
+ }
532
+
533
+ function resolveElementClasses(element, cache, runningAnimations) {
534
+ runningAnimations = runningAnimations || {};
535
+
536
+ var lookup = {};
537
+ forEach(runningAnimations, function(data, selector) {
538
+ forEach(selector.split(' '), function(s) {
539
+ lookup[s]=data;
540
+ });
541
+ });
542
+
543
+ var hasClasses = Object.create(null);
544
+ forEach((element.attr('class') || '').split(/\s+/), function(className) {
545
+ hasClasses[className] = true;
546
+ });
547
+
548
+ var toAdd = [], toRemove = [];
549
+ forEach(cache.classes, function(status, className) {
550
+ var hasClass = hasClasses[className];
551
+ var matchingAnimation = lookup[className] || {};
552
+
553
+ // When addClass and removeClass is called then $animate will check to
554
+ // see if addClass and removeClass cancel each other out. When there are
555
+ // more calls to removeClass than addClass then the count falls below 0
556
+ // and then the removeClass animation will be allowed. Otherwise if the
557
+ // count is above 0 then that means an addClass animation will commence.
558
+ // Once an animation is allowed then the code will also check to see if
559
+ // there exists any on-going animation that is already adding or remvoing
560
+ // the matching CSS class.
561
+ if (status === false) {
562
+ //does it have the class or will it have the class
563
+ if (hasClass || matchingAnimation.event == 'addClass') {
564
+ toRemove.push(className);
565
+ }
566
+ } else if (status === true) {
567
+ //is the class missing or will it be removed?
568
+ if (!hasClass || matchingAnimation.event == 'removeClass') {
569
+ toAdd.push(className);
570
+ }
571
+ }
572
+ });
573
+
574
+ return (toAdd.length + toRemove.length) > 0 && [toAdd.join(' '), toRemove.join(' ')];
575
+ }
576
+
577
+ function lookup(name) {
578
+ if (name) {
579
+ var matches = [],
580
+ flagMap = {},
581
+ classes = name.substr(1).split('.');
582
+
583
+ //the empty string value is the default animation
584
+ //operation which performs CSS transition and keyframe
585
+ //animations sniffing. This is always included for each
586
+ //element animation procedure if the browser supports
587
+ //transitions and/or keyframe animations. The default
588
+ //animation is added to the top of the list to prevent
589
+ //any previous animations from affecting the element styling
590
+ //prior to the element being animated.
591
+ if ($sniffer.transitions || $sniffer.animations) {
592
+ matches.push($injector.get(selectors['']));
593
+ }
594
+
595
+ for(var i=0; i < classes.length; i++) {
596
+ var klass = classes[i],
597
+ selectorFactoryName = selectors[klass];
598
+ if (selectorFactoryName && !flagMap[klass]) {
599
+ matches.push($injector.get(selectorFactoryName));
600
+ flagMap[klass] = true;
601
+ }
602
+ }
603
+ return matches;
604
+ }
605
+ }
606
+
607
+ function animationRunner(element, animationEvent, className, options) {
608
+ //transcluded directives may sometimes fire an animation using only comment nodes
609
+ //best to catch this early on to prevent any animation operations from occurring
610
+ var node = element[0];
611
+ if (!node) {
612
+ return;
613
+ }
614
+
615
+ if (options) {
616
+ options.to = options.to || {};
617
+ options.from = options.from || {};
618
+ }
619
+
620
+ var classNameAdd;
621
+ var classNameRemove;
622
+ if (isArray(className)) {
623
+ classNameAdd = className[0];
624
+ classNameRemove = className[1];
625
+ if (!classNameAdd) {
626
+ className = classNameRemove;
627
+ animationEvent = 'removeClass';
628
+ } else if (!classNameRemove) {
629
+ className = classNameAdd;
630
+ animationEvent = 'addClass';
631
+ } else {
632
+ className = classNameAdd + ' ' + classNameRemove;
633
+ }
634
+ }
635
+
636
+ var isSetClassOperation = animationEvent == 'setClass';
637
+ var isClassBased = isSetClassOperation
638
+ || animationEvent == 'addClass'
639
+ || animationEvent == 'removeClass'
640
+ || animationEvent == 'animate';
641
+
642
+ var currentClassName = element.attr('class');
643
+ var classes = currentClassName + ' ' + className;
644
+ if (!isAnimatableClassName(classes)) {
645
+ return;
646
+ }
647
+
648
+ var beforeComplete = noop,
649
+ beforeCancel = [],
650
+ before = [],
651
+ afterComplete = noop,
652
+ afterCancel = [],
653
+ after = [];
654
+
655
+ var animationLookup = (' ' + classes).replace(/\s+/g,'.');
656
+ forEach(lookup(animationLookup), function(animationFactory) {
657
+ var created = registerAnimation(animationFactory, animationEvent);
658
+ if (!created && isSetClassOperation) {
659
+ registerAnimation(animationFactory, 'addClass');
660
+ registerAnimation(animationFactory, 'removeClass');
661
+ }
662
+ });
663
+
664
+ function registerAnimation(animationFactory, event) {
665
+ var afterFn = animationFactory[event];
666
+ var beforeFn = animationFactory['before' + event.charAt(0).toUpperCase() + event.substr(1)];
667
+ if (afterFn || beforeFn) {
668
+ if (event == 'leave') {
669
+ beforeFn = afterFn;
670
+ //when set as null then animation knows to skip this phase
671
+ afterFn = null;
672
+ }
673
+ after.push({
674
+ event : event, fn : afterFn
675
+ });
676
+ before.push({
677
+ event : event, fn : beforeFn
678
+ });
679
+ return true;
680
+ }
681
+ }
682
+
683
+ function run(fns, cancellations, allCompleteFn) {
684
+ var animations = [];
685
+ forEach(fns, function(animation) {
686
+ animation.fn && animations.push(animation);
687
+ });
688
+
689
+ var count = 0;
690
+ function afterAnimationComplete(index) {
691
+ if (cancellations) {
692
+ (cancellations[index] || noop)();
693
+ if (++count < animations.length) return;
694
+ cancellations = null;
695
+ }
696
+ allCompleteFn();
697
+ }
698
+
699
+ //The code below adds directly to the array in order to work with
700
+ //both sync and async animations. Sync animations are when the done()
701
+ //operation is called right away. DO NOT REFACTOR!
702
+ forEach(animations, function(animation, index) {
703
+ var progress = function() {
704
+ afterAnimationComplete(index);
705
+ };
706
+ switch(animation.event) {
707
+ case 'setClass':
708
+ cancellations.push(animation.fn(element, classNameAdd, classNameRemove, progress, options));
709
+ break;
710
+ case 'animate':
711
+ cancellations.push(animation.fn(element, className, options.from, options.to, progress));
712
+ break;
713
+ case 'addClass':
714
+ cancellations.push(animation.fn(element, classNameAdd || className, progress, options));
715
+ break;
716
+ case 'removeClass':
717
+ cancellations.push(animation.fn(element, classNameRemove || className, progress, options));
718
+ break;
719
+ default:
720
+ cancellations.push(animation.fn(element, progress, options));
721
+ break;
722
+ }
723
+ });
724
+
725
+ if (cancellations && cancellations.length === 0) {
726
+ allCompleteFn();
727
+ }
728
+ }
729
+
730
+ return {
731
+ node : node,
732
+ event : animationEvent,
733
+ className : className,
734
+ isClassBased : isClassBased,
735
+ isSetClassOperation : isSetClassOperation,
736
+ applyStyles : function() {
737
+ if (options) {
738
+ element.css(angular.extend(options.from || {}, options.to || {}));
739
+ }
740
+ },
741
+ before : function(allCompleteFn) {
742
+ beforeComplete = allCompleteFn;
743
+ run(before, beforeCancel, function() {
744
+ beforeComplete = noop;
745
+ allCompleteFn();
746
+ });
747
+ },
748
+ after : function(allCompleteFn) {
749
+ afterComplete = allCompleteFn;
750
+ run(after, afterCancel, function() {
751
+ afterComplete = noop;
752
+ allCompleteFn();
753
+ });
754
+ },
755
+ cancel : function() {
756
+ if (beforeCancel) {
757
+ forEach(beforeCancel, function(cancelFn) {
758
+ (cancelFn || noop)(true);
759
+ });
760
+ beforeComplete(true);
761
+ }
762
+ if (afterCancel) {
763
+ forEach(afterCancel, function(cancelFn) {
764
+ (cancelFn || noop)(true);
765
+ });
766
+ afterComplete(true);
767
+ }
768
+ }
769
+ };
770
+ }
771
+
772
+ /**
773
+ * @ngdoc service
774
+ * @name $animate
775
+ * @kind object
776
+ *
777
+ * @description
778
+ * The `$animate` service provides animation detection support while performing DOM operations (enter, leave and move) as well as during addClass and removeClass operations.
779
+ * When any of these operations are run, the $animate service
780
+ * will examine any JavaScript-defined animations (which are defined by using the $animateProvider provider object)
781
+ * as well as any CSS-defined animations against the CSS classes present on the element once the DOM operation is run.
782
+ *
783
+ * The `$animate` service is used behind the scenes with pre-existing directives and animation with these directives
784
+ * will work out of the box without any extra configuration.
785
+ *
786
+ * Requires the {@link ngAnimate `ngAnimate`} module to be installed.
787
+ *
788
+ * Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
789
+ * ## Callback Promises
790
+ * With AngularJS 1.3, each of the animation methods, on the `$animate` service, return a promise when called. The
791
+ * promise itself is then resolved once the animation has completed itself, has been cancelled or has been
792
+ * skipped due to animations being disabled. (Note that even if the animation is cancelled it will still
793
+ * call the resolve function of the animation.)
794
+ *
795
+ * ```js
796
+ * $animate.enter(element, container).then(function() {
797
+ * //...this is called once the animation is complete...
798
+ * });
799
+ * ```
800
+ *
801
+ * Also note that, due to the nature of the callback promise, if any Angular-specific code (like changing the scope,
802
+ * location of the page, etc...) is executed within the callback promise then be sure to wrap the code using
803
+ * `$scope.$apply(...)`;
804
+ *
805
+ * ```js
806
+ * $animate.leave(element).then(function() {
807
+ * $scope.$apply(function() {
808
+ * $location.path('/new-page');
809
+ * });
810
+ * });
811
+ * ```
812
+ *
813
+ * An animation can also be cancelled by calling the `$animate.cancel(promise)` method with the provided
814
+ * promise that was returned when the animation was started.
815
+ *
816
+ * ```js
817
+ * var promise = $animate.addClass(element, 'super-long-animation').then(function() {
818
+ * //this will still be called even if cancelled
819
+ * });
820
+ *
821
+ * element.on('click', function() {
822
+ * //tooo lazy to wait for the animation to end
823
+ * $animate.cancel(promise);
824
+ * });
825
+ * ```
826
+ *
827
+ * (Keep in mind that the promise cancellation is unique to `$animate` since promises in
828
+ * general cannot be cancelled.)
829
+ *
830
+ */
831
+ return {
832
+ /**
833
+ * @ngdoc method
834
+ * @name $animate#animate
835
+ * @kind function
836
+ *
837
+ * @description
838
+ * Performs an inline animation on the element which applies the provided `to` and `from` CSS styles to the element.
839
+ * If any detected CSS transition, keyframe or JavaScript matches the provided `className` value then the animation
840
+ * will take on the provided styles. For example, if a transition animation is set for the given className then the
841
+ * provided `from` and `to` styles will be applied alongside the given transition. If a JavaScript animation is
842
+ * detected then the provided styles will be given in as function paramters.
843
+ *
844
+ * ```js
845
+ * ngModule.animation('.my-inline-animation', function() {
846
+ * return {
847
+ * animate : function(element, className, from, to, done) {
848
+ * //styles
849
+ * }
850
+ * }
851
+ * });
852
+ * ```
853
+ *
854
+ * Below is a breakdown of each step that occurs during the `animate` animation:
855
+ *
856
+ * | Animation Step | What the element class attribute looks like |
857
+ * |-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
858
+ * | 1. $animate.animate(...) is called | class="my-animation" |
859
+ * | 2. $animate waits for the next digest to start the animation | class="my-animation ng-animate" |
860
+ * | 3. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
861
+ * | 4. the className class value is added to the element | class="my-animation ng-animate className" |
862
+ * | 5. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate className" |
863
+ * | 6. $animate blocks all CSS transitions on the element to ensure the .className class styling is applied right away| class="my-animation ng-animate className" |
864
+ * | 7. $animate applies the provided collection of `from` CSS styles to the element | class="my-animation ng-animate className" |
865
+ * | 8. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate className" |
866
+ * | 9. $animate removes the CSS transition block placed on the element | class="my-animation ng-animate className" |
867
+ * | 10. the className-active class is added (this triggers the CSS transition/animation) | class="my-animation ng-animate className className-active" |
868
+ * | 11. $animate applies the collection of `to` CSS styles to the element which are then handled by the transition | class="my-animation ng-animate className className-active" |
869
+ * | 12. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate className className-active" |
870
+ * | 13. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
871
+ * | 14. The returned promise is resolved. | class="my-animation" |
872
+ *
873
+ * @param {DOMElement} element the element that will be the focus of the enter animation
874
+ * @param {object} from a collection of CSS styles that will be applied to the element at the start of the animation
875
+ * @param {object} to a collection of CSS styles that the element will animate towards
876
+ * @param {string=} className an optional CSS class that will be added to the element for the duration of the animation (the default class is `ng-inline-animate`)
877
+ * @param {object=} options an optional collection of options that will be picked up by the CSS transition/animation
878
+ * @return {Promise} the animation callback promise
879
+ */
880
+ animate : function(element, from, to, className, options) {
881
+ className = className || 'ng-inline-animate';
882
+ options = parseAnimateOptions(options) || {};
883
+ options.from = to ? from : null;
884
+ options.to = to ? to : from;
885
+
886
+ return runAnimationPostDigest(function(done) {
887
+ return performAnimation('animate', className, stripCommentsFromElement(element), null, null, noop, options, done);
888
+ });
889
+ },
890
+
891
+ /**
892
+ * @ngdoc method
893
+ * @name $animate#enter
894
+ * @kind function
895
+ *
896
+ * @description
897
+ * Appends the element to the parentElement element that resides in the document and then runs the enter animation. Once
898
+ * the animation is started, the following CSS classes will be present on the element for the duration of the animation:
899
+ *
900
+ * Below is a breakdown of each step that occurs during enter animation:
901
+ *
902
+ * | Animation Step | What the element class attribute looks like |
903
+ * |-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
904
+ * | 1. $animate.enter(...) is called | class="my-animation" |
905
+ * | 2. element is inserted into the parentElement element or beside the afterElement element | class="my-animation" |
906
+ * | 3. $animate waits for the next digest to start the animation | class="my-animation ng-animate" |
907
+ * | 4. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
908
+ * | 5. the .ng-enter class is added to the element | class="my-animation ng-animate ng-enter" |
909
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-enter" |
910
+ * | 7. $animate blocks all CSS transitions on the element to ensure the .ng-enter class styling is applied right away | class="my-animation ng-animate ng-enter" |
911
+ * | 8. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate ng-enter" |
912
+ * | 9. $animate removes the CSS transition block placed on the element | class="my-animation ng-animate ng-enter" |
913
+ * | 10. the .ng-enter-active class is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-enter ng-enter-active" |
914
+ * | 11. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate ng-enter ng-enter-active" |
915
+ * | 12. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
916
+ * | 13. The returned promise is resolved. | class="my-animation" |
917
+ *
918
+ * @param {DOMElement} element the element that will be the focus of the enter animation
919
+ * @param {DOMElement} parentElement the parent element of the element that will be the focus of the enter animation
920
+ * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
921
+ * @param {object=} options an optional collection of options that will be picked up by the CSS transition/animation
922
+ * @return {Promise} the animation callback promise
923
+ */
924
+ enter : function(element, parentElement, afterElement, options) {
925
+ options = parseAnimateOptions(options);
926
+ element = angular.element(element);
927
+ parentElement = prepareElement(parentElement);
928
+ afterElement = prepareElement(afterElement);
929
+
930
+ classBasedAnimationsBlocked(element, true);
931
+ $delegate.enter(element, parentElement, afterElement);
932
+ return runAnimationPostDigest(function(done) {
933
+ return performAnimation('enter', 'ng-enter', stripCommentsFromElement(element), parentElement, afterElement, noop, options, done);
934
+ });
935
+ },
936
+
937
+ /**
938
+ * @ngdoc method
939
+ * @name $animate#leave
940
+ * @kind function
941
+ *
942
+ * @description
943
+ * Runs the leave animation operation and, upon completion, removes the element from the DOM. Once
944
+ * the animation is started, the following CSS classes will be added for the duration of the animation:
945
+ *
946
+ * Below is a breakdown of each step that occurs during leave animation:
947
+ *
948
+ * | Animation Step | What the element class attribute looks like |
949
+ * |-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
950
+ * | 1. $animate.leave(...) is called | class="my-animation" |
951
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
952
+ * | 3. $animate waits for the next digest to start the animation | class="my-animation ng-animate" |
953
+ * | 4. the .ng-leave class is added to the element | class="my-animation ng-animate ng-leave" |
954
+ * | 5. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-leave" |
955
+ * | 6. $animate blocks all CSS transitions on the element to ensure the .ng-leave class styling is applied right away | class="my-animation ng-animate ng-leave” |
956
+ * | 7. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate ng-leave" |
957
+ * | 8. $animate removes the CSS transition block placed on the element | class="my-animation ng-animate ng-leave” |
958
+ * | 9. the .ng-leave-active class is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-leave ng-leave-active" |
959
+ * | 10. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate ng-leave ng-leave-active" |
960
+ * | 11. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
961
+ * | 12. The element is removed from the DOM | ... |
962
+ * | 13. The returned promise is resolved. | ... |
963
+ *
964
+ * @param {DOMElement} element the element that will be the focus of the leave animation
965
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
966
+ * @return {Promise} the animation callback promise
967
+ */
968
+ leave : function(element, options) {
969
+ options = parseAnimateOptions(options);
970
+ element = angular.element(element);
971
+
972
+ cancelChildAnimations(element);
973
+ classBasedAnimationsBlocked(element, true);
974
+ return runAnimationPostDigest(function(done) {
975
+ return performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
976
+ $delegate.leave(element);
977
+ }, options, done);
978
+ });
979
+ },
980
+
981
+ /**
982
+ * @ngdoc method
983
+ * @name $animate#move
984
+ * @kind function
985
+ *
986
+ * @description
987
+ * Fires the move DOM operation. Just before the animation starts, the animate service will either append it into the parentElement container or
988
+ * add the element directly after the afterElement element if present. Then the move animation will be run. Once
989
+ * the animation is started, the following CSS classes will be added for the duration of the animation:
990
+ *
991
+ * Below is a breakdown of each step that occurs during move animation:
992
+ *
993
+ * | Animation Step | What the element class attribute looks like |
994
+ * |------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
995
+ * | 1. $animate.move(...) is called | class="my-animation" |
996
+ * | 2. element is moved into the parentElement element or beside the afterElement element | class="my-animation" |
997
+ * | 3. $animate waits for the next digest to start the animation | class="my-animation ng-animate" |
998
+ * | 4. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
999
+ * | 5. the .ng-move class is added to the element | class="my-animation ng-animate ng-move" |
1000
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-move" |
1001
+ * | 7. $animate blocks all CSS transitions on the element to ensure the .ng-move class styling is applied right away | class="my-animation ng-animate ng-move” |
1002
+ * | 8. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate ng-move" |
1003
+ * | 9. $animate removes the CSS transition block placed on the element | class="my-animation ng-animate ng-move” |
1004
+ * | 10. the .ng-move-active class is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-move ng-move-active" |
1005
+ * | 11. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate ng-move ng-move-active" |
1006
+ * | 12. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
1007
+ * | 13. The returned promise is resolved. | class="my-animation" |
1008
+ *
1009
+ * @param {DOMElement} element the element that will be the focus of the move animation
1010
+ * @param {DOMElement} parentElement the parentElement element of the element that will be the focus of the move animation
1011
+ * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
1012
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
1013
+ * @return {Promise} the animation callback promise
1014
+ */
1015
+ move : function(element, parentElement, afterElement, options) {
1016
+ options = parseAnimateOptions(options);
1017
+ element = angular.element(element);
1018
+ parentElement = prepareElement(parentElement);
1019
+ afterElement = prepareElement(afterElement);
1020
+
1021
+ cancelChildAnimations(element);
1022
+ classBasedAnimationsBlocked(element, true);
1023
+ $delegate.move(element, parentElement, afterElement);
1024
+ return runAnimationPostDigest(function(done) {
1025
+ return performAnimation('move', 'ng-move', stripCommentsFromElement(element), parentElement, afterElement, noop, options, done);
1026
+ });
1027
+ },
1028
+
1029
+ /**
1030
+ * @ngdoc method
1031
+ * @name $animate#addClass
1032
+ *
1033
+ * @description
1034
+ * Triggers a custom animation event based off the className variable and then attaches the className value to the element as a CSS class.
1035
+ * Unlike the other animation methods, the animate service will suffix the className value with {@type -add} in order to provide
1036
+ * the animate service the setup and active CSS classes in order to trigger the animation (this will be skipped if no CSS transitions
1037
+ * or keyframes are defined on the -add-active or base CSS class).
1038
+ *
1039
+ * Below is a breakdown of each step that occurs during addClass animation:
1040
+ *
1041
+ * | Animation Step | What the element class attribute looks like |
1042
+ * |----------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
1043
+ * | 1. $animate.addClass(element, 'super') is called | class="my-animation" |
1044
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
1045
+ * | 3. the .super-add class is added to the element | class="my-animation ng-animate super-add" |
1046
+ * | 4. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate super-add" |
1047
+ * | 5. the .super and .super-add-active classes are added (this triggers the CSS transition/animation) | class="my-animation ng-animate super super-add super-add-active" |
1048
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate super-add" |
1049
+ * | 7. $animate waits for the animation to complete (via events and timeout) | class="my-animation super super-add super-add-active" |
1050
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation super" |
1051
+ * | 9. The super class is kept on the element | class="my-animation super" |
1052
+ * | 10. The returned promise is resolved. | class="my-animation super" |
1053
+ *
1054
+ * @param {DOMElement} element the element that will be animated
1055
+ * @param {string} className the CSS class that will be added to the element and then animated
1056
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
1057
+ * @return {Promise} the animation callback promise
1058
+ */
1059
+ addClass : function(element, className, options) {
1060
+ return this.setClass(element, className, [], options);
1061
+ },
1062
+
1063
+ /**
1064
+ * @ngdoc method
1065
+ * @name $animate#removeClass
1066
+ *
1067
+ * @description
1068
+ * Triggers a custom animation event based off the className variable and then removes the CSS class provided by the className value
1069
+ * from the element. Unlike the other animation methods, the animate service will suffix the className value with {@type -remove} in
1070
+ * order to provide the animate service the setup and active CSS classes in order to trigger the animation (this will be skipped if
1071
+ * no CSS transitions or keyframes are defined on the -remove or base CSS classes).
1072
+ *
1073
+ * Below is a breakdown of each step that occurs during removeClass animation:
1074
+ *
1075
+ * | Animation Step | What the element class attribute looks like |
1076
+ * |------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
1077
+ * | 1. $animate.removeClass(element, 'super') is called | class="my-animation super" |
1078
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation super ng-animate" |
1079
+ * | 3. the .super-remove class is added to the element | class="my-animation super ng-animate super-remove" |
1080
+ * | 4. $animate waits for a single animation frame (this performs a reflow) | class="my-animation super ng-animate super-remove" |
1081
+ * | 5. the .super-remove-active classes are added and .super is removed (this triggers the CSS transition/animation) | class="my-animation ng-animate super-remove super-remove-active" |
1082
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation super ng-animate super-remove" |
1083
+ * | 7. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate super-remove super-remove-active" |
1084
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
1085
+ * | 9. The returned promise is resolved. | class="my-animation" |
1086
+ *
1087
+ *
1088
+ * @param {DOMElement} element the element that will be animated
1089
+ * @param {string} className the CSS class that will be animated and then removed from the element
1090
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
1091
+ * @return {Promise} the animation callback promise
1092
+ */
1093
+ removeClass : function(element, className, options) {
1094
+ return this.setClass(element, [], className, options);
1095
+ },
1096
+
1097
+ /**
1098
+ *
1099
+ * @ngdoc method
1100
+ * @name $animate#setClass
1101
+ *
1102
+ * @description Adds and/or removes the given CSS classes to and from the element.
1103
+ * Once complete, the done() callback will be fired (if provided).
1104
+ *
1105
+ * | Animation Step | What the element class attribute looks like |
1106
+ * |--------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
1107
+ * | 1. $animate.removeClass(element, ‘on’, ‘off’) is called | class="my-animation super off” |
1108
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation super ng-animate off” |
1109
+ * | 3. the .on-add and .off-remove classes are added to the element | class="my-animation ng-animate on-add off-remove off” |
1110
+ * | 4. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate on-add off-remove off” |
1111
+ * | 5. the .on, .on-add-active and .off-remove-active classes are added and .off is removed (this triggers the CSS transition/animation) | class="my-animation ng-animate on on-add on-add-active off-remove off-remove-active” |
1112
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate on on-add on-add-active off-remove off-remove-active" |
1113
+ * | 7. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate on on-add on-add-active off-remove off-remove-active" |
1114
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation on" |
1115
+ * | 9. The returned promise is resolved. | class="my-animation on" |
1116
+ *
1117
+ * @param {DOMElement} element the element which will have its CSS classes changed
1118
+ * removed from it
1119
+ * @param {string} add the CSS classes which will be added to the element
1120
+ * @param {string} remove the CSS class which will be removed from the element
1121
+ * CSS classes have been set on the element
1122
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
1123
+ * @return {Promise} the animation callback promise
1124
+ */
1125
+ setClass : function(element, add, remove, options) {
1126
+ options = parseAnimateOptions(options);
1127
+
1128
+ var STORAGE_KEY = '$$animateClasses';
1129
+ element = angular.element(element);
1130
+ element = stripCommentsFromElement(element);
1131
+
1132
+ if (classBasedAnimationsBlocked(element)) {
1133
+ return $delegate.$$setClassImmediately(element, add, remove, options);
1134
+ }
1135
+
1136
+ // we're using a combined array for both the add and remove
1137
+ // operations since the ORDER OF addClass and removeClass matters
1138
+ var classes, cache = element.data(STORAGE_KEY);
1139
+ var hasCache = !!cache;
1140
+ if (!cache) {
1141
+ cache = {};
1142
+ cache.classes = {};
1143
+ }
1144
+ classes = cache.classes;
1145
+
1146
+ add = isArray(add) ? add : add.split(' ');
1147
+ forEach(add, function(c) {
1148
+ if (c && c.length) {
1149
+ classes[c] = true;
1150
+ }
1151
+ });
1152
+
1153
+ remove = isArray(remove) ? remove : remove.split(' ');
1154
+ forEach(remove, function(c) {
1155
+ if (c && c.length) {
1156
+ classes[c] = false;
1157
+ }
1158
+ });
1159
+
1160
+ if (hasCache) {
1161
+ if (options && cache.options) {
1162
+ cache.options = angular.extend(cache.options || {}, options);
1163
+ }
1164
+
1165
+ //the digest cycle will combine all the animations into one function
1166
+ return cache.promise;
1167
+ } else {
1168
+ element.data(STORAGE_KEY, cache = {
1169
+ classes : classes,
1170
+ options : options
1171
+ });
1172
+ }
1173
+
1174
+ return cache.promise = runAnimationPostDigest(function(done) {
1175
+ var parentElement = element.parent();
1176
+ var elementNode = extractElementNode(element);
1177
+ var parentNode = elementNode.parentNode;
1178
+ // TODO(matsko): move this code into the animationsDisabled() function once #8092 is fixed
1179
+ if (!parentNode || parentNode['$$NG_REMOVED'] || elementNode['$$NG_REMOVED']) {
1180
+ done();
1181
+ return;
1182
+ }
1183
+
1184
+ var cache = element.data(STORAGE_KEY);
1185
+ element.removeData(STORAGE_KEY);
1186
+
1187
+ var state = element.data(NG_ANIMATE_STATE) || {};
1188
+ var classes = resolveElementClasses(element, cache, state.active);
1189
+ return !classes
1190
+ ? done()
1191
+ : performAnimation('setClass', classes, element, parentElement, null, function() {
1192
+ if (classes[0]) $delegate.$$addClassImmediately(element, classes[0]);
1193
+ if (classes[1]) $delegate.$$removeClassImmediately(element, classes[1]);
1194
+ }, cache.options, done);
1195
+ });
1196
+ },
1197
+
1198
+ /**
1199
+ * @ngdoc method
1200
+ * @name $animate#cancel
1201
+ * @kind function
1202
+ *
1203
+ * @param {Promise} animationPromise The animation promise that is returned when an animation is started.
1204
+ *
1205
+ * @description
1206
+ * Cancels the provided animation.
1207
+ */
1208
+ cancel : function(promise) {
1209
+ promise.$$cancelFn();
1210
+ },
1211
+
1212
+ /**
1213
+ * @ngdoc method
1214
+ * @name $animate#enabled
1215
+ * @kind function
1216
+ *
1217
+ * @param {boolean=} value If provided then set the animation on or off.
1218
+ * @param {DOMElement=} element If provided then the element will be used to represent the enable/disable operation
1219
+ * @return {boolean} Current animation state.
1220
+ *
1221
+ * @description
1222
+ * Globally enables/disables animations.
1223
+ *
1224
+ */
1225
+ enabled : function(value, element) {
1226
+ switch(arguments.length) {
1227
+ case 2:
1228
+ if (value) {
1229
+ cleanup(element);
1230
+ } else {
1231
+ var data = element.data(NG_ANIMATE_STATE) || {};
1232
+ data.disabled = true;
1233
+ element.data(NG_ANIMATE_STATE, data);
1234
+ }
1235
+ break;
1236
+
1237
+ case 1:
1238
+ rootAnimateState.disabled = !value;
1239
+ break;
1240
+
1241
+ default:
1242
+ value = !rootAnimateState.disabled;
1243
+ break;
1244
+ }
1245
+ return !!value;
1246
+ }
1247
+ };
1248
+
1249
+ /*
1250
+ all animations call this shared animation triggering function internally.
1251
+ The animationEvent variable refers to the JavaScript animation event that will be triggered
1252
+ and the className value is the name of the animation that will be applied within the
1253
+ CSS code. Element, parentElement and afterElement are provided DOM elements for the animation
1254
+ and the onComplete callback will be fired once the animation is fully complete.
1255
+ */
1256
+ function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, options, doneCallback) {
1257
+ var noopCancel = noop;
1258
+ var runner = animationRunner(element, animationEvent, className, options);
1259
+ if (!runner) {
1260
+ fireDOMOperation();
1261
+ fireBeforeCallbackAsync();
1262
+ fireAfterCallbackAsync();
1263
+ closeAnimation();
1264
+ return noopCancel;
1265
+ }
1266
+
1267
+ animationEvent = runner.event;
1268
+ className = runner.className;
1269
+ var elementEvents = angular.element._data(runner.node);
1270
+ elementEvents = elementEvents && elementEvents.events;
1271
+
1272
+ if (!parentElement) {
1273
+ parentElement = afterElement ? afterElement.parent() : element.parent();
1274
+ }
1275
+
1276
+ //skip the animation if animations are disabled, a parent is already being animated,
1277
+ //the element is not currently attached to the document body or then completely close
1278
+ //the animation if any matching animations are not found at all.
1279
+ //NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found.
1280
+ if (animationsDisabled(element, parentElement)) {
1281
+ fireDOMOperation();
1282
+ fireBeforeCallbackAsync();
1283
+ fireAfterCallbackAsync();
1284
+ closeAnimation();
1285
+ return noopCancel;
1286
+ }
1287
+
1288
+ var ngAnimateState = element.data(NG_ANIMATE_STATE) || {};
1289
+ var runningAnimations = ngAnimateState.active || {};
1290
+ var totalActiveAnimations = ngAnimateState.totalActive || 0;
1291
+ var lastAnimation = ngAnimateState.last;
1292
+ var skipAnimation = false;
1293
+
1294
+ if (totalActiveAnimations > 0) {
1295
+ var animationsToCancel = [];
1296
+ if (!runner.isClassBased) {
1297
+ if (animationEvent == 'leave' && runningAnimations['ng-leave']) {
1298
+ skipAnimation = true;
1299
+ } else {
1300
+ //cancel all animations when a structural animation takes place
1301
+ for(var klass in runningAnimations) {
1302
+ animationsToCancel.push(runningAnimations[klass]);
1303
+ }
1304
+ ngAnimateState = {};
1305
+ cleanup(element, true);
1306
+ }
1307
+ } else if (lastAnimation.event == 'setClass') {
1308
+ animationsToCancel.push(lastAnimation);
1309
+ cleanup(element, className);
1310
+ }
1311
+ else if (runningAnimations[className]) {
1312
+ var current = runningAnimations[className];
1313
+ if (current.event == animationEvent) {
1314
+ skipAnimation = true;
1315
+ } else {
1316
+ animationsToCancel.push(current);
1317
+ cleanup(element, className);
1318
+ }
1319
+ }
1320
+
1321
+ if (animationsToCancel.length > 0) {
1322
+ forEach(animationsToCancel, function(operation) {
1323
+ operation.cancel();
1324
+ });
1325
+ }
1326
+ }
1327
+
1328
+ if (runner.isClassBased
1329
+ && !runner.isSetClassOperation
1330
+ && animationEvent != 'animate'
1331
+ && !skipAnimation) {
1332
+ skipAnimation = (animationEvent == 'addClass') == element.hasClass(className); //opposite of XOR
1333
+ }
1334
+
1335
+ if (skipAnimation) {
1336
+ fireDOMOperation();
1337
+ fireBeforeCallbackAsync();
1338
+ fireAfterCallbackAsync();
1339
+ fireDoneCallbackAsync();
1340
+ return noopCancel;
1341
+ }
1342
+
1343
+ runningAnimations = ngAnimateState.active || {};
1344
+ totalActiveAnimations = ngAnimateState.totalActive || 0;
1345
+
1346
+ if (animationEvent == 'leave') {
1347
+ //there's no need to ever remove the listener since the element
1348
+ //will be removed (destroyed) after the leave animation ends or
1349
+ //is cancelled midway
1350
+ element.one('$destroy', function(e) {
1351
+ var element = angular.element(this);
1352
+ var state = element.data(NG_ANIMATE_STATE);
1353
+ if (state) {
1354
+ var activeLeaveAnimation = state.active['ng-leave'];
1355
+ if (activeLeaveAnimation) {
1356
+ activeLeaveAnimation.cancel();
1357
+ cleanup(element, 'ng-leave');
1358
+ }
1359
+ }
1360
+ });
1361
+ }
1362
+
1363
+ //the ng-animate class does nothing, but it's here to allow for
1364
+ //parent animations to find and cancel child animations when needed
1365
+ element.addClass(NG_ANIMATE_CLASS_NAME);
1366
+ if (options && options.tempClasses) {
1367
+ forEach(options.tempClasses, function(className) {
1368
+ element.addClass(className);
1369
+ });
1370
+ }
1371
+
1372
+ var localAnimationCount = globalAnimationCounter++;
1373
+ totalActiveAnimations++;
1374
+ runningAnimations[className] = runner;
1375
+
1376
+ element.data(NG_ANIMATE_STATE, {
1377
+ last : runner,
1378
+ active : runningAnimations,
1379
+ index : localAnimationCount,
1380
+ totalActive : totalActiveAnimations
1381
+ });
1382
+
1383
+ //first we run the before animations and when all of those are complete
1384
+ //then we perform the DOM operation and run the next set of animations
1385
+ fireBeforeCallbackAsync();
1386
+ runner.before(function(cancelled) {
1387
+ var data = element.data(NG_ANIMATE_STATE);
1388
+ cancelled = cancelled ||
1389
+ !data || !data.active[className] ||
1390
+ (runner.isClassBased && data.active[className].event != animationEvent);
1391
+
1392
+ fireDOMOperation();
1393
+ if (cancelled === true) {
1394
+ closeAnimation();
1395
+ } else {
1396
+ fireAfterCallbackAsync();
1397
+ runner.after(closeAnimation);
1398
+ }
1399
+ });
1400
+
1401
+ return runner.cancel;
1402
+
1403
+ function fireDOMCallback(animationPhase) {
1404
+ var eventName = '$animate:' + animationPhase;
1405
+ if (elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
1406
+ $$asyncCallback(function() {
1407
+ element.triggerHandler(eventName, {
1408
+ event : animationEvent,
1409
+ className : className
1410
+ });
1411
+ });
1412
+ }
1413
+ }
1414
+
1415
+ function fireBeforeCallbackAsync() {
1416
+ fireDOMCallback('before');
1417
+ }
1418
+
1419
+ function fireAfterCallbackAsync() {
1420
+ fireDOMCallback('after');
1421
+ }
1422
+
1423
+ function fireDoneCallbackAsync() {
1424
+ fireDOMCallback('close');
1425
+ doneCallback();
1426
+ }
1427
+
1428
+ //it is less complicated to use a flag than managing and canceling
1429
+ //timeouts containing multiple callbacks.
1430
+ function fireDOMOperation() {
1431
+ if (!fireDOMOperation.hasBeenRun) {
1432
+ fireDOMOperation.hasBeenRun = true;
1433
+ domOperation();
1434
+ }
1435
+ }
1436
+
1437
+ function closeAnimation() {
1438
+ if (!closeAnimation.hasBeenRun) {
1439
+ if (runner) { //the runner doesn't exist if it fails to instantiate
1440
+ runner.applyStyles();
1441
+ }
1442
+
1443
+ closeAnimation.hasBeenRun = true;
1444
+ if (options && options.tempClasses) {
1445
+ forEach(options.tempClasses, function(className) {
1446
+ element.removeClass(className);
1447
+ });
1448
+ }
1449
+
1450
+ var data = element.data(NG_ANIMATE_STATE);
1451
+ if (data) {
1452
+
1453
+ /* only structural animations wait for reflow before removing an
1454
+ animation, but class-based animations don't. An example of this
1455
+ failing would be when a parent HTML tag has a ng-class attribute
1456
+ causing ALL directives below to skip animations during the digest */
1457
+ if (runner && runner.isClassBased) {
1458
+ cleanup(element, className);
1459
+ } else {
1460
+ $$asyncCallback(function() {
1461
+ var data = element.data(NG_ANIMATE_STATE) || {};
1462
+ if (localAnimationCount == data.index) {
1463
+ cleanup(element, className, animationEvent);
1464
+ }
1465
+ });
1466
+ element.data(NG_ANIMATE_STATE, data);
1467
+ }
1468
+ }
1469
+ fireDoneCallbackAsync();
1470
+ }
1471
+ }
1472
+ }
1473
+
1474
+ function cancelChildAnimations(element) {
1475
+ var node = extractElementNode(element);
1476
+ if (node) {
1477
+ var nodes = angular.isFunction(node.getElementsByClassName) ?
1478
+ node.getElementsByClassName(NG_ANIMATE_CLASS_NAME) :
1479
+ node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME);
1480
+ forEach(nodes, function(element) {
1481
+ element = angular.element(element);
1482
+ var data = element.data(NG_ANIMATE_STATE);
1483
+ if (data && data.active) {
1484
+ forEach(data.active, function(runner) {
1485
+ runner.cancel();
1486
+ });
1487
+ }
1488
+ });
1489
+ }
1490
+ }
1491
+
1492
+ function cleanup(element, className) {
1493
+ if (isMatchingElement(element, $rootElement)) {
1494
+ if (!rootAnimateState.disabled) {
1495
+ rootAnimateState.running = false;
1496
+ rootAnimateState.structural = false;
1497
+ }
1498
+ } else if (className) {
1499
+ var data = element.data(NG_ANIMATE_STATE) || {};
1500
+
1501
+ var removeAnimations = className === true;
1502
+ if (!removeAnimations && data.active && data.active[className]) {
1503
+ data.totalActive--;
1504
+ delete data.active[className];
1505
+ }
1506
+
1507
+ if (removeAnimations || !data.totalActive) {
1508
+ element.removeClass(NG_ANIMATE_CLASS_NAME);
1509
+ element.removeData(NG_ANIMATE_STATE);
1510
+ }
1511
+ }
1512
+ }
1513
+
1514
+ function animationsDisabled(element, parentElement) {
1515
+ if (rootAnimateState.disabled) {
1516
+ return true;
1517
+ }
1518
+
1519
+ if (isMatchingElement(element, $rootElement)) {
1520
+ return rootAnimateState.running;
1521
+ }
1522
+
1523
+ var allowChildAnimations, parentRunningAnimation, hasParent;
1524
+ do {
1525
+ //the element did not reach the root element which means that it
1526
+ //is not apart of the DOM. Therefore there is no reason to do
1527
+ //any animations on it
1528
+ if (parentElement.length === 0) break;
1529
+
1530
+ var isRoot = isMatchingElement(parentElement, $rootElement);
1531
+ var state = isRoot ? rootAnimateState : (parentElement.data(NG_ANIMATE_STATE) || {});
1532
+ if (state.disabled) {
1533
+ return true;
1534
+ }
1535
+
1536
+ //no matter what, for an animation to work it must reach the root element
1537
+ //this implies that the element is attached to the DOM when the animation is run
1538
+ if (isRoot) {
1539
+ hasParent = true;
1540
+ }
1541
+
1542
+ //once a flag is found that is strictly false then everything before
1543
+ //it will be discarded and all child animations will be restricted
1544
+ if (allowChildAnimations !== false) {
1545
+ var animateChildrenFlag = parentElement.data(NG_ANIMATE_CHILDREN);
1546
+ if (angular.isDefined(animateChildrenFlag)) {
1547
+ allowChildAnimations = animateChildrenFlag;
1548
+ }
1549
+ }
1550
+
1551
+ parentRunningAnimation = parentRunningAnimation ||
1552
+ state.running ||
1553
+ (state.last && !state.last.isClassBased);
1554
+ }
1555
+ while(parentElement = parentElement.parent());
1556
+
1557
+ return !hasParent || (!allowChildAnimations && parentRunningAnimation);
1558
+ }
1559
+ }]);
1560
+
1561
+ $animateProvider.register('', ['$window', '$sniffer', '$timeout', '$$animateReflow',
1562
+ function($window, $sniffer, $timeout, $$animateReflow) {
1563
+ // Detect proper transitionend/animationend event names.
1564
+ var CSS_PREFIX = '', TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMATIONEND_EVENT;
1565
+
1566
+ // If unprefixed events are not supported but webkit-prefixed are, use the latter.
1567
+ // Otherwise, just use W3C names, browsers not supporting them at all will just ignore them.
1568
+ // Note: Chrome implements `window.onwebkitanimationend` and doesn't implement `window.onanimationend`
1569
+ // but at the same time dispatches the `animationend` event and not `webkitAnimationEnd`.
1570
+ // Register both events in case `window.onanimationend` is not supported because of that,
1571
+ // do the same for `transitionend` as Safari is likely to exhibit similar behavior.
1572
+ // Also, the only modern browser that uses vendor prefixes for transitions/keyframes is webkit
1573
+ // therefore there is no reason to test anymore for other vendor prefixes: http://caniuse.com/#search=transition
1574
+ if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
1575
+ CSS_PREFIX = '-webkit-';
1576
+ TRANSITION_PROP = 'WebkitTransition';
1577
+ TRANSITIONEND_EVENT = 'webkitTransitionEnd transitionend';
1578
+ } else {
1579
+ TRANSITION_PROP = 'transition';
1580
+ TRANSITIONEND_EVENT = 'transitionend';
1581
+ }
1582
+
1583
+ if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
1584
+ CSS_PREFIX = '-webkit-';
1585
+ ANIMATION_PROP = 'WebkitAnimation';
1586
+ ANIMATIONEND_EVENT = 'webkitAnimationEnd animationend';
1587
+ } else {
1588
+ ANIMATION_PROP = 'animation';
1589
+ ANIMATIONEND_EVENT = 'animationend';
1590
+ }
1591
+
1592
+ var DURATION_KEY = 'Duration';
1593
+ var PROPERTY_KEY = 'Property';
1594
+ var DELAY_KEY = 'Delay';
1595
+ var ANIMATION_ITERATION_COUNT_KEY = 'IterationCount';
1596
+ var ANIMATION_PLAYSTATE_KEY = 'PlayState';
1597
+ var NG_ANIMATE_PARENT_KEY = '$$ngAnimateKey';
1598
+ var NG_ANIMATE_CSS_DATA_KEY = '$$ngAnimateCSS3Data';
1599
+ var ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
1600
+ var CLOSING_TIME_BUFFER = 1.5;
1601
+ var ONE_SECOND = 1000;
1602
+
1603
+ var lookupCache = {};
1604
+ var parentCounter = 0;
1605
+ var animationReflowQueue = [];
1606
+ var cancelAnimationReflow;
1607
+ function clearCacheAfterReflow() {
1608
+ if (!cancelAnimationReflow) {
1609
+ cancelAnimationReflow = $$animateReflow(function() {
1610
+ animationReflowQueue = [];
1611
+ cancelAnimationReflow = null;
1612
+ lookupCache = {};
1613
+ });
1614
+ }
1615
+ }
1616
+
1617
+ function afterReflow(element, callback) {
1618
+ if (cancelAnimationReflow) {
1619
+ cancelAnimationReflow();
1620
+ }
1621
+ animationReflowQueue.push(callback);
1622
+ cancelAnimationReflow = $$animateReflow(function() {
1623
+ forEach(animationReflowQueue, function(fn) {
1624
+ fn();
1625
+ });
1626
+
1627
+ animationReflowQueue = [];
1628
+ cancelAnimationReflow = null;
1629
+ lookupCache = {};
1630
+ });
1631
+ }
1632
+
1633
+ var closingTimer = null;
1634
+ var closingTimestamp = 0;
1635
+ var animationElementQueue = [];
1636
+ function animationCloseHandler(element, totalTime) {
1637
+ var node = extractElementNode(element);
1638
+ element = angular.element(node);
1639
+
1640
+ //this item will be garbage collected by the closing
1641
+ //animation timeout
1642
+ animationElementQueue.push(element);
1643
+
1644
+ //but it may not need to cancel out the existing timeout
1645
+ //if the timestamp is less than the previous one
1646
+ var futureTimestamp = Date.now() + totalTime;
1647
+ if (futureTimestamp <= closingTimestamp) {
1648
+ return;
1649
+ }
1650
+
1651
+ $timeout.cancel(closingTimer);
1652
+
1653
+ closingTimestamp = futureTimestamp;
1654
+ closingTimer = $timeout(function() {
1655
+ closeAllAnimations(animationElementQueue);
1656
+ animationElementQueue = [];
1657
+ }, totalTime, false);
1658
+ }
1659
+
1660
+ function closeAllAnimations(elements) {
1661
+ forEach(elements, function(element) {
1662
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1663
+ if (elementData) {
1664
+ forEach(elementData.closeAnimationFns, function(fn) {
1665
+ fn();
1666
+ });
1667
+ }
1668
+ });
1669
+ }
1670
+
1671
+ function getElementAnimationDetails(element, cacheKey) {
1672
+ var data = cacheKey ? lookupCache[cacheKey] : null;
1673
+ if (!data) {
1674
+ var transitionDuration = 0;
1675
+ var transitionDelay = 0;
1676
+ var animationDuration = 0;
1677
+ var animationDelay = 0;
1678
+
1679
+ //we want all the styles defined before and after
1680
+ forEach(element, function(element) {
1681
+ if (element.nodeType == ELEMENT_NODE) {
1682
+ var elementStyles = $window.getComputedStyle(element) || {};
1683
+
1684
+ var transitionDurationStyle = elementStyles[TRANSITION_PROP + DURATION_KEY];
1685
+ transitionDuration = Math.max(parseMaxTime(transitionDurationStyle), transitionDuration);
1686
+
1687
+ var transitionDelayStyle = elementStyles[TRANSITION_PROP + DELAY_KEY];
1688
+ transitionDelay = Math.max(parseMaxTime(transitionDelayStyle), transitionDelay);
1689
+
1690
+ var animationDelayStyle = elementStyles[ANIMATION_PROP + DELAY_KEY];
1691
+ animationDelay = Math.max(parseMaxTime(elementStyles[ANIMATION_PROP + DELAY_KEY]), animationDelay);
1692
+
1693
+ var aDuration = parseMaxTime(elementStyles[ANIMATION_PROP + DURATION_KEY]);
1694
+
1695
+ if (aDuration > 0) {
1696
+ aDuration *= parseInt(elementStyles[ANIMATION_PROP + ANIMATION_ITERATION_COUNT_KEY], 10) || 1;
1697
+ }
1698
+ animationDuration = Math.max(aDuration, animationDuration);
1699
+ }
1700
+ });
1701
+ data = {
1702
+ total : 0,
1703
+ transitionDelay: transitionDelay,
1704
+ transitionDuration: transitionDuration,
1705
+ animationDelay: animationDelay,
1706
+ animationDuration: animationDuration
1707
+ };
1708
+ if (cacheKey) {
1709
+ lookupCache[cacheKey] = data;
1710
+ }
1711
+ }
1712
+ return data;
1713
+ }
1714
+
1715
+ function parseMaxTime(str) {
1716
+ var maxValue = 0;
1717
+ var values = isString(str) ?
1718
+ str.split(/\s*,\s*/) :
1719
+ [];
1720
+ forEach(values, function(value) {
1721
+ maxValue = Math.max(parseFloat(value) || 0, maxValue);
1722
+ });
1723
+ return maxValue;
1724
+ }
1725
+
1726
+ function getCacheKey(element) {
1727
+ var parentElement = element.parent();
1728
+ var parentID = parentElement.data(NG_ANIMATE_PARENT_KEY);
1729
+ if (!parentID) {
1730
+ parentElement.data(NG_ANIMATE_PARENT_KEY, ++parentCounter);
1731
+ parentID = parentCounter;
1732
+ }
1733
+ return parentID + '-' + extractElementNode(element).getAttribute('class');
1734
+ }
1735
+
1736
+ function animateSetup(animationEvent, element, className, styles) {
1737
+ var structural = ['ng-enter','ng-leave','ng-move'].indexOf(className) >= 0;
1738
+
1739
+ var cacheKey = getCacheKey(element);
1740
+ var eventCacheKey = cacheKey + ' ' + className;
1741
+ var itemIndex = lookupCache[eventCacheKey] ? ++lookupCache[eventCacheKey].total : 0;
1742
+
1743
+ var stagger = {};
1744
+ if (itemIndex > 0) {
1745
+ var staggerClassName = className + '-stagger';
1746
+ var staggerCacheKey = cacheKey + ' ' + staggerClassName;
1747
+ var applyClasses = !lookupCache[staggerCacheKey];
1748
+
1749
+ applyClasses && element.addClass(staggerClassName);
1750
+
1751
+ stagger = getElementAnimationDetails(element, staggerCacheKey);
1752
+
1753
+ applyClasses && element.removeClass(staggerClassName);
1754
+ }
1755
+
1756
+ element.addClass(className);
1757
+
1758
+ var formerData = element.data(NG_ANIMATE_CSS_DATA_KEY) || {};
1759
+ var timings = getElementAnimationDetails(element, eventCacheKey);
1760
+ var transitionDuration = timings.transitionDuration;
1761
+ var animationDuration = timings.animationDuration;
1762
+
1763
+ if (structural && transitionDuration === 0 && animationDuration === 0) {
1764
+ element.removeClass(className);
1765
+ return false;
1766
+ }
1767
+
1768
+ var blockTransition = styles || (structural && transitionDuration > 0);
1769
+ var blockAnimation = animationDuration > 0 &&
1770
+ stagger.animationDelay > 0 &&
1771
+ stagger.animationDuration === 0;
1772
+
1773
+ var closeAnimationFns = formerData.closeAnimationFns || [];
1774
+ element.data(NG_ANIMATE_CSS_DATA_KEY, {
1775
+ stagger : stagger,
1776
+ cacheKey : eventCacheKey,
1777
+ running : formerData.running || 0,
1778
+ itemIndex : itemIndex,
1779
+ blockTransition : blockTransition,
1780
+ closeAnimationFns : closeAnimationFns
1781
+ });
1782
+
1783
+ var node = extractElementNode(element);
1784
+
1785
+ if (blockTransition) {
1786
+ blockTransitions(node, true);
1787
+ if (styles) {
1788
+ element.css(styles);
1789
+ }
1790
+ }
1791
+
1792
+ if (blockAnimation) {
1793
+ blockAnimations(node, true);
1794
+ }
1795
+
1796
+ return true;
1797
+ }
1798
+
1799
+ function animateRun(animationEvent, element, className, activeAnimationComplete, styles) {
1800
+ var node = extractElementNode(element);
1801
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1802
+ if (node.getAttribute('class').indexOf(className) == -1 || !elementData) {
1803
+ activeAnimationComplete();
1804
+ return;
1805
+ }
1806
+
1807
+ var activeClassName = '';
1808
+ var pendingClassName = '';
1809
+ forEach(className.split(' '), function(klass, i) {
1810
+ var prefix = (i > 0 ? ' ' : '') + klass;
1811
+ activeClassName += prefix + '-active';
1812
+ pendingClassName += prefix + '-pending';
1813
+ });
1814
+
1815
+ var style = '';
1816
+ var appliedStyles = [];
1817
+ var itemIndex = elementData.itemIndex;
1818
+ var stagger = elementData.stagger;
1819
+ var staggerTime = 0;
1820
+ if (itemIndex > 0) {
1821
+ var transitionStaggerDelay = 0;
1822
+ if (stagger.transitionDelay > 0 && stagger.transitionDuration === 0) {
1823
+ transitionStaggerDelay = stagger.transitionDelay * itemIndex;
1824
+ }
1825
+
1826
+ var animationStaggerDelay = 0;
1827
+ if (stagger.animationDelay > 0 && stagger.animationDuration === 0) {
1828
+ animationStaggerDelay = stagger.animationDelay * itemIndex;
1829
+ appliedStyles.push(CSS_PREFIX + 'animation-play-state');
1830
+ }
1831
+
1832
+ staggerTime = Math.round(Math.max(transitionStaggerDelay, animationStaggerDelay) * 100) / 100;
1833
+ }
1834
+
1835
+ if (!staggerTime) {
1836
+ element.addClass(activeClassName);
1837
+ if (elementData.blockTransition) {
1838
+ blockTransitions(node, false);
1839
+ }
1840
+ }
1841
+
1842
+ var eventCacheKey = elementData.cacheKey + ' ' + activeClassName;
1843
+ var timings = getElementAnimationDetails(element, eventCacheKey);
1844
+ var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration);
1845
+ if (maxDuration === 0) {
1846
+ element.removeClass(activeClassName);
1847
+ animateClose(element, className);
1848
+ activeAnimationComplete();
1849
+ return;
1850
+ }
1851
+
1852
+ if (!staggerTime && styles) {
1853
+ if (!timings.transitionDuration) {
1854
+ element.css('transition', timings.animationDuration + 's linear all');
1855
+ appliedStyles.push('transition');
1856
+ }
1857
+ element.css(styles);
1858
+ }
1859
+
1860
+ var maxDelay = Math.max(timings.transitionDelay, timings.animationDelay);
1861
+ var maxDelayTime = maxDelay * ONE_SECOND;
1862
+
1863
+ if (appliedStyles.length > 0) {
1864
+ //the element being animated may sometimes contain comment nodes in
1865
+ //the jqLite object, so we're safe to use a single variable to house
1866
+ //the styles since there is always only one element being animated
1867
+ var oldStyle = node.getAttribute('style') || '';
1868
+ if (oldStyle.charAt(oldStyle.length-1) !== ';') {
1869
+ oldStyle += ';';
1870
+ }
1871
+ node.setAttribute('style', oldStyle + ' ' + style);
1872
+ }
1873
+
1874
+ var startTime = Date.now();
1875
+ var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
1876
+ var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER;
1877
+ var totalTime = (staggerTime + animationTime) * ONE_SECOND;
1878
+
1879
+ var staggerTimeout;
1880
+ if (staggerTime > 0) {
1881
+ element.addClass(pendingClassName);
1882
+ staggerTimeout = $timeout(function() {
1883
+ staggerTimeout = null;
1884
+
1885
+ if (timings.transitionDuration > 0) {
1886
+ blockTransitions(node, false);
1887
+ }
1888
+ if (timings.animationDuration > 0) {
1889
+ blockAnimations(node, false);
1890
+ }
1891
+
1892
+ element.addClass(activeClassName);
1893
+ element.removeClass(pendingClassName);
1894
+
1895
+ if (styles) {
1896
+ if (timings.transitionDuration === 0) {
1897
+ element.css('transition', timings.animationDuration + 's linear all');
1898
+ }
1899
+ element.css(styles);
1900
+ appliedStyles.push('transition');
1901
+ }
1902
+ }, staggerTime * ONE_SECOND, false);
1903
+ }
1904
+
1905
+ element.on(css3AnimationEvents, onAnimationProgress);
1906
+ elementData.closeAnimationFns.push(function() {
1907
+ onEnd();
1908
+ activeAnimationComplete();
1909
+ });
1910
+
1911
+ elementData.running++;
1912
+ animationCloseHandler(element, totalTime);
1913
+ return onEnd;
1914
+
1915
+ // This will automatically be called by $animate so
1916
+ // there is no need to attach this internally to the
1917
+ // timeout done method.
1918
+ function onEnd() {
1919
+ element.off(css3AnimationEvents, onAnimationProgress);
1920
+ element.removeClass(activeClassName);
1921
+ element.removeClass(pendingClassName);
1922
+ if (staggerTimeout) {
1923
+ $timeout.cancel(staggerTimeout);
1924
+ }
1925
+ animateClose(element, className);
1926
+ var node = extractElementNode(element);
1927
+ for (var i in appliedStyles) {
1928
+ node.style.removeProperty(appliedStyles[i]);
1929
+ }
1930
+ }
1931
+
1932
+ function onAnimationProgress(event) {
1933
+ event.stopPropagation();
1934
+ var ev = event.originalEvent || event;
1935
+ var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now();
1936
+
1937
+ /* Firefox (or possibly just Gecko) likes to not round values up
1938
+ * when a ms measurement is used for the animation */
1939
+ var elapsedTime = parseFloat(ev.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES));
1940
+
1941
+ /* $manualTimeStamp is a mocked timeStamp value which is set
1942
+ * within browserTrigger(). This is only here so that tests can
1943
+ * mock animations properly. Real events fallback to event.timeStamp,
1944
+ * or, if they don't, then a timeStamp is automatically created for them.
1945
+ * We're checking to see if the timeStamp surpasses the expected delay,
1946
+ * but we're using elapsedTime instead of the timeStamp on the 2nd
1947
+ * pre-condition since animations sometimes close off early */
1948
+ if (Math.max(timeStamp - startTime, 0) >= maxDelayTime && elapsedTime >= maxDuration) {
1949
+ activeAnimationComplete();
1950
+ }
1951
+ }
1952
+ }
1953
+
1954
+ function blockTransitions(node, bool) {
1955
+ node.style[TRANSITION_PROP + PROPERTY_KEY] = bool ? 'none' : '';
1956
+ }
1957
+
1958
+ function blockAnimations(node, bool) {
1959
+ node.style[ANIMATION_PROP + ANIMATION_PLAYSTATE_KEY] = bool ? 'paused' : '';
1960
+ }
1961
+
1962
+ function animateBefore(animationEvent, element, className, styles) {
1963
+ if (animateSetup(animationEvent, element, className, styles)) {
1964
+ return function(cancelled) {
1965
+ cancelled && animateClose(element, className);
1966
+ };
1967
+ }
1968
+ }
1969
+
1970
+ function animateAfter(animationEvent, element, className, afterAnimationComplete, styles) {
1971
+ if (element.data(NG_ANIMATE_CSS_DATA_KEY)) {
1972
+ return animateRun(animationEvent, element, className, afterAnimationComplete, styles);
1973
+ } else {
1974
+ animateClose(element, className);
1975
+ afterAnimationComplete();
1976
+ }
1977
+ }
1978
+
1979
+ function animate(animationEvent, element, className, animationComplete, options) {
1980
+ //If the animateSetup function doesn't bother returning a
1981
+ //cancellation function then it means that there is no animation
1982
+ //to perform at all
1983
+ var preReflowCancellation = animateBefore(animationEvent, element, className, options.from);
1984
+ if (!preReflowCancellation) {
1985
+ clearCacheAfterReflow();
1986
+ animationComplete();
1987
+ return;
1988
+ }
1989
+
1990
+ //There are two cancellation functions: one is before the first
1991
+ //reflow animation and the second is during the active state
1992
+ //animation. The first function will take care of removing the
1993
+ //data from the element which will not make the 2nd animation
1994
+ //happen in the first place
1995
+ var cancel = preReflowCancellation;
1996
+ afterReflow(element, function() {
1997
+ //once the reflow is complete then we point cancel to
1998
+ //the new cancellation function which will remove all of the
1999
+ //animation properties from the active animation
2000
+ cancel = animateAfter(animationEvent, element, className, animationComplete, options.to);
2001
+ });
2002
+
2003
+ return function(cancelled) {
2004
+ (cancel || noop)(cancelled);
2005
+ };
2006
+ }
2007
+
2008
+ function animateClose(element, className) {
2009
+ element.removeClass(className);
2010
+ var data = element.data(NG_ANIMATE_CSS_DATA_KEY);
2011
+ if (data) {
2012
+ if (data.running) {
2013
+ data.running--;
2014
+ }
2015
+ if (!data.running || data.running === 0) {
2016
+ element.removeData(NG_ANIMATE_CSS_DATA_KEY);
2017
+ }
2018
+ }
2019
+ }
2020
+
2021
+ return {
2022
+ animate : function(element, className, from, to, animationCompleted, options) {
2023
+ options = options || {};
2024
+ options.from = from;
2025
+ options.to = to;
2026
+ return animate('animate', element, className, animationCompleted, options);
2027
+ },
2028
+
2029
+ enter : function(element, animationCompleted, options) {
2030
+ options = options || {};
2031
+ return animate('enter', element, 'ng-enter', animationCompleted, options);
2032
+ },
2033
+
2034
+ leave : function(element, animationCompleted, options) {
2035
+ options = options || {};
2036
+ return animate('leave', element, 'ng-leave', animationCompleted, options);
2037
+ },
2038
+
2039
+ move : function(element, animationCompleted, options) {
2040
+ options = options || {};
2041
+ return animate('move', element, 'ng-move', animationCompleted, options);
2042
+ },
2043
+
2044
+ beforeSetClass : function(element, add, remove, animationCompleted, options) {
2045
+ options = options || {};
2046
+ var className = suffixClasses(remove, '-remove') + ' ' +
2047
+ suffixClasses(add, '-add');
2048
+ var cancellationMethod = animateBefore('setClass', element, className, options.from);
2049
+ if (cancellationMethod) {
2050
+ afterReflow(element, animationCompleted);
2051
+ return cancellationMethod;
2052
+ }
2053
+ clearCacheAfterReflow();
2054
+ animationCompleted();
2055
+ },
2056
+
2057
+ beforeAddClass : function(element, className, animationCompleted, options) {
2058
+ options = options || {};
2059
+ var cancellationMethod = animateBefore('addClass', element, suffixClasses(className, '-add'), options.from);
2060
+ if (cancellationMethod) {
2061
+ afterReflow(element, animationCompleted);
2062
+ return cancellationMethod;
2063
+ }
2064
+ clearCacheAfterReflow();
2065
+ animationCompleted();
2066
+ },
2067
+
2068
+ beforeRemoveClass : function(element, className, animationCompleted, options) {
2069
+ options = options || {};
2070
+ var cancellationMethod = animateBefore('removeClass', element, suffixClasses(className, '-remove'), options.from);
2071
+ if (cancellationMethod) {
2072
+ afterReflow(element, animationCompleted);
2073
+ return cancellationMethod;
2074
+ }
2075
+ clearCacheAfterReflow();
2076
+ animationCompleted();
2077
+ },
2078
+
2079
+ setClass : function(element, add, remove, animationCompleted, options) {
2080
+ options = options || {};
2081
+ remove = suffixClasses(remove, '-remove');
2082
+ add = suffixClasses(add, '-add');
2083
+ var className = remove + ' ' + add;
2084
+ return animateAfter('setClass', element, className, animationCompleted, options.to);
2085
+ },
2086
+
2087
+ addClass : function(element, className, animationCompleted, options) {
2088
+ options = options || {};
2089
+ return animateAfter('addClass', element, suffixClasses(className, '-add'), animationCompleted, options.to);
2090
+ },
2091
+
2092
+ removeClass : function(element, className, animationCompleted, options) {
2093
+ options = options || {};
2094
+ return animateAfter('removeClass', element, suffixClasses(className, '-remove'), animationCompleted, options.to);
2095
+ }
2096
+ };
2097
+
2098
+ function suffixClasses(classes, suffix) {
2099
+ var className = '';
2100
+ classes = isArray(classes) ? classes : classes.split(/\s+/);
2101
+ forEach(classes, function(klass, i) {
2102
+ if (klass && klass.length > 0) {
2103
+ className += (i > 0 ? ' ' : '') + klass + suffix;
2104
+ }
2105
+ });
2106
+ return className;
2107
+ }
2108
+ }]);
2109
+ }]);
2110
+
2111
+
2112
+ })(window, window.angular);