From 36c21ca322265787f8e327a6156818fb72f64630 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 13 Nov 2013 18:44:44 +1100 Subject: [PATCH] refactors out ui.tablet into private variable - only navigationService needs to know about this, otherwise if everything does it needs to go into appState and the listener needs to go elsewhere (a directive) --- .../src/common/services/navigation.service.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 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 f141cd22e0..009ba33022 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 @@ -20,11 +20,12 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo var minScreenSize = 1100; //used to track the current dialog object var currentDialog = null; + //tracks the screen size as a tablet + var isTablet = false; //TODO: Once most of the state vars have been refactored out to use appState, this UI object will be internal ONLY and will not be // exposed from this service. - var ui = { - tablet: false, + var ui = { currentPath: undefined, currentTree: undefined, treeEventHandler: undefined, @@ -35,9 +36,9 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo }; function setTreeMode() { - ui.tablet = ($(window).width() <= minScreenSize); + isTablet = ($(window).width() <= minScreenSize); - appState.setGlobalState("showNavigation", !ui.tablet); + appState.setGlobalState("showNavigation", !isTablet); } function setMode(mode) { @@ -88,7 +89,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo appState.setGlobalState("stickyNavigation", false); appState.setGlobalState("showTray", false); - if (ui.tablet) { + if (isTablet) { appState.setGlobalState("showNavigation", false); } @@ -104,8 +105,6 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo /** initializes the navigation service */ init: function() { - //TODO: detect tablet mode, subscribe to window resizing - //for now we just hardcode it to non-tablet mode setTreeMode(); //keep track of the current section - initially this will always be undefined so @@ -402,7 +401,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo */ hideTree: function() { - if (this.ui.tablet && !appState.getGlobalState("stickyNavigation")) { + if (isTablet && !appState.getGlobalState("stickyNavigation")) { //reset it to whatever is in the url appState.setSectionState("currentSection", $routeParams.section); setMode("default-hidesectiontree");