refactored out the usage of ui.showTray to use appState

This commit is contained in:
Shannon
2013-11-13 16:35:23 +11:00
parent 2aaf3d06fa
commit 886d146595
5 changed files with 19 additions and 10 deletions

View File

@@ -16,6 +16,8 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se
scope.sections = [];
scope.nav = navigationService;
scope.currentSection = appState.getSectionState("currentSection");
scope.showTray = appState.getGlobalState("showTray");
scope.needTray = false;
function loadSections(){
sectionResource.getSections()
@@ -40,6 +42,13 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se
});
}
//Listen for showTray changes
scope.$on("appState.globalState.changed", function (e, args) {
if (args.key === "showTray") {
scope.showTray = args.value;
}
});
//When the user logs in
scope.$on("authenticated", function (evt, data) {
//populate their sections if the user has changed

View File

@@ -13,7 +13,8 @@ function appState($rootScope) {
var globalState = {
showNavigation: null,
touchDevice: null
touchDevice: null,
showTray: null
};
var sectionState = {

View File

@@ -23,7 +23,6 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
var ui = {
tablet: false,
stickyNavigation: false,
showTray: false,
currentPath: undefined,
currentTree: undefined,
treeEventHandler: undefined,
@@ -53,7 +52,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
appState.setMenuState("showMenu", false);
appState.setMenuState("showMenuDialog", false);
ui.stickyNavigation = false;
ui.showTray = false;
appState.setGlobalState("showTray", false);
//$("#search-form input").focus();
break;
@@ -91,7 +90,7 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
appState.setMenuState("showMenuDialog", false);
appState.setSectionState("showSearchResults", false);
ui.stickyNavigation = false;
ui.showTray = false;
appState.setGlobalState("showTray", false);
if (ui.tablet) {
appState.setGlobalState("showNavigation", false);
@@ -186,12 +185,12 @@ function navigationService($rootScope, $routeParams, $log, $location, $q, $timeo
setMode("tree");
},
showTray: function() {
ui.showTray = true;
showTray: function () {
appState.setGlobalState("showTray", true);
},
hideTray: function() {
ui.showTray = false;
hideTray: function () {
appState.setGlobalState("showTray", false);
},
//adding this to get clean global access to the main tree directive

View File

@@ -11,7 +11,7 @@
*/
function NavigationController($scope, $rootScope, $location, $log, $routeParams, appState, navigationService, keyboardService, dialogService, historyService, sectionResource, angularHelper) {
//TODO: Put all of this nav service init in the main controller ! - or on the appStart not here!
//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
$scope.treeEventHandler = $({});
navigationService.setupTreeEvents($scope.treeEventHandler, $scope);

View File

@@ -31,7 +31,7 @@
</ul>
</div>
<div id="applications-tray" ng-show="nav.ui.showTray" ng-animate="'slide'">
<div id="applications-tray" ng-show="showTray" ng-animate="'slide'">
<ul class="sections sections-tray">
<li ng-repeat="section in sections | limitTo: overflowingSections" ng-class="{current: section.alias == currentSection}">
<a href="#/{{section.alias}}"