js.libs.angularjs.oc-lazy-load.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openmuc-webui-base Show documentation
Show all versions of openmuc-webui-base Show documentation
WebUI base for the OpenMUC framework.
/**
* oclazyload - Load modules on demand (lazy load) with angularJS
* @version v0.6.3
* @link https://github.com/ocombe/ocLazyLoad
* @license MIT
* @author Olivier Combe
*/
!function(){"use strict";function e(e){var n=[];return angular.forEach(e.requires,function(e){-1===l.indexOf(e)&&n.push(e)}),n}function n(e){if(!angular.isString(e))return!1;try{return L(e)}catch(n){if(/No module/.test(n)||n.message.indexOf("$injector:nomod")>-1)return!1}}function r(e){try{return L(e)}catch(n){throw(/No module/.test(n)||n.message.indexOf("$injector:nomod")>-1)&&(n.message='The module "'+e+'" that you are trying to load does not exist. '+n.message),n}}function a(e,n,r,a){if(n){var t,i,u,l;for(t=0,i=n.length;i>t;t++)if(u=n[t],angular.isArray(u)){if(null!==e){if(!e.hasOwnProperty(u[0]))throw new Error("unsupported provider "+u[0]);l=e[u[0]]}var s=o(u,r);if("invoke"!==u[1])s&&angular.isDefined(l)&&l[u[1]].apply(l,u[2]);else{var c=function(e){var n=f.indexOf(r+"-"+e);(-1===n||a)&&(-1===n&&f.push(r+"-"+e),angular.isDefined(l)&&l[u[1]].apply(l,u[2]))};if(angular.isFunction(u[2][0]))c(u[2][0]);else if(angular.isArray(u[2][0]))for(var d=0,g=u[2][0].length;g>d;d++)angular.isFunction(u[2][0][d])&&c(u[2][0][d])}}}}function t(e,n,r){if(n){var o,u,s,f=[];for(o=n.length-1;o>=0;o--)if(u=n[o],"string"!=typeof u&&(u=i(u)),u&&-1===c.indexOf(u)){var g=-1===l.indexOf(u);if(s=L(u),g&&(l.push(u),t(e,s.requires,r)),s._runBlocks.length>0)for(d[u]=[];s._runBlocks.length>0;)d[u].push(s._runBlocks.shift());angular.isDefined(d[u])&&(g||r.rerun)&&(f=f.concat(d[u])),a(e,s._invokeQueue,u,r.reconfig),a(e,s._configBlocks,u,r.reconfig),h(g?"ocLazyLoad.moduleLoaded":"ocLazyLoad.moduleReloaded",u),n.pop(),c.push(u)}var p=e.getInstanceInjector();angular.forEach(f,function(e){p.invoke(e)})}}function o(e,n){var r=e[2][0],a=e[1],t=!1;angular.isUndefined(s[n])&&(s[n]={}),angular.isUndefined(s[n][a])&&(s[n][a]={});var o=function(e,r){t=!0,s[n][a][e].push(r),h("ocLazyLoad.componentLoaded",[n,a,e])},i=function(e){return angular.isArray(e)?w(e.toString()):angular.isObject(e)?w(j(e)):angular.isDefined(e)&&null!==e?w(e.toString()):e};if(angular.isString(r))angular.isUndefined(s[n][a][r])&&(s[n][a][r]=[]),-1===s[n][a][r].indexOf(i(e[2][1]))&&o(r,i(e[2][1]));else{if(!angular.isObject(r))return!1;angular.forEach(r,function(e){angular.isString(e)&&(angular.isUndefined(s[n][a][e])&&(s[n][a][e]=[]),-1===s[n][a][e].indexOf(i(r[1]))&&o(e,i(r[1])))})}return t}function i(e){var n=null;return angular.isString(e)?n=e:angular.isObject(e)&&e.hasOwnProperty("name")&&angular.isString(e.name)&&(n=e.name),n}function u(e){if(0===p.length){var n=[e],r=["ng:app","ng-app","x-ng-app","data-ng-app"],t=/\sng[:\-]app(:\s*([\w\d_]+);?)?\s/,o=function(e){return e&&n.push(e)};angular.forEach(r,function(n){r[n]=!0,o(document.getElementById(n)),n=n.replace(":","\\:"),e[0].querySelectorAll&&(angular.forEach(e[0].querySelectorAll("."+n),o),angular.forEach(e[0].querySelectorAll("."+n+"\\:"),o),angular.forEach(e[0].querySelectorAll("["+n+"]"),o))}),angular.forEach(n,function(n){if(0===p.length){var a=" "+e.className+" ",o=t.exec(a);o?p.push((o[2]||"").replace(/\s+/g,",")):angular.forEach(n.attributes,function(e){0===p.length&&r[e.name]&&p.push(e.value)})}})}0!==p.length||(window.jasmine||window.mocha)&&angular.isDefined(angular.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 i=function u(e){if(-1===l.indexOf(e)){l.push(e);var n=angular.module(e);a(null,n._invokeQueue,e),a(null,n._configBlocks,e),angular.forEach(n.requires,u)}};angular.forEach(p,function(e){i(e)}),p=[],m.pop()}var l=["ng"],s={},f=[],c=[],d={},g=angular.module("oc.lazyLoad",["ng"]),h=angular.noop,p=[],m=[!0];g.provider("$ocLazyLoad",["$controllerProvider","$provide","$compileProvider","$filterProvider","$injector","$animateProvider",function(a,o,s,f,d,g){var v,L,w,j={},O={$controllerProvider:a,$compileProvider:s,$filterProvider:f,$provide:o,$injector:d,$animateProvider:g},E=document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0],x=!1,b=!1;u(angular.element(window.document)),this.$get=["$log","$q","$templateCache","$http","$rootElement","$rootScope","$cacheFactory","$interval",function(a,o,u,s,f,d,g,$){var S,D=g("ocLazyLoad"),z=!1,A=!1;x||(a={},a.error=angular.noop,a.warn=angular.noop,a.info=angular.noop),O.getInstanceInjector=function(){return S?S:S=f.data("$injector")||angular.injector()},h=function(e,n){b&&d.$broadcast(e,n),x&&a.info(e,n)};var P=function(e,n,r){var a,t,i=o.defer(),u=function(e){var n=(new Date).getTime();return e.indexOf("?")>=0?"&"===e.substring(0,e.length-1)?e+"_dc="+n:e+"&_dc="+n:e+"?_dc="+n};switch(angular.isUndefined(D.get(n))&&D.put(n,i.promise),e){case"css":a=document.createElement("link"),a.type="text/css",a.rel="stylesheet",a.href=r.cache===!1?u(n):n;break;case"js":a=document.createElement("script"),a.src=r.cache===!1?u(n):n;break;default:i.reject(new Error('Requested type "'+e+'" is not known. Could not inject "'+n+'"'))}a.onload=a.onreadystatechange=function(){a.readyState&&!/^c|loade/.test(a.readyState)||t||(a.onload=a.onreadystatechange=null,t=1,h("ocLazyLoad.fileLoaded",n),i.resolve())},a.onerror=function(){i.reject(new Error("Unable to load "+n))},a.async=r.serie?0:1;var l=E.lastChild;if(r.insertBefore){var s=angular.element(r.insertBefore);s&&s.length>0&&(l=s[0])}if(E.insertBefore(a,l),"css"==e){if(!z){var f=navigator.userAgent.toLowerCase();if(/iP(hone|od|ad)/.test(navigator.platform)){var c=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),d=parseFloat([parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3]||0,10)].join("."));A=6>d}else if(f.indexOf("android")>-1){var g=parseFloat(f.slice(f.indexOf("android")+8));A=4.4>g}else if(f.indexOf("safari")>-1&&-1==f.indexOf("chrome")){var p=parseFloat(f.match(/version\/([\.\d]+)/i)[1]);A=6>p}}if(A)var m=1e3,v=$(function(){try{a.sheet.cssRules,$.cancel(v),a.onload()}catch(e){--m<=0&&a.onerror()}},20)}return i.promise};angular.isUndefined(v)&&(v=function(e,n,r){var a=[];angular.forEach(e,function(e){a.push(P("js",e,r))}),o.all(a).then(function(){n()},function(e){n(e)})},v.ocLazyLoadLoader=!0),angular.isUndefined(L)&&(L=function(e,n,r){var a=[];angular.forEach(e,function(e){a.push(P("css",e,r))}),o.all(a).then(function(){n()},function(e){n(e)})},L.ocLazyLoadLoader=!0),angular.isUndefined(w)&&(w=function(e,n,r){var a=[];return angular.forEach(e,function(e){var n=o.defer();a.push(n.promise),s.get(e,r).success(function(r){angular.isString(r)&&r.length>0&&angular.forEach(angular.element(r),function(e){"SCRIPT"===e.nodeName&&"text/ng-template"===e.type&&u.put(e.id,e.innerHTML)}),angular.isUndefined(D.get(e))&&D.put(e,!0),n.resolve()}).error(function(r){n.reject(new Error('Unable to load template file "'+e+'": '+r))})}),o.all(a).then(function(){n()},function(e){n(e)})},w.ocLazyLoadLoader=!0);var k=function M(e,n){var r=[],t=[],i=[],u=[],l=null;m.push(!0),angular.extend(n||{},e);var s=function(e){var o,s=null;if("object"==typeof e&&(s=e.type,e=e.path),l=D.get(e),angular.isUndefined(l)||n.cache===!1){if(null!==(o=/^(css|less|html|htm|js)?(?=!)/.exec(e))&&(s=o[1],e=e.substr(o[1].length+1,e.length)),!s)if(null!==(o=/[.](css|less|html|htm|js)?(\?.*)?$/.exec(e)))s=o[1];else{if(v.hasOwnProperty("ocLazyLoadLoader")||!v.hasOwnProperty("load"))return void a.error("File type could not be determined. "+e);s="js"}"css"!==s&&"less"!==s||-1!==r.indexOf(e)?"html"!==s&&"htm"!==s||-1!==t.indexOf(e)?"js"===s||-1===i.indexOf(e)?i.push(e):a.error("File type is not valid. "+e):t.push(e):r.push(e)}else l&&u.push(l)};if(n.serie?s(n.files.shift()):angular.forEach(n.files,function(e){s(e)}),r.length>0){var f=o.defer();L(r,function(e){angular.isDefined(e)&&L.hasOwnProperty("ocLazyLoadLoader")?(a.error(e),f.reject(e)):f.resolve()},n),u.push(f.promise)}if(t.length>0){var c=o.defer();w(t,function(e){angular.isDefined(e)&&w.hasOwnProperty("ocLazyLoadLoader")?(a.error(e),c.reject(e)):c.resolve()},n),u.push(c.promise)}if(i.length>0){var d=o.defer();v(i,function(e){angular.isDefined(e)&&v.hasOwnProperty("ocLazyLoadLoader")?(a.error(e),d.reject(e)):d.resolve()},n),u.push(d.promise)}return n.serie&&n.files.length>0?o.all(u).then(function(){return M(e,n)}):o.all(u)["finally"](function(e){return m.pop(),e})};return{getModuleConfig:function(e){if(!angular.isString(e))throw new Error("You need to give the name of the module to get");return j[e]?j[e]:null},setModuleConfig:function(e){if(!angular.isObject(e))throw new Error("You need to give the module config object to set");return j[e.name]=e,e},getModules:function(){return l},isLoaded:function(e){var r=function(e){var r=l.indexOf(e)>-1;return r||(r=!!n(e)),r};if(angular.isString(e)&&(e=[e]),angular.isArray(e)){var a,t;for(a=0,t=e.length;t>a;a++)if(!r(e[a]))return!1;return!0}throw new Error("You need to define the module(s) name(s)")},load:function(u,l){var s,f=this,d=null,g=[],h=[],v=o.defer();if(angular.isUndefined(l)&&(l={}),angular.isArray(u))return angular.forEach(u,function(e){e&&h.push(f.load(e,l))}),o.all(h).then(function(){v.resolve(u)},function(e){v.reject(e)}),v.promise;if("string"==typeof u?(d=f.getModuleConfig(u),d||(d={files:[u]})):"object"==typeof u&&(d=angular.isDefined(u.path)&&angular.isDefined(u.type)?{files:[u]}:f.setModuleConfig(u)),null===d){var L=i(u);return s='Module "'+(L||"unknown")+'" is not configured, cannot load.',a.error(s),v.reject(new Error(s)),v.promise}angular.isDefined(d.template)&&(angular.isUndefined(d.files)&&(d.files=[]),angular.isString(d.template)?d.files.push(d.template):angular.isArray(d.template)&&d.files.concat(d.template)),g.push=function(e){-1===this.indexOf(e)&&Array.prototype.push.apply(this,arguments)};var w={};angular.extend(w,l,d);var j=function E(t){var u,l,s,c,d=[];if(u=i(t),null===u)return o.when();try{l=r(u)}catch(h){var p=o.defer();return a.error(h.message),p.reject(h),p.promise}return s=e(l),angular.forEach(s,function(e){if("string"==typeof e){var r=f.getModuleConfig(e);if(null===r)return void g.push(e);e=r}return n(e.name)?void("string"!=typeof t&&(c=e.files.filter(function(n){return f.getModuleConfig(e.name).files.indexOf(n)<0}),0!==c.length&&a.warn('Module "',u,'" attempted to redefine configuration for dependency. "',e.name,'"\n Additional Files Loaded:',c),d.push(k(e.files,w).then(function(){return E(e)})))):(angular.isArray(e)?e={files:e}:"object"==typeof e&&e.hasOwnProperty("name")&&e.name&&(f.setModuleConfig(e),g.push(e.name)),void(e.hasOwnProperty("files")&&0!==e.files.length&&e.files&&d.push(k(e,w).then(function(){return E(e)}))))}),o.all(d)};return angular.isUndefined(d.files)&&angular.isDefined(d.name)&&n(d.name)&&(m.push(!0),y(d.name),m.pop()),k(d,w).then(function(){if(0===p.length)v.resolve(u);else{var e=function n(e){g.push(e),j(e).then(function(){try{c=[],t(O,g,w)}catch(e){return a.error(e.message),void v.reject(e)}p.length>0?n(p.shift()):v.resolve(u)},function(e){v.reject(e)})};e(p.shift())}},function(e){v.reject(e)}),v.promise}}}],this.config=function(e){if(angular.isDefined(e.jsLoader)||angular.isDefined(e.asyncLoader)){if(!angular.isFunction(e.jsLoader||e.asyncLoader))throw"The js loader needs to be a function";v=e.jsLoader||e.asyncLoader}if(angular.isDefined(e.cssLoader)){if(!angular.isFunction(e.cssLoader))throw"The css loader needs to be a function";L=e.cssLoader}if(angular.isDefined(e.templatesLoader)){if(!angular.isFunction(e.templatesLoader))throw"The template loader needs to be a function";w=e.templatesLoader}angular.isDefined(e.modules)&&(angular.isArray(e.modules)?angular.forEach(e.modules,function(e){j[e.name]=e}):j[e.modules.name]=e.modules),angular.isDefined(e.debug)&&(x=e.debug),angular.isDefined(e.events)&&(b=e.events)}}]),g.directive("ocLazyLoad",["$ocLazyLoad","$compile","$animate","$parse",function(e,n,r,a){return{restrict:"A",terminal:!0,priority:1e3,compile:function(t){var o=t[0].innerHTML;return t.html(""),function(t,i,u){var l=a(u.ocLazyLoad);t.$watch(function(){return l(t)||u.ocLazyLoad},function(a){angular.isDefined(a)&&e.load(a).then(function(){r.enter(n(o)(t),null,i)})},!0)}}}}]);var v=angular.bootstrap;angular.bootstrap=function(e,n,r){return angular.forEach(n.slice(),function(e){y(e)}),v(e,n,r)};var y=function(e){m.length>0&&angular.isString(e)&&-1===p.indexOf(e)&&p.push(e)},L=angular.module;angular.module=function(e,n,r){return y(e),L(e,n,r)};var w=function(e){var n,r,a,t=0;if(0==e.length)return t;for(n=0,a=e.length;a>n;n++)r=e.charCodeAt(n),t=(t<<5)-t+r,t|=0;return t},j=function(e){var n=[];return JSON.stringify(e,function(e,r){if("object"==typeof r&&null!==r){if(-1!==n.indexOf(r))return;n.push(r)}return r})};Array.prototype.indexOf||(Array.prototype.indexOf=function(e,n){var r;if(null==this)throw new TypeError('"this" is null or not defined');var a=Object(this),t=a.length>>>0;if(0===t)return-1;var o=+n||0;if(1/0===Math.abs(o)&&(o=0),o>=t)return-1;for(r=Math.max(o>=0?o:t-Math.abs(o),0);t>r;){if(r in a&&a[r]===e)return r;r++}return-1})}();
© 2015 - 2025 Weber Informatics LLC | Privacy Policy