summaryrefslogtreecommitdiffstats
path: root/js-old/directive/NewsTitleUnreadCount.js
diff options
context:
space:
mode:
Diffstat (limited to 'js-old/directive/NewsTitleUnreadCount.js')
-rw-r--r--js-old/directive/NewsTitleUnreadCount.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/js-old/directive/NewsTitleUnreadCount.js b/js-old/directive/NewsTitleUnreadCount.js
new file mode 100644
index 000000000..8454a1858
--- /dev/null
+++ b/js-old/directive/NewsTitleUnreadCount.js
@@ -0,0 +1,35 @@
+/**
+ * Nextcloud - 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', function ($window) {
+ 'use strict';
+
+ var baseTitle = $window.document.title;
+ var titles = baseTitle.split('-');
+ var appName = titles[0] || 'News';
+ var ownCloudName = titles[1] || 'Nextcloud';
+
+ return {
+ restrict: 'E',
+ scope: {
+ unreadCount: '@'
+ },
+ link: function (scope, elem, attrs) {
+ attrs.$observe('unreadCount', function (value) {
+ if (value !== '0') {
+ $window.document.title = appName +
+ '(' + value + ') - ' + ownCloudName;
+ } else {
+ $window.document.title = appName + ' - ' + ownCloudName;
+ }
+ });
+ }
+ };
+
+}); \ No newline at end of file