interval-braining-ui-asset-pack 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/asset_pack/engine.rb +5 -2
  3. data/lib/asset_pack/version.rb +1 -1
  4. data/vendor/assets/bower_components/angular/angular.js +23377 -0
  5. data/vendor/assets/bower_components/angular-animate/angular-animate.js +1729 -0
  6. data/vendor/assets/bower_components/angular-growl-notifications/dist/growl-notifications.js +241 -0
  7. data/vendor/assets/bower_components/angular-input-match/dist/angular-input-match.js +39 -0
  8. data/vendor/assets/bower_components/angular-messages/angular-messages.js +400 -0
  9. data/vendor/assets/bower_components/angular-mocks/angular-mocks.js +2228 -0
  10. data/vendor/assets/bower_components/angular-resource/angular-resource.js +660 -0
  11. data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.js +640 -0
  12. data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js +3223 -0
  13. data/vendor/assets/bower_components/angular-ui-router-breadcrumbs/dist/angular-ui-router-breadcrumbs.js +82 -0
  14. data/vendor/assets/bower_components/angular-ui-router-helpers/dist/angular-ui-router-helpers.js +52 -0
  15. data/vendor/assets/bower_components/angular-ui-router-hooks-before-state/dist/angular-ui-router-hooks-before-state.js +56 -0
  16. data/vendor/assets/bower_components/angular-validate-in-set/dist/angular-validate-in-set.js +77 -0
  17. data/vendor/assets/bower_components/animate.css/animate.css +3125 -0
  18. data/vendor/assets/bower_components/bootstrap/dist/css/bootstrap.css +5785 -0
  19. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  20. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +229 -0
  21. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  22. data/vendor/assets/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  23. data/vendor/assets/bower_components/bootstrap/dist/js/bootstrap.js +1951 -0
  24. data/vendor/assets/bower_components/cardigan/dist/cardigan.css +37 -0
  25. data/vendor/assets/bower_components/cardigan/dist/cardigan.js +239 -0
  26. data/vendor/assets/bower_components/font-awesome-bower/css/font-awesome.css +1338 -0
  27. data/vendor/assets/bower_components/font-awesome-bower/fonts/FontAwesome.otf +0 -0
  28. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.eot +0 -0
  29. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.svg +414 -0
  30. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.ttf +0 -0
  31. data/vendor/assets/bower_components/font-awesome-bower/fonts/fontawesome-webfont.woff +0 -0
  32. data/vendor/assets/bower_components/jquery/dist/jquery.js +9190 -0
  33. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.css +10 -0
  34. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.eot +0 -0
  35. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.svg +1831 -0
  36. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.ttf +0 -0
  37. data/vendor/assets/bower_components/webfont-OpenSans-Light/dist/OpenSans-Light.woff +0 -0
  38. metadata +36 -2
@@ -0,0 +1,1729 @@
1
+ /**
2
+ * @license AngularJS v1.3.0-build.2991+sha.9025113
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#usage_animations ngRepeat} | enter, leave and move |
31
+ * | {@link ngRoute.directive:ngView#usage_animations ngView} | enter and leave |
32
+ * | {@link ng.directive:ngInclude#usage_animations ngInclude} | enter and leave |
33
+ * | {@link ng.directive:ngSwitch#usage_animations ngSwitch} | enter and leave |
34
+ * | {@link ng.directive:ngIf#usage_animations ngIf} | enter and leave |
35
+ * | {@link ng.directive:ngClass#usage_animations ngClass} | add and remove (the CSS class(es) present) |
36
+ * | {@link ng.directive:ngShow#usage_animations ngShow} & {@link ng.directive:ngHide#usage_animations ngHide} | add and remove (the ng-hide class value) |
37
+ * | {@link ng.directive:form#usage_animations form} & {@link ng.directive:ngModel#usage_animations ngModel} | add and remove (dirty, pristine, valid, invalid & all other validations) |
38
+ * | {@link ngMessages.directive:ngMessage#usage_animations ngMessages} | add and remove (ng-active & ng-inactive) |
39
+ * | {@link ngMessages.directive:ngMessage#usage_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
+ * <h2>CSS-defined Animations</h2>
83
+ * The animate service will automatically apply two CSS classes to the animated element and these two CSS classes
84
+ * are designed to contain the start and end CSS styling. Both CSS transitions and keyframe animations are supported
85
+ * and can be used to play along with this naming structure.
86
+ *
87
+ * The following code below demonstrates how to perform animations using **CSS transitions** with Angular:
88
+ *
89
+ * ```html
90
+ * <style type="text/css">
91
+ * /&#42;
92
+ * The animate class is apart of the element and the ng-enter class
93
+ * is attached to the element once the enter animation event is triggered
94
+ * &#42;/
95
+ * .reveal-animation.ng-enter {
96
+ * -webkit-transition: 1s linear all; /&#42; Safari/Chrome &#42;/
97
+ * transition: 1s linear all; /&#42; All other modern browsers and IE10+ &#42;/
98
+ *
99
+ * /&#42; The animation preparation code &#42;/
100
+ * opacity: 0;
101
+ * }
102
+ *
103
+ * /&#42;
104
+ * Keep in mind that you want to combine both CSS
105
+ * classes together to avoid any CSS-specificity
106
+ * conflicts
107
+ * &#42;/
108
+ * .reveal-animation.ng-enter.ng-enter-active {
109
+ * /&#42; The animation code itself &#42;/
110
+ * opacity: 1;
111
+ * }
112
+ * </style>
113
+ *
114
+ * <div class="view-container">
115
+ * <div ng-view class="reveal-animation"></div>
116
+ * </div>
117
+ * ```
118
+ *
119
+ * The following code below demonstrates how to perform animations using **CSS animations** with Angular:
120
+ *
121
+ * ```html
122
+ * <style type="text/css">
123
+ * .reveal-animation.ng-enter {
124
+ * -webkit-animation: enter_sequence 1s linear; /&#42; Safari/Chrome &#42;/
125
+ * animation: enter_sequence 1s linear; /&#42; IE10+ and Future Browsers &#42;/
126
+ * }
127
+ * @-webkit-keyframes enter_sequence {
128
+ * from { opacity:0; }
129
+ * to { opacity:1; }
130
+ * }
131
+ * @keyframes enter_sequence {
132
+ * from { opacity:0; }
133
+ * to { opacity:1; }
134
+ * }
135
+ * </style>
136
+ *
137
+ * <div class="view-container">
138
+ * <div ng-view class="reveal-animation"></div>
139
+ * </div>
140
+ * ```
141
+ *
142
+ * Both CSS3 animations and transitions can be used together and the animate service will figure out the correct duration and delay timing.
143
+ *
144
+ * Upon DOM mutation, the event class is added first (something like `ng-enter`), then the browser prepares itself to add
145
+ * the active class (in this case `ng-enter-active`) which then triggers the animation. The animation module will automatically
146
+ * detect the CSS code to determine when the animation ends. Once the animation is over then both CSS classes will be
147
+ * removed from the DOM. If a browser does not support CSS transitions or CSS animations then the animation will start and end
148
+ * immediately resulting in a DOM element that is at its final state. This final state is when the DOM element
149
+ * has no CSS transition/animation classes applied to it.
150
+ *
151
+ * ### Structural transition animations
152
+ *
153
+ * Structural transitions (such as enter, leave and move) will always apply a `0s none` transition
154
+ * value to force the browser into rendering the styles defined in the setup (.ng-enter, .ng-leave
155
+ * or .ng-move) class. This means that any active transition animations operating on the element
156
+ * will be cut off to make way for the enter, leave or move animation.
157
+ *
158
+ * ### Class-based transition animations
159
+ *
160
+ * Class-based transitions refer to transition animations that are triggered when a CSS class is
161
+ * added to or removed from the element (via `$animate.addClass`, `$animate.removeClass`,
162
+ * `$animate.setClass`, or by directives such as `ngClass`, `ngModel` and `form`).
163
+ * They are different when compared to structural animations since they **do not cancel existing
164
+ * animations** nor do they **block successive transitions** from rendering on the same element.
165
+ * This distinction allows for **multiple class-based transitions** to be performed on the same element.
166
+ *
167
+ * In addition to ngAnimate supporting the default (natural) functionality of class-based transition
168
+ * animations, ngAnimate also decorates the element with starting and ending CSS classes to aid the
169
+ * developer in further styling the element throughout the transition animation. Earlier versions
170
+ * of ngAnimate may have caused natural CSS transitions to break and not render properly due to
171
+ * $animate temporarily blocking transitions using `0s none` in order to allow the setup CSS class
172
+ * (the `-add` or `-remove` class) to be applied without triggering an animation. However, as of
173
+ * **version 1.3**, this workaround has been removed with ngAnimate and all non-ngAnimate CSS
174
+ * class transitions are compatible with ngAnimate.
175
+ *
176
+ * There is, however, one special case when dealing with class-based transitions in ngAnimate.
177
+ * When rendering class-based transitions that make use of the setup and active CSS classes
178
+ * (e.g. `.fade-add` and `.fade-add-active` for when `.fade` is added) be sure to define
179
+ * the transition value **on the active CSS class** and not the setup class.
180
+ *
181
+ * ```css
182
+ * .fade-add {
183
+ * /&#42; remember to place a 0s transition here
184
+ * to ensure that the styles are applied instantly
185
+ * even if the element already has a transition style &#42;/
186
+ * transition:0s linear all;
187
+ *
188
+ * /&#42; starting CSS styles &#42;/
189
+ * opacity:1;
190
+ * }
191
+ * .fade-add.fade-add-active {
192
+ * /&#42; this will be the length of the animation &#42;/
193
+ * transition:1s linear all;
194
+ * opacity:0;
195
+ * }
196
+ * ```
197
+ *
198
+ * The setup CSS class (in this case `.fade-add`) also has a transition style property, however, it
199
+ * has a duration of zero. This may not be required, however, incase the browser is unable to render
200
+ * the styling present in this CSS class instantly then it could be that the browser is attempting
201
+ * to perform an unnecessary transition.
202
+ *
203
+ * This workaround, however, does not apply to standard class-based transitions that are rendered
204
+ * when a CSS class containing a transition is applied to an element:
205
+ *
206
+ * ```css
207
+ * .fade {
208
+ * /&#42; this works as expected &#42;/
209
+ * transition:1s linear all;
210
+ * opacity:0;
211
+ * }
212
+ * ```
213
+ *
214
+ * Please keep this in mind when coding the CSS markup that will be used within class-based transitions.
215
+ * Also, try not to mix the two class-based animation flavors together since the CSS code may become
216
+ * overly complex.
217
+ *
218
+ * ### CSS Staggering Animations
219
+ * A Staggering animation is a collection of animations that are issued with a slight delay in between each successive operation resulting in a
220
+ * curtain-like effect. The ngAnimate module, as of 1.2.0, supports staggering animations and the stagger effect can be
221
+ * performed by creating a **ng-EVENT-stagger** CSS class and attaching that class to the base CSS class used for
222
+ * the animation. The style property expected within the stagger class can either be a **transition-delay** or an
223
+ * **animation-delay** property (or both if your animation contains both transitions and keyframe animations).
224
+ *
225
+ * ```css
226
+ * .my-animation.ng-enter {
227
+ * /&#42; standard transition code &#42;/
228
+ * -webkit-transition: 1s linear all;
229
+ * transition: 1s linear all;
230
+ * opacity:0;
231
+ * }
232
+ * .my-animation.ng-enter-stagger {
233
+ * /&#42; this will have a 100ms delay between each successive leave animation &#42;/
234
+ * -webkit-transition-delay: 0.1s;
235
+ * transition-delay: 0.1s;
236
+ *
237
+ * /&#42; in case the stagger doesn't work then these two values
238
+ * must be set to 0 to avoid an accidental CSS inheritance &#42;/
239
+ * -webkit-transition-duration: 0s;
240
+ * transition-duration: 0s;
241
+ * }
242
+ * .my-animation.ng-enter.ng-enter-active {
243
+ * /&#42; standard transition styles &#42;/
244
+ * opacity:1;
245
+ * }
246
+ * ```
247
+ *
248
+ * Staggering animations work by default in ngRepeat (so long as the CSS class is defined). Outside of ngRepeat, to use staggering animations
249
+ * on your own, they can be triggered by firing multiple calls to the same event on $animate. However, the restrictions surrounding this
250
+ * are that each of the elements must have the same CSS className value as well as the same parent element. A stagger operation
251
+ * will also be reset if more than 10ms has passed after the last animation has been fired.
252
+ *
253
+ * The following code will issue the **ng-leave-stagger** event on the element provided:
254
+ *
255
+ * ```js
256
+ * var kids = parent.children();
257
+ *
258
+ * $animate.leave(kids[0]); //stagger index=0
259
+ * $animate.leave(kids[1]); //stagger index=1
260
+ * $animate.leave(kids[2]); //stagger index=2
261
+ * $animate.leave(kids[3]); //stagger index=3
262
+ * $animate.leave(kids[4]); //stagger index=4
263
+ *
264
+ * $timeout(function() {
265
+ * //stagger has reset itself
266
+ * $animate.leave(kids[5]); //stagger index=0
267
+ * $animate.leave(kids[6]); //stagger index=1
268
+ * }, 100, false);
269
+ * ```
270
+ *
271
+ * Stagger animations are currently only supported within CSS-defined animations.
272
+ *
273
+ * <h2>JavaScript-defined Animations</h2>
274
+ * 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
275
+ * yet support CSS transitions/animations, then you can make use of JavaScript animations defined inside of your AngularJS module.
276
+ *
277
+ * ```js
278
+ * //!annotate="YourApp" Your AngularJS Module|Replace this or ngModule with the module that you used to define your application.
279
+ * var ngModule = angular.module('YourApp', ['ngAnimate']);
280
+ * ngModule.animation('.my-crazy-animation', function() {
281
+ * return {
282
+ * enter: function(element, done) {
283
+ * //run the animation here and call done when the animation is complete
284
+ * return function(cancelled) {
285
+ * //this (optional) function will be called when the animation
286
+ * //completes or when the animation is cancelled (the cancelled
287
+ * //flag will be set to true if cancelled).
288
+ * };
289
+ * },
290
+ * leave: function(element, done) { },
291
+ * move: function(element, done) { },
292
+ *
293
+ * //animation that can be triggered before the class is added
294
+ * beforeAddClass: function(element, className, done) { },
295
+ *
296
+ * //animation that can be triggered after the class is added
297
+ * addClass: function(element, className, done) { },
298
+ *
299
+ * //animation that can be triggered before the class is removed
300
+ * beforeRemoveClass: function(element, className, done) { },
301
+ *
302
+ * //animation that can be triggered after the class is removed
303
+ * removeClass: function(element, className, done) { }
304
+ * };
305
+ * });
306
+ * ```
307
+ *
308
+ * JavaScript-defined animations are created with a CSS-like class selector and a collection of events which are set to run
309
+ * a javascript callback function. When an animation is triggered, $animate will look for a matching animation which fits
310
+ * the element's CSS class attribute value and then run the matching animation event function (if found).
311
+ * In other words, if the CSS classes present on the animated element match any of the JavaScript animations then the callback function will
312
+ * be executed. It should be also noted that only simple, single class selectors are allowed (compound class selectors are not supported).
313
+ *
314
+ * Within a JavaScript animation, an object containing various event callback animation functions is expected to be returned.
315
+ * As explained above, these callbacks are triggered based on the animation event. Therefore if an enter animation is run,
316
+ * and the JavaScript animation is found, then the enter callback will handle that animation (in addition to the CSS keyframe animation
317
+ * or transition code that is defined via a stylesheet).
318
+ *
319
+ */
320
+
321
+ angular.module('ngAnimate', ['ng'])
322
+
323
+ /**
324
+ * @ngdoc provider
325
+ * @name $animateProvider
326
+ * @description
327
+ *
328
+ * The `$animateProvider` allows developers to register JavaScript animation event handlers directly inside of a module.
329
+ * When an animation is triggered, the $animate service will query the $animate service to find any animations that match
330
+ * the provided name value.
331
+ *
332
+ * Requires the {@link ngAnimate `ngAnimate`} module to be installed.
333
+ *
334
+ * Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
335
+ *
336
+ */
337
+ .directive('ngAnimateChildren', function() {
338
+ var NG_ANIMATE_CHILDREN = '$$ngAnimateChildren';
339
+ return function(scope, element, attrs) {
340
+ var val = attrs.ngAnimateChildren;
341
+ if(angular.isString(val) && val.length === 0) { //empty attribute
342
+ element.data(NG_ANIMATE_CHILDREN, true);
343
+ } else {
344
+ scope.$watch(val, function(value) {
345
+ element.data(NG_ANIMATE_CHILDREN, !!value);
346
+ });
347
+ }
348
+ };
349
+ })
350
+
351
+ //this private service is only used within CSS-enabled animations
352
+ //IE8 + IE9 do not support rAF natively, but that is fine since they
353
+ //also don't support transitions and keyframes which means that the code
354
+ //below will never be used by the two browsers.
355
+ .factory('$$animateReflow', ['$$rAF', '$document', function($$rAF, $document) {
356
+ var bod = $document[0].body;
357
+ return function(fn) {
358
+ //the returned function acts as the cancellation function
359
+ return $$rAF(function() {
360
+ //the line below will force the browser to perform a repaint
361
+ //so that all the animated elements within the animation frame
362
+ //will be properly updated and drawn on screen. This is
363
+ //required to perform multi-class CSS based animations with
364
+ //Firefox. DO NOT REMOVE THIS LINE.
365
+ var a = bod.offsetWidth + 1;
366
+ fn();
367
+ });
368
+ };
369
+ }])
370
+
371
+ .config(['$provide', '$animateProvider', function($provide, $animateProvider) {
372
+ var noop = angular.noop;
373
+ var forEach = angular.forEach;
374
+ var selectors = $animateProvider.$$selectors;
375
+
376
+ var ELEMENT_NODE = 1;
377
+ var NG_ANIMATE_STATE = '$$ngAnimateState';
378
+ var NG_ANIMATE_CHILDREN = '$$ngAnimateChildren';
379
+ var NG_ANIMATE_CLASS_NAME = 'ng-animate';
380
+ var rootAnimateState = {running: true};
381
+
382
+ function extractElementNode(element) {
383
+ for(var i = 0; i < element.length; i++) {
384
+ var elm = element[i];
385
+ if(elm.nodeType == ELEMENT_NODE) {
386
+ return elm;
387
+ }
388
+ }
389
+ }
390
+
391
+ function prepareElement(element) {
392
+ return element && angular.element(element);
393
+ }
394
+
395
+ function stripCommentsFromElement(element) {
396
+ return angular.element(extractElementNode(element));
397
+ }
398
+
399
+ function isMatchingElement(elm1, elm2) {
400
+ return extractElementNode(elm1) == extractElementNode(elm2);
401
+ }
402
+
403
+ $provide.decorator('$animate', ['$delegate', '$injector', '$sniffer', '$rootElement', '$$asyncCallback', '$rootScope', '$document',
404
+ function($delegate, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document) {
405
+
406
+ var globalAnimationCounter = 0;
407
+ $rootElement.data(NG_ANIMATE_STATE, rootAnimateState);
408
+
409
+ // disable animations during bootstrap, but once we bootstrapped, wait again
410
+ // for another digest until enabling animations. The reason why we digest twice
411
+ // is because all structural animations (enter, leave and move) all perform a
412
+ // post digest operation before animating. If we only wait for a single digest
413
+ // to pass then the structural animation would render its animation on page load.
414
+ // (which is what we're trying to avoid when the application first boots up.)
415
+ $rootScope.$$postDigest(function() {
416
+ $rootScope.$$postDigest(function() {
417
+ rootAnimateState.running = false;
418
+ });
419
+ });
420
+
421
+ var classNameFilter = $animateProvider.classNameFilter();
422
+ var isAnimatableClassName = !classNameFilter
423
+ ? function() { return true; }
424
+ : function(className) {
425
+ return classNameFilter.test(className);
426
+ };
427
+
428
+ function blockElementAnimations(element) {
429
+ var data = element.data(NG_ANIMATE_STATE) || {};
430
+ data.running = true;
431
+ element.data(NG_ANIMATE_STATE, data);
432
+ }
433
+
434
+ function runAnimationPostDigest(fn) {
435
+ var cancelFn;
436
+ $rootScope.$$postDigest(function() {
437
+ cancelFn = fn();
438
+ });
439
+ return function() {
440
+ cancelFn && cancelFn();
441
+ };
442
+ }
443
+
444
+ function lookup(name) {
445
+ if (name) {
446
+ var matches = [],
447
+ flagMap = {},
448
+ classes = name.substr(1).split('.');
449
+
450
+ //the empty string value is the default animation
451
+ //operation which performs CSS transition and keyframe
452
+ //animations sniffing. This is always included for each
453
+ //element animation procedure if the browser supports
454
+ //transitions and/or keyframe animations. The default
455
+ //animation is added to the top of the list to prevent
456
+ //any previous animations from affecting the element styling
457
+ //prior to the element being animated.
458
+ if ($sniffer.transitions || $sniffer.animations) {
459
+ matches.push($injector.get(selectors['']));
460
+ }
461
+
462
+ for(var i=0; i < classes.length; i++) {
463
+ var klass = classes[i],
464
+ selectorFactoryName = selectors[klass];
465
+ if(selectorFactoryName && !flagMap[klass]) {
466
+ matches.push($injector.get(selectorFactoryName));
467
+ flagMap[klass] = true;
468
+ }
469
+ }
470
+ return matches;
471
+ }
472
+ }
473
+
474
+ function animationRunner(element, animationEvent, className) {
475
+ //transcluded directives may sometimes fire an animation using only comment nodes
476
+ //best to catch this early on to prevent any animation operations from occurring
477
+ var node = element[0];
478
+ if(!node) {
479
+ return;
480
+ }
481
+
482
+ var isSetClassOperation = animationEvent == 'setClass';
483
+ var isClassBased = isSetClassOperation ||
484
+ animationEvent == 'addClass' ||
485
+ animationEvent == 'removeClass';
486
+
487
+ var classNameAdd, classNameRemove;
488
+ if(angular.isArray(className)) {
489
+ classNameAdd = className[0];
490
+ classNameRemove = className[1];
491
+ className = classNameAdd + ' ' + classNameRemove;
492
+ }
493
+
494
+ var currentClassName = element.attr('class');
495
+ var classes = currentClassName + ' ' + className;
496
+ if(!isAnimatableClassName(classes)) {
497
+ return;
498
+ }
499
+
500
+ var beforeComplete = noop,
501
+ beforeCancel = [],
502
+ before = [],
503
+ afterComplete = noop,
504
+ afterCancel = [],
505
+ after = [];
506
+
507
+ var animationLookup = (' ' + classes).replace(/\s+/g,'.');
508
+ forEach(lookup(animationLookup), function(animationFactory) {
509
+ var created = registerAnimation(animationFactory, animationEvent);
510
+ if(!created && isSetClassOperation) {
511
+ registerAnimation(animationFactory, 'addClass');
512
+ registerAnimation(animationFactory, 'removeClass');
513
+ }
514
+ });
515
+
516
+ function registerAnimation(animationFactory, event) {
517
+ var afterFn = animationFactory[event];
518
+ var beforeFn = animationFactory['before' + event.charAt(0).toUpperCase() + event.substr(1)];
519
+ if(afterFn || beforeFn) {
520
+ if(event == 'leave') {
521
+ beforeFn = afterFn;
522
+ //when set as null then animation knows to skip this phase
523
+ afterFn = null;
524
+ }
525
+ after.push({
526
+ event : event, fn : afterFn
527
+ });
528
+ before.push({
529
+ event : event, fn : beforeFn
530
+ });
531
+ return true;
532
+ }
533
+ }
534
+
535
+ function run(fns, cancellations, allCompleteFn) {
536
+ var animations = [];
537
+ forEach(fns, function(animation) {
538
+ animation.fn && animations.push(animation);
539
+ });
540
+
541
+ var count = 0;
542
+ function afterAnimationComplete(index) {
543
+ if(cancellations) {
544
+ (cancellations[index] || noop)();
545
+ if(++count < animations.length) return;
546
+ cancellations = null;
547
+ }
548
+ allCompleteFn();
549
+ }
550
+
551
+ //The code below adds directly to the array in order to work with
552
+ //both sync and async animations. Sync animations are when the done()
553
+ //operation is called right away. DO NOT REFACTOR!
554
+ forEach(animations, function(animation, index) {
555
+ var progress = function() {
556
+ afterAnimationComplete(index);
557
+ };
558
+ switch(animation.event) {
559
+ case 'setClass':
560
+ cancellations.push(animation.fn(element, classNameAdd, classNameRemove, progress));
561
+ break;
562
+ case 'addClass':
563
+ cancellations.push(animation.fn(element, classNameAdd || className, progress));
564
+ break;
565
+ case 'removeClass':
566
+ cancellations.push(animation.fn(element, classNameRemove || className, progress));
567
+ break;
568
+ default:
569
+ cancellations.push(animation.fn(element, progress));
570
+ break;
571
+ }
572
+ });
573
+
574
+ if(cancellations && cancellations.length === 0) {
575
+ allCompleteFn();
576
+ }
577
+ }
578
+
579
+ return {
580
+ node : node,
581
+ event : animationEvent,
582
+ className : className,
583
+ isClassBased : isClassBased,
584
+ isSetClassOperation : isSetClassOperation,
585
+ before : function(allCompleteFn) {
586
+ beforeComplete = allCompleteFn;
587
+ run(before, beforeCancel, function() {
588
+ beforeComplete = noop;
589
+ allCompleteFn();
590
+ });
591
+ },
592
+ after : function(allCompleteFn) {
593
+ afterComplete = allCompleteFn;
594
+ run(after, afterCancel, function() {
595
+ afterComplete = noop;
596
+ allCompleteFn();
597
+ });
598
+ },
599
+ cancel : function() {
600
+ if(beforeCancel) {
601
+ forEach(beforeCancel, function(cancelFn) {
602
+ (cancelFn || noop)(true);
603
+ });
604
+ beforeComplete(true);
605
+ }
606
+ if(afterCancel) {
607
+ forEach(afterCancel, function(cancelFn) {
608
+ (cancelFn || noop)(true);
609
+ });
610
+ afterComplete(true);
611
+ }
612
+ }
613
+ };
614
+ }
615
+
616
+ /**
617
+ * @ngdoc service
618
+ * @name $animate
619
+ * @kind function
620
+ *
621
+ * @description
622
+ * The `$animate` service provides animation detection support while performing DOM operations (enter, leave and move) as well as during addClass and removeClass operations.
623
+ * When any of these operations are run, the $animate service
624
+ * will examine any JavaScript-defined animations (which are defined by using the $animateProvider provider object)
625
+ * as well as any CSS-defined animations against the CSS classes present on the element once the DOM operation is run.
626
+ *
627
+ * The `$animate` service is used behind the scenes with pre-existing directives and animation with these directives
628
+ * will work out of the box without any extra configuration.
629
+ *
630
+ * Requires the {@link ngAnimate `ngAnimate`} module to be installed.
631
+ *
632
+ * Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
633
+ *
634
+ */
635
+ return {
636
+ /**
637
+ * @ngdoc method
638
+ * @name $animate#enter
639
+ * @kind function
640
+ *
641
+ * @description
642
+ * Appends the element to the parentElement element that resides in the document and then runs the enter animation. Once
643
+ * the animation is started, the following CSS classes will be present on the element for the duration of the animation:
644
+ *
645
+ * Below is a breakdown of each step that occurs during enter animation:
646
+ *
647
+ * | Animation Step | What the element class attribute looks like |
648
+ * |-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
649
+ * | 1. $animate.enter(...) is called | class="my-animation" |
650
+ * | 2. element is inserted into the parentElement element or beside the afterElement element | class="my-animation" |
651
+ * | 3. $animate waits for the next digest to start the animation | class="my-animation ng-animate" |
652
+ * | 4. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
653
+ * | 5. the .ng-enter class is added to the element | class="my-animation ng-animate ng-enter" |
654
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-enter" |
655
+ * | 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" |
656
+ * | 8. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate ng-enter" |
657
+ * | 9. $animate removes the CSS transition block placed on the element | class="my-animation ng-animate ng-enter" |
658
+ * | 10. the .ng-enter-active class is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-enter ng-enter-active" |
659
+ * | 11. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate ng-enter ng-enter-active" |
660
+ * | 12. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
661
+ * | 13. The doneCallback() callback is fired (if provided) | class="my-animation" |
662
+ *
663
+ * @param {DOMElement} element the element that will be the focus of the enter animation
664
+ * @param {DOMElement} parentElement the parent element of the element that will be the focus of the enter animation
665
+ * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
666
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
667
+ * @return {function} the animation cancellation function
668
+ */
669
+ enter : function(element, parentElement, afterElement, doneCallback) {
670
+ element = angular.element(element);
671
+ parentElement = prepareElement(parentElement);
672
+ afterElement = prepareElement(afterElement);
673
+
674
+ blockElementAnimations(element);
675
+ $delegate.enter(element, parentElement, afterElement);
676
+ return runAnimationPostDigest(function() {
677
+ return performAnimation('enter', 'ng-enter', stripCommentsFromElement(element), parentElement, afterElement, noop, doneCallback);
678
+ });
679
+ },
680
+
681
+ /**
682
+ * @ngdoc method
683
+ * @name $animate#leave
684
+ * @kind function
685
+ *
686
+ * @description
687
+ * Runs the leave animation operation and, upon completion, removes the element from the DOM. Once
688
+ * the animation is started, the following CSS classes will be added for the duration of the animation:
689
+ *
690
+ * Below is a breakdown of each step that occurs during leave animation:
691
+ *
692
+ * | Animation Step | What the element class attribute looks like |
693
+ * |-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
694
+ * | 1. $animate.leave(...) is called | class="my-animation" |
695
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
696
+ * | 3. $animate waits for the next digest to start the animation | class="my-animation ng-animate" |
697
+ * | 4. the .ng-leave class is added to the element | class="my-animation ng-animate ng-leave" |
698
+ * | 5. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-leave" |
699
+ * | 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” |
700
+ * | 7. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate ng-leave" |
701
+ * | 8. $animate removes the CSS transition block placed on the element | class="my-animation ng-animate ng-leave” |
702
+ * | 9. the .ng-leave-active class is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-leave ng-leave-active" |
703
+ * | 10. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate ng-leave ng-leave-active" |
704
+ * | 11. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
705
+ * | 12. The element is removed from the DOM | ... |
706
+ * | 13. The doneCallback() callback is fired (if provided) | ... |
707
+ *
708
+ * @param {DOMElement} element the element that will be the focus of the leave animation
709
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
710
+ * @return {function} the animation cancellation function
711
+ */
712
+ leave : function(element, doneCallback) {
713
+ element = angular.element(element);
714
+
715
+ cancelChildAnimations(element);
716
+ blockElementAnimations(element);
717
+ this.enabled(false, element);
718
+ return runAnimationPostDigest(function() {
719
+ return performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
720
+ $delegate.leave(element);
721
+ }, doneCallback);
722
+ });
723
+ },
724
+
725
+ /**
726
+ * @ngdoc method
727
+ * @name $animate#move
728
+ * @kind function
729
+ *
730
+ * @description
731
+ * Fires the move DOM operation. Just before the animation starts, the animate service will either append it into the parentElement container or
732
+ * add the element directly after the afterElement element if present. Then the move animation will be run. Once
733
+ * the animation is started, the following CSS classes will be added for the duration of the animation:
734
+ *
735
+ * Below is a breakdown of each step that occurs during move animation:
736
+ *
737
+ * | Animation Step | What the element class attribute looks like |
738
+ * |------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------|
739
+ * | 1. $animate.move(...) is called | class="my-animation" |
740
+ * | 2. element is moved into the parentElement element or beside the afterElement element | class="my-animation" |
741
+ * | 3. $animate waits for the next digest to start the animation | class="my-animation ng-animate" |
742
+ * | 4. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
743
+ * | 5. the .ng-move class is added to the element | class="my-animation ng-animate ng-move" |
744
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-move" |
745
+ * | 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” |
746
+ * | 8. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate ng-move" |
747
+ * | 9. $animate removes the CSS transition block placed on the element | class="my-animation ng-animate ng-move” |
748
+ * | 10. the .ng-move-active class is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-move ng-move-active" |
749
+ * | 11. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate ng-move ng-move-active" |
750
+ * | 12. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
751
+ * | 13. The doneCallback() callback is fired (if provided) | class="my-animation" |
752
+ *
753
+ * @param {DOMElement} element the element that will be the focus of the move animation
754
+ * @param {DOMElement} parentElement the parentElement element of the element that will be the focus of the move animation
755
+ * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
756
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
757
+ * @return {function} the animation cancellation function
758
+ */
759
+ move : function(element, parentElement, afterElement, doneCallback) {
760
+ element = angular.element(element);
761
+ parentElement = prepareElement(parentElement);
762
+ afterElement = prepareElement(afterElement);
763
+
764
+ cancelChildAnimations(element);
765
+ blockElementAnimations(element);
766
+ $delegate.move(element, parentElement, afterElement);
767
+ return runAnimationPostDigest(function() {
768
+ return performAnimation('move', 'ng-move', stripCommentsFromElement(element), parentElement, afterElement, noop, doneCallback);
769
+ });
770
+ },
771
+
772
+ /**
773
+ * @ngdoc method
774
+ * @name $animate#addClass
775
+ *
776
+ * @description
777
+ * Triggers a custom animation event based off the className variable and then attaches the className value to the element as a CSS class.
778
+ * Unlike the other animation methods, the animate service will suffix the className value with {@type -add} in order to provide
779
+ * the animate service the setup and active CSS classes in order to trigger the animation (this will be skipped if no CSS transitions
780
+ * or keyframes are defined on the -add-active or base CSS class).
781
+ *
782
+ * Below is a breakdown of each step that occurs during addClass animation:
783
+ *
784
+ * | Animation Step | What the element class attribute looks like |
785
+ * |----------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
786
+ * | 1. $animate.addClass(element, 'super') is called | class="my-animation" |
787
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation ng-animate" |
788
+ * | 3. the .super-add class is added to the element | class="my-animation ng-animate super-add" |
789
+ * | 4. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate super-add" |
790
+ * | 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" |
791
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate super-add" |
792
+ * | 7. $animate waits for the animation to complete (via events and timeout) | class="my-animation super super-add super-add-active" |
793
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation super" |
794
+ * | 9. The super class is kept on the element | class="my-animation super" |
795
+ * | 10. The doneCallback() callback is fired (if provided) | class="my-animation super" |
796
+ *
797
+ * @param {DOMElement} element the element that will be animated
798
+ * @param {string} className the CSS class that will be added to the element and then animated
799
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
800
+ * @return {function} the animation cancellation function
801
+ */
802
+ addClass : function(element, className, doneCallback) {
803
+ element = angular.element(element);
804
+ element = stripCommentsFromElement(element);
805
+ return performAnimation('addClass', className, element, null, null, function() {
806
+ $delegate.addClass(element, className);
807
+ }, doneCallback);
808
+ },
809
+
810
+ /**
811
+ * @ngdoc method
812
+ * @name $animate#removeClass
813
+ *
814
+ * @description
815
+ * Triggers a custom animation event based off the className variable and then removes the CSS class provided by the className value
816
+ * from the element. Unlike the other animation methods, the animate service will suffix the className value with {@type -remove} in
817
+ * order to provide the animate service the setup and active CSS classes in order to trigger the animation (this will be skipped if
818
+ * no CSS transitions or keyframes are defined on the -remove or base CSS classes).
819
+ *
820
+ * Below is a breakdown of each step that occurs during removeClass animation:
821
+ *
822
+ * | Animation Step | What the element class attribute looks like |
823
+ * |------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
824
+ * | 1. $animate.removeClass(element, 'super') is called | class="my-animation super" |
825
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation super ng-animate" |
826
+ * | 3. the .super-remove class is added to the element | class="my-animation super ng-animate super-remove" |
827
+ * | 4. $animate waits for a single animation frame (this performs a reflow) | class="my-animation super ng-animate super-remove" |
828
+ * | 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" |
829
+ * | 6. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation super ng-animate super-remove" |
830
+ * | 7. $animate waits for the animation to complete (via events and timeout) | class="my-animation ng-animate super-remove super-remove-active" |
831
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
832
+ * | 9. The doneCallback() callback is fired (if provided) | class="my-animation" |
833
+ *
834
+ *
835
+ * @param {DOMElement} element the element that will be animated
836
+ * @param {string} className the CSS class that will be animated and then removed from the element
837
+ * @param {function()=} doneCallback the callback function that will be called once the animation is complete
838
+ * @return {function} the animation cancellation function
839
+ */
840
+ removeClass : function(element, className, doneCallback) {
841
+ element = angular.element(element);
842
+ element = stripCommentsFromElement(element);
843
+ return performAnimation('removeClass', className, element, null, null, function() {
844
+ $delegate.removeClass(element, className);
845
+ }, doneCallback);
846
+ },
847
+
848
+ /**
849
+ *
850
+ * @ngdoc method
851
+ * @name $animate#setClass
852
+ *
853
+ * @description Adds and/or removes the given CSS classes to and from the element.
854
+ * Once complete, the done() callback will be fired (if provided).
855
+ *
856
+ * | Animation Step | What the element class attribute looks like |
857
+ * |--------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
858
+ * | 1. $animate.removeClass(element, ‘on’, ‘off’) is called | class="my-animation super off” |
859
+ * | 2. $animate runs the JavaScript-defined animations detected on the element | class="my-animation super ng-animate off” |
860
+ * | 3. the .on-add and .off-remove classes are added to the element | class="my-animation ng-animate on-add off-remove off” |
861
+ * | 4. $animate waits for a single animation frame (this performs a reflow) | class="my-animation ng-animate on-add off-remove off” |
862
+ * | 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” |
863
+ * | 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" |
864
+ * | 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" |
865
+ * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
866
+ * | 9. The doneCallback() callback is fired (if provided) | class="my-animation" |
867
+ *
868
+ * @param {DOMElement} element the element which will have its CSS classes changed
869
+ * removed from it
870
+ * @param {string} add the CSS classes which will be added to the element
871
+ * @param {string} remove the CSS class which will be removed from the element
872
+ * @param {function=} done the callback function (if provided) that will be fired after the
873
+ * CSS classes have been set on the element
874
+ * @return {function} the animation cancellation function
875
+ */
876
+ setClass : function(element, add, remove, doneCallback) {
877
+ element = angular.element(element);
878
+ element = stripCommentsFromElement(element);
879
+ return performAnimation('setClass', [add, remove], element, null, null, function() {
880
+ $delegate.setClass(element, add, remove);
881
+ }, doneCallback);
882
+ },
883
+
884
+ /**
885
+ * @ngdoc method
886
+ * @name $animate#enabled
887
+ * @kind function
888
+ *
889
+ * @param {boolean=} value If provided then set the animation on or off.
890
+ * @param {DOMElement=} element If provided then the element will be used to represent the enable/disable operation
891
+ * @return {boolean} Current animation state.
892
+ *
893
+ * @description
894
+ * Globally enables/disables animations.
895
+ *
896
+ */
897
+ enabled : function(value, element) {
898
+ switch(arguments.length) {
899
+ case 2:
900
+ if(value) {
901
+ cleanup(element);
902
+ } else {
903
+ var data = element.data(NG_ANIMATE_STATE) || {};
904
+ data.disabled = true;
905
+ element.data(NG_ANIMATE_STATE, data);
906
+ }
907
+ break;
908
+
909
+ case 1:
910
+ rootAnimateState.disabled = !value;
911
+ break;
912
+
913
+ default:
914
+ value = !rootAnimateState.disabled;
915
+ break;
916
+ }
917
+ return !!value;
918
+ }
919
+ };
920
+
921
+ /*
922
+ all animations call this shared animation triggering function internally.
923
+ The animationEvent variable refers to the JavaScript animation event that will be triggered
924
+ and the className value is the name of the animation that will be applied within the
925
+ CSS code. Element, parentElement and afterElement are provided DOM elements for the animation
926
+ and the onComplete callback will be fired once the animation is fully complete.
927
+ */
928
+ function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, doneCallback) {
929
+
930
+ var noopCancel = noop;
931
+ var runner = animationRunner(element, animationEvent, className);
932
+ if(!runner) {
933
+ fireDOMOperation();
934
+ fireBeforeCallbackAsync();
935
+ fireAfterCallbackAsync();
936
+ closeAnimation();
937
+ return noopCancel;
938
+ }
939
+
940
+ className = runner.className;
941
+ var elementEvents = angular.element._data(runner.node);
942
+ elementEvents = elementEvents && elementEvents.events;
943
+
944
+ if (!parentElement) {
945
+ parentElement = afterElement ? afterElement.parent() : element.parent();
946
+ }
947
+
948
+ var ngAnimateState = element.data(NG_ANIMATE_STATE) || {};
949
+ var runningAnimations = ngAnimateState.active || {};
950
+ var totalActiveAnimations = ngAnimateState.totalActive || 0;
951
+ var lastAnimation = ngAnimateState.last;
952
+
953
+ //only allow animations if the currently running animation is not structural
954
+ //or if there is no animation running at all
955
+ var skipAnimations;
956
+ if (runner.isClassBased) {
957
+ skipAnimations = ngAnimateState.running ||
958
+ ngAnimateState.disabled ||
959
+ (lastAnimation && !lastAnimation.isClassBased);
960
+ }
961
+
962
+ //skip the animation if animations are disabled, a parent is already being animated,
963
+ //the element is not currently attached to the document body or then completely close
964
+ //the animation if any matching animations are not found at all.
965
+ //NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found.
966
+ if (skipAnimations || animationsDisabled(element, parentElement)) {
967
+ fireDOMOperation();
968
+ fireBeforeCallbackAsync();
969
+ fireAfterCallbackAsync();
970
+ closeAnimation();
971
+ return noopCancel;
972
+ }
973
+
974
+ var skipAnimation = false;
975
+ if(totalActiveAnimations > 0) {
976
+ var animationsToCancel = [];
977
+ if(!runner.isClassBased) {
978
+ if(animationEvent == 'leave' && runningAnimations['ng-leave']) {
979
+ skipAnimation = true;
980
+ } else {
981
+ //cancel all animations when a structural animation takes place
982
+ for(var klass in runningAnimations) {
983
+ animationsToCancel.push(runningAnimations[klass]);
984
+ }
985
+ ngAnimateState = {};
986
+ cleanup(element, true);
987
+ }
988
+ } else if(lastAnimation.event == 'setClass') {
989
+ animationsToCancel.push(lastAnimation);
990
+ cleanup(element, className);
991
+ }
992
+ else if(runningAnimations[className]) {
993
+ var current = runningAnimations[className];
994
+ if(current.event == animationEvent) {
995
+ skipAnimation = true;
996
+ } else {
997
+ animationsToCancel.push(current);
998
+ cleanup(element, className);
999
+ }
1000
+ }
1001
+
1002
+ if(animationsToCancel.length > 0) {
1003
+ forEach(animationsToCancel, function(operation) {
1004
+ operation.cancel();
1005
+ });
1006
+ }
1007
+ }
1008
+
1009
+ runningAnimations = ngAnimateState.active || {};
1010
+ totalActiveAnimations = ngAnimateState.totalActive || 0;
1011
+
1012
+ if(runner.isClassBased && !runner.isSetClassOperation && !skipAnimation) {
1013
+ skipAnimation = (animationEvent == 'addClass') == element.hasClass(className); //opposite of XOR
1014
+ }
1015
+
1016
+ if(skipAnimation) {
1017
+ fireDOMOperation();
1018
+ fireBeforeCallbackAsync();
1019
+ fireAfterCallbackAsync();
1020
+ fireDoneCallbackAsync();
1021
+ return noopCancel;
1022
+ }
1023
+
1024
+ if(animationEvent == 'leave') {
1025
+ //there's no need to ever remove the listener since the element
1026
+ //will be removed (destroyed) after the leave animation ends or
1027
+ //is cancelled midway
1028
+ element.one('$destroy', function(e) {
1029
+ var element = angular.element(this);
1030
+ var state = element.data(NG_ANIMATE_STATE);
1031
+ if(state) {
1032
+ var activeLeaveAnimation = state.active['ng-leave'];
1033
+ if(activeLeaveAnimation) {
1034
+ activeLeaveAnimation.cancel();
1035
+ cleanup(element, 'ng-leave');
1036
+ }
1037
+ }
1038
+ });
1039
+ }
1040
+
1041
+ //the ng-animate class does nothing, but it's here to allow for
1042
+ //parent animations to find and cancel child animations when needed
1043
+ element.addClass(NG_ANIMATE_CLASS_NAME);
1044
+
1045
+ var localAnimationCount = globalAnimationCounter++;
1046
+ totalActiveAnimations++;
1047
+ runningAnimations[className] = runner;
1048
+
1049
+ element.data(NG_ANIMATE_STATE, {
1050
+ last : runner,
1051
+ active : runningAnimations,
1052
+ index : localAnimationCount,
1053
+ totalActive : totalActiveAnimations
1054
+ });
1055
+
1056
+ //first we run the before animations and when all of those are complete
1057
+ //then we perform the DOM operation and run the next set of animations
1058
+ fireBeforeCallbackAsync();
1059
+ runner.before(function(cancelled) {
1060
+ var data = element.data(NG_ANIMATE_STATE);
1061
+ cancelled = cancelled ||
1062
+ !data || !data.active[className] ||
1063
+ (runner.isClassBased && data.active[className].event != animationEvent);
1064
+
1065
+ fireDOMOperation();
1066
+ if(cancelled === true) {
1067
+ closeAnimation();
1068
+ } else {
1069
+ fireAfterCallbackAsync();
1070
+ runner.after(closeAnimation);
1071
+ }
1072
+ });
1073
+
1074
+ return runner.cancel;
1075
+
1076
+ function fireDOMCallback(animationPhase) {
1077
+ var eventName = '$animate:' + animationPhase;
1078
+ if(elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
1079
+ $$asyncCallback(function() {
1080
+ element.triggerHandler(eventName, {
1081
+ event : animationEvent,
1082
+ className : className
1083
+ });
1084
+ });
1085
+ }
1086
+ }
1087
+
1088
+ function fireBeforeCallbackAsync() {
1089
+ fireDOMCallback('before');
1090
+ }
1091
+
1092
+ function fireAfterCallbackAsync() {
1093
+ fireDOMCallback('after');
1094
+ }
1095
+
1096
+ function fireDoneCallbackAsync() {
1097
+ fireDOMCallback('close');
1098
+ if(doneCallback) {
1099
+ $$asyncCallback(function() {
1100
+ doneCallback();
1101
+ });
1102
+ }
1103
+ }
1104
+
1105
+ //it is less complicated to use a flag than managing and canceling
1106
+ //timeouts containing multiple callbacks.
1107
+ function fireDOMOperation() {
1108
+ if(!fireDOMOperation.hasBeenRun) {
1109
+ fireDOMOperation.hasBeenRun = true;
1110
+ domOperation();
1111
+ }
1112
+ }
1113
+
1114
+ function closeAnimation() {
1115
+ if(!closeAnimation.hasBeenRun) {
1116
+ closeAnimation.hasBeenRun = true;
1117
+ var data = element.data(NG_ANIMATE_STATE);
1118
+ if(data) {
1119
+ /* only structural animations wait for reflow before removing an
1120
+ animation, but class-based animations don't. An example of this
1121
+ failing would be when a parent HTML tag has a ng-class attribute
1122
+ causing ALL directives below to skip animations during the digest */
1123
+ if(runner && runner.isClassBased) {
1124
+ cleanup(element, className);
1125
+ } else {
1126
+ $$asyncCallback(function() {
1127
+ var data = element.data(NG_ANIMATE_STATE) || {};
1128
+ if(localAnimationCount == data.index) {
1129
+ cleanup(element, className, animationEvent);
1130
+ }
1131
+ });
1132
+ element.data(NG_ANIMATE_STATE, data);
1133
+ }
1134
+ }
1135
+ fireDoneCallbackAsync();
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+ function cancelChildAnimations(element) {
1141
+ var node = extractElementNode(element);
1142
+ if (node) {
1143
+ var nodes = angular.isFunction(node.getElementsByClassName) ?
1144
+ node.getElementsByClassName(NG_ANIMATE_CLASS_NAME) :
1145
+ node.querySelectorAll('.' + NG_ANIMATE_CLASS_NAME);
1146
+ forEach(nodes, function(element) {
1147
+ element = angular.element(element);
1148
+ var data = element.data(NG_ANIMATE_STATE);
1149
+ if(data && data.active) {
1150
+ forEach(data.active, function(runner) {
1151
+ runner.cancel();
1152
+ });
1153
+ }
1154
+ });
1155
+ }
1156
+ }
1157
+
1158
+ function cleanup(element, className) {
1159
+ if(isMatchingElement(element, $rootElement)) {
1160
+ if(!rootAnimateState.disabled) {
1161
+ rootAnimateState.running = false;
1162
+ rootAnimateState.structural = false;
1163
+ }
1164
+ } else if(className) {
1165
+ var data = element.data(NG_ANIMATE_STATE) || {};
1166
+
1167
+ var removeAnimations = className === true;
1168
+ if(!removeAnimations && data.active && data.active[className]) {
1169
+ data.totalActive--;
1170
+ delete data.active[className];
1171
+ }
1172
+
1173
+ if(removeAnimations || !data.totalActive) {
1174
+ element.removeClass(NG_ANIMATE_CLASS_NAME);
1175
+ element.removeData(NG_ANIMATE_STATE);
1176
+ }
1177
+ }
1178
+ }
1179
+
1180
+ function animationsDisabled(element, parentElement) {
1181
+ if (rootAnimateState.disabled) {
1182
+ return true;
1183
+ }
1184
+
1185
+ if (isMatchingElement(element, $rootElement)) {
1186
+ return rootAnimateState.running;
1187
+ }
1188
+
1189
+ var allowChildAnimations, parentRunningAnimation, hasParent;
1190
+ do {
1191
+ //the element did not reach the root element which means that it
1192
+ //is not apart of the DOM. Therefore there is no reason to do
1193
+ //any animations on it
1194
+ if (parentElement.length === 0) break;
1195
+
1196
+ var isRoot = isMatchingElement(parentElement, $rootElement);
1197
+ var state = isRoot ? rootAnimateState : (parentElement.data(NG_ANIMATE_STATE) || {});
1198
+ if (state.disabled) {
1199
+ return true;
1200
+ }
1201
+
1202
+ //no matter what, for an animation to work it must reach the root element
1203
+ //this implies that the element is attached to the DOM when the animation is run
1204
+ if (isRoot) {
1205
+ hasParent = true;
1206
+ }
1207
+
1208
+ //once a flag is found that is strictly false then everything before
1209
+ //it will be discarded and all child animations will be restricted
1210
+ if (allowChildAnimations !== false) {
1211
+ var animateChildrenFlag = parentElement.data(NG_ANIMATE_CHILDREN);
1212
+ if(angular.isDefined(animateChildrenFlag)) {
1213
+ allowChildAnimations = animateChildrenFlag;
1214
+ }
1215
+ }
1216
+
1217
+ parentRunningAnimation = parentRunningAnimation ||
1218
+ state.running ||
1219
+ (state.last && !state.last.isClassBased);
1220
+ }
1221
+ while(parentElement = parentElement.parent());
1222
+
1223
+ return !hasParent || (!allowChildAnimations && parentRunningAnimation);
1224
+ }
1225
+ }]);
1226
+
1227
+ $animateProvider.register('', ['$window', '$sniffer', '$timeout', '$$animateReflow',
1228
+ function($window, $sniffer, $timeout, $$animateReflow) {
1229
+ // Detect proper transitionend/animationend event names.
1230
+ var CSS_PREFIX = '', TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMATIONEND_EVENT;
1231
+
1232
+ // If unprefixed events are not supported but webkit-prefixed are, use the latter.
1233
+ // Otherwise, just use W3C names, browsers not supporting them at all will just ignore them.
1234
+ // Note: Chrome implements `window.onwebkitanimationend` and doesn't implement `window.onanimationend`
1235
+ // but at the same time dispatches the `animationend` event and not `webkitAnimationEnd`.
1236
+ // Register both events in case `window.onanimationend` is not supported because of that,
1237
+ // do the same for `transitionend` as Safari is likely to exhibit similar behavior.
1238
+ // Also, the only modern browser that uses vendor prefixes for transitions/keyframes is webkit
1239
+ // therefore there is no reason to test anymore for other vendor prefixes: http://caniuse.com/#search=transition
1240
+ if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) {
1241
+ CSS_PREFIX = '-webkit-';
1242
+ TRANSITION_PROP = 'WebkitTransition';
1243
+ TRANSITIONEND_EVENT = 'webkitTransitionEnd transitionend';
1244
+ } else {
1245
+ TRANSITION_PROP = 'transition';
1246
+ TRANSITIONEND_EVENT = 'transitionend';
1247
+ }
1248
+
1249
+ if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) {
1250
+ CSS_PREFIX = '-webkit-';
1251
+ ANIMATION_PROP = 'WebkitAnimation';
1252
+ ANIMATIONEND_EVENT = 'webkitAnimationEnd animationend';
1253
+ } else {
1254
+ ANIMATION_PROP = 'animation';
1255
+ ANIMATIONEND_EVENT = 'animationend';
1256
+ }
1257
+
1258
+ var DURATION_KEY = 'Duration';
1259
+ var PROPERTY_KEY = 'Property';
1260
+ var DELAY_KEY = 'Delay';
1261
+ var ANIMATION_ITERATION_COUNT_KEY = 'IterationCount';
1262
+ var NG_ANIMATE_PARENT_KEY = '$$ngAnimateKey';
1263
+ var NG_ANIMATE_CSS_DATA_KEY = '$$ngAnimateCSS3Data';
1264
+ var ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
1265
+ var CLOSING_TIME_BUFFER = 1.5;
1266
+ var ONE_SECOND = 1000;
1267
+
1268
+ var lookupCache = {};
1269
+ var parentCounter = 0;
1270
+ var animationReflowQueue = [];
1271
+ var cancelAnimationReflow;
1272
+ function afterReflow(element, callback) {
1273
+ if(cancelAnimationReflow) {
1274
+ cancelAnimationReflow();
1275
+ }
1276
+ animationReflowQueue.push(callback);
1277
+ cancelAnimationReflow = $$animateReflow(function() {
1278
+ forEach(animationReflowQueue, function(fn) {
1279
+ fn();
1280
+ });
1281
+
1282
+ animationReflowQueue = [];
1283
+ cancelAnimationReflow = null;
1284
+ lookupCache = {};
1285
+ });
1286
+ }
1287
+
1288
+ var closingTimer = null;
1289
+ var closingTimestamp = 0;
1290
+ var animationElementQueue = [];
1291
+ function animationCloseHandler(element, totalTime) {
1292
+ var node = extractElementNode(element);
1293
+ element = angular.element(node);
1294
+
1295
+ //this item will be garbage collected by the closing
1296
+ //animation timeout
1297
+ animationElementQueue.push(element);
1298
+
1299
+ //but it may not need to cancel out the existing timeout
1300
+ //if the timestamp is less than the previous one
1301
+ var futureTimestamp = Date.now() + totalTime;
1302
+ if(futureTimestamp <= closingTimestamp) {
1303
+ return;
1304
+ }
1305
+
1306
+ $timeout.cancel(closingTimer);
1307
+
1308
+ closingTimestamp = futureTimestamp;
1309
+ closingTimer = $timeout(function() {
1310
+ closeAllAnimations(animationElementQueue);
1311
+ animationElementQueue = [];
1312
+ }, totalTime, false);
1313
+ }
1314
+
1315
+ function closeAllAnimations(elements) {
1316
+ forEach(elements, function(element) {
1317
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1318
+ if(elementData) {
1319
+ forEach(elementData.closeAnimationFns, function(fn) {
1320
+ fn();
1321
+ });
1322
+ }
1323
+ });
1324
+ }
1325
+
1326
+ function getElementAnimationDetails(element, cacheKey) {
1327
+ var data = cacheKey ? lookupCache[cacheKey] : null;
1328
+ if(!data) {
1329
+ var transitionDuration = 0;
1330
+ var transitionDelay = 0;
1331
+ var animationDuration = 0;
1332
+ var animationDelay = 0;
1333
+ var transitionDelayStyle;
1334
+ var animationDelayStyle;
1335
+ var transitionDurationStyle;
1336
+ var transitionPropertyStyle;
1337
+
1338
+ //we want all the styles defined before and after
1339
+ forEach(element, function(element) {
1340
+ if (element.nodeType == ELEMENT_NODE) {
1341
+ var elementStyles = $window.getComputedStyle(element) || {};
1342
+
1343
+ transitionDurationStyle = elementStyles[TRANSITION_PROP + DURATION_KEY];
1344
+
1345
+ transitionDuration = Math.max(parseMaxTime(transitionDurationStyle), transitionDuration);
1346
+
1347
+ transitionPropertyStyle = elementStyles[TRANSITION_PROP + PROPERTY_KEY];
1348
+
1349
+ transitionDelayStyle = elementStyles[TRANSITION_PROP + DELAY_KEY];
1350
+
1351
+ transitionDelay = Math.max(parseMaxTime(transitionDelayStyle), transitionDelay);
1352
+
1353
+ animationDelayStyle = elementStyles[ANIMATION_PROP + DELAY_KEY];
1354
+
1355
+ animationDelay = Math.max(parseMaxTime(animationDelayStyle), animationDelay);
1356
+
1357
+ var aDuration = parseMaxTime(elementStyles[ANIMATION_PROP + DURATION_KEY]);
1358
+
1359
+ if(aDuration > 0) {
1360
+ aDuration *= parseInt(elementStyles[ANIMATION_PROP + ANIMATION_ITERATION_COUNT_KEY], 10) || 1;
1361
+ }
1362
+
1363
+ animationDuration = Math.max(aDuration, animationDuration);
1364
+ }
1365
+ });
1366
+ data = {
1367
+ total : 0,
1368
+ transitionPropertyStyle: transitionPropertyStyle,
1369
+ transitionDurationStyle: transitionDurationStyle,
1370
+ transitionDelayStyle: transitionDelayStyle,
1371
+ transitionDelay: transitionDelay,
1372
+ transitionDuration: transitionDuration,
1373
+ animationDelayStyle: animationDelayStyle,
1374
+ animationDelay: animationDelay,
1375
+ animationDuration: animationDuration
1376
+ };
1377
+ if(cacheKey) {
1378
+ lookupCache[cacheKey] = data;
1379
+ }
1380
+ }
1381
+ return data;
1382
+ }
1383
+
1384
+ function parseMaxTime(str) {
1385
+ var maxValue = 0;
1386
+ var values = angular.isString(str) ?
1387
+ str.split(/\s*,\s*/) :
1388
+ [];
1389
+ forEach(values, function(value) {
1390
+ maxValue = Math.max(parseFloat(value) || 0, maxValue);
1391
+ });
1392
+ return maxValue;
1393
+ }
1394
+
1395
+ function getCacheKey(element) {
1396
+ var parentElement = element.parent();
1397
+ var parentID = parentElement.data(NG_ANIMATE_PARENT_KEY);
1398
+ if(!parentID) {
1399
+ parentElement.data(NG_ANIMATE_PARENT_KEY, ++parentCounter);
1400
+ parentID = parentCounter;
1401
+ }
1402
+ return parentID + '-' + extractElementNode(element).getAttribute('class');
1403
+ }
1404
+
1405
+ function animateSetup(animationEvent, element, className) {
1406
+ var structural = ['ng-enter','ng-leave','ng-move'].indexOf(className) >= 0;
1407
+
1408
+ var cacheKey = getCacheKey(element);
1409
+ var eventCacheKey = cacheKey + ' ' + className;
1410
+ var itemIndex = lookupCache[eventCacheKey] ? ++lookupCache[eventCacheKey].total : 0;
1411
+
1412
+ var stagger = {};
1413
+ if(itemIndex > 0) {
1414
+ var staggerClassName = className + '-stagger';
1415
+ var staggerCacheKey = cacheKey + ' ' + staggerClassName;
1416
+ var applyClasses = !lookupCache[staggerCacheKey];
1417
+
1418
+ applyClasses && element.addClass(staggerClassName);
1419
+
1420
+ stagger = getElementAnimationDetails(element, staggerCacheKey);
1421
+
1422
+ applyClasses && element.removeClass(staggerClassName);
1423
+ }
1424
+
1425
+ element.addClass(className);
1426
+
1427
+ var formerData = element.data(NG_ANIMATE_CSS_DATA_KEY) || {};
1428
+ var timings = getElementAnimationDetails(element, eventCacheKey);
1429
+ var transitionDuration = timings.transitionDuration;
1430
+ var animationDuration = timings.animationDuration;
1431
+
1432
+ if(structural && transitionDuration === 0 && animationDuration === 0) {
1433
+ element.removeClass(className);
1434
+ return false;
1435
+ }
1436
+
1437
+ var blockTransition = structural && transitionDuration > 0;
1438
+ var blockAnimation = animationDuration > 0 &&
1439
+ stagger.animationDelay > 0 &&
1440
+ stagger.animationDuration === 0;
1441
+
1442
+ var closeAnimationFns = formerData.closeAnimationFns || [];
1443
+ element.data(NG_ANIMATE_CSS_DATA_KEY, {
1444
+ stagger : stagger,
1445
+ cacheKey : eventCacheKey,
1446
+ running : formerData.running || 0,
1447
+ itemIndex : itemIndex,
1448
+ blockTransition : blockTransition,
1449
+ blockAnimation : blockAnimation,
1450
+ closeAnimationFns : closeAnimationFns
1451
+ });
1452
+
1453
+ var node = extractElementNode(element);
1454
+
1455
+ if(blockTransition) {
1456
+ node.style[TRANSITION_PROP + PROPERTY_KEY] = 'none';
1457
+ }
1458
+
1459
+ if(blockAnimation) {
1460
+ node.style[ANIMATION_PROP] = 'none 0s';
1461
+ }
1462
+
1463
+ return true;
1464
+ }
1465
+
1466
+ function animateRun(animationEvent, element, className, activeAnimationComplete) {
1467
+ var node = extractElementNode(element);
1468
+ var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1469
+ if(node.getAttribute('class').indexOf(className) == -1 || !elementData) {
1470
+ activeAnimationComplete();
1471
+ return;
1472
+ }
1473
+
1474
+ if(elementData.blockTransition) {
1475
+ node.style[TRANSITION_PROP + PROPERTY_KEY] = '';
1476
+ }
1477
+
1478
+ if(elementData.blockAnimation) {
1479
+ node.style[ANIMATION_PROP] = '';
1480
+ }
1481
+
1482
+ var activeClassName = '';
1483
+ forEach(className.split(' '), function(klass, i) {
1484
+ activeClassName += (i > 0 ? ' ' : '') + klass + '-active';
1485
+ });
1486
+
1487
+ element.addClass(activeClassName);
1488
+ var eventCacheKey = elementData.cacheKey + ' ' + activeClassName;
1489
+ var timings = getElementAnimationDetails(element, eventCacheKey);
1490
+
1491
+ var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration);
1492
+ if(maxDuration === 0) {
1493
+ element.removeClass(activeClassName);
1494
+ animateClose(element, className);
1495
+ activeAnimationComplete();
1496
+ return;
1497
+ }
1498
+
1499
+ var maxDelay = Math.max(timings.transitionDelay, timings.animationDelay);
1500
+ var stagger = elementData.stagger;
1501
+ var itemIndex = elementData.itemIndex;
1502
+ var maxDelayTime = maxDelay * ONE_SECOND;
1503
+
1504
+ var style = '', appliedStyles = [];
1505
+ if(timings.transitionDuration > 0) {
1506
+ var propertyStyle = timings.transitionPropertyStyle;
1507
+ if(propertyStyle.indexOf('all') == -1) {
1508
+ style += CSS_PREFIX + 'transition-property: ' + propertyStyle + ';';
1509
+ style += CSS_PREFIX + 'transition-duration: ' + timings.transitionDurationStyle + ';';
1510
+ appliedStyles.push(CSS_PREFIX + 'transition-property');
1511
+ appliedStyles.push(CSS_PREFIX + 'transition-duration');
1512
+ }
1513
+ }
1514
+
1515
+ if(itemIndex > 0) {
1516
+ if(stagger.transitionDelay > 0 && stagger.transitionDuration === 0) {
1517
+ var delayStyle = timings.transitionDelayStyle;
1518
+ style += CSS_PREFIX + 'transition-delay: ' +
1519
+ prepareStaggerDelay(delayStyle, stagger.transitionDelay, itemIndex) + '; ';
1520
+ appliedStyles.push(CSS_PREFIX + 'transition-delay');
1521
+ }
1522
+
1523
+ if(stagger.animationDelay > 0 && stagger.animationDuration === 0) {
1524
+ style += CSS_PREFIX + 'animation-delay: ' +
1525
+ prepareStaggerDelay(timings.animationDelayStyle, stagger.animationDelay, itemIndex) + '; ';
1526
+ appliedStyles.push(CSS_PREFIX + 'animation-delay');
1527
+ }
1528
+ }
1529
+
1530
+ if(appliedStyles.length > 0) {
1531
+ //the element being animated may sometimes contain comment nodes in
1532
+ //the jqLite object, so we're safe to use a single variable to house
1533
+ //the styles since there is always only one element being animated
1534
+ var oldStyle = node.getAttribute('style') || '';
1535
+ node.setAttribute('style', oldStyle + '; ' + style);
1536
+ }
1537
+
1538
+ var startTime = Date.now();
1539
+ var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
1540
+
1541
+ element.on(css3AnimationEvents, onAnimationProgress);
1542
+ elementData.closeAnimationFns.push(function() {
1543
+ onEnd();
1544
+ activeAnimationComplete();
1545
+ });
1546
+
1547
+ var staggerTime = itemIndex * (Math.max(stagger.animationDelay, stagger.transitionDelay) || 0);
1548
+ var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER;
1549
+ var totalTime = (staggerTime + animationTime) * ONE_SECOND;
1550
+
1551
+ elementData.running++;
1552
+ animationCloseHandler(element, totalTime);
1553
+ return onEnd;
1554
+
1555
+ // This will automatically be called by $animate so
1556
+ // there is no need to attach this internally to the
1557
+ // timeout done method.
1558
+ function onEnd(cancelled) {
1559
+ element.off(css3AnimationEvents, onAnimationProgress);
1560
+ element.removeClass(activeClassName);
1561
+ animateClose(element, className);
1562
+ var node = extractElementNode(element);
1563
+ for (var i in appliedStyles) {
1564
+ node.style.removeProperty(appliedStyles[i]);
1565
+ }
1566
+ }
1567
+
1568
+ function onAnimationProgress(event) {
1569
+ event.stopPropagation();
1570
+ var ev = event.originalEvent || event;
1571
+ var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now();
1572
+
1573
+ /* Firefox (or possibly just Gecko) likes to not round values up
1574
+ * when a ms measurement is used for the animation */
1575
+ var elapsedTime = parseFloat(ev.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES));
1576
+
1577
+ /* $manualTimeStamp is a mocked timeStamp value which is set
1578
+ * within browserTrigger(). This is only here so that tests can
1579
+ * mock animations properly. Real events fallback to event.timeStamp,
1580
+ * or, if they don't, then a timeStamp is automatically created for them.
1581
+ * We're checking to see if the timeStamp surpasses the expected delay,
1582
+ * but we're using elapsedTime instead of the timeStamp on the 2nd
1583
+ * pre-condition since animations sometimes close off early */
1584
+ if(Math.max(timeStamp - startTime, 0) >= maxDelayTime && elapsedTime >= maxDuration) {
1585
+ activeAnimationComplete();
1586
+ }
1587
+ }
1588
+ }
1589
+
1590
+ function prepareStaggerDelay(delayStyle, staggerDelay, index) {
1591
+ var style = '';
1592
+ forEach(delayStyle.split(','), function(val, i) {
1593
+ style += (i > 0 ? ',' : '') +
1594
+ (index * staggerDelay + parseInt(val, 10)) + 's';
1595
+ });
1596
+ return style;
1597
+ }
1598
+
1599
+ function animateBefore(animationEvent, element, className, calculationDecorator) {
1600
+ if(animateSetup(animationEvent, element, className, calculationDecorator)) {
1601
+ return function(cancelled) {
1602
+ cancelled && animateClose(element, className);
1603
+ };
1604
+ }
1605
+ }
1606
+
1607
+ function animateAfter(animationEvent, element, className, afterAnimationComplete) {
1608
+ if(element.data(NG_ANIMATE_CSS_DATA_KEY)) {
1609
+ return animateRun(animationEvent, element, className, afterAnimationComplete);
1610
+ } else {
1611
+ animateClose(element, className);
1612
+ afterAnimationComplete();
1613
+ }
1614
+ }
1615
+
1616
+ function animate(animationEvent, element, className, animationComplete) {
1617
+ //If the animateSetup function doesn't bother returning a
1618
+ //cancellation function then it means that there is no animation
1619
+ //to perform at all
1620
+ var preReflowCancellation = animateBefore(animationEvent, element, className);
1621
+ if(!preReflowCancellation) {
1622
+ animationComplete();
1623
+ return;
1624
+ }
1625
+
1626
+ //There are two cancellation functions: one is before the first
1627
+ //reflow animation and the second is during the active state
1628
+ //animation. The first function will take care of removing the
1629
+ //data from the element which will not make the 2nd animation
1630
+ //happen in the first place
1631
+ var cancel = preReflowCancellation;
1632
+ afterReflow(element, function() {
1633
+ //once the reflow is complete then we point cancel to
1634
+ //the new cancellation function which will remove all of the
1635
+ //animation properties from the active animation
1636
+ cancel = animateAfter(animationEvent, element, className, animationComplete);
1637
+ });
1638
+
1639
+ return function(cancelled) {
1640
+ (cancel || noop)(cancelled);
1641
+ };
1642
+ }
1643
+
1644
+ function animateClose(element, className) {
1645
+ element.removeClass(className);
1646
+ var data = element.data(NG_ANIMATE_CSS_DATA_KEY);
1647
+ if(data) {
1648
+ if(data.running) {
1649
+ data.running--;
1650
+ }
1651
+ if(!data.running || data.running === 0) {
1652
+ element.removeData(NG_ANIMATE_CSS_DATA_KEY);
1653
+ }
1654
+ }
1655
+ }
1656
+
1657
+ return {
1658
+ enter : function(element, animationCompleted) {
1659
+ return animate('enter', element, 'ng-enter', animationCompleted);
1660
+ },
1661
+
1662
+ leave : function(element, animationCompleted) {
1663
+ return animate('leave', element, 'ng-leave', animationCompleted);
1664
+ },
1665
+
1666
+ move : function(element, animationCompleted) {
1667
+ return animate('move', element, 'ng-move', animationCompleted);
1668
+ },
1669
+
1670
+ beforeSetClass : function(element, add, remove, animationCompleted) {
1671
+ var className = suffixClasses(remove, '-remove') + ' ' +
1672
+ suffixClasses(add, '-add');
1673
+ var cancellationMethod = animateBefore('setClass', element, className);
1674
+ if(cancellationMethod) {
1675
+ afterReflow(element, animationCompleted);
1676
+ return cancellationMethod;
1677
+ }
1678
+ animationCompleted();
1679
+ },
1680
+
1681
+ beforeAddClass : function(element, className, animationCompleted) {
1682
+ var cancellationMethod = animateBefore('addClass', element, suffixClasses(className, '-add'));
1683
+ if(cancellationMethod) {
1684
+ afterReflow(element, animationCompleted);
1685
+ return cancellationMethod;
1686
+ }
1687
+ animationCompleted();
1688
+ },
1689
+
1690
+ beforeRemoveClass : function(element, className, animationCompleted) {
1691
+ var cancellationMethod = animateBefore('removeClass', element, suffixClasses(className, '-remove'));
1692
+ if(cancellationMethod) {
1693
+ afterReflow(element, animationCompleted);
1694
+ return cancellationMethod;
1695
+ }
1696
+ animationCompleted();
1697
+ },
1698
+
1699
+ setClass : function(element, add, remove, animationCompleted) {
1700
+ remove = suffixClasses(remove, '-remove');
1701
+ add = suffixClasses(add, '-add');
1702
+ var className = remove + ' ' + add;
1703
+ return animateAfter('setClass', element, className, animationCompleted);
1704
+ },
1705
+
1706
+ addClass : function(element, className, animationCompleted) {
1707
+ return animateAfter('addClass', element, suffixClasses(className, '-add'), animationCompleted);
1708
+ },
1709
+
1710
+ removeClass : function(element, className, animationCompleted) {
1711
+ return animateAfter('removeClass', element, suffixClasses(className, '-remove'), animationCompleted);
1712
+ }
1713
+ };
1714
+
1715
+ function suffixClasses(classes, suffix) {
1716
+ var className = '';
1717
+ classes = angular.isArray(classes) ? classes : classes.split(/\s+/);
1718
+ forEach(classes, function(klass, i) {
1719
+ if(klass && klass.length > 0) {
1720
+ className += (i > 0 ? ' ' : '') + klass + suffix;
1721
+ }
1722
+ });
1723
+ return className;
1724
+ }
1725
+ }]);
1726
+ }]);
1727
+
1728
+
1729
+ })(window, window.angular);