From 33a4f2b83565fe339484ac4b79c000a3ad53328a Mon Sep 17 00:00:00 2001 From: Athou Date: Sat, 6 Apr 2013 17:29:27 +0200 Subject: [PATCH] unread count in page title (fixes #17) --- src/main/webapp/js/controllers.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/js/controllers.js b/src/main/webapp/js/controllers.js index 0f3fcf6d..9c52b21b 100644 --- a/src/main/webapp/js/controllers.js +++ b/src/main/webapp/js/controllers.js @@ -79,7 +79,7 @@ module.controller('SubscribeCtrl', function($scope, SubscriptionService) { }); module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams, - $location, $state, $route, SubscriptionService) { + $window, $location, $state, $route, SubscriptionService) { $scope.$on('$stateChangeSuccess', function() { $scope.selectedType = $stateParams._type; @@ -110,6 +110,18 @@ module.controller('CategoryTreeCtrl', function($scope, $timeout, $stateParams, } return count; }; + + var rootUnreadCount = function() { + return unreadCount($scope.SubscriptionService.subscriptions) + }; + + $scope.$watch(rootUnreadCount, function(value) { + var label = 'CommaFeed'; + if (value > 0) { + label += ' (' + value + ')'; + } + $window.document.title = label; + }); $scope.formatCategoryName = function(category) { var count = unreadCount(category); @@ -494,10 +506,11 @@ module.controller('SettingsCtrl', function($scope, $location, SettingsService) { }; }); -module.controller('ManageSettingsCtrl', function($scope, $location, AdminSettingsService) { - +module.controller('ManageSettingsCtrl', function($scope, $location, + AdminSettingsService) { + $scope.settings = AdminSettingsService.get(); - + $scope.cancel = function() { $location.path('/'); };