Fixes all references to assetsService.load* that do not pass in a required scope object and changes assets.service to always use the $rootScope of an explicit scope is not passed

This commit is contained in:
Shannon
2018-04-03 11:27:53 +10:00
parent a27ea994b7
commit e77ebc0c1c
18 changed files with 39 additions and 47 deletions

View File

@@ -125,7 +125,7 @@
function link(scope, el, attr, ngModel) {
// Load in ace library
assetsService.load(['lib/ace-builds/src-min-noconflict/ace.js', 'lib/ace-builds/src-min-noconflict/ext-language_tools.js']).then(function () {
assetsService.load(['lib/ace-builds/src-min-noconflict/ace.js', 'lib/ace-builds/src-min-noconflict/ext-language_tools.js'], scope).then(function () {
if (angular.isUndefined(window.ace)) {
throw new Error('ui-ace need ace to work... (o rly?)');
} else {

View File

@@ -101,7 +101,7 @@
var clipboard;
var target = element[0];
assetsService.loadJs("lib/clipboard/clipboard.min.js")
assetsService.loadJs("lib/clipboard/clipboard.min.js", scope)
.then(function () {
if(scope.umbClipboardTarget) {

View File

@@ -92,10 +92,10 @@ Use this directive to render a date time picker
scope.hasTranscludedContent = element.find('.js-datePicker__transcluded-content')[0].children.length > 0;
// load css file for the date picker
assetsService.loadCss('lib/datetimepicker/bootstrap-datetimepicker.min.css');
assetsService.loadCss('lib/datetimepicker/bootstrap-datetimepicker.min.css', scope);
// load the js file for the date picker
assetsService.loadJs('lib/datetimepicker/bootstrap-datetimepicker.js').then(function () {
assetsService.loadJs('lib/datetimepicker/bootstrap-datetimepicker.js', scope).then(function () {
// init date picker
initDatePicker();
});

View File

@@ -129,14 +129,12 @@ angular.module('umbraco.services')
asset.state = "loading";
LazyLoad.css(appendRnd(path), function () {
if (!scope) {
asset.state = "loaded";
asset.deferred.resolve(true);
} else {
asset.state = "loaded";
angularHelper.safeApply(scope, function () {
asset.deferred.resolve(true);
});
scope = $rootScope;
}
asset.state = "loaded";
angularHelper.safeApply(scope, function () {
asset.deferred.resolve(true);
});
});
} else if (asset.state === "loaded") {
asset.deferred.resolve(true);
@@ -171,14 +169,12 @@ angular.module('umbraco.services')
LazyLoad.js(appendRnd(path), function () {
if (!scope) {
asset.state = "loaded";
asset.deferred.resolve(true);
} else {
asset.state = "loaded";
angularHelper.safeApply(scope, function () {
asset.deferred.resolve(true);
});
scope = $rootScope;
}
asset.state = "loaded";
angularHelper.safeApply(scope, function () {
asset.deferred.resolve(true);
});
});
} else if (asset.state === "loaded") {
@@ -234,8 +230,7 @@ angular.module('umbraco.services')
assets.push(asset);
}
//we need to always push to the promises collection to monitor correct
//execution
//we need to always push to the promises collection to monitor correct execution
promises.push(asset.deferred.promise);
}
});
@@ -256,8 +251,7 @@ angular.module('umbraco.services')
function assetLoaded(asset) {
asset.state = "loaded";
if (!scope) {
asset.deferred.resolve(true);
return;
scope = $rootScope;
}
angularHelper.safeApply(scope,
function () {
@@ -280,4 +274,4 @@ angular.module('umbraco.services')
};
return service;
});
});

View File

@@ -278,8 +278,6 @@ angular.module('umbraco.services')
/** Loads the Moment.js Locale for the current user. */
loadMomentLocaleForCurrentUser: function () {
function loadLocales(currentUser, supportedLocales) {
var locale = currentUser.locale.toLowerCase();
@@ -294,7 +292,7 @@ angular.module('umbraco.services')
localeUrls.push('lib/moment/' + majorLocale);
}
}
return assetsService.load(localeUrls);
return assetsService.load(localeUrls, $rootScope);
}
else {
//return a noop promise

View File

@@ -1,6 +1,6 @@
angular.module("umbraco")
.controller("Umbraco.Dialogs.ApprovedColorPickerController", function ($scope, $http, umbPropEditorHelper, assetsService) {
assetsService.loadJs("lib/cssparser/cssparser.js")
assetsService.loadJs("lib/cssparser/cssparser.js", $scope)
.then(function () {
var cssPath = $scope.dialogData.cssPath;
@@ -19,7 +19,7 @@ angular.module("umbraco")
$scope.classes.splice(0, 0, "noclass");
})
assetsService.loadCss("/App_Plugins/Lecoati.uSky.Grid/lib/uSky.Grid.ApprovedColorPicker.css");
assetsService.loadCss(cssPath);
assetsService.loadCss("/App_Plugins/Lecoati.uSky.Grid/lib/uSky.Grid.ApprovedColorPicker.css", $scope);
assetsService.loadCss(cssPath, $scope);
});
});
});

View File

@@ -95,7 +95,7 @@ function startUpDynamicContentController($timeout, dashboardResource, assetsServ
}));
//proxy remote css through the local server
assetsService.loadCss( dashboardResource.getRemoteDashboardCssUrl("content") );
assetsService.loadCss(dashboardResource.getRemoteDashboardCssUrl("content"), $scope);
dashboardResource.getRemoteDashboardContent("content").then(
function (data) {

View File

@@ -249,7 +249,7 @@
function init() {
//we need to load this somewhere, for now its here.
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css");
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css", $scope);
if ($routeParams.create) {
@@ -355,4 +355,4 @@
}
angular.module("umbraco").controller("Umbraco.Editors.PartialViewMacros.EditController", partialViewMacrosEditController);
})();
})();

View File

@@ -242,7 +242,7 @@
function init() {
//we need to load this somewhere, for now its here.
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css");
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css", $scope);
if ($routeParams.create) {

View File

@@ -105,5 +105,5 @@
};
//load the separate css for the editor to avoid it blocking our js loading
assetsService.loadCss("lib/spectrum/spectrum.css");
assetsService.loadCss("lib/spectrum/spectrum.css", $scope);
});

View File

@@ -112,7 +112,7 @@ function dateTimePickerController($scope, notificationsService, assetsService, a
//get the current user to see if we can localize this picker
userService.getCurrentUser().then(function (user) {
assetsService.loadCss('lib/datetimepicker/bootstrap-datetimepicker.min.css').then(function() {
assetsService.loadCss('lib/datetimepicker/bootstrap-datetimepicker.min.css', $scope).then(function() {
var filesToLoad = ["lib/datetimepicker/bootstrap-datetimepicker.js"];

View File

@@ -2,7 +2,7 @@ angular.module("umbraco")
.controller("Umbraco.PropertyEditors.GoogleMapsController",
function ($element, $rootScope, $scope, notificationsService, dialogService, assetsService, $log, $timeout) {
assetsService.loadJs('https://www.google.com/jsapi')
assetsService.loadJs('https://www.google.com/jsapi', $scope)
.then(function () {
google.load("maps", "3",
{
@@ -94,4 +94,4 @@ angular.module("umbraco")
//update the display val again if it has changed from the server
initMap();
};
});
});

View File

@@ -74,7 +74,7 @@ function MarkdownEditorController($scope, $element, assetsService, dialogService
});
//load the seperat css for the editor to avoid it blocking our js loading TEMP HACK
assetsService.loadCss("lib/markdown/markdown.css");
assetsService.loadCss("lib/markdown/markdown.css", $scope);
})
}

View File

@@ -117,5 +117,5 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.RteController",
});
// load TinyMCE skin which contains css for font-icons
assetsService.loadCss("lib/tinymce/skins/umbraco/skin.min.css");
});
assetsService.loadCss("lib/tinymce/skins/umbraco/skin.min.css", $scope);
});

View File

@@ -211,7 +211,7 @@
});
//load the separate css for the editor to avoid it blocking our js loading
assetsService.loadCss("lib/slider/bootstrap-slider.css");
assetsService.loadCss("lib/slider/bootstrap-slider-custom.css");
assetsService.loadCss("lib/slider/bootstrap-slider.css", $scope);
assetsService.loadCss("lib/slider/bootstrap-slider-custom.css", $scope);
}
angular.module("umbraco").controller("Umbraco.PropertyEditors.SliderController", sliderController);

View File

@@ -7,7 +7,7 @@ angular.module("umbraco")
$scope.isLoading = true;
$scope.tagToAdd = "";
assetsService.loadJs("lib/typeahead.js/typeahead.bundle.min.js").then(function () {
assetsService.loadJs("lib/typeahead.js/typeahead.bundle.min.js", $scope).then(function () {
$scope.isLoading = false;

View File

@@ -92,7 +92,7 @@
function init() {
//we need to load this somewhere, for now its here.
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css");
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css", $scope);
if ($routeParams.create) {
codefileResource.getScaffold("scripts", $routeParams.id).then(function (script) {
@@ -199,4 +199,4 @@
}
angular.module("umbraco").controller("Umbraco.Editors.Scripts.EditController", ScriptsEditController);
})();
})();

View File

@@ -105,7 +105,7 @@
vm.init = function () {
//we need to load this somewhere, for now its here.
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css");
assetsService.loadCss("lib/ace-razor-mode/theme/razor_chrome.css", $scope);
//load templates - used in the master template picker
templateResource.getAll()