A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth.
+
We provide the best medical expertise and care for your fur kids!
diff --git a/src/main/webapp/components/visits/VisitController.js b/src/main/webapp/components/visits/VisitController.js
index acfc81adb..622bc6124 100644
--- a/src/main/webapp/components/visits/VisitController.js
+++ b/src/main/webapp/components/visits/VisitController.js
@@ -1,4 +1,3 @@
-var VisitController = function($scope) {
-};
+var VisitController = ['$scope',function($scope) {
-var VisitControllerDeclaration = ['$scope',VisitController];
\ No newline at end of file
+}];
\ No newline at end of file
diff --git a/src/main/webapp/js/app.js b/src/main/webapp/js/app.js
index 5b2a6cdbb..b814ff5b6 100644
--- a/src/main/webapp/js/app.js
+++ b/src/main/webapp/js/app.js
@@ -1,11 +1,4 @@
-var app = angular.module('spring-petclinic', ['ui.router','ui.router.stateHelper','ngAnimate','ngCookies']);
-
-app.controller('MainController', MainControllerDeclaration);
-app.controller('VeterinarianController', VeterinarianControllerDeclaration);
-app.controller('PetController', PetControllerDeclaration);
-app.controller('OwnerController', OwnerControllerDeclaration);
-app.controller('VisitController', VisitControllerDeclaration);
-app.controller('AboutController', AboutControllerDeclaration);
+var app = angular.module('spring-petclinic', ['ui.router','ui.router.stateHelper','ngAnimate','ngCookies','ngResource']);
app.config(['stateHelperProvider','$urlRouterProvider','$urlMatcherFactoryProvider',function(stateHelperProvider,$urlRouterProvider,$urlMatcherFactoryProvider) {
@@ -36,3 +29,16 @@ app.config(['stateHelperProvider','$urlRouterProvider','$urlMatcherFactoryProvid
});
} ]);
+
+/** Controllers **/
+app.controller('MainController', MainController);
+app.controller('VeterinarianController', VeterinarianController);
+app.controller('PetController', PetController);
+app.controller('OwnerController', OwnerController);
+app.controller('VisitController', VisitController);
+
+/** Services **/
+app.factory('Owner', Owner);
+app.factory('Pet', Pet);
+app.factory('Vet', Vet);
+app.factory('Visit', Visit);
\ No newline at end of file
diff --git a/src/main/webapp/js/lib/angular-animate.js b/src/main/webapp/js/lib/angular-animate.js
index 61befa2a0..56c7e9498 100644
--- a/src/main/webapp/js/lib/angular-animate.js
+++ b/src/main/webapp/js/lib/angular-animate.js
@@ -1,5 +1,5 @@
/**
- * @license AngularJS v1.2.25
+ * @license AngularJS v1.3.11
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
@@ -12,33 +12,31 @@
* @name ngAnimate
* @description
*
- * # ngAnimate
- *
* The `ngAnimate` module provides support for JavaScript, CSS3 transition and CSS3 keyframe animation hooks within existing core and custom directives.
*
- *
*
*
* # Usage
*
* To see animations in action, all that is required is to define the appropriate CSS classes
- * or to register a JavaScript animation via the myModule.animation() function. The directives that support animation automatically are:
+ * or to register a JavaScript animation via the `myModule.animation()` function. The directives that support animation automatically are:
* `ngRepeat`, `ngInclude`, `ngIf`, `ngSwitch`, `ngShow`, `ngHide`, `ngView` and `ngClass`. Custom directives can take advantage of animation
* by using the `$animate` service.
*
* Below is a more detailed breakdown of the supported animation events provided by pre-existing ng directives:
*
- * | Directive | Supported Animations |
- * |---------------------------------------------------------- |----------------------------------------------------|
- * | {@link ng.directive:ngRepeat#usage_animations ngRepeat} | enter, leave and move |
- * | {@link ngRoute.directive:ngView#usage_animations ngView} | enter and leave |
- * | {@link ng.directive:ngInclude#usage_animations ngInclude} | enter and leave |
- * | {@link ng.directive:ngSwitch#usage_animations ngSwitch} | enter and leave |
- * | {@link ng.directive:ngIf#usage_animations ngIf} | enter and leave |
- * | {@link ng.directive:ngClass#usage_animations ngClass} | add and remove |
- * | {@link ng.directive:ngShow#usage_animations ngShow & ngHide} | add and remove (the ng-hide class value) |
- * | {@link ng.directive:form#usage_animations form} | add and remove (dirty, pristine, valid, invalid & all other validations) |
- * | {@link ng.directive:ngModel#usage_animations ngModel} | add and remove (dirty, pristine, valid, invalid & all other validations) |
+ * | Directive | Supported Animations |
+ * |----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
+ * | {@link ng.directive:ngRepeat#animations ngRepeat} | enter, leave and move |
+ * | {@link ngRoute.directive:ngView#animations ngView} | enter and leave |
+ * | {@link ng.directive:ngInclude#animations ngInclude} | enter and leave |
+ * | {@link ng.directive:ngSwitch#animations ngSwitch} | enter and leave |
+ * | {@link ng.directive:ngIf#animations ngIf} | enter and leave |
+ * | {@link ng.directive:ngClass#animations ngClass} | add and remove (the CSS class(es) present) |
+ * | {@link ng.directive:ngShow#animations ngShow} & {@link ng.directive:ngHide#animations ngHide} | add and remove (the ng-hide class value) |
+ * | {@link ng.directive:form#animation-hooks form} & {@link ng.directive:ngModel#animation-hooks ngModel} | add and remove (dirty, pristine, valid, invalid & all other validations) |
+ * | {@link module:ngMessages#animations ngMessages} | add and remove (ng-active & ng-inactive) |
+ * | {@link module:ngMessages#animations ngMessage} | enter and leave |
*
* You can find out more information about animations upon visiting each directive page.
*
@@ -81,7 +79,17 @@
* When the `on` expression value changes and an animation is triggered then each of the elements within
* will all animate without the block being applied to child elements.
*
- *
CSS-defined Animations
+ * ## Are animations run when the application starts?
+ * No they are not. When an application is bootstrapped Angular will disable animations from running to avoid
+ * a frenzy of animations from being triggered as soon as the browser has rendered the screen. For this to work,
+ * Angular will wait for two digest cycles until enabling animations. From there on, any animation-triggering
+ * layout changes in the application will trigger animations as normal.
+ *
+ * In addition, upon bootstrap, if the routing system or any directives or load remote data (via $http) then Angular
+ * will automatically extend the wait time to enable animations once **all** of the outbound HTTP requests
+ * are complete.
+ *
+ * ## CSS-defined Animations
* The animate service will automatically apply two CSS classes to the animated element and these two CSS classes
* are designed to contain the start and end CSS styling. Both CSS transitions and keyframe animations are supported
* and can be used to play along with this naming structure.
@@ -150,9 +158,100 @@
* immediately resulting in a DOM element that is at its final state. This final state is when the DOM element
* has no CSS transition/animation classes applied to it.
*
- *
CSS Staggering Animations
+ * ### Structural transition animations
+ *
+ * Structural transitions (such as enter, leave and move) will always apply a `0s none` transition
+ * value to force the browser into rendering the styles defined in the setup (`.ng-enter`, `.ng-leave`
+ * or `.ng-move`) class. This means that any active transition animations operating on the element
+ * will be cut off to make way for the enter, leave or move animation.
+ *
+ * ### Class-based transition animations
+ *
+ * Class-based transitions refer to transition animations that are triggered when a CSS class is
+ * added to or removed from the element (via `$animate.addClass`, `$animate.removeClass`,
+ * `$animate.setClass`, or by directives such as `ngClass`, `ngModel` and `form`).
+ * They are different when compared to structural animations since they **do not cancel existing
+ * animations** nor do they **block successive transitions** from rendering on the same element.
+ * This distinction allows for **multiple class-based transitions** to be performed on the same element.
+ *
+ * In addition to ngAnimate supporting the default (natural) functionality of class-based transition
+ * animations, ngAnimate also decorates the element with starting and ending CSS classes to aid the
+ * developer in further styling the element throughout the transition animation. Earlier versions
+ * of ngAnimate may have caused natural CSS transitions to break and not render properly due to
+ * $animate temporarily blocking transitions using `0s none` in order to allow the setup CSS class
+ * (the `-add` or `-remove` class) to be applied without triggering an animation. However, as of
+ * **version 1.3**, this workaround has been removed with ngAnimate and all non-ngAnimate CSS
+ * class transitions are compatible with ngAnimate.
+ *
+ * There is, however, one special case when dealing with class-based transitions in ngAnimate.
+ * When rendering class-based transitions that make use of the setup and active CSS classes
+ * (e.g. `.fade-add` and `.fade-add-active` for when `.fade` is added) be sure to define
+ * the transition value **on the active CSS class** and not the setup class.
+ *
+ * ```css
+ * .fade-add {
+ * /* remember to place a 0s transition here
+ * to ensure that the styles are applied instantly
+ * even if the element already has a transition style */
+ * transition:0s linear all;
+ *
+ * /* starting CSS styles */
+ * opacity:1;
+ * }
+ * .fade-add.fade-add-active {
+ * /* this will be the length of the animation */
+ * transition:1s linear all;
+ * opacity:0;
+ * }
+ * ```
+ *
+ * The setup CSS class (in this case `.fade-add`) also has a transition style property, however, it
+ * has a duration of zero. This may not be required, however, incase the browser is unable to render
+ * the styling present in this CSS class instantly then it could be that the browser is attempting
+ * to perform an unnecessary transition.
+ *
+ * This workaround, however, does not apply to standard class-based transitions that are rendered
+ * when a CSS class containing a transition is applied to an element:
+ *
+ * ```css
+ * /* this works as expected */
+ * .fade {
+ * transition:1s linear all;
+ * opacity:0;
+ * }
+ * ```
+ *
+ * Please keep this in mind when coding the CSS markup that will be used within class-based transitions.
+ * Also, try not to mix the two class-based animation flavors together since the CSS code may become
+ * overly complex.
+ *
+ *
+ * ### Preventing Collisions With Third Party Libraries
+ *
+ * Some third-party frameworks place animation duration defaults across many element or className
+ * selectors in order to make their code small and reuseable. This can lead to issues with ngAnimate, which
+ * is expecting actual animations on these elements and has to wait for their completion.
+ *
+ * You can prevent this unwanted behavior by using a prefix on all your animation classes:
+ *
+ * ```css
+ * /* prefixed with animate- */
+ * .animate-fade-add.animate-fade-add-active {
+ * transition:1s linear all;
+ * opacity:0;
+ * }
+ * ```
+ *
+ * You then configure `$animate` to enforce this prefix:
+ *
+ * ```js
+ * $animateProvider.classNameFilter(/animate-/);
+ * ```
+ *
+ *
+ * ### CSS Staggering Animations
* A Staggering animation is a collection of animations that are issued with a slight delay in between each successive operation resulting in a
- * curtain-like effect. The ngAnimate module, as of 1.2.0, supports staggering animations and the stagger effect can be
+ * curtain-like effect. The ngAnimate module (versions >=1.2) supports staggering animations and the stagger effect can be
* performed by creating a **ng-EVENT-stagger** CSS class and attaching that class to the base CSS class used for
* the animation. The style property expected within the stagger class can either be a **transition-delay** or an
* **animation-delay** property (or both if your animation contains both transitions and keyframe animations).
@@ -205,7 +304,7 @@
*
* Stagger animations are currently only supported within CSS-defined animations.
*
- *
JavaScript-defined Animations
+ * ## JavaScript-defined Animations
* 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
* yet support CSS transitions/animations, then you can make use of JavaScript animations defined inside of your AngularJS module.
*
@@ -251,6 +350,49 @@
* and the JavaScript animation is found, then the enter callback will handle that animation (in addition to the CSS keyframe animation
* or transition code that is defined via a stylesheet).
*
+ *
+ * ### Applying Directive-specific Styles to an Animation
+ * In some cases a directive or service may want to provide `$animate` with extra details that the animation will
+ * include into its animation. Let's say for example we wanted to render an animation that animates an element
+ * towards the mouse coordinates as to where the user clicked last. By collecting the X/Y coordinates of the click
+ * (via the event parameter) we can set the `top` and `left` styles into an object and pass that into our function
+ * call to `$animate.addClass`.
+ *
+ * ```js
+ * canvas.on('click', function(e) {
+ * $animate.addClass(element, 'on', {
+ * to: {
+ * left : e.client.x + 'px',
+ * top : e.client.y + 'px'
+ * }
+ * }):
+ * });
+ * ```
+ *
+ * Now when the animation runs, and a transition or keyframe animation is picked up, then the animation itself will
+ * also include and transition the styling of the `left` and `top` properties into its running animation. If we want
+ * to provide some starting animation values then we can do so by placing the starting animations styles into an object
+ * called `from` in the same object as the `to` animations.
+ *
+ * ```js
+ * canvas.on('click', function(e) {
+ * $animate.addClass(element, 'on', {
+ * from: {
+ * position: 'absolute',
+ * left: '0px',
+ * top: '0px'
+ * },
+ * to: {
+ * left : e.client.x + 'px',
+ * top : e.client.y + 'px'
+ * }
+ * }):
+ * });
+ * ```
+ *
+ * Once the animation is complete or cancelled then the union of both the before and after styles are applied to the
+ * element. If `ngAnimate` is not present then the styles will be applied immediately.
+ *
*/
angular.module('ngAnimate', ['ng'])
@@ -273,7 +415,7 @@ angular.module('ngAnimate', ['ng'])
var NG_ANIMATE_CHILDREN = '$$ngAnimateChildren';
return function(scope, element, attrs) {
var val = attrs.ngAnimateChildren;
- if(angular.isString(val) && val.length === 0) { //empty attribute
+ if (angular.isString(val) && val.length === 0) { //empty attribute
element.data(NG_ANIMATE_CHILDREN, true);
} else {
scope.$watch(val, function(value) {
@@ -307,6 +449,9 @@ angular.module('ngAnimate', ['ng'])
var noop = angular.noop;
var forEach = angular.forEach;
var selectors = $animateProvider.$$selectors;
+ var isArray = angular.isArray;
+ var isString = angular.isString;
+ var isObject = angular.isObject;
var ELEMENT_NODE = 1;
var NG_ANIMATE_STATE = '$$ngAnimateState';
@@ -315,9 +460,9 @@ angular.module('ngAnimate', ['ng'])
var rootAnimateState = {running: true};
function extractElementNode(element) {
- for(var i = 0; i < element.length; i++) {
+ for (var i = 0; i < element.length; i++) {
var elm = element[i];
- if(elm.nodeType == ELEMENT_NODE) {
+ if (elm.nodeType == ELEMENT_NODE) {
return elm;
}
}
@@ -334,25 +479,40 @@ angular.module('ngAnimate', ['ng'])
function isMatchingElement(elm1, elm2) {
return extractElementNode(elm1) == extractElementNode(elm2);
}
+ var $$jqLite;
+ $provide.decorator('$animate',
+ ['$delegate', '$$q', '$injector', '$sniffer', '$rootElement', '$$asyncCallback', '$rootScope', '$document', '$templateRequest', '$$jqLite',
+ function($delegate, $$q, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document, $templateRequest, $$$jqLite) {
- $provide.decorator('$animate', ['$delegate', '$injector', '$sniffer', '$rootElement', '$$asyncCallback', '$rootScope', '$document',
- function($delegate, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document) {
-
- var globalAnimationCounter = 0;
+ $$jqLite = $$$jqLite;
$rootElement.data(NG_ANIMATE_STATE, rootAnimateState);
- // disable animations during bootstrap, but once we bootstrapped, wait again
- // for another digest until enabling animations. The reason why we digest twice
- // is because all structural animations (enter, leave and move) all perform a
- // post digest operation before animating. If we only wait for a single digest
- // to pass then the structural animation would render its animation on page load.
- // (which is what we're trying to avoid when the application first boots up.)
- $rootScope.$$postDigest(function() {
- $rootScope.$$postDigest(function() {
- rootAnimateState.running = false;
- });
- });
+ // Wait until all directive and route-related templates are downloaded and
+ // compiled. The $templateRequest.totalPendingRequests variable keeps track of
+ // all of the remote templates being currently downloaded. If there are no
+ // templates currently downloading then the watcher will still fire anyway.
+ var deregisterWatch = $rootScope.$watch(
+ function() { return $templateRequest.totalPendingRequests; },
+ function(val, oldVal) {
+ if (val !== 0) return;
+ deregisterWatch();
+ // Now that all templates have been downloaded, $animate will wait until
+ // the post digest queue is empty before enabling animations. By having two
+ // calls to $postDigest calls we can ensure that the flag is enabled at the
+ // very end of the post digest queue. Since all of the animations in $animate
+ // use $postDigest, it's important that the code below executes at the end.
+ // This basically means that the page is fully downloaded and compiled before
+ // any animations are triggered.
+ $rootScope.$$postDigest(function() {
+ $rootScope.$$postDigest(function() {
+ rootAnimateState.running = false;
+ });
+ });
+ }
+ );
+
+ var globalAnimationCounter = 0;
var classNameFilter = $animateProvider.classNameFilter();
var isAnimatableClassName = !classNameFilter
? function() { return true; }
@@ -360,10 +520,83 @@ angular.module('ngAnimate', ['ng'])
return classNameFilter.test(className);
};
- function blockElementAnimations(element) {
+ function classBasedAnimationsBlocked(element, setter) {
var data = element.data(NG_ANIMATE_STATE) || {};
- data.running = true;
- element.data(NG_ANIMATE_STATE, data);
+ if (setter) {
+ data.running = true;
+ data.structural = true;
+ element.data(NG_ANIMATE_STATE, data);
+ }
+ return data.disabled || (data.running && data.structural);
+ }
+
+ function runAnimationPostDigest(fn) {
+ var cancelFn, defer = $$q.defer();
+ defer.promise.$$cancelFn = function() {
+ cancelFn && cancelFn();
+ };
+ $rootScope.$$postDigest(function() {
+ cancelFn = fn(function() {
+ defer.resolve();
+ });
+ });
+ return defer.promise;
+ }
+
+ function parseAnimateOptions(options) {
+ // some plugin code may still be passing in the callback
+ // function as the last param for the $animate methods so
+ // it's best to only allow string or array values for now
+ if (isObject(options)) {
+ if (options.tempClasses && isString(options.tempClasses)) {
+ options.tempClasses = options.tempClasses.split(/\s+/);
+ }
+ return options;
+ }
+ }
+
+ function resolveElementClasses(element, cache, runningAnimations) {
+ runningAnimations = runningAnimations || {};
+
+ var lookup = {};
+ forEach(runningAnimations, function(data, selector) {
+ forEach(selector.split(' '), function(s) {
+ lookup[s]=data;
+ });
+ });
+
+ var hasClasses = Object.create(null);
+ forEach((element.attr('class') || '').split(/\s+/), function(className) {
+ hasClasses[className] = true;
+ });
+
+ var toAdd = [], toRemove = [];
+ forEach((cache && cache.classes) || [], function(status, className) {
+ var hasClass = hasClasses[className];
+ var matchingAnimation = lookup[className] || {};
+
+ // When addClass and removeClass is called then $animate will check to
+ // see if addClass and removeClass cancel each other out. When there are
+ // more calls to removeClass than addClass then the count falls below 0
+ // and then the removeClass animation will be allowed. Otherwise if the
+ // count is above 0 then that means an addClass animation will commence.
+ // Once an animation is allowed then the code will also check to see if
+ // there exists any on-going animation that is already adding or remvoing
+ // the matching CSS class.
+ if (status === false) {
+ //does it have the class or will it have the class
+ if (hasClass || matchingAnimation.event == 'addClass') {
+ toRemove.push(className);
+ }
+ } else if (status === true) {
+ //is the class missing or will it be removed?
+ if (!hasClass || matchingAnimation.event == 'removeClass') {
+ toAdd.push(className);
+ }
+ }
+ });
+
+ return (toAdd.length + toRemove.length) > 0 && [toAdd.join(' '), toRemove.join(' ')];
}
function lookup(name) {
@@ -384,10 +617,10 @@ angular.module('ngAnimate', ['ng'])
matches.push($injector.get(selectors['']));
}
- for(var i=0; i < classes.length; i++) {
+ for (var i=0; i < classes.length; i++) {
var klass = classes[i],
selectorFactoryName = selectors[klass];
- if(selectorFactoryName && !flagMap[klass]) {
+ if (selectorFactoryName && !flagMap[klass]) {
matches.push($injector.get(selectorFactoryName));
flagMap[klass] = true;
}
@@ -396,29 +629,44 @@ angular.module('ngAnimate', ['ng'])
}
}
- function animationRunner(element, animationEvent, className) {
+ function animationRunner(element, animationEvent, className, options) {
//transcluded directives may sometimes fire an animation using only comment nodes
//best to catch this early on to prevent any animation operations from occurring
var node = element[0];
- if(!node) {
+ if (!node) {
return;
}
- var isSetClassOperation = animationEvent == 'setClass';
- var isClassBased = isSetClassOperation ||
- animationEvent == 'addClass' ||
- animationEvent == 'removeClass';
+ if (options) {
+ options.to = options.to || {};
+ options.from = options.from || {};
+ }
- var classNameAdd, classNameRemove;
- if(angular.isArray(className)) {
+ var classNameAdd;
+ var classNameRemove;
+ if (isArray(className)) {
classNameAdd = className[0];
classNameRemove = className[1];
- className = classNameAdd + ' ' + classNameRemove;
+ if (!classNameAdd) {
+ className = classNameRemove;
+ animationEvent = 'removeClass';
+ } else if (!classNameRemove) {
+ className = classNameAdd;
+ animationEvent = 'addClass';
+ } else {
+ className = classNameAdd + ' ' + classNameRemove;
+ }
}
+ var isSetClassOperation = animationEvent == 'setClass';
+ var isClassBased = isSetClassOperation
+ || animationEvent == 'addClass'
+ || animationEvent == 'removeClass'
+ || animationEvent == 'animate';
+
var currentClassName = element.attr('class');
var classes = currentClassName + ' ' + className;
- if(!isAnimatableClassName(classes)) {
+ if (!isAnimatableClassName(classes)) {
return;
}
@@ -432,7 +680,7 @@ angular.module('ngAnimate', ['ng'])
var animationLookup = (' ' + classes).replace(/\s+/g,'.');
forEach(lookup(animationLookup), function(animationFactory) {
var created = registerAnimation(animationFactory, animationEvent);
- if(!created && isSetClassOperation) {
+ if (!created && isSetClassOperation) {
registerAnimation(animationFactory, 'addClass');
registerAnimation(animationFactory, 'removeClass');
}
@@ -441,17 +689,17 @@ angular.module('ngAnimate', ['ng'])
function registerAnimation(animationFactory, event) {
var afterFn = animationFactory[event];
var beforeFn = animationFactory['before' + event.charAt(0).toUpperCase() + event.substr(1)];
- if(afterFn || beforeFn) {
- if(event == 'leave') {
+ if (afterFn || beforeFn) {
+ if (event == 'leave') {
beforeFn = afterFn;
//when set as null then animation knows to skip this phase
afterFn = null;
}
after.push({
- event : event, fn : afterFn
+ event: event, fn: afterFn
});
before.push({
- event : event, fn : beforeFn
+ event: event, fn: beforeFn
});
return true;
}
@@ -465,9 +713,9 @@ angular.module('ngAnimate', ['ng'])
var count = 0;
function afterAnimationComplete(index) {
- if(cancellations) {
+ if (cancellations) {
(cancellations[index] || noop)();
- if(++count < animations.length) return;
+ if (++count < animations.length) return;
cancellations = null;
}
allCompleteFn();
@@ -480,55 +728,63 @@ angular.module('ngAnimate', ['ng'])
var progress = function() {
afterAnimationComplete(index);
};
- switch(animation.event) {
+ switch (animation.event) {
case 'setClass':
- cancellations.push(animation.fn(element, classNameAdd, classNameRemove, progress));
+ cancellations.push(animation.fn(element, classNameAdd, classNameRemove, progress, options));
+ break;
+ case 'animate':
+ cancellations.push(animation.fn(element, className, options.from, options.to, progress));
break;
case 'addClass':
- cancellations.push(animation.fn(element, classNameAdd || className, progress));
+ cancellations.push(animation.fn(element, classNameAdd || className, progress, options));
break;
case 'removeClass':
- cancellations.push(animation.fn(element, classNameRemove || className, progress));
+ cancellations.push(animation.fn(element, classNameRemove || className, progress, options));
break;
default:
- cancellations.push(animation.fn(element, progress));
+ cancellations.push(animation.fn(element, progress, options));
break;
}
});
- if(cancellations && cancellations.length === 0) {
+ if (cancellations && cancellations.length === 0) {
allCompleteFn();
}
}
return {
- node : node,
- event : animationEvent,
- className : className,
- isClassBased : isClassBased,
- isSetClassOperation : isSetClassOperation,
- before : function(allCompleteFn) {
+ node: node,
+ event: animationEvent,
+ className: className,
+ isClassBased: isClassBased,
+ isSetClassOperation: isSetClassOperation,
+ applyStyles: function() {
+ if (options) {
+ element.css(angular.extend(options.from || {}, options.to || {}));
+ }
+ },
+ before: function(allCompleteFn) {
beforeComplete = allCompleteFn;
run(before, beforeCancel, function() {
beforeComplete = noop;
allCompleteFn();
});
},
- after : function(allCompleteFn) {
+ after: function(allCompleteFn) {
afterComplete = allCompleteFn;
run(after, afterCancel, function() {
afterComplete = noop;
allCompleteFn();
});
},
- cancel : function() {
- if(beforeCancel) {
+ cancel: function() {
+ if (beforeCancel) {
forEach(beforeCancel, function(cancelFn) {
(cancelFn || noop)(true);
});
beforeComplete(true);
}
- if(afterCancel) {
+ if (afterCancel) {
forEach(afterCancel, function(cancelFn) {
(cancelFn || noop)(true);
});
@@ -541,7 +797,7 @@ angular.module('ngAnimate', ['ng'])
/**
* @ngdoc service
* @name $animate
- * @kind function
+ * @kind object
*
* @description
* The `$animate` service provides animation detection support while performing DOM operations (enter, leave and move) as well as during addClass and removeClass operations.
@@ -555,9 +811,109 @@ angular.module('ngAnimate', ['ng'])
* Requires the {@link ngAnimate `ngAnimate`} module to be installed.
*
* Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application.
+ * ## Callback Promises
+ * With AngularJS 1.3, each of the animation methods, on the `$animate` service, return a promise when called. The
+ * promise itself is then resolved once the animation has completed itself, has been cancelled or has been
+ * skipped due to animations being disabled. (Note that even if the animation is cancelled it will still
+ * call the resolve function of the animation.)
+ *
+ * ```js
+ * $animate.enter(element, container).then(function() {
+ * //...this is called once the animation is complete...
+ * });
+ * ```
+ *
+ * Also note that, due to the nature of the callback promise, if any Angular-specific code (like changing the scope,
+ * location of the page, etc...) is executed within the callback promise then be sure to wrap the code using
+ * `$scope.$apply(...)`;
+ *
+ * ```js
+ * $animate.leave(element).then(function() {
+ * $scope.$apply(function() {
+ * $location.path('/new-page');
+ * });
+ * });
+ * ```
+ *
+ * An animation can also be cancelled by calling the `$animate.cancel(promise)` method with the provided
+ * promise that was returned when the animation was started.
+ *
+ * ```js
+ * var promise = $animate.addClass(element, 'super-long-animation');
+ * promise.then(function() {
+ * //this will still be called even if cancelled
+ * });
+ *
+ * element.on('click', function() {
+ * //tooo lazy to wait for the animation to end
+ * $animate.cancel(promise);
+ * });
+ * ```
+ *
+ * (Keep in mind that the promise cancellation is unique to `$animate` since promises in
+ * general cannot be cancelled.)
*
*/
return {
+ /**
+ * @ngdoc method
+ * @name $animate#animate
+ * @kind function
+ *
+ * @description
+ * Performs an inline animation on the element which applies the provided `to` and `from` CSS styles to the element.
+ * If any detected CSS transition, keyframe or JavaScript matches the provided `className` value then the animation
+ * will take on the provided styles. For example, if a transition animation is set for the given className then the
+ * provided `from` and `to` styles will be applied alongside the given transition. If a JavaScript animation is
+ * detected then the provided styles will be given in as function paramters.
+ *
+ * ```js
+ * ngModule.animation('.my-inline-animation', function() {
+ * return {
+ * animate : function(element, className, from, to, done) {
+ * //styles
+ * }
+ * }
+ * });
+ * ```
+ *
+ * Below is a breakdown of each step that occurs during the `animate` animation:
+ *
+ * | Animation Step | What the element class attribute looks like |
+ * |-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
+ * | 1. `$animate.animate(...)` is called | `class="my-animation"` |
+ * | 2. `$animate` waits for the next digest to start the animation | `class="my-animation ng-animate"` |
+ * | 3. `$animate` runs the JavaScript-defined animations detected on the element | `class="my-animation ng-animate"` |
+ * | 4. the `className` class value is added to the element | `class="my-animation ng-animate className"` |
+ * | 5. `$animate` scans the element styles to get the CSS transition/animation duration and delay | `class="my-animation ng-animate className"` |
+ * | 6. `$animate` blocks all CSS transitions on the element to ensure the `.className` class styling is applied right away| `class="my-animation ng-animate className"` |
+ * | 7. `$animate` applies the provided collection of `from` CSS styles to the element | `class="my-animation ng-animate className"` |
+ * | 8. `$animate` waits for a single animation frame (this performs a reflow) | `class="my-animation ng-animate className"` |
+ * | 9. `$animate` removes the CSS transition block placed on the element | `class="my-animation ng-animate className"` |
+ * | 10. the `className-active` class is added (this triggers the CSS transition/animation) | `class="my-animation ng-animate className className-active"` |
+ * | 11. `$animate` applies the collection of `to` CSS styles to the element which are then handled by the transition | `class="my-animation ng-animate className className-active"` |
+ * | 12. `$animate` waits for the animation to complete (via events and timeout) | `class="my-animation ng-animate className className-active"` |
+ * | 13. The animation ends and all generated CSS classes are removed from the element | `class="my-animation"` |
+ * | 14. The returned promise is resolved. | `class="my-animation"` |
+ *
+ * @param {DOMElement} element the element that will be the focus of the enter animation
+ * @param {object} from a collection of CSS styles that will be applied to the element at the start of the animation
+ * @param {object} to a collection of CSS styles that the element will animate towards
+ * @param {string=} className an optional CSS class that will be added to the element for the duration of the animation (the default class is `ng-inline-animate`)
+ * @param {object=} options an optional collection of options that will be picked up by the CSS transition/animation
+ * @return {Promise} the animation callback promise
+ */
+ animate: function(element, from, to, className, options) {
+ className = className || 'ng-inline-animate';
+ options = parseAnimateOptions(options) || {};
+ options.from = to ? from : null;
+ options.to = to ? to : from;
+
+ return runAnimationPostDigest(function(done) {
+ return performAnimation('animate', className, stripCommentsFromElement(element), null, null, noop, options, done);
+ });
+ },
+
/**
* @ngdoc method
* @name $animate#enter
@@ -569,34 +925,38 @@ angular.module('ngAnimate', ['ng'])
*
* Below is a breakdown of each step that occurs during enter animation:
*
- * | Animation Step | What the element class attribute looks like |
- * |----------------------------------------------------------------------------------------------|---------------------------------------------|
- * | 1. $animate.enter(...) is called | class="my-animation" |
- * | 2. element is inserted into the parentElement element or beside the afterElement element | class="my-animation" |
- * | 3. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
- * | 4. the .ng-enter class is added to the element | class="my-animation ng-animate ng-enter" |
- * | 5. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-enter" |
- * | 6. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate ng-enter" |
- * | 7. the .ng-enter-active and .ng-animate-active classes are added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active ng-enter ng-enter-active" |
- * | 8. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active ng-enter ng-enter-active" |
- * | 9. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
- * | 10. The doneCallback() callback is fired (if provided) | class="my-animation" |
+ * | Animation Step | What the element class attribute looks like |
+ * |-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
+ * | 1. `$animate.enter(...)` is called | `class="my-animation"` |
+ * | 2. element is inserted into the `parentElement` element or beside the `afterElement` element | `class="my-animation"` |
+ * | 3. `$animate` waits for the next digest to start the animation | `class="my-animation ng-animate"` |
+ * | 4. `$animate` runs the JavaScript-defined animations detected on the element | `class="my-animation ng-animate"` |
+ * | 5. the `.ng-enter` class is added to the element | `class="my-animation ng-animate ng-enter"` |
+ * | 6. `$animate` scans the element styles to get the CSS transition/animation duration and delay | `class="my-animation ng-animate ng-enter"` |
+ * | 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"` |
+ * | 8. `$animate` waits for a single animation frame (this performs a reflow) | `class="my-animation ng-animate ng-enter"` |
+ * | 9. `$animate` removes the CSS transition block placed on the element | `class="my-animation ng-animate ng-enter"` |
+ * | 10. the `.ng-enter-active` class is added (this triggers the CSS transition/animation) | `class="my-animation ng-animate ng-enter ng-enter-active"` |
+ * | 11. `$animate` waits for the animation to complete (via events and timeout) | `class="my-animation ng-animate ng-enter ng-enter-active"` |
+ * | 12. The animation ends and all generated CSS classes are removed from the element | `class="my-animation"` |
+ * | 13. The returned promise is resolved. | `class="my-animation"` |
*
* @param {DOMElement} element the element that will be the focus of the enter animation
* @param {DOMElement} parentElement the parent element of the element that will be the focus of the enter animation
* @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
- * @param {function()=} doneCallback the callback function that will be called once the animation is complete
+ * @param {object=} options an optional collection of options that will be picked up by the CSS transition/animation
+ * @return {Promise} the animation callback promise
*/
- enter : function(element, parentElement, afterElement, doneCallback) {
+ enter: function(element, parentElement, afterElement, options) {
+ options = parseAnimateOptions(options);
element = angular.element(element);
parentElement = prepareElement(parentElement);
afterElement = prepareElement(afterElement);
- blockElementAnimations(element);
+ classBasedAnimationsBlocked(element, true);
$delegate.enter(element, parentElement, afterElement);
- $rootScope.$$postDigest(function() {
- element = stripCommentsFromElement(element);
- performAnimation('enter', 'ng-enter', element, parentElement, afterElement, noop, doneCallback);
+ return runAnimationPostDigest(function(done) {
+ return performAnimation('enter', 'ng-enter', stripCommentsFromElement(element), parentElement, afterElement, noop, options, done);
});
},
@@ -611,30 +971,36 @@ angular.module('ngAnimate', ['ng'])
*
* Below is a breakdown of each step that occurs during leave animation:
*
- * | Animation Step | What the element class attribute looks like |
- * |----------------------------------------------------------------------------------------------|---------------------------------------------|
- * | 1. $animate.leave(...) is called | class="my-animation" |
- * | 2. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
- * | 3. the .ng-leave class is added to the element | class="my-animation ng-animate ng-leave" |
- * | 4. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-leave" |
- * | 5. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate ng-leave" |
- * | 6. the .ng-leave-active and .ng-animate-active classes is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active ng-leave ng-leave-active" |
- * | 7. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active ng-leave ng-leave-active" |
- * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
- * | 9. The element is removed from the DOM | ... |
- * | 10. The doneCallback() callback is fired (if provided) | ... |
+ * | Animation Step | What the element class attribute looks like |
+ * |-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|
+ * | 1. `$animate.leave(...)` is called | `class="my-animation"` |
+ * | 2. `$animate` runs the JavaScript-defined animations detected on the element | `class="my-animation ng-animate"` |
+ * | 3. `$animate` waits for the next digest to start the animation | `class="my-animation ng-animate"` |
+ * | 4. the `.ng-leave` class is added to the element | `class="my-animation ng-animate ng-leave"` |
+ * | 5. `$animate` scans the element styles to get the CSS transition/animation duration and delay | `class="my-animation ng-animate ng-leave"` |
+ * | 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"` |
+ * | 7. `$animate` waits for a single animation frame (this performs a reflow) | `class="my-animation ng-animate ng-leave"` |
+ * | 8. `$animate` removes the CSS transition block placed on the element | `class="my-animation ng-animate ng-leave"` |
+ * | 9. the `.ng-leave-active` class is added (this triggers the CSS transition/animation) | `class="my-animation ng-animate ng-leave ng-leave-active"` |
+ * | 10. `$animate` waits for the animation to complete (via events and timeout) | `class="my-animation ng-animate ng-leave ng-leave-active"` |
+ * | 11. The animation ends and all generated CSS classes are removed from the element | `class="my-animation"` |
+ * | 12. The element is removed from the DOM | ... |
+ * | 13. The returned promise is resolved. | ... |
*
* @param {DOMElement} element the element that will be the focus of the leave animation
- * @param {function()=} doneCallback the callback function that will be called once the animation is complete
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
+ * @return {Promise} the animation callback promise
*/
- leave : function(element, doneCallback) {
+ leave: function(element, options) {
+ options = parseAnimateOptions(options);
element = angular.element(element);
+
cancelChildAnimations(element);
- blockElementAnimations(element);
- $rootScope.$$postDigest(function() {
- performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
+ classBasedAnimationsBlocked(element, true);
+ return runAnimationPostDigest(function(done) {
+ return performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
$delegate.leave(element);
- }, doneCallback);
+ }, options, done);
});
},
@@ -650,35 +1016,39 @@ angular.module('ngAnimate', ['ng'])
*
* Below is a breakdown of each step that occurs during move animation:
*
- * | Animation Step | What the element class attribute looks like |
- * |----------------------------------------------------------------------------------------------|---------------------------------------------|
- * | 1. $animate.move(...) is called | class="my-animation" |
- * | 2. element is moved into the parentElement element or beside the afterElement element | class="my-animation" |
- * | 3. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
- * | 4. the .ng-move class is added to the element | class="my-animation ng-animate ng-move" |
- * | 5. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate ng-move" |
- * | 6. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate ng-move" |
- * | 7. the .ng-move-active and .ng-animate-active classes is added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active ng-move ng-move-active" |
- * | 8. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active ng-move ng-move-active" |
- * | 9. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
- * | 10. The doneCallback() callback is fired (if provided) | class="my-animation" |
+ * | Animation Step | What the element class attribute looks like |
+ * |----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------|
+ * | 1. `$animate.move(...)` is called | `class="my-animation"` |
+ * | 2. element is moved into the parentElement element or beside the afterElement element | `class="my-animation"` |
+ * | 3. `$animate` waits for the next digest to start the animation | `class="my-animation ng-animate"` |
+ * | 4. `$animate` runs the JavaScript-defined animations detected on the element | `class="my-animation ng-animate"` |
+ * | 5. the `.ng-move` class is added to the element | `class="my-animation ng-animate ng-move"` |
+ * | 6. `$animate` scans the element styles to get the CSS transition/animation duration and delay | `class="my-animation ng-animate ng-move"` |
+ * | 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"` |
+ * | 8. `$animate` waits for a single animation frame (this performs a reflow) | `class="my-animation ng-animate ng-move"` |
+ * | 9. `$animate` removes the CSS transition block placed on the element | `class="my-animation ng-animate ng-move"` |
+ * | 10. the `.ng-move-active` class is added (this triggers the CSS transition/animation) | `class="my-animation ng-animate ng-move ng-move-active"` |
+ * | 11. `$animate` waits for the animation to complete (via events and timeout) | `class="my-animation ng-animate ng-move ng-move-active"` |
+ * | 12. The animation ends and all generated CSS classes are removed from the element | `class="my-animation"` |
+ * | 13. The returned promise is resolved. | `class="my-animation"` |
*
* @param {DOMElement} element the element that will be the focus of the move animation
* @param {DOMElement} parentElement the parentElement element of the element that will be the focus of the move animation
* @param {DOMElement} afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
- * @param {function()=} doneCallback the callback function that will be called once the animation is complete
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
+ * @return {Promise} the animation callback promise
*/
- move : function(element, parentElement, afterElement, doneCallback) {
+ move: function(element, parentElement, afterElement, options) {
+ options = parseAnimateOptions(options);
element = angular.element(element);
parentElement = prepareElement(parentElement);
afterElement = prepareElement(afterElement);
cancelChildAnimations(element);
- blockElementAnimations(element);
+ classBasedAnimationsBlocked(element, true);
$delegate.move(element, parentElement, afterElement);
- $rootScope.$$postDigest(function() {
- element = stripCommentsFromElement(element);
- performAnimation('move', 'ng-move', element, parentElement, afterElement, noop, doneCallback);
+ return runAnimationPostDigest(function(done) {
+ return performAnimation('move', 'ng-move', stripCommentsFromElement(element), parentElement, afterElement, noop, options, done);
});
},
@@ -690,33 +1060,30 @@ angular.module('ngAnimate', ['ng'])
* Triggers a custom animation event based off the className variable and then attaches the className value to the element as a CSS class.
* Unlike the other animation methods, the animate service will suffix the className value with {@type -add} in order to provide
* the animate service the setup and active CSS classes in order to trigger the animation (this will be skipped if no CSS transitions
- * or keyframes are defined on the -add or base CSS class).
+ * or keyframes are defined on the -add-active or base CSS class).
*
* Below is a breakdown of each step that occurs during addClass animation:
*
- * | Animation Step | What the element class attribute looks like |
- * |------------------------------------------------------------------------------------------------|---------------------------------------------|
- * | 1. $animate.addClass(element, 'super') is called | class="my-animation" |
- * | 2. $animate runs any JavaScript-defined animations on the element | class="my-animation ng-animate" |
- * | 3. the .super-add class are added to the element | class="my-animation ng-animate super-add" |
- * | 4. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation ng-animate super-add" |
- * | 5. $animate waits for 10ms (this performs a reflow) | class="my-animation ng-animate super-add" |
- * | 6. the .super, .super-add-active and .ng-animate-active classes are added (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active super super-add super-add-active" |
- * | 7. $animate waits for X milliseconds for the animation to complete | class="my-animation super super-add super-add-active" |
- * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation super" |
- * | 9. The super class is kept on the element | class="my-animation super" |
- * | 10. The doneCallback() callback is fired (if provided) | class="my-animation super" |
+ * | Animation Step | What the element class attribute looks like |
+ * |--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
+ * | 1. `$animate.addClass(element, 'super')` is called | `class="my-animation"` |
+ * | 2. `$animate` runs the JavaScript-defined animations detected on the element | `class="my-animation ng-animate"` |
+ * | 3. the `.super-add` class is added to the element | `class="my-animation ng-animate super-add"` |
+ * | 4. `$animate` waits for a single animation frame (this performs a reflow) | `class="my-animation ng-animate super-add"` |
+ * | 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"` |
+ * | 6. `$animate` scans the element styles to get the CSS transition/animation duration and delay | `class="my-animation ng-animate super super-add super-add-active"` |
+ * | 7. `$animate` waits for the animation to complete (via events and timeout) | `class="my-animation ng-animate super super-add super-add-active"` |
+ * | 8. The animation ends and all generated CSS classes are removed from the element | `class="my-animation super"` |
+ * | 9. The super class is kept on the element | `class="my-animation super"` |
+ * | 10. The returned promise is resolved. | `class="my-animation super"` |
*
* @param {DOMElement} element the element that will be animated
* @param {string} className the CSS class that will be added to the element and then animated
- * @param {function()=} doneCallback the callback function that will be called once the animation is complete
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
+ * @return {Promise} the animation callback promise
*/
- addClass : function(element, className, doneCallback) {
- element = angular.element(element);
- element = stripCommentsFromElement(element);
- performAnimation('addClass', className, element, null, null, function() {
- $delegate.addClass(element, className);
- }, doneCallback);
+ addClass: function(element, className, options) {
+ return this.setClass(element, className, [], options);
},
/**
@@ -731,51 +1098,141 @@ angular.module('ngAnimate', ['ng'])
*
* Below is a breakdown of each step that occurs during removeClass animation:
*
- * | Animation Step | What the element class attribute looks like |
- * |-----------------------------------------------------------------------------------------------|---------------------------------------------|
- * | 1. $animate.removeClass(element, 'super') is called | class="my-animation super" |
- * | 2. $animate runs any JavaScript-defined animations on the element | class="my-animation super ng-animate" |
- * | 3. the .super-remove class are added to the element | class="my-animation super ng-animate super-remove"|
- * | 4. $animate scans the element styles to get the CSS transition/animation duration and delay | class="my-animation super ng-animate super-remove" |
- * | 5. $animate waits for 10ms (this performs a reflow) | class="my-animation super ng-animate super-remove" |
- * | 6. the .super-remove-active and .ng-animate-active classes are added and .super is removed (this triggers the CSS transition/animation) | class="my-animation ng-animate ng-animate-active super-remove super-remove-active" |
- * | 7. $animate waits for X milliseconds for the animation to complete | class="my-animation ng-animate ng-animate-active super-remove super-remove-active" |
- * | 8. The animation ends and all generated CSS classes are removed from the element | class="my-animation" |
- * | 9. The doneCallback() callback is fired (if provided) | class="my-animation" |
+ * | Animation Step | What the element class attribute looks like |
+ * |----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
+ * | 1. `$animate.removeClass(element, 'super')` is called | `class="my-animation super"` |
+ * | 2. `$animate` runs the JavaScript-defined animations detected on the element | `class="my-animation super ng-animate"` |
+ * | 3. the `.super-remove` class is added to the element | `class="my-animation super ng-animate super-remove"` |
+ * | 4. `$animate` waits for a single animation frame (this performs a reflow) | `class="my-animation super ng-animate super-remove"` |
+ * | 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"` |
+ * | 6. `$animate` scans the element styles to get the CSS transition/animation duration and delay | `class="my-animation ng-animate super-remove super-remove-active"` |
+ * | 7. `$animate` waits for the animation to complete (via events and timeout) | `class="my-animation ng-animate super-remove super-remove-active"` |
+ * | 8. The animation ends and all generated CSS classes are removed from the element | `class="my-animation"` |
+ * | 9. The returned promise is resolved. | `class="my-animation"` |
*
*
* @param {DOMElement} element the element that will be animated
* @param {string} className the CSS class that will be animated and then removed from the element
- * @param {function()=} doneCallback the callback function that will be called once the animation is complete
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
+ * @return {Promise} the animation callback promise
*/
- removeClass : function(element, className, doneCallback) {
- element = angular.element(element);
- element = stripCommentsFromElement(element);
- performAnimation('removeClass', className, element, null, null, function() {
- $delegate.removeClass(element, className);
- }, doneCallback);
+ removeClass: function(element, className, options) {
+ return this.setClass(element, [], className, options);
},
- /**
- *
- * @ngdoc function
- * @name $animate#setClass
- * @function
- * @description Adds and/or removes the given CSS classes to and from the element.
- * Once complete, the done() callback will be fired (if provided).
- * @param {DOMElement} element the element which will its CSS classes changed
- * removed from it
- * @param {string} add the CSS classes which will be added to the element
- * @param {string} remove the CSS class which will be removed from the element
- * @param {Function=} done the callback function (if provided) that will be fired after the
- * CSS classes have been set on the element
- */
- setClass : function(element, add, remove, doneCallback) {
+ /**
+ *
+ * @ngdoc method
+ * @name $animate#setClass
+ *
+ * @description Adds and/or removes the given CSS classes to and from the element.
+ * Once complete, the `done()` callback will be fired (if provided).
+ *
+ * | Animation Step | What the element class attribute looks like |
+ * |----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
+ * | 1. `$animate.setClass(element, 'on', 'off')` is called | `class="my-animation off"` |
+ * | 2. `$animate` runs the JavaScript-defined animations detected on the element | `class="my-animation ng-animate off"` |
+ * | 3. the `.on-add` and `.off-remove` classes are added to the element | `class="my-animation ng-animate on-add off-remove off"` |
+ * | 4. `$animate` waits for a single animation frame (this performs a reflow) | `class="my-animation ng-animate on-add off-remove off"` |
+ * | 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"` |
+ * | 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"` |
+ * | 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"` |
+ * | 8. The animation ends and all generated CSS classes are removed from the element | `class="my-animation on"` |
+ * | 9. The returned promise is resolved. | `class="my-animation on"` |
+ *
+ * @param {DOMElement} element the element which will have its CSS classes changed
+ * removed from it
+ * @param {string} add the CSS classes which will be added to the element
+ * @param {string} remove the CSS class which will be removed from the element
+ * CSS classes have been set on the element
+ * @param {object=} options an optional collection of styles that will be picked up by the CSS transition/animation
+ * @return {Promise} the animation callback promise
+ */
+ setClass: function(element, add, remove, options) {
+ options = parseAnimateOptions(options);
+
+ var STORAGE_KEY = '$$animateClasses';
element = angular.element(element);
element = stripCommentsFromElement(element);
- performAnimation('setClass', [add, remove], element, null, null, function() {
- $delegate.setClass(element, add, remove);
- }, doneCallback);
+
+ if (classBasedAnimationsBlocked(element)) {
+ return $delegate.$$setClassImmediately(element, add, remove, options);
+ }
+
+ // we're using a combined array for both the add and remove
+ // operations since the ORDER OF addClass and removeClass matters
+ var classes, cache = element.data(STORAGE_KEY);
+ var hasCache = !!cache;
+ if (!cache) {
+ cache = {};
+ cache.classes = {};
+ }
+ classes = cache.classes;
+
+ add = isArray(add) ? add : add.split(' ');
+ forEach(add, function(c) {
+ if (c && c.length) {
+ classes[c] = true;
+ }
+ });
+
+ remove = isArray(remove) ? remove : remove.split(' ');
+ forEach(remove, function(c) {
+ if (c && c.length) {
+ classes[c] = false;
+ }
+ });
+
+ if (hasCache) {
+ if (options && cache.options) {
+ cache.options = angular.extend(cache.options || {}, options);
+ }
+
+ //the digest cycle will combine all the animations into one function
+ return cache.promise;
+ } else {
+ element.data(STORAGE_KEY, cache = {
+ classes: classes,
+ options: options
+ });
+ }
+
+ return cache.promise = runAnimationPostDigest(function(done) {
+ var parentElement = element.parent();
+ var elementNode = extractElementNode(element);
+ var parentNode = elementNode.parentNode;
+ // TODO(matsko): move this code into the animationsDisabled() function once #8092 is fixed
+ if (!parentNode || parentNode['$$NG_REMOVED'] || elementNode['$$NG_REMOVED']) {
+ done();
+ return;
+ }
+
+ var cache = element.data(STORAGE_KEY);
+ element.removeData(STORAGE_KEY);
+
+ var state = element.data(NG_ANIMATE_STATE) || {};
+ var classes = resolveElementClasses(element, cache, state.active);
+ return !classes
+ ? done()
+ : performAnimation('setClass', classes, element, parentElement, null, function() {
+ if (classes[0]) $delegate.$$addClassImmediately(element, classes[0]);
+ if (classes[1]) $delegate.$$removeClassImmediately(element, classes[1]);
+ }, cache.options, done);
+ });
+ },
+
+ /**
+ * @ngdoc method
+ * @name $animate#cancel
+ * @kind function
+ *
+ * @param {Promise} animationPromise The animation promise that is returned when an animation is started.
+ *
+ * @description
+ * Cancels the provided animation.
+ */
+ cancel: function(promise) {
+ promise.$$cancelFn();
},
/**
@@ -791,10 +1248,10 @@ angular.module('ngAnimate', ['ng'])
* Globally enables/disables animations.
*
*/
- enabled : function(value, element) {
- switch(arguments.length) {
+ enabled: function(value, element) {
+ switch (arguments.length) {
case 2:
- if(value) {
+ if (value) {
cleanup(element);
} else {
var data = element.data(NG_ANIMATE_STATE) || {};
@@ -819,20 +1276,21 @@ angular.module('ngAnimate', ['ng'])
all animations call this shared animation triggering function internally.
The animationEvent variable refers to the JavaScript animation event that will be triggered
and the className value is the name of the animation that will be applied within the
- CSS code. Element, parentElement and afterElement are provided DOM elements for the animation
+ CSS code. Element, `parentElement` and `afterElement` are provided DOM elements for the animation
and the onComplete callback will be fired once the animation is fully complete.
*/
- function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, doneCallback) {
-
- var runner = animationRunner(element, animationEvent, className);
- if(!runner) {
+ function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, options, doneCallback) {
+ var noopCancel = noop;
+ var runner = animationRunner(element, animationEvent, className, options);
+ if (!runner) {
fireDOMOperation();
fireBeforeCallbackAsync();
fireAfterCallbackAsync();
closeAnimation();
- return;
+ return noopCancel;
}
+ animationEvent = runner.event;
className = runner.className;
var elementEvents = angular.element._data(runner.node);
elementEvents = elementEvents && elementEvents.events;
@@ -841,54 +1299,44 @@ angular.module('ngAnimate', ['ng'])
parentElement = afterElement ? afterElement.parent() : element.parent();
}
- var ngAnimateState = element.data(NG_ANIMATE_STATE) || {};
- var runningAnimations = ngAnimateState.active || {};
- var totalActiveAnimations = ngAnimateState.totalActive || 0;
- var lastAnimation = ngAnimateState.last;
-
- //only allow animations if the currently running animation is not structural
- //or if there is no animation running at all
- var skipAnimations;
- if (runner.isClassBased) {
- skipAnimations = ngAnimateState.running ||
- ngAnimateState.disabled ||
- (lastAnimation && !lastAnimation.isClassBased);
- }
-
//skip the animation if animations are disabled, a parent is already being animated,
//the element is not currently attached to the document body or then completely close
//the animation if any matching animations are not found at all.
//NOTE: IE8 + IE9 should close properly (run closeAnimation()) in case an animation was found.
- if (skipAnimations || animationsDisabled(element, parentElement)) {
+ if (animationsDisabled(element, parentElement)) {
fireDOMOperation();
fireBeforeCallbackAsync();
fireAfterCallbackAsync();
closeAnimation();
- return;
+ return noopCancel;
}
+ var ngAnimateState = element.data(NG_ANIMATE_STATE) || {};
+ var runningAnimations = ngAnimateState.active || {};
+ var totalActiveAnimations = ngAnimateState.totalActive || 0;
+ var lastAnimation = ngAnimateState.last;
var skipAnimation = false;
- if(totalActiveAnimations > 0) {
+
+ if (totalActiveAnimations > 0) {
var animationsToCancel = [];
- if(!runner.isClassBased) {
- if(animationEvent == 'leave' && runningAnimations['ng-leave']) {
+ if (!runner.isClassBased) {
+ if (animationEvent == 'leave' && runningAnimations['ng-leave']) {
skipAnimation = true;
} else {
//cancel all animations when a structural animation takes place
- for(var klass in runningAnimations) {
+ for (var klass in runningAnimations) {
animationsToCancel.push(runningAnimations[klass]);
- cleanup(element, klass);
}
- runningAnimations = {};
- totalActiveAnimations = 0;
+ ngAnimateState = {};
+ cleanup(element, true);
}
- } else if(lastAnimation.event == 'setClass') {
+ } else if (lastAnimation.event == 'setClass') {
animationsToCancel.push(lastAnimation);
cleanup(element, className);
}
- else if(runningAnimations[className]) {
+ else if (runningAnimations[className]) {
var current = runningAnimations[className];
- if(current.event == animationEvent) {
+ if (current.event == animationEvent) {
skipAnimation = true;
} else {
animationsToCancel.push(current);
@@ -896,35 +1344,41 @@ angular.module('ngAnimate', ['ng'])
}
}
- if(animationsToCancel.length > 0) {
+ if (animationsToCancel.length > 0) {
forEach(animationsToCancel, function(operation) {
operation.cancel();
});
}
}
- if(runner.isClassBased && !runner.isSetClassOperation && !skipAnimation) {
+ if (runner.isClassBased
+ && !runner.isSetClassOperation
+ && animationEvent != 'animate'
+ && !skipAnimation) {
skipAnimation = (animationEvent == 'addClass') == element.hasClass(className); //opposite of XOR
}
- if(skipAnimation) {
+ if (skipAnimation) {
fireDOMOperation();
fireBeforeCallbackAsync();
fireAfterCallbackAsync();
fireDoneCallbackAsync();
- return;
+ return noopCancel;
}
- if(animationEvent == 'leave') {
+ runningAnimations = ngAnimateState.active || {};
+ totalActiveAnimations = ngAnimateState.totalActive || 0;
+
+ if (animationEvent == 'leave') {
//there's no need to ever remove the listener since the element
//will be removed (destroyed) after the leave animation ends or
//is cancelled midway
element.one('$destroy', function(e) {
var element = angular.element(this);
var state = element.data(NG_ANIMATE_STATE);
- if(state) {
+ if (state) {
var activeLeaveAnimation = state.active['ng-leave'];
- if(activeLeaveAnimation) {
+ if (activeLeaveAnimation) {
activeLeaveAnimation.cancel();
cleanup(element, 'ng-leave');
}
@@ -934,17 +1388,22 @@ angular.module('ngAnimate', ['ng'])
//the ng-animate class does nothing, but it's here to allow for
//parent animations to find and cancel child animations when needed
- element.addClass(NG_ANIMATE_CLASS_NAME);
+ $$jqLite.addClass(element, NG_ANIMATE_CLASS_NAME);
+ if (options && options.tempClasses) {
+ forEach(options.tempClasses, function(className) {
+ $$jqLite.addClass(element, className);
+ });
+ }
var localAnimationCount = globalAnimationCounter++;
totalActiveAnimations++;
runningAnimations[className] = runner;
element.data(NG_ANIMATE_STATE, {
- last : runner,
- active : runningAnimations,
- index : localAnimationCount,
- totalActive : totalActiveAnimations
+ last: runner,
+ active: runningAnimations,
+ index: localAnimationCount,
+ totalActive: totalActiveAnimations
});
//first we run the before animations and when all of those are complete
@@ -957,7 +1416,7 @@ angular.module('ngAnimate', ['ng'])
(runner.isClassBased && data.active[className].event != animationEvent);
fireDOMOperation();
- if(cancelled === true) {
+ if (cancelled === true) {
closeAnimation();
} else {
fireAfterCallbackAsync();
@@ -965,13 +1424,15 @@ angular.module('ngAnimate', ['ng'])
}
});
+ return runner.cancel;
+
function fireDOMCallback(animationPhase) {
var eventName = '$animate:' + animationPhase;
- if(elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
+ if (elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) {
$$asyncCallback(function() {
element.triggerHandler(eventName, {
- event : animationEvent,
- className : className
+ event: animationEvent,
+ className: className
});
});
}
@@ -987,37 +1448,44 @@ angular.module('ngAnimate', ['ng'])
function fireDoneCallbackAsync() {
fireDOMCallback('close');
- if(doneCallback) {
- $$asyncCallback(function() {
- doneCallback();
- });
- }
+ doneCallback();
}
//it is less complicated to use a flag than managing and canceling
//timeouts containing multiple callbacks.
function fireDOMOperation() {
- if(!fireDOMOperation.hasBeenRun) {
+ if (!fireDOMOperation.hasBeenRun) {
fireDOMOperation.hasBeenRun = true;
domOperation();
}
}
function closeAnimation() {
- if(!closeAnimation.hasBeenRun) {
+ if (!closeAnimation.hasBeenRun) {
+ if (runner) { //the runner doesn't exist if it fails to instantiate
+ runner.applyStyles();
+ }
+
closeAnimation.hasBeenRun = true;
+ if (options && options.tempClasses) {
+ forEach(options.tempClasses, function(className) {
+ $$jqLite.removeClass(element, className);
+ });
+ }
+
var data = element.data(NG_ANIMATE_STATE);
- if(data) {
+ if (data) {
+
/* only structural animations wait for reflow before removing an
animation, but class-based animations don't. An example of this
failing would be when a parent HTML tag has a ng-class attribute
causing ALL directives below to skip animations during the digest */
- if(runner && runner.isClassBased) {
+ if (runner && runner.isClassBased) {
cleanup(element, className);
} else {
$$asyncCallback(function() {
var data = element.data(NG_ANIMATE_STATE) || {};
- if(localAnimationCount == data.index) {
+ if (localAnimationCount == data.index) {
cleanup(element, className, animationEvent);
}
});
@@ -1038,7 +1506,7 @@ angular.module('ngAnimate', ['ng'])
forEach(nodes, function(element) {
element = angular.element(element);
var data = element.data(NG_ANIMATE_STATE);
- if(data && data.active) {
+ if (data && data.active) {
forEach(data.active, function(runner) {
runner.cancel();
});
@@ -1048,22 +1516,22 @@ angular.module('ngAnimate', ['ng'])
}
function cleanup(element, className) {
- if(isMatchingElement(element, $rootElement)) {
- if(!rootAnimateState.disabled) {
+ if (isMatchingElement(element, $rootElement)) {
+ if (!rootAnimateState.disabled) {
rootAnimateState.running = false;
rootAnimateState.structural = false;
}
- } else if(className) {
+ } else if (className) {
var data = element.data(NG_ANIMATE_STATE) || {};
var removeAnimations = className === true;
- if(!removeAnimations && data.active && data.active[className]) {
+ if (!removeAnimations && data.active && data.active[className]) {
data.totalActive--;
delete data.active[className];
}
- if(removeAnimations || !data.totalActive) {
- element.removeClass(NG_ANIMATE_CLASS_NAME);
+ if (removeAnimations || !data.totalActive) {
+ $$jqLite.removeClass(element, NG_ANIMATE_CLASS_NAME);
element.removeData(NG_ANIMATE_STATE);
}
}
@@ -1101,7 +1569,7 @@ angular.module('ngAnimate', ['ng'])
//it will be discarded and all child animations will be restricted
if (allowChildAnimations !== false) {
var animateChildrenFlag = parentElement.data(NG_ANIMATE_CHILDREN);
- if(angular.isDefined(animateChildrenFlag)) {
+ if (angular.isDefined(animateChildrenFlag)) {
allowChildAnimations = animateChildrenFlag;
}
}
@@ -1110,7 +1578,7 @@ angular.module('ngAnimate', ['ng'])
state.running ||
(state.last && !state.last.isClassBased);
}
- while(parentElement = parentElement.parent());
+ while (parentElement = parentElement.parent());
return !hasParent || (!allowChildAnimations && parentRunningAnimation);
}
@@ -1151,9 +1619,9 @@ angular.module('ngAnimate', ['ng'])
var PROPERTY_KEY = 'Property';
var DELAY_KEY = 'Delay';
var ANIMATION_ITERATION_COUNT_KEY = 'IterationCount';
+ var ANIMATION_PLAYSTATE_KEY = 'PlayState';
var NG_ANIMATE_PARENT_KEY = '$$ngAnimateKey';
var NG_ANIMATE_CSS_DATA_KEY = '$$ngAnimateCSS3Data';
- var NG_ANIMATE_BLOCK_CLASS_NAME = 'ng-animate-block-transitions';
var ELAPSED_TIME_MAX_DECIMAL_PLACES = 3;
var CLOSING_TIME_BUFFER = 1.5;
var ONE_SECOND = 1000;
@@ -1162,8 +1630,18 @@ angular.module('ngAnimate', ['ng'])
var parentCounter = 0;
var animationReflowQueue = [];
var cancelAnimationReflow;
+ function clearCacheAfterReflow() {
+ if (!cancelAnimationReflow) {
+ cancelAnimationReflow = $$animateReflow(function() {
+ animationReflowQueue = [];
+ cancelAnimationReflow = null;
+ lookupCache = {};
+ });
+ }
+ }
+
function afterReflow(element, callback) {
- if(cancelAnimationReflow) {
+ if (cancelAnimationReflow) {
cancelAnimationReflow();
}
animationReflowQueue.push(callback);
@@ -1192,7 +1670,7 @@ angular.module('ngAnimate', ['ng'])
//but it may not need to cancel out the existing timeout
//if the timestamp is less than the previous one
var futureTimestamp = Date.now() + totalTime;
- if(futureTimestamp <= closingTimestamp) {
+ if (futureTimestamp <= closingTimestamp) {
return;
}
@@ -1208,64 +1686,52 @@ angular.module('ngAnimate', ['ng'])
function closeAllAnimations(elements) {
forEach(elements, function(element) {
var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
- if(elementData) {
- (elementData.closeAnimationFn || noop)();
+ if (elementData) {
+ forEach(elementData.closeAnimationFns, function(fn) {
+ fn();
+ });
}
});
}
function getElementAnimationDetails(element, cacheKey) {
var data = cacheKey ? lookupCache[cacheKey] : null;
- if(!data) {
+ if (!data) {
var transitionDuration = 0;
var transitionDelay = 0;
var animationDuration = 0;
var animationDelay = 0;
- var transitionDelayStyle;
- var animationDelayStyle;
- var transitionDurationStyle;
- var transitionPropertyStyle;
//we want all the styles defined before and after
forEach(element, function(element) {
if (element.nodeType == ELEMENT_NODE) {
var elementStyles = $window.getComputedStyle(element) || {};
- transitionDurationStyle = elementStyles[TRANSITION_PROP + DURATION_KEY];
-
+ var transitionDurationStyle = elementStyles[TRANSITION_PROP + DURATION_KEY];
transitionDuration = Math.max(parseMaxTime(transitionDurationStyle), transitionDuration);
- transitionPropertyStyle = elementStyles[TRANSITION_PROP + PROPERTY_KEY];
-
- transitionDelayStyle = elementStyles[TRANSITION_PROP + DELAY_KEY];
-
+ var transitionDelayStyle = elementStyles[TRANSITION_PROP + DELAY_KEY];
transitionDelay = Math.max(parseMaxTime(transitionDelayStyle), transitionDelay);
- animationDelayStyle = elementStyles[ANIMATION_PROP + DELAY_KEY];
-
- animationDelay = Math.max(parseMaxTime(animationDelayStyle), animationDelay);
+ var animationDelayStyle = elementStyles[ANIMATION_PROP + DELAY_KEY];
+ animationDelay = Math.max(parseMaxTime(elementStyles[ANIMATION_PROP + DELAY_KEY]), animationDelay);
var aDuration = parseMaxTime(elementStyles[ANIMATION_PROP + DURATION_KEY]);
- if(aDuration > 0) {
+ if (aDuration > 0) {
aDuration *= parseInt(elementStyles[ANIMATION_PROP + ANIMATION_ITERATION_COUNT_KEY], 10) || 1;
}
-
animationDuration = Math.max(aDuration, animationDuration);
}
});
data = {
- total : 0,
- transitionPropertyStyle: transitionPropertyStyle,
- transitionDurationStyle: transitionDurationStyle,
- transitionDelayStyle: transitionDelayStyle,
+ total: 0,
transitionDelay: transitionDelay,
transitionDuration: transitionDuration,
- animationDelayStyle: animationDelayStyle,
animationDelay: animationDelay,
animationDuration: animationDuration
};
- if(cacheKey) {
+ if (cacheKey) {
lookupCache[cacheKey] = data;
}
}
@@ -1274,7 +1740,7 @@ angular.module('ngAnimate', ['ng'])
function parseMaxTime(str) {
var maxValue = 0;
- var values = angular.isString(str) ?
+ var values = isString(str) ?
str.split(/\s*,\s*/) :
[];
forEach(values, function(value) {
@@ -1286,179 +1752,187 @@ angular.module('ngAnimate', ['ng'])
function getCacheKey(element) {
var parentElement = element.parent();
var parentID = parentElement.data(NG_ANIMATE_PARENT_KEY);
- if(!parentID) {
+ if (!parentID) {
parentElement.data(NG_ANIMATE_PARENT_KEY, ++parentCounter);
parentID = parentCounter;
}
return parentID + '-' + extractElementNode(element).getAttribute('class');
}
- function animateSetup(animationEvent, element, className, calculationDecorator) {
+ function animateSetup(animationEvent, element, className, styles) {
+ var structural = ['ng-enter','ng-leave','ng-move'].indexOf(className) >= 0;
+
var cacheKey = getCacheKey(element);
var eventCacheKey = cacheKey + ' ' + className;
var itemIndex = lookupCache[eventCacheKey] ? ++lookupCache[eventCacheKey].total : 0;
var stagger = {};
- if(itemIndex > 0) {
+ if (itemIndex > 0) {
var staggerClassName = className + '-stagger';
var staggerCacheKey = cacheKey + ' ' + staggerClassName;
var applyClasses = !lookupCache[staggerCacheKey];
- applyClasses && element.addClass(staggerClassName);
+ applyClasses && $$jqLite.addClass(element, staggerClassName);
stagger = getElementAnimationDetails(element, staggerCacheKey);
- applyClasses && element.removeClass(staggerClassName);
+ applyClasses && $$jqLite.removeClass(element, staggerClassName);
}
- /* the animation itself may need to add/remove special CSS classes
- * before calculating the anmation styles */
- calculationDecorator = calculationDecorator ||
- function(fn) { return fn(); };
-
- element.addClass(className);
+ $$jqLite.addClass(element, className);
var formerData = element.data(NG_ANIMATE_CSS_DATA_KEY) || {};
-
- var timings = calculationDecorator(function() {
- return getElementAnimationDetails(element, eventCacheKey);
- });
-
+ var timings = getElementAnimationDetails(element, eventCacheKey);
var transitionDuration = timings.transitionDuration;
var animationDuration = timings.animationDuration;
- if(transitionDuration === 0 && animationDuration === 0) {
- element.removeClass(className);
+
+ if (structural && transitionDuration === 0 && animationDuration === 0) {
+ $$jqLite.removeClass(element, className);
return false;
}
+ var blockTransition = styles || (structural && transitionDuration > 0);
+ var blockAnimation = animationDuration > 0 &&
+ stagger.animationDelay > 0 &&
+ stagger.animationDuration === 0;
+
+ var closeAnimationFns = formerData.closeAnimationFns || [];
element.data(NG_ANIMATE_CSS_DATA_KEY, {
- running : formerData.running || 0,
- itemIndex : itemIndex,
- stagger : stagger,
- timings : timings,
- closeAnimationFn : noop
+ stagger: stagger,
+ cacheKey: eventCacheKey,
+ running: formerData.running || 0,
+ itemIndex: itemIndex,
+ blockTransition: blockTransition,
+ closeAnimationFns: closeAnimationFns
});
- //temporarily disable the transition so that the enter styles
- //don't animate twice (this is here to avoid a bug in Chrome/FF).
- var isCurrentlyAnimating = formerData.running > 0 || animationEvent == 'setClass';
- if(transitionDuration > 0) {
- blockTransitions(element, className, isCurrentlyAnimating);
+ var node = extractElementNode(element);
+
+ if (blockTransition) {
+ blockTransitions(node, true);
+ if (styles) {
+ element.css(styles);
+ }
}
- //staggering keyframe animations work by adjusting the `animation-delay` CSS property
- //on the given element, however, the delay value can only calculated after the reflow
- //since by that time $animate knows how many elements are being animated. Therefore,
- //until the reflow occurs the element needs to be blocked (where the keyframe animation
- //is set to `none 0s`). This blocking mechanism should only be set for when a stagger
- //animation is detected and when the element item index is greater than 0.
- if(animationDuration > 0 && stagger.animationDelay > 0 && stagger.animationDuration === 0) {
- blockKeyframeAnimations(element);
+ if (blockAnimation) {
+ blockAnimations(node, true);
}
return true;
}
- function isStructuralAnimation(className) {
- return className == 'ng-enter' || className == 'ng-move' || className == 'ng-leave';
- }
-
- function blockTransitions(element, className, isAnimating) {
- if(isStructuralAnimation(className) || !isAnimating) {
- extractElementNode(element).style[TRANSITION_PROP + PROPERTY_KEY] = 'none';
- } else {
- element.addClass(NG_ANIMATE_BLOCK_CLASS_NAME);
- }
- }
-
- function blockKeyframeAnimations(element) {
- extractElementNode(element).style[ANIMATION_PROP] = 'none 0s';
- }
-
- function unblockTransitions(element, className) {
- var prop = TRANSITION_PROP + PROPERTY_KEY;
- var node = extractElementNode(element);
- if(node.style[prop] && node.style[prop].length > 0) {
- node.style[prop] = '';
- }
- element.removeClass(NG_ANIMATE_BLOCK_CLASS_NAME);
- }
-
- function unblockKeyframeAnimations(element) {
- var prop = ANIMATION_PROP;
- var node = extractElementNode(element);
- if(node.style[prop] && node.style[prop].length > 0) {
- node.style[prop] = '';
- }
- }
-
- function animateRun(animationEvent, element, className, activeAnimationComplete) {
+ function animateRun(animationEvent, element, className, activeAnimationComplete, styles) {
var node = extractElementNode(element);
var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY);
- if(node.getAttribute('class').indexOf(className) == -1 || !elementData) {
+ if (node.getAttribute('class').indexOf(className) == -1 || !elementData) {
activeAnimationComplete();
return;
}
var activeClassName = '';
+ var pendingClassName = '';
forEach(className.split(' '), function(klass, i) {
- activeClassName += (i > 0 ? ' ' : '') + klass + '-active';
+ var prefix = (i > 0 ? ' ' : '') + klass;
+ activeClassName += prefix + '-active';
+ pendingClassName += prefix + '-pending';
});
- var stagger = elementData.stagger;
- var timings = elementData.timings;
+ var style = '';
+ var appliedStyles = [];
var itemIndex = elementData.itemIndex;
+ var stagger = elementData.stagger;
+ var staggerTime = 0;
+ if (itemIndex > 0) {
+ var transitionStaggerDelay = 0;
+ if (stagger.transitionDelay > 0 && stagger.transitionDuration === 0) {
+ transitionStaggerDelay = stagger.transitionDelay * itemIndex;
+ }
+
+ var animationStaggerDelay = 0;
+ if (stagger.animationDelay > 0 && stagger.animationDuration === 0) {
+ animationStaggerDelay = stagger.animationDelay * itemIndex;
+ appliedStyles.push(CSS_PREFIX + 'animation-play-state');
+ }
+
+ staggerTime = Math.round(Math.max(transitionStaggerDelay, animationStaggerDelay) * 100) / 100;
+ }
+
+ if (!staggerTime) {
+ $$jqLite.addClass(element, activeClassName);
+ if (elementData.blockTransition) {
+ blockTransitions(node, false);
+ }
+ }
+
+ var eventCacheKey = elementData.cacheKey + ' ' + activeClassName;
+ var timings = getElementAnimationDetails(element, eventCacheKey);
var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration);
+ if (maxDuration === 0) {
+ $$jqLite.removeClass(element, activeClassName);
+ animateClose(element, className);
+ activeAnimationComplete();
+ return;
+ }
+
+ if (!staggerTime && styles && Object.keys(styles).length > 0) {
+ if (!timings.transitionDuration) {
+ element.css('transition', timings.animationDuration + 's linear all');
+ appliedStyles.push('transition');
+ }
+ element.css(styles);
+ }
+
var maxDelay = Math.max(timings.transitionDelay, timings.animationDelay);
var maxDelayTime = maxDelay * ONE_SECOND;
- var startTime = Date.now();
- var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
-
- var style = '', appliedStyles = [];
- if(timings.transitionDuration > 0) {
- var propertyStyle = timings.transitionPropertyStyle;
- if(propertyStyle.indexOf('all') == -1) {
- style += CSS_PREFIX + 'transition-property: ' + propertyStyle + ';';
- style += CSS_PREFIX + 'transition-duration: ' + timings.transitionDurationStyle + ';';
- appliedStyles.push(CSS_PREFIX + 'transition-property');
- appliedStyles.push(CSS_PREFIX + 'transition-duration');
- }
- }
-
- if(itemIndex > 0) {
- if(stagger.transitionDelay > 0 && stagger.transitionDuration === 0) {
- var delayStyle = timings.transitionDelayStyle;
- style += CSS_PREFIX + 'transition-delay: ' +
- prepareStaggerDelay(delayStyle, stagger.transitionDelay, itemIndex) + '; ';
- appliedStyles.push(CSS_PREFIX + 'transition-delay');
- }
-
- if(stagger.animationDelay > 0 && stagger.animationDuration === 0) {
- style += CSS_PREFIX + 'animation-delay: ' +
- prepareStaggerDelay(timings.animationDelayStyle, stagger.animationDelay, itemIndex) + '; ';
- appliedStyles.push(CSS_PREFIX + 'animation-delay');
- }
- }
-
- if(appliedStyles.length > 0) {
+ if (appliedStyles.length > 0) {
//the element being animated may sometimes contain comment nodes in
//the jqLite object, so we're safe to use a single variable to house
//the styles since there is always only one element being animated
var oldStyle = node.getAttribute('style') || '';
- node.setAttribute('style', oldStyle + '; ' + style);
+ if (oldStyle.charAt(oldStyle.length - 1) !== ';') {
+ oldStyle += ';';
+ }
+ node.setAttribute('style', oldStyle + ' ' + style);
+ }
+
+ var startTime = Date.now();
+ var css3AnimationEvents = ANIMATIONEND_EVENT + ' ' + TRANSITIONEND_EVENT;
+ var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER;
+ var totalTime = (staggerTime + animationTime) * ONE_SECOND;
+
+ var staggerTimeout;
+ if (staggerTime > 0) {
+ $$jqLite.addClass(element, pendingClassName);
+ staggerTimeout = $timeout(function() {
+ staggerTimeout = null;
+
+ if (timings.transitionDuration > 0) {
+ blockTransitions(node, false);
+ }
+ if (timings.animationDuration > 0) {
+ blockAnimations(node, false);
+ }
+
+ $$jqLite.addClass(element, activeClassName);
+ $$jqLite.removeClass(element, pendingClassName);
+
+ if (styles) {
+ if (timings.transitionDuration === 0) {
+ element.css('transition', timings.animationDuration + 's linear all');
+ }
+ element.css(styles);
+ appliedStyles.push('transition');
+ }
+ }, staggerTime * ONE_SECOND, false);
}
element.on(css3AnimationEvents, onAnimationProgress);
- element.addClass(activeClassName);
- elementData.closeAnimationFn = function() {
+ elementData.closeAnimationFns.push(function() {
onEnd();
activeAnimationComplete();
- };
-
- var staggerTime = itemIndex * (Math.max(stagger.animationDelay, stagger.transitionDelay) || 0);
- var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER;
- var totalTime = (staggerTime + animationTime) * ONE_SECOND;
+ });
elementData.running++;
animationCloseHandler(element, totalTime);
@@ -1467,9 +1941,13 @@ angular.module('ngAnimate', ['ng'])
// This will automatically be called by $animate so
// there is no need to attach this internally to the
// timeout done method.
- function onEnd(cancelled) {
+ function onEnd() {
element.off(css3AnimationEvents, onAnimationProgress);
- element.removeClass(activeClassName);
+ $$jqLite.removeClass(element, activeClassName);
+ $$jqLite.removeClass(element, pendingClassName);
+ if (staggerTimeout) {
+ $timeout.cancel(staggerTimeout);
+ }
animateClose(element, className);
var node = extractElementNode(element);
for (var i in appliedStyles) {
@@ -1493,44 +1971,44 @@ angular.module('ngAnimate', ['ng'])
* We're checking to see if the timeStamp surpasses the expected delay,
* but we're using elapsedTime instead of the timeStamp on the 2nd
* pre-condition since animations sometimes close off early */
- if(Math.max(timeStamp - startTime, 0) >= maxDelayTime && elapsedTime >= maxDuration) {
+ if (Math.max(timeStamp - startTime, 0) >= maxDelayTime && elapsedTime >= maxDuration) {
activeAnimationComplete();
}
}
}
- function prepareStaggerDelay(delayStyle, staggerDelay, index) {
- var style = '';
- forEach(delayStyle.split(','), function(val, i) {
- style += (i > 0 ? ',' : '') +
- (index * staggerDelay + parseInt(val, 10)) + 's';
- });
- return style;
+ function blockTransitions(node, bool) {
+ node.style[TRANSITION_PROP + PROPERTY_KEY] = bool ? 'none' : '';
}
- function animateBefore(animationEvent, element, className, calculationDecorator) {
- if(animateSetup(animationEvent, element, className, calculationDecorator)) {
+ function blockAnimations(node, bool) {
+ node.style[ANIMATION_PROP + ANIMATION_PLAYSTATE_KEY] = bool ? 'paused' : '';
+ }
+
+ function animateBefore(animationEvent, element, className, styles) {
+ if (animateSetup(animationEvent, element, className, styles)) {
return function(cancelled) {
cancelled && animateClose(element, className);
};
}
}
- function animateAfter(animationEvent, element, className, afterAnimationComplete) {
- if(element.data(NG_ANIMATE_CSS_DATA_KEY)) {
- return animateRun(animationEvent, element, className, afterAnimationComplete);
+ function animateAfter(animationEvent, element, className, afterAnimationComplete, styles) {
+ if (element.data(NG_ANIMATE_CSS_DATA_KEY)) {
+ return animateRun(animationEvent, element, className, afterAnimationComplete, styles);
} else {
animateClose(element, className);
afterAnimationComplete();
}
}
- function animate(animationEvent, element, className, animationComplete) {
+ function animate(animationEvent, element, className, animationComplete, options) {
//If the animateSetup function doesn't bother returning a
//cancellation function then it means that there is no animation
//to perform at all
- var preReflowCancellation = animateBefore(animationEvent, element, className);
- if(!preReflowCancellation) {
+ var preReflowCancellation = animateBefore(animationEvent, element, className, options.from);
+ if (!preReflowCancellation) {
+ clearCacheAfterReflow();
animationComplete();
return;
}
@@ -1542,12 +2020,10 @@ angular.module('ngAnimate', ['ng'])
//happen in the first place
var cancel = preReflowCancellation;
afterReflow(element, function() {
- unblockTransitions(element, className);
- unblockKeyframeAnimations(element);
//once the reflow is complete then we point cancel to
//the new cancellation function which will remove all of the
//animation properties from the active animation
- cancel = animateAfter(animationEvent, element, className, animationComplete);
+ cancel = animateAfter(animationEvent, element, className, animationComplete, options.to);
});
return function(cancelled) {
@@ -1556,127 +2032,100 @@ angular.module('ngAnimate', ['ng'])
}
function animateClose(element, className) {
- element.removeClass(className);
+ $$jqLite.removeClass(element, className);
var data = element.data(NG_ANIMATE_CSS_DATA_KEY);
- if(data) {
- if(data.running) {
+ if (data) {
+ if (data.running) {
data.running--;
}
- if(!data.running || data.running === 0) {
+ if (!data.running || data.running === 0) {
element.removeData(NG_ANIMATE_CSS_DATA_KEY);
}
}
}
return {
- enter : function(element, animationCompleted) {
- return animate('enter', element, 'ng-enter', animationCompleted);
+ animate: function(element, className, from, to, animationCompleted, options) {
+ options = options || {};
+ options.from = from;
+ options.to = to;
+ return animate('animate', element, className, animationCompleted, options);
},
- leave : function(element, animationCompleted) {
- return animate('leave', element, 'ng-leave', animationCompleted);
+ enter: function(element, animationCompleted, options) {
+ options = options || {};
+ return animate('enter', element, 'ng-enter', animationCompleted, options);
},
- move : function(element, animationCompleted) {
- return animate('move', element, 'ng-move', animationCompleted);
+ leave: function(element, animationCompleted, options) {
+ options = options || {};
+ return animate('leave', element, 'ng-leave', animationCompleted, options);
},
- beforeSetClass : function(element, add, remove, animationCompleted) {
+ move: function(element, animationCompleted, options) {
+ options = options || {};
+ return animate('move', element, 'ng-move', animationCompleted, options);
+ },
+
+ beforeSetClass: function(element, add, remove, animationCompleted, options) {
+ options = options || {};
var className = suffixClasses(remove, '-remove') + ' ' +
suffixClasses(add, '-add');
- var cancellationMethod = animateBefore('setClass', element, className, function(fn) {
- /* when classes are removed from an element then the transition style
- * that is applied is the transition defined on the element without the
- * CSS class being there. This is how CSS3 functions outside of ngAnimate.
- * http://plnkr.co/edit/j8OzgTNxHTb4n3zLyjGW?p=preview */
- var klass = element.attr('class');
- element.removeClass(remove);
- element.addClass(add);
- var timings = fn();
- element.attr('class', klass);
- return timings;
- });
-
- if(cancellationMethod) {
- afterReflow(element, function() {
- unblockTransitions(element, className);
- unblockKeyframeAnimations(element);
- animationCompleted();
- });
+ var cancellationMethod = animateBefore('setClass', element, className, options.from);
+ if (cancellationMethod) {
+ afterReflow(element, animationCompleted);
return cancellationMethod;
}
+ clearCacheAfterReflow();
animationCompleted();
},
- beforeAddClass : function(element, className, animationCompleted) {
- var cancellationMethod = animateBefore('addClass', element, suffixClasses(className, '-add'), function(fn) {
-
- /* when a CSS class is added to an element then the transition style that
- * is applied is the transition defined on the element when the CSS class
- * is added at the time of the animation. This is how CSS3 functions
- * outside of ngAnimate. */
- element.addClass(className);
- var timings = fn();
- element.removeClass(className);
- return timings;
- });
-
- if(cancellationMethod) {
- afterReflow(element, function() {
- unblockTransitions(element, className);
- unblockKeyframeAnimations(element);
- animationCompleted();
- });
+ beforeAddClass: function(element, className, animationCompleted, options) {
+ options = options || {};
+ var cancellationMethod = animateBefore('addClass', element, suffixClasses(className, '-add'), options.from);
+ if (cancellationMethod) {
+ afterReflow(element, animationCompleted);
return cancellationMethod;
}
+ clearCacheAfterReflow();
animationCompleted();
},
- setClass : function(element, add, remove, animationCompleted) {
+ beforeRemoveClass: function(element, className, animationCompleted, options) {
+ options = options || {};
+ var cancellationMethod = animateBefore('removeClass', element, suffixClasses(className, '-remove'), options.from);
+ if (cancellationMethod) {
+ afterReflow(element, animationCompleted);
+ return cancellationMethod;
+ }
+ clearCacheAfterReflow();
+ animationCompleted();
+ },
+
+ setClass: function(element, add, remove, animationCompleted, options) {
+ options = options || {};
remove = suffixClasses(remove, '-remove');
add = suffixClasses(add, '-add');
var className = remove + ' ' + add;
- return animateAfter('setClass', element, className, animationCompleted);
+ return animateAfter('setClass', element, className, animationCompleted, options.to);
},
- addClass : function(element, className, animationCompleted) {
- return animateAfter('addClass', element, suffixClasses(className, '-add'), animationCompleted);
+ addClass: function(element, className, animationCompleted, options) {
+ options = options || {};
+ return animateAfter('addClass', element, suffixClasses(className, '-add'), animationCompleted, options.to);
},
- beforeRemoveClass : function(element, className, animationCompleted) {
- var cancellationMethod = animateBefore('removeClass', element, suffixClasses(className, '-remove'), function(fn) {
- /* when classes are removed from an element then the transition style
- * that is applied is the transition defined on the element without the
- * CSS class being there. This is how CSS3 functions outside of ngAnimate.
- * http://plnkr.co/edit/j8OzgTNxHTb4n3zLyjGW?p=preview */
- var klass = element.attr('class');
- element.removeClass(className);
- var timings = fn();
- element.attr('class', klass);
- return timings;
- });
-
- if(cancellationMethod) {
- afterReflow(element, function() {
- unblockTransitions(element, className);
- unblockKeyframeAnimations(element);
- animationCompleted();
- });
- return cancellationMethod;
- }
- animationCompleted();
- },
-
- removeClass : function(element, className, animationCompleted) {
- return animateAfter('removeClass', element, suffixClasses(className, '-remove'), animationCompleted);
+ removeClass: function(element, className, animationCompleted, options) {
+ options = options || {};
+ return animateAfter('removeClass', element, suffixClasses(className, '-remove'), animationCompleted, options.to);
}
};
function suffixClasses(classes, suffix) {
var className = '';
- classes = angular.isArray(classes) ? classes : classes.split(/\s+/);
+ classes = isArray(classes) ? classes : classes.split(/\s+/);
forEach(classes, function(klass, i) {
- if(klass && klass.length > 0) {
+ if (klass && klass.length > 0) {
className += (i > 0 ? ' ' : '') + klass + suffix;
}
});
diff --git a/src/main/webapp/js/lib/angular-cookies.js b/src/main/webapp/js/lib/angular-cookies.js
index 122a215c2..fd0e73fdd 100644
--- a/src/main/webapp/js/lib/angular-cookies.js
+++ b/src/main/webapp/js/lib/angular-cookies.js
@@ -1,5 +1,5 @@
/**
- * @license AngularJS v1.3.0-build.3242+sha.6a96a82
+ * @license AngularJS v1.3.11
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
@@ -48,7 +48,7 @@ angular.module('ngCookies', ['ng']).
* }]);
* ```
*/
- factory('$cookies', ['$rootScope', '$browser', function ($rootScope, $browser) {
+ factory('$cookies', ['$rootScope', '$browser', function($rootScope, $browser) {
var cookies = {},
lastCookies = {},
lastBrowserCookies,
@@ -95,7 +95,7 @@ angular.module('ngCookies', ['ng']).
}
//update all cookies updated in $cookies
- for(name in cookies) {
+ for (name in cookies) {
value = cookies[name];
if (!angular.isString(value)) {
value = '' + value;
@@ -108,7 +108,7 @@ angular.module('ngCookies', ['ng']).
}
//verify what was actually stored
- if (updated){
+ if (updated) {
updated = false;
browserCookies = $browser.cookies();
diff --git a/src/main/webapp/js/lib/angular-file-upload-shim.js b/src/main/webapp/js/lib/angular-file-upload-shim.js
deleted file mode 100644
index 3623d76df..000000000
--- a/src/main/webapp/js/lib/angular-file-upload-shim.js
+++ /dev/null
@@ -1,366 +0,0 @@
-/**!
- * AngularJS file upload/drop directive with progress and abort
- * FileAPI Flash shim for old browsers not supporting FormData
- * @author Danial
- * @version <%= pkg.version %>
- */
-
-(function() {
-
-var hasFlash = function() {
- try {
- var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
- if (fo) return true;
- } catch(e) {
- if (navigator.mimeTypes['application/x-shockwave-flash'] != undefined) return true;
- }
- return false;
-}
-
-function patchXHR(fnName, newFn) {
- window.XMLHttpRequest.prototype[fnName] = newFn(window.XMLHttpRequest.prototype[fnName]);
-};
-
-if ((window.XMLHttpRequest && !window.FormData) || (window.FileAPI && FileAPI.forceLoad)) {
- var initializeUploadListener = function(xhr) {
- if (!xhr.__listeners) {
- if (!xhr.upload) xhr.upload = {};
- xhr.__listeners = [];
- var origAddEventListener = xhr.upload.addEventListener;
- xhr.upload.addEventListener = function(t, fn, b) {
- xhr.__listeners[t] = fn;
- origAddEventListener && origAddEventListener.apply(this, arguments);
- };
- }
- }
-
- patchXHR('open', function(orig) {
- return function(m, url, b) {
- initializeUploadListener(this);
- this.__url = url;
- try {
- orig.apply(this, [m, url, b]);
- } catch (e) {
- if (e.message.indexOf('Access is denied') > -1) {
- orig.apply(this, [m, '_fix_for_ie_crossdomain__', b]);
- }
- }
- }
- });
-
- patchXHR('getResponseHeader', function(orig) {
- return function(h) {
- return this.__fileApiXHR && this.__fileApiXHR.getResponseHeader ? this.__fileApiXHR.getResponseHeader(h) : (orig == null ? null : orig.apply(this, [h]));
- };
- });
-
- patchXHR('getAllResponseHeaders', function(orig) {
- return function() {
- return this.__fileApiXHR && this.__fileApiXHR.getAllResponseHeaders ? this.__fileApiXHR.getAllResponseHeaders() : (orig == null ? null : orig.apply(this));
- }
- });
-
- patchXHR('abort', function(orig) {
- return function() {
- return this.__fileApiXHR && this.__fileApiXHR.abort ? this.__fileApiXHR.abort() : (orig == null ? null : orig.apply(this));
- }
- });
-
- patchXHR('setRequestHeader', function(orig) {
- return function(header, value) {
- if (header === '__setXHR_') {
- initializeUploadListener(this);
- var val = value(this);
- // fix for angular < 1.2.0
- if (val instanceof Function) {
- val(this);
- }
- } else {
- this.__requestHeaders = this.__requestHeaders || {};
- this.__requestHeaders[header] = value;
- orig.apply(this, arguments);
- }
- }
- });
-
- function redefineProp(xhr, prop, fn) {
- try {
- Object.defineProperty(xhr, prop, {get: fn});
- } catch (e) {/*ignore*/}
- }
-
- patchXHR('send', function(orig) {
- return function() {
- var xhr = this;
- if (arguments[0] && arguments[0].__isFileAPIShim) {
- var formData = arguments[0];
- var config = {
- url: xhr.__url,
- jsonp: false, //removes the callback form param
- cache: true, //removes the ?fileapiXXX in the url
- complete: function(err, fileApiXHR) {
- xhr.__completed = true;
- if (!err && xhr.__listeners['load'])
- xhr.__listeners['load']({type: 'load', loaded: xhr.__loaded, total: xhr.__total, target: xhr, lengthComputable: true});
- if (!err && xhr.__listeners['loadend'])
- xhr.__listeners['loadend']({type: 'loadend', loaded: xhr.__loaded, total: xhr.__total, target: xhr, lengthComputable: true});
- if (err === 'abort' && xhr.__listeners['abort'])
- xhr.__listeners['abort']({type: 'abort', loaded: xhr.__loaded, total: xhr.__total, target: xhr, lengthComputable: true});
- if (fileApiXHR.status !== undefined) redefineProp(xhr, 'status', function() {return (fileApiXHR.status == 0 && err && err !== 'abort') ? 500 : fileApiXHR.status});
- if (fileApiXHR.statusText !== undefined) redefineProp(xhr, 'statusText', function() {return fileApiXHR.statusText});
- redefineProp(xhr, 'readyState', function() {return 4});
- if (fileApiXHR.response !== undefined) redefineProp(xhr, 'response', function() {return fileApiXHR.response});
- var resp = fileApiXHR.responseText || (err && fileApiXHR.status == 0 && err !== 'abort' ? err : undefined);
- redefineProp(xhr, 'responseText', function() {return resp});
- redefineProp(xhr, 'response', function() {return resp});
- if (err) redefineProp(xhr, 'err', function() {return err});
- xhr.__fileApiXHR = fileApiXHR;
- if (xhr.onreadystatechange) xhr.onreadystatechange();
- if (xhr.onload) xhr.onload();
- },
- fileprogress: function(e) {
- e.target = xhr;
- xhr.__listeners['progress'] && xhr.__listeners['progress'](e);
- xhr.__total = e.total;
- xhr.__loaded = e.loaded;
- if (e.total === e.loaded) {
- // fix flash issue that doesn't call complete if there is no response text from the server
- var _this = this
- setTimeout(function() {
- if (!xhr.__completed) {
- xhr.getAllResponseHeaders = function(){};
- _this.complete(null, {status: 204, statusText: 'No Content'});
- }
- }, 10000);
- }
- },
- headers: xhr.__requestHeaders
- }
- config.data = {};
- config.files = {}
- for (var i = 0; i < formData.data.length; i++) {
- var item = formData.data[i];
- if (item.val != null && item.val.name != null && item.val.size != null && item.val.type != null) {
- config.files[item.key] = item.val;
- } else {
- config.data[item.key] = item.val;
- }
- }
-
- setTimeout(function() {
- if (!hasFlash()) {
- throw 'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';
- }
- xhr.__fileApiXHR = FileAPI.upload(config);
- }, 1);
- } else {
- orig.apply(xhr, arguments);
- }
- }
- });
- window.XMLHttpRequest.__isFileAPIShim = true;
-
- var addFlash = function(elem) {
- if (!hasFlash()) {
- throw 'Adode Flash Player need to be installed. To check ahead use "FileAPI.hasFlash"';
- }
- var el = angular.element(elem);
- if (!el.attr('disabled')) {
- if (!el.hasClass('js-fileapi-wrapper') && (el.attr('ng-file-select') != null || el.attr('data-ng-file-select') != null ||
- (el.attr('ng-file-generated-elem') &&
- (el.parent().attr('ng-file-select') != null || el.parent().attr('data-ng-file-select') != null)))) {
- if (FileAPI.wrapInsideDiv) {
- var wrap = document.createElement('div');
- wrap.innerHTML = '';
- wrap = wrap.firstChild;
- var parent = elem.parentNode;
- parent.insertBefore(wrap, elem);
- parent.removeChild(elem);
- wrap.appendChild(elem);
- } else {
- el.addClass('js-fileapi-wrapper');
- if (el.attr('ng-file-generated-elem')) {
- if (el.parent().css('position') === '' || el.parent().css('position') === 'static') {
- el.parent().css('position', 'relative');
- }
- el.css('top', 0).css('bottom', 0).css('left', 0).css('right', 0).css('width', '100%').css('height', '100%').
- css('padding', 0).css('margin', 0);
- el.parent().unbind('click', el.parent().__afu_fileClickDelegate__);
- }
- }
- }
- }
- };
- var changeFnWrapper = function(fn) {
- return function(evt) {
- var files = FileAPI.getFiles(evt);
- //just a double check for #233
- for (var i = 0; i < files.length; i++) {
- if (files[i].size === undefined) files[i].size = 0;
- if (files[i].name === undefined) files[i].name = 'file';
- if (files[i].type === undefined) files[i].type = 'undefined';
- }
- if (!evt.target) {
- evt.target = {};
- }
- evt.target.files = files;
- // if evt.target.files is not writable use helper field
- if (evt.target.files != files) {
- evt.__files_ = files;
- }
- (evt.__files_ || evt.target.files).item = function(i) {
- return (evt.__files_ || evt.target.files)[i] || null;
- }
- if (fn) fn.apply(this, [evt]);
- };
- };
- var isFileChange = function(elem, e) {
- return (e.toLowerCase() === 'change' || e.toLowerCase() === 'onchange') && elem.getAttribute('type') == 'file';
- }
- if (HTMLInputElement.prototype.addEventListener) {
- HTMLInputElement.prototype.addEventListener = (function(origAddEventListener) {
- return function(e, fn, b, d) {
- if (isFileChange(this, e)) {
- addFlash(this);
- origAddEventListener.apply(this, [e, changeFnWrapper(fn), b, d]);
- } else {
- origAddEventListener.apply(this, [e, fn, b, d]);
- }
- }
- })(HTMLInputElement.prototype.addEventListener);
- }
- if (HTMLInputElement.prototype.attachEvent) {
- HTMLInputElement.prototype.attachEvent = (function(origAttachEvent) {
- return function(e, fn) {
- if (isFileChange(this, e)) {
- addFlash(this);
- if (window.jQuery) {
- // fix for #281 jQuery on IE8
- angular.element(this).bind('change', changeFnWrapper(null));
- } else {
- origAttachEvent.apply(this, [e, changeFnWrapper(fn)]);
- }
- } else {
- origAttachEvent.apply(this, [e, fn]);
- }
- }
- })(HTMLInputElement.prototype.attachEvent);
- }
-
- window.FormData = FormData = function() {
- return {
- append: function(key, val, name) {
- this.data.push({
- key: key,
- val: val,
- name: name
- });
- },
- data: [],
- __isFileAPIShim: true
- };
- };
-
- (function () {
- //load FileAPI
- if (!window.FileAPI) {
- window.FileAPI = {};
- }
- if (FileAPI.forceLoad) {
- FileAPI.html5 = false;
- }
-
- if (!FileAPI.upload) {
- var jsUrl, basePath, script = document.createElement('script'), allScripts = document.getElementsByTagName('script'), i, index, src;
- if (window.FileAPI.jsUrl) {
- jsUrl = window.FileAPI.jsUrl;
- } else if (window.FileAPI.jsPath) {
- basePath = window.FileAPI.jsPath;
- } else {
- for (i = 0; i < allScripts.length; i++) {
- src = allScripts[i].src;
- index = src.search(/\/angular\-file\-upload[\-a-zA-z0-9\.]*\.js/)
- if (index > -1) {
- basePath = src.substring(0, index + 1);
- break;
- }
- }
- }
-
- if (FileAPI.staticPath == null) FileAPI.staticPath = basePath;
- script.setAttribute('src', jsUrl || basePath + 'FileAPI.min.js');
- document.getElementsByTagName('head')[0].appendChild(script);
- FileAPI.hasFlash = hasFlash();
- }
- })();
- FileAPI.disableFileInput = function(elem, disable) {
- if (disable) {
- elem.removeClass('js-fileapi-wrapper')
- } else {
- elem.addClass('js-fileapi-wrapper');
- }
- }
-}
-
-
-if (!window.FileReader) {
- window.FileReader = function() {
- var _this = this, loadStarted = false;
- this.listeners = {};
- this.addEventListener = function(type, fn) {
- _this.listeners[type] = _this.listeners[type] || [];
- _this.listeners[type].push(fn);
- };
- this.removeEventListener = function(type, fn) {
- _this.listeners[type] && _this.listeners[type].splice(_this.listeners[type].indexOf(fn), 1);
- };
- this.dispatchEvent = function(evt) {
- var list = _this.listeners[evt.type];
- if (list) {
- for (var i = 0; i < list.length; i++) {
- list[i].call(_this, evt);
- }
- }
- };
- this.onabort = this.onerror = this.onload = this.onloadstart = this.onloadend = this.onprogress = null;
-
- var constructEvent = function(type, evt) {
- var e = {type: type, target: _this, loaded: evt.loaded, total: evt.total, error: evt.error};
- if (evt.result != null) e.target.result = evt.result;
- return e;
- };
- var listener = function(evt) {
- if (!loadStarted) {
- loadStarted = true;
- _this.onloadstart && this.onloadstart(constructEvent('loadstart', evt));
- }
- if (evt.type === 'load') {
- _this.onloadend && _this.onloadend(constructEvent('loadend', evt));
- var e = constructEvent('load', evt);
- _this.onload && _this.onload(e);
- _this.dispatchEvent(e);
- } else if (evt.type === 'progress') {
- var e = constructEvent('progress', evt);
- _this.onprogress && _this.onprogress(e);
- _this.dispatchEvent(e);
- } else {
- var e = constructEvent('error', evt);
- _this.onerror && _this.onerror(e);
- _this.dispatchEvent(e);
- }
- };
- this.readAsArrayBuffer = function(file) {
- FileAPI.readAsBinaryString(file, listener);
- }
- this.readAsBinaryString = function(file) {
- FileAPI.readAsBinaryString(file, listener);
- }
- this.readAsDataURL = function(file) {
- FileAPI.readAsDataURL(file, listener);
- }
- this.readAsText = function(file) {
- FileAPI.readAsText(file, listener);
- }
- }
-}
-})();
diff --git a/src/main/webapp/js/lib/angular-file-upload.js b/src/main/webapp/js/lib/angular-file-upload.js
deleted file mode 100644
index dfca6a700..000000000
--- a/src/main/webapp/js/lib/angular-file-upload.js
+++ /dev/null
@@ -1,483 +0,0 @@
-/**!
- * AngularJS file upload/drop directive with progress and abort
- * @author Danial
- * @version <%= pkg.version %>
- */
-(function() {
-
-function patchXHR(fnName, newFn) {
- window.XMLHttpRequest.prototype[fnName] = newFn(window.XMLHttpRequest.prototype[fnName]);
-}
-
-if (window.XMLHttpRequest && !window.XMLHttpRequest.__isFileAPIShim) {
- patchXHR('setRequestHeader', function(orig) {
- return function(header, value) {
- if (header === '__setXHR_') {
- var val = value(this);
- // fix for angular < 1.2.0
- if (val instanceof Function) {
- val(this);
- }
- } else {
- orig.apply(this, arguments);
- }
- }
- });
-}
-
-var angularFileUpload = angular.module('angularFileUpload', []);
-angularFileUpload.version = '<%= pkg.version %>';
-angularFileUpload.service('$upload', ['$http', '$q', '$timeout', function($http, $q, $timeout) {
- function sendHttp(config) {
- config.method = config.method || 'POST';
- config.headers = config.headers || {};
- config.transformRequest = config.transformRequest || function(data, headersGetter) {
- if (window.ArrayBuffer && data instanceof window.ArrayBuffer) {
- return data;
- }
- return $http.defaults.transformRequest[0](data, headersGetter);
- };
- var deferred = $q.defer();
- var promise = deferred.promise;
-
- config.headers['__setXHR_'] = function() {
- return function(xhr) {
- if (!xhr) return;
- config.__XHR = xhr;
- config.xhrFn && config.xhrFn(xhr);
- xhr.upload.addEventListener('progress', function(e) {
- e.config = config;
- deferred.notify ? deferred.notify(e) : promise.progress_fn && $timeout(function(){promise.progress_fn(e)});
- }, false);
- //fix for firefox not firing upload progress end, also IE8-9
- xhr.upload.addEventListener('load', function(e) {
- if (e.lengthComputable) {
- e.config = config;
- deferred.notify ? deferred.notify(e) : promise.progress_fn && $timeout(function(){promise.progress_fn(e)});
- }
- }, false);
- };
- };
-
- $http(config).then(function(r){deferred.resolve(r)}, function(e){deferred.reject(e)}, function(n){deferred.notify(n)});
-
- promise.success = function(fn) {
- promise.then(function(response) {
- fn(response.data, response.status, response.headers, config);
- });
- return promise;
- };
-
- promise.error = function(fn) {
- promise.then(null, function(response) {
- fn(response.data, response.status, response.headers, config);
- });
- return promise;
- };
-
- promise.progress = function(fn) {
- promise.progress_fn = fn;
- promise.then(null, null, function(update) {
- fn(update);
- });
- return promise;
- };
- promise.abort = function() {
- if (config.__XHR) {
- $timeout(function() {
- config.__XHR.abort();
- });
- }
- return promise;
- };
- promise.xhr = function(fn) {
- config.xhrFn = (function(origXhrFn) {
- return function() {
- origXhrFn && origXhrFn.apply(promise, arguments);
- fn.apply(promise, arguments);
- }
- })(config.xhrFn);
- return promise;
- };
-
- return promise;
- }
-
- this.upload = function(config) {
- config.headers = config.headers || {};
- config.headers['Content-Type'] = undefined;
- config.transformRequest = config.transformRequest || $http.defaults.transformRequest;
- var formData = new FormData();
- var origTransformRequest = config.transformRequest;
- var origData = config.data;
- config.transformRequest = function(formData, headerGetter) {
- if (origData) {
- if (config.formDataAppender) {
- for (var key in origData) {
- var val = origData[key];
- config.formDataAppender(formData, key, val);
- }
- } else {
- for (var key in origData) {
- var val = origData[key];
- if (typeof origTransformRequest == 'function') {
- val = origTransformRequest(val, headerGetter);
- } else {
- for (var i = 0; i < origTransformRequest.length; i++) {
- var transformFn = origTransformRequest[i];
- if (typeof transformFn == 'function') {
- val = transformFn(val, headerGetter);
- }
- }
- }
- if (val != undefined) formData.append(key, val);
- }
- }
- }
-
- if (config.file != null) {
- var fileFormName = config.fileFormDataName || 'file';
-
- if (Object.prototype.toString.call(config.file) === '[object Array]') {
- var isFileFormNameString = Object.prototype.toString.call(fileFormName) === '[object String]';
- for (var i = 0; i < config.file.length; i++) {
- formData.append(isFileFormNameString ? fileFormName : fileFormName[i], config.file[i],
- (config.fileName && config.fileName[i]) || config.file[i].name);
- }
- } else {
- formData.append(fileFormName, config.file, config.fileName || config.file.name);
- }
- }
- return formData;
- };
-
- config.data = formData;
-
- return sendHttp(config);
- };
-
- this.http = function(config) {
- return sendHttp(config);
- };
-}]);
-
-angularFileUpload.directive('ngFileSelect', [ '$parse', '$timeout', function($parse, $timeout) { return {
- restrict: 'AEC',
- require:'?ngModel',
- scope: {
- fileModel: '=ngModel',
- change: '&ngFileChange',
- select : '&ngFileSelect',
- resetOnClick: '&resetOnClick',
- multiple: '&ngMultiple',
- accept: '&ngAccept'
- },
- link: function(scope, elem, attr, ngModel) {
- handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout);
- }
-}}]);
-
-function handleFileSelect(scope, elem, attr, ngModel, $parse, $timeout) {
- if (scope.multiple()) {
- elem.attr('multiple', 'true');
- attr['multiple'] = 'true';
- }
- var accept = scope.accept();
- if (accept) {
- elem.attr('accept', accept);
- attr['accept'] = accept;
- }
- if (elem[0].tagName.toLowerCase() !== 'input' || (elem.attr('type') && elem.attr('type').toLowerCase()) !== 'file') {
- var fileElem = angular.element('')
- if (attr['multiple']) fileElem.attr('multiple', attr['multiple']);
- if (attr['accept']) fileElem.attr('accept', attr['accept']);
- fileElem.css('width', '1px').css('height', '1px').css('opacity', 0).css('position', 'absolute').css('filter', 'alpha(opacity=0)')
- .css('padding', 0).css('margin', 0).css('overflow', 'hidden').attr('tabindex', '-1').attr('ng-file-generated-elem', true);
- elem.append(fileElem);
- elem.__afu_fileClickDelegate__ = function() {
- fileElem[0].click();
- };
- elem.bind('click', elem.__afu_fileClickDelegate__);
- elem.css('overflow', 'hidden');
- elem = fileElem;
- }
- if (scope.resetOnClick() != false) {
- elem.bind('click', function(evt) {
- if (elem[0].value) {
- updateModel([], attr, ngModel, scope, evt);
- }
- elem[0].value = null;
- });
- }
- if (ngModel) {
- scope.$parent.$watch(attr['ngModel'], function(val) {
- if (val == null) {
- elem[0].value = null;
- }
- });
- }
- if (attr['ngFileSelect'] != '') {
- scope.change = scope.select;
- }
- elem.bind('change', function(evt) {
- var files = [], fileList, i;
- fileList = evt.__files_ || evt.target.files;
- updateModel(fileList, attr, ngModel, scope, evt);
- });
-
- function updateModel(fileList, attr, ngModel, scope, evt) {
- $timeout(function() {
- var files = [];
- for (var i = 0; i < fileList.length; i++) {
- files.push(fileList.item(i));
- }
- if (ngModel) {
- scope.fileModel = files;
- ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
- }
- $timeout(function() {
- scope.change({
- $files : files,
- $event : evt
- });
- });
- });
- }
-}
-
-angularFileUpload.directive('ngFileDrop', [ '$parse', '$timeout', '$location', function($parse, $timeout, $location) { return {
- restrict: 'AEC',
- require:'?ngModel',
- scope: {
- fileModel: '=ngModel',
- fileRejectedModel: '=ngFileRejectedModel',
- change: '&ngFileChange',
- drop: '&ngFileDrop',
- allowDir: '&allowDir',
- dragOverClass: '&dragOverClass',
- dropAvailable: '=dropAvailable',
- stopPropagation: '&stopPropagation',
- hideOnDropNotAvailable: '&hideOnDropNotAvailable',
- multiple: '&ngMultiple',
- accept: '&ngAccept'
- },
- link: function(scope, elem, attr, ngModel) {
- handleDrop(scope, elem, attr, ngModel, $parse, $timeout, $location);
- }
-}}]);
-
-angularFileUpload.directive('ngNoFileDrop', function() {
- return function(scope, elem, attr) {
- if (dropAvailable()) elem.css('display', 'none')
- }
-});
-
-//for backward compatibility
-angularFileUpload.directive('ngFileDropAvailable', [ '$parse', '$timeout', function($parse, $timeout) {
- return function(scope, elem, attr) {
- if (dropAvailable()) {
- var fn = $parse(attr['ngFileDropAvailable']);
- $timeout(function() {
- fn(scope);
- });
- }
- }
-}]);
-
-function handleDrop(scope, elem, attr, ngModel, $parse, $timeout, $location) {
- var available = dropAvailable();
- if (attr['dropAvailable']) {
- $timeout(function() {
- scope.dropAvailable = available;
- });
- }
- if (!available) {
- if (scope.hideOnDropNotAvailable() != false) {
- elem.css('display', 'none');
- }
- return;
- }
- var leaveTimeout = null;
- var stopPropagation = scope.stopPropagation();
- var dragOverDelay = 1;
- var accept = scope.accept() || attr['accept'] || attr['ngAccept'];
- var regexp = accept ? new RegExp(globStringToRegex(accept)) : null;
- elem[0].addEventListener('dragover', function(evt) {
- evt.preventDefault();
- if (stopPropagation) evt.stopPropagation();
- $timeout.cancel(leaveTimeout);
- if (!scope.actualDragOverClass) {
- scope.actualDragOverClass = calculateDragOverClass(scope, attr, evt);
- }
- elem.addClass(scope.actualDragOverClass);
- }, false);
- elem[0].addEventListener('dragenter', function(evt) {
- evt.preventDefault();
- if (stopPropagation) evt.stopPropagation();
- }, false);
- elem[0].addEventListener('dragleave', function(evt) {
- leaveTimeout = $timeout(function() {
- elem.removeClass(scope.actualDragOverClass);
- scope.actualDragOverClass = null;
- }, dragOverDelay || 1);
- }, false);
- if (attr['ngFileDrop'] != '') {
- scope.change = scope.drop;
- }
- elem[0].addEventListener('drop', function(evt) {
- evt.preventDefault();
- if (stopPropagation) evt.stopPropagation();
- elem.removeClass(scope.actualDragOverClass);
- scope.actualDragOverClass = null;
- extractFiles(evt, function(files, rejFiles) {
- if (ngModel) {
- scope.fileModel = files;
- ngModel && ngModel.$setViewValue(files != null && files.length == 0 ? '' : files);
- }
- if (attr['ngFileRejectedModel']) scope.fileRejectedModel = rejFiles;
- $timeout(function(){
- scope.change({
- $files : files,
- $rejectedFiles: rejFiles,
- $event : evt
- });
- });
- }, scope.allowDir() != false, attr['multiple'] || scope.multiple() || attr['ngMultiple'] == 'true');
- }, false);
-
- function calculateDragOverClass(scope, attr, evt) {
- var valid = true;
- if (regexp) {
- var items = evt.dataTransfer.items;
- if (items != null) {
- for (var i = 0 ; i < items.length && valid; i++) {
- valid = valid && (items[i].kind == 'file' || items[i].kind == '') &&
- (items[i].type.match(regexp) != null || (items[i].name != null && items[i].name.match(regexp) != null));
- }
- }
- }
- var clazz = scope.dragOverClass({$event : evt});
- if (clazz) {
- if (clazz.delay) dragOverDelay = clazz.delay;
- if (clazz.accept) clazz = valid ? clazz.accept : clazz.reject;
- }
- return clazz || attr['dragOverClass'] || 'dragover';
- }
-
- function extractFiles(evt, callback, allowDir, multiple) {
- var files = [], rejFiles = [], items = evt.dataTransfer.items;
-
- function addFile(file) {
- if (!regexp || file.type.match(regexp) || (file.name != null && file.name.match(regexp))) {
- files.push(file);
- } else {
- rejFiles.push(file);
- }
- }
-
- if (items && items.length > 0 && $location.protocol() != 'file') {
- for (var i = 0; i < items.length; i++) {
- if (items[i].webkitGetAsEntry && items[i].webkitGetAsEntry() && items[i].webkitGetAsEntry().isDirectory) {
- var entry = items[i].webkitGetAsEntry();
- if (entry.isDirectory && !allowDir) {
- continue;
- }
- if (entry != null) {
- //fix for chrome bug https://code.google.com/p/chromium/issues/detail?id=149735
- if (isASCII(entry.name)) {
- traverseFileTree(files, entry);
- } else if (!items[i].webkitGetAsEntry().isDirectory) {
- addFile(items[i].getAsFile());
- }
- }
- } else {
- var f = items[i].getAsFile();
- if (f != null) addFile(f);
- }
- if (!multiple && files.length > 0) break;
- }
- } else {
- var fileList = evt.dataTransfer.files;
- if (fileList != null) {
- for (var i = 0; i < fileList.length; i++) {
- addFile(fileList.item(i));
- if (!multiple && files.length > 0) break;
- }
- }
- }
- var delays = 0;
- (function waitForProcess(delay) {
- $timeout(function() {
- if (!processing) {
- if (!multiple && files.length > 1) {
- var i = 0;
- while (files[i].type == 'directory') i++;
- files = [files[i]];
- }
- callback(files, rejFiles);
- } else {
- if (delays++ * 10 < 20 * 1000) {
- waitForProcess(10);
- }
- }
- }, delay || 0)
- })();
-
- var processing = 0;
- function traverseFileTree(files, entry, path) {
- if (entry != null) {
- if (entry.isDirectory) {
- addFile({name: entry.name, type: 'directory', path: (path ? path : '') + entry.name});
- var dirReader = entry.createReader();
- processing++;
- dirReader.readEntries(function(entries) {
- try {
- for (var i = 0; i < entries.length; i++) {
- traverseFileTree(files, entries[i], (path ? path : '') + entry.name + '/');
- }
- } finally {
- processing--;
- }
- });
- } else {
- processing++;
- entry.file(function(file) {
- processing--;
- file.path = (path ? path : '') + file.name;
- addFile(file);
- });
- }
- }
- }
- }
-}
-
-function dropAvailable() {
- var div = document.createElement('div');
- return ('draggable' in div) && ('ondrop' in div);
-}
-
-function isASCII(str) {
- return /^[\000-\177]*$/.test(str);
-}
-
-function globStringToRegex(str) {
- if (str.length > 2 && str[0] === '/' && str[str.length -1] === '/') {
- return str.substring(1, str.length - 1);
- }
- var split = str.split(','), result = '';
- if (split.length > 1) {
- for (var i = 0; i < split.length; i++) {
- result += '(' + globStringToRegex(split[i]) + ')';
- if (i < split.length - 1) {
- result += '|'
- }
- }
- } else {
- result = '^' + str.replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + '-]', 'g'), '\\$&') + '$';
- result = result.replace(/\\\*/g, '.*').replace(/\\\?/g, '.');
- }
- return result;
-}
-
-})();
diff --git a/src/main/webapp/js/lib/angular-mocks.js b/src/main/webapp/js/lib/angular-mocks.js
index ecbb22bcf..2a411cc38 100644
--- a/src/main/webapp/js/lib/angular-mocks.js
+++ b/src/main/webapp/js/lib/angular-mocks.js
@@ -1,5 +1,5 @@
/**
- * @license AngularJS v1.3.0
+ * @license AngularJS v1.3.11
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
@@ -74,7 +74,7 @@ angular.mock.$Browser = function() {
self.defer = function(fn, delay) {
delay = delay || 0;
self.deferredFns.push({time:(self.defer.now + delay), fn:fn, id: self.deferredNextId});
- self.deferredFns.sort(function(a,b){ return a.time - b.time;});
+ self.deferredFns.sort(function(a, b) { return a.time - b.time;});
return self.deferredNextId++;
};
@@ -117,7 +117,7 @@ angular.mock.$Browser = function() {
self.defer.now += delay;
} else {
if (self.deferredFns.length) {
- self.defer.now = self.deferredFns[self.deferredFns.length-1].time;
+ self.defer.now = self.deferredFns[self.deferredFns.length - 1].time;
} else {
throw new Error('No deferred tasks to be flushed');
}
@@ -142,7 +142,7 @@ angular.mock.$Browser.prototype = {
* run all fns in pollFns
*/
poll: function poll() {
- angular.forEach(this.pollFns, function(pollFn){
+ angular.forEach(this.pollFns, function(pollFn) {
pollFn();
});
},
@@ -250,31 +250,31 @@ angular.mock.$ExceptionHandlerProvider = function() {
*
* @param {string} mode Mode of operation, defaults to `rethrow`.
*
- * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there
- * is a bug in the application or test, so this mock will make these tests fail.
* - `log`: Sometimes it is desirable to test that an error is thrown, for this case the `log`
* mode stores an array of errors in `$exceptionHandler.errors`, to allow later
* assertion of them. See {@link ngMock.$log#assertEmpty assertEmpty()} and
* {@link ngMock.$log#reset reset()}
+ * - `rethrow`: If any errors are passed to the handler in tests, it typically means that there
+ * is a bug in the application or test, so this mock will make these tests fail.
+ * For any implementations that expect exceptions to be thrown, the `rethrow` mode
+ * will also maintain a log of thrown errors.
*/
this.mode = function(mode) {
- switch(mode) {
- case 'rethrow':
- handler = function(e) {
- throw e;
- };
- break;
- case 'log':
- var errors = [];
+ switch (mode) {
+ case 'log':
+ case 'rethrow':
+ var errors = [];
handler = function(e) {
if (arguments.length == 1) {
errors.push(e);
} else {
errors.push([].slice.call(arguments, 0));
}
+ if (mode === "rethrow") {
+ throw e;
+ }
};
-
handler.errors = errors;
break;
default:
@@ -316,7 +316,7 @@ angular.mock.$LogProvider = function() {
}
};
- this.$get = function () {
+ this.$get = function() {
var $log = {
log: function() { $log.log.logs.push(concat([], arguments, 0)); },
warn: function() { $log.warn.logs.push(concat([], arguments, 0)); },
@@ -336,7 +336,7 @@ angular.mock.$LogProvider = function() {
* @description
* Reset all of the logging arrays to empty.
*/
- $log.reset = function () {
+ $log.reset = function() {
/**
* @ngdoc property
* @name $log#log.logs
@@ -421,14 +421,14 @@ angular.mock.$LogProvider = function() {
var errors = [];
angular.forEach(['error', 'warn', 'info', 'log', 'debug'], function(logLevel) {
angular.forEach($log[logLevel].logs, function(log) {
- angular.forEach(log, function (logItem) {
+ angular.forEach(log, function(logItem) {
errors.push('MOCK $log (' + logLevel + '): ' + String(logItem) + '\n' +
(logItem.stack || ''));
});
});
});
if (errors.length) {
- errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or "+
+ errors.unshift("Expected $log to be empty! Either a message was logged unexpectedly, or " +
"an expected log message was not checked and removed:");
errors.push('');
throw new Error(errors.join('\n---------\n'));
@@ -461,17 +461,17 @@ angular.mock.$LogProvider = function() {
* @returns {promise} A promise which will be notified on each iteration.
*/
angular.mock.$IntervalProvider = function() {
- this.$get = ['$rootScope', '$q',
- function($rootScope, $q) {
+ this.$get = ['$browser', '$rootScope', '$q', '$$q',
+ function($browser, $rootScope, $q, $$q) {
var repeatFns = [],
nextRepeatId = 0,
now = 0;
var $interval = function(fn, delay, count, invokeApply) {
- var deferred = $q.defer(),
- promise = deferred.promise,
- iteration = 0,
- skipApply = (angular.isDefined(invokeApply) && !invokeApply);
+ var iteration = 0,
+ skipApply = (angular.isDefined(invokeApply) && !invokeApply),
+ deferred = (skipApply ? $$q : $q).defer(),
+ promise = deferred.promise;
count = (angular.isDefined(count)) ? count : 0;
promise.then(null, null, fn);
@@ -494,7 +494,11 @@ angular.mock.$IntervalProvider = function() {
}
}
- if (!skipApply) $rootScope.$apply();
+ if (skipApply) {
+ $browser.defer.flush();
+ } else {
+ $rootScope.$apply();
+ }
}
repeatFns.push({
@@ -504,7 +508,7 @@ angular.mock.$IntervalProvider = function() {
id: nextRepeatId,
deferred: deferred
});
- repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;});
+ repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;});
nextRepeatId++;
return promise;
@@ -520,7 +524,7 @@ angular.mock.$IntervalProvider = function() {
* @returns {boolean} Returns `true` if the task was successfully cancelled.
*/
$interval.cancel = function(promise) {
- if(!promise) return false;
+ if (!promise) return false;
var fnIndex;
angular.forEach(repeatFns, function(fn, index) {
@@ -553,7 +557,7 @@ angular.mock.$IntervalProvider = function() {
var task = repeatFns[0];
task.fn();
task.nextTime += task.delay;
- repeatFns.sort(function(a,b){ return a.nextTime - b.nextTime;});
+ repeatFns.sort(function(a, b) { return a.nextTime - b.nextTime;});
}
return millis;
};
@@ -581,10 +585,10 @@ function jsonStringToDate(string) {
tzMin = int(match[9] + match[11]);
}
date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3]));
- date.setUTCHours(int(match[4]||0) - tzHour,
- int(match[5]||0) - tzMin,
- int(match[6]||0),
- int(match[7]||0));
+ date.setUTCHours(int(match[4] || 0) - tzHour,
+ int(match[5] || 0) - tzMin,
+ int(match[6] || 0),
+ int(match[7] || 0));
return date;
}
return string;
@@ -601,7 +605,7 @@ function padNumber(num, digits, trim) {
num = -num;
}
num = '' + num;
- while(num.length < digits) num = '0' + num;
+ while (num.length < digits) num = '0' + num;
if (trim)
num = num.substr(num.length - digits);
return neg + num;
@@ -645,7 +649,7 @@ function padNumber(num, digits, trim) {
* ```
*
*/
-angular.mock.TzDate = function (offset, timestamp) {
+angular.mock.TzDate = function(offset, timestamp) {
var self = new Date(0);
if (angular.isString(timestamp)) {
var tsStr = timestamp;
@@ -663,7 +667,7 @@ angular.mock.TzDate = function (offset, timestamp) {
}
var localOffset = new Date(timestamp).getTimezoneOffset();
- self.offsetDiff = localOffset*60*1000 - offset*1000*60*60;
+ self.offsetDiff = localOffset * 60 * 1000 - offset * 1000 * 60 * 60;
self.date = new Date(timestamp + self.offsetDiff);
self.getTime = function() {
@@ -788,20 +792,20 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
$provide.decorator('$animate', ['$delegate', '$$asyncCallback', '$timeout', '$browser',
function($delegate, $$asyncCallback, $timeout, $browser) {
var animate = {
- queue : [],
- cancel : $delegate.cancel,
- enabled : $delegate.enabled,
- triggerCallbackEvents : function() {
+ queue: [],
+ cancel: $delegate.cancel,
+ enabled: $delegate.enabled,
+ triggerCallbackEvents: function() {
$$asyncCallback.flush();
},
- triggerCallbackPromise : function() {
+ triggerCallbackPromise: function() {
$timeout.flush(0);
},
- triggerCallbacks : function() {
+ triggerCallbacks: function() {
this.triggerCallbackEvents();
this.triggerCallbackPromise();
},
- triggerReflow : function() {
+ triggerReflow: function() {
angular.forEach(reflowQueue, function(fn) {
fn();
});
@@ -813,10 +817,10 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
['animate','enter','leave','move','addClass','removeClass','setClass'], function(method) {
animate[method] = function() {
animate.queue.push({
- event : method,
- element : arguments[0],
- options : arguments[arguments.length-1],
- args : arguments
+ event: method,
+ element: arguments[0],
+ options: arguments[arguments.length - 1],
+ args: arguments
});
return $delegate[method].apply($delegate, arguments);
};
@@ -883,13 +887,13 @@ angular.mock.dump = function(object) {
function serializeScope(scope, offset) {
offset = offset || ' ';
var log = [offset + 'Scope(' + scope.$id + '): {'];
- for ( var key in scope ) {
+ for (var key in scope) {
if (Object.prototype.hasOwnProperty.call(scope, key) && !key.match(/^(\$|this)/)) {
log.push(' ' + key + ': ' + angular.toJson(scope[key]));
}
}
var child = scope.$$childHead;
- while(child) {
+ while (child) {
log.push(serializeScope(child, offset + ' '));
child = child.$$nextSibling;
}
@@ -1115,7 +1119,7 @@ angular.mock.dump = function(object) {
```
*/
angular.mock.$HttpBackendProvider = function() {
- this.$get = ['$rootScope', createHttpBackendMock];
+ this.$get = ['$rootScope', '$timeout', createHttpBackendMock];
};
/**
@@ -1132,7 +1136,7 @@ angular.mock.$HttpBackendProvider = function() {
* @param {Object=} $browser Auto-flushing enabled if specified
* @return {Object} Instance of $httpBackend mock
*/
-function createHttpBackendMock($rootScope, $delegate, $browser) {
+function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
var definitions = [],
expectations = [],
responses = [],
@@ -1145,7 +1149,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
return function() {
return angular.isNumber(status)
? [status, data, headers, statusText]
- : [200, status, data];
+ : [200, status, data, headers];
};
}
@@ -1162,7 +1166,9 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
}
function wrapResponse(wrapped) {
- if (!$browser && timeout && timeout.then) timeout.then(handleTimeout);
+ if (!$browser && timeout) {
+ timeout.then ? timeout.then(handleTimeout) : $timeout(handleTimeout, timeout);
+ }
return handleResponse;
@@ -1277,7 +1283,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1291,7 +1297,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1305,7 +1311,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1321,7 +1327,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
* data string and returns true if the data is as expected.
* @param {(Object|function(Object))=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1337,7 +1343,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
* data string and returns true if the data is as expected.
* @param {(Object|function(Object))=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1350,7 +1356,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
*
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1371,7 +1377,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* is in JSON format.
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
* object and returns true if the headers match the current expectation.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*
@@ -1386,7 +1392,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
$httpBackend.expect = function(method, url, data, headers) {
var expectation = new MockHttpExpectation(method, url, data, headers),
chain = {
- respond: function (status, data, headers, statusText) {
+ respond: function(status, data, headers, statusText) {
expectation.response = createResponse(status, data, headers, statusText);
return chain;
}
@@ -1406,7 +1412,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
* @param {Object=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled. See #expect for more info.
*/
@@ -1420,7 +1426,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
* @param {Object=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1434,7 +1440,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
* @param {Object=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1451,7 +1457,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* receives data string and returns true if the data is as expected, or Object if request body
* is in JSON format.
* @param {Object=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1468,7 +1474,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* receives data string and returns true if the data is as expected, or Object if request body
* is in JSON format.
* @param {Object=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1485,7 +1491,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
* receives data string and returns true if the data is as expected, or Object if request body
* is in JSON format.
* @param {Object=} headers HTTP headers.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1498,7 +1504,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
*
* @param {string|RegExp|function(string)} url HTTP url or function that receives the url
* and returns true if the url match the current definition.
- * @returns {requestHandler} Returns an object with `respond` method that control how a matched
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
@@ -1636,7 +1642,9 @@ function MockHttpExpectation(method, url, data, headers) {
if (angular.isUndefined(data)) return true;
if (data && angular.isFunction(data.test)) return data.test(d);
if (data && angular.isFunction(data)) return data(d);
- if (data && !angular.isString(data)) return angular.equals(data, angular.fromJson(d));
+ if (data && !angular.isString(data)) {
+ return angular.equals(angular.fromJson(angular.toJson(data)), angular.fromJson(d));
+ }
return data == d;
};
@@ -1709,7 +1717,7 @@ function MockXhr() {
* that adds a "flush" and "verifyNoPendingTasks" methods.
*/
-angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function ($delegate, $browser) {
+angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $browser) {
/**
* @ngdoc method
@@ -1763,12 +1771,12 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
rafFn.supported = $delegate.supported;
rafFn.flush = function() {
- if(queue.length === 0) {
+ if (queue.length === 0) {
throw new Error('No rAF callbacks present');
}
var length = queue.length;
- for(var i=0;i
+ *
+ * See {@link ngResource.$resource `$resource`} for usage.
+ */
+
+/**
+ * @ngdoc service
+ * @name $resource
+ * @requires $http
+ *
+ * @description
+ * A factory which creates a resource object that lets you interact with
+ * [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer) server-side data sources.
+ *
+ * The returned resource object has action methods which provide high-level behaviors without
+ * the need to interact with the low level {@link ng.$http $http} service.
+ *
+ * Requires the {@link ngResource `ngResource`} module to be installed.
+ *
+ * By default, trailing slashes will be stripped from the calculated URLs,
+ * which can pose problems with server backends that do not expect that
+ * behavior. This can be disabled by configuring the `$resourceProvider` like
+ * this:
+ *
+ * ```js
+ app.config(['$resourceProvider', function($resourceProvider) {
+ // Don't strip trailing slashes from calculated URLs
+ $resourceProvider.defaults.stripTrailingSlashes = false;
+ }]);
+ * ```
+ *
+ * @param {string} url A parametrized URL template with parameters prefixed by `:` as in
+ * `/user/:username`. If you are using a URL with a port number (e.g.
+ * `http://example.com:8080/api`), it will be respected.
+ *
+ * If you are using a url with a suffix, just add the suffix, like this:
+ * `$resource('http://example.com/resource.json')` or `$resource('http://example.com/:id.json')`
+ * or even `$resource('http://example.com/resource/:resource_id.:format')`
+ * If the parameter before the suffix is empty, :resource_id in this case, then the `/.` will be
+ * collapsed down to a single `.`. If you need this sequence to appear and not collapse then you
+ * can escape it with `/\.`.
+ *
+ * @param {Object=} paramDefaults Default values for `url` parameters. These can be overridden in
+ * `actions` methods. If any of the parameter value is a function, it will be executed every time
+ * when a param value needs to be obtained for a request (unless the param was overridden).
+ *
+ * Each key value in the parameter object is first bound to url template if present and then any
+ * excess keys are appended to the url search query after the `?`.
+ *
+ * Given a template `/path/:verb` and parameter `{verb:'greet', salutation:'Hello'}` results in
+ * URL `/path/greet?salutation=Hello`.
+ *
+ * If the parameter value is prefixed with `@` then the value for that parameter will be extracted
+ * from the corresponding property on the `data` object (provided when calling an action method). For
+ * example, if the `defaultParam` object is `{someParam: '@someProp'}` then the value of `someParam`
+ * will be `data.someProp`.
+ *
+ * @param {Object.