ocLazyLoad.core.min.js 8.0 KB

12
  1. !function(e,n){"use strict";var o=["ng","oc.lazyLoad"],r={},i=[],t=[],u=[],a=[],f=e.noop,s={},d=[],c=e.module("oc.lazyLoad",["ng"]);c.provider("$ocLazyLoad",["$controllerProvider","$provide","$compileProvider","$filterProvider","$injector","$animateProvider",function(c,l,p,m,v,y){function L(n,r,i){if(r){var t,a,c,l=[];for(t=r.length-1;t>=0;t--)if(a=r[t],e.isString(a)||(a=$(a)),a&&d.indexOf(a)===-1&&(!w[a]||u.indexOf(a)!==-1)){var h=o.indexOf(a)===-1;if(c=g(a),h&&(o.push(a),L(n,c.requires,i)),c._runBlocks.length>0)for(s[a]=[];c._runBlocks.length>0;)s[a].push(c._runBlocks.shift());e.isDefined(s[a])&&(h||i.rerun)&&(l=l.concat(s[a])),_(n,c._invokeQueue,a,i.reconfig),_(n,c._configBlocks,a,i.reconfig),f(h?"ocLazyLoad.moduleLoaded":"ocLazyLoad.moduleReloaded",a),r.pop(),d.push(a)}var p=n.getInstanceInjector();e.forEach(l,function(e){p.invoke(e)})}}function E(n,o){function i(n,o){var r,i=!0;return o.length&&(r=t(n),e.forEach(o,function(e){i=i&&t(e)!==r})),i}function t(n){return e.isArray(n)?M(n.toString()):e.isObject(n)?M(A(n)):e.isDefined(n)&&null!==n?M(n.toString()):n}var u=n[2][0],a=n[1],s=!1;e.isUndefined(r[o])&&(r[o]={}),e.isUndefined(r[o][a])&&(r[o][a]={});var d=function(e,n){r[o][a].hasOwnProperty(e)||(r[o][a][e]=[]),i(n,r[o][a][e])&&(s=!0,r[o][a][e].push(n),f("ocLazyLoad.componentLoaded",[o,a,e]))};if(e.isString(u))d(u,n[2][1]);else{if(!e.isObject(u))return!1;e.forEach(u,function(n,o){e.isString(n)?d(n,u[1]):d(o,n)})}return s}function _(n,o,r,t){if(o){var u,a,f,s;for(u=0,a=o.length;u<a;u++)if(f=o[u],e.isArray(f)){if(null!==n){if(!n.hasOwnProperty(f[0]))throw new Error("unsupported provider "+f[0]);s=n[f[0]]}var d=E(f,r);if("invoke"!==f[1])d&&e.isDefined(s)&&s[f[1]].apply(s,f[2]);else{var c=function(n){var o=i.indexOf(r+"-"+n);(o===-1||t)&&(o===-1&&i.push(r+"-"+n),e.isDefined(s)&&s[f[1]].apply(s,f[2]))};if(e.isFunction(f[2][0]))c(f[2][0]);else if(e.isArray(f[2][0]))for(var l=0,h=f[2][0].length;l<h;l++)e.isFunction(f[2][0][l])&&c(f[2][0][l])}}}}function $(n){var o=null;return e.isString(n)?o=n:e.isObject(n)&&n.hasOwnProperty("name")&&e.isString(n.name)&&(o=n.name),o}function O(n){if(!e.isString(n))return!1;try{return g(n)}catch(e){if(/No module/.test(e)||e.message.indexOf("$injector:nomod")>-1)return!1}}var w={},x={$controllerProvider:c,$compileProvider:p,$filterProvider:m,$provide:l,$injector:v,$animateProvider:y},b=!1,j=!1,S=[],D={};S.push=function(e){this.indexOf(e)===-1&&Array.prototype.push.apply(this,arguments)},this.config=function(n){e.isDefined(n.modules)&&(e.isArray(n.modules)?e.forEach(n.modules,function(e){w[e.name]=e}):w[n.modules.name]=n.modules),e.isDefined(n.debug)&&(b=n.debug),e.isDefined(n.events)&&(j=n.events)},this._init=function(r){if(0===t.length){var i=[r],u=["ng:app","ng-app","x-ng-app","data-ng-app"],f=/\sng[:\-]app(:\s*([\w\d_]+);?)?\s/,s=function(e){return e&&i.push(e)};e.forEach(u,function(n){u[n]=!0,s(document.getElementById(n)),n=n.replace(":","\\:"),"undefined"!=typeof r[0]&&r[0].querySelectorAll&&(e.forEach(r[0].querySelectorAll("."+n),s),e.forEach(r[0].querySelectorAll("."+n+"\\:"),s),e.forEach(r[0].querySelectorAll("["+n+"]"),s))}),e.forEach(i,function(n){if(0===t.length){var o=" "+r.className+" ",i=f.exec(o);i?t.push((i[2]||"").replace(/\s+/g,",")):e.forEach(n.attributes,function(e){0===t.length&&u[e.name]&&t.push(e.value)})}})}0!==t.length||(n.jasmine||n.mocha)&&e.isDefined(e.mock)||console.error("No module found during bootstrap, unable to init ocLazyLoad. You should always use the ng-app directive or angular.boostrap when you use ocLazyLoad.");var d=function n(r){if(o.indexOf(r)===-1){o.push(r);var i=e.module(r);_(null,i._invokeQueue,r),_(null,i._configBlocks,r),e.forEach(i.requires,n)}};e.forEach(t,function(e){d(e)}),t=[],a.pop()};var A=function(n){try{return JSON.stringify(n)}catch(r){var o=[];return JSON.stringify(n,function(n,r){if(e.isObject(r)&&null!==r){if(o.indexOf(r)!==-1)return;o.push(r)}return r})}},M=function(e){var n,o,r,i=0;if(0==e.length)return i;for(n=0,r=e.length;n<r;n++)o=e.charCodeAt(n),i=(i<<5)-i+o,i|=0;return i};this.$get=["$log","$rootElement","$rootScope","$cacheFactory","$q",function(n,i,u,s,c){function l(e){var o=c.defer();return n.error(e.message),o.reject(e),o.promise}var p,m=s("ocLazyLoad");return b||(n={},n.error=e.noop,n.warn=e.noop,n.info=e.noop),x.getInstanceInjector=function(){return p?p:p=i.data("$injector")||e.injector()},f=function(e,o){j&&u.$broadcast(e,o),b&&n.info(e,o)},{_broadcast:f,_$log:n,_getFilesCache:function(){return m},toggleWatch:function(e){e?a.push(!0):a.pop()},getModuleConfig:function(n){if(!e.isString(n))throw new Error("You need to give the name of the module to get");return w[n]?e.copy(w[n]):null},setModuleConfig:function(n){if(!e.isObject(n))throw new Error("You need to give the module config object to set");return w[n.name]=n,n},getModules:function(){return o},isLoaded:function(n){var r=function(e){var n=o.indexOf(e)>-1;return n||(n=!!O(e)),n};if(e.isString(n)&&(n=[n]),e.isArray(n)){var i,t;for(i=0,t=n.length;i<t;i++)if(!r(n[i]))return!1;return!0}throw new Error("You need to define the module(s) name(s)")},_getModuleName:$,_getModule:function(e){try{return g(e)}catch(n){throw(/No module/.test(n)||n.message.indexOf("$injector:nomod")>-1)&&(n.message='The module "'+A(e)+'" that you are trying to load does not exist. '+n.message),n}},moduleExists:O,_loadDependencies:function(n,o){var r,i,t,u=[],a=this;if(n=a._getModuleName(n),null===n)return c.when();try{r=a._getModule(n)}catch(e){return l(e)}return i=a.getRequires(r),e.forEach(i,function(r){if(e.isString(r)){var i=a.getModuleConfig(r);if(null===i)return void S.push(r);r=i,i.name=void 0}if(a.moduleExists(r.name))return t=r.files.filter(function(e){return a.getModuleConfig(r.name).files.indexOf(e)<0}),0!==t.length&&a._$log.warn('Module "',n,'" attempted to redefine configuration for dependency. "',r.name,'"\n Additional Files Loaded:',t),e.isDefined(a.filesLoader)?void u.push(a.filesLoader(r,o).then(function(){return a._loadDependencies(r)})):l(new Error("Error: New dependencies need to be loaded from external files ("+r.files+"), but no loader has been defined."));if(e.isArray(r)){var f=[];e.forEach(r,function(e){var n=a.getModuleConfig(e);null===n?f.push(e):n.files&&(f=f.concat(n.files))}),f.length>0&&(r={files:f})}else e.isObject(r)&&r.hasOwnProperty("name")&&r.name&&(a.setModuleConfig(r),S.push(r.name));if(e.isDefined(r.files)&&0!==r.files.length){if(!e.isDefined(a.filesLoader))return l(new Error('Error: the module "'+r.name+'" is defined in external files ('+r.files+"), but no loader has been defined."));u.push(a.filesLoader(r,o).then(function(){return a._loadDependencies(r)}))}}),c.all(u)},inject:function(n){var o=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=!(arguments.length<=2||void 0===arguments[2])&&arguments[2],i=this,u=c.defer();if(e.isDefined(n)&&null!==n){if(e.isArray(n)){var a=[];return e.forEach(n,function(e){a.push(i.inject(e,o,r))}),c.all(a)}i._addToLoadList(i._getModuleName(n),!0,r)}if(t.length>0){var f=t.slice(),s=function e(n){S.push(n),D[n]=u.promise,i._loadDependencies(n,o).then(function(){try{d=[],L(x,S,o)}catch(e){return i._$log.error(e.message),void u.reject(e)}t.length>0?e(t.shift()):u.resolve(f)},function(e){u.reject(e)})};s(t.shift())}else{if(o&&o.name&&D[o.name])return D[o.name];u.resolve()}return u.promise},getRequires:function(n){var r=[];return e.forEach(n.requires,function(e){o.indexOf(e)===-1&&r.push(e)}),r},_invokeQueue:_,_registerInvokeList:E,_register:L,_addToLoadList:h,_unregister:function(n){e.isDefined(n)&&e.isArray(n)&&e.forEach(n,function(e){r[e]=void 0})}}}],this._init(e.element(n.document))}]);var l=e.bootstrap;e.bootstrap=function(n,c,g){return o=["ng","oc.lazyLoad"],r={},i=[],t=[],u=[],a=[],f=e.noop,s={},d=[],e.forEach(c.slice(),function(e){h(e,!0,!0)}),l(n,c,g)};var h=function(n,o,r){(a.length>0||o)&&e.isString(n)&&t.indexOf(n)===-1&&(t.push(n),r&&u.push(n))},g=e.module;e.module=function(e,n,o){return h(e,!1,!0),g(e,n,o)},"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="oc.lazyLoad")}(angular,window);
  2. //# sourceMappingURL=ocLazyLoad.core.min.js.map