From 4c23f21ae1078d0b4c27e3f061c3772760b75aad Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Mon, 12 Sep 2016 16:11:35 -0400 Subject: [PATCH] (js) Insert unseen msgs count in window's title --- NEWS | 1 + UI/Templates/UIxPageFrame.wox | 4 +--- UI/WebServerResources/js/Mailer/MailboxController.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index a51a68c80..a3ba3f321 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Enhancements - [web] don't allow a recurrence rule to end before the first occurrence - [web] updated Angular Material to version 1.1.0 - [web] show user's name upon successful login + - [web] inserted unseen messages count and mailbox name in browser's window title Bug fixes - [eas] properly generate the BusyStatus for normal events diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox index 91fc82adc..0ce2d27ec 100644 --- a/UI/Templates/UIxPageFrame.wox +++ b/UI/Templates/UIxPageFrame.wox @@ -12,9 +12,7 @@ - - <var:string value="title" /> - + <var:string value="title"/> diff --git a/UI/WebServerResources/js/Mailer/MailboxController.js b/UI/WebServerResources/js/Mailer/MailboxController.js index 01421a1bd..3d2efbbef 100644 --- a/UI/WebServerResources/js/Mailer/MailboxController.js +++ b/UI/WebServerResources/js/Mailer/MailboxController.js @@ -8,7 +8,8 @@ */ MailboxController.$inject = ['$window', '$scope', '$timeout', '$q', '$state', '$mdDialog', '$mdToast', 'stateAccounts', 'stateAccount', 'stateMailbox', 'encodeUriFilter', 'sgFocus', 'Dialog', 'Account', 'Mailbox']; function MailboxController($window, $scope, $timeout, $q, $state, $mdDialog, $mdToast, stateAccounts, stateAccount, stateMailbox, encodeUriFilter, focus, Dialog, Account, Mailbox) { - var vm = this, messageDialog = null; + var vm = this, messageDialog = null, + defaultWindowTitle = angular.element($window.document).find('title').attr('sg-default') || "SOGo"; // Expose controller for eventual popup windows $window.$mailboxController = vm; @@ -42,6 +43,15 @@ angular.element($window).off('beforeunload', _compactBeforeUnload); }); + // Update window's title with unseen messages count of selected mailbox + $scope.$watch(function() { return vm.selectedFolder.unseenCount; }, function(unseenCount) { + var title = defaultWindowTitle + ' - '; + if (unseenCount) + title += '(' + unseenCount + ') '; + title += vm.selectedFolder.name; + $window.document.title = title; + }); + function _compactBeforeUnload(event) { return vm.selectedFolder.$compact(); }