diff options
Diffstat (limited to 'plugins/newmail_notifier/newmail_notifier.js')
-rw-r--r-- | plugins/newmail_notifier/newmail_notifier.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/plugins/newmail_notifier/newmail_notifier.js b/plugins/newmail_notifier/newmail_notifier.js index b00f33d10..2beacf650 100644 --- a/plugins/newmail_notifier/newmail_notifier.js +++ b/plugins/newmail_notifier/newmail_notifier.js @@ -71,7 +71,13 @@ function newmail_notifier_basic() // Sound notification function newmail_notifier_sound() { - var elem, src = 'plugins/newmail_notifier/sound.wav'; + var elem, src = 'plugins/newmail_notifier/sound', + plugin = navigator.mimeTypes ? navigator.mimeTypes['audio/mp3'] : {}; + + // Internet Explorer does not support wav files, + // support in other browsers depends on enabled plugins, + // so we use wav as a fallback + src += bw.ie || (plugin && plugin.enabledPlugin) ? '.mp3' : '.wav'; // HTML5 try { @@ -90,13 +96,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'), { @@ -109,7 +113,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; } } @@ -125,7 +129,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; } |