summaryrefslogtreecommitdiff
path: root/web-ui/app/js
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/app/js')
-rw-r--r--web-ui/app/js/page/default.js2
-rw-r--r--web-ui/app/js/page/unread_count_title.js25
-rw-r--r--web-ui/app/js/views/templates.js1
3 files changed, 19 insertions, 9 deletions
diff --git a/web-ui/app/js/page/default.js b/web-ui/app/js/page/default.js
index 1ca10b50..e33ec723 100644
--- a/web-ui/app/js/page/default.js
+++ b/web-ui/app/js/page/default.js
@@ -128,7 +128,7 @@ define(
feedback.attachTo('#feedback');
feedbackSender.attachTo(document);
- unreadCountTitle.attachTo('#unread-count-title');
+ unreadCountTitle.attachTo(document);
}
return initialize;
diff --git a/web-ui/app/js/page/unread_count_title.js b/web-ui/app/js/page/unread_count_title.js
index f60f5668..26daabec 100644
--- a/web-ui/app/js/page/unread_count_title.js
+++ b/web-ui/app/js/page/unread_count_title.js
@@ -19,21 +19,32 @@
define(
[
'flight/lib/component',
- 'views/templates',
'page/events',
],
- function (defineComponent, templates, events) {
+ function (defineComponent, events) {
'use strict';
-
+
return defineComponent(function () {
- this.render = function () {
- var unreadCountTitleHTML = templates.page.unreadCountTitle();
- this.$node.html(unreadCountTitleHTML);
+ this.getTitleText = function () {
+ return document.title;
+ };
+
+ this.updateCount = function (ev, data) {
+ var unread = data.mails.filter(function (mail) {
+ return mail.status.indexOf('read') === -1;
+ }).length;
+
+ if (unread > 0) {
+ document.title = '(' + unread + ') - ' + this.rawTitle;
+ } else {
+ document.title = this.rawTitle;
+ }
};
this.after('initialize', function () {
- this.render();
+ this.rawTitle = document.title;
+ this.on(document, events.mails.available, this.updateCount);
});
});
diff --git a/web-ui/app/js/views/templates.js b/web-ui/app/js/views/templates.js
index 99bffae9..e3b8d1f2 100644
--- a/web-ui/app/js/views/templates.js
+++ b/web-ui/app/js/views/templates.js
@@ -62,7 +62,6 @@ define(['hbs/templates'], function (templates) {
userSettingsBox: window.Pixelated['app/templates/page/user_settings_box.hbs'],
logout: window.Pixelated['app/templates/page/logout.hbs'],
logoutShortcut: window.Pixelated['app/templates/page/logout_shortcut.hbs'],
- unreadCountTitle: window.Pixelated['app/templates/page/unread_count_title.hbs'],
version: window.Pixelated['app/templates/page/version.hbs']
},
feedback: {