").parent())},function(e){throw"info-window template request failed: "+e}):e(i)}).then(function(e){var t=e.html().trim();if(1!=angular.element(t).length)throw"info-window working as a template must have a container";s.__template=t.replace(/\s?ng-non-bindable[='"]+/,"")});return s.__open=function(e,n,o){c.then(function(){a(function(){o&&(n.anchor=o);var a=t(s.__template)(n);s.setContent(a[0]),n.$apply(),o&&o.getPosition?s.open(e,o):o&&o instanceof google.maps.LatLng?(s.open(e),s.setPosition(o)):s.open(e);var r=s.content.parentElement.parentElement.parentElement;r.className="ng-map-info-window"})})},s},c=function(e,t,n,o){o=o[0]||o[1],t.css("display","none");var a,c=s.orgAttributes(t),u=s.filter(n),l=s.getOptions(u,{scope:e}),g=s.getEvents(e,u),d=p(l,g,l.template||t);!l.position||l.position instanceof google.maps.LatLng||(a=l.position),a&&i.getGeoLocation(a).then(function(t){d.setPosition(t),d.__open(o.map,e,t);var a=n.geoCallback;a&&r(a)(e)}),o.addObject("infoWindows",d),o.observeAttrSetObj(c,n,d),o.showInfoWindow=o.map.showInfoWindow=o.showInfoWindow||function(t,n,a){var r="string"==typeof t?t:n,i="string"==typeof t?n:a;if("string"==typeof i)if("undefined"!=typeof o.map.markers&&"undefined"!=typeof o.map.markers[i])i=o.map.markers[i];else{if("undefined"==typeof o.map.customMarkers||"undefined"==typeof o.map.customMarkers[i])throw new Error("Cant open info window for id "+i+". Marker or CustomMarker is not defined");i=o.map.customMarkers[i]}var s=o.map.infoWindows[r],p=i?i:this.getPosition?this:null;s.__open(o.map,e,p),o.singleInfoWindow&&(o.lastInfoWindow&&e.hideInfoWindow(o.lastInfoWindow),o.lastInfoWindow=r)},o.hideInfoWindow=o.map.hideInfoWindow=o.hideInfoWindow||function(e,t){var n="string"==typeof e?e:t,a=o.map.infoWindows[n];a.close()},e.showInfoWindow=o.map.showInfoWindow,e.hideInfoWindow=o.map.hideInfoWindow;var m=d.mapId?{id:d.mapId}:0;i.getMap(m).then(function(t){if(d.visible&&d.__open(t,e),d.visibleOnMarker){var n=d.visibleOnMarker;d.__open(t,e,t.markers[n])}})};return{restrict:"E",require:["?^map","?^ngMap"],link:c}};e.$inject=["Attr2MapOptions","$compile","$q","$templateRequest","$timeout","$parse","NgMap"],angular.module("ngMap").directive("infoWindow",e)}(),function(){"use strict";angular.module("ngMap").directive("kmlLayer",["Attr2MapOptions",function(e){var t=e,n=function(e,t){var n=new google.maps.KmlLayer(e);for(var o in t)google.maps.event.addListener(n,o,t[o]);return n};return{restrict:"E",require:["?^map","?^ngMap"],link:function(e,o,a,r){r=r[0]||r[1];var i=t.orgAttributes(o),s=t.filter(a),p=t.getOptions(s,{scope:e}),c=t.getEvents(e,s),u=n(p,c);r.addObject("kmlLayers",u),r.observeAttrSetObj(i,a,u),o.bind("$destroy",function(){r.deleteObject("kmlLayers",u)})}}}])}(),function(){"use strict";angular.module("ngMap").directive("mapData",["Attr2MapOptions","NgMap",function(e,t){var n=e;return{restrict:"E",require:["?^map","?^ngMap"],link:function(e,o,a,r){r=r[0]||r[1];var i=n.filter(a),s=n.getOptions(i,{scope:e}),p=n.getEvents(e,i,p);t.getMap(r.map.id).then(function(t){for(var n in s){var o=s[n];"function"==typeof e[o]?t.data[n](e[o]):t.data[n](o)}for(var a in p)t.data.addListener(a,p[a])})}}}])}(),function(){"use strict";var e,t,n,o=[],a=[],r=function(n,r,i){var s=i.mapLazyLoadParams||i.mapLazyLoad;if(void 0===window.google||void 0===window.google.maps){a.push({scope:n,element:r,savedHtml:o[a.length]}),window.lazyLoadCallback=function(){e(function(){a.forEach(function(e){e.element.html(e.savedHtml),t(e.element.contents())(e.scope)})},100)};var p=document.createElement("script");p.src=s+(s.indexOf("?")>-1?"&":"?")+"callback=lazyLoadCallback",document.querySelector('script[src="'+p.src+'"]')||document.body.appendChild(p)}else r.html(o),t(r.contents())(n)},i=function(e,t){return!t.mapLazyLoad&&void 0,o.push(e.html()),n=t.mapLazyLoad,void 0!==window.google&&void 0!==window.google.maps?!1:(e.html(""),{pre:r})},s=function(n,o){return t=n,e=o,{compile:i}};s.$inject=["$compile","$timeout"],angular.module("ngMap").directive("mapLazyLoad",s)}(),function(){"use strict";angular.module("ngMap").directive("mapType",["$parse","NgMap",function(e,t){return{restrict:"E",require:["?^map","?^ngMap"],link:function(n,o,a,r){r=r[0]||r[1];var i,s=a.name;if(!s)throw"invalid map-type name";if(i=e(a.object)(n),!i)throw"invalid map-type object";t.getMap().then(function(e){e.mapTypes.set(s,i)}),r.addObject("mapTypes",i)}}}])}(),function(){"use strict";var e=function(){return{restrict:"AE",controller:"__MapController",controllerAs:"ngmap"}};angular.module("ngMap").directive("map",[e]),angular.module("ngMap").directive("ngMap",[e])}(),function(){"use strict";angular.module("ngMap").directive("mapsEngineLayer",["Attr2MapOptions",function(e){var t=e,n=function(e,t){var n=new google.maps.visualization.MapsEngineLayer(e);for(var o in t)google.maps.event.addListener(n,o,t[o]);return n};return{restrict:"E",require:["?^map","?^ngMap"],link:function(e,o,a,r){r=r[0]||r[1];var i=t.filter(a),s=t.getOptions(i,{scope:e}),p=t.getEvents(e,i,p),c=n(s,p);r.addObject("mapsEngineLayers",c)}}}])}(),function(){"use strict";var e,t,n,o=function(e,t){var o;if(n.defaultOptions.marker)for(var a in n.defaultOptions.marker)"undefined"==typeof e[a]&&(e[a]=n.defaultOptions.marker[a]);e.position instanceof google.maps.LatLng||(e.position=new google.maps.LatLng(0,0)),o=new google.maps.Marker(e),Object.keys(t).length>0;for(var r in t)r&&google.maps.event.addListener(o,r,t[r]);return o},a=function(a,r,i,s){s=s[0]||s[1];var p,c=e.orgAttributes(r),u=e.filter(i),l=e.getOptions(u,a,{scope:a}),g=e.getEvents(a,u);l.position instanceof google.maps.LatLng||(p=l.position);var d=o(l,g);s.addObject("markers",d),p&&n.getGeoLocation(p).then(function(e){d.setPosition(e),l.centered&&d.map.setCenter(e);var n=i.geoCallback;n&&t(n)(a)}),s.observeAttrSetObj(c,i,d),r.bind("$destroy",function(){s.deleteObject("markers",d)})},r=function(o,r,i){return e=o,t=r,n=i,{restrict:"E",require:["^?map","?^ngMap"],link:a}};r.$inject=["Attr2MapOptions","$parse","NgMap"],angular.module("ngMap").directive("marker",r)}(),function(){"use strict";angular.module("ngMap").directive("overlayMapType",["NgMap",function(e){return{restrict:"E",require:["?^map","?^ngMap"],link:function(t,n,o,a){a=a[0]||a[1];var r=o.initMethod||"insertAt",i=t[o.object];e.getMap().then(function(e){if("insertAt"==r){var t=parseInt(o.index,10);e.overlayMapTypes.insertAt(t,i)}else"push"==r&&e.overlayMapTypes.push(i)}),a.addObject("overlayMapTypes",i)}}}])}(),function(){"use strict";var e=function(e,t){var n=e,o=function(e,o,a,r){if("false"===a.placesAutoComplete)return!1;var i=n.filter(a),s=n.getOptions(i,{scope:e}),p=n.getEvents(e,i),c=new google.maps.places.Autocomplete(o[0],s);for(var u in p)google.maps.event.addListener(c,u,p[u]);var l=function(){t(function(){r&&r.$setViewValue(o.val())},100)};google.maps.event.addListener(c,"place_changed",l),o[0].addEventListener("change",l),a.$observe("types",function(e){if(e){var t=n.toOptionValue(e,{key:"types"});c.setTypes(t)}}),a.$observe("componentRestrictions",function(t){t&&c.setComponentRestrictions(e.$eval(t))})};return{restrict:"A",require:"?ngModel",link:o}};e.$inject=["Attr2MapOptions","$timeout"],angular.module("ngMap").directive("placesAutoComplete",e)}(),function(){"use strict";var e=function(e,t){var n,o=e.name;switch(delete e.name,o){case"circle":e.center instanceof google.maps.LatLng||(e.center=new google.maps.LatLng(0,0)),n=new google.maps.Circle(e);break;case"polygon":n=new google.maps.Polygon(e);break;case"polyline":n=new google.maps.Polyline(e);break;case"rectangle":n=new google.maps.Rectangle(e);break;case"groundOverlay":case"image":var a=e.url,r={opacity:e.opacity,clickable:e.clickable,id:e.id};n=new google.maps.GroundOverlay(a,e.bounds,r)}for(var i in t)t[i]&&google.maps.event.addListener(n,i,t[i]);return n},t=function(t,n,o){var a=t,r=function(t,r,i,s){s=s[0]||s[1];var p,c,u=a.orgAttributes(r),l=a.filter(i),g=a.getOptions(l,{scope:t}),d=a.getEvents(t,l);c=g.name,g.center instanceof google.maps.LatLng||(p=g.center);var m=e(g,d);s.addObject("shapes",m),p&&"circle"==c&&o.getGeoLocation(p).then(function(e){m.setCenter(e),m.centered&&m.map.setCenter(e);var o=i.geoCallback;o&&n(o)(t)}),s.observeAttrSetObj(u,i,m),r.bind("$destroy",function(){s.deleteObject("shapes",m)})};return{restrict:"E",require:["?^map","?^ngMap"],link:r}};t.$inject=["Attr2MapOptions","$parse","NgMap"],angular.module("ngMap").directive("shape",t)}(),function(){"use strict";var e=function(e,t){var n=e,o=function(e,t,n){var o,a;t.container&&(a=document.getElementById(t.container),a=a||document.querySelector(t.container)),a?o=new google.maps.StreetViewPanorama(a,t):(o=e.getStreetView(),o.setOptions(t));for(var r in n)r&&google.maps.event.addListener(o,r,n[r]);return o},a=function(e,a,r){var i=n.filter(r),s=n.getOptions(i,{scope:e}),p=n.getControlOptions(i),c=angular.extend(s,p),u=n.getEvents(e,i);t.getMap().then(function(e){var t=o(e,c,u);e.setStreetView(t),!t.getPosition()&&t.setPosition(e.getCenter()),google.maps.event.addListener(t,"position_changed",function(){t.getPosition()!==e.getCenter()&&e.setCenter(t.getPosition())});var n=google.maps.event.addListener(e,"center_changed",function(){t.setPosition(e.getCenter()),google.maps.event.removeListener(n)})})};return{restrict:"E",require:["?^map","?^ngMap"],link:a}};e.$inject=["Attr2MapOptions","NgMap"],angular.module("ngMap").directive("streetViewPanorama",e)}(),function(){"use strict";angular.module("ngMap").directive("trafficLayer",["Attr2MapOptions",function(e){var t=e,n=function(e,t){var n=new google.maps.TrafficLayer(e);for(var o in t)google.maps.event.addListener(n,o,t[o]);return n};return{restrict:"E",require:["?^map","?^ngMap"],link:function(e,o,a,r){r=r[0]||r[1];var i=t.orgAttributes(o),s=t.filter(a),p=t.getOptions(s,{scope:e}),c=t.getEvents(e,s),u=n(p,c);r.addObject("trafficLayers",u),r.observeAttrSetObj(i,a,u),o.bind("$destroy",function(){r.deleteObject("trafficLayers",u)})}}}])}(),function(){"use strict";angular.module("ngMap").directive("transitLayer",["Attr2MapOptions",function(e){var t=e,n=function(e,t){var n=new google.maps.TransitLayer(e);for(var o in t)google.maps.event.addListener(n,o,t[o]);return n};return{restrict:"E",require:["?^map","?^ngMap"],link:function(e,o,a,r){r=r[0]||r[1];var i=t.orgAttributes(o),s=t.filter(a),p=t.getOptions(s,{scope:e}),c=t.getEvents(e,s),u=n(p,c);r.addObject("transitLayers",u),r.observeAttrSetObj(i,a,u),o.bind("$destroy",function(){r.deleteObject("transitLayers",u)})}}}])}(),function(){"use strict";var e=/([\:\-\_]+(.))/g,t=/^moz([A-Z])/,n=function(){return function(n){return n.replace(e,function(e,t,n,o){return o?n.toUpperCase():n}).replace(t,"Moz$1")}};angular.module("ngMap").filter("camelCase",n)}(),function(){"use strict";var e=function(){return function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}};angular.module("ngMap").filter("escapeRegexp",e)}(),function(){"use strict";var e=function(){return function(e){try{return JSON.parse(e),e}catch(t){return e.replace(/([\$\w]+)\s*:/g,function(e,t){return'"'+t+'":'}).replace(/'([^']+)'/g,function(e,t){return'"'+t+'"'}).replace(/''/g,'""')}}};angular.module("ngMap").filter("jsonize",e)}(),function(){"use strict";var isoDateRE=/^(\d{4}\-\d\d\-\d\d([tT][\d:\.]*)?)([zZ]|([+\-])(\d\d):?(\d\d))?$/,Attr2MapOptions=function($parse,$timeout,$log,$interpolate,NavigatorGeolocation,GeoCoder,camelCaseFilter,jsonizeFilter,escapeRegExp){var exprStartSymbol=$interpolate.startSymbol(),exprEndSymbol=$interpolate.endSymbol(),orgAttributes=function(e){e.length>0&&(e=e[0]);for(var t={},n=0;n
-1?"&":"?")+"callback=lazyLoadCallback",document.querySelector('script[src="'+a.src+'"]')||document.body.appendChild(a)}else o.resolve(window.google);return o.promise}}};n.$inject=["$q","$timeout"],angular.module("ngMap").service("GoogleMapsApi",n)}(),function(){"use strict";var e,t=function(t){var n=e.defer();return navigator.geolocation?(void 0===t?t={timeout:5e3}:void 0===t.timeout&&(t.timeout=5e3),navigator.geolocation.getCurrentPosition(function(e){n.resolve(e)},function(e){n.reject(e)},t)):n.reject("Browser Geolocation service failed."),n.promise},n=function(n){return e=n,{getCurrentPosition:t}};n.$inject=["$q"],angular.module("ngMap").service("NavigatorGeolocation",n)}(),function(){"use strict";var e,t,n,o=[],a=function(n){var a=t.createElement("div");a.style.width="100%",a.style.height="100%",n.appendChild(a);var r=new e.google.maps.Map(a,{});return o.push(r),r},r=function(e,t){for(var n,a=0;ai?r.reject("could not find map"):e.setTimeout(function(){a(n+100)},100)}o=o||{},t="object"==typeof t?t.id:t;var r=n.defer(),i=o.timeout||1e4;return a(0),r.promise},g=function(e){if(e.map){var t=Object.keys(p).length;p[e.map.id||t]=e}},d=function(e){var t=Object.keys(p).length-1,n=e.map.id||t;if(e.map){for(var o in e.eventListeners){var a=e.eventListeners[o];google.maps.event.removeListener(a)}e.map.controls&&e.map.controls.forEach(function(e){e.clear()})}e.map.heatmapLayers&&Object.keys(e.map.heatmapLayers).forEach(function(t){e.deleteObject("heatmapLayers",e.map.heatmapLayers[t])}),s.deleteMapInstance(n),delete p[n]},m=function(e,t){var a=n.defer();return!e||e.match(/^current/i)?o.getCurrentPosition(t).then(function(e){var t=e.coords.latitude,n=e.coords.longitude,o=new google.maps.LatLng(t,n);a.resolve(o)},function(e){a.reject(e)}):r.geocode({address:e}).then(function(e){a.resolve(e[0].geometry.location)},function(e){a.reject(e)}),a.promise},f=function(e,t){return function(n){if(n){var o=i("set-"+e),r=a.toOptionValue(n,{key:e});t[o]&&(e.match(/center|position/)&&"string"==typeof r?m(r).then(function(e){t[o](e)}):t[o](r))}}},v=function(e){var t=e.getAttribute("default-style");"true"==t?(e.style.display="block",e.style.height="300px"):("block"!=c(e,"display")&&(e.style.display="block"),c(e,"height").match(/^(0|auto)/)&&(e.style.height="300px"))};angular.module("ngMap").provider("NgMap",function(){var p={};this.setDefaultOptions=function(e){p=e};var c=function(c,y,h,b,M,O,w,L){return e=c,t=y[0],n=h,o=b,a=M,r=O,i=w,s=L,{defaultOptions:p,addMap:g,deleteMap:d,getMap:l,initMap:u,setStyle:v,getGeoLocation:m,observeAndSet:f}};c.$inject=["$window","$document","$q","NavigatorGeolocation","Attr2MapOptions","GeoCoder","camelCaseFilter","NgMapPool"],this.$get=c})}(),function(){"use strict";var e,t=function(t,n){n=n||t.getCenter();var o=e.defer(),a=new google.maps.StreetViewService;return a.getPanoramaByLocation(n||t.getCenter,100,function(e,t){t===google.maps.StreetViewStatus.OK?o.resolve(e.location.pano):o.resolve(!1)}),o.promise},n=function(e,t){var n=new google.maps.StreetViewPanorama(e.getDiv(),{enableCloseButton:!0});n.setPano(t)},o=function(o){return e=o,{getPanorama:t,setPanorama:n}};o.$inject=["$q"],angular.module("ngMap").service("StreetView",o)}(),"ngMap"});
/**
* oclazyload - Load modules on demand (lazy load) with angularJS
* @version v1.0.10
* @link https://github.com/ocombe/ocLazyLoad
* @license MIT
* @author Olivier Combe
*/
(function (angular, window) {
'use strict';
var regModules = ['ng', 'oc.lazyLoad'],
regInvokes = {},
regConfigs = [],
modulesToLoad = [],
// modules to load from angular.module or other sources
realModules = [],
// real modules called from angular.module
recordDeclarations = [],
broadcast = angular.noop,
runBlocks = {},
justLoaded = [];
var ocLazyLoad = angular.module('oc.lazyLoad', ['ng']);
ocLazyLoad.provider('$ocLazyLoad', ["$controllerProvider", "$provide", "$compileProvider", "$filterProvider", "$injector", "$animateProvider", function ($controllerProvider, $provide, $compileProvider, $filterProvider, $injector, $animateProvider) {
var modules = {},
providers = {
$controllerProvider: $controllerProvider,
$compileProvider: $compileProvider,
$filterProvider: $filterProvider,
$provide: $provide, // other things (constant, decorator, provider, factory, service)
$injector: $injector,
$animateProvider: $animateProvider
},
debug = false,
events = false,
moduleCache = [],
modulePromises = {};
moduleCache.push = function (value) {
if (this.indexOf(value) === -1) {
Array.prototype.push.apply(this, arguments);
}
};
this.config = function (config) {
// If we want to define modules configs
if (angular.isDefined(config.modules)) {
if (angular.isArray(config.modules)) {
angular.forEach(config.modules, function (moduleConfig) {
modules[moduleConfig.name] = moduleConfig;
});
} else {
modules[config.modules.name] = config.modules;
}
}
if (angular.isDefined(config.debug)) {
debug = config.debug;
}
if (angular.isDefined(config.events)) {
events = config.events;
}
};
/**
* Get the list of existing registered modules
* @param element
*/
this._init = function _init(element) {
// this is probably useless now because we override angular.bootstrap
if (modulesToLoad.length === 0) {
var elements = [element],
names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],
NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/,
append = function append(elm) {
return elm && elements.push(elm);
};
angular.forEach(names, function (name) {
names[name] = true;
append(document.getElementById(name));
name = name.replace(':', '\\:');
if (typeof element[0] !== 'undefined' && element[0].querySelectorAll) {
angular.forEach(element[0].querySelectorAll('.' + name), append);
angular.forEach(element[0].querySelectorAll('.' + name + '\\:'), append);
angular.forEach(element[0].querySelectorAll('[' + name + ']'), append);
}
});
angular.forEach(elements, function (elm) {
if (modulesToLoad.length === 0) {
var className = ' ' + element.className + ' ';
var match = NG_APP_CLASS_REGEXP.exec(className);
if (match) {
modulesToLoad.push((match[2] || '').replace(/\s+/g, ','));
} else {
angular.forEach(elm.attributes, function (attr) {
if (modulesToLoad.length === 0 && names[attr.name]) {
modulesToLoad.push(attr.value);
}
});
}
}
});
}
if (modulesToLoad.length === 0 && !((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 addReg = function addReg(moduleName) {
if (regModules.indexOf(moduleName) === -1) {
// register existing modules
regModules.push(moduleName);
var mainModule = angular.module(moduleName);
// register existing components (directives, services, ...)
_invokeQueue(null, mainModule._invokeQueue, moduleName);
_invokeQueue(null, mainModule._configBlocks, moduleName); // angular 1.3+
angular.forEach(mainModule.requires, addReg);
}
};
angular.forEach(modulesToLoad, function (moduleName) {
addReg(moduleName);
});
modulesToLoad = []; // reset for next bootstrap
recordDeclarations.pop(); // wait for the next lazy load
};
/**
* Like JSON.stringify but that doesn't throw on circular references
* @param obj
*/
var stringify = function stringify(obj) {
try {
return JSON.stringify(obj);
} catch (e) {
var cache = [];
return JSON.stringify(obj, function (key, value) {
if (angular.isObject(value) && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);
}
return value;
});
}
};
var hashCode = function hashCode(str) {
var hash = 0,
i,
chr,
len;
if (str.length == 0) {
return hash;
}
for (i = 0, len = str.length; i < len; i++) {
chr = str.charCodeAt(i);
hash = (hash << 5) - hash + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
function _register(providers, registerModules, params) {
if (registerModules) {
var k,
moduleName,
moduleFn,
tempRunBlocks = [];
for (k = registerModules.length - 1; k >= 0; k--) {
moduleName = registerModules[k];
if (!angular.isString(moduleName)) {
moduleName = getModuleName(moduleName);
}
if (!moduleName || justLoaded.indexOf(moduleName) !== -1 || modules[moduleName] && realModules.indexOf(moduleName) === -1) {
continue;
}
// new if not registered
var newModule = regModules.indexOf(moduleName) === -1;
moduleFn = ngModuleFct(moduleName);
if (newModule) {
regModules.push(moduleName);
_register(providers, moduleFn.requires, params);
}
if (moduleFn._runBlocks.length > 0) {
// new run blocks detected! Replace the old ones (if existing)
runBlocks[moduleName] = [];
while (moduleFn._runBlocks.length > 0) {
runBlocks[moduleName].push(moduleFn._runBlocks.shift());
}
}
if (angular.isDefined(runBlocks[moduleName]) && (newModule || params.rerun)) {
tempRunBlocks = tempRunBlocks.concat(runBlocks[moduleName]);
}
_invokeQueue(providers, moduleFn._invokeQueue, moduleName, params.reconfig);
_invokeQueue(providers, moduleFn._configBlocks, moduleName, params.reconfig); // angular 1.3+
broadcast(newModule ? 'ocLazyLoad.moduleLoaded' : 'ocLazyLoad.moduleReloaded', moduleName);
registerModules.pop();
justLoaded.push(moduleName);
}
// execute the run blocks at the end
var instanceInjector = providers.getInstanceInjector();
angular.forEach(tempRunBlocks, function (fn) {
instanceInjector.invoke(fn);
});
}
}
function _registerInvokeList(args, moduleName) {
var invokeList = args[2][0],
type = args[1],
newInvoke = false;
if (angular.isUndefined(regInvokes[moduleName])) {
regInvokes[moduleName] = {};
}
if (angular.isUndefined(regInvokes[moduleName][type])) {
regInvokes[moduleName][type] = {};
}
var onInvoke = function onInvoke(invokeName, invoke) {
if (!regInvokes[moduleName][type].hasOwnProperty(invokeName)) {
regInvokes[moduleName][type][invokeName] = [];
}
if (checkHashes(invoke, regInvokes[moduleName][type][invokeName])) {
newInvoke = true;
regInvokes[moduleName][type][invokeName].push(invoke);
broadcast('ocLazyLoad.componentLoaded', [moduleName, type, invokeName]);
}
};
function checkHashes(potentialNew, invokes) {
var isNew = true,
newHash;
if (invokes.length) {
newHash = signature(potentialNew);
angular.forEach(invokes, function (invoke) {
isNew = isNew && signature(invoke) !== newHash;
});
}
return isNew;
}
function signature(data) {
if (angular.isArray(data)) {
// arrays are objects, we need to test for it first
return hashCode(data.toString());
} else if (angular.isObject(data)) {
// constants & values for example
return hashCode(stringify(data));
} else {
if (angular.isDefined(data) && data !== null) {
return hashCode(data.toString());
} else {
// null & undefined constants
return data;
}
}
}
if (angular.isString(invokeList)) {
onInvoke(invokeList, args[2][1]);
} else if (angular.isObject(invokeList)) {
angular.forEach(invokeList, function (invoke, key) {
if (angular.isString(invoke)) {
// decorators for example
onInvoke(invoke, invokeList[1]);
} else {
// components registered as object lists {"componentName": function() {}}
onInvoke(key, invoke);
}
});
} else {
return false;
}
return newInvoke;
}
function _invokeQueue(providers, queue, moduleName, reconfig) {
if (!queue) {
return;
}
var i, len, args, provider;
for (i = 0, len = queue.length; i < len; i++) {
args = queue[i];
if (angular.isArray(args)) {
if (providers !== null) {
if (providers.hasOwnProperty(args[0])) {
provider = providers[args[0]];
} else {
throw new Error('unsupported provider ' + args[0]);
}
}
var isNew = _registerInvokeList(args, moduleName);
if (args[1] !== 'invoke') {
if (isNew && angular.isDefined(provider)) {
provider[args[1]].apply(provider, args[2]);
}
} else {
// config block
var callInvoke = function callInvoke(fct) {
var invoked = regConfigs.indexOf(moduleName + '-' + fct);
if (invoked === -1 || reconfig) {
if (invoked === -1) {
regConfigs.push(moduleName + '-' + fct);
}
if (angular.isDefined(provider)) {
provider[args[1]].apply(provider, args[2]);
}
}
};
if (angular.isFunction(args[2][0])) {
callInvoke(args[2][0]);
} else if (angular.isArray(args[2][0])) {
for (var j = 0, jlen = args[2][0].length; j < jlen; j++) {
if (angular.isFunction(args[2][0][j])) {
callInvoke(args[2][0][j]);
}
}
}
}
}
}
}
function getModuleName(module) {
var moduleName = null;
if (angular.isString(module)) {
moduleName = module;
} else if (angular.isObject(module) && module.hasOwnProperty('name') && angular.isString(module.name)) {
moduleName = module.name;
}
return moduleName;
}
function moduleExists(moduleName) {
if (!angular.isString(moduleName)) {
return false;
}
try {
return ngModuleFct(moduleName);
} catch (e) {
if (/No module/.test(e) || e.message.indexOf('$injector:nomod') > -1) {
return false;
}
}
}
this.$get = ["$log", "$rootElement", "$rootScope", "$cacheFactory", "$q", function ($log, $rootElement, $rootScope, $cacheFactory, $q) {
var instanceInjector,
filesCache = $cacheFactory('ocLazyLoad');
if (!debug) {
$log = {};
$log['error'] = angular.noop;
$log['warn'] = angular.noop;
$log['info'] = angular.noop;
}
// Make this lazy because when $get() is called the instance injector hasn't been assigned to the rootElement yet
providers.getInstanceInjector = function () {
return instanceInjector ? instanceInjector : instanceInjector = $rootElement.data('$injector') || angular.injector();
};
broadcast = function broadcast(eventName, params) {
if (events) {
$rootScope.$broadcast(eventName, params);
}
if (debug) {
$log.info(eventName, params);
}
};
function reject(e) {
var deferred = $q.defer();
$log.error(e.message);
deferred.reject(e);
return deferred.promise;
}
return {
_broadcast: broadcast,
_$log: $log,
/**
* Returns the files cache used by the loaders to store the files currently loading
* @returns {*}
*/
_getFilesCache: function getFilesCache() {
return filesCache;
},
/**
* Let the service know that it should monitor angular.module because files are loading
* @param watch boolean
*/
toggleWatch: function toggleWatch(watch) {
if (watch) {
recordDeclarations.push(true);
} else {
recordDeclarations.pop();
}
},
/**
* Let you get a module config object
* @param moduleName String the name of the module
* @returns {*}
*/
getModuleConfig: function getModuleConfig(moduleName) {
if (!angular.isString(moduleName)) {
throw new Error('You need to give the name of the module to get');
}
if (!modules[moduleName]) {
return null;
}
return angular.copy(modules[moduleName]);
},
/**
* Let you define a module config object
* @param moduleConfig Object the module config object
* @returns {*}
*/
setModuleConfig: function setModuleConfig(moduleConfig) {
if (!angular.isObject(moduleConfig)) {
throw new Error('You need to give the module config object to set');
}
modules[moduleConfig.name] = moduleConfig;
return moduleConfig;
},
/**
* Returns the list of loaded modules
* @returns {string[]}
*/
getModules: function getModules() {
return regModules;
},
/**
* Let you check if a module has been loaded into Angular or not
* @param modulesNames String/Object a module name, or a list of module names
* @returns {boolean}
*/
isLoaded: function isLoaded(modulesNames) {
var moduleLoaded = function moduleLoaded(module) {
var isLoaded = regModules.indexOf(module) > -1;
if (!isLoaded) {
isLoaded = !!moduleExists(module);
}
return isLoaded;
};
if (angular.isString(modulesNames)) {
modulesNames = [modulesNames];
}
if (angular.isArray(modulesNames)) {
var i, len;
for (i = 0, len = modulesNames.length; i < len; i++) {
if (!moduleLoaded(modulesNames[i])) {
return false;
}
}
return true;
} else {
throw new Error('You need to define the module(s) name(s)');
}
},
/**
* Given a module, return its name
* @param module
* @returns {String}
*/
_getModuleName: getModuleName,
/**
* Returns a module if it exists
* @param moduleName
* @returns {module}
*/
_getModule: function getModule(moduleName) {
try {
return ngModuleFct(moduleName);
} catch (e) {
// this error message really suxx
if (/No module/.test(e) || e.message.indexOf('$injector:nomod') > -1) {
e.message = 'The module "' + stringify(moduleName) + '" that you are trying to load does not exist. ' + e.message;
}
throw e;
}
},
/**
* Check if a module exists and returns it if it does
* @param moduleName
* @returns {boolean}
*/
moduleExists: moduleExists,
/**
* Load the dependencies, and might try to load new files depending on the config
* @param moduleName (String or Array of Strings)
* @param localParams
* @returns {*}
* @private
*/
_loadDependencies: function _loadDependencies(moduleName, localParams) {
var loadedModule,
requires,
diff,
promisesList = [],
self = this;
moduleName = self._getModuleName(moduleName);
if (moduleName === null) {
return $q.when();
} else {
try {
loadedModule = self._getModule(moduleName);
} catch (e) {
return reject(e);
}
// get unloaded requires
requires = self.getRequires(loadedModule);
}
angular.forEach(requires, function (requireEntry) {
// If no configuration is provided, try and find one from a previous load.
// If there isn't one, bail and let the normal flow run
if (angular.isString(requireEntry)) {
var config = self.getModuleConfig(requireEntry);
if (config === null) {
moduleCache.push(requireEntry); // We don't know about this module, but something else might, so push it anyway.
return;
}
requireEntry = config;
// ignore the name because it's probably not a real module name
config.name = undefined;
}
// Check if this dependency has been loaded previously
if (self.moduleExists(requireEntry.name)) {
// compare against the already loaded module to see if the new definition adds any new files
diff = requireEntry.files.filter(function (n) {
return self.getModuleConfig(requireEntry.name).files.indexOf(n) < 0;
});
// If the module was redefined, advise via the console
if (diff.length !== 0) {
self._$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency. "', requireEntry.name, '"\n Additional Files Loaded:', diff);
}
// Push everything to the file loader, it will weed out the duplicates.
if (angular.isDefined(self.filesLoader)) {
// if a files loader is defined
promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
return self._loadDependencies(requireEntry);
}));
} else {
return reject(new Error('Error: New dependencies need to be loaded from external files (' + requireEntry.files + '), but no loader has been defined.'));
}
return;
} else if (angular.isArray(requireEntry)) {
var files = [];
angular.forEach(requireEntry, function (entry) {
// let's check if the entry is a file name or a config name
var config = self.getModuleConfig(entry);
if (config === null) {
files.push(entry);
} else if (config.files) {
files = files.concat(config.files);
}
});
if (files.length > 0) {
requireEntry = {
files: files
};
}
} else if (angular.isObject(requireEntry)) {
if (requireEntry.hasOwnProperty('name') && requireEntry['name']) {
// The dependency doesn't exist in the module cache and is a new configuration, so store and push it.
self.setModuleConfig(requireEntry);
moduleCache.push(requireEntry['name']);
}
}
// Check if the dependency has any files that need to be loaded. If there are, push a new promise to the promise list.
if (angular.isDefined(requireEntry.files) && requireEntry.files.length !== 0) {
if (angular.isDefined(self.filesLoader)) {
// if a files loader is defined
promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {
return self._loadDependencies(requireEntry);
}));
} else {
return reject(new Error('Error: the module "' + requireEntry.name + '" is defined in external files (' + requireEntry.files + '), but no loader has been defined.'));
}
}
});
// Create a wrapper promise to watch the promise list and resolve it once everything is done.
return $q.all(promisesList);
},
/**
* Inject new modules into Angular
* @param moduleName
* @param localParams
* @param real
*/
inject: function inject(moduleName) {
var localParams = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var real = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var self = this,
deferred = $q.defer();
if (angular.isDefined(moduleName) && moduleName !== null) {
if (angular.isArray(moduleName)) {
var promisesList = [];
angular.forEach(moduleName, function (module) {
promisesList.push(self.inject(module, localParams, real));
});
return $q.all(promisesList);
} else {
self._addToLoadList(self._getModuleName(moduleName), true, real);
}
}
if (modulesToLoad.length > 0) {
var res = modulesToLoad.slice(); // clean copy
var loadNext = function loadNext(moduleName) {
moduleCache.push(moduleName);
modulePromises[moduleName] = deferred.promise;
self._loadDependencies(moduleName, localParams).then(function success() {
try {
justLoaded = [];
_register(providers, moduleCache, localParams);
} catch (e) {
self._$log.error(e.message);
deferred.reject(e);
return;
}
if (modulesToLoad.length > 0) {
loadNext(modulesToLoad.shift()); // load the next in list
} else {
deferred.resolve(res); // everything has been loaded, resolve
}
}, function error(err) {
deferred.reject(err);
});
};
// load the first in list
loadNext(modulesToLoad.shift());
} else if (localParams && localParams.name && modulePromises[localParams.name]) {
return modulePromises[localParams.name];
} else {
deferred.resolve();
}
return deferred.promise;
},
/**
* Get the list of required modules/services/... for this module
* @param module
* @returns {Array}
*/
getRequires: function getRequires(module) {
var requires = [];
angular.forEach(module.requires, function (requireModule) {
if (regModules.indexOf(requireModule) === -1) {
requires.push(requireModule);
}
});
return requires;
},
/**
* Invoke the new modules & component by their providers
* @param providers
* @param queue
* @param moduleName
* @param reconfig
* @private
*/
_invokeQueue: _invokeQueue,
/**
* Check if a module has been invoked and registers it if not
* @param args
* @param moduleName
* @returns {boolean} is new
*/
_registerInvokeList: _registerInvokeList,
/**
* Register a new module and loads it, executing the run/config blocks if needed
* @param providers
* @param registerModules
* @param params
* @private
*/
_register: _register,
/**
* Add a module name to the list of modules that will be loaded in the next inject
* @param name
* @param force
* @private
*/
_addToLoadList: _addToLoadList,
/**
* Unregister modules (you shouldn't have to use this)
* @param modules
*/
_unregister: function _unregister(modules) {
if (angular.isDefined(modules)) {
if (angular.isArray(modules)) {
angular.forEach(modules, function (module) {
regInvokes[module] = undefined;
});
}
}
}
};
}];
// Let's get the list of loaded modules & components
this._init(angular.element(window.document));
}]);
var bootstrapFct = angular.bootstrap;
angular.bootstrap = function (element, modules, config) {
// Clean state from previous bootstrap
regModules = ['ng', 'oc.lazyLoad'];
regInvokes = {};
regConfigs = [];
modulesToLoad = [];
realModules = [];
recordDeclarations = [];
broadcast = angular.noop;
runBlocks = {};
justLoaded = [];
// we use slice to make a clean copy
angular.forEach(modules.slice(), function (module) {
_addToLoadList(module, true, true);
});
return bootstrapFct(element, modules, config);
};
var _addToLoadList = function _addToLoadList(name, force, real) {
if ((recordDeclarations.length > 0 || force) && angular.isString(name) && modulesToLoad.indexOf(name) === -1) {
modulesToLoad.push(name);
if (real) {
realModules.push(name);
}
}
};
var ngModuleFct = angular.module;
angular.module = function (name, requires, configFn) {
_addToLoadList(name, false, true);
return ngModuleFct(name, requires, configFn);
};
// CommonJS package manager support:
if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports) {
module.exports = 'oc.lazyLoad';
}
})(angular, window);
(function (angular) {
'use strict';
angular.module('oc.lazyLoad').directive('ocLazyLoad', ["$ocLazyLoad", "$compile", "$animate", "$parse", "$timeout", function ($ocLazyLoad, $compile, $animate, $parse, $timeout) {
return {
restrict: 'A',
terminal: true,
priority: 1000,
compile: function compile(element, attrs) {
// we store the content and remove it before compilation
var content = element[0].innerHTML;
element.html('');
return function ($scope, $element, $attr) {
var model = $parse($attr.ocLazyLoad);
$scope.$watch(function () {
return model($scope) || $attr.ocLazyLoad; // it can be a module name (string), an object, an array, or a scope reference to any of this
}, function (moduleName) {
if (angular.isDefined(moduleName)) {
$ocLazyLoad.load(moduleName).then(function () {
// Attach element contents to DOM and then compile them.
// This prevents an issue where IE invalidates saved element objects (HTMLCollections)
// of the compiled contents when attaching to the parent DOM.
$animate.enter(content, $element);
// get the new content & compile it
$compile($element.contents())($scope);
});
}
}, true);
};
}
};
}]);
})(angular);
(function (angular) {
'use strict';
angular.module('oc.lazyLoad').config(["$provide", function ($provide) {
$provide.decorator('$ocLazyLoad', ["$delegate", "$q", "$window", "$interval", function ($delegate, $q, $window, $interval) {
var uaCssChecked = false,
useCssLoadPatch = false,
anchor = $window.document.getElementsByTagName('head')[0] || $window.document.getElementsByTagName('body')[0];
/**
* Load a js/css file
* @param type
* @param path
* @param params
* @returns promise
*/
$delegate.buildElement = function buildElement(type, path, params) {
var deferred = $q.defer(),
el,
loaded,
filesCache = $delegate._getFilesCache(),
cacheBuster = function cacheBuster(url) {
var dc = new Date().getTime();
if (url.indexOf('?') >= 0) {
if (url.substring(0, url.length - 1) === '&') {
return url + '_dc=' + dc;
}
return url + '&_dc=' + dc;
} else {
return url + '?_dc=' + dc;
}
};
// Store the promise early so the file load can be detected by other parallel lazy loads
// (ie: multiple routes on one page) a 'true' value isn't sufficient
// as it causes false positive load results.
if (angular.isUndefined(filesCache.get(path))) {
filesCache.put(path, deferred.promise);
}
// Switch in case more content types are added later
switch (type) {
case 'css':
el = $window.document.createElement('link');
el.type = 'text/css';
el.rel = 'stylesheet';
el.href = params.cache === false ? cacheBuster(path) : path;
break;
case 'js':
el = $window.document.createElement('script');
el.src = params.cache === false ? cacheBuster(path) : path;
break;
default:
filesCache.remove(path);
deferred.reject(new Error('Requested type "' + type + '" is not known. Could not inject "' + path + '"'));
break;
}
el.onload = el['onreadystatechange'] = function (e) {
if (el['readyState'] && !/^c|loade/.test(el['readyState']) || loaded) return;
el.onload = el['onreadystatechange'] = null;
loaded = 1;
$delegate._broadcast('ocLazyLoad.fileLoaded', path);
deferred.resolve(el);
};
el.onerror = function () {
filesCache.remove(path);
deferred.reject(new Error('Unable to load ' + path));
};
el.async = params.serie ? 0 : 1;
var insertBeforeElem = anchor.lastChild;
if (params.insertBefore) {
var element = angular.element(angular.isDefined(window.jQuery) ? params.insertBefore : document.querySelector(params.insertBefore));
if (element && element.length > 0) {
insertBeforeElem = element[0];
}
}
insertBeforeElem.parentNode.insertBefore(el, insertBeforeElem);
/*
The event load or readystatechange doesn't fire in:
- PhantomJS 1.9 (headless webkit browser)
- iOS < 6 (default mobile browser)
- Android < 4.4 (default mobile browser)
- Safari < 6 (desktop browser)
*/
if (type == 'css') {
if (!uaCssChecked) {
var ua = $window.navigator.userAgent.toLowerCase();
if (ua.indexOf('phantomjs/1.9') > -1) {
// PhantomJS ~1.9
useCssLoadPatch = true;
} else if (/iP(hone|od|ad)/.test($window.navigator.platform)) {
// iOS < 6
var v = $window.navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
var iOSVersion = parseFloat([parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)].join('.'));
useCssLoadPatch = iOSVersion < 6;
} else if (ua.indexOf('android') > -1) {
// Android < 4.4
var androidVersion = parseFloat(ua.slice(ua.indexOf('android') + 8));
useCssLoadPatch = androidVersion < 4.4;
} else if (ua.indexOf('safari') > -1) {
// Safari < 6
var versionMatch = ua.match(/version\/([\.\d]+)/i);
useCssLoadPatch = versionMatch && versionMatch[1] && parseFloat(versionMatch[1]) < 6;
}
}
if (useCssLoadPatch) {
var tries = 1000; // * 20 = 20000 miliseconds
var interval = $interval(function () {
try {
el.sheet.cssRules;
$interval.cancel(interval);
el.onload();
} catch (e) {
if (--tries <= 0) {
el.onerror();
}
}
}, 20);
}
}
return deferred.promise;
};
return $delegate;
}]);
}]);
})(angular);
(function (angular) {
'use strict';
angular.module('oc.lazyLoad').config(["$provide", function ($provide) {
$provide.decorator('$ocLazyLoad', ["$delegate", "$q", function ($delegate, $q) {
/**
* The function that loads new files
* @param config
* @param params
* @returns {*}
*/
$delegate.filesLoader = function filesLoader(config) {
var params = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var cssFiles = [],
templatesFiles = [],
jsFiles = [],
promises = [],
cachePromise = null,
filesCache = $delegate._getFilesCache();
$delegate.toggleWatch(true); // start watching angular.module calls
angular.extend(params, config);
var pushFile = function pushFile(path) {
var file_type = null,
m;
if (angular.isObject(path)) {
file_type = path.type;
path = path.path;
}
cachePromise = filesCache.get(path);
if (angular.isUndefined(cachePromise) || params.cache === false) {
// always check for requirejs syntax just in case
if ((m = /^(css|less|html|htm|js)?(?=!)/.exec(path)) !== null) {
// Detect file type using preceding type declaration (ala requireJS)
file_type = m[1];
path = path.substr(m[1].length + 1, path.length); // Strip the type from the path
}
if (!file_type) {
if ((m = /[.](css|less|html|htm|js)?((\?|#).*)?$/.exec(path)) !== null) {
// Detect file type via file extension
file_type = m[1];
} else if (!$delegate.jsLoader.hasOwnProperty('ocLazyLoadLoader') && $delegate.jsLoader.hasOwnProperty('requirejs')) {
// requirejs
file_type = 'js';
} else {
$delegate._$log.error('File type could not be determined. ' + path);
return;
}
}
if ((file_type === 'css' || file_type === 'less') && cssFiles.indexOf(path) === -1) {
cssFiles.push(path);
} else if ((file_type === 'html' || file_type === 'htm') && templatesFiles.indexOf(path) === -1) {
templatesFiles.push(path);
} else if (file_type === 'js' || jsFiles.indexOf(path) === -1) {
jsFiles.push(path);
} else {
$delegate._$log.error('File type is not valid. ' + path);
}
} else if (cachePromise) {
promises.push(cachePromise);
}
};
if (params.serie) {
pushFile(params.files.shift());
} else {
angular.forEach(params.files, function (path) {
pushFile(path);
});
}
if (cssFiles.length > 0) {
var cssDeferred = $q.defer();
$delegate.cssLoader(cssFiles, function (err) {
if (angular.isDefined(err) && $delegate.cssLoader.hasOwnProperty('ocLazyLoadLoader')) {
$delegate._$log.error(err);
cssDeferred.reject(err);
} else {
cssDeferred.resolve();
}
}, params);
promises.push(cssDeferred.promise);
}
if (templatesFiles.length > 0) {
var templatesDeferred = $q.defer();
$delegate.templatesLoader(templatesFiles, function (err) {
if (angular.isDefined(err) && $delegate.templatesLoader.hasOwnProperty('ocLazyLoadLoader')) {
$delegate._$log.error(err);
templatesDeferred.reject(err);
} else {
templatesDeferred.resolve();
}
}, params);
promises.push(templatesDeferred.promise);
}
if (jsFiles.length > 0) {
var jsDeferred = $q.defer();
$delegate.jsLoader(jsFiles, function (err) {
if (angular.isDefined(err) && ($delegate.jsLoader.hasOwnProperty("ocLazyLoadLoader") || $delegate.jsLoader.hasOwnProperty("requirejs"))) {
$delegate._$log.error(err);
jsDeferred.reject(err);
} else {
jsDeferred.resolve();
}
}, params);
promises.push(jsDeferred.promise);
}
if (promises.length === 0) {
var deferred = $q.defer(),
err = "Error: no file to load has been found, if you're trying to load an existing module you should use the 'inject' method instead of 'load'.";
$delegate._$log.error(err);
deferred.reject(err);
return deferred.promise;
} else if (params.serie && params.files.length > 0) {
return $q.all(promises).then(function () {
return $delegate.filesLoader(config, params);
});
} else {
return $q.all(promises)['finally'](function (res) {
$delegate.toggleWatch(false); // stop watching angular.module calls
return res;
});
}
};
/**
* Load a module or a list of modules into Angular
* @param module Mixed the name of a predefined module config object, or a module config object, or an array of either
* @param params Object optional parameters
* @returns promise
*/
$delegate.load = function (originalModule) {
var originalParams = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var self = this,
config = null,
deferredList = [],
deferred = $q.defer(),
errText;
// clean copy
var module = angular.copy(originalModule);
var params = angular.copy(originalParams);
// If module is an array, break it down
if (angular.isArray(module)) {
// Resubmit each entry as a single module
angular.forEach(module, function (m) {
deferredList.push(self.load(m, params));
});
// Resolve the promise once everything has loaded
$q.all(deferredList).then(function (res) {
deferred.resolve(res);
}, function (err) {
deferred.reject(err);
});
return deferred.promise;
}
// Get or Set a configuration depending on what was passed in
if (angular.isString(module)) {
config = self.getModuleConfig(module);
if (!config) {
config = {
files: [module]
};
}
} else if (angular.isObject(module)) {
// case {type: 'js', path: lazyLoadUrl + 'testModule.fakejs'}
if (angular.isDefined(module.path) && angular.isDefined(module.type)) {
config = {
files: [module]
};
} else {
config = self.setModuleConfig(module);
}
}
if (config === null) {
var moduleName = self._getModuleName(module);
errText = 'Module "' + (moduleName || 'unknown') + '" is not configured, cannot load.';
$delegate._$log.error(errText);
deferred.reject(new Error(errText));
return deferred.promise;
} else {
// deprecated
if (angular.isDefined(config.template)) {
if (angular.isUndefined(config.files)) {
config.files = [];
}
if (angular.isString(config.template)) {
config.files.push(config.template);
} else if (angular.isArray(config.template)) {
config.files.concat(config.template);
}
}
}
var localParams = angular.extend({}, params, config);
// if someone used an external loader and called the load function with just the module name
if (angular.isUndefined(config.files) && angular.isDefined(config.name) && $delegate.moduleExists(config.name)) {
return $delegate.inject(config.name, localParams, true);
}
$delegate.filesLoader(config, localParams).then(function () {
$delegate.inject(null, localParams).then(function (res) {
deferred.resolve(res);
}, function (err) {
deferred.reject(err);
});
}, function (err) {
deferred.reject(err);
});
return deferred.promise;
};
// return the patched service
return $delegate;
}]);
}]);
})(angular);
(function (angular) {
'use strict';
angular.module('oc.lazyLoad').config(["$provide", function ($provide) {
$provide.decorator('$ocLazyLoad', ["$delegate", "$q", function ($delegate, $q) {
/**
* cssLoader function
* @type Function
* @param paths array list of css files to load
* @param callback to call when everything is loaded. We use a callback and not a promise
* @param params object config parameters
* because the user can overwrite cssLoader and it will probably not use promises :(
*/
$delegate.cssLoader = function (paths, callback, params) {
var promises = [];
angular.forEach(paths, function (path) {
promises.push($delegate.buildElement('css', path, params));
});
$q.all(promises).then(function () {
callback();
}, function (err) {
callback(err);
});
};
$delegate.cssLoader.ocLazyLoadLoader = true;
return $delegate;
}]);
}]);
})(angular);
(function (angular) {
'use strict';
angular.module('oc.lazyLoad').config(["$provide", function ($provide) {
$provide.decorator('$ocLazyLoad', ["$delegate", "$q", function ($delegate, $q) {
/**
* jsLoader function
* @type Function
* @param paths array list of js files to load
* @param callback to call when everything is loaded. We use a callback and not a promise
* @param params object config parameters
* because the user can overwrite jsLoader and it will probably not use promises :(
*/
$delegate.jsLoader = function (paths, callback, params) {
var promises = [];
angular.forEach(paths, function (path) {
promises.push($delegate.buildElement('js', path, params));
});
$q.all(promises).then(function () {
callback();
}, function (err) {
callback(err);
});
};
$delegate.jsLoader.ocLazyLoadLoader = true;
return $delegate;
}]);
}]);
})(angular);
(function (angular) {
'use strict';
angular.module('oc.lazyLoad').config(["$provide", function ($provide) {
$provide.decorator('$ocLazyLoad', ["$delegate", "$templateCache", "$q", "$http", function ($delegate, $templateCache, $q, $http) {
/**
* templatesLoader function
* @type Function
* @param paths array list of css files to load
* @param callback to call when everything is loaded. We use a callback and not a promise
* @param params object config parameters for $http
* because the user can overwrite templatesLoader and it will probably not use promises :(
*/
$delegate.templatesLoader = function (paths, callback, params) {
var promises = [],
filesCache = $delegate._getFilesCache();
angular.forEach(paths, function (url) {
var deferred = $q.defer();
promises.push(deferred.promise);
$http.get(url, params).then(function (response) {
var data = response.data;
if (angular.isString(data) && data.length > 0) {
angular.forEach(angular.element(data), function (node) {
if (node.nodeName === 'SCRIPT' && node.type === 'text/ng-template') {
$templateCache.put(node.id, node.innerHTML);
}
});
}
if (angular.isUndefined(filesCache.get(url))) {
filesCache.put(url, true);
}
deferred.resolve();
})['catch'](function (response) {
deferred.reject(new Error('Unable to load template file "' + url + '": ' + response.data));
});
});
return $q.all(promises).then(function () {
callback();
}, function (err) {
callback(err);
});
};
$delegate.templatesLoader.ocLazyLoadLoader = true;
return $delegate;
}]);
}]);
})(angular);
// Array.indexOf polyfill for IE8
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement, fromIndex) {
var k;
// 1. Let O be the result of calling ToObject passing
// the this value as the argument.
if (this == null) {
throw new TypeError('"this" is null or not defined');
}
var O = Object(this);
// 2. Let lenValue be the result of calling the Get
// internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If len is 0, return -1.
if (len === 0) {
return -1;
}
// 5. If argument fromIndex was passed let n be
// ToInteger(fromIndex); else let n be 0.
var n = +fromIndex || 0;
if (Math.abs(n) === Infinity) {
n = 0;
}
// 6. If n >= len, return -1.
if (n >= len) {
return -1;
}
// 7. If n >= 0, then Let k be n.
// 8. Else, n<0, Let k be len - abs(n).
// If k is less than 0, then let k be 0.
k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
// 9. Repeat, while k < len
while (k < len) {
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the
// HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
// i. Let elementK be the result of calling the Get
// internal method of O with the argument ToString(k).
// ii. Let same be the result of applying the
// Strict Equality Comparison Algorithm to
// searchElement and elementK.
// iii. If same is true, return k.
if (k in O && O[k] === searchElement) {
return k;
}
k++;
}
return -1;
};
}