angularjs-rails 1.3.15 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/angularjs-rails/version.rb +2 -2
- data/vendor/assets/javascripts/angular-animate.js +3443 -1872
- data/vendor/assets/javascripts/angular-aria.js +89 -75
- data/vendor/assets/javascripts/angular-cookies.js +255 -141
- data/vendor/assets/javascripts/angular-loader.js +41 -17
- data/vendor/assets/javascripts/angular-message-format.js +980 -0
- data/vendor/assets/javascripts/angular-messages.js +430 -153
- data/vendor/assets/javascripts/angular-mocks.js +76 -92
- data/vendor/assets/javascripts/angular-resource.js +6 -6
- data/vendor/assets/javascripts/angular-route.js +8 -6
- data/vendor/assets/javascripts/angular-sanitize.js +32 -28
- data/vendor/assets/javascripts/angular-scenario.js +4315 -2452
- data/vendor/assets/javascripts/angular-touch.js +26 -21
- data/vendor/assets/javascripts/angular.js +4314 -2490
- data/vendor/assets/javascripts/unstable/angular2.js +24024 -0
- metadata +4 -14
- data/vendor/assets/javascripts/unstable/angular-animate.js +0 -2137
- data/vendor/assets/javascripts/unstable/angular-aria.js +0 -364
- data/vendor/assets/javascripts/unstable/angular-cookies.js +0 -206
- data/vendor/assets/javascripts/unstable/angular-loader.js +0 -405
- data/vendor/assets/javascripts/unstable/angular-messages.js +0 -401
- data/vendor/assets/javascripts/unstable/angular-mocks.js +0 -2468
- data/vendor/assets/javascripts/unstable/angular-resource.js +0 -668
- data/vendor/assets/javascripts/unstable/angular-route.js +0 -989
- data/vendor/assets/javascripts/unstable/angular-sanitize.js +0 -679
- data/vendor/assets/javascripts/unstable/angular-scenario.js +0 -37678
- data/vendor/assets/javascripts/unstable/angular-touch.js +0 -622
- data/vendor/assets/javascripts/unstable/angular.js +0 -26309
@@ -1,364 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license AngularJS v1.3.15
|
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:ngDisabled ngDisabled} | aria-disabled |
|
31
|
-
* | {@link ng.directive:ngShow ngShow} | aria-hidden |
|
32
|
-
* | {@link ng.directive:ngHide ngHide} | aria-hidden |
|
33
|
-
* | {@link ng.directive:ngDblclick ngDblclick} | tabindex |
|
34
|
-
* | {@link module:ngMessages ngMessages} | aria-live |
|
35
|
-
* | {@link ng.directive:ngModel ngModel} | aria-checked, aria-valuemin, aria-valuemax, aria-valuenow, aria-invalid, aria-required, input roles |
|
36
|
-
* | {@link ng.directive:ngClick ngClick} | tabindex, keypress event, button role |
|
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 `<div>` and
|
109
|
-
* `<li>` elements with ng-click
|
110
|
-
*
|
111
|
-
* @description
|
112
|
-
* Enables/disables various ARIA attributes
|
113
|
-
*/
|
114
|
-
this.config = function(newConfig) {
|
115
|
-
config = angular.extend(config, newConfig);
|
116
|
-
};
|
117
|
-
|
118
|
-
function watchExpr(attrName, ariaAttr, negate) {
|
119
|
-
return function(scope, elem, attr) {
|
120
|
-
var ariaCamelName = attr.$normalize(ariaAttr);
|
121
|
-
if (config[ariaCamelName] && !attr[ariaCamelName]) {
|
122
|
-
scope.$watch(attr[attrName], function(boolVal) {
|
123
|
-
if (negate) {
|
124
|
-
boolVal = !boolVal;
|
125
|
-
}
|
126
|
-
elem.attr(ariaAttr, boolVal);
|
127
|
-
});
|
128
|
-
}
|
129
|
-
};
|
130
|
-
}
|
131
|
-
|
132
|
-
/**
|
133
|
-
* @ngdoc service
|
134
|
-
* @name $aria
|
135
|
-
*
|
136
|
-
* @description
|
137
|
-
* @priority 200
|
138
|
-
*
|
139
|
-
* The $aria service contains helper methods for applying common
|
140
|
-
* [ARIA](http://www.w3.org/TR/wai-aria/) attributes to HTML directives.
|
141
|
-
*
|
142
|
-
* ngAria injects common accessibility attributes that tell assistive technologies when HTML
|
143
|
-
* elements are enabled, selected, hidden, and more. To see how this is performed with ngAria,
|
144
|
-
* let's review a code snippet from ngAria itself:
|
145
|
-
*
|
146
|
-
*```js
|
147
|
-
* ngAriaModule.directive('ngDisabled', ['$aria', function($aria) {
|
148
|
-
* return $aria.$$watchExpr('ngDisabled', 'aria-disabled');
|
149
|
-
* }])
|
150
|
-
*```
|
151
|
-
* Shown above, the ngAria module creates a directive with the same signature as the
|
152
|
-
* traditional `ng-disabled` directive. But this ngAria version is dedicated to
|
153
|
-
* solely managing accessibility attributes. The internal `$aria` service is used to watch the
|
154
|
-
* boolean attribute `ngDisabled`. If it has not been explicitly set by the developer,
|
155
|
-
* `aria-disabled` is injected as an attribute with its value synchronized to the value in
|
156
|
-
* `ngDisabled`.
|
157
|
-
*
|
158
|
-
* Because ngAria hooks into the `ng-disabled` directive, developers do not have to do
|
159
|
-
* anything to enable this feature. The `aria-disabled` attribute is automatically managed
|
160
|
-
* simply as a silent side-effect of using `ng-disabled` with the ngAria module.
|
161
|
-
*
|
162
|
-
* The full list of directives that interface with ngAria:
|
163
|
-
* * **ngModel**
|
164
|
-
* * **ngShow**
|
165
|
-
* * **ngHide**
|
166
|
-
* * **ngClick**
|
167
|
-
* * **ngDblclick**
|
168
|
-
* * **ngMessages**
|
169
|
-
* * **ngDisabled**
|
170
|
-
*
|
171
|
-
* Read the {@link guide/accessibility ngAria Developer Guide} for a thorough explanation of each
|
172
|
-
* directive.
|
173
|
-
*
|
174
|
-
*
|
175
|
-
* ## Dependencies
|
176
|
-
* Requires the {@link ngAria} module to be installed.
|
177
|
-
*/
|
178
|
-
this.$get = function() {
|
179
|
-
return {
|
180
|
-
config: function(key) {
|
181
|
-
return config[key];
|
182
|
-
},
|
183
|
-
$$watchExpr: watchExpr
|
184
|
-
};
|
185
|
-
};
|
186
|
-
}
|
187
|
-
|
188
|
-
|
189
|
-
ngAriaModule.directive('ngShow', ['$aria', function($aria) {
|
190
|
-
return $aria.$$watchExpr('ngShow', 'aria-hidden', true);
|
191
|
-
}])
|
192
|
-
.directive('ngHide', ['$aria', function($aria) {
|
193
|
-
return $aria.$$watchExpr('ngHide', 'aria-hidden', false);
|
194
|
-
}])
|
195
|
-
.directive('ngModel', ['$aria', function($aria) {
|
196
|
-
|
197
|
-
function shouldAttachAttr(attr, normalizedAttr, elem) {
|
198
|
-
return $aria.config(normalizedAttr) && !elem.attr(attr);
|
199
|
-
}
|
200
|
-
|
201
|
-
function shouldAttachRole(role, elem) {
|
202
|
-
return !elem.attr('role') && (elem.attr('type') === role) && (elem[0].nodeName !== 'INPUT');
|
203
|
-
}
|
204
|
-
|
205
|
-
function getShape(attr, elem) {
|
206
|
-
var type = attr.type,
|
207
|
-
role = attr.role;
|
208
|
-
|
209
|
-
return ((type || role) === 'checkbox' || role === 'menuitemcheckbox') ? 'checkbox' :
|
210
|
-
((type || role) === 'radio' || role === 'menuitemradio') ? 'radio' :
|
211
|
-
(type === 'range' || role === 'progressbar' || role === 'slider') ? 'range' :
|
212
|
-
(type || role) === 'textbox' || elem[0].nodeName === 'TEXTAREA' ? 'multiline' : '';
|
213
|
-
}
|
214
|
-
|
215
|
-
return {
|
216
|
-
restrict: 'A',
|
217
|
-
require: '?ngModel',
|
218
|
-
priority: 200, //Make sure watches are fired after any other directives that affect the ngModel value
|
219
|
-
link: function(scope, elem, attr, ngModel) {
|
220
|
-
var shape = getShape(attr, elem);
|
221
|
-
var needsTabIndex = shouldAttachAttr('tabindex', 'tabindex', elem);
|
222
|
-
|
223
|
-
function ngAriaWatchModelValue() {
|
224
|
-
return ngModel.$modelValue;
|
225
|
-
}
|
226
|
-
|
227
|
-
function getRadioReaction() {
|
228
|
-
if (needsTabIndex) {
|
229
|
-
needsTabIndex = false;
|
230
|
-
return function ngAriaRadioReaction(newVal) {
|
231
|
-
var boolVal = (attr.value == ngModel.$viewValue);
|
232
|
-
elem.attr('aria-checked', boolVal);
|
233
|
-
elem.attr('tabindex', 0 - !boolVal);
|
234
|
-
};
|
235
|
-
} else {
|
236
|
-
return function ngAriaRadioReaction(newVal) {
|
237
|
-
elem.attr('aria-checked', (attr.value == ngModel.$viewValue));
|
238
|
-
};
|
239
|
-
}
|
240
|
-
}
|
241
|
-
|
242
|
-
function ngAriaCheckboxReaction(newVal) {
|
243
|
-
elem.attr('aria-checked', !ngModel.$isEmpty(ngModel.$viewValue));
|
244
|
-
}
|
245
|
-
|
246
|
-
switch (shape) {
|
247
|
-
case 'radio':
|
248
|
-
case 'checkbox':
|
249
|
-
if (shouldAttachRole(shape, elem)) {
|
250
|
-
elem.attr('role', shape);
|
251
|
-
}
|
252
|
-
if (shouldAttachAttr('aria-checked', 'ariaChecked', elem)) {
|
253
|
-
scope.$watch(ngAriaWatchModelValue, shape === 'radio' ?
|
254
|
-
getRadioReaction() : ngAriaCheckboxReaction);
|
255
|
-
}
|
256
|
-
break;
|
257
|
-
case 'range':
|
258
|
-
if (shouldAttachRole(shape, elem)) {
|
259
|
-
elem.attr('role', 'slider');
|
260
|
-
}
|
261
|
-
if ($aria.config('ariaValue')) {
|
262
|
-
if (attr.min && !elem.attr('aria-valuemin')) {
|
263
|
-
elem.attr('aria-valuemin', attr.min);
|
264
|
-
}
|
265
|
-
if (attr.max && !elem.attr('aria-valuemax')) {
|
266
|
-
elem.attr('aria-valuemax', attr.max);
|
267
|
-
}
|
268
|
-
if (!elem.attr('aria-valuenow')) {
|
269
|
-
scope.$watch(ngAriaWatchModelValue, function ngAriaValueNowReaction(newVal) {
|
270
|
-
elem.attr('aria-valuenow', newVal);
|
271
|
-
});
|
272
|
-
}
|
273
|
-
}
|
274
|
-
break;
|
275
|
-
case 'multiline':
|
276
|
-
if (shouldAttachAttr('aria-multiline', 'ariaMultiline', elem)) {
|
277
|
-
elem.attr('aria-multiline', true);
|
278
|
-
}
|
279
|
-
break;
|
280
|
-
}
|
281
|
-
|
282
|
-
if (needsTabIndex) {
|
283
|
-
elem.attr('tabindex', 0);
|
284
|
-
}
|
285
|
-
|
286
|
-
if (ngModel.$validators.required && shouldAttachAttr('aria-required', 'ariaRequired', elem)) {
|
287
|
-
scope.$watch(function ngAriaRequiredWatch() {
|
288
|
-
return ngModel.$error.required;
|
289
|
-
}, function ngAriaRequiredReaction(newVal) {
|
290
|
-
elem.attr('aria-required', !!newVal);
|
291
|
-
});
|
292
|
-
}
|
293
|
-
|
294
|
-
if (shouldAttachAttr('aria-invalid', 'ariaInvalid', elem)) {
|
295
|
-
scope.$watch(function ngAriaInvalidWatch() {
|
296
|
-
return ngModel.$invalid;
|
297
|
-
}, function ngAriaInvalidReaction(newVal) {
|
298
|
-
elem.attr('aria-invalid', !!newVal);
|
299
|
-
});
|
300
|
-
}
|
301
|
-
}
|
302
|
-
};
|
303
|
-
}])
|
304
|
-
.directive('ngDisabled', ['$aria', function($aria) {
|
305
|
-
return $aria.$$watchExpr('ngDisabled', 'aria-disabled');
|
306
|
-
}])
|
307
|
-
.directive('ngMessages', function() {
|
308
|
-
return {
|
309
|
-
restrict: 'A',
|
310
|
-
require: '?ngMessages',
|
311
|
-
link: function(scope, elem, attr, ngMessages) {
|
312
|
-
if (!elem.attr('aria-live')) {
|
313
|
-
elem.attr('aria-live', 'assertive');
|
314
|
-
}
|
315
|
-
}
|
316
|
-
};
|
317
|
-
})
|
318
|
-
.directive('ngClick',['$aria', '$parse', function($aria, $parse) {
|
319
|
-
return {
|
320
|
-
restrict: 'A',
|
321
|
-
compile: function(elem, attr) {
|
322
|
-
var fn = $parse(attr.ngClick, /* interceptorFn */ null, /* expensiveChecks */ true);
|
323
|
-
return function(scope, elem, attr) {
|
324
|
-
|
325
|
-
var nodeBlackList = ['BUTTON', 'A', 'INPUT', 'TEXTAREA'];
|
326
|
-
|
327
|
-
function isNodeOneOf(elem, nodeTypeArray) {
|
328
|
-
if (nodeTypeArray.indexOf(elem[0].nodeName) !== -1) {
|
329
|
-
return true;
|
330
|
-
}
|
331
|
-
}
|
332
|
-
if (!elem.attr('role') && !isNodeOneOf(elem, nodeBlackList)) {
|
333
|
-
elem.attr('role', 'button');
|
334
|
-
}
|
335
|
-
|
336
|
-
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
337
|
-
elem.attr('tabindex', 0);
|
338
|
-
}
|
339
|
-
|
340
|
-
if ($aria.config('bindKeypress') && !attr.ngKeypress && !isNodeOneOf(elem, nodeBlackList)) {
|
341
|
-
elem.on('keypress', function(event) {
|
342
|
-
if (event.keyCode === 32 || event.keyCode === 13) {
|
343
|
-
scope.$apply(callback);
|
344
|
-
}
|
345
|
-
|
346
|
-
function callback() {
|
347
|
-
fn(scope, { $event: event });
|
348
|
-
}
|
349
|
-
});
|
350
|
-
}
|
351
|
-
};
|
352
|
-
}
|
353
|
-
};
|
354
|
-
}])
|
355
|
-
.directive('ngDblclick', ['$aria', function($aria) {
|
356
|
-
return function(scope, elem, attr) {
|
357
|
-
if ($aria.config('tabindex') && !elem.attr('tabindex')) {
|
358
|
-
elem.attr('tabindex', 0);
|
359
|
-
}
|
360
|
-
};
|
361
|
-
}]);
|
362
|
-
|
363
|
-
|
364
|
-
})(window, window.angular);
|
@@ -1,206 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license AngularJS v1.3.15
|
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);
|