|
|
|
@ -1,20 +1,19 @@
|
|
|
|
|
/**
|
|
|
|
|
* @license AngularJS v1.2.1
|
|
|
|
|
* (c) 2010-2012 Google, Inc. http://angularjs.org
|
|
|
|
|
* @license AngularJS v1.2.16
|
|
|
|
|
* (c) 2010-2014 Google, Inc. http://angularjs.org
|
|
|
|
|
* License: MIT
|
|
|
|
|
*/
|
|
|
|
|
(function(window, angular, undefined) {'use strict';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ngdoc overview
|
|
|
|
|
* @ngdoc module
|
|
|
|
|
* @name ngCookies
|
|
|
|
|
* @description
|
|
|
|
|
*
|
|
|
|
|
* # ngCookies
|
|
|
|
|
*
|
|
|
|
|
* The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
|
|
|
|
|
* The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
|
|
|
|
|
*
|
|
|
|
|
* {@installModule cookies}
|
|
|
|
|
*
|
|
|
|
|
* <div doc-module-components="ngCookies"></div>
|
|
|
|
|
*
|
|
|
|
@ -25,21 +24,21 @@
|
|
|
|
|
|
|
|
|
|
angular.module('ngCookies', ['ng']).
|
|
|
|
|
/**
|
|
|
|
|
* @ngdoc object
|
|
|
|
|
* @name ngCookies.$cookies
|
|
|
|
|
* @requires $browser
|
|
|
|
|
* @ngdoc service
|
|
|
|
|
* @name $cookies
|
|
|
|
|
*
|
|
|
|
|
* @description
|
|
|
|
|
* Provides read/write access to browser's cookies.
|
|
|
|
|
*
|
|
|
|
|
* Only a simple Object is exposed and by adding or removing properties to/from
|
|
|
|
|
* this object, new cookies are created/deleted at the end of current $eval.
|
|
|
|
|
* Only a simple Object is exposed and by adding or removing properties to/from this object, new
|
|
|
|
|
* cookies are created/deleted at the end of current $eval.
|
|
|
|
|
* The object's properties can only be strings.
|
|
|
|
|
*
|
|
|
|
|
* Requires the {@link ngCookies `ngCookies`} module to be installed.
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
<doc:example>
|
|
|
|
|
<doc:source>
|
|
|
|
|
<example>
|
|
|
|
|
<file name="index.html">
|
|
|
|
|
<script>
|
|
|
|
|
function ExampleController($cookies) {
|
|
|
|
|
// Retrieving a cookie
|
|
|
|
@ -48,8 +47,8 @@ angular.module('ngCookies', ['ng']).
|
|
|
|
|
$cookies.myFavorite = 'oatmeal';
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</doc:source>
|
|
|
|
|
</doc:example>
|
|
|
|
|
</file>
|
|
|
|
|
</example>
|
|
|
|
|
*/
|
|
|
|
|
factory('$cookies', ['$rootScope', '$browser', function ($rootScope, $browser) {
|
|
|
|
|
var cookies = {},
|
|
|
|
@ -101,12 +100,10 @@ angular.module('ngCookies', ['ng']).
|
|
|
|
|
for(name in cookies) {
|
|
|
|
|
value = cookies[name];
|
|
|
|
|
if (!angular.isString(value)) {
|
|
|
|
|
if (angular.isDefined(lastCookies[name])) {
|
|
|
|
|
cookies[name] = lastCookies[name];
|
|
|
|
|
} else {
|
|
|
|
|
delete cookies[name];
|
|
|
|
|
}
|
|
|
|
|
} else if (value !== lastCookies[name]) {
|
|
|
|
|
value = '' + value;
|
|
|
|
|
cookies[name] = value;
|
|
|
|
|
}
|
|
|
|
|
if (value !== lastCookies[name]) {
|
|
|
|
|
$browser.cookies(name, value);
|
|
|
|
|
updated = true;
|
|
|
|
|
}
|
|
|
|
@ -134,8 +131,8 @@ angular.module('ngCookies', ['ng']).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ngdoc object
|
|
|
|
|
* @name ngCookies.$cookieStore
|
|
|
|
|
* @ngdoc service
|
|
|
|
|
* @name $cookieStore
|
|
|
|
|
* @requires $cookies
|
|
|
|
|
*
|
|
|
|
|
* @description
|
|
|
|
@ -152,8 +149,7 @@ angular.module('ngCookies', ['ng']).
|
|
|
|
|
return {
|
|
|
|
|
/**
|
|
|
|
|
* @ngdoc method
|
|
|
|
|
* @name ngCookies.$cookieStore#get
|
|
|
|
|
* @methodOf ngCookies.$cookieStore
|
|
|
|
|
* @name $cookieStore#get
|
|
|
|
|
*
|
|
|
|
|
* @description
|
|
|
|
|
* Returns the value of given cookie key
|
|
|
|
@ -168,8 +164,7 @@ angular.module('ngCookies', ['ng']).
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ngdoc method
|
|
|
|
|
* @name ngCookies.$cookieStore#put
|
|
|
|
|
* @methodOf ngCookies.$cookieStore
|
|
|
|
|
* @name $cookieStore#put
|
|
|
|
|
*
|
|
|
|
|
* @description
|
|
|
|
|
* Sets a value for given cookie key
|
|
|
|
@ -183,8 +178,7 @@ angular.module('ngCookies', ['ng']).
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ngdoc method
|
|
|
|
|
* @name ngCookies.$cookieStore#remove
|
|
|
|
|
* @methodOf ngCookies.$cookieStore
|
|
|
|
|
* @name $cookieStore#remove
|
|
|
|
|
*
|
|
|
|
|
* @description
|
|
|
|
|
* Remove given cookie
|
|
|
|
|