/** * Roundcube Webmail Client Script * * This file is part of the Roundcube Webmail client * * @licstart The following is the entire license notice for the * JavaScript code in this file. * * Copyright (C) The Roundcube Dev Team * Copyright (C) Kolab Systems AG * * 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 (GNU GPL) as published by the Free Software * Foundation, either version 3 of the License, or (at your option) * any later version. The code is distributed WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. * * As additional permission under GNU GPL version 3 section 7, you * may distribute non-source (e.g., minimized or compacted) forms of * that code without the copy of the GNU GPL normally required by * section 4, provided you include this license notice and a URL * through which recipients can access the Corresponding Source. * * @licend The above is the entire license notice * for the JavaScript code in this file. * * @author Thomas Bruederli * @author Aleksander 'A.L.E.C' Machniak * @author Charles McNulty * * @requires jquery.js, common.js, list.js */ function rcube_webmail(){this.labels={};this.buttons={};this.buttons_sel={};this.gui_objects={};this.gui_containers={};this.commands={};this.command_handlers={};this.onloads=[];this.messages={};this.group2expand={};this.http_request_jobs={};this.menu_stack=[];this.menu_buttons={};this.entity_selectors=[];this.image_style={};this.uploads={};this.dblclick_time=500;this.message_time=5E3;this.preview_delay_select=400;this.preview_delay_click=60;this.identifier_expr=/[^0-9a-z_-]/gi;this.env={request_timeout:180, draft_autosave:0,comm_path:"./",recipients_separator:",",recipients_delimiter:", ",popup_width:1150,popup_width_small:900,thread_padding:"15px"};this.ref="rcmail";var h=this;$.ajaxSetup({cache:!1,timeout:1E3*this.env.request_timeout,error:function(a,b,d){h.http_error(a,b,d)},beforeSend:function(a){a.setRequestHeader("X-Roundcube-Request",h.env.request_token)}});$(window).on("beforeunload",function(){h.unload=!0});this.set_env=function(a,b){if(null==a||"object"!==typeof a||b)this.env[a]=b;else for(var d in a)this.env[d]= a[d]};this.add_label=function(a,b){"string"==typeof a?this.labels[a]=b:"object"==typeof a&&$.extend(this.labels,a)};this.register_button=function(a,b,d,e,f,g){b={id:b,type:d};e&&(b.act=e);f&&(b.sel=f);g&&(b.over=g);this.buttons[a]||(this.buttons[a]=[]);this.buttons[a].push(b);this.loaded&&(this.init_button(a,b),this.set_button(a,this.commands[a]?"act":"pas"))};this.register_menu_button=function(a,b){if(this.menu_buttons[b])this.menu_buttons[b][0].push(a);else{var d=[];$("#"+b).find("a").each(function(){var e= $(this);var f=(f=e.attr("onclick"))&&String(f).match(/rcmail\.command\('([^']+)/)?RegExp.$1:function(){return e.is(".active")};d.push(f)});d.length&&(this.menu_buttons[b]=[[a],d])}this.set_menu_buttons()};this.set_menu_buttons=function(){clearTimeout(this.menu_buttons_timeout);this.menu_buttons_timeout=setTimeout(function(){$.each(h.menu_buttons,function(){var a=!0;$.each(this[1],function(){var b="function"==typeof this;if(b&&this()||!b&&h.commands[this])return a=!1});$(this[0]).add($(this[0]).parent(".dropbutton")).addClass(a? "disabled":"active").removeClass(a?"active":"disabled")})},50)};this.gui_object=function(a,b){this.gui_objects[a]=this.loaded?rcube_find_object(b):b};this.gui_container=function(a,b){this.gui_containers[a]=b};this.add_element=function(a,b){this.gui_containers[b]&&this.gui_containers[b].jquery&&this.gui_containers[b].append(a)};this.register_command=function(a,b,d){this.command_handlers[a]=b;d&&this.enable_command(a,!0)};this.add_onload=function(a){this.onloads.push(a)};this.init=function(){var a; this.task=this.env.task;if(409==this.env.server_error||bw.dom&&bw.xmlhttp_test()){this.env.blankpage||(this.env.blankpage="about:blank");for(a in this.gui_containers)this.gui_containers[a]=$("#"+this.gui_containers[a]);for(a in this.gui_objects)this.gui_objects[a]=rcube_find_object(this.gui_objects[a]);this.init_buttons();this.is_framed()&&parent.rcmail.unlock_frame();this.enable_command("close","logout","mail","addressbook","settings","save-pref","compose","undo","about","switch-task","menu-open", "menu-close","menu-save",!0);this.set_button(this.task,"sel");this.env.permaurl&&this.enable_command("permaurl","extwin",!0);switch(this.task){case "mail":this.enable_command("list","checkmail","add-contact","search","reset-search","collapse-folder","import-messages",!0);if(this.gui_objects.messagelist){this.env.widescreen_list_template=[{className:"threads",cells:["threads"]},{className:"subject",cells:["fromto","date","status","subject"]},{className:"flags",cells:["flag","attachment"]}];this.message_list= new rcube_list_widget(this.gui_objects.messagelist,{multiselect:!0,multiexpand:!0,draggable:!0,keyboard:!0,column_movable:this.env.col_movable,dblclick_time:this.dblclick_time});this.message_list.addEventListener("initrow",function(g){h.init_message_row(g)}).addEventListener("dblclick",function(g){h.msglist_dbl_click(g)}).addEventListener("keypress",function(g){h.msglist_keypress(g)}).addEventListener("select",function(g){h.msglist_select(g)}).addEventListener("dragstart",function(g){h.drag_start(g)}).addEventListener("dragmove", function(g){h.drag_move(g)}).addEventListener("dragend",function(g){h.drag_end(g)}).addEventListener("expandcollapse",function(g){h.msglist_expand(g)}).addEventListener("column_replace",function(g){h.msglist_set_coltypes(g)}).init();$(this.message_list.thead).on("click","a.sortcol",function(g){return h.command("sort",$(this).attr("rel"),this)});this.enable_command("toggle_status","toggle_flag","sort",!0);this.enable_command("set-listmode",this.env.threads&&!this.is_multifolder_listing());var b=$(this.gui_objects.search_filter).val(); b&&"ALL"!=b?this.filter_mailbox(b):this.command("list");$(this.gui_objects.qsearchbox).val(this.env.search_text).focusin(function(){h.message_list.blur()})}this.set_button_titles();this.env.message_commands="show reply reply-all reply-list move copy delete open mark edit viewsource bounce print load-attachment download-attachment show-headers hide-headers download forward forward-inline forward-attachment change-format".split(" ");if("show"==this.env.action||"preview"==this.env.action){if(this.enable_command(this.env.message_commands, this.env.uid),this.enable_command("reply-list",this.env.list_post),"show"==this.env.action&&this.http_request("pagenav",{_uid:this.env.uid,_mbox:this.env.mailbox,_search:this.env.search_request},this.display_message("","loading")),0 a",this.gui_objects.attachments).not(".drop").on("dragstart",function(g){var k=this.href,l=g.originalEvent.dataTransfer;l&&(k=k.replace(/^https?:\/\//,function(m){return m+urlencode(h.env.username)+"@"}),g=$(this).clone(),g.children().remove(),l.setData("roundcube-uri", k),l.setData("roundcube-name",$.trim(g.text())))})}else if("compose"==this.env.action)this.env.address_group_stack=[],this.env.compose_commands="send-attachment remove-attachment send cancel toggle-editor list-addresses pushgroup search reset-search extwin insert-response save-response menu-open menu-close load-attachment download-attachment open-attachment rename-attachment".split(" "),this.env.drafts_mailbox&&this.env.compose_commands.push("savedraft"),this.enable_command(this.env.compose_commands, !0),$.merge(this.env.compose_commands,["add-recipient","firstpage","previouspage","nextpage","lastpage"]),window.googie&&(this.env.editor_config.spellchecker=googie,this.env.editor_config.spellcheck_observer=function(g){h.spellcheck_state()},this.env.compose_commands.push("spellcheck"),this.enable_command("spellcheck",!0)),this.editor_init(this.env.editor_config,this.env.composebody),this.gui_objects.responseslist&&($("a.insertresponse",this.gui_objects.responseslist).attr("unselectable","on").mousedown(function(g){return rcube_event.cancel(g)}).on("mouseup keypress", function(g){if("mouseup"==g.type||13==rcube_event.get_keycode(g))return h.command("insert-response",$(this).attr("rel")),$(document.body).trigger("mouseup"),rcube_event.cancel(g)}),$.each(this.buttons["save-response"]||[],function(g,k){$("#"+k.id).mousedown(function(l){return rcube_event.cancel(l)})})),this.init_messageform();else if("bounce"==this.env.action)this.init_messageform_inputs(),this.env.compose_commands=[];else if("get"==this.env.action){if(this.enable_command("download",!0),this.enable_command("image-scale", "image-rotate",!!/^image\//.test(this.env.mimetype)),this.enable_command("print","application/pdf"!=this.env.mimetype||!bw.mz||75<=bw.vendver),this.env.is_message&&(this.enable_command("reply","reply-all","edit","viewsource","forward","forward-inline","forward-attachment","bounce",!0),this.env.list_post&&this.enable_command("reply-list",!0)),this.env.mimetype.startsWith("image/"))$(this.gui_objects.messagepartframe).on("load",function(){var g=$(this).contents();g.find("img").length&&g.find("head").append('')})}else"print"!= this.env.action||!this.env.uid||this.env.is_pgp_content||this.env.pgp_mime_part||this.print_dialog();this.gui_objects.mailboxlist&&(this.env.unread_counts={},this.gui_objects.folderlist=this.gui_objects.mailboxlist,this.http_request("getunread",{_page:this.env.current_page}));this.gui_objects.contactslist&&(this.contact_list=new rcube_list_widget(this.gui_objects.contactslist,{multiselect:!0,draggable:!1,keyboard:!0}),this.contact_list.addEventListener("initrow",function(g){h.triggerEvent("insertrow", {cid:g.uid,row:g})}).addEventListener("select",function(g){h.compose_recipient_select(g)}).addEventListener("dblclick",function(g){h.compose_add_recipient()}).addEventListener("keypress",function(g){g.key_pressed==g.ENTER_KEY&&(h.compose_add_recipient()||g.last_selected&&"G"==String(g.last_selected).charAt(0)&&$(g.rows[g.last_selected].obj).find("a").first().click())}).init(),$("#_to,#_cc,#_bcc").focus(function(){h.env.focused_field=this}));this.gui_objects.addressbookslist&&(this.gui_objects.folderlist= this.gui_objects.addressbookslist,this.enable_command("list-addresses",!0));if(this.env.mdn_request&&this.env.uid){b="sendmdn";var d={_uid:this.env.uid,_mbox:this.env.mailbox};confirm(this.get_label("mdnrequest"))||(d._flag="mdnsent",b="mark");this.http_post(b,d)}this.check_mailvelope(this.env.action);this.is_framed()||this.env.extwin||this.browser_capabilities_check();break;case "addressbook":this.env.address_group_stack=[];this.gui_objects.folderlist&&(this.env.contactfolders=$.extend($.extend({}, this.env.address_sources),this.env.contactgroups));this.enable_command("add","import",this.env.writable_source);this.enable_command("list","listgroup","pushgroup","popgroup","listsearch","search","reset-search","advanced-search",!0);this.gui_objects.contactslist&&(this.contact_list=new rcube_list_widget(this.gui_objects.contactslist,{multiselect:!0,draggable:this.gui_objects.folderlist?!0:!1,keyboard:!0}),this.contact_list.addEventListener("initrow",function(g){h.triggerEvent("insertrow",{cid:g.uid, row:g})}).addEventListener("keypress",function(g){h.list_keypress(g)}).addEventListener("select",function(g){h.contactlist_select(g)}).addEventListener("dragstart",function(g){h.drag_start(g)}).addEventListener("dragmove",function(g){h.drag_move(g)}).addEventListener("dragend",function(g){h.drag_end(g)}).init(),$(this.gui_objects.qsearchbox).focusin(function(){h.contact_list.blur()}),this.update_group_commands(),this.command("list"));this.gui_objects.savedsearchlist&&(this.savedsearchlist=new rcube_treelist_widget(this.gui_objects.savedsearchlist, {id_prefix:"rcmli",id_encode:this.html_identifier_encode,id_decode:this.html_identifier_decode}),this.savedsearchlist.addEventListener("select",function(g){h.triggerEvent("selectfolder",{folder:g.id,prefix:"rcmli"})}));this.set_page_buttons();this.env.cid&&(this.enable_command("show","edit","qrcode",!0),this.gui_objects.editform&&$("input.groupmember").change(function(){h.group_member_change(this.checked?"add":"del",h.env.cid,h.env.source,this.value)}));this.gui_objects.editform?(this.enable_command("save", !0),"add"!=this.env.action&&"edit"!=this.env.action&&"search"!=this.env.action||this.init_contact_form()):"print"==this.env.action&&this.print_dialog();break;case "settings":this.enable_command("show","save",!0);"identities"==this.env.action?this.enable_command("add",2>this.env.identities_level):"edit-identity"==this.env.action||"add-identity"==this.env.action?(this.enable_command("save","edit","toggle-editor",!0),this.enable_command("delete",2>this.env.identities_level),this.editor_init(this.env.editor_config, "rcmfd_signature"),this.check_mailvelope(this.env.action)):"folders"==this.env.action?this.enable_command("subscribe","unsubscribe","create-folder","rename-folder",!0):"edit-folder"==this.env.action&&this.gui_objects.editform?(this.enable_command("save","folder-size",!0),parent.rcmail.env.exists=this.env.messagecount,parent.rcmail.enable_command("purge",this.env.messagecount)):"responses"==this.env.action&&this.enable_command("add",!0);this.gui_objects.identitieslist?(this.identity_list=new rcube_list_widget(this.gui_objects.identitieslist, {multiselect:!1,draggable:!1,keyboard:!0}),this.identity_list.addEventListener("select",function(g){h.identity_select(g)}).addEventListener("keypress",function(g){h.list_keypress(g)}).init().focus()):this.gui_objects.sectionslist?(this.sections_list=new rcube_list_widget(this.gui_objects.sectionslist,{multiselect:!1,draggable:!1,keyboard:!0}),this.sections_list.addEventListener("select",function(g){h.section_select(g)}).init().focus()):this.gui_objects.subscriptionlist?this.init_subscription_list(): this.gui_objects.responseslist&&(this.responses_list=new rcube_list_widget(this.gui_objects.responseslist,{multiselect:!1,draggable:!1,keyboard:!0}),this.responses_list.addEventListener("select",function(g){h.response_select(g)}).addEventListener("keypress",function(g){h.list_keypress(g)}).init().focus());break;case "login":var e=$("#rcmloginuser"),f=$("#rcmlogintz");""==e.val()?e.focus():$("#rcmloginpwd").focus();window.jstz&&(b=jstz.determine())&&(d=b.name());f.val(d?d:(new Date).getStdTimezoneOffset()/ -60);$("form").submit(function(){$("[type=submit]",this).prop("disabled",!0);h.clear_messages();h.display_message("","loading")})}this.gui_objects.editform&&$("input,select,textarea",this.gui_objects.editform).not(":hidden").not(":disabled").first().select().focus();bw.ie&&$("input[type=file]").keydown(function(g){"13"==g.keyCode&&g.preventDefault()});this.loaded=!0;this.env.lastrefresh=new Date;this.pending_message&&this.display_message.apply(this,this.pending_message);this.gui_objects.folderlist&& window.rcube_treelist_widget&&this.gui_objects.folderlist!=this.gui_objects.addressbookslist&&(this.treelist=new rcube_treelist_widget(this.gui_objects.folderlist,{selectable:!0,id_prefix:"rcmli",parent_focus:!0,id_encode:this.html_identifier_encode,id_decode:this.html_identifier_decode,check_droptarget:function(g){return!g.virtual&&h.check_droptarget(g.id)}}),this.treelist.addEventListener("collapse",function(g){h.folder_collapsed(g)}).addEventListener("expand",function(g){h.folder_collapsed(g)}).addEventListener("beforeselect", function(g){return!h.busy}).addEventListener("select",function(g){h.triggerEvent("selectfolder",{folder:g.id,prefix:"rcmli"});h.mark_all_read_state()}));this.gui_objects.filedrop&&this.env.filedrop&&window.FormData&&($(document.body).on("dragover dragleave drop",function(g){return h.document_drag_hover(g,"dragover"==g.type)}),$(this.gui_objects.filedrop).addClass("droptarget").on("dragover dragleave",function(g){return h.file_drag_hover(g,"dragover"==g.type)}).get(0).addEventListener("drop",function(g){return h.file_dropped(g)}, !1));b=function(g){return h.doc_mouse_up(g)};$(document.body).mouseup(b).keydown(function(g){return h.doc_keypress(g)});rcube_webmail.set_iframe_events({mouseup:b});this.triggerEvent("init",{task:this.task,action:this.env.action});for(a in this.onloads)if("string"===typeof this.onloads[a])eval(this.onloads[a]);else if("function"===typeof this.onloads[a])this.onloads[a]();$("[data-popup]").each(function(){h.register_menu_button(this,$(this).data("popup"))});this.start_refresh();this.start_keepalive()}else this.goto_url("error", "_code=0x199")};this.log=function(a){this.env.devel_mode&&window.console&&console.log&&console.log(a)};this.command=function(a,b,d,e,f){!d||!d.blur||e&&rcube_event.is_keyboard(e)||d.blur();if(this.busy&&("reset-search"!=a||"search"!=this.last_command)&&!a.match(/^menu-/))return!1;if(d&&d.href&&0>String(d.href).indexOf("#")&&rcube_event.get_modifier(e))return!0;if(!f&&!this.commands[a])return this.is_framed()&&parent.rcmail.command(a,b),!1;if("mail"==this.task&&"compose"==this.env.action&&!this.env.server_error&& "save-pref"!=a&&0>$.inArray(a,this.env.compose_commands)&&!this.compose_skip_unsavedcheck&&!this.env.is_sent&&this.cmp_hash!=this.compose_field_hash())return this.confirm_dialog(this.get_label("notsentwarning"),"discard",function(){h.remove_compose_data(h.env.compose_id);h.compose_skip_unsavedcheck=!0;h.command(a,b,d,e)}),!1;this.last_command=a;this.command_aborted=!1;this.triggerEvent("actionbefore",{props:b,action:a,originalEvent:e});if(void 0!==(f=this.triggerEvent("before"+a,b||e))){if(!1===f)return!1; b=f}f="function"===typeof this.command_handlers[a]?this.command_handlers[a](b,d,e):"string"===typeof this.command_handlers[a]?window[this.command_handlers[a]](b,d,e):this.command_handler(a,b,d,e);this.command_aborted||!1!==this.triggerEvent("after"+a,b)||(f=!1);this.triggerEvent("actionafter",{props:b,action:a,aborted:this.command_aborted,ret:f,originalEvent:e});return!1===f||d&&!0!==f||!0===this.command_aborted?!1:!0};this.command_handler=function(a,b,d,e){var f;switch(a){case "logout":case "mail":case "addressbook":case "settings":this.switch_task(a); break;case "about":this.redirect("?_task=settings&_action=about",!1);break;case "permaurl":if(d&&d.href&&d.target)return!0;this.env.permaurl&&(parent.location.href=this.env.permaurl);break;case "extwin":if("compose"==this.env.action){if(a=this.gui_objects.messageform,b=this.open_window(""))this.save_compose_form_local(),this.compose_skip_unsavedcheck=!0,$("[name='_action']",a).val("compose"),a.action=this.url("mail/compose",{_id:this.env.compose_id,_extwin:1}),a.target=b.name,a.submit()}else this.open_window(this.env.permaurl, !0);break;case "change-format":e=this.env.permaurl+"&_format="+b;"preview"==this.env.action&&(e=e.replace(/_action=show/,"_action=preview")+"&_framed=1");this.env.extwin&&(e+="&_extwin=1");location.href=e;break;case "menu-open":b&&"attachmentmenu"==b.menu&&((f=this.env.attachments[b.id])&&f.mimetype&&(f=f.mimetype),this.enable_command("open-attachment",f&&this.env.mimetypes&&0<=$.inArray(f,this.env.mimetypes)));this.show_menu(b,b.show||void 0,e);break;case "menu-close":this.hide_menu(b,e);break;case "menu-save":return this.triggerEvent(a, {props:b,originalEvent:e}),!1;case "open":if(f=this.get_single_uid())return d.href=this.url("show",this.params_from_uid(f,{_extwin:1})),!0;break;case "close":this.env.extwin&&window.close();break;case "list":b&&""!=b&&this.reset_qsearch(!0);"compose"==this.env.action&&this.env.extwin?window.close():"mail"==this.task?(this.list_mailbox(b),this.set_button_titles()):"addressbook"==this.task&&this.list_contacts(b);break;case "set-listmode":this.set_list_options(null,void 0,void 0,"threads"==b?1:0);break; case "sort":a=this.env.sort_order;b=this.env.disabled_sort_col?this.env.sort_col:b;this.env.disabled_sort_order||(a=this.env.sort_col==b&&"ASC"==a?"DESC":"ASC");this.set_list_sorting(b,a);this.list_mailbox("","",b+"_"+a);break;case "nextpage":this.list_page("next");break;case "lastpage":this.list_page("last");break;case "previouspage":this.list_page("prev");break;case "firstpage":this.list_page("first");break;case "expunge":this.env.exists&&this.expunge_mailbox(this.env.mailbox);break;case "purge":case "empty-mailbox":this.env.exists&& this.purge_mailbox(this.env.mailbox);break;case "show":if("mail"==this.task)!(f=this.get_single_uid())||this.env.uid&&f==this.env.uid||(b=this.get_message_mailbox(f),b==this.env.drafts_mailbox?this.open_compose_step({_draft_uid:f,_mbox:b}):this.show_message(f));else if("addressbook"==this.task){var g=b?b:this.get_single_cid();!g||"show"==this.env.action&&g==this.env.cid||this.load_contact(g,"show")}else"settings"==this.task&&this.goto_url("settings/"+b,{_framed:0});break;case "add":"addressbook"== this.task?this.load_contact(0,"add"):"settings"==this.task&&"responses"==this.env.action?this.load_response(0,"add-response"):"settings"==this.task&&this.load_identity(0,"add-identity");break;case "edit":"addressbook"==this.task&&(g=this.get_single_cid())?this.load_contact(g,"edit"):"mail"==this.task&&(f=this.get_single_uid())&&(e={_mbox:this.get_message_mailbox(f)},e[e._mbox==this.env.drafts_mailbox&&"new"!=b?"_draft_uid":"_uid"]=f,this.open_compose_step(e));break;case "save":var k;if(a=this.gui_objects.editform)if((k= $("[name='_pagesize']",a))&&k.length&&isNaN(parseInt(k.val())))this.alert_dialog(this.get_label("nopagesizewarning"),function(){k.focus()});else{if("reload"==b)a.action+="&_reload=1";else if("settings"==this.task&&0==this.env.identities_level%2&&(k=$("[name='_email']",a))&&k.length&&!rcube_check_email(k.val())){this.alert_dialog(this.get_label("noemailwarning"),function(){k.focus()});break}parent.rcmail&&parent.rcmail.env.source&&(a.action=this.add_url(a.action,"_orig_source",parent.rcmail.env.source)); a.submit()}break;case "delete":"mail"==this.task?this.delete_messages(e):"addressbook"==this.task?this.delete_contacts():"settings"==this.task&&"responses"==this.env.action?this.delete_response():"settings"==this.task&&this.delete_identity();break;case "move":case "moveto":"mail"==this.task?this.move_messages(b,e):"addressbook"==this.task&&this.move_contacts(b,e);break;case "copy":"mail"==this.task?this.copy_messages(b,e):"addressbook"==this.task&&this.copy_contacts(b,e);break;case "mark":b&&this.mark_message(b); break;case "toggle_status":case "toggle_flag":a="toggle_flag"==a?"flagged":"read";if(f=b)"flagged"==a?this.message_list.rows[f].flagged&&(a="unflagged"):this.message_list.rows[f].deleted?a="undelete":this.message_list.rows[f].unread||(a="unread"),this.mark_message(a,f);break;case "add-contact":this.add_contact(b);break;case "load-remote":this.env.uid&&(b&&this.env.sender?this.add_contact(this.env.sender,!0):this.show_message(this.env.uid,!0,"preview"==this.env.action));break;case "load-attachment":case "open-attachment":case "download-attachment":f= this.env.attachments[b];"compose"==this.env.action?(b={_file:b,_id:this.env.compose_id},f=f?f.mimetype:""):b={_mbox:this.env.mailbox,_uid:this.env.uid,_part:b};if("download-attachment"!=a&&f&&this.env.mimetypes&&0<=$.inArray(f,this.env.mimetypes)&&this.open_window(this.url("get",$.extend({_frame:1,_framed:0},b))))break;this.compose_skip_unsavedcheck=b._download=1;this.goto_url("get",b,!1,!0);this.compose_skip_unsavedcheck=0;break;case "select-all":this.select_all_mode=b?!1:!0;this.dummy_select=!0; a=this["addressbook"==this.task?"contact_list":"message_list"];"invert"==b?a.invert_selection():a.select_all("page"==b?"":b);this.dummy_select=null;break;case "select-none":this.select_all_mode=!1;this["addressbook"==this.task?"contact_list":"message_list"].clear_selection();break;case "expand-all":this.env.autoexpand_threads=1;this.message_list.expand_all();break;case "expand-unread":this.env.autoexpand_threads=2;this.message_list.collapse_all();this.expand_unread();break;case "collapse-all":this.env.autoexpand_threads= 0;this.message_list.collapse_all();break;case "nextmessage":this.env.next_uid&&this.show_message(this.env.next_uid,!1,"preview"==this.env.action);break;case "lastmessage":this.env.last_uid&&this.show_message(this.env.last_uid);break;case "previousmessage":this.env.prev_uid&&this.show_message(this.env.prev_uid,!1,"preview"==this.env.action);break;case "firstmessage":this.env.first_uid&&this.show_message(this.env.first_uid);break;case "compose":e={};if("mail"==this.task)e={_mbox:this.env.mailbox,_search:this.env.search_request}, b&&(e._to=b);else if("addressbook"==this.task)if(b&&0").attr("src",this.url("import",{_framed:1,_target:this.env.source}));this.import_state=null;this.import_dialog=this.simple_dialog(q,this.gettext("importcontacts"),function(p){var t=q[0].contentWindow,v=t.rcmail.gui_objects.importform; if(v){var w;(w=t.$("#rcmimportfile")[0])&&!w.value?t.rcmail.alert_dialog(t.rcmail.get_label("selectimportfile")):(w=t.rcmail.set_busy(!0,"importwait"),$('[name="_unlock"]',v).val(w),v.submit(),t.rcmail.lock_form(v,!0),$(p.target).attr("disabled",!0).next().focus())}},{close:function(p,t){$(this).remove();"reload"==h.import_state&&h.command("list")},button:"import",width:500,height:300});break;case "export":0f?"prevAll":"nextAll",l=0>f?"last":"first";return h.focused_menu&& (g=$("#"+h.focused_menu))?(f=g.find(":focus").closest("li")[k]().has(":not([aria-disabled=true])").find("a,input")[l](),f.length||(f=g.find(":focus").closest("ul")[k]().has(":not([aria-disabled=true])").find("a,input")[l]()),f.focus().length):0},d=a.target||{},e=rcube_event.get_keycode(a);if(27!=a.keyCode&&(!this.menu_keyboard_active||"TEXTAREA"==d.nodeName||"SELECT"==d.nodeName))return!0;switch(e){case 38:case 40:case 63232:case 63233:return b(38==e||63232==e?-1:1),rcube_event.cancel(a);case 9:return this.focused_menu&& (d=rcube_event.get_modifier(a),b(d==SHIFT_KEY?-1:1)||this.hide_menu(this.focused_menu,a)),rcube_event.cancel(a);case 27:this.menu_stack.length&&this.hide_menu(this.menu_stack[this.menu_stack.length-1],a)}return!0};this.list_keypress=function(a,b){a.modkey!=CONTROL_KEY&&(a.key_pressed==a.DELETE_KEY||a.key_pressed==a.BACKSPACE_KEY?this.command(b&&b.del?b.del:"delete"):33==a.key_pressed?this.command(b&&b.prev?b.prev:"previouspage"):34==a.key_pressed&&this.command(b&&b.next?b.next:"nextpage"))};this.msglist_keypress= function(a){a.key_pressed!=a.ENTER_KEY||this.env.contentframe?this.list_keypress(a):this.command("show")};this.msglist_select=function(a){this.preview_timer&&clearTimeout(this.preview_timer);var b=a.get_single_selection(),d=a.get_selection(!1).length;this.enable_command(this.env.message_commands,null!=b);b&&(this.get_message_mailbox(b)==this.env.drafts_mailbox?this.enable_command("reply","reply-all","reply-list","forward","forward-attachment","forward-inline",!1):this.env.messages[b].ml||this.enable_command("reply-list", !1));this.enable_command("delete","move","copy","mark","forward","forward-attachment",0"+this.get_label("loading")+""),this.triggerEvent("openwindow", {url:a,handle:f}),setTimeout(function(){f&&f.focus()},10),f};this.init_message_row=function(a){var b={},d=a.uid,e=(null!=this.env.status_col?"status":"msg")+"icn"+a.id;d&&this.env.messages[d]&&$.extend(a,this.env.messages[d]);if(a.icon=document.getElementById(e))b.icon=function(f){h.command("toggle_status",d)};a.msgicon=null!=this.env.status_col?document.getElementById("msgicn"+a.id):a.icon;null!=this.env.flagged_col&&(a.flagicon=document.getElementById("flagicn"+a.id))&&(b.flagicon=function(f){h.command("toggle_flag", d)});!a.depth&&a.has_children&&(a.expando=document.getElementById("rcmexpando"+a.id))&&(b.expando=function(f){h.expand_message_row(f,d)});$.each(b,function(f,g){a[f].onclick=function(k){g(k);return rcube_event.cancel(k)};bw.touch&&a[f].addEventListener&&a[f].addEventListener("touchend",function(k){if(1==k.changedTouches.length)return g(k),rcube_event.cancel(k)},!1)});this.triggerEvent("insertrow",{uid:d,row:a})};this.add_message_row=function(a,b,d,e){if(!this.gui_objects.messagelist||!this.message_list|| d.mbox!=this.env.mailbox&&!d.skip_mbox_check||this.message_list.rows[a])return!1;this.env.messages[a]||(this.env.messages[a]={});$.extend(this.env.messages[a],{deleted:d.deleted?1:0,replied:d.answered?1:0,unread:d.seen?0:1,forwarded:d.forwarded?1:0,flagged:d.flagged?1:0,has_children:d.has_children?1:0,depth:d.depth?d.depth:0,unread_children:d.unread_children||0,flagged_children:d.flagged_children||0,parent_uid:d.parent_uid||0,selected:this.select_all_mode||this.message_list.in_selection(a),ml:d.ml? 1:0,ctype:d.ctype,mbox:d.mbox,flags:d.extra_flags});var f,g,k="",l=g="",m="",q=this.message_list;var p=q.rows;var t=this.env.messages[a],v=this.html_identifier(a,!0),w="message"+(d.seen?"":" unread")+(d.deleted?" deleted":"")+(d.flagged?" flagged":"")+(t.selected?" selected":""),x={cols:[],style:{},id:"rcmrow"+v,uid:a};var u="msgicon";null===this.env.status_col&&(u+=" status",d.deleted?(k+=" deleted",g+=this.get_label("deleted")+" "):d.seen?0  ',p[t.parent_uid]&&!1===p[t.parent_uid].expanded||!(0!=this.env.autoexpand_threads&&2!=this.env.autoexpand_threads||p[t.parent_uid]&&p[t.parent_uid].expanded)?(x.style.display= "none",t.expanded=!1):t.expanded=!0,w+=" thread expanded"):t.has_children&&(void 0===t.expanded&&(1==this.env.autoexpand_threads||2==this.env.autoexpand_threads&&t.unread_children)&&(t.expanded=!0),m='
  
',w+=" thread"+(t.expanded?" expanded":"")),d.unread_children&&d.seen&&!t.expanded&&(w+=" unroot"),d.flagged_children&&!t.expanded&&(w+=" flaggedroot"));l+='';x.className=w;b.subject&&(u=d.mbox==this.env.drafts_mailbox?"compose":"show",g={_mbox:d.mbox},g[d.mbox==this.env.drafts_mailbox?"_draft_uid":"_uid"]=a,b.subject=''+b.subject+"");for(f in this.env.listcols)u=this.env.listcols[f],g={className:String(u).toLowerCase(),events:{}},this.env.coltypes[u]&&this.env.coltypes[u].hidden&& (g.className+=" hidden"),"flag"==u?(u=d.flagged?"flagged":"unflagged",p=this.get_label(u),u=''):"attachment"==u?(p=this.get_label("withattachment"),u=d.attachmentClass?'':"multipart/report"==d.ctype?'':"multipart/encrypted"==d.ctype||"application/pkcs7-mime"==d.ctype?'':d.hasattachment||!d.hasnoattachment&&/application\/|multipart\/(m|signed)/.test(d.ctype)? '':" "):"status"==u?(p="",d.deleted?(u="deleted",p=this.get_label("deleted")):d.seen?u=0'):"threads"==u?u=m:"subject"==u?u=l+b[u]:"priority"==u?0d.prio?(p=this.get_label("priority")+" "+d.prio,u=''):u=" ":u="folder"==u?''+ b[u]+"":b[u],g.innerHTML=u,x.cols.push(g);"widescreen"==this.env.layout&&(x=this.widescreen_message_row(x,a,t));q.insert_row(x,e);e&&this.env.pagesize&&q.rowcount>this.env.pagesize&&(a=q.get_last_row(),q.remove_row(a),q.clear_selection(a))};this.widescreen_message_row=function(a,b,d){var e=document.createElement("tr");e.id=a.id;e.uid=a.uid;e.className=a.className;a.style&&$.extend(e.style,a.style);$.each(this.env.widescreen_list_template,function(){if(h.env.threading||"threads"!=this.className){var f, g,k=document.createElement("td");this.className&&(k.className=this.className);for(f=0;this.cells&&f a").prop("rel","arrival"== a?"arrival":"date");this.env.sort_col=a;this.env.sort_order=b};this.set_list_options=function(a,b,d,e,f){var g={};void 0===b&&(b=this.env.sort_col);d||(d=this.env.sort_order);if(this.env.sort_col!=b||this.env.sort_order!=d){var k=1;this.set_list_sorting(b,d)}this.env.threading!=e&&(k=1,g._threads=e);f&&this.env.layout!=f&&(this.triggerEvent("layout-change",{old_layout:this.env.layout,new_layout:f}),k=1,this.env.layout=g._layout=f);if(a&&a.length){var l=[],m=this.env.listcols;for(e=0;ed.location.href.indexOf(this.env.blankpage)&&(d.stop?d.stop():d.document.execCommand("Stop"),d.location.href=this.env.blankpage);else if(!bw.safari&&!bw.konq)$(b)[a?"show":"hide"]();a||(this.unlock_frame(),delete this.preview_id)};this.get_frame_element=function(a){var b;if(a&&(b=document.getElementById(a)))return b};this.get_frame_window= function(a){if((a=this.get_frame_element(a))&&a.name&&window.frames)return window.frames[a.name]};this.lock_frame=function(a){var b=this.is_framed()?parent.rcmail:this;b.env.frame_lock||(b.env.frame_lock=b.set_busy(!0,"loading"));if(a.frameElement)$(a.frameElement).on("load.lock",function(d){b.unlock_frame();$(this).off("load.lock")})};this.unlock_frame=function(){this.env.frame_lock&&(this.set_busy(!1,null,this.env.frame_lock),this.env.frame_lock=null)};this.list_page=function(a){"next"==a?a=this.env.current_page+ 1:"last"==a?a=this.env.pagecount:"prev"==a&&1d.depth){var m=l-d.depth;e[b][m]&2||(e[b][m]=e[b][m]?e[b][m]+2:2)}else l==d.depth&&(e[b][0]&2||(e[b][0]+=2));if(d.depth>l)break}e.push(Array(d.depth));e[e.length-1][0]=1;f.push(d.uid)}else{if(e.length){for(b in e)this.set_tree_icons(f[b],e[b]); e=[];f=[]}if(a&&g!=k[a].obj)break}g=g.nextSibling}if(e.length)for(b in e)this.set_tree_icons(f[b],e[b])};this.set_tree_icons=function(a,b){var d,e=[],f="",g=b.length;for(d=0;d'):f+('
');f&&$("#rcmtab"+this.html_identifier(a,!0)).html(f)};this.update_thread_root=function(a,b){if(this.env.threading){var d=this.message_list.find_root(a);if(a!=d){a=this.message_list.rows[d];if("read"==b&&a.unread_children)a.unread_children--;else if("unread"==b&&a.has_children)a.unread_children=(a.unread_children||0)+1;else if("unflagged"==b&&a.flagged_children)a.flagged_children--;else if("flagged"==b&&a.has_children)a.flagged_children=(a.flagged_children||0)+1;else return;this.set_message_icon(d); this.set_unread_children(d);this.set_flagged_children(d)}}};this.update_thread=function(a){if(!this.env.threading||!this.message_list.rows[a])return 0;var b,d=0,e=this.message_list,f=e.rows,g=f[a],k=f[a].depth,l=[];g.depth||d--;if(g.depth&&g.unread){var m=e.find_root(a);f[m].unread_children--;this.set_unread_children(m)}g.depth&&g.flagged&&(m=e.find_root(a),f[m].flagged_children--,this.set_flagged_children(m));m=g.parent_uid;for(g=g.obj.nextSibling;g;){if(1==g.nodeType&&(b=f[g.uid])){if(!b.depth|| b.depth<=k)break;b.depth--;$("#rcmtab"+b.id).width(15*b.depth).html("");b.depth?(b.depth==k&&(b.parent_uid=m),b.unread&&l.length&&l[l.length-1].unread_children++):(d++,b.parent_uid=0,b.has_children&&($("#"+b.id+" .leaf").first().attr("id","rcmexpando"+b.id).attr("class","none"!=b.obj.style.display?"expanded":"collapsed").mousedown({uid:b.uid},function(q){return h.expand_message_row(q,q.data.uid)}),b.unread_children=0,l.push(b)),"none"==b.obj.style.display&&$(b.obj).show())}g=g.nextSibling}for(b=0;b< l.length;b++)this.set_unread_children(l[b].uid),this.set_flagged_children(l[b].uid);return d};this.delete_excessive_thread_rows=function(){for(var a=this.message_list.rows,b=this.message_list.tbody.firstChild,d=this.env.pagesize+1;b;)1==b.nodeType&&(r=a[b.uid])&&(!r.depth&&d&&d--,d||this.message_list.remove_row(b.uid)),b=b.nextSibling};this.set_message_icon=function(a){var b="",d=this.message_list.rows[a];if(!d)return!1;d.icon&&(a="msgicon",d.deleted?(a+=" deleted",b+=this.get_label("deleted")+" "): d.unread?(a+=" unread",b+=this.get_label("unread")+" "):d.unread_children&&(a+=" unreadchildren"),d.msgicon==d.icon&&(d.replied&&(a+=" replied",b+=this.get_label("replied")+" "),d.forwarded&&(a+=" forwarded",b+=this.get_label("forwarded")+" "),a+=" status"),$(d.icon).attr({"class":a,title:b}));d.msgicon&&d.msgicon!=d.icon&&(b="",a="msgicon",!d.unread&&d.unread_children&&(a+=" unreadchildren"),d.replied&&(a+=" replied",b+=this.get_label("replied")+" "),d.forwarded&&(a+=" forwarded",b+=this.get_label("forwarded")+ " "),$(d.msgicon).attr({"class":a,title:b}));d.flagicon&&(a=d.flagged?"flagged":"unflagged",b=this.get_label(a),$(d.flagicon).attr("class",a).attr({"aria-label":b,title:b}))};this.set_message_status=function(a,b,d){var e=this.message_list.rows[a];if(!e)return!1;"unread"==b?e.unread!=d&&this.update_thread_root(a,d?"unread":"read"):"flagged"==b&&this.update_thread_root(a,d?"flagged":"unflagged");-1<$.inArray(b,["unread","deleted","replied","forwarded","flagged"])&&(e[b]=d)};this.set_message=function(a, b,d){var e=this.message_list&&this.message_list.rows[a];if(!e)return!1;b&&this.set_message_status(a,b,d);if(-1<$.inArray(b,["unread","deleted","flagged"]))$(e.obj)[e[b]?"addClass":"removeClass"](b);this.set_unread_children(a);this.set_message_icon(a)};this.set_unread_children=function(a){a=this.message_list.rows[a];if(!a.parent_uid){var b=!a.unread&&a.unread_children&&!a.expanded;$(a.obj)[b?"addClass":"removeClass"]("unroot")}};this.set_flagged_children=function(a){a=this.message_list.rows[a];if(!a.parent_uid){var b= a.flagged_children&&!a.expanded;$(a.obj)[b?"addClass":"removeClass"]("flaggedroot")}};this.copy_messages=function(a,b,d){if(a&&"object"===typeof a)a.uids&&(d=a.uids),a=a.id;else if(!a)return d=this.env.uid?[this.env.uid]:this.message_list.get_selection(),this.folder_selector(b,function(e,f){h.command("copy",{id:e,uids:d},f,b,!0)});a&&a!=this.env.mailbox&&(a=this.selection_post_data({_target_mbox:a,_uid:d}),a._uid&&this.http_post("copy",a,this.display_message("copyingmessage","loading")))};this.move_messages= function(a,b,d){if(a&&"object"===typeof a)a.uids&&(d=a.uids),a=a.id;else if(!a)return d=this.env.uid?[this.env.uid]:this.message_list.get_selection(),this.folder_selector(b,function(f,g){h.command("move",{id:f,uids:d},g,b,!0)});if(a&&(a!=this.env.mailbox||this.is_multifolder_listing())){var e=!1;a=this.selection_post_data({_target_mbox:a,_uid:d});a._uid&&("show"==this.env.action&&(e=this.set_busy(!0,"movingmessage")),this.enable_command(this.env.message_commands,!1),this.with_selected_messages("move", a,e),"show"!=this.env.action&&this.show_contentframe(!1))}};this.delete_messages=function(a){var b=this.message_list,d=this.env.trash_mailbox;if(this.env.flag_for_deletion)return this.mark_message("delete"),!1;d&&this.env.mailbox!=d?this.env.delete_junk&&this.env.junk_mailbox&&this.env.mailbox==this.env.junk_mailbox?this.permanently_remove_messages():b&&b.modkey==SHIFT_KEY||a&&rcube_event.get_modifier(a)==SHIFT_KEY?this.confirm_dialog(this.get_label("deletemessagesconfirm"),"delete",function(){h.permanently_remove_messages()}): this.move_messages(d):this.permanently_remove_messages();return!0};this.permanently_remove_messages=function(){var a=this.selection_post_data();a._uid&&(this.with_selected_messages("delete",a),this.show_contentframe(!1))};this.with_selected_messages=function(a,b,d,e){var f=0,g="delete"==a||!this.is_multifolder_listing();if(this.message_list){var k,l=[],m=b._uid,q=this.check_display_next();"*"===m?m=this.message_list.get_selection():"string"==typeof m&&(m=m.split(","));var p=0;for(k=m.length;p$.inArray(v,l)&&l.push(v)}g&&this.message_list.remove_row(t,q&&p==m.length-1)}!q&&g&&this.message_list.clear_selection();p=0;for(k=l.length;pf?b._count=-1*f:0k?d._count=-1*k:0"+d+"";e='";h.pagejump||(h.pagejump=$('
').appendTo(document.body).on("click","li",function(){h.busy||$(a).val($(this).text()).change()})); h.pagejump.data("count")!=d&&h.pagejump.html(e);h.pagejump.attr("rel","#"+this.id).data("count",d);h.show_menu("pagejump-selector",!0,b);$(this).keydown()}).on("keydown keyup click",function(b){var d=$("#pagejump-selector"),e=$("ul",d),f=$("li",e);e.height();var g=parseInt(this.value);if(27!=b.which&&9!=b.which&&13!=b.which&&!d.is(":visible"))return h.show_menu("pagejump-selector",!0,b);if("keydown"==b.type)if(40==b.which)f.length>g&&(this.value=g+=1);else if(38==b.which)1g-1&&(this.value= --g);else{if(13==b.which)return $(this).change();if(27==b.which||9==b.which)return h.hide_menu("pagejump-selector",b),$(a).val(h.env.current_page)}$("li.selected",e).removeClass("selected");(b=$(f[g-1])).length&&(b.addClass("selected"),$("#pagejump-selector").scrollTop(e.height()/f.length*(g-1)-d.height()/2))}).on("change",function(b){var d=parseInt(this.value);d&&d!=h.env.current_page&&!h.busy&&(h.hide_menu("pagejump-selector",b),h.list_page(d))})};this.update_pagejumper=function(){$("input.rcpagejumper").val(this.env.current_page).prop("disabled", 2>this.env.pagecount)};this.check_mailvelope=function(a){if("undefined"!==typeof window.mailvelope)this.mailvelope_load(a);else $(window).on("mailvelope",function(){h.mailvelope_load(a)})};this.mailvelope_load=function(a){this.env.browser_capabilities&&(this.env.browser_capabilities.pgpmime=1);var b=this.env.user_id,d=function(e){h.mailvelope_keyring=e;h.mailvelope_init(a,e)};mailvelope.getVersion().then(function(e){mailvelope.VERSION=e;mailvelope.VERSION_MAJOR=Math.floor(parseFloat(e));return mailvelope.getKeyring(b)}).then(d, function(e){mailvelope.createKeyring(b).then(d,function(f){console.error(f)})})};this.mailvelope_init=function(a,b){if(window.mailvelope)if("show"==a||"preview"==a||"print"==a)if(this.env.is_pgp_content)a=$(this.env.is_pgp_content).text(),h.mailvelope_display_container(this.env.is_pgp_content,a,b);else{if(this.env.pgp_mime_part){var d=this.display_message("loadingdata","loading"),e=this.env.pgp_mime_container;$.ajax({type:"GET",url:this.url("get",{_mbox:this.env.mailbox,_uid:this.env.uid,_part:this.env.pgp_mime_part}), error:function(l,m,q){h.http_error(l,m,q,d)},success:function(l){h.mailvelope_display_container(e,l,b,d)}})}}else if("compose"==a){this.env.compose_commands.push("compose-encrypted");var f=2<=mailvelope.VERSION_MAJOR,g=0<$('[name="_is_html"]').val();f&&this.env.compose_commands.push("compose-encrypted-signed");if(this.env.pgp_mime_message){var k=this.set_busy(!0,this.get_label("loadingdata"));$.ajax({type:"GET",url:this.url("get",this.env.pgp_mime_message),error:function(l,m,q){h.http_error(l,m,q, k);h.enable_command("compose-encrypted",!g);f&&h.enable_command("compose-encrypted-signed",!g)},success:function(l){h.set_busy(!1,null,k);g&&(h.command("toggle-editor",{html:!1,noconvert:!0}),$("#"+h.env.composebody).val(""));h.compose_encrypted({quotedMail:l});h.enable_command("compose-encrypted",!0);h.enable_command("compose-encrypted-signed",!1)}})}else this.enable_command("compose-encrypted",!g),f&&this.enable_command("compose-encrypted-signed",!g);this.addEventListener("actionafter",function(l){l.ret&& "toggle-editor"==l.action&&(h.enable_command("compose-encrypted",!l.props.html),f&&h.enable_command("compose-encrypted-signed",!l.props.html))})}else"edit-identity"==a&&h.mailvelope_identity_keygen()};this.compose_encrypted_signed=function(a){a=a||{};a.signMsg=!0;this.compose_encrypted(a)};this.compose_encrypted=function(a){var b=$("#"+this.env.composebody).parent();if(h.mailvelope_editor)h.mailvelope_editor=null,h.compose_skip_unsavedcheck=!1,h.set_button("compose-encrypted","act"),b.removeClass("mailvelope").find("iframe:not([aria-hidden=true])").remove(), $("#"+h.env.composebody).show(),$("[name='_pgpmime']").remove(),h.enable_command("toggle-editor","insert-response","save-response",!0),h.enable_command("spellcheck",!!window.googie),h.enable_command("insert-sig",!!(h.env.signatures&&h.env.identity&&h.env.signatures[h.env.identity])),h.triggerEvent("compose-encrypted",{active:!1});else{this.spellcheck_state()&&this.editor.spellcheck_stop();var d=a.quotedMail?{quotedMail:a.quotedMail,quotedMailIndent:!1}:{predefinedText:$("#"+this.env.composebody).val()}; a.signMsg&&(d.signMsg=a.signMsg);"reply"==this.env.compose_mode&&(d.quotedMailIndent=!0,d.quotedMailHeader=this.env.compose_reply_header);mailvelope.createEditorContainer("#"+b.attr("id"),h.mailvelope_keyring,d).then(function(e){h.mailvelope_editor=e;h.compose_skip_unsavedcheck=!0;h.set_button("compose-encrypted","sel");b.addClass("mailvelope");$("#"+h.env.composebody).hide();h.enable_command("spellcheck","insert-sig","toggle-editor","insert-response","save-response",!1);h.triggerEvent("compose-encrypted", {active:!0});h.env.attachments&&!$.isEmptyObject(h.env.attachments)&&(h.alert_dialog(h.get_label("encryptnoattachments")),$.each(h.env.attachments,function(f,g){h.remove_from_attachment_list(f)}))},function(e){console.error(e);console.log(d)})}};this.mailvelope_submit_messageform=function(a,b){var d=[];$.each(["to","cc","bcc"],function(f,g){for(g=$.trim($('[name="_'+g+'"]').val());g.length&&rcube_check_email(g,!0);)f=RegExp.$2.replace(/^<+/,"").replace(/>+$/,""),d.push(f),g=g.substr(g.indexOf(f)+ f.length+1).replace(/^\s*,\s*/,"")});var e=0"+h.get_label("searchpubkeyservers")+"

","encryptedsendialog",function(){h.mailvelope_search_pubkeys(g,function(){return!0})},{button:"search"}),!1;if(!e)return d.length||h.alert_dialog(h.get_label("norecipientwarning"),function(){$("[name='_to']").focus()}), !1;var k=[],l=h.env.identities[$("[name='_from'] option:selected").val()];$.each(h.env.identities,function(m,q){k.push(q.email)});h.mailvelope_keyring.validKeyForAddress(k).then(function(m){valid_sender=null;$.each(m,function(q,p){if(!1!==p&&(valid_sender=q,valid_sender==l))return!1});if(!valid_sender&&!confirm(h.get_label("nopubkeyforsender")))return!1;d.push(valid_sender);h.mailvelope_editor.encrypt(d).then(function(q){var p=h.gui_objects.messageform,t=$("[name='_pgpmime']",p),v=h.set_busy(!0,a|| b?"savingmessage":"sendingmessage");p.target=h.get_save_target();p._draft.value=a?"1":"";p.action=h.add_url(p.action,"_unlock",v);p.action=h.add_url(p.action,"_framed",1);b&&(p.action=h.add_url(p.action,"_saveonly",1));t.length||(t=$('').appendTo(p));t.val(q);p.submit()},function(q){console.log(q)})},function(m){console.error(m)})},function(f){console.error(f)});return!1};this.mailvelope_display_container=function(a,b,d,e){var f=function(g){$(a+" > iframe").remove(); h.hide_message(e);h.display_message(g.message,"error")};mailvelope.createDisplayContainer(a,b,d,{senderAddress:this.env.sender}).then(function(g){if(g.error&&g.error.message)return f(g.error);h.hide_message(e);$(a).addClass("mailvelope").children().not("iframe").hide();h.env.pgp_mime_part&&$("#attach"+h.env.pgp_mime_part).remove();setTimeout(function(){$(window).resize()},10)},f)};this.mailvelope_search_pubkeys=function(a,b,d){var e=[],f=new PublicKey(this.env.keyservers),g=h.display_message("","loading"); $.each(a,function(k,l){var m=$.Deferred();f.search(l,function(q,p){null!==p?m.resolve([l]):m.resolve([l].concat(q))});e.push(m)});$.when.apply($,e).then(function(){var k=[],l=[];$.each(arguments,function(m,q){m=q.shift();q.length?l=l.concat(q):k.push(m)});h.hide_message(g);b(!0);l.length&&h.mailvelope_key_import_dialog(l,d);k.length&&h.display_message(h.get_label("nopubkeyfor").replace("$email",k.join(", ")),"warning")}).fail(function(){console.error("Pubkey lookup failed with",arguments);h.hide_message(g); h.display_message("pubkeysearcherror","error");b(!1)})};this.mailvelope_key_import_dialog=function(a,b){var d=$("
").addClass("listing pgpkeyimport");$.each(a,function(e,f){e=$("
").addClass("key");f.revoked&&e.addClass("revoked");f.disabled&&e.addClass("disabled");f.expired&&e.addClass("expired");e.append($("