upgrade to AnuglarJS 0.10.6 bubblewrap-cape
[angular-drzb] / app / lib / angular / angular-loader.js
1 /**
2  * @license AngularJS v0.10.6-5cdfe45a
3  * (c) 2010-2012 AngularJS http://angularjs.org
4  * License: MIT
5  */
6
7 (
8
9 /**
10  * @ngdoc interface
11  * @name angular.Module
12  * @description
13  *
14  * Interface for configuring angular {@link angular.module modules}.
15  */
16
17 function setupModuleLoader(window) {
18
19   function ensure(obj, name, factory) {
20     return obj[name] || (obj[name] = factory());
21   }
22
23   return ensure(ensure(window, 'angular', Object), 'module', function() {
24     /** @type {Object.<string, angular.Module>} */
25     var modules = {};
26
27     /**
28      * @ngdoc function
29      * @name angular.module
30      * @description
31      *
32      * The `angular.module` is a global place for registering angular modules. All modules
33      * (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
34      *
35      * # Module
36      *
37      * A module is a collocation of services, directives, filters, and configure information. Module is used to configure the,
38      * {@link angular.module.AUTO.$injector $injector}.
39      *
40      * <pre>
41      * // Create a new module
42      * var myModule = angular.module('myModule', []);
43      *
44      * // configure a new service
45      * myModule.value('appName', 'MyCoolApp');
46      *
47      * // configure existing services inside initialization blocks.
48      * myModule.init(function($locationProvider) {
49      *   // Configure existing providers
50      *   $locationProvider.hashPrefix = '!';
51      * });
52      * </pre>
53      *
54      * Then you can load your module like this:
55      *
56      * <pre>
57      * var injector = angular.injector(['ng', 'MyModule'])
58      * </pre>
59      *
60      * @param {!string} name The name of the module to create or retrieve.
61      * @param {Array.<string>=} requires If specified then new module is being created. If unspecified then the
62      *        the module is being retrieved for further configuration.
63      * @param {Function} initFn Option configuration function for the module. Same as
64      *        {@link angular.Module#init Module.init()}.
65      * @return {angular.Module}
66      */
67     return function module(name, requires, configFn) {
68       if (requires && modules.hasOwnProperty(name)) {
69         modules[name] = null;
70       }
71       return ensure(modules, name, function() {
72         if (!requires) {
73           throw Error('No module: ' + name);
74         }
75
76         /** @type {!Array.<Array.<*>>} */
77         var invokeQueue = [];
78
79         /** @type {!Array.<Function>} */
80         var runBlocks = [];
81
82         var config = invokeLater('$injector', 'invoke');
83
84         /** @type {angular.Module} */
85         var moduleInstance = {
86           // Private state
87           _invokeQueue: invokeQueue,
88           _runBlocks: runBlocks,
89
90           /**
91            * @ngdoc property
92            * @name angular.Module#requires
93            * @propertyOf angular.Module
94            * @returns {Array.<string>} List of module names which must be loaded before this module.
95            * @description
96            * Holds the list of modules which the injector will load before the current module is loaded.
97            */
98           requires: requires,
99
100           /**
101            * @ngdoc property
102            * @name angular.Module#name
103            * @propertyOf angular.Module
104            * @returns {string} Name of the module.
105            * @description
106            */
107           name: name,
108
109
110           /**
111            * @ngdoc method
112            * @name angular.Module#service
113            * @methodOf angular.Module
114            * @param {string} name service name
115            * @param {Function} providerType Construction function for creating new instance of the service.
116            * @description
117            * See {@link angular.module.AUTO.$provide#service $provide.service()}.
118            */
119           service: invokeLater('$provide', 'service'),
120
121           /**
122            * @ngdoc method
123            * @name angular.Module#factory
124            * @methodOf angular.Module
125            * @param {string} name service name
126            * @param {Function} providerFunction Function for creating new instance of the service.
127            * @description
128            * See {@link angular.module.AUTO.$provide#service $provide.factory()}.
129            */
130           factory: invokeLater('$provide', 'factory'),
131
132           /**
133            * @ngdoc method
134            * @name angular.Module#value
135            * @methodOf angular.Module
136            * @param {string} name service name
137            * @param {*} object Service instance object.
138            * @description
139            * See {@link angular.module.AUTO.$provide#value $provide.value()}.
140            */
141           value: invokeLater('$provide', 'value'),
142
143           /**
144            * @ngdoc method
145            * @name angular.Module#filter
146            * @methodOf angular.Module
147            * @param {string} name filterr name
148            * @param {Function} filterFactory Factory function for creating new instance of filter.
149            * @description
150            * See {@link angular.module.ng.$filterProvider#register $filterProvider.register()}.
151            */
152           filter: invokeLater('$filterProvider', 'register'),
153
154           /**
155            * @ngdoc method
156            * @name angular.Module#config
157            * @methodOf angular.Module
158            * @param {Function} initializationFn Execute this function on module load. Useful for
159            *    service configuration.
160            * @description
161            * Use this method to register work which needs to be performed on module loading.
162            */
163           config: config,
164
165           /**
166            * @ngdoc method
167            * @name angular.Module#run
168            * @methodOf angular.Module
169            * @param {Function} initializationFn Execute this function after injector creation.
170            *    Useful for application initialization.
171            * @description
172            * Use this method to register work which needs to be performed on module loading.
173            */
174           run: function(block) {
175             runBlocks.push(block);
176             return this;
177           }
178         };
179
180         if (configFn) {
181           config(configFn);
182         }
183
184         return  moduleInstance;
185
186         /**
187          * @param {string} provider
188          * @param {string} method
189          * @returns {angular.Module}
190          */
191         function invokeLater(provider, method) {
192           return function() {
193             invokeQueue.push([provider, method, arguments]);
194             return moduleInstance;
195           }
196         }
197       });
198     };
199   });
200
201 }
202 )(window);
203
204 /**
205  * Closure compiler type information
206  *
207  * @typedef { {
208  *   requires: !Array.<string>,
209  *   invokeQueue: !Array.<Array.<*>>,
210  *
211  *   service: function(string, Function):angular.Module,
212  *   factory: function(string, Function):angular.Module,
213  *   value: function(string, *):angular.Module,
214  *
215  *   filter: function(string, Function):angular.Module,
216  *
217  *   init: function(Function):angular.Module
218  * } }
219  */
220 angular.Module;
221