angular-gem 1.2.0.1 → 1.2.1

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.
@@ -0,0 +1,202 @@
1
+ /**
2
+ * @license AngularJS v1.2.1
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
+ * @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,405 @@
1
+ /**
2
+ * @license AngularJS v1.2.1
3
+ * (c) 2010-2012 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.1/' +
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
+ return ensure(ensure(window, 'angular', Object), 'module', function() {
101
+ /** @type {Object.<string, angular.Module>} */
102
+ var modules = {};
103
+
104
+ /**
105
+ * @ngdoc function
106
+ * @name angular.module
107
+ * @description
108
+ *
109
+ * The `angular.module` is a global place for creating, registering and retrieving Angular
110
+ * modules.
111
+ * All modules (angular core or 3rd party) that should be available to an application must be
112
+ * registered using this mechanism.
113
+ *
114
+ * When passed two or more arguments, a new module is created. If passed only one argument, an
115
+ * existing module (the name passed as the first argument to `module`) is retrieved.
116
+ *
117
+ *
118
+ * # Module
119
+ *
120
+ * A module is a collection of services, directives, filters, and configuration information.
121
+ * `angular.module` is used to configure the {@link AUTO.$injector $injector}.
122
+ *
123
+ * <pre>
124
+ * // Create a new module
125
+ * var myModule = angular.module('myModule', []);
126
+ *
127
+ * // register a new service
128
+ * myModule.value('appName', 'MyCoolApp');
129
+ *
130
+ * // configure existing services inside initialization blocks.
131
+ * myModule.config(function($locationProvider) {
132
+ * // Configure existing providers
133
+ * $locationProvider.hashPrefix('!');
134
+ * });
135
+ * </pre>
136
+ *
137
+ * Then you can create an injector and load your modules like this:
138
+ *
139
+ * <pre>
140
+ * var injector = angular.injector(['ng', 'MyModule'])
141
+ * </pre>
142
+ *
143
+ * However it's more likely that you'll just use
144
+ * {@link ng.directive:ngApp ngApp} or
145
+ * {@link angular.bootstrap} to simplify this process for you.
146
+ *
147
+ * @param {!string} name The name of the module to create or retrieve.
148
+ * @param {Array.<string>=} requires If specified then new module is being created. If
149
+ * unspecified then the the module is being retrieved for further configuration.
150
+ * @param {Function} configFn Optional configuration function for the module. Same as
151
+ * {@link angular.Module#methods_config Module#config()}.
152
+ * @returns {module} new module with the {@link angular.Module} api.
153
+ */
154
+ return function module(name, requires, configFn) {
155
+ var assertNotHasOwnProperty = function(name, context) {
156
+ if (name === 'hasOwnProperty') {
157
+ throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
158
+ }
159
+ };
160
+
161
+ assertNotHasOwnProperty(name, 'module');
162
+ if (requires && modules.hasOwnProperty(name)) {
163
+ modules[name] = null;
164
+ }
165
+ return ensure(modules, name, function() {
166
+ if (!requires) {
167
+ throw $injectorMinErr('nomod', "Module '{0}' is not available! You either misspelled " +
168
+ "the module name or forgot to load it. If registering a module ensure that you " +
169
+ "specify the dependencies as the second argument.", name);
170
+ }
171
+
172
+ /** @type {!Array.<Array.<*>>} */
173
+ var invokeQueue = [];
174
+
175
+ /** @type {!Array.<Function>} */
176
+ var runBlocks = [];
177
+
178
+ var config = invokeLater('$injector', 'invoke');
179
+
180
+ /** @type {angular.Module} */
181
+ var moduleInstance = {
182
+ // Private state
183
+ _invokeQueue: invokeQueue,
184
+ _runBlocks: runBlocks,
185
+
186
+ /**
187
+ * @ngdoc property
188
+ * @name angular.Module#requires
189
+ * @propertyOf angular.Module
190
+ * @returns {Array.<string>} List of module names which must be loaded before this module.
191
+ * @description
192
+ * Holds the list of modules which the injector will load before the current module is
193
+ * loaded.
194
+ */
195
+ requires: requires,
196
+
197
+ /**
198
+ * @ngdoc property
199
+ * @name angular.Module#name
200
+ * @propertyOf angular.Module
201
+ * @returns {string} Name of the module.
202
+ * @description
203
+ */
204
+ name: name,
205
+
206
+
207
+ /**
208
+ * @ngdoc method
209
+ * @name angular.Module#provider
210
+ * @methodOf angular.Module
211
+ * @param {string} name service name
212
+ * @param {Function} providerType Construction function for creating new instance of the
213
+ * service.
214
+ * @description
215
+ * See {@link AUTO.$provide#provider $provide.provider()}.
216
+ */
217
+ provider: invokeLater('$provide', 'provider'),
218
+
219
+ /**
220
+ * @ngdoc method
221
+ * @name angular.Module#factory
222
+ * @methodOf angular.Module
223
+ * @param {string} name service name
224
+ * @param {Function} providerFunction Function for creating new instance of the service.
225
+ * @description
226
+ * See {@link AUTO.$provide#factory $provide.factory()}.
227
+ */
228
+ factory: invokeLater('$provide', 'factory'),
229
+
230
+ /**
231
+ * @ngdoc method
232
+ * @name angular.Module#service
233
+ * @methodOf angular.Module
234
+ * @param {string} name service name
235
+ * @param {Function} constructor A constructor function that will be instantiated.
236
+ * @description
237
+ * See {@link AUTO.$provide#service $provide.service()}.
238
+ */
239
+ service: invokeLater('$provide', 'service'),
240
+
241
+ /**
242
+ * @ngdoc method
243
+ * @name angular.Module#value
244
+ * @methodOf angular.Module
245
+ * @param {string} name service name
246
+ * @param {*} object Service instance object.
247
+ * @description
248
+ * See {@link AUTO.$provide#value $provide.value()}.
249
+ */
250
+ value: invokeLater('$provide', 'value'),
251
+
252
+ /**
253
+ * @ngdoc method
254
+ * @name angular.Module#constant
255
+ * @methodOf angular.Module
256
+ * @param {string} name constant name
257
+ * @param {*} object Constant value.
258
+ * @description
259
+ * Because the constant are fixed, they get applied before other provide methods.
260
+ * See {@link AUTO.$provide#constant $provide.constant()}.
261
+ */
262
+ constant: invokeLater('$provide', 'constant', 'unshift'),
263
+
264
+ /**
265
+ * @ngdoc method
266
+ * @name angular.Module#animation
267
+ * @methodOf angular.Module
268
+ * @param {string} name animation name
269
+ * @param {Function} animationFactory Factory function for creating new instance of an
270
+ * animation.
271
+ * @description
272
+ *
273
+ * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.
274
+ *
275
+ *
276
+ * Defines an animation hook that can be later used with
277
+ * {@link ngAnimate.$animate $animate} service and directives that use this service.
278
+ *
279
+ * <pre>
280
+ * module.animation('.animation-name', function($inject1, $inject2) {
281
+ * return {
282
+ * eventName : function(element, done) {
283
+ * //code to run the animation
284
+ * //once complete, then run done()
285
+ * return function cancellationFunction(element) {
286
+ * //code to cancel the animation
287
+ * }
288
+ * }
289
+ * }
290
+ * })
291
+ * </pre>
292
+ *
293
+ * See {@link ngAnimate.$animateProvider#register $animateProvider.register()} and
294
+ * {@link ngAnimate ngAnimate module} for more information.
295
+ */
296
+ animation: invokeLater('$animateProvider', 'register'),
297
+
298
+ /**
299
+ * @ngdoc method
300
+ * @name angular.Module#filter
301
+ * @methodOf angular.Module
302
+ * @param {string} name Filter name.
303
+ * @param {Function} filterFactory Factory function for creating new instance of filter.
304
+ * @description
305
+ * See {@link ng.$filterProvider#register $filterProvider.register()}.
306
+ */
307
+ filter: invokeLater('$filterProvider', 'register'),
308
+
309
+ /**
310
+ * @ngdoc method
311
+ * @name angular.Module#controller
312
+ * @methodOf angular.Module
313
+ * @param {string|Object} name Controller name, or an object map of controllers where the
314
+ * keys are the names and the values are the constructors.
315
+ * @param {Function} constructor Controller constructor function.
316
+ * @description
317
+ * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
318
+ */
319
+ controller: invokeLater('$controllerProvider', 'register'),
320
+
321
+ /**
322
+ * @ngdoc method
323
+ * @name angular.Module#directive
324
+ * @methodOf angular.Module
325
+ * @param {string|Object} name Directive name, or an object map of directives where the
326
+ * keys are the names and the values are the factories.
327
+ * @param {Function} directiveFactory Factory function for creating new instance of
328
+ * directives.
329
+ * @description
330
+ * See {@link ng.$compileProvider#methods_directive $compileProvider.directive()}.
331
+ */
332
+ directive: invokeLater('$compileProvider', 'directive'),
333
+
334
+ /**
335
+ * @ngdoc method
336
+ * @name angular.Module#config
337
+ * @methodOf angular.Module
338
+ * @param {Function} configFn Execute this function on module load. Useful for service
339
+ * configuration.
340
+ * @description
341
+ * Use this method to register work which needs to be performed on module loading.
342
+ */
343
+ config: config,
344
+
345
+ /**
346
+ * @ngdoc method
347
+ * @name angular.Module#run
348
+ * @methodOf angular.Module
349
+ * @param {Function} initializationFn Execute this function after injector creation.
350
+ * Useful for application initialization.
351
+ * @description
352
+ * Use this method to register work which should be performed when the injector is done
353
+ * loading all modules.
354
+ */
355
+ run: function(block) {
356
+ runBlocks.push(block);
357
+ return this;
358
+ }
359
+ };
360
+
361
+ if (configFn) {
362
+ config(configFn);
363
+ }
364
+
365
+ return moduleInstance;
366
+
367
+ /**
368
+ * @param {string} provider
369
+ * @param {string} method
370
+ * @param {String=} insertMethod
371
+ * @returns {angular.Module}
372
+ */
373
+ function invokeLater(provider, method, insertMethod) {
374
+ return function() {
375
+ invokeQueue[insertMethod || 'push']([provider, method, arguments]);
376
+ return moduleInstance;
377
+ };
378
+ }
379
+ });
380
+ };
381
+ });
382
+
383
+ }
384
+
385
+ setupModuleLoader(window);
386
+ })(window);
387
+
388
+ /**
389
+ * Closure compiler type information
390
+ *
391
+ * @typedef { {
392
+ * requires: !Array.<string>,
393
+ * invokeQueue: !Array.<Array.<*>>,
394
+ *
395
+ * service: function(string, Function):angular.Module,
396
+ * factory: function(string, Function):angular.Module,
397
+ * value: function(string, *):angular.Module,
398
+ *
399
+ * filter: function(string, Function):angular.Module,
400
+ *
401
+ * init: function(Function):angular.Module
402
+ * } }
403
+ */
404
+ angular.Module;
405
+