Files
2018-09-16 15:08:47 -04:00

71 lines
2.9 KiB
JavaScript

var app = angular.module('umbraco', [
'umbraco.filters',
'umbraco.directives',
'umbraco.resources',
'umbraco.services',
'umbraco.packages',
'umbraco.views',
'ngCookies',
'ngSanitize',
'ngMobile',
'tmh.dynamicLocale',
'ngFileUpload',
'LocalStorageModule'
]);
var packages = angular.module("umbraco.packages", []);
//this ensures we can inject our own views into templateCache and clear
//the entire cache before the app runs, due to the module
//order, clearing will always happen before umbraco.views and umbraco
//module is initilized.
angular.module("umbraco.views", ["umbraco.viewcache"]);
angular.module("umbraco.viewcache", [])
.run(function ($rootScope, $templateCache, localStorageService) {
/** For debug mode, always clear template cache to cut down on
dev frustration and chrome cache on templates */
if (Umbraco.Sys.ServerVariables.isDebuggingEnabled) {
$templateCache.removeAll();
}
else {
var storedVersion = localStorageService.get("umbVersion");
if (!storedVersion || storedVersion !== Umbraco.Sys.ServerVariables.application.cacheBuster) {
//if the stored version doesn't match our cache bust version, clear the template cache
$templateCache.removeAll();
//store the current version
localStorageService.set("umbVersion", Umbraco.Sys.ServerVariables.application.cacheBuster);
}
}
})
.config([
//This ensures that all of our angular views are cache busted, if the path starts with views/ and ends with .html, then
// we will append the cache busting value to it. This way all upgraded sites will not have to worry about browser cache.
"$provide", function($provide) {
return $provide.decorator("$http", [
"$delegate", function($delegate) {
var get = $delegate.get;
$delegate.get = function (url, config) {
if (Umbraco.Sys.ServerVariables.application && url.startsWith("views/") && url.endsWith(".html")) {
var rnd = Umbraco.Sys.ServerVariables.application.cacheBuster;
var _op = (url.indexOf("?") > 0) ? "&" : "?";
url += _op + "umb__rnd=" + rnd;
}
return get(url, config);
};
return $delegate;
}
]);
}
]);
//Call a document callback if defined, this is sort of a dodgy hack to
// be able to configure angular values in the Default.cshtml
// view which is much easier to do that configuring values by injecting them in the back office controller
// to follow through to the js initialization stuff
if (angular.isFunction(document.angularReady)) {
document.angularReady.apply(this, [app]);
}