diff --git a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js index d4e31c81ee..912c624ce4 100644 --- a/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js +++ b/src/Umbraco.Web.UI.Client/lib/umbraco/LegacyUmbClientMgr.js @@ -361,7 +361,7 @@ Umbraco.Sys.registerNamespace("Umbraco.Application"); else { //instead of calling just the dialog service we funnel it through the global //event emitter - getRootScope().$emit("closeDialogs", undefined); + getRootScope().$emit("app.closeDialogs", undefined); } }, _debug: function(strMsg) { diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js index 5dec6c3586..349bf0a496 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/umbsections.directive.js @@ -3,7 +3,7 @@ * @name umbraco.directives.directive:umbSections * @restrict E **/ -function sectionsDirective($timeout, $window, navigationService, treeService, sectionResource, appState) { +function sectionsDirective($timeout, $window, navigationService, treeService, sectionResource, appState, eventsService) { return { restrict: "E", // restrict to an element replace: true, // replace the html element with the template @@ -51,7 +51,7 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se } //Listen for global state changes - scope.$on("appState.globalState.changed", function (e, args) { + eventsService.on("appState.globalState.changed", function (e, args) { if (args.key === "showTray") { scope.showTray = args.value; } @@ -60,7 +60,7 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se } }); - scope.$on("appState.sectionState.changed", function (e, args) { + eventsService.on("appState.sectionState.changed", function (e, args) { if (args.key === "currentSection") { scope.currentSection = args.value; } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js b/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js index 1714ec7526..d1d867977a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/appstate.service.js @@ -13,7 +13,7 @@ *
   *    scope.showTree = appState.getGlobalState("showNavigation");
   *
-  *    scope.$on("appState.globalState.changed", function (e, args) {
+  *    eventsService.on("appState.globalState.changed", function (e, args) {
   *               if (args.key === "showNavigation") {
   *                   scope.showTree = args.value;
   *               }
@@ -25,14 +25,14 @@
  * 
  *    scope.currentSection = appState.getSectionState("currentSection");
  *
- *    scope.$on("appState.sectionState.changed", function (e, args) {
+ *    eventsService.on("appState.sectionState.changed", function (e, args) {
  *               if (args.key === "currentSection") {
  *                   scope.currentSection = args.value;
  *               }
  *           });  
  * 
*/ -function appState($rootScope) { +function appState(eventsService) { //Define all variables here - we are never returning this objects so they cannot be publicly mutable // changed, we only expose methods to interact with the values. @@ -80,7 +80,7 @@ function appState($rootScope) { var changed = stateObj[key] !== value; stateObj[key] = value; if (changed) { - $rootScope.$broadcast("appState." + stateObjName + ".changed", { key: key, value: value }); + eventsService.emit("appState." + stateObjName + ".changed", { key: key, value: value }); } } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js index f5600037e5..0c65e0569a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/dialog.service.js @@ -29,7 +29,7 @@ */ angular.module('umbraco.services') -.factory('dialogService', function ($rootScope, $compile, $http, $timeout, $q, $templateCache, appState) { +.factory('dialogService', function ($rootScope, $compile, $http, $timeout, $q, $templateCache, appState, eventsService) { var dialogs = []; @@ -238,7 +238,7 @@ angular.module('umbraco.services') } /** Handles the closeDialogs event */ - $rootScope.$on("closeDialogs", function (evt, args) { + eventsService.on("app.closeDialogs", function (evt, args) { removeAllDialogs(args); }); diff --git a/src/Umbraco.Web.UI.Client/src/common/services/events.service.js b/src/Umbraco.Web.UI.Client/src/common/services/events.service.js index 542b454f2c..560b743a29 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/events.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/events.service.js @@ -1,24 +1,45 @@ /** Used to broadcast and listen for global events and allow the ability to add async listeners to the callbacks */ + +/* + Core app events: + + app.ready + app.authenticated + app.notAuthenticated + app.closeDialogs +*/ + function eventsService($q, $rootScope) { return { /** raise an event with a given name, returns an array of promises for each listener */ - publish: function (name, args) { + emit: function (name, args) { //there are no listeners if (!$rootScope.$$listeners[name]) { return []; } + //send the event + $rootScope.$emit(name, args); + + + //PP: I've commented out the below, since we currently dont + // expose the eventsService as a documented api + // and think we need to figure out our usecases for this + // since the below modifies the return value of the then on() method + /* //setup a deferred promise for each listener var deferred = []; for (var i = 0; i < $rootScope.$$listeners[name].length; i++) { deferred.push($q.defer()); - } + }*/ + //create a new event args object to pass to the - // $broadcast containing methods that will allow listeners + // $emit containing methods that will allow listeners // to return data in an async if required + /* var eventArgs = { args: args, reject: function (a) { @@ -27,20 +48,20 @@ function eventsService($q, $rootScope) { resolve: function (a) { deferred.pop().resolve(a); } - }; + };*/ - //send the event - $rootScope.$broadcast(name, eventArgs); + + /* //return an array of promises var promises = _.map(deferred, function(p) { return p.promise; }); - return promises; + return promises;*/ }, /** subscribe to a method, or use scope.$on = same thing */ - subscribe: function(name, callback) { + on: function(name, callback) { return $rootScope.$on(name, callback); }, @@ -50,7 +71,6 @@ function eventsService($q, $rootScope) { handle(); } } - }; } diff --git a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js index 70e4b9cba3..6a46da27f2 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/localization.service.js @@ -1,5 +1,5 @@ angular.module('umbraco.services') -.factory('localizationService', function ($http, $q, $rootScope, $window, $filter, userService) { +.factory('localizationService', function ($http, $q, eventsService, $window, $filter, userService) { var service = { // array to hold the localized resource string entries dictionary:[], @@ -15,7 +15,7 @@ angular.module('umbraco.services') // set the flag that the resource are loaded service.resourceFileLoaded = true; // broadcast that the file has been loaded - $rootScope.$broadcast('localizeResourcesUpdates'); + eventsService.emit("localizationService.updated", data); }, // allows setting of language on the fly @@ -38,7 +38,7 @@ angular.module('umbraco.services') service.resourceFileLoaded = true; service.dictionary = response.data; - $rootScope.$broadcast('localizeResourcesUpdates'); + eventsService.emit("localizationService.updated", service.dictionary); return deferred.resolve(service.dictionary); }, function(err){ @@ -102,13 +102,16 @@ angular.module('umbraco.services') } return "[" + value + "]"; } - - }; // force the load of the resource file service.initLocalizedResources(); + //This happens after login / auth and assets loading + eventsService.on("app.authenticated", function(){ + service.resourceFileLoaded = false; + }); + // return the local instance when called return service; }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js b/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js index ffa81967ec..63c77a114a 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/tree.service.js @@ -7,7 +7,7 @@ * @description * The tree service factory, used internally by the umbTree and umbTreeItem directives */ -function treeService($q, treeResource, iconHelper, notificationsService, $rootScope) { +function treeService($q, treeResource, iconHelper, notificationsService, eventsService) { //SD: Have looked at putting this in sessionStorage (not localStorage since that means you wouldn't be able to work // in multiple tabs) - however our tree structure is cyclical, meaning a node has a reference to it's parent and it's children @@ -252,7 +252,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, $rootSc }, function(reason) { //in case of error, emit event - $rootScope.$broadcast("treeNodeLoadError", {error: reason }); + eventsService.emit("treeService.treeNodeLoadError", {error: reason } ); //stop show the loading indicator node.loading = false; diff --git a/src/Umbraco.Web.UI.Client/src/common/services/user.service.js b/src/Umbraco.Web.UI.Client/src/common/services/user.service.js index 9348541826..3d1dec009d 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/user.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/user.service.js @@ -1,5 +1,5 @@ angular.module('umbraco.services') -.factory('userService', function ($rootScope, $q, $location, $log, securityRetryQueue, authResource, dialogService, $timeout, angularHelper) { +.factory('userService', function ($rootScope, eventsService, $q, $location, $log, securityRetryQueue, authResource, dialogService, $timeout, angularHelper) { var currentUser = null; var lastUserId = null; @@ -147,7 +147,7 @@ angular.module('umbraco.services') currentUser = null; //broadcast a global event that the user is no longer logged in - $rootScope.$broadcast("notAuthenticated"); + eventsService.emit("app.notAuthenticated"); openLoginDialog(isLogout === undefined ? true : !isLogout); } @@ -189,8 +189,7 @@ angular.module('umbraco.services') var result = { user: data, authenticated: true, lastUserId: lastUserId }; //broadcast a global event - $rootScope.$broadcast("authenticated", result); - + eventsService.emit("app.authenticated", result); return result; }); }, @@ -220,7 +219,7 @@ angular.module('umbraco.services') if (args && args.broadcastEvent) { //broadcast a global event, will inform listening controllers to load in the user specific data - $rootScope.$broadcast("authenticated", result); + eventsService.emit("app.authenticated", result); } setCurrentUser(data); diff --git a/src/Umbraco.Web.UI.Client/src/init.js b/src/Umbraco.Web.UI.Client/src/init.js index 984c2b1d64..d6244e5a06 100644 --- a/src/Umbraco.Web.UI.Client/src/init.js +++ b/src/Umbraco.Web.UI.Client/src/init.js @@ -1,17 +1,15 @@ /** Executed when the application starts, binds to events and set global state */ -app.run(['userService', '$log', '$rootScope', '$location', 'navigationService', 'appState', 'editorState', 'fileManager', 'assetsService', 'umbRequestHelper', - function (userService, $log, $rootScope, $location, navigationService, appState, editorState, fileManager, assetsService, umbRequestHelper) { +app.run(['userService', '$log', '$rootScope', '$location', 'navigationService', 'appState', 'editorState', 'fileManager', 'assetsService','eventsService', 'umbRequestHelper', + function (userService, $log, $rootScope, $location, navigationService, appState, editorState, fileManager, assetsService, eventsService, umbRequestHelper) { var firstRun = true; /** Listens for authentication and checks if our required assets are loaded, if/once they are we'll broadcast a ready event */ - $rootScope.$on("authenticated", function(evt, data) { - + eventsService.on("app.authenticated", function(evt, data) { assetsService._loadInitAssets().then(function() { //send the ready event - $rootScope.$broadcast("ready", data); + eventsService.emit("app.ready", data); }); - }); /** when we have a successful first route that is not the login page - *meaning the user is authenticated* @@ -57,5 +55,4 @@ app.run(['userService', '$log', '$rootScope', '$location', 'navigationService', //check for touch device, add to global appState var touchDevice = ("ontouchstart" in window || window.touch || window.navigator.msMaxTouchPoints === 5 || window.DocumentTouch && document instanceof DocumentTouch); appState.setGlobalState("touchDevice", touchDevice); - }]); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/contentpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/contentpicker.controller.js index 3c9ce94bf9..97eb4ace53 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/contentpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/contentpicker.controller.js @@ -43,7 +43,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.ContentPickerController", args.event.preventDefault(); args.event.stopPropagation(); - eventsService.publish("Umbraco.Dialogs.ContentPickerController.Select", args); + eventsService.emit("dialogs.contentPicker.select", args); if (dialogOptions && dialogOptions.multiPicker) { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js index b0ad65477e..49980ef843 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/linkpicker.controller.js @@ -30,7 +30,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.LinkPickerController", args.event.preventDefault(); args.event.stopPropagation(); - eventsService.publish("Umbraco.Dialogs.LinkPickerController.Select", args); + eventsService.emit("dialogs.linkPicker.select", args); var c = $(args.event.target.parentElement); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js index a6559cc0ef..a625e3e56a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/mediapicker.controller.js @@ -94,7 +94,7 @@ angular.module("umbraco") if (image.contentTypeAlias.toLowerCase() == 'folder' && !select) { $scope.gotoFolder(image); }else{ - eventsService.publish("Umbraco.Dialogs.MediaPickerController.Select", image); + eventsService.emit("dialogs.mediaPicker.select", image); if ($scope.multiPicker) { $scope.select(image); @@ -120,7 +120,7 @@ angular.module("umbraco") if (image.contentTypeAlias.toLowerCase() == 'folder') { $scope.gotoFolder(image); }else{ - eventsService.publish("Umbraco.Dialogs.MediaPickerController.Select", image); + eventsService.emit("dialogs.mediaPicker.select", image); if ($scope.multiPicker) { $scope.select(image); diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/membergrouppicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/membergrouppicker.controller.js index 3b3fac0d11..1882f81eba 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/membergrouppicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/membergrouppicker.controller.js @@ -40,7 +40,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.MemberGroupPickerControlle args.event.stopPropagation(); - eventsService.publish("Umbraco.Dialogs.MemberGroupPickerController.Select", args); + eventsService.emit("dialogs.memberGroupPicker.select", args); //This is a tree node, so we don't have an entity to pass in, it will need to be looked up //from the server in this method. diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/memberpicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/memberpicker.controller.js index 8731c62e44..85cbb802ff 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/memberpicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/memberpicker.controller.js @@ -62,7 +62,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.MemberPickerController", return; } - eventsService.publish("Umbraco.Dialogs.MemberPickerController.Select", args); + eventsService.emit("dialogs.memberPickerController", args); //This is a tree node, so we don't have an entity to pass in, it will need to be looked up //from the server in this method. diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js index 0ae5c667f4..4d7fd6be09 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/treepicker.controller.js @@ -173,7 +173,7 @@ angular.module("umbraco").controller("Umbraco.Dialogs.TreePickerController", args.event.preventDefault(); args.event.stopPropagation(); - eventsService.publish("Umbraco.Dialogs.TreePickerController.Select", args); + eventsService.emit("dialogs.treePickerController.select", args); if (args.node.filtered) { return; diff --git a/src/Umbraco.Web.UI.Client/src/views/common/login.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/login.controller.js index 65446f6f66..ad8fec63a9 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/login.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/login.controller.js @@ -1,13 +1,10 @@ /** This controller is simply here to launch the login dialog when the route is explicitly changed to /login */ -angular.module('umbraco').controller("Umbraco.LoginController", function ($scope, userService, $location) { +angular.module('umbraco').controller("Umbraco.LoginController", function (eventsService, $scope, userService, $location) { - userService._showLoginDialog(); - - //when the app is ready and the user is authorized, redirect - this will only be handled here when we are actually on the /login route - $scope.$on("ready", function (evt, data) { - //reset the avatar - $scope.avatar = "assets/img/application/logo.png"; - $location.path("/").search(""); + userService._showLoginDialog(); + + eventsService.on("app.ready", function(){ + $scope.avatar = "assets/img/application/logo.png"; + $location.path("/").search(""); }); - }); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js index c03ef50445..5a180ac223 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/main.controller.js @@ -8,7 +8,7 @@ * The main application controller * */ -function MainController($scope, $rootScope, $location, $routeParams, $timeout, $http, $log, appState, treeService, notificationsService, userService, navigationService, historyService, updateChecker, assetsService, umbRequestHelper) { +function MainController($scope, $rootScope, $location, $routeParams, $timeout, $http, $log, appState, treeService, notificationsService, userService, navigationService, historyService, updateChecker, assetsService, eventsService, umbRequestHelper) { //the null is important because we do an explicit bool check on this in the view //the avatar is by default the umbraco logo @@ -45,17 +45,17 @@ function MainController($scope, $rootScope, $location, $routeParams, $timeout, $ return; } - $rootScope.$emit("closeDialogs", event); + eventsService.emit("app.closeDialogs", event); }; //when a user logs out or timesout - $scope.$on("notAuthenticated", function() { + eventsService.on("app.notAuthenticated", function() { $scope.authenticated = null; $scope.user = null; }); //when the app is read/user is logged in, setup the data - $scope.$on("ready", function (evt, data) { + eventsService.on("app.ready", function (evt, data) { $scope.authenticated = data.authenticated; $scope.user = data.user; @@ -105,4 +105,4 @@ function MainController($scope, $rootScope, $location, $routeParams, $timeout, $ //register it -angular.module('umbraco').controller("Umbraco.MainController", MainController); +angular.module('umbraco').controller("Umbraco.MainController", MainController); \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js index d557abd403..c559cfb084 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/navigation.controller.js @@ -9,7 +9,7 @@ * * @param {navigationService} navigationService A reference to the navigationService */ -function NavigationController($scope, $rootScope, $location, $log, $routeParams, $timeout, appState, navigationService, keyboardService, dialogService, historyService, sectionResource, angularHelper) { +function NavigationController($scope, $rootScope, $location, $log, $routeParams, $timeout, appState, navigationService, keyboardService, dialogService, historyService, eventsService, sectionResource, angularHelper) { //TODO: Need to think about this and an nicer way to acheive what this is doing. //the tree event handler i used to subscribe to the main tree click events @@ -42,20 +42,20 @@ function NavigationController($scope, $rootScope, $location, $log, $routeParams, //trigger dialods with a hotkey: //TODO: Unfortunately this will also close the login dialog. keyboardService.bind("esc", function () { - $rootScope.$emit("closeDialogs"); + eventsService.emit("app.closeDialogs"); }); $scope.selectedId = navigationService.currentId; //Listen for global state changes - $scope.$on("appState.globalState.changed", function (e, args) { + eventsService.on("appState.globalState.changed", function (e, args) { if (args.key === "showNavigation") { $scope.showNavigation = args.value; } }); //Listen for menu state changes - $scope.$on("appState.menuState.changed", function (e, args) { + eventsService.on("appState.menuState.changed", function (e, args) { if (args.key === "showMenuDialog") { $scope.showContextMenuDialog = args.value; } @@ -74,7 +74,7 @@ function NavigationController($scope, $rootScope, $location, $log, $routeParams, }); //Listen for section state changes - $scope.$on("appState.sectionState.changed", function (e, args) { + eventsService.on("appState.sectionState.changed", function (e, args) { //section changed if (args.key === "currentSection") { $scope.currentSection = args.value; @@ -86,7 +86,7 @@ function NavigationController($scope, $rootScope, $location, $log, $routeParams, }); //This reacts to clicks passed to the body element which emits a global call to close all dialogs - $rootScope.$on("closeDialogs", function (event) { + eventsService.on("app.closeDialogs", function (event) { if (appState.getGlobalState("stickyNavigation")) { navigationService.hideNavigation(); //TODO: don't know why we need this? - we are inside of an angular event listener. @@ -95,12 +95,12 @@ function NavigationController($scope, $rootScope, $location, $log, $routeParams, }); //when a user logs out or timesout - $scope.$on("notAuthenticated", function () { + eventsService.on("app.notAuthenticated", function () { $scope.authenticated = false; }); //when the application is ready and the user is authorized setup the data - $scope.$on("ready", function (evt, data) { + eventsService.on("app.ready", function (evt, data) { $scope.authenticated = true; }); diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js index 27a4bf0046..32f4b287a3 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.copy.controller.js @@ -10,7 +10,7 @@ angular.module("umbraco") args.event.preventDefault(); args.event.stopPropagation(); - eventsService.publish("Umbraco.Editors.Content.CopyController.Select", args); + eventsService.publish("editors.content.copyController.select", args); var c = $(args.event.target.parentElement); if ($scope.selectedEl) { diff --git a/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js index 284e4a5fa2..71e08ac458 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/content.move.controller.js @@ -10,7 +10,7 @@ angular.module("umbraco").controller("Umbraco.Editors.Content.MoveController", args.event.preventDefault(); args.event.stopPropagation(); - eventsService.publish("Umbraco.Editors.Content.MoveController.Select", args); + eventsService.publish("editors.content.moveController.select", args); var c = $(args.event.target.parentElement); diff --git a/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js b/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js index b3b0b346c4..5f85adaf6a 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/media/media.move.controller.js @@ -10,7 +10,7 @@ angular.module("umbraco").controller("Umbraco.Editors.Media.MoveController", args.event.preventDefault(); args.event.stopPropagation(); - eventsService.publish("Umbraco.Editors.Media.MoveController.Select", args); + eventsService.emit("editors.media.moveController.select", args); var c = $(args.event.target.parentElement); diff --git a/src/Umbraco.Web.UI.Client/test/unit/common/services/events-service.spec.js b/src/Umbraco.Web.UI.Client/test/unit/common/services/events-service.spec.js index a696bdd0e4..37788a4cad 100644 --- a/src/Umbraco.Web.UI.Client/test/unit/common/services/events-service.spec.js +++ b/src/Umbraco.Web.UI.Client/test/unit/common/services/events-service.spec.js @@ -17,11 +17,11 @@ describe('angular event tests', function () { val: "" }; - eventsService.subscribe("testEvent", function (e, args) { + eventsService.on("testEvent", function (e, args) { args.args.val = "changed"; }); - eventsService.publish("testEvent", eventArgs); + eventsService.emit("testEvent", eventArgs); expect(eventArgs.val).toBe("changed"); @@ -33,15 +33,15 @@ describe('angular event tests', function () { val: "" }; - eventsService.subscribe("testEvent", function (e, args) { + eventsService.on("testEvent", function (e, args) { args.args.val = "changed"; }); - eventsService.subscribe("testEvent", function (e, args) { + eventsService.on("testEvent", function (e, args) { args.args.val = "changed1"; }); - eventsService.publish("testEvent", eventArgs); + eventsService.emit("testEvent", eventArgs); expect(eventArgs.val).toBe("changed1"); @@ -53,7 +53,7 @@ describe('angular event tests', function () { val: "" }; - eventsService.subscribe("testEvent", function (e, msg) { + eventsService.on("testEvent", function (e, msg) { $timeout(function () { msg.args.val = "changed"; //NOTE: We could resolve anything here @@ -61,16 +61,16 @@ describe('angular event tests', function () { }, 1000); }); - var promises = eventsService.publish("testEvent", eventArgs); + var promises = eventsService.emit("testEvent", eventArgs); //this won't be changed yet expect(eventArgs.val).toBe(""); + /* promises[0].then(function (args) { - console.log("WOOT"); expect(args.val).toBe("changed"); expect(eventArgs.val).toBe("changed"); - }); + });*/ $rootScope.$digest(); $timeout.flush(); @@ -82,7 +82,6 @@ describe('angular event tests', function () { //assign multiple listeners $rootScope.$on("testEvent", function(e, args) { - console.log("handler #1"); $timeout(function () { console.log("timeout #1"); args.val = "changed1"; @@ -91,7 +90,6 @@ describe('angular event tests', function () { }); $rootScope.$on("testEvent", function (e, args) { - console.log("handler #2"); $timeout(function () { console.log("timeout #2"); args.val = "changed2";