angularjs-rails 1.2.19 → 1.2.20

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v1.3.0-beta.14
2
+ * @license AngularJS v1.3.0-beta.15
3
3
  * (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
  * License: MIT
5
5
  */
@@ -62,8 +62,22 @@
62
62
  * <ANY class="slide" ng-include="..."></ANY>
63
63
  * ```
64
64
  *
65
- * Keep in mind that if an animation is running, any child elements cannot be animated until the parent element's
66
- * animation has completed.
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.
67
81
  *
68
82
  * <h2>CSS-defined Animations</h2>
69
83
  * The animate service will automatically apply two CSS classes to the animated element and these two CSS classes
@@ -320,6 +334,19 @@ angular.module('ngAnimate', ['ng'])
320
334
  * Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
321
335
  *
322
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
+ })
323
350
 
324
351
  //this private service is only used within CSS-enabled animations
325
352
  //IE8 + IE9 do not support rAF natively, but that is fine since they
@@ -348,6 +375,7 @@ angular.module('ngAnimate', ['ng'])
348
375
 
349
376
  var ELEMENT_NODE = 1;
350
377
  var NG_ANIMATE_STATE = '$$ngAnimateState';
378
+ var NG_ANIMATE_CHILDREN = '$$ngAnimateChildren';
351
379
  var NG_ANIMATE_CLASS_NAME = 'ng-animate';
352
380
  var rootAnimateState = {running: true};
353
381
 
@@ -397,6 +425,22 @@ angular.module('ngAnimate', ['ng'])
397
425
  return classNameFilter.test(className);
398
426
  };
399
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
+
400
444
  function lookup(name) {
401
445
  if (name) {
402
446
  var matches = [],
@@ -620,17 +664,17 @@ angular.module('ngAnimate', ['ng'])
620
664
  * @param {DOMElement} parentElement the parent element of the element that will be the focus of the enter animation
621
665
  * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
622
666
  * @param {function()=} doneCallback the callback function that will be called once the animation is complete
667
+ * @return {function} the animation cancellation function
623
668
  */
624
669
  enter : function(element, parentElement, afterElement, doneCallback) {
625
670
  element = angular.element(element);
626
671
  parentElement = prepareElement(parentElement);
627
672
  afterElement = prepareElement(afterElement);
628
673
 
629
- this.enabled(false, element);
674
+ blockElementAnimations(element);
630
675
  $delegate.enter(element, parentElement, afterElement);
631
- $rootScope.$$postDigest(function() {
632
- element = stripCommentsFromElement(element);
633
- performAnimation('enter', 'ng-enter', element, parentElement, afterElement, noop, doneCallback);
676
+ return runAnimationPostDigest(function() {
677
+ return performAnimation('enter', 'ng-enter', stripCommentsFromElement(element), parentElement, afterElement, noop, doneCallback);
634
678
  });
635
679
  },
636
680
 
@@ -663,13 +707,16 @@ angular.module('ngAnimate', ['ng'])
663
707
  *
664
708
  * @param {DOMElement} element the element that will be the focus of the leave animation
665
709
  * @param {function()=} doneCallback the callback function that will be called once the animation is complete
710
+ * @return {function} the animation cancellation function
666
711
  */
667
712
  leave : function(element, doneCallback) {
668
713
  element = angular.element(element);
714
+
669
715
  cancelChildAnimations(element);
716
+ blockElementAnimations(element);
670
717
  this.enabled(false, element);
671
- $rootScope.$$postDigest(function() {
672
- performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
718
+ return runAnimationPostDigest(function() {
719
+ return performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
673
720
  $delegate.leave(element);
674
721
  }, doneCallback);
675
722
  });
@@ -707,6 +754,7 @@ angular.module('ngAnimate', ['ng'])
707
754
  * @param {DOMElement} parentElement the parentElement element of the element that will be the focus of the move animation
708
755
  * @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
709
756
  * @param {function()=} doneCallback the callback function that will be called once the animation is complete
757
+ * @return {function} the animation cancellation function
710
758
  */
711
759
  move : function(element, parentElement, afterElement, doneCallback) {
712
760
  element = angular.element(element);
@@ -714,11 +762,10 @@ angular.module('ngAnimate', ['ng'])
714
762
  afterElement = prepareElement(afterElement);
715
763
 
716
764
  cancelChildAnimations(element);
717
- this.enabled(false, element);
765
+ blockElementAnimations(element);
718
766
  $delegate.move(element, parentElement, afterElement);
719
- $rootScope.$$postDigest(function() {
720
- element = stripCommentsFromElement(element);
721
- performAnimation('move', 'ng-move', element, parentElement, afterElement, noop, doneCallback);
767
+ return runAnimationPostDigest(function() {
768
+ return performAnimation('move', 'ng-move', stripCommentsFromElement(element), parentElement, afterElement, noop, doneCallback);
722
769
  });
723
770
  },
724
771
 
@@ -750,11 +797,12 @@ angular.module('ngAnimate', ['ng'])
750
797
  * @param {DOMElement} element the element that will be animated
751
798
  * @param {string} className the CSS class that will be added to the element and then animated
752
799
  * @param {function()=} doneCallback the callback function that will be called once the animation is complete
800
+ * @return {function} the animation cancellation function
753
801
  */
754
802
  addClass : function(element, className, doneCallback) {
755
803
  element = angular.element(element);
756
804
  element = stripCommentsFromElement(element);
757
- performAnimation('addClass', className, element, null, null, function() {
805
+ return performAnimation('addClass', className, element, null, null, function() {
758
806
  $delegate.addClass(element, className);
759
807
  }, doneCallback);
760
808
  },
@@ -787,11 +835,12 @@ angular.module('ngAnimate', ['ng'])
787
835
  * @param {DOMElement} element the element that will be animated
788
836
  * @param {string} className the CSS class that will be animated and then removed from the element
789
837
  * @param {function()=} doneCallback the callback function that will be called once the animation is complete
838
+ * @return {function} the animation cancellation function
790
839
  */
791
840
  removeClass : function(element, className, doneCallback) {
792
841
  element = angular.element(element);
793
842
  element = stripCommentsFromElement(element);
794
- performAnimation('removeClass', className, element, null, null, function() {
843
+ return performAnimation('removeClass', className, element, null, null, function() {
795
844
  $delegate.removeClass(element, className);
796
845
  }, doneCallback);
797
846
  },
@@ -820,13 +869,14 @@ angular.module('ngAnimate', ['ng'])
820
869
  * removed from it
821
870
  * @param {string} add the CSS classes which will be added to the element
822
871
  * @param {string} remove the CSS class which will be removed from the element
823
- * @param {Function=} done the callback function (if provided) that will be fired after the
872
+ * @param {function=} done the callback function (if provided) that will be fired after the
824
873
  * CSS classes have been set on the element
874
+ * @return {function} the animation cancellation function
825
875
  */
826
876
  setClass : function(element, add, remove, doneCallback) {
827
877
  element = angular.element(element);
828
878
  element = stripCommentsFromElement(element);
829
- performAnimation('setClass', [add, remove], element, null, null, function() {
879
+ return performAnimation('setClass', [add, remove], element, null, null, function() {
830
880
  $delegate.setClass(element, add, remove);
831
881
  }, doneCallback);
832
882
  },
@@ -877,13 +927,14 @@ angular.module('ngAnimate', ['ng'])
877
927
  */
878
928
  function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, doneCallback) {
879
929
 
930
+ var noopCancel = noop;
880
931
  var runner = animationRunner(element, animationEvent, className);
881
932
  if(!runner) {
882
933
  fireDOMOperation();
883
934
  fireBeforeCallbackAsync();
884
935
  fireAfterCallbackAsync();
885
936
  closeAnimation();
886
- return;
937
+ return noopCancel;
887
938
  }
888
939
 
889
940
  className = runner.className;
@@ -901,9 +952,12 @@ angular.module('ngAnimate', ['ng'])
901
952
 
902
953
  //only allow animations if the currently running animation is not structural
903
954
  //or if there is no animation running at all
904
- var skipAnimations = runner.isClassBased
905
- ? ngAnimateState.disabled || (lastAnimation && !lastAnimation.isClassBased)
906
- : false;
955
+ var skipAnimations;
956
+ if (runner.isClassBased) {
957
+ skipAnimations = ngAnimateState.running ||
958
+ ngAnimateState.disabled ||
959
+ (lastAnimation && !lastAnimation.isClassBased);
960
+ }
907
961
 
908
962
  //skip the animation if animations are disabled, a parent is already being animated,
909
963
  //the element is not currently attached to the document body or then completely close
@@ -914,7 +968,7 @@ angular.module('ngAnimate', ['ng'])
914
968
  fireBeforeCallbackAsync();
915
969
  fireAfterCallbackAsync();
916
970
  closeAnimation();
917
- return;
971
+ return noopCancel;
918
972
  }
919
973
 
920
974
  var skipAnimation = false;
@@ -927,10 +981,9 @@ angular.module('ngAnimate', ['ng'])
927
981
  //cancel all animations when a structural animation takes place
928
982
  for(var klass in runningAnimations) {
929
983
  animationsToCancel.push(runningAnimations[klass]);
930
- cleanup(element, klass);
931
984
  }
932
- runningAnimations = {};
933
- totalActiveAnimations = 0;
985
+ ngAnimateState = {};
986
+ cleanup(element, true);
934
987
  }
935
988
  } else if(lastAnimation.event == 'setClass') {
936
989
  animationsToCancel.push(lastAnimation);
@@ -953,6 +1006,9 @@ angular.module('ngAnimate', ['ng'])
953
1006
  }
954
1007
  }
955
1008
 
1009
+ runningAnimations = ngAnimateState.active || {};
1010
+ totalActiveAnimations = ngAnimateState.totalActive || 0;
1011
+
956
1012
  if(runner.isClassBased && !runner.isSetClassOperation && !skipAnimation) {
957
1013
  skipAnimation = (animationEvent == 'addClass') == element.hasClass(className); //opposite of XOR
958
1014
  }
@@ -962,7 +1018,7 @@ angular.module('ngAnimate', ['ng'])
962
1018
  fireBeforeCallbackAsync();
963
1019
  fireAfterCallbackAsync();
964
1020
  fireDoneCallbackAsync();
965
- return;
1021
+ return noopCancel;
966
1022
  }
967
1023
 
968
1024
  if(animationEvent == 'leave') {
@@ -1015,6 +1071,8 @@ angular.module('ngAnimate', ['ng'])
1015
1071
  }
1016
1072
  });
1017
1073
 
1074
+ return runner.cancel;
1075
+
1018
1076
  function fireDOMCallback(animationPhase) {
1019
1077
  var eventName = '$animate:' + animationPhase;
1020
1078
  if(elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
@@ -1120,33 +1178,49 @@ angular.module('ngAnimate', ['ng'])
1120
1178
  }
1121
1179
 
1122
1180
  function animationsDisabled(element, parentElement) {
1123
- if (rootAnimateState.disabled) return true;
1181
+ if (rootAnimateState.disabled) {
1182
+ return true;
1183
+ }
1124
1184
 
1125
- if(isMatchingElement(element, $rootElement)) {
1126
- return rootAnimateState.disabled || rootAnimateState.running;
1185
+ if (isMatchingElement(element, $rootElement)) {
1186
+ return rootAnimateState.running;
1127
1187
  }
1128
1188
 
1189
+ var allowChildAnimations, parentRunningAnimation, hasParent;
1129
1190
  do {
1130
1191
  //the element did not reach the root element which means that it
1131
1192
  //is not apart of the DOM. Therefore there is no reason to do
1132
1193
  //any animations on it
1133
- if(parentElement.length === 0) break;
1194
+ if (parentElement.length === 0) break;
1134
1195
 
1135
1196
  var isRoot = isMatchingElement(parentElement, $rootElement);
1136
1197
  var state = isRoot ? rootAnimateState : (parentElement.data(NG_ANIMATE_STATE) || {});
1137
- var result = state.disabled || state.running
1138
- ? true
1139
- : state.last && !state.last.isClassBased;
1198
+ if (state.disabled) {
1199
+ return true;
1200
+ }
1140
1201
 
1141
- if(isRoot || result) {
1142
- return result;
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
+ }
1143
1215
  }
1144
1216
 
1145
- if(isRoot) return true;
1217
+ parentRunningAnimation = parentRunningAnimation ||
1218
+ state.running ||
1219
+ (state.last && !state.last.isClassBased);
1146
1220
  }
1147
1221
  while(parentElement = parentElement.parent());
1148
1222
 
1149
- return true;
1223
+ return !hasParent || (!allowChildAnimations && parentRunningAnimation);
1150
1224
  }
1151
1225
  }]);
1152
1226
 
@@ -1242,7 +1316,9 @@ angular.module('ngAnimate', ['ng'])
1242
1316
  forEach(elements, function(element) {
1243
1317
  var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
1244
1318
  if(elementData) {
1245
- (elementData.closeAnimationFn || noop)();
1319
+ forEach(elementData.closeAnimationFns, function(fn) {
1320
+ fn();
1321
+ });
1246
1322
  }
1247
1323
  });
1248
1324
  }
@@ -1363,6 +1439,7 @@ angular.module('ngAnimate', ['ng'])
1363
1439
  stagger.animationDelay > 0 &&
1364
1440
  stagger.animationDuration === 0;
1365
1441
 
1442
+ var closeAnimationFns = formerData.closeAnimationFns || [];
1366
1443
  element.data(NG_ANIMATE_CSS_DATA_KEY, {
1367
1444
  stagger : stagger,
1368
1445
  cacheKey : eventCacheKey,
@@ -1370,7 +1447,7 @@ angular.module('ngAnimate', ['ng'])
1370
1447
  itemIndex : itemIndex,
1371
1448
  blockTransition : blockTransition,
1372
1449
  blockAnimation : blockAnimation,
1373
- closeAnimationFn : noop
1450
+ closeAnimationFns : closeAnimationFns
1374
1451
  });
1375
1452
 
1376
1453
  var node = extractElementNode(element);
@@ -1462,10 +1539,10 @@ angular.module('ngAnimate', ['ng'])
1462
1539
  var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
1463
1540
 
1464
1541
  element.on(css3AnimationEvents, onAnimationProgress);
1465
- elementData.closeAnimationFn = function() {
1542
+ elementData.closeAnimationFns.push(function() {
1466
1543
  onEnd();
1467
1544
  activeAnimationComplete();
1468
- };
1545
+ });
1469
1546
 
1470
1547
  var staggerTime = itemIndex * (Math.max(stagger.animationDelay, stagger.transitionDelay) || 0);
1471
1548
  var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v1.3.0-beta.14
2
+ * @license AngularJS v1.3.0-beta.15
3
3
  * (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
  * License: MIT
5
5
  */
@@ -39,12 +39,13 @@ angular.module('ngCookies', ['ng']).
39
39
  * @example
40
40
  *
41
41
  * ```js
42
- * function ExampleController($cookies) {
43
- * // Retrieving a cookie
44
- * var favoriteCookie = $cookies.myFavorite;
45
- * // Setting a cookie
46
- * $cookies.myFavorite = 'oatmeal';
47
- * }
42
+ * angular.module('cookiesExample', ['ngCookies'])
43
+ * .controller('ExampleController', ['$cookies', function($cookies) {
44
+ * // Retrieving a cookie
45
+ * var favoriteCookie = $cookies.myFavorite;
46
+ * // Setting a cookie
47
+ * $cookies.myFavorite = 'oatmeal';
48
+ * }]);
48
49
  * ```
49
50
  */
50
51
  factory('$cookies', ['$rootScope', '$browser', function ($rootScope, $browser) {
@@ -142,14 +143,15 @@ angular.module('ngCookies', ['ng']).
142
143
  * @example
143
144
  *
144
145
  * ```js
145
- * function ExampleController($cookieStore) {
146
- * // Put cookie
147
- * $cookieStore.put('myFavorite','oatmeal');
148
- * // Get cookie
149
- * var favoriteCookie = $cookieStore.get('myFavorite');
150
- * // Removing a cookie
151
- * $cookieStore.remove('myFavorite');
152
- * }
146
+ * angular.module('cookieStoreExample', ['ngCookies'])
147
+ * .controller('ExampleController', ['$cookieStore', function($cookieStore) {
148
+ * // Put cookie
149
+ * $cookieStore.put('myFavorite','oatmeal');
150
+ * // Get cookie
151
+ * var favoriteCookie = $cookieStore.get('myFavorite');
152
+ * // Removing a cookie
153
+ * $cookieStore.remove('myFavorite');
154
+ * }]);
153
155
  * ```
154
156
  */
155
157
  factory('$cookieStore', ['$cookies', function($cookies) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v1.3.0-beta.14
2
+ * @license AngularJS v1.3.0-beta.15
3
3
  * (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
  * License: MIT
5
5
  */
@@ -69,7 +69,7 @@ function minErr(module) {
69
69
  return match;
70
70
  });
71
71
 
72
- message = message + '\nhttp://errors.angularjs.org/1.3.0-beta.14/' +
72
+ message = message + '\nhttp://errors.angularjs.org/1.3.0-beta.15/' +
73
73
  (module ? module + '/' : '') + code;
74
74
  for (i = 2; i < arguments.length; i++) {
75
75
  message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v1.3.0-beta.14
2
+ * @license AngularJS v1.3.0-beta.15
3
3
  * (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
  * License: MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license AngularJS v1.3.0-beta.14
2
+ * @license AngularJS v1.3.0-beta.15
3
3
  * (c) 2010-2014 Google, Inc. http://angularjs.org
4
4
  * License: MIT
5
5
  */
@@ -798,7 +798,7 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
798
798
  element : arguments[0],
799
799
  args : arguments
800
800
  });
801
- $delegate[method].apply($delegate, arguments);
801
+ return $delegate[method].apply($delegate, arguments);
802
802
  };
803
803
  });
804
804