summaryrefslogtreecommitdiff
path: root/plugins/newmail_notifier/newmail_notifier.js
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/newmail_notifier/newmail_notifier.js')
-rw-r--r--plugins/newmail_notifier/newmail_notifier.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/plugins/newmail_notifier/newmail_notifier.js b/plugins/newmail_notifier/newmail_notifier.js
index c398424b6..846bc94c3 100644
--- a/plugins/newmail_notifier/newmail_notifier.js
+++ b/plugins/newmail_notifier/newmail_notifier.js
@@ -30,9 +30,9 @@ function newmail_notifier_run(prop)
function newmail_notifier_stop(prop)
{
// revert original favicon
- if (rcmail.env.favicon_href && (!prop || prop.action != 'check-recent')) {
+ if (rcmail.env.favicon_href && rcmail.env.favicon_changed && (!prop || prop.action != 'check-recent')) {
$('<link rel="shortcut icon" href="'+rcmail.env.favicon_href+'"/>').replaceAll('link[rel="shortcut icon"]');
- rcmail.env.favicon_href = null;
+ rcmail.env.favicon_changed = 0;
}
// Remove IE icon overlay if we're pinned to Taskbar
@@ -54,7 +54,10 @@ function newmail_notifier_basic()
var link = $('<link rel="shortcut icon" href="plugins/newmail_notifier/favicon.ico"/>'),
oldlink = $('link[rel="shortcut icon"]', w.document);
- rcmail.env.favicon_href = oldlink.attr('href');
+ if (!rcmail.env.favicon_href)
+ rcmail.env.favicon_href = oldlink.attr('href');
+
+ rcmail.env.favicon_changed = 1;
link.replaceAll(oldlink);
// Add IE icon overlay if we're pinned to Taskbar
@@ -87,13 +90,11 @@ function newmail_notifier_sound()
// - Require Chrome or Firefox latest version (22+) / 21.0 or older with a plugin
function newmail_notifier_desktop(body)
{
+ var timeout = rcmail.env.newmail_notifier_timeout || 10;
-/**
- * Fix: As of 17 June 2013, Chrome/Chromium does not implement Notification.permission correctly that
- * it gives 'undefined' until an object has been created:
- * https://code.google.com/p/chromium/issues/detail?id=163226
- *
- */
+ // As of 17 June 2013, Chrome/Chromium does not implement Notification.permission correctly that
+ // it gives 'undefined' until an object has been created:
+ // https://code.google.com/p/chromium/issues/detail?id=163226
try {
if (Notification.permission == 'granted' || Notification.permission == undefined) {
var popup = new Notification(rcmail.gettext('title', 'newmail_notifier'), {
@@ -106,7 +107,7 @@ function newmail_notifier_desktop(body)
popup.onclick = function() {
this.close();
}
- setTimeout(function() { popup.close(); }, 10000); // close after 10 seconds
+ setTimeout(function() { popup.close(); }, timeout * 1000);
if (popup.permission == 'granted') return true;
}
}
@@ -122,7 +123,7 @@ function newmail_notifier_desktop(body)
this.cancel();
}
popup.show();
- setTimeout(function() { popup.cancel(); }, 10000); // close after 10 seconds
+ setTimeout(function() { popup.cancel(); }, timeout * 1000);
rcmail.newmail_popup = popup;
return true;
}