From 5d49dfbe28a981a18d2665cf962ed305c483398c Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 13 Nov 2013 14:25:07 +1100 Subject: [PATCH] refactors showSearchResults to be part of appState --- .../src/common/services/appstate.service.js | 3 ++- .../src/common/services/navigation.service.js | 5 ++--- .../src/views/common/navigation.controller.js | 8 ++++++++ .../src/views/directives/umb-navigation.html | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) 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 d160e7ba53..20704108fb 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 @@ -20,7 +20,8 @@ function appState($rootScope) { var sectionState = { //The currently active section - currentSection: null + currentSection: null, + showSearchResults: null }; var treeState = { 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 71da12ffca..4d8d215dc7 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 @@ -26,7 +26,6 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo showContextMenu: false, stickyNavigation: false, showTray: false, - showSearchResults: false, currentSection: undefined, currentPath: undefined, currentTree: undefined, @@ -79,7 +78,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo ui.stickyNavigation = false; ui.showNavigation = true; ui.showContextMenu = false; - ui.showSearchResults = true; + appState.setSectionState("showSearchResults", true); appState.setMenuState("showMenu", false); $timeout(function() { @@ -91,7 +90,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo ui.currentMode = "default"; ui.showContextMenu = false; appState.setMenuState("showMenu", false); - ui.showSearchResults = false; + appState.setSectionState("showSearchResults", false); ui.stickyNavigation = false; ui.showTray = false; 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 44660c80ce..1dfcbc042e 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 @@ -18,6 +18,7 @@ function NavigationController($scope,$rootScope, $location, $log, $routeParams, //set up our scope vars $scope.showContextMenuDialog = false; + $scope.showSearchResults = false; //wire up the screensize and tree mode detection navigationService.init(); @@ -53,6 +54,13 @@ function NavigationController($scope,$rootScope, $location, $log, $routeParams, $scope.showContextMenuDialog = args.value; } }); + + //Listen for section state changes + $scope.$on("appState.sectionState.changed", function (e, args) { + if (args.key === "showSearchResults") { + $scope.showSearchResults = args.value; + } + }); //This reacts to clicks passed to the body element which emits a global call to close all dialogs $rootScope.$on("closeDialogs", function (event) { diff --git a/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html b/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html index dcc0b05f0c..323834a9a0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html +++ b/src/Umbraco.Web.UI.Client/src/views/directives/umb-navigation.html @@ -29,7 +29,7 @@ -
+