rails-angularjs 1.3.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +22 -0
- data/README.md +37 -0
- data/lib/rails-angularjs.rb +9 -0
- data/lib/rails-angularjs/engine.rb +4 -0
- data/lib/rails-angularjs/sprockets.rb +3 -0
- data/lib/rails-angularjs/version.rb +4 -0
- data/vendor/assets/javascripts/angularjs/angular-animate.js +2137 -0
- data/vendor/assets/javascripts/angularjs/angular-animate.min.js +33 -0
- data/vendor/assets/javascripts/angularjs/angular-aria.js +339 -0
- data/vendor/assets/javascripts/angularjs/angular-aria.min.js +12 -0
- data/vendor/assets/javascripts/angularjs/angular-cookies.js +206 -0
- data/vendor/assets/javascripts/angularjs/angular-cookies.min.js +8 -0
- data/vendor/assets/javascripts/angularjs/angular-loader.js +405 -0
- data/vendor/assets/javascripts/angularjs/angular-loader.min.js +9 -0
- data/vendor/assets/javascripts/angularjs/angular-messages.js +400 -0
- data/vendor/assets/javascripts/angularjs/angular-messages.min.js +10 -0
- data/vendor/assets/javascripts/angularjs/angular-mocks.js +2396 -0
- data/vendor/assets/javascripts/angularjs/angular-resource.js +667 -0
- data/vendor/assets/javascripts/angularjs/angular-resource.min.js +13 -0
- data/vendor/assets/javascripts/angularjs/angular-route.js +989 -0
- data/vendor/assets/javascripts/angularjs/angular-route.min.js +15 -0
- data/vendor/assets/javascripts/angularjs/angular-sanitize.js +680 -0
- data/vendor/assets/javascripts/angularjs/angular-sanitize.min.js +16 -0
- data/vendor/assets/javascripts/angularjs/angular-scenario.js +37499 -0
- data/vendor/assets/javascripts/angularjs/angular-touch.js +622 -0
- data/vendor/assets/javascripts/angularjs/angular-touch.min.js +13 -0
- data/vendor/assets/javascripts/angularjs/angular.js +26130 -0
- data/vendor/assets/javascripts/angularjs/angular.min.js +250 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-animate.js +2137 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-animate.min.js +33 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-aria.js +339 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-aria.min.js +12 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-cookies.js +206 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-cookies.min.js +8 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-loader.js +410 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-loader.min.js +9 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-messages.js +400 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-messages.min.js +10 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-mocks.js +2400 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-resource.js +667 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-resource.min.js +13 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-route.js +989 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-route.min.js +15 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-sanitize.js +682 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-sanitize.min.js +16 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-scenario.js +38463 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-touch.js +622 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular-touch.min.js +13 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular.js +27088 -0
- data/vendor/assets/javascripts/angularjs/unstable/angular.min.js +281 -0
- metadata +140 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
/*
|
2
|
+
AngularJS v1.3.12
|
3
|
+
(c) 2010-2014 Google, Inc. http://angularjs.org
|
4
|
+
License: MIT
|
5
|
+
*/
|
6
|
+
(function(N,f,W){'use strict';f.module("ngAnimate",["ng"]).directive("ngAnimateChildren",function(){return function(X,C,g){g=g.ngAnimateChildren;f.isString(g)&&0===g.length?C.data("$$ngAnimateChildren",!0):X.$watch(g,function(f){C.data("$$ngAnimateChildren",!!f)})}}).factory("$$animateReflow",["$$rAF","$document",function(f,C){return function(g){return f(function(){g()})}}]).config(["$provide","$animateProvider",function(X,C){function g(f){for(var n=0;n<f.length;n++){var g=f[n];if(1==g.nodeType)return g}}
|
7
|
+
function ba(f,n){return g(f)==g(n)}var t=f.noop,n=f.forEach,da=C.$$selectors,aa=f.isArray,ea=f.isString,ga=f.isObject,r={running:!0},u;X.decorator("$animate",["$delegate","$$q","$injector","$sniffer","$rootElement","$$asyncCallback","$rootScope","$document","$templateRequest","$$jqLite",function(O,N,M,Y,y,H,P,W,Z,Q){function R(a,c){var b=a.data("$$ngAnimateState")||{};c&&(b.running=!0,b.structural=!0,a.data("$$ngAnimateState",b));return b.disabled||b.running&&b.structural}function D(a){var c,b=N.defer();
|
8
|
+
b.promise.$$cancelFn=function(){c&&c()};P.$$postDigest(function(){c=a(function(){b.resolve()})});return b.promise}function I(a){if(ga(a))return a.tempClasses&&ea(a.tempClasses)&&(a.tempClasses=a.tempClasses.split(/\s+/)),a}function S(a,c,b){b=b||{};var d={};n(b,function(e,a){n(a.split(" "),function(a){d[a]=e})});var h=Object.create(null);n((a.attr("class")||"").split(/\s+/),function(e){h[e]=!0});var f=[],l=[];n(c&&c.classes||[],function(e,a){var b=h[a],c=d[a]||{};!1===e?(b||"addClass"==c.event)&&
|
9
|
+
l.push(a):!0===e&&(b&&"removeClass"!=c.event||f.push(a))});return 0<f.length+l.length&&[f.join(" "),l.join(" ")]}function T(a){if(a){var c=[],b={};a=a.substr(1).split(".");(Y.transitions||Y.animations)&&c.push(M.get(da[""]));for(var d=0;d<a.length;d++){var f=a[d],k=da[f];k&&!b[f]&&(c.push(M.get(k)),b[f]=!0)}return c}}function U(a,c,b,d){function h(e,a){var b=e[a],c=e["before"+a.charAt(0).toUpperCase()+a.substr(1)];if(b||c)return"leave"==a&&(c=b,b=null),u.push({event:a,fn:b}),J.push({event:a,fn:c}),
|
10
|
+
!0}function k(c,l,w){var E=[];n(c,function(a){a.fn&&E.push(a)});var m=0;n(E,function(c,f){var p=function(){a:{if(l){(l[f]||t)();if(++m<E.length)break a;l=null}w()}};switch(c.event){case "setClass":l.push(c.fn(a,e,A,p,d));break;case "animate":l.push(c.fn(a,b,d.from,d.to,p));break;case "addClass":l.push(c.fn(a,e||b,p,d));break;case "removeClass":l.push(c.fn(a,A||b,p,d));break;default:l.push(c.fn(a,p,d))}});l&&0===l.length&&w()}var l=a[0];if(l){d&&(d.to=d.to||{},d.from=d.from||{});var e,A;aa(b)&&(e=
|
11
|
+
b[0],A=b[1],e?A?b=e+" "+A:(b=e,c="addClass"):(b=A,c="removeClass"));var w="setClass"==c,E=w||"addClass"==c||"removeClass"==c||"animate"==c,p=a.attr("class")+" "+b;if(x(p)){var ca=t,m=[],J=[],g=t,s=[],u=[],p=(" "+p).replace(/\s+/g,".");n(T(p),function(a){!h(a,c)&&w&&(h(a,"addClass"),h(a,"removeClass"))});return{node:l,event:c,className:b,isClassBased:E,isSetClassOperation:w,applyStyles:function(){d&&a.css(f.extend(d.from||{},d.to||{}))},before:function(a){ca=a;k(J,m,function(){ca=t;a()})},after:function(a){g=
|
12
|
+
a;k(u,s,function(){g=t;a()})},cancel:function(){m&&(n(m,function(a){(a||t)(!0)}),ca(!0));s&&(n(s,function(a){(a||t)(!0)}),g(!0))}}}}}function G(a,c,b,d,h,k,l,e){function A(e){var l="$animate:"+e;J&&J[l]&&0<J[l].length&&H(function(){b.triggerHandler(l,{event:a,className:c})})}function w(){A("before")}function E(){A("after")}function p(){p.hasBeenRun||(p.hasBeenRun=!0,k())}function g(){if(!g.hasBeenRun){m&&m.applyStyles();g.hasBeenRun=!0;l&&l.tempClasses&&n(l.tempClasses,function(a){u.removeClass(b,
|
13
|
+
a)});var w=b.data("$$ngAnimateState");w&&(m&&m.isClassBased?B(b,c):(H(function(){var e=b.data("$$ngAnimateState")||{};fa==e.index&&B(b,c,a)}),b.data("$$ngAnimateState",w)));A("close");e()}}var m=U(b,a,c,l);if(!m)return p(),w(),E(),g(),t;a=m.event;c=m.className;var J=f.element._data(m.node),J=J&&J.events;d||(d=h?h.parent():b.parent());if(z(b,d))return p(),w(),E(),g(),t;d=b.data("$$ngAnimateState")||{};var L=d.active||{},s=d.totalActive||0,q=d.last;h=!1;if(0<s){s=[];if(m.isClassBased)"setClass"==q.event?
|
14
|
+
(s.push(q),B(b,c)):L[c]&&(v=L[c],v.event==a?h=!0:(s.push(v),B(b,c)));else if("leave"==a&&L["ng-leave"])h=!0;else{for(var v in L)s.push(L[v]);d={};B(b,!0)}0<s.length&&n(s,function(a){a.cancel()})}!m.isClassBased||m.isSetClassOperation||"animate"==a||h||(h="addClass"==a==b.hasClass(c));if(h)return p(),w(),E(),A("close"),e(),t;L=d.active||{};s=d.totalActive||0;if("leave"==a)b.one("$destroy",function(a){a=f.element(this);var e=a.data("$$ngAnimateState");e&&(e=e.active["ng-leave"])&&(e.cancel(),B(a,"ng-leave"))});
|
15
|
+
u.addClass(b,"ng-animate");l&&l.tempClasses&&n(l.tempClasses,function(a){u.addClass(b,a)});var fa=K++;s++;L[c]=m;b.data("$$ngAnimateState",{last:m,active:L,index:fa,totalActive:s});w();m.before(function(e){var l=b.data("$$ngAnimateState");e=e||!l||!l.active[c]||m.isClassBased&&l.active[c].event!=a;p();!0===e?g():(E(),m.after(g))});return m.cancel}function q(a){if(a=g(a))a=f.isFunction(a.getElementsByClassName)?a.getElementsByClassName("ng-animate"):a.querySelectorAll(".ng-animate"),n(a,function(a){a=
|
16
|
+
f.element(a);(a=a.data("$$ngAnimateState"))&&a.active&&n(a.active,function(a){a.cancel()})})}function B(a,c){if(ba(a,y))r.disabled||(r.running=!1,r.structural=!1);else if(c){var b=a.data("$$ngAnimateState")||{},d=!0===c;!d&&b.active&&b.active[c]&&(b.totalActive--,delete b.active[c]);if(d||!b.totalActive)u.removeClass(a,"ng-animate"),a.removeData("$$ngAnimateState")}}function z(a,c){if(r.disabled)return!0;if(ba(a,y))return r.running;var b,d,g;do{if(0===c.length)break;var k=ba(c,y),l=k?r:c.data("$$ngAnimateState")||
|
17
|
+
{};if(l.disabled)return!0;k&&(g=!0);!1!==b&&(k=c.data("$$ngAnimateChildren"),f.isDefined(k)&&(b=k));d=d||l.running||l.last&&!l.last.isClassBased}while(c=c.parent());return!g||!b&&d}u=Q;y.data("$$ngAnimateState",r);var $=P.$watch(function(){return Z.totalPendingRequests},function(a,c){0===a&&($(),P.$$postDigest(function(){P.$$postDigest(function(){r.running=!1})}))}),K=0,V=C.classNameFilter(),x=V?function(a){return V.test(a)}:function(){return!0};return{animate:function(a,c,b,d,h){d=d||"ng-inline-animate";
|
18
|
+
h=I(h)||{};h.from=b?c:null;h.to=b?b:c;return D(function(b){return G("animate",d,f.element(g(a)),null,null,t,h,b)})},enter:function(a,c,b,d){d=I(d);a=f.element(a);c=c&&f.element(c);b=b&&f.element(b);R(a,!0);O.enter(a,c,b);return D(function(h){return G("enter","ng-enter",f.element(g(a)),c,b,t,d,h)})},leave:function(a,c){c=I(c);a=f.element(a);q(a);R(a,!0);return D(function(b){return G("leave","ng-leave",f.element(g(a)),null,null,function(){O.leave(a)},c,b)})},move:function(a,c,b,d){d=I(d);a=f.element(a);
|
19
|
+
c=c&&f.element(c);b=b&&f.element(b);q(a);R(a,!0);O.move(a,c,b);return D(function(h){return G("move","ng-move",f.element(g(a)),c,b,t,d,h)})},addClass:function(a,c,b){return this.setClass(a,c,[],b)},removeClass:function(a,c,b){return this.setClass(a,[],c,b)},setClass:function(a,c,b,d){d=I(d);a=f.element(a);a=f.element(g(a));if(R(a))return O.$$setClassImmediately(a,c,b,d);var h,k=a.data("$$animateClasses"),l=!!k;k||(k={classes:{}});h=k.classes;c=aa(c)?c:c.split(" ");n(c,function(a){a&&a.length&&(h[a]=
|
20
|
+
!0)});b=aa(b)?b:b.split(" ");n(b,function(a){a&&a.length&&(h[a]=!1)});if(l)return d&&k.options&&(k.options=f.extend(k.options||{},d)),k.promise;a.data("$$animateClasses",k={classes:h,options:d});return k.promise=D(function(e){var l=a.parent(),b=g(a),c=b.parentNode;if(!c||c.$$NG_REMOVED||b.$$NG_REMOVED)e();else{b=a.data("$$animateClasses");a.removeData("$$animateClasses");var c=a.data("$$ngAnimateState")||{},d=S(a,b,c.active);return d?G("setClass",d,a,l,null,function(){d[0]&&O.$$addClassImmediately(a,
|
21
|
+
d[0]);d[1]&&O.$$removeClassImmediately(a,d[1])},b.options,e):e()}})},cancel:function(a){a.$$cancelFn()},enabled:function(a,c){switch(arguments.length){case 2:if(a)B(c);else{var b=c.data("$$ngAnimateState")||{};b.disabled=!0;c.data("$$ngAnimateState",b)}break;case 1:r.disabled=!a;break;default:a=!r.disabled}return!!a}}}]);C.register("",["$window","$sniffer","$timeout","$$animateReflow",function(r,C,M,Y){function y(){b||(b=Y(function(){c=[];b=null;x={}}))}function H(a,e){b&&b();c.push(e);b=Y(function(){n(c,
|
22
|
+
function(a){a()});c=[];b=null;x={}})}function P(a,e){var b=g(a);a=f.element(b);k.push(a);b=Date.now()+e;b<=h||(M.cancel(d),h=b,d=M(function(){X(k);k=[]},e,!1))}function X(a){n(a,function(a){(a=a.data("$$ngAnimateCSS3Data"))&&n(a.closeAnimationFns,function(a){a()})})}function Z(a,e){var b=e?x[e]:null;if(!b){var c=0,d=0,f=0,g=0;n(a,function(a){if(1==a.nodeType){a=r.getComputedStyle(a)||{};c=Math.max(Q(a[z+"Duration"]),c);d=Math.max(Q(a[z+"Delay"]),d);g=Math.max(Q(a[K+"Delay"]),g);var e=Q(a[K+"Duration"]);
|
23
|
+
0<e&&(e*=parseInt(a[K+"IterationCount"],10)||1);f=Math.max(e,f)}});b={total:0,transitionDelay:d,transitionDuration:c,animationDelay:g,animationDuration:f};e&&(x[e]=b)}return b}function Q(a){var e=0;a=ea(a)?a.split(/\s*,\s*/):[];n(a,function(a){e=Math.max(parseFloat(a)||0,e)});return e}function R(b,e,c,d){b=0<=["ng-enter","ng-leave","ng-move"].indexOf(c);var f,p=e.parent(),h=p.data("$$ngAnimateKey");h||(p.data("$$ngAnimateKey",++a),h=a);f=h+"-"+g(e).getAttribute("class");var p=f+" "+c,h=x[p]?++x[p].total:
|
24
|
+
0,m={};if(0<h){var n=c+"-stagger",m=f+" "+n;(f=!x[m])&&u.addClass(e,n);m=Z(e,m);f&&u.removeClass(e,n)}u.addClass(e,c);var n=e.data("$$ngAnimateCSS3Data")||{},k=Z(e,p);f=k.transitionDuration;k=k.animationDuration;if(b&&0===f&&0===k)return u.removeClass(e,c),!1;c=d||b&&0<f;b=0<k&&0<m.animationDelay&&0===m.animationDuration;e.data("$$ngAnimateCSS3Data",{stagger:m,cacheKey:p,running:n.running||0,itemIndex:h,blockTransition:c,closeAnimationFns:n.closeAnimationFns||[]});p=g(e);c&&(I(p,!0),d&&e.css(d));
|
25
|
+
b&&(p.style[K+"PlayState"]="paused");return!0}function D(a,e,b,c,d){function f(){e.off(D,h);u.removeClass(e,k);u.removeClass(e,t);z&&M.cancel(z);G(e,b);var a=g(e),c;for(c in s)a.style.removeProperty(s[c])}function h(a){a.stopPropagation();var b=a.originalEvent||a;a=b.$manualTimeStamp||b.timeStamp||Date.now();b=parseFloat(b.elapsedTime.toFixed(3));Math.max(a-H,0)>=C&&b>=x&&c()}var m=g(e);a=e.data("$$ngAnimateCSS3Data");if(-1!=m.getAttribute("class").indexOf(b)&&a){var k="",t="";n(b.split(" "),function(a,
|
26
|
+
b){var e=(0<b?" ":"")+a;k+=e+"-active";t+=e+"-pending"});var s=[],q=a.itemIndex,v=a.stagger,r=0;if(0<q){r=0;0<v.transitionDelay&&0===v.transitionDuration&&(r=v.transitionDelay*q);var y=0;0<v.animationDelay&&0===v.animationDuration&&(y=v.animationDelay*q,s.push(B+"animation-play-state"));r=Math.round(100*Math.max(r,y))/100}r||(u.addClass(e,k),a.blockTransition&&I(m,!1));var F=Z(e,a.cacheKey+" "+k),x=Math.max(F.transitionDuration,F.animationDuration);if(0===x)u.removeClass(e,k),G(e,b),c();else{!r&&
|
27
|
+
d&&0<Object.keys(d).length&&(F.transitionDuration||(e.css("transition",F.animationDuration+"s linear all"),s.push("transition")),e.css(d));var q=Math.max(F.transitionDelay,F.animationDelay),C=1E3*q;0<s.length&&(v=m.getAttribute("style")||"",";"!==v.charAt(v.length-1)&&(v+=";"),m.setAttribute("style",v+" "));var H=Date.now(),D=V+" "+$,q=1E3*(r+1.5*(q+x)),z;0<r&&(u.addClass(e,t),z=M(function(){z=null;0<F.transitionDuration&&I(m,!1);0<F.animationDuration&&(m.style[K+"PlayState"]="");u.addClass(e,k);
|
28
|
+
u.removeClass(e,t);d&&(0===F.transitionDuration&&e.css("transition",F.animationDuration+"s linear all"),e.css(d),s.push("transition"))},1E3*r,!1));e.on(D,h);a.closeAnimationFns.push(function(){f();c()});a.running++;P(e,q);return f}}else c()}function I(a,b){a.style[z+"Property"]=b?"none":""}function S(a,b,c,d){if(R(a,b,c,d))return function(a){a&&G(b,c)}}function T(a,b,c,d,f){if(b.data("$$ngAnimateCSS3Data"))return D(a,b,c,d,f);G(b,c);d()}function U(a,b,c,d,f){var g=S(a,b,c,f.from);if(g){var h=g;H(b,
|
29
|
+
function(){h=T(a,b,c,d,f.to)});return function(a){(h||t)(a)}}y();d()}function G(a,b){u.removeClass(a,b);var c=a.data("$$ngAnimateCSS3Data");c&&(c.running&&c.running--,c.running&&0!==c.running||a.removeData("$$ngAnimateCSS3Data"))}function q(a,b){var c="";a=aa(a)?a:a.split(/\s+/);n(a,function(a,d){a&&0<a.length&&(c+=(0<d?" ":"")+a+b)});return c}var B="",z,$,K,V;N.ontransitionend===W&&N.onwebkittransitionend!==W?(B="-webkit-",z="WebkitTransition",$="webkitTransitionEnd transitionend"):(z="transition",
|
30
|
+
$="transitionend");N.onanimationend===W&&N.onwebkitanimationend!==W?(B="-webkit-",K="WebkitAnimation",V="webkitAnimationEnd animationend"):(K="animation",V="animationend");var x={},a=0,c=[],b,d=null,h=0,k=[];return{animate:function(a,b,c,d,f,g){g=g||{};g.from=c;g.to=d;return U("animate",a,b,f,g)},enter:function(a,b,c){c=c||{};return U("enter",a,"ng-enter",b,c)},leave:function(a,b,c){c=c||{};return U("leave",a,"ng-leave",b,c)},move:function(a,b,c){c=c||{};return U("move",a,"ng-move",b,c)},beforeSetClass:function(a,
|
31
|
+
b,c,d,f){f=f||{};b=q(c,"-remove")+" "+q(b,"-add");if(f=S("setClass",a,b,f.from))return H(a,d),f;y();d()},beforeAddClass:function(a,b,c,d){d=d||{};if(b=S("addClass",a,q(b,"-add"),d.from))return H(a,c),b;y();c()},beforeRemoveClass:function(a,b,c,d){d=d||{};if(b=S("removeClass",a,q(b,"-remove"),d.from))return H(a,c),b;y();c()},setClass:function(a,b,c,d,f){f=f||{};c=q(c,"-remove");b=q(b,"-add");return T("setClass",a,c+" "+b,d,f.to)},addClass:function(a,b,c,d){d=d||{};return T("addClass",a,q(b,"-add"),
|
32
|
+
c,d.to)},removeClass:function(a,b,c,d){d=d||{};return T("removeClass",a,q(b,"-remove"),c,d.to)}}}])}])})(window,window.angular);
|
33
|
+
//# sourceMappingURL=angular-animate.min.js.map
|
@@ -0,0 +1,339 @@
|
|
1
|
+
/**
|
2
|
+
* @license AngularJS v1.3.12
|
3
|
+
* (c) 2010-2014 Google, Inc. http://angularjs.org
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
|
+
(function(window, angular, undefined) {'use strict';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @ngdoc module
|
10
|
+
* @name ngAria
|
11
|
+
* @description
|
12
|
+
*
|
13
|
+
* The `ngAria` module provides support for common
|
14
|
+
* [<abbr title="Accessible Rich Internet Applications">ARIA</abbr>](http://www.w3.org/TR/wai-aria/)
|
15
|
+
* attributes that convey state or semantic information about the application for users
|
16
|
+
* of assistive technologies, such as screen readers.
|
17
|
+
*
|
18
|
+
* <div doc-module-components="ngAria"></div>
|
19
|
+
*
|
20
|
+
* ## Usage
|
21
|
+
*
|
22
|
+
* For ngAria to do its magic, simply include the module as a dependency. The directives supported
|
23
|
+
* by ngAria are:
|
24
|
+
* `ngModel`, `ngDisabled`, `ngShow`, `ngHide`, `ngClick`, `ngDblClick`, and `ngMessages`.
|
25
|
+
*
|
26
|
+
* Below is a more detailed breakdown of the attributes handled by ngAria:
|
27
|
+
*
|
28
|
+
* | Directive | Supported Attributes |
|
29
|
+
* |---------------------------------------------|----------------------------------------------------------------------------------------|
|
30
|
+
* | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required |
|
31
|
+
* | {@link ng.directive:ngDisabled ngDisabled} | aria-disabled |
|
32
|
+
* | {@link ng.directive:ngShow ngShow} | aria-hidden |
|
33
|
+
* | {@link ng.directive:ngHide ngHide} | aria-hidden |
|
34
|
+
* | {@link ng.directive:ngClick ngClick} | tabindex, keypress event |
|
35
|
+
* | {@link ng.directive:ngDblclick ngDblclick} | tabindex |
|
36
|
+
* | {@link module:ngMessages ngMessages} | aria-live |
|
37
|
+
*
|
38
|
+
* Find out more information about each directive by reading the
|
39
|
+
* {@link guide/accessibility ngAria Developer Guide}.
|
40
|
+
*
|
41
|
+
* ##Example
|
42
|
+
* Using ngDisabled with ngAria:
|
43
|
+
* ```html
|
44
|
+
* <md-checkbox ng-disabled="disabled">
|
45
|
+
* ```
|
46
|
+
* Becomes:
|
47
|
+
* ```html
|
48
|
+
* <md-checkbox ng-disabled="disabled" aria-disabled="true">
|
49
|
+
* ```
|
50
|
+
*
|
51
|
+
* ##Disabling Attributes
|
52
|
+
* It's possible to disable individual attributes added by ngAria with the
|
53
|
+
* {@link ngAria.$ariaProvider#config config} method. For more details, see the
|
54
|
+
* {@link guide/accessibility Developer Guide}.
|
55
|
+
*/
|
56
|
+
/* global -ngAriaModule */
|
57
|
+
var ngAriaModule = angular.module('ngAria', ['ng']).
|
58
|
+
provider('$aria', $AriaProvider);
|
59
|
+
|
60
|
+
/**
|
61
|
+
* @ngdoc provider
|
62
|
+
* @name $ariaProvider
|
63
|
+
*
|
64
|
+
* @description
|
65
|
+
*
|
66
|
+
* Used for configuring the ARIA attributes injected and managed by ngAria.
|
67
|
+
*
|
68
|
+
* ```js
|
69
|
+
* angular.module('myApp', ['ngAria'], function config($ariaProvider) {
|
70
|
+
* $ariaProvider.config({
|
71
|
+
* ariaValue: true,
|
72
|
+
* tabindex: false
|
73
|
+
* });
|
74
|
+
* });
|
75
|
+
*```
|
76
|
+
*
|
77
|
+
* ## Dependencies
|
78
|
+
* Requires the {@link ngAria} module to be installed.
|
79
|
+
*
|
80
|
+
*/
|
81
|
+
function $AriaProvider() {
|
82
|
+
var config = {
|
83
|
+
ariaHidden: true,
|
84
|
+
ariaChecked: true,
|
85
|
+
ariaDisabled: true,
|
86
|
+
ariaRequired: true,
|
87
|
+
ariaInvalid: true,
|
88
|
+
ariaMultiline: true,
|
89
|
+
ariaValue: true,
|
90
|
+
tabindex: true,
|
91
|
+
bindKeypress: true
|
92
|
+
};
|
93
|
+
|
94
|
+
/**
|
95
|
+
* @ngdoc method
|
96
|
+
* @name $ariaProvider#config
|
97
|
+
*
|
98
|
+
* @param {object} config object to enable/disable specific ARIA attributes
|
99
|
+
*
|
100
|
+
* - **ariaHidden** – `{boolean}` – Enables/disables aria-hidden tags
|
101
|
+
* - **ariaChecked** – `{boolean}` – Enables/disables aria-checked tags
|
102
|
+
* - **ariaDisabled** – `{boolean}` – Enables/disables aria-disabled tags
|
103
|
+
* - **ariaRequired** – `{boolean}` – Enables/disables aria-required tags
|
104
|
+
* - **ariaInvalid** – `{boolean}` – Enables/disables aria-invalid tags
|
105
|
+
* - **ariaMultiline** – `{boolean}` – Enables/disables aria-multiline tags
|
106
|
+
* - **ariaValue** – `{boolean}` – Enables/disables aria-valuemin, aria-valuemax and aria-valuenow tags
|
107
|
+
* - **tabindex** – `{boolean}` – Enables/disables tabindex tags
|
108
|
+
* - **bindKeypress** – `{boolean}` – Enables/disables keypress event binding on ng-click
|
109
|
+
*
|
110
|
+
* @description
|
111
|
+
* Enables/disables various ARIA attributes
|
112
|
+
*/
|
113
|
+
this.config = function(newConfig) {
|
114
|
+
config = angular.extend(config, newConfig);
|
115
|
+
};
|
116
|
+
|
117
|
+
function watchExpr(attrName, ariaAttr, negate) {
|
118
|
+
return function(scope, elem, attr) {
|
119
|
+
var ariaCamelName = attr.$normalize(ariaAttr);
|
120
|
+
if (config[ariaCamelName] && !attr[ariaCamelName]) {
|
121
|
+
scope.$watch(attr[attrName], function(boolVal) {
|
122
|
+
if (negate) {
|
123
|
+
boolVal = !boolVal;
|
124
|
+
}
|
125
|
+
elem.attr(ariaAttr, boolVal);
|
126
|
+
});
|
127
|
+
}
|
128
|
+
};
|
129
|
+
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* @ngdoc service
|
133
|
+
* @name $aria
|
134
|
+
*
|
135
|
+
* @description
|
136
|
+
*
|
137
|
+
* The $aria service contains helper methods for applying common
|
138
|
+
* [ARIA](http://www.w3.org/TR/wai-aria/) attributes to HTML directives.
|
139
|
+
*
|
140
|
+
* ngAria injects common accessibility attributes that tell assistive technologies when HTML
|
141
|
+
* elements are enabled, selected, hidden, and more. To see how this is performed with ngAria,
|
142
|
+
* let's review a code snippet from ngAria itself:
|
143
|
+
*
|
144
|
+
*```js
|
145
|
+
* ngAriaModule.directive('ngDisabled', ['$aria', function($aria) {
|
146
|
+
* return $aria.$$watchExpr('ngDisabled', 'aria-disabled');
|
147
|
+
* }])
|
148
|
+
*```
|
149
|
+
* Shown above, the ngAria module creates a directive with the same signature as the
|
150
|
+
* traditional `ng-disabled` directive. But this ngAria version is dedicated to
|
151
|
+
* solely managing accessibility attributes. The internal `$aria` service is used to watch the
|
152
|
+
* boolean attribute `ngDisabled`. If it has not been explicitly set by the developer,
|
153
|
+
* `aria-disabled` is injected as an attribute with its value synchronized to the value in
|
154
|
+
* `ngDisabled`.
|
155
|
+
*
|
156
|
+
* Because ngAria hooks into the `ng-disabled` directive, developers do not have to do
|
157
|
+
* anything to enable this feature. The `aria-disabled` attribute is automatically managed
|
158
|
+
* simply as a silent side-effect of using `ng-disabled` with the ngAria module.
|
159
|
+
*
|
160
|
+
* The full list of directives that interface with ngAria:
|
161
|
+
* * **ngModel**
|
162
|
+
* * **ngShow**
|
163
|
+
* * **ngHide**
|
164
|
+
* * **ngClick**
|
165
|
+
* * **ngDblclick**
|
166
|
+
* * **ngMessages**
|
167
|
+
* * **ngDisabled**
|
168
|
+
*
|
169
|
+
* Read the {@link guide/accessibility ngAria Developer Guide} for a thorough explanation of each
|
170
|
+
* directive.
|
171
|
+
*
|
172
|
+
*
|
173
|
+
* ## Dependencies
|
174
|
+
* Requires the {@link ngAria} module to be installed.
|
175
|
+
*/
|
176
|
+
this.$get = function() {
|
177
|
+
return {
|
178
|
+
config: function(key) {
|
179
|
+
return config[key];
|
180
|
+
},
|
181
|
+
$$watchExpr: watchExpr
|
182
|
+
};
|
183
|
+
};
|
184
|
+
}
|
185
|
+
|
186
|
+
|
187
|
+
ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
188
|
+
return $aria.$$watchExpr('ngShow', 'aria-hidden', true);
|
189
|
+
}])
|
190
|
+
.directive('ngHide', ['$aria', function($aria) {
|
191
|
+
return $aria.$$watchExpr('ngHide', 'aria-hidden', false);
|
192
|
+
}])
|
193
|
+
.directive('ngModel', ['$aria', function($aria) {
|
194
|
+
|
195
|
+
function shouldAttachAttr(attr, normalizedAttr, elem) {
|
196
|
+
return $aria.config(normalizedAttr) && !elem.attr(attr);
|
197
|
+
}
|
198
|
+
|
199
|
+
function getShape(attr, elem) {
|
200
|
+
var type = attr.type,
|
201
|
+
role = attr.role;
|
202
|
+
|
203
|
+
return ((type || role) === 'checkbox' || role === 'menuitemcheckbox') ? 'checkbox' :
|
204
|
+
((type || role) === 'radio' || role === 'menuitemradio') ? 'radio' :
|
205
|
+
(type === 'range' || role === 'progressbar' || role === 'slider') ? 'range' :
|
206
|
+
(type || role) === 'textbox' || elem[0].nodeName === 'TEXTAREA' ? 'multiline' : '';
|
207
|
+
}
|
208
|
+
|
209
|
+
return {
|
210
|
+
restrict: 'A',
|
211
|
+
require: '?ngModel',
|
212
|
+
link: function(scope, elem, attr, ngModel) {
|
213
|
+
var shape = getShape(attr, elem);
|
214
|
+
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem);
|
215
|
+
|
216
|
+
function ngAriaWatchModelValue() {
|
217
|
+
return ngModel.$modelValue;
|
218
|
+
}
|
219
|
+
|
220
|
+
function getRadioReaction() {
|
221
|
+
if (needsTabIndex) {
|
222
|
+
needsTabIndex = false;
|
223
|
+
return function ngAriaRadioReaction(newVal) {
|
224
|
+
var boolVal = newVal === attr.value;
|
225
|
+
elem.attr('aria-checked', boolVal);
|
226
|
+
elem.attr('tabindex', 0 - !boolVal);
|
227
|
+
};
|
228
|
+
} else {
|
229
|
+
return function ngAriaRadioReaction(newVal) {
|
230
|
+
elem.attr('aria-checked', newVal === attr.value);
|
231
|
+
};
|
232
|
+
}
|
233
|
+
}
|
234
|
+
|
235
|
+
function ngAriaCheckboxReaction(newVal) {
|
236
|
+
elem.attr('aria-checked', !!newVal);
|
237
|
+
}
|
238
|
+
|
239
|
+
switch (shape) {
|
240
|
+
case 'radio':
|
241
|
+
case 'checkbox':
|
242
|
+
if (shouldAttachAttr('aria-checked', 'ariaChecked', elem)) {
|
243
|
+
scope.$watch(ngAriaWatchModelValue, shape === 'radio' ?
|
244
|
+
getRadioReaction() : ngAriaCheckboxReaction);
|
245
|
+
}
|
246
|
+
break;
|
247
|
+
case 'range':
|
248
|
+
if ($aria.config('ariaValue')) {
|
249
|
+
if (attr.min && !elem.attr('aria-valuemin')) {
|
250
|
+
elem.attr('aria-valuemin', attr.min);
|
251
|
+
}
|
252
|
+
if (attr.max && !elem.attr('aria-valuemax')) {
|
253
|
+
elem.attr('aria-valuemax', attr.max);
|
254
|
+
}
|
255
|
+
if (!elem.attr('aria-valuenow')) {
|
256
|
+
scope.$watch(ngAriaWatchModelValue, function ngAriaValueNowReaction(newVal) {
|
257
|
+
elem.attr('aria-valuenow', newVal);
|
258
|
+
});
|
259
|
+
}
|
260
|
+
}
|
261
|
+
break;
|
262
|
+
case 'multiline':
|
263
|
+
if (shouldAttachAttr('aria-multiline', 'ariaMultiline', elem)) {
|
264
|
+
elem.attr('aria-multiline', true);
|
265
|
+
}
|
266
|
+
break;
|
267
|
+
}
|
268
|
+
|
269
|
+
if (needsTabIndex) {
|
270
|
+
elem.attr('tabindex', 0);
|
271
|
+
}
|
272
|
+
|
273
|
+
if (ngModel.$validators.required && shouldAttachAttr('aria-required', 'ariaRequired', elem)) {
|
274
|
+
scope.$watch(function ngAriaRequiredWatch() {
|
275
|
+
return ngModel.$error.required;
|
276
|
+
}, function ngAriaRequiredReaction(newVal) {
|
277
|
+
elem.attr('aria-required', !!newVal);
|
278
|
+
});
|
279
|
+
}
|
280
|
+
|
281
|
+
if (shouldAttachAttr('aria-invalid', 'ariaInvalid', elem)) {
|
282
|
+
scope.$watch(function ngAriaInvalidWatch() {
|
283
|
+
return ngModel.$invalid;
|
284
|
+
}, function ngAriaInvalidReaction(newVal) {
|
285
|
+
elem.attr('aria-invalid', !!newVal);
|
286
|
+
});
|
287
|
+
}
|
288
|
+
}
|
289
|
+
};
|
290
|
+
}])
|
291
|
+
.directive('ngDisabled', ['$aria', function($aria) {
|
292
|
+
return $aria.$$watchExpr('ngDisabled', 'aria-disabled');
|
293
|
+
}])
|
294
|
+
.directive('ngMessages', function() {
|
295
|
+
return {
|
296
|
+
restrict: 'A',
|
297
|
+
require: '?ngMessages',
|
298
|
+
link: function(scope, elem, attr, ngMessages) {
|
299
|
+
if (!elem.attr('aria-live')) {
|
300
|
+
elem.attr('aria-live', 'assertive');
|
301
|
+
}
|
302
|
+
}
|
303
|
+
};
|
304
|
+
})
|
305
|
+
.directive('ngClick',['$aria', '$parse', function($aria, $parse) {
|
306
|
+
return {
|
307
|
+
restrict: 'A',
|
308
|
+
compile: function(elem, attr) {
|
309
|
+
var fn = $parse(attr.ngClick, /* interceptorFn */ null, /* expensiveChecks */ true);
|
310
|
+
return function(scope, elem, attr) {
|
311
|
+
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
312
|
+
elem.attr('tabindex', 0);
|
313
|
+
}
|
314
|
+
|
315
|
+
if ($aria.config('bindKeypress') && !attr.ngKeypress) {
|
316
|
+
elem.on('keypress', function(event) {
|
317
|
+
if (event.keyCode === 32 || event.keyCode === 13) {
|
318
|
+
scope.$apply(callback);
|
319
|
+
}
|
320
|
+
|
321
|
+
function callback() {
|
322
|
+
fn(scope, { $event: event });
|
323
|
+
}
|
324
|
+
});
|
325
|
+
}
|
326
|
+
};
|
327
|
+
}
|
328
|
+
};
|
329
|
+
}])
|
330
|
+
.directive('ngDblclick', ['$aria', function($aria) {
|
331
|
+
return function(scope, elem, attr) {
|
332
|
+
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
333
|
+
elem.attr('tabindex', 0);
|
334
|
+
}
|
335
|
+
};
|
336
|
+
}]);
|
337
|
+
|
338
|
+
|
339
|
+
})(window, window.angular);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/*
|
2
|
+
AngularJS v1.3.12
|
3
|
+
(c) 2010-2014 Google, Inc. http://angularjs.org
|
4
|
+
License: MIT
|
5
|
+
*/
|
6
|
+
(function(p,k,q){'use strict';k.module("ngAria",["ng"]).provider("$aria",function(){function b(b,e,c){return function(d,h,f){var l=f.$normalize(e);a[l]&&!f[l]&&d.$watch(f[b],function(d){c&&(d=!d);h.attr(e,d)})}}var a={ariaHidden:!0,ariaChecked:!0,ariaDisabled:!0,ariaRequired:!0,ariaInvalid:!0,ariaMultiline:!0,ariaValue:!0,tabindex:!0,bindKeypress:!0};this.config=function(b){a=k.extend(a,b)};this.$get=function(){return{config:function(b){return a[b]},$$watchExpr:b}}}).directive("ngShow",["$aria",function(b){return b.$$watchExpr("ngShow",
|
7
|
+
"aria-hidden",!0)}]).directive("ngHide",["$aria",function(b){return b.$$watchExpr("ngHide","aria-hidden",!1)}]).directive("ngModel",["$aria",function(b){function a(a,c,d){return b.config(c)&&!d.attr(a)}function g(b,c){var d=b.type,a=b.role;return"checkbox"===(d||a)||"menuitemcheckbox"===a?"checkbox":"radio"===(d||a)||"menuitemradio"===a?"radio":"range"===d||"progressbar"===a||"slider"===a?"range":"textbox"===(d||a)||"TEXTAREA"===c[0].nodeName?"multiline":""}return{restrict:"A",require:"?ngModel",
|
8
|
+
link:function(e,c,d,h){function f(){return h.$modelValue}function l(){return m?(m=!1,function(a){a=a===d.value;c.attr("aria-checked",a);c.attr("tabindex",0-!a)}):function(a){c.attr("aria-checked",a===d.value)}}function n(a){c.attr("aria-checked",!!a)}var k=g(d,c),m=a("tabindex","tabindex",c);switch(k){case "radio":case "checkbox":a("aria-checked","ariaChecked",c)&&e.$watch(f,"radio"===k?l():n);break;case "range":b.config("ariaValue")&&(d.min&&!c.attr("aria-valuemin")&&c.attr("aria-valuemin",d.min),
|
9
|
+
d.max&&!c.attr("aria-valuemax")&&c.attr("aria-valuemax",d.max),c.attr("aria-valuenow")||e.$watch(f,function(a){c.attr("aria-valuenow",a)}));break;case "multiline":a("aria-multiline","ariaMultiline",c)&&c.attr("aria-multiline",!0)}m&&c.attr("tabindex",0);h.$validators.required&&a("aria-required","ariaRequired",c)&&e.$watch(function(){return h.$error.required},function(a){c.attr("aria-required",!!a)});a("aria-invalid","ariaInvalid",c)&&e.$watch(function(){return h.$invalid},function(a){c.attr("aria-invalid",
|
10
|
+
!!a)})}}}]).directive("ngDisabled",["$aria",function(b){return b.$$watchExpr("ngDisabled","aria-disabled")}]).directive("ngMessages",function(){return{restrict:"A",require:"?ngMessages",link:function(b,a,g,e){a.attr("aria-live")||a.attr("aria-live","assertive")}}}).directive("ngClick",["$aria","$parse",function(b,a){return{restrict:"A",compile:function(g,e){var c=a(e.ngClick,null,!0);return function(a,e,f){b.config("tabindex")&&!e.attr("tabindex")&&e.attr("tabindex",0);if(b.config("bindKeypress")&&
|
11
|
+
!f.ngKeypress)e.on("keypress",function(b){function e(){c(a,{$event:b})}32!==b.keyCode&&13!==b.keyCode||a.$apply(e)})}}}}]).directive("ngDblclick",["$aria",function(b){return function(a,g,e){b.config("tabindex")&&!g.attr("tabindex")&&g.attr("tabindex",0)}}])})(window,window.angular);
|
12
|
+
//# sourceMappingURL=angular-aria.min.js.map
|
@@ -0,0 +1,206 @@
|
|
1
|
+
/**
|
2
|
+
* @license AngularJS v1.3.12
|
3
|
+
* (c) 2010-2014 Google, Inc. http://angularjs.org
|
4
|
+
* License: MIT
|
5
|
+
*/
|
6
|
+
(function(window, angular, undefined) {'use strict';
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @ngdoc module
|
10
|
+
* @name ngCookies
|
11
|
+
* @description
|
12
|
+
*
|
13
|
+
* # ngCookies
|
14
|
+
*
|
15
|
+
* The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
|
16
|
+
*
|
17
|
+
*
|
18
|
+
* <div doc-module-components="ngCookies"></div>
|
19
|
+
*
|
20
|
+
* See {@link ngCookies.$cookies `$cookies`} and
|
21
|
+
* {@link ngCookies.$cookieStore `$cookieStore`} for usage.
|
22
|
+
*/
|
23
|
+
|
24
|
+
|
25
|
+
angular.module('ngCookies', ['ng']).
|
26
|
+
/**
|
27
|
+
* @ngdoc service
|
28
|
+
* @name $cookies
|
29
|
+
*
|
30
|
+
* @description
|
31
|
+
* Provides read/write access to browser's cookies.
|
32
|
+
*
|
33
|
+
* Only a simple Object is exposed and by adding or removing properties to/from this object, new
|
34
|
+
* cookies are created/deleted at the end of current $eval.
|
35
|
+
* The object's properties can only be strings.
|
36
|
+
*
|
37
|
+
* Requires the {@link ngCookies `ngCookies`} module to be installed.
|
38
|
+
*
|
39
|
+
* @example
|
40
|
+
*
|
41
|
+
* ```js
|
42
|
+
* angular.module('cookiesExample', ['ngCookies'])
|
43
|
+
* .controller('ExampleController', ['$cookies', function($cookies) {
|
44
|
+
* // Retrieving a cookie
|
45
|
+
* var favoriteCookie = $cookies.myFavorite;
|
46
|
+
* // Setting a cookie
|
47
|
+
* $cookies.myFavorite = 'oatmeal';
|
48
|
+
* }]);
|
49
|
+
* ```
|
50
|
+
*/
|
51
|
+
factory('$cookies', ['$rootScope', '$browser', function($rootScope, $browser) {
|
52
|
+
var cookies = {},
|
53
|
+
lastCookies = {},
|
54
|
+
lastBrowserCookies,
|
55
|
+
runEval = false,
|
56
|
+
copy = angular.copy,
|
57
|
+
isUndefined = angular.isUndefined;
|
58
|
+
|
59
|
+
//creates a poller fn that copies all cookies from the $browser to service & inits the service
|
60
|
+
$browser.addPollFn(function() {
|
61
|
+
var currentCookies = $browser.cookies();
|
62
|
+
if (lastBrowserCookies != currentCookies) { //relies on browser.cookies() impl
|
63
|
+
lastBrowserCookies = currentCookies;
|
64
|
+
copy(currentCookies, lastCookies);
|
65
|
+
copy(currentCookies, cookies);
|
66
|
+
if (runEval) $rootScope.$apply();
|
67
|
+
}
|
68
|
+
})();
|
69
|
+
|
70
|
+
runEval = true;
|
71
|
+
|
72
|
+
//at the end of each eval, push cookies
|
73
|
+
//TODO: this should happen before the "delayed" watches fire, because if some cookies are not
|
74
|
+
// strings or browser refuses to store some cookies, we update the model in the push fn.
|
75
|
+
$rootScope.$watch(push);
|
76
|
+
|
77
|
+
return cookies;
|
78
|
+
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Pushes all the cookies from the service to the browser and verifies if all cookies were
|
82
|
+
* stored.
|
83
|
+
*/
|
84
|
+
function push() {
|
85
|
+
var name,
|
86
|
+
value,
|
87
|
+
browserCookies,
|
88
|
+
updated;
|
89
|
+
|
90
|
+
//delete any cookies deleted in $cookies
|
91
|
+
for (name in lastCookies) {
|
92
|
+
if (isUndefined(cookies[name])) {
|
93
|
+
$browser.cookies(name, undefined);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
//update all cookies updated in $cookies
|
98
|
+
for (name in cookies) {
|
99
|
+
value = cookies[name];
|
100
|
+
if (!angular.isString(value)) {
|
101
|
+
value = '' + value;
|
102
|
+
cookies[name] = value;
|
103
|
+
}
|
104
|
+
if (value !== lastCookies[name]) {
|
105
|
+
$browser.cookies(name, value);
|
106
|
+
updated = true;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
//verify what was actually stored
|
111
|
+
if (updated) {
|
112
|
+
updated = false;
|
113
|
+
browserCookies = $browser.cookies();
|
114
|
+
|
115
|
+
for (name in cookies) {
|
116
|
+
if (cookies[name] !== browserCookies[name]) {
|
117
|
+
//delete or reset all cookies that the browser dropped from $cookies
|
118
|
+
if (isUndefined(browserCookies[name])) {
|
119
|
+
delete cookies[name];
|
120
|
+
} else {
|
121
|
+
cookies[name] = browserCookies[name];
|
122
|
+
}
|
123
|
+
updated = true;
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}]).
|
129
|
+
|
130
|
+
|
131
|
+
/**
|
132
|
+
* @ngdoc service
|
133
|
+
* @name $cookieStore
|
134
|
+
* @requires $cookies
|
135
|
+
*
|
136
|
+
* @description
|
137
|
+
* Provides a key-value (string-object) storage, that is backed by session cookies.
|
138
|
+
* Objects put or retrieved from this storage are automatically serialized or
|
139
|
+
* deserialized by angular's toJson/fromJson.
|
140
|
+
*
|
141
|
+
* Requires the {@link ngCookies `ngCookies`} module to be installed.
|
142
|
+
*
|
143
|
+
* @example
|
144
|
+
*
|
145
|
+
* ```js
|
146
|
+
* angular.module('cookieStoreExample', ['ngCookies'])
|
147
|
+
* .controller('ExampleController', ['$cookieStore', function($cookieStore) {
|
148
|
+
* // Put cookie
|
149
|
+
* $cookieStore.put('myFavorite','oatmeal');
|
150
|
+
* // Get cookie
|
151
|
+
* var favoriteCookie = $cookieStore.get('myFavorite');
|
152
|
+
* // Removing a cookie
|
153
|
+
* $cookieStore.remove('myFavorite');
|
154
|
+
* }]);
|
155
|
+
* ```
|
156
|
+
*/
|
157
|
+
factory('$cookieStore', ['$cookies', function($cookies) {
|
158
|
+
|
159
|
+
return {
|
160
|
+
/**
|
161
|
+
* @ngdoc method
|
162
|
+
* @name $cookieStore#get
|
163
|
+
*
|
164
|
+
* @description
|
165
|
+
* Returns the value of given cookie key
|
166
|
+
*
|
167
|
+
* @param {string} key Id to use for lookup.
|
168
|
+
* @returns {Object} Deserialized cookie value.
|
169
|
+
*/
|
170
|
+
get: function(key) {
|
171
|
+
var value = $cookies[key];
|
172
|
+
return value ? angular.fromJson(value) : value;
|
173
|
+
},
|
174
|
+
|
175
|
+
/**
|
176
|
+
* @ngdoc method
|
177
|
+
* @name $cookieStore#put
|
178
|
+
*
|
179
|
+
* @description
|
180
|
+
* Sets a value for given cookie key
|
181
|
+
*
|
182
|
+
* @param {string} key Id for the `value`.
|
183
|
+
* @param {Object} value Value to be stored.
|
184
|
+
*/
|
185
|
+
put: function(key, value) {
|
186
|
+
$cookies[key] = angular.toJson(value);
|
187
|
+
},
|
188
|
+
|
189
|
+
/**
|
190
|
+
* @ngdoc method
|
191
|
+
* @name $cookieStore#remove
|
192
|
+
*
|
193
|
+
* @description
|
194
|
+
* Remove given cookie
|
195
|
+
*
|
196
|
+
* @param {string} key Id of the key-value pair to delete.
|
197
|
+
*/
|
198
|
+
remove: function(key) {
|
199
|
+
delete $cookies[key];
|
200
|
+
}
|
201
|
+
};
|
202
|
+
|
203
|
+
}]);
|
204
|
+
|
205
|
+
|
206
|
+
})(window, window.angular);
|