From 0675405a8cb0a35797e4f0b96bd9072986bd1507 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sat, 31 May 2014 01:34:08 +0200 Subject: show unreadcount in title --- js/directive/NewsTitleUnreadCount.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 js/directive/NewsTitleUnreadCount.js (limited to 'js/directive') diff --git a/js/directive/NewsTitleUnreadCount.js b/js/directive/NewsTitleUnreadCount.js new file mode 100644 index 000000000..709b910ed --- /dev/null +++ b/js/directive/NewsTitleUnreadCount.js @@ -0,0 +1,32 @@ +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt + * @copyright Bernhard Posselt 2014 + */ +app.directive('newsTitleUnreadCount', ($window) => { + 'use strict'; + + let baseTitle = $window.document.title; + + return { + restrict: 'E', + scope: { + unreadCount: '@' + }, + link: (scope, elem, attrs) => { + attrs.$observe('unreadCount', (value) => { + let titles = baseTitle.split('-'); + + if (value !== '0') { + $window.document.title = titles[0] + + '(' + value + ') - ' + titles[1]; + } + }); + } + }; + +}); \ No newline at end of file -- cgit v1.2.3