angular-gem 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,202 @@
1
+ /**
2
+ * @license AngularJS v1.2.3
3
+ * (c) 2010-2014 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
+ * @description
12
+ *
13
+ * # ngCookies
14
+ *
15
+ * The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
16
+ *
17
+ * {@installModule cookies}
18
+ *
19
+ * <div doc-module-components="ngCookies"></div>
20
+ *
21
+ * See {@link ngCookies.$cookies `$cookies`} and
22
+ * {@link ngCookies.$cookieStore `$cookieStore`} for usage.
23
+ */
24
+
25
+
26
+ angular.module('ngCookies', ['ng']).
27
+ /**
28
+ * @ngdoc object
29
+ * @name ngCookies.$cookies
30
+ * @requires $browser
31
+ *
32
+ * @description
33
+ * Provides read/write access to browser's cookies.
34
+ *
35
+ * Only a simple Object is exposed and by adding or removing properties to/from
36
+ * this object, new cookies are created/deleted at the end of current $eval.
37
+ *
38
+ * Requires the {@link ngCookies `ngCookies`} module to be installed.
39
+ *
40
+ * @example
41
+ <doc:example>
42
+ <doc:source>
43
+ <script>
44
+ function ExampleController($cookies) {
45
+ // Retrieving a cookie
46
+ var favoriteCookie = $cookies.myFavorite;
47
+ // Setting a cookie
48
+ $cookies.myFavorite = 'oatmeal';
49
+ }
50
+ </script>
51
+ </doc:source>
52
+ </doc:example>
53
+ */
54
+ factory('$cookies', ['$rootScope', '$browser', function ($rootScope, $browser) {
55
+ var cookies = {},
56
+ lastCookies = {},
57
+ lastBrowserCookies,
58
+ runEval = false,
59
+ copy = angular.copy,
60
+ isUndefined = angular.isUndefined;
61
+
62
+ //creates a poller fn that copies all cookies from the $browser to service & inits the service
63
+ $browser.addPollFn(function() {
64
+ var currentCookies = $browser.cookies();
65
+ if (lastBrowserCookies != currentCookies) { //relies on browser.cookies() impl
66
+ lastBrowserCookies = currentCookies;
67
+ copy(currentCookies, lastCookies);
68
+ copy(currentCookies, cookies);
69
+ if (runEval) $rootScope.$apply();
70
+ }
71
+ })();
72
+
73
+ runEval = true;
74
+
75
+ //at the end of each eval, push cookies
76
+ //TODO: this should happen before the "delayed" watches fire, because if some cookies are not
77
+ // strings or browser refuses to store some cookies, we update the model in the push fn.
78
+ $rootScope.$watch(push);
79
+
80
+ return cookies;
81
+
82
+
83
+ /**
84
+ * Pushes all the cookies from the service to the browser and verifies if all cookies were
85
+ * stored.
86
+ */
87
+ function push() {
88
+ var name,
89
+ value,
90
+ browserCookies,
91
+ updated;
92
+
93
+ //delete any cookies deleted in $cookies
94
+ for (name in lastCookies) {
95
+ if (isUndefined(cookies[name])) {
96
+ $browser.cookies(name, undefined);
97
+ }
98
+ }
99
+
100
+ //update all cookies updated in $cookies
101
+ for(name in cookies) {
102
+ value = cookies[name];
103
+ if (!angular.isString(value)) {
104
+ if (angular.isDefined(lastCookies[name])) {
105
+ cookies[name] = lastCookies[name];
106
+ } else {
107
+ delete cookies[name];
108
+ }
109
+ } else if (value !== lastCookies[name]) {
110
+ $browser.cookies(name, value);
111
+ updated = true;
112
+ }
113
+ }
114
+
115
+ //verify what was actually stored
116
+ if (updated){
117
+ updated = false;
118
+ browserCookies = $browser.cookies();
119
+
120
+ for (name in cookies) {
121
+ if (cookies[name] !== browserCookies[name]) {
122
+ //delete or reset all cookies that the browser dropped from $cookies
123
+ if (isUndefined(browserCookies[name])) {
124
+ delete cookies[name];
125
+ } else {
126
+ cookies[name] = browserCookies[name];
127
+ }
128
+ updated = true;
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }]).
134
+
135
+
136
+ /**
137
+ * @ngdoc object
138
+ * @name ngCookies.$cookieStore
139
+ * @requires $cookies
140
+ *
141
+ * @description
142
+ * Provides a key-value (string-object) storage, that is backed by session cookies.
143
+ * Objects put or retrieved from this storage are automatically serialized or
144
+ * deserialized by angular's toJson/fromJson.
145
+ *
146
+ * Requires the {@link ngCookies `ngCookies`} module to be installed.
147
+ *
148
+ * @example
149
+ */
150
+ factory('$cookieStore', ['$cookies', function($cookies) {
151
+
152
+ return {
153
+ /**
154
+ * @ngdoc method
155
+ * @name ngCookies.$cookieStore#get
156
+ * @methodOf ngCookies.$cookieStore
157
+ *
158
+ * @description
159
+ * Returns the value of given cookie key
160
+ *
161
+ * @param {string} key Id to use for lookup.
162
+ * @returns {Object} Deserialized cookie value.
163
+ */
164
+ get: function(key) {
165
+ var value = $cookies[key];
166
+ return value ? angular.fromJson(value) : value;
167
+ },
168
+
169
+ /**
170
+ * @ngdoc method
171
+ * @name ngCookies.$cookieStore#put
172
+ * @methodOf ngCookies.$cookieStore
173
+ *
174
+ * @description
175
+ * Sets a value for given cookie key
176
+ *
177
+ * @param {string} key Id for the `value`.
178
+ * @param {Object} value Value to be stored.
179
+ */
180
+ put: function(key, value) {
181
+ $cookies[key] = angular.toJson(value);
182
+ },
183
+
184
+ /**
185
+ * @ngdoc method
186
+ * @name ngCookies.$cookieStore#remove
187
+ * @methodOf ngCookies.$cookieStore
188
+ *
189
+ * @description
190
+ * Remove given cookie
191
+ *
192
+ * @param {string} key Id of the key-value pair to delete.
193
+ */
194
+ remove: function(key) {
195
+ delete $cookies[key];
196
+ }
197
+ };
198
+
199
+ }]);
200
+
201
+
202
+ })(window, window.angular);
@@ -0,0 +1,410 @@
1
+ /**
2
+ * @license AngularJS v1.2.3
3
+ * (c) 2010-2014 Google, Inc. http://angularjs.org
4
+ * License: MIT
5
+ */
6
+
7
+ (function() {'use strict';
8
+
9
+ /**
10
+ * @description
11
+ *
12
+ * This object provides a utility for producing rich Error messages within
13
+ * Angular. It can be called as follows:
14
+ *
15
+ * var exampleMinErr = minErr('example');
16
+ * throw exampleMinErr('one', 'This {0} is {1}', foo, bar);
17
+ *
18
+ * The above creates an instance of minErr in the example namespace. The
19
+ * resulting error will have a namespaced error code of example.one. The
20
+ * resulting error will replace {0} with the value of foo, and {1} with the
21
+ * value of bar. The object is not restricted in the number of arguments it can
22
+ * take.
23
+ *
24
+ * If fewer arguments are specified than necessary for interpolation, the extra
25
+ * interpolation markers will be preserved in the final string.
26
+ *
27
+ * Since data will be parsed statically during a build step, some restrictions
28
+ * are applied with respect to how minErr instances are created and called.
29
+ * Instances should have names of the form namespaceMinErr for a minErr created
30
+ * using minErr('namespace') . Error codes, namespaces and template strings
31
+ * should all be static strings, not variables or general expressions.
32
+ *
33
+ * @param {string} module The namespace to use for the new minErr instance.
34
+ * @returns {function(string, string, ...): Error} instance
35
+ */
36
+
37
+ function minErr(module) {
38
+ return function () {
39
+ var code = arguments[0],
40
+ prefix = '[' + (module ? module + ':' : '') + code + '] ',
41
+ template = arguments[1],
42
+ templateArgs = arguments,
43
+ stringify = function (obj) {
44
+ if (typeof obj === 'function') {
45
+ return obj.toString().replace(/ \{[\s\S]*$/, '');
46
+ } else if (typeof obj === 'undefined') {
47
+ return 'undefined';
48
+ } else if (typeof obj !== 'string') {
49
+ return JSON.stringify(obj);
50
+ }
51
+ return obj;
52
+ },
53
+ message, i;
54
+
55
+ message = prefix + template.replace(/\{\d+\}/g, function (match) {
56
+ var index = +match.slice(1, -1), arg;
57
+
58
+ if (index + 2 < templateArgs.length) {
59
+ arg = templateArgs[index + 2];
60
+ if (typeof arg === 'function') {
61
+ return arg.toString().replace(/ ?\{[\s\S]*$/, '');
62
+ } else if (typeof arg === 'undefined') {
63
+ return 'undefined';
64
+ } else if (typeof arg !== 'string') {
65
+ return toJson(arg);
66
+ }
67
+ return arg;
68
+ }
69
+ return match;
70
+ });
71
+
72
+ message = message + '\nhttp://errors.angularjs.org/1.2.3/' +
73
+ (module ? module + '/' : '') + code;
74
+ for (i = 2; i < arguments.length; i++) {
75
+ message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
76
+ encodeURIComponent(stringify(arguments[i]));
77
+ }
78
+
79
+ return new Error(message);
80
+ };
81
+ }
82
+
83
+ /**
84
+ * @ngdoc interface
85
+ * @name angular.Module
86
+ * @description
87
+ *
88
+ * Interface for configuring angular {@link angular.module modules}.
89
+ */
90
+
91
+ function setupModuleLoader(window) {
92
+
93
+ var $injectorMinErr = minErr('$injector');
94
+ var ngMinErr = minErr('ng');
95
+
96
+ function ensure(obj, name, factory) {
97
+ return obj[name] || (obj[name] = factory());
98
+ }
99
+
100
+ var angular = ensure(window, 'angular', Object);
101
+
102
+ // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap
103
+ angular.$$minErr = angular.$$minErr || minErr;
104
+
105
+ return ensure(angular, 'module', function() {
106
+ /** @type {Object.<string, angular.Module>} */
107
+ var modules = {};
108
+
109
+ /**
110
+ * @ngdoc function
111
+ * @name angular.module
112
+ * @description
113
+ *
114
+ * The `angular.module` is a global place for creating, registering and retrieving Angular
115
+ * modules.
116
+ * All modules (angular core or 3rd party) that should be available to an application must be
117
+ * registered using this mechanism.
118
+ *
119
+ * When passed two or more arguments, a new module is created. If passed only one argument, an
120
+ * existing module (the name passed as the first argument to `module`) is retrieved.
121
+ *
122
+ *
123
+ * # Module
124
+ *
125
+ * A module is a collection of services, directives, filters, and configuration information.
126
+ * `angular.module` is used to configure the {@link AUTO.$injector $injector}.
127
+ *
128
+ * <pre>
129
+ * // Create a new module
130
+ * var myModule = angular.module('myModule', []);
131
+ *
132
+ * // register a new service
133
+ * myModule.value('appName', 'MyCoolApp');
134
+ *
135
+ * // configure existing services inside initialization blocks.
136
+ * myModule.config(function($locationProvider) {
137
+ * // Configure existing providers
138
+ * $locationProvider.hashPrefix('!');
139
+ * });
140
+ * </pre>
141
+ *
142
+ * Then you can create an injector and load your modules like this:
143
+ *
144
+ * <pre>
145
+ * var injector = angular.injector(['ng', 'MyModule'])
146
+ * </pre>
147
+ *
148
+ * However it's more likely that you'll just use
149
+ * {@link ng.directive:ngApp ngApp} or
150
+ * {@link angular.bootstrap} to simplify this process for you.
151
+ *
152
+ * @param {!string} name The name of the module to create or retrieve.
153
+ * @param {Array.<string>=} requires If specified then new module is being created. If
154
+ * unspecified then the the module is being retrieved for further configuration.
155
+ * @param {Function} configFn Optional configuration function for the module. Same as
156
+ * {@link angular.Module#methods_config Module#config()}.
157
+ * @returns {module} new module with the {@link angular.Module} api.
158
+ */
159
+ return function module(name, requires, configFn) {
160
+ var assertNotHasOwnProperty = function(name, context) {
161
+ if (name === 'hasOwnProperty') {
162
+ throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
163
+ }
164
+ };
165
+
166
+ assertNotHasOwnProperty(name, 'module');
167
+ if (requires && modules.hasOwnProperty(name)) {
168
+ modules[name] = null;
169
+ }
170
+ return ensure(modules, name, function() {
171
+ if (!requires) {
172
+ throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " +
173
+ "the module name or forgot to load it. If registering a module ensure that you " +
174
+ "specify the dependencies as the second argument.", name);
175
+ }
176
+
177
+ /** @type {!Array.<Array.<*>>} */
178
+ var invokeQueue = [];
179
+
180
+ /** @type {!Array.<Function>} */
181
+ var runBlocks = [];
182
+
183
+ var config = invokeLater('$injector', 'invoke');
184
+
185
+ /** @type {angular.Module} */
186
+ var moduleInstance = {
187
+ // Private state
188
+ _invokeQueue: invokeQueue,
189
+ _runBlocks: runBlocks,
190
+
191
+ /**
192
+ * @ngdoc property
193
+ * @name angular.Module#requires
194
+ * @propertyOf angular.Module
195
+ * @returns {Array.<string>} List of module names which must be loaded before this module.
196
+ * @description
197
+ * Holds the list of modules which the injector will load before the current module is
198
+ * loaded.
199
+ */
200
+ requires: requires,
201
+
202
+ /**
203
+ * @ngdoc property
204
+ * @name angular.Module#name
205
+ * @propertyOf angular.Module
206
+ * @returns {string} Name of the module.
207
+ * @description
208
+ */
209
+ name: name,
210
+
211
+
212
+ /**
213
+ * @ngdoc method
214
+ * @name angular.Module#provider
215
+ * @methodOf angular.Module
216
+ * @param {string} name service name
217
+ * @param {Function} providerType Construction function for creating new instance of the
218
+ * service.
219
+ * @description
220
+ * See {@link AUTO.$provide#provider $provide.provider()}.
221
+ */
222
+ provider: invokeLater('$provide', 'provider'),
223
+
224
+ /**
225
+ * @ngdoc method
226
+ * @name angular.Module#factory
227
+ * @methodOf angular.Module
228
+ * @param {string} name service name
229
+ * @param {Function} providerFunction Function for creating new instance of the service.
230
+ * @description
231
+ * See {@link AUTO.$provide#factory $provide.factory()}.
232
+ */
233
+ factory: invokeLater('$provide', 'factory'),
234
+
235
+ /**
236
+ * @ngdoc method
237
+ * @name angular.Module#service
238
+ * @methodOf angular.Module
239
+ * @param {string} name service name
240
+ * @param {Function} constructor A constructor function that will be instantiated.
241
+ * @description
242
+ * See {@link AUTO.$provide#service $provide.service()}.
243
+ */
244
+ service: invokeLater('$provide', 'service'),
245
+
246
+ /**
247
+ * @ngdoc method
248
+ * @name angular.Module#value
249
+ * @methodOf angular.Module
250
+ * @param {string} name service name
251
+ * @param {*} object Service instance object.
252
+ * @description
253
+ * See {@link AUTO.$provide#value $provide.value()}.
254
+ */
255
+ value: invokeLater('$provide', 'value'),
256
+
257
+ /**
258
+ * @ngdoc method
259
+ * @name angular.Module#constant
260
+ * @methodOf angular.Module
261
+ * @param {string} name constant name
262
+ * @param {*} object Constant value.
263
+ * @description
264
+ * Because the constant are fixed, they get applied before other provide methods.
265
+ * See {@link AUTO.$provide#constant $provide.constant()}.
266
+ */
267
+ constant: invokeLater('$provide', 'constant', 'unshift'),
268
+
269
+ /**
270
+ * @ngdoc method
271
+ * @name angular.Module#animation
272
+ * @methodOf angular.Module
273
+ * @param {string} name animation name
274
+ * @param {Function} animationFactory Factory function for creating new instance of an
275
+ * animation.
276
+ * @description
277
+ *
278
+ * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
279
+ *
280
+ *
281
+ * Defines an animation hook that can be later used with
282
+ * {@link ngAnimate.$animate $animate} service and directives that use this service.
283
+ *
284
+ * <pre>
285
+ * module.animation('.animation-name', function($inject1, $inject2) {
286
+ * return {
287
+ * eventName : function(element, done) {
288
+ * //code to run the animation
289
+ * //once complete, then run done()
290
+ * return function cancellationFunction(element) {
291
+ * //code to cancel the animation
292
+ * }
293
+ * }
294
+ * }
295
+ * })
296
+ * </pre>
297
+ *
298
+ * See {@link ngAnimate.$animateProvider#register $animateProvider.register()} and
299
+ * {@link ngAnimate ngAnimate module} for more information.
300
+ */
301
+ animation: invokeLater('$animateProvider', 'register'),
302
+
303
+ /**
304
+ * @ngdoc method
305
+ * @name angular.Module#filter
306
+ * @methodOf angular.Module
307
+ * @param {string} name Filter name.
308
+ * @param {Function} filterFactory Factory function for creating new instance of filter.
309
+ * @description
310
+ * See {@link ng.$filterProvider#register $filterProvider.register()}.
311
+ */
312
+ filter: invokeLater('$filterProvider', 'register'),
313
+
314
+ /**
315
+ * @ngdoc method
316
+ * @name angular.Module#controller
317
+ * @methodOf angular.Module
318
+ * @param {string|Object} name Controller name, or an object map of controllers where the
319
+ * keys are the names and the values are the constructors.
320
+ * @param {Function} constructor Controller constructor function.
321
+ * @description
322
+ * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
323
+ */
324
+ controller: invokeLater('$controllerProvider', 'register'),
325
+
326
+ /**
327
+ * @ngdoc method
328
+ * @name angular.Module#directive
329
+ * @methodOf angular.Module
330
+ * @param {string|Object} name Directive name, or an object map of directives where the
331
+ * keys are the names and the values are the factories.
332
+ * @param {Function} directiveFactory Factory function for creating new instance of
333
+ * directives.
334
+ * @description
335
+ * See {@link ng.$compileProvider#methods_directive $compileProvider.directive()}.
336
+ */
337
+ directive: invokeLater('$compileProvider', 'directive'),
338
+
339
+ /**
340
+ * @ngdoc method
341
+ * @name angular.Module#config
342
+ * @methodOf angular.Module
343
+ * @param {Function} configFn Execute this function on module load. Useful for service
344
+ * configuration.
345
+ * @description
346
+ * Use this method to register work which needs to be performed on module loading.
347
+ */
348
+ config: config,
349
+
350
+ /**
351
+ * @ngdoc method
352
+ * @name angular.Module#run
353
+ * @methodOf angular.Module
354
+ * @param {Function} initializationFn Execute this function after injector creation.
355
+ * Useful for application initialization.
356
+ * @description
357
+ * Use this method to register work which should be performed when the injector is done
358
+ * loading all modules.
359
+ */
360
+ run: function(block) {
361
+ runBlocks.push(block);
362
+ return this;
363
+ }
364
+ };
365
+
366
+ if (configFn) {
367
+ config(configFn);
368
+ }
369
+
370
+ return moduleInstance;
371
+
372
+ /**
373
+ * @param {string} provider
374
+ * @param {string} method
375
+ * @param {String=} insertMethod
376
+ * @returns {angular.Module}
377
+ */
378
+ function invokeLater(provider, method, insertMethod) {
379
+ return function() {
380
+ invokeQueue[insertMethod || 'push']([provider, method, arguments]);
381
+ return moduleInstance;
382
+ };
383
+ }
384
+ });
385
+ };
386
+ });
387
+
388
+ }
389
+
390
+ setupModuleLoader(window);
391
+ })(window);
392
+
393
+ /**
394
+ * Closure compiler type information
395
+ *
396
+ * @typedef { {
397
+ * requires: !Array.<string>,
398
+ * invokeQueue: !Array.<Array.<*>>,
399
+ *
400
+ * service: function(string, Function):angular.Module,
401
+ * factory: function(string, Function):angular.Module,
402
+ * value: function(string, *):angular.Module,
403
+ *
404
+ * filter: function(string, Function):angular.Module,
405
+ *
406
+ * init: function(Function):angular.Module
407
+ * } }
408
+ */
409
+ angular.Module;
410
+