From fc87a91e1452a35c5b9853c243efec053d9a1a0f Mon Sep 17 00:00:00 2001 From: perploug Date: Wed, 21 Aug 2013 14:24:29 +0200 Subject: [PATCH] Adds a delay to the navigation hide --- .../src/common/services/navigation.service.js | 48 ++++++++++++++++--- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js index 49740101c8..d17bb46eff 100644 --- a/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js +++ b/src/Umbraco.Web.UI.Client/src/common/services/navigation.service.js @@ -17,7 +17,7 @@ */ angular.module('umbraco.services') -.factory('navigationService', function ($rootScope, $routeParams, $log, $location, $q, dialogService, treeService, notificationsService) { +.factory('navigationService', function ($rootScope, $routeParams, $log, $location, $q, $timeout, dialogService, treeService, notificationsService) { //TODO: would be nicer to set all of the options here first instead of implicitly below! var ui = {}; @@ -61,7 +61,8 @@ angular.module('umbraco.services') } } - return { + var service = { + active: false, mode: "default", ui: ui, @@ -116,6 +117,36 @@ angular.module('umbraco.services') } }, + /** + * @ngdoc method + * @name umbraco.services.navigationService#enterTree + * @methodOf umbraco.services.navigationService + * + * @description + * Sets a service variable as soon as the user hovers the navigation with the mouse + * used by the leaveTree method to delay hiding + */ + enterTree: function () { + servicea.active = true; + }, + + /** + * @ngdoc method + * @name umbraco.services.navigationService#leaveTree + * @methodOf umbraco.services.navigationService + * + * @description + * Hides navigation tree, with a short delay, is cancelled if the user moves the mouse over the tree again + */ + leaveTree: function () { + service.active = false; + $timeout(function(){ + if(!service.active){ + service.hideTree(); + } + }, 700); + }, + /** * @ngdoc method * @name umbraco.services.navigationService#hideTree @@ -126,7 +157,6 @@ angular.module('umbraco.services') */ hideTree: function () { if (!this.ui.stickyNavigation) { - $log.log("hide tree"); this.ui.currentSection = ""; setMode("default-hidesectiontree"); } @@ -358,12 +388,16 @@ angular.module('umbraco.services') * hides any open navigation panes and resets the tree, actions and the currently selected node */ hideNavigation: function () { - this.ui.currentSection = ""; - this.ui.actions = []; - this.ui.currentNode = undefined; - setMode("default"); + if(!service.active){ + this.ui.currentSection = ""; + this.ui.actions = []; + this.ui.currentNode = undefined; + + setMode("default"); + } } }; + return service; });