summaryrefslogtreecommitdiffstats
path: root/js/directive
diff options
context:
space:
mode:
Diffstat (limited to 'js/directive')
-rw-r--r--js/directive/NewsTitleUnreadCount.js32
1 files changed, 32 insertions, 0 deletions
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 <dev@bernhard-posselt.com>
+ * @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