Skip to content

Commit 2a9d940

Browse files
committed
angular 1.2.0rc1 spooky-giraffe
1 parent 762b2ae commit 2a9d940

681 files changed

Lines changed: 134125 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1.2.0rc1/angular-1.2.0rc1.zip

4.3 MB
Binary file not shown.

1.2.0rc1/angular-animate.js

Lines changed: 677 additions & 0 deletions
Large diffs are not rendered by default.

1.2.0rc1/angular-animate.min.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.2.0rc1/angular-animate.min.js.map

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

1.2.0rc1/angular-cookies.js

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/**
2+
* @license AngularJS v1.2.0rc1
3+
* (c) 2010-2012 Google, Inc. http://angularjs.org
4+
* License: MIT
5+
*/
6+
(function(window, angular, undefined) {'use strict';
7+
8+
/**
9+
* @ngdoc overview
10+
* @name ngCookies
11+
*/
12+
13+
14+
angular.module('ngCookies', ['ng']).
15+
/**
16+
* @ngdoc object
17+
* @name ngCookies.$cookies
18+
* @requires $browser
19+
*
20+
* @description
21+
* Provides read/write access to browser's cookies.
22+
*
23+
* Only a simple Object is exposed and by adding or removing properties to/from
24+
* this object, new cookies are created/deleted at the end of current $eval.
25+
*
26+
* @example
27+
<doc:example>
28+
<doc:source>
29+
<script>
30+
function ExampleController($cookies) {
31+
// Retrieving a cookie
32+
var favoriteCookie = $cookies.myFavorite;
33+
// Setting a cookie
34+
$cookies.myFavorite = 'oatmeal';
35+
}
36+
</script>
37+
</doc:source>
38+
</doc:example>
39+
*/
40+
factory('$cookies', ['$rootScope', '$browser', function ($rootScope, $browser) {
41+
var cookies = {},
42+
lastCookies = {},
43+
lastBrowserCookies,
44+
runEval = false,
45+
copy = angular.copy,
46+
isUndefined = angular.isUndefined;
47+
48+
//creates a poller fn that copies all cookies from the $browser to service & inits the service
49+
$browser.addPollFn(function() {
50+
var currentCookies = $browser.cookies();
51+
if (lastBrowserCookies != currentCookies) { //relies on browser.cookies() impl
52+
lastBrowserCookies = currentCookies;
53+
copy(currentCookies, lastCookies);
54+
copy(currentCookies, cookies);
55+
if (runEval) $rootScope.$apply();
56+
}
57+
})();
58+
59+
runEval = true;
60+
61+
//at the end of each eval, push cookies
62+
//TODO: this should happen before the "delayed" watches fire, because if some cookies are not
63+
// strings or browser refuses to store some cookies, we update the model in the push fn.
64+
$rootScope.$watch(push);
65+
66+
return cookies;
67+
68+
69+
/**
70+
* Pushes all the cookies from the service to the browser and verifies if all cookies were stored.
71+
*/
72+
function push() {
73+
var name,
74+
value,
75+
browserCookies,
76+
updated;
77+
78+
//delete any cookies deleted in $cookies
79+
for (name in lastCookies) {
80+
if (isUndefined(cookies[name])) {
81+
$browser.cookies(name, undefined);
82+
}
83+
}
84+
85+
//update all cookies updated in $cookies
86+
for(name in cookies) {
87+
value = cookies[name];
88+
if (!angular.isString(value)) {
89+
if (angular.isDefined(lastCookies[name])) {
90+
cookies[name] = lastCookies[name];
91+
} else {
92+
delete cookies[name];
93+
}
94+
} else if (value !== lastCookies[name]) {
95+
$browser.cookies(name, value);
96+
updated = true;
97+
}
98+
}
99+
100+
//verify what was actually stored
101+
if (updated){
102+
updated = false;
103+
browserCookies = $browser.cookies();
104+
105+
for (name in cookies) {
106+
if (cookies[name] !== browserCookies[name]) {
107+
//delete or reset all cookies that the browser dropped from $cookies
108+
if (isUndefined(browserCookies[name])) {
109+
delete cookies[name];
110+
} else {
111+
cookies[name] = browserCookies[name];
112+
}
113+
updated = true;
114+
}
115+
}
116+
}
117+
}
118+
}]).
119+
120+
121+
/**
122+
* @ngdoc object
123+
* @name ngCookies.$cookieStore
124+
* @requires $cookies
125+
*
126+
* @description
127+
* Provides a key-value (string-object) storage, that is backed by session cookies.
128+
* Objects put or retrieved from this storage are automatically serialized or
129+
* deserialized by angular's toJson/fromJson.
130+
* @example
131+
*/
132+
factory('$cookieStore', ['$cookies', function($cookies) {
133+
134+
return {
135+
/**
136+
* @ngdoc method
137+
* @name ngCookies.$cookieStore#get
138+
* @methodOf ngCookies.$cookieStore
139+
*
140+
* @description
141+
* Returns the value of given cookie key
142+
*
143+
* @param {string} key Id to use for lookup.
144+
* @returns {Object} Deserialized cookie value.
145+
*/
146+
get: function(key) {
147+
var value = $cookies[key];
148+
return value ? angular.fromJson(value) : value;
149+
},
150+
151+
/**
152+
* @ngdoc method
153+
* @name ngCookies.$cookieStore#put
154+
* @methodOf ngCookies.$cookieStore
155+
*
156+
* @description
157+
* Sets a value for given cookie key
158+
*
159+
* @param {string} key Id for the `value`.
160+
* @param {Object} value Value to be stored.
161+
*/
162+
put: function(key, value) {
163+
$cookies[key] = angular.toJson(value);
164+
},
165+
166+
/**
167+
* @ngdoc method
168+
* @name ngCookies.$cookieStore#remove
169+
* @methodOf ngCookies.$cookieStore
170+
*
171+
* @description
172+
* Remove given cookie
173+
*
174+
* @param {string} key Id of the key-value pair to delete.
175+
*/
176+
remove: function(key) {
177+
delete $cookies[key];
178+
}
179+
};
180+
181+
}]);
182+
183+
184+
})(window, window.angular);

1.2.0rc1/angular-cookies.min.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
AngularJS v1.2.0rc1
3+
(c) 2010-2012 Google, Inc. http://angularjs.org
4+
License: MIT
5+
*/
6+
(function(p,f,n){'use strict';f.module("ngCookies",["ng"]).factory("$cookies",["$rootScope","$browser",function(d,b){var c={},g={},h,k=!1,l=f.copy,m=f.isUndefined;b.addPollFn(function(){var a=b.cookies();h!=a&&(h=a,l(a,g),l(a,c),k&&d.$apply())})();k=!0;d.$watch(function(){var a,e,d;for(a in g)m(c[a])&&b.cookies(a,n);for(a in c)(e=c[a],f.isString(e))?e!==g[a]&&(b.cookies(a,e),d=!0):f.isDefined(g[a])?c[a]=g[a]:delete c[a];if(d)for(a in e=b.cookies(),c)c[a]!==e[a]&&(m(e[a])?delete c[a]:c[a]=e[a])});
7+
return c}]).factory("$cookieStore",["$cookies",function(d){return{get:function(b){return(b=d[b])?f.fromJson(b):b},put:function(b,c){d[b]=f.toJson(c)},remove:function(b){delete d[b]}}}])})(window,window.angular);
8+
/*
9+
//@ sourceMappingURL=angular-cookies.min.js.map
10+
*/

0 commit comments

Comments
 (0)