/** * New Mail Notifier plugin script * * @version @package_version@ * @author Aleksander Machniak */ if (window.rcmail && rcmail.env.task == 'mail') { rcmail.addEventListener('plugin.newmail_notifier', newmail_notifier_run); rcmail.addEventListener('actionbefore', newmail_notifier_stop); rcmail.addEventListener('init', function() { // bind to messages list select event, so favicon will be reverted on message preview too if (rcmail.message_list) rcmail.message_list.addEventListener('select', newmail_notifier_stop); }); } // Executes notification methods function newmail_notifier_run(prop) { if (prop.basic) newmail_notifier_basic(); if (prop.sound) newmail_notifier_sound(); if (prop.desktop) newmail_notifier_desktop(rcmail.gettext('body', 'newmail_notifier')); } // Stops notification function newmail_notifier_stop(prop) { // revert original favicon if (rcmail.env.favicon_href && rcmail.env.favicon_changed && (!prop || prop.action != 'check-recent')) { $('').replaceAll('link[rel="shortcut icon"]'); rcmail.env.favicon_changed = 0; } } // Basic notification: window.focus and favicon change function newmail_notifier_basic() { var w = rcmail.is_framed() ? window.parent : window; w.focus(); // we cannot simply change a href attribute, we must to replace the link element (at least in FF) var link = $(''), oldlink = $('link[rel="shortcut icon"]', w.document); if (!rcmail.env.favicon_href) rcmail.env.favicon_href = oldlink.attr('href'); rcmail.env.favicon_changed = 1; link.replaceAll(oldlink); } // Sound notification function newmail_notifier_sound() { var elem, src = 'plugins/newmail_notifier/sound.wav'; // HTML5 try { elem = $('