zipdownload.min.js 2.3 KB
/**
 * ZipDownload plugin script
 *
 * @licstart  The following is the entire license notice for the
 * JavaScript code in this file.
 *
 * Copyright (c) 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.
 */
function rcmail_zipdownload(a){var i,e,n,l;"eml"!=a?rcmail.message_list&&1<rcmail.message_list.get_selection().length&&(i=[],e=rcmail.selection_post_data(),l="zipdownload-"+(new Date).getTime(),n=$("<iframe>").attr({name:l,style:"display:none"}),l=$("<form>").attr({target:l,style:"display: none",method:"post",action:rcmail.url("mail/plugin.zipdownload.messages")}),e._mode=a,e._token=rcmail.env.request_token,$.each(e,function(a,e){if("object"==typeof e&&1<e.length)for(var n=0;n<e.length;n++)i.push($("<input>").attr({type:"hidden",name:a+"[]",value:e[n]}));else i.push($("<input>").attr({type:"hidden",name:a,value:e}))}),n.appendTo(document.body),l.append(i).appendTo(document.body).submit()):(l=rcmail.get_single_uid(),rcmail.goto_url("viewsource",rcmail.params_from_uid(l,{_save:1}),!1,!0))}function rcmail_zipdownload_menu(a){var e=rcmail.message_list.get_selection().length;return rcmail.enable_command("download-eml",1==e),rcmail.enable_command("download-mbox","download-maildir",1<e),rcmail.command("menu-open","zipdownload-menu",a&&a.target?a.target:rcmail.env.download_link,a),!1}window.rcmail&&rcmail.addEventListener("init",function(a){rcmail.register_command("download-eml",function(){rcmail_zipdownload("eml")}),rcmail.register_command("download-mbox",function(){rcmail_zipdownload("mbox")}),rcmail.register_command("download-maildir",function(){rcmail_zipdownload("maildir")}),rcmail.message_list&&rcmail.message_list.addEventListener("select",function(a){a=a.get_selection().length;rcmail.enable_command("download",0<a)}),rcmail.addEventListener("beforedownload",rcmail_zipdownload_menu),$.each(rcmail.buttons.download||[],function(){var a=$("#"+this.id),e=$("span",a);e.length||(e=$("<span>"),a.html("").append(e)),a.attr("aria-haspopup","true"),e.text(rcmail.get_label("zipdownload.download")),rcmail.env.download_link=a})});