Mercurial > hg > rc1
view plugins/newmail_notifier/newmail_notifier.min.js @ 34:50ac5484d514
one fix to distro
author | Charlie Root |
---|---|
date | Sun, 27 May 2018 16:53:56 -0400 |
parents | 1e000243b222 |
children |
line wrap: on
line source
/** * New Mail Notifier plugin script * * @author Aleksander Machniak <alec@alec.pl> * * @licstart The following is the entire license notice for the * JavaScript code in this file. * * Copyright (c) 2013-2016, The Roundcube Dev Team * * The JavaScript code in this page is free software: you can redistribute it * and/or modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * @licend The above is the entire license notice * for the JavaScript code in this file. */ window.rcmail&&"mail"==rcmail.env.task&&rcmail.addEventListener("plugin.newmail_notifier",newmail_notifier_run).addEventListener("actionbefore",newmail_notifier_stop).addEventListener("init",function(){rcmail.message_list&&rcmail.message_list.addEventListener("select",newmail_notifier_stop)});function newmail_notifier_run(a){a.basic&&newmail_notifier_basic();a.sound&&newmail_notifier_sound();a.desktop&&newmail_notifier_desktop(rcmail.get_label("body","newmail_notifier"))} function newmail_notifier_stop(a){!rcmail.env.favicon_href||!rcmail.env.favicon_changed||a&&"check-recent"==a.action||($('<link rel="shortcut icon" href="'+rcmail.env.favicon_href+'"/>').replaceAll('link[rel="shortcut icon"]'),rcmail.env.favicon_changed=0);try{window.external.msIsSiteMode()&&window.external.msSiteModeClearIconOverlay()}catch(b){}} function newmail_notifier_basic(){var a=rcmail.is_framed()?window.parent:window,b=rcmail.assets_path("plugins/newmail_notifier");a.focus();var c=$('<link rel="shortcut icon">').attr("href",b+"/favicon.ico");a=$('link[rel="shortcut icon"]',a.document);rcmail.env.favicon_href||(rcmail.env.favicon_href=a.attr("href"));rcmail.env.favicon_changed=1;c.replaceAll(a);try{window.external.msIsSiteMode()&&window.external.msSiteModeSetIconOverlay(b+"/overlay.ico",rcmail.get_label("title","newmail_notifier"))}catch(d){}} function newmail_notifier_sound(){var a=rcmail.assets_path("plugins/newmail_notifier/sound"),b=navigator.mimeTypes?navigator.mimeTypes["audio/mp3"]:{};a+=bw.ie||b&&b.enabledPlugin?".mp3":".wav";try{var c=$("<audio>").attr("src",a);c.get(0).play()}catch(d){c=$('<embed id="sound" src="'+a+'" hidden=true autostart=true loop=false />'),c.appendTo($("body")),window.setTimeout("$('#sound').remove()",5E3)}} function newmail_notifier_desktop(a,b){var c=rcmail.env.newmail_notifier_timeout||10,d=rcmail.assets_path("plugins/newmail_notifier/mail.png"),e=function(){var b=new window.Notification(rcmail.get_label("title","newmail_notifier"),{dir:"auto",lang:"",body:a,tag:"newmail_notifier",icon:d});b.onclick=function(){this.close()};setTimeout(function(){b.close()},1E3*c)};try{return window.Notification.requestPermission(function(a){"granted"==a?e():"denied"==a&&b&&b()}),!0}catch(f){return!1}} function newmail_notifier_test_desktop(){newmail_notifier_desktop(rcmail.get_label("testbody","newmail_notifier"),function(){rcmail.display_message(rcmail.get_label("desktopdisabled","newmail_notifier"),"error")})||rcmail.display_message(rcmail.get_label("desktopunsupported","newmail_notifier"),"error")}function newmail_notifier_test_basic(){newmail_notifier_basic()}function newmail_notifier_test_sound(){newmail_notifier_sound()};