14 lines
60 KiB
JavaScript
14 lines
60 KiB
JavaScript
/**
|
|
* Roundcube webmail functions for the Elastic skin
|
|
*
|
|
* Copyright (c) The Roundcube Dev Team
|
|
*
|
|
* The contents are subject to the Creative Commons Attribution-ShareAlike
|
|
* License. It is allowed to copy, distribute, transmit and to adapt the work
|
|
* by keeping credits to the original autors in the README file.
|
|
* See http://creativecommons.org/licenses/by-sa/3.0/ for details.
|
|
*
|
|
* @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
|
|
*/
|
|
"use strict";function rcube_elastic_ui(){var a,f,n,R,t,i,N,o,e,s,r,W,P,U,q,l,c,H,d,u,p=this,m="normal",h="light",B=!1,F=!1,v=rcmail.is_framed(),g={config:{standard_windows:rcmail.env.standard_windows,message_extwin:rcmail.env.message_extwin,compose_extwin:rcmail.env.compose_extwin,help_open_extwin:rcmail.env.help_open_extwin},checkboxes:0,small_screen_config:{standard_windows:!0,message_extwin:!1,compose_extwin:!1,help_open_extwin:!1}},b={},Y=[],K=[],_={menu:$("#layout-menu"),sidebar:$("#layout-sidebar"),list:$("#layout-list"),content:$("#layout-content")},k={menu:$("a.task-menu-button"),back_sidebar:$("a.back-sidebar-button"),back_list:$("a.back-list-button"),back_content:$("a.back-content-button")};this.register_content_buttons=function(e){{var t;g.frame_nav&&e&&e.length&&(t=g.frame_nav.children(".buttons"),Y=[],$.each(e,function(){this.data("target")&&Y.push(this.data("target"))}),t.html("").append(e))}},this.menu_hide=O,this.menu_toggle=ce,this.menu_destroy=de,this.popup_init=z,this.about_dialog=function(e){var t,a,n=!1,i=$("<iframe>").attr({id:"aboutframe",src:rcmail.url("settings/about",{_framed:1})}),o=$("#supportlink");o.length&&(t=o.attr("href"))&&(n=o.text(),a=function(e){t.indexOf("mailto:")<0?window.open(t):location.href=t});rcmail.simple_dialog(i,$(e).text(),a,{button:n,button_class:"help",cancel_button:"close",height:400})},this.headers_dialog=function(){var e={_uid:rcmail.env.uid,_mbox:rcmail.env.mailbox,_framed:1},e=$("<iframe>").attr({id:"headersframe",src:rcmail.url("headers",e)});rcmail.simple_dialog(e,"arialabelmessageheaders",null,{cancel_button:"close",height:400})},this.import_dialog=function(){var t;rcmail.commands["import-messages"]&&(t=$("#uploadform").clone(!0),rcmail.simple_dialog(t,"importmessages",function(e){return rcmail.command("import-messages",$(t.find("form")[0]))},{button:"import",closeOnEscape:!0,minWidth:400}))},this.props_dialog=function(){var e=$("#properties-menu").clone();rcmail.simple_dialog(e,"properties",null,{cancel_button:"close",height:400})},this.headers_show=ue,this.spellmenu=function(e){var t,a,n=[],i=rcmail.spellcheck_lang(),o=$("ul",e);if(!o.length){for(t in o=$('<ul class="selectable listing iconized" role="menu">'),rcmail.env.spell_langs)a=$('<li role="menuitem">'),$('<a href="#'+t+'" tabindex="0"></a>').text(rcmail.env.spell_langs[t]).addClass("active").data("lang",t).on("click keypress",function(e){if("keypress"!=e.type||13==rcube_event.get_keycode(e))return rcmail.spellcheck_lang_set($(this).data("lang")),rcmail.hide_menu("spell-menu",e),!1}).appendTo(a),n.push(a);o.append(n).appendTo(e)}$("li",o).each(function(){var e=$("a",this);e.data("lang")==i?e.addClass("selected").attr("aria-selected","true"):e.hasClass("selected")&&e.removeClass("selected").removeAttr("aria-selected")})},this.searchmenu=function(c){var e,t="*",a=$('input[name="s_mods[]"]',c),n=$("#s_scope",c),i=$("#s_interval",c),o=rcmail.env.mailbox,s=rcmail.env.search_mods,r=rcmail.env.search_scope||"base";$(c).data("initialized")||($(c).data("initialized",!0),a.length&&(a.on("change",function(){var e,t,a=c,n=this,i={},o=$('input[name="s_mods[]"]',a),s=rcmail.env.task,r=rcmail.env.search_mods||{},l=rcmail.env.mailbox;"mail"==s?(r[l]||(r[l]=rcube_clone_object(r["*"])),t=r[l],e="text",i={sender:["from","replyto","followupto"],recipient:["to","cc","bcc"]}):(t=r,e="*"),n.checked?t[n.value]=1:delete t[n.value],n.value==e?o.not(n).each(function(){this.checked=!0,n.checked?(this.disabled=!0,delete t[this.value]):(this.disabled=!1,this.value in i||(t[this.value]=1))}):n.value in i?(delete t[n.value],o.filter(function(){return-1!=$.inArray(this.value,i[n.value])}).each(function(){n.checked?(this.checked=!0,t[this.value]=1):(this.checked=!1,delete t[this.value])})):i.sender&&pe(a),rcmail.set_searchmods(t)}),rcmail.addEventListener("beforesearch",function(){rcmail.env.search_scope=n.val(),rcmail.env.search_interval=i.val()})),$(c).find(".proplist > li > a.dropdown").on("click",function(){var e=$(this).next();e[e.is(".d-none")?"removeClass":"addClass"]("d-none")}));if(n.val(r),s)if("mail"==rcmail.env.task&&(s=s[o]||s["*"],t="text"),s[t])a.map(function(){this.checked=!0,this.disabled=this.value!=t});else for(e in a.prop("disabled",!1).prop("checked",!1),s)a.filter('[value="'+e+'"]').prop("checked",!0);pe(c)},this.headersmenu=function(e,t,a){$("li > a",e).each(function(){var e=$(this),t="#compose_"+e.data("target");e[$(t).is(":visible")?"removeClass":"addClass"]("active").off().on("click",function(){$(t).removeClass("hidden").find(".recipient-input input").focus(),e.removeClass("active"),rcmail.set_menu_buttons()})})},this.header_reset=function(e){$("#"+e).val("").change().closest(".form-group").nextAll(":not(.hidden)").first().find("input").focus(),$("a[data-target="+e.replace(/^_/,"")+"]").addClass("active"),rcmail.set_menu_buttons()},this.compose_status=me,this.attachmentmenu=he,this.mailtomenu=ve,this.recipient_selector=function(e,t){t=t||{};function a(){i.is(":visible")&&rcmail.env.recipient_dialog.dialog("close")}var n=t.title||"insertcontact",i=$("#recipient-dialog"),o=i.parent();rcmail.env.recipient_selector_initialized||(rcmail.addEventListener("add-recipient",a),rcmail.env.recipient_selector_initialized=!0);e&&(rcmail.env.focused_field="#_"+e);rcmail.contact_list.clear_selection(),rcmail.contact_list.multiselect=!("multiselect"in t)||t.multiselect,rcmail.env.recipient_dialog=rcmail.simple_dialog(i,n,function(){t.action?(t.action(),a()):rcmail.command("add-recipient")},{button:rcmail.gettext(t.button||"insert"),button_class:t.button_class||"insert recipient",height:600,classes:{"ui-dialog-content":"p-0"},open:function(){$("#directorylist a").first().focus()},close:function(){i.appendTo(o),$(this).remove(),$(t.focus||rcmail.env.focused_field).focus()}})},this.show_list=oe,this.show_sidebar=ie,this.smart_field_init=function(a){var e=a.id+"_list",n=$('<div class="multi-input"><div class="content"></div><div class="invalid-feedback"></div></div>'),t=a.value?a.value.split("\n"):[""];$("#"+e).length||($.each(t,function(e,t){ke($(".content",n),t,0,a)}),n.attr("id",e),(a=$(a)).attr("disabled")?n.hide():a.prop("disabled",!0),a.data("hidden")&&n.hide(),a.after(n),a.hasClass("is-invalid")&&(n.addClass("is-invalid"),$(".invalid-feedback",n).text(a.data("error-msg"))))},this.smart_field_reset=function(a,e){var t=a.id+"_list",e=e.length?e:[""],n=$("#"+t).children(".content");n.empty(),$.each(e,function(e,t){ke(n,t,0,a)})},this.form_errors=function(e){$.each(e,function(){var e=$("#"+this[0]).addClass("is-invalid");"list"==e.data("type")?(e.data("error-msg",this[2]),$("#"+this[0]+"_list > .invalid-feedback").text(this[2])):e.after($('<span class="invalid-feedback">').text(this[2]))})},this.switch_nav_list=function(e){var t,a,n=$("a",e),i=$(e).next();i.height()?(i.animate({height:"0"},250),n.addClass("expand").removeClass("collapse"),$(e).removeClass("expanded")):(t=$("tr,li",i).filter(function(){return"none"!=this.style.display}),a=$(t[0]).height()||50,i.animate({height:Math.min(5,t.length)*a+1+"px"},250),n.addClass("collapse").removeClass("expand"),$(e).addClass("expanded"))},this.searchbar_init=le,this.pretty_checkbox=A,this.pretty_select=_e,this.datepicker_init=function(e){window.MutationObserver&&$(e).not("[data-observed]").each(function(){var n,i=!0,o=v?parent:window;$(this).attr("data-observed","1"),v&&($(this).detach().appendTo(parent.document.body),$('<div id="ui-datepicker-div" class="hidden">').appendTo(document.body)),new MutationObserver(function(e){$.each(e,function(e,t){var a;"attributes"==t.type?(a="true"==$(t.target).attr("aria-hidden"))!=i&&(a?n&&n.remove():n=$("<div>").attr("class","ui-widget-overlay datepicker").appendTo(o.document.body).click(function(e){$(this).remove(),v&&$.datepicker._hideDatepicker()}),i=a):t.addedNodes.length&&(o.UI.bootstrap_style(t.target),v)&&(o.$("select.ui-datepicker-month",t.target).on("change",function(){$.datepicker._selectMonthYear($.datepicker._lastInput,this,"M")}),o.$("select.ui-datepicker-year",t.target).on("change",function(){$.datepicker._selectMonthYear($.datepicker._lastInput,this,"Y")}))})}).observe(this,{childList:!0,subtree:!1,attributes:!0,attributeFilter:["aria-hidden"]})})},this.bootstrap_style=E,this.toggle_list_selection=function(e,t){$(e).is(".active")&&Ee("list-selection",$("#"+t).toggleClass("withselection").is(".withselection"))},this.get_screen_mode=function(){return m},this.is_mobile=I,this.is_touch=Ce,Z(),"print"!=rcmail.env.action&&(l=rcmail.get_cookie("colorMode"),c=window.matchMedia("(prefers-color-scheme: dark)"),H=function(){rcmail.set_cookie("colorMode","",new Date)},d=function(){try{$(this.contentWindow.document).find("html")["dark"==h?"addClass":"removeClass"]("dark-mode")}catch(e){}},!(u=function(){"dark"==h?($("#taskmenu a.theme").removeClass("dark").addClass("light").find("span").text(rcmail.gettext("lightmode")),$("html").addClass("dark-mode")):($("#taskmenu a.theme").removeClass("light").addClass("dark").find("span").text(rcmail.gettext("darkmode")),$("html").removeClass("dark-mode")),te(m),$("iframe").each(d)})===rcmail.env.dark_mode_support?"dark"==l&&(H(),$("iframe").each(d)):($("#taskmenu a.theme").on("click",function(){h=$(this).is(".dark")?"dark":"light",u(),rcmail.set_cookie("colorMode",h,!1)}),c.addListener(function(e){h=e.matches?"dark":"light",u(),H()}),l?h=l:c.matches&&(h="dark"),u(),$("iframe").on("load",d))),g.last_selected=$("#layout > div.selected")[0],!g.last_selected&&_.content.length&&$.each(["sidebar","list","content"],function(){if(_[this].length)return g.last_selected=_[this][0],_[this].addClass("selected"),!1}),$(window).on("resize",function(){clearTimeout(g.resize_timeout),g.resize_timeout=setTimeout(function(){T()},25)}),g.open_window=rcmail.open_window,rcmail.open_window=xe,rcmail.addEventListener("message",se).addEventListener("menu-open",ce).addEventListener("menu-close",ce).addEventListener("editor-init",J).addEventListener("autocomplete_create",Q).addEventListener("googiespell_create",Q).addEventListener("setquota",ge).addEventListener("enable-command",X).addEventListener("destroy-entity-selector",function(e){de(e.name)}).addEventListener("clonerow",be).addEventListener("init",G),(_.list.length||_.content.length)&&I()&&(n=[],$("[data-fab]").each(function(){var e=$(this),t=e.data("fab-task")||"*",a=e.data("fab-action")||"*";"*"!=t&&t!=rcmail.env.task||"*"!=a&&a!=rcmail.env.action&&("none"!=a||rcmail.env.action)||n.push(C(e,!1,!1,!0))}),n.length)&&$('<div class="floating-action-buttons">').append(n).appendTo(_.list.length?_.list:_.content),_.sidebar.length&&we(_.sidebar),_.list.length&&we(_.list),E(),g.got_smart_toolbar||(g.got_smart_toolbar=!0,t=[],i=[],N=D(),o=function(e,t,a){var n=$('<li role="menuitem">');(e=a?C($(e),!0,"hidden-big hidden-large"):$(e).detach()).contents().filter(function(){3==this.nodeType&&0==this.nodeValue.trim().length&&$(this).remove()}),e.is(".spacer")?n.addClass("spacer"):n.append(e),t.push(n)},_.content.find(".header > .menu").each(function(){var e=$(this);e.children().each(function(){o(this,t)}),e.remove()}),_.list.find(".header > .menu").each(function(){var e=$(this);R=e.next(),e.children().each(function(){"large"!=N.mode&&$(this).data("popup-pos","right"),o(this,t,!0),o(this,i)}),e.remove()}),$('ul[data-menu="toolbar-small"] > li > a').each(function(){var e=$(this).clone();e.attr("id",this.id+"_clone"),t.push($('<li role="menuitem">').addClass("hidden-big").append(e))}),i.length&&(e=_.list.children(".header"),s={class:"menu toolbar popupmenu listing iconized",id:"toolbar-list-menu"},r=$('<a class="button icon toolbar-list-button" href="#list-menu">').attr({"data-popup":"toolbar-list-menu"}),l=$("<ul>").attr(s).data("popup-parent",e).append(i),R.length?l.insertBefore(R):e.append(l),e.append(r)),t.length&&(e=_.content.children(".header"),s={class:"menu toolbar popupmenu listing iconized",id:"toolbar-menu"},r=$('<a class="button icon toolbar-menu-button" href="#menu">').attr({"data-popup":"toolbar-menu"}),e.append($("<ul>").attr(s).data("popup-parent",e).append(t)).append(r),_.list.find("a.toolbar-menu-button").click(function(e){e.stopPropagation(),r.click()}))),_.list.length&&(W=g.last_selected,P=function(e){"string"==typeof e&&e.length||(e=$("h1.voice").text()||$("title").text()||""),_.content.find(".header > .header-title").text(e)},U=function(e,t,a,n){var i,o,s,r,l;I()&&g.frame_nav&&(e=e,(t=t).match(/_action=(create|add)/)||t.match(/_nav=hide/)?$(g.frame_nav).addClass("hide-nav-buttons"):(t=$("[data-list]",_.list).data("list"))&&(i=rcmail[t])?($(g.frame_nav).removeClass("hide-nav-buttons hidden"),(l=i.get_single_selection())&&(i.rows&&i.rows[l]&&!i.rows[l].expanded?i.expand_row(e,l):i.get_node&&(e=i.get_node(l))&&e.collapsed&&i.expand(l)),r=$("#"+rcmail.env.contentframe),e=$("a.button.next",g.frame_nav).off("click").addClass("disabled"),l=$("a.button.prev",g.frame_nav).off("click").addClass("disabled"),((s=i.get_next())||rcmail.env.current_page<rcmail.env.pagecount)&&e.removeClass("disabled").on("click",function(){g.content_lock=!0,S(r),s?i.select(s):(rcmail.env.list_uid="FIRST",rcmail.command("nextpage"))}),((o=i.get_prev())&&("*"!=o||"subscription_list"!=t)||1<rcmail.env.current_page)&&l.removeClass("disabled").on("click",function(){g.content_lock=!0,S(r),o?i.select(o):(rcmail.env.list_uid="LAST",rcmail.command("previouspage"))})):$(g.frame_nav).is(".hide-nav-buttons")&&!$(".buttons",g.frame_nav).children().length&&$(g.frame_nav).addClass("hidden")),a&&!_.content.is(":visible")?g.last_selected=_.content[0]:a||g.last_selected==W||g.content_lock||(g.last_selected=W),ee(),P(n&&a?n:null),g.content_lock=!1},q=function(e){"large"!=m&&!g.content_lock&&e.force&&oe(),g.content_lock=!1,e.title&&$(".header > .header-title",_.list).text(e.title)},c=function(e){var t={};"addressbook"!=rcmail.env.task&&"mail"!=rcmail.env.task||(t.force=!0),"mail"!=rcmail.env.task||rcmail.env.action||(e="string"==$.type(e)?e:rcmail.env.mailbox,e=rcmail.env.mailboxes[e],t.title=e?e.name:""),q(t)},_.content.find("iframe").on("load",function(e){var t,a="",n=!0;$(this).parent(".iframe-wrapper").scrollTop(0);try{n=!(a=(t=e.target.contentWindow).location.href).endsWith(rcmail.env.blankpage),$(t).on("unload",P)}catch(e){}U(e,a,n)}),rcmail.addEventListener("afterlist",c).addEventListener("afterlistgroup",c).addEventListener("afterlistsearch",c).addEventListener("show-list",function(e){e.force=!0,q(e)}).addEventListener("show-content",function(e){e.obj&&!$(e.obj).is("iframe")&&($(e.scrollElement||e.obj).scrollTop(0),I())&&S(e.obj),U(e.event||new Event,"_action="+(e.mode||"edit"),!0,e.title)})),$("[data-popup]").each(function(){z(this)}),$(document).on("click",M),rcube_webmail.set_iframe_events({mousedown:M,touchstart:M});var w,x,V=[];function C(t,e,a,n){var i,o=!0,s=$("<a>"),r=t.attr("id")||(new Date).getTime(),l=r+"-clone",a=t[0].className+(a?" "+a:"");return e?(i=t.data("popup"))&&(s.data({popup:i,"toggle-button":t.data("toggle-button")}),z(s[0]),o=!1,rcmail.register_menu_button(s[0],i)):(a=a.replace("btn-primary","primary").replace(/(btn[a-z-]*|button|disabled)/g,"").trim(),a+=" button"+(n?"":" disabled")),s.attr({id:l,href:"#",class:a}).append($('<span class="inner">').text(t.text())),o&&s.on("click",function(e){t.click()}),v&&!e?(s.data("target",t),K.push($.extend({button_id:l},y(t[0].id)))):(i=r,n=l,o=a.replace(" disabled",""),(i=y(i))&&rcmail.register_button(i.command,n,i.data.type,o,i.data.sel)),s}function y(e){var t,a,n;for(n in rcmail.buttons)for(t=0;t<rcmail.buttons[n].length;t++)if((a=rcmail.buttons[n][t]).id==e)return{command:n,index:t,data:a}}function G(){$("[data-list]").filter("ul,table").each(function(){var e,t,a,n,i=$(this),o=i.data("list");rcmail[o]&&rcmail[o].multiselect&&((t=(a=(e=i.parents("layout-sidebar,#layout-list,#layout-content").last()).find(".header")).find("ul")).length?n=(n=t.find("a.select").data("toggle-button"))&&$("#"+n):t=a,rcmail[o].enable_checkbox_selection(),!0===ye("list-selection")&&i.addClass("withselection"),n||(n=$("<a>").attr({class:"button selection disabled",role:"button",title:rcmail.gettext("select")}).on("click",function(){UI.toggle_list_selection(this,i.attr("id"))}).append($('<span class="inner">').text(rcmail.gettext("select"))),t.is(".menu")?(n.prependTo(t).wrap('<li role="menuitem">'),_.content&&(a=C(n,!0,"hidden-big hidden-large"),$('<li role="menuitem">').append(a).appendTo("#toolbar-menu"),n=n.add(a))):(a=i.data("list-select-replace"))?$(a).replaceWith(n):(n.appendTo(t).addClass("icon"),e.is("#layout-sidebar")||n.addClass("toolbar-button"))),rcmail.addEventListener("listupdate",function(e){e.list&&e.list==rcmail[o]&&(e.rowcount?n.addClass("active").removeClass("disabled").attr("tabindex",0):n.removeClass("active").addClass("disabled").attr("tabindex",-1))})),B&&rcmail[o]&&("function"==typeof rcmail[o].draggable?rcmail[o].draggable("destroy"):"boolean"==typeof rcmail[o].draggable&&(rcmail[o].draggable=!1),rcmail[o].dblclick_time=0)}),window.MutationObserver&&$("[data-label-msg]").filter("ul,table").each(function(){var n=$('<div class="listing-info hidden">').insertAfter(this),i=$(this),e=function(){var e,t=i.data("label-msg"),a=i.is("ul")?i:i.children("tbody");rcmail.env.search_request||rcmail.env.qsearch||!t||a.children(":visible").length?n.addClass("hidden"):(a=i.data("label-ext"),e=i.data("create-command"),!a||e&&!rcmail.commands[e]||(t+=" "+a),n.text(t).removeClass("hidden"))},t=function(){if(rcmail.busy||!i.is(":visible"))return setTimeout(t,250);clearTimeout(g.list_timer),g.list_timer=setTimeout(e,50)};new MutationObserver(t).observe(i[0],{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),t()}),"print"!=rcmail.env.action&&$("#attachment-list > li").each(function(){fe(this)});function t(e){"phone"==m&&rcmail.display_message(rcmail.gettext(e),"confirmation")}var e,a;rcmail.addEventListener("fileappended",function(e){e.attachment.complete&&(fe(e.item),"text/vcard"==e.attachment.mimetype)&&rcmail.commands["attach-vcard"]&&t("vcard_attachments.vcardattached")}).addEventListener("managesieve.insertrow",function(e){E(e.obj)}).addEventListener("add-recipient",function(){t("recipientsadded")}),rcmail.init_pagejumper(".pagenav > input"),"mail"==rcmail.task?("compose"==rcmail.env.action&&(rcmail.addEventListener("compose-encrypted",function(e){$("a.mode-html, button.attach").prop("disabled",e.active),$("a.attach, a.responses:not(.edit)")[e.active?"addClass":"removeClass"]("disabled")}),$("#layout-sidebar > .footer:not(.pagenav) > a.button").click(function(){$(this).is(".disabled")&&rcmail.display_message(rcmail.gettext("nocontactselected"),"warning")}),window.MutationObserver)&&(e=$("#attachment-list"),a=function(){me("attach",0<e.children().length)},new MutationObserver(a).observe(e[0],{childList:!0}),a()),rcmail.env.extwin||"compose"!=rcmail.env.action&&"show"!=rcmail.env.action||$("a.mail",_.menu).attr({"aria-disabled":!1,onclick:"return rcmail.command('list','',this,event);"}),"preview"!=rcmail.env.action&&"show"!=rcmail.env.action||($("a").filter('[href^="mailto:"]').each(function(){var a,n;n=(a=this).onclick,a.onclick=null,$(a).on("click",function(e,t){return t||ve($("#mailto-menu"),a,e,n)})}),ue())):"settings"==rcmail.task&&(rcmail.addEventListener("identity-encryption-show",function(e){E(e.container)}),rcmail.addEventListener("identity-encryption-update",function(e){E(e.container)})),rcmail.set_env({thread_padding:"1.5rem",popup_width_small:1025,popup_width:1200}),rcmail.env.devel_mode&&window.less?less.pageLoadFinished.then(function(){T(),rcmail.env.compose_focus_elem&&$(rcmail.env.compose_focus_elem).focus()}):T();var n,i=rcmail.env.date_format_localized;i&&(n=function(e){$(e).filter(".datepicker").attr("placeholder",i),$(e).parent().find("select").each(function(){_e(this)})},$("input.datepicker").each(function(){n(this)}),rcmail.addEventListener("insert-edit-field",n))}function E(t){t=t||document,$("input.button,button",t).not(".btn").addClass("btn").not(".btn-primary,.primary,.mainaction").addClass("btn-secondary"),$("input.button.mainaction,button.primary,button.mainaction",t).addClass("btn-primary"),$("button.btn.delete,button.btn.discard",t).addClass("btn-danger"),$.each(["warning","error","information","confirmation"],function(){var e=this;$(".box"+e+":not(.ui.alert)",t).each(function(){re(this,e,!0)})}),t!=document&&1==$(".popup",t).children().length&&((a=$(".popup",t).children().first()).is("img")?$(".popup",t).addClass("justified"):a.is("label")&&(e=a.find("input").detach(),a=a.detach(),(n=e.attr("id"))||e.attr("id",n="dialog-input-elastic"),$(".popup",t).addClass("formcontent").append($('<div class="form-group row">').append(a.attr("for",n).addClass("col-sm-4 col-form-label text-break")).append($('<div class="col-sm-8">').append(e))),e.focus()));var e,a,n,i="input:not(.button,.no-bs,[type=button],[type=radio],[type=checkbox],[type=file]),textarea";$(i,$(".propform",t)).addClass("form-control"),$("[type=checkbox]",$(".propform",t)).addClass("form-check-input"),$("select",t).addClass("form-control custom-select"),t!=document&&$(i,t).addClass("form-control"),$("table.propform",t).each(function(){var o=0,s=0,r=["sm",4,8];$(this).attr("class").match(/cols-([a-z]+)-(\d)-(\d)/)&&(r=[RegExp.$1,RegExp.$2,RegExp.$3]),$(this).find("> tbody > tr, > tr").each(function(){var e,t,a=$(this),n=["form-group","row"],i=a.children("td");2==i.length?(e=i.first(),t=i.last(),$("label",e).addClass("col-form-label"),e.addClass("col-"+r[0]+"-"+r[1]),t.addClass("col-"+r[0]+"-"+r[2]),1!=t.find("[type=checkbox]").length||t.find(".proplist").length?t.find("input:not([type=hidden]),textarea,radio,select").length?s++:(t.addClass("form-control-plaintext"),o++):(n.push("form-check"),t.find("a").length&&n.push("with-link"),s++),t.children(".datepicker")&&2==t.children("input").length&&t.addClass("datetime")):1==i.length&&i.css("width","100%"),a.addClass(n.join(" "))}),s<o&&$(this).addClass("text-only")}),$("td.input-group",t).each(function(){$(this).children().slice(1).addClass("input-group-append")}),$("fieldset.propform:not(.grouped) div.row",t).each(function(){var e=0<$("input:not([type=hidden]),select,textarea",this).length;e&&$(i,this).addClass("form-control"),$(this).children().last().addClass("col-sm-8"+(e?"":" form-control-plaintext")),$(this).children().first().addClass("col-sm-4 col-form-label"),$(this).addClass("form-group")}),$("fieldset.propform.grouped fieldset",t).each(function(){$(".row",this).each(function(){var e,t=0<$("input,select,textarea",this).length,a=$(this).children();t&&$(i,this).addClass("form-control"),a.length<2||((e=a.first()).is("select")?e.addClass("input-group-prepend"):e.wrap('<span class="input-group-prepend">').addClass("input-group-text"),t||a.last().addClass("form-control-plaintext"),$(".content",this).addClass("input-group-prepend input-group-append input-group-text"),$("a.deletebutton",this).addClass("input-group-text icon delete").wrap('<span class="input-group-append">'),$(this).addClass("input-group"))})}),$("fieldset.advanced",t).each(function(){var e=$(this).children(".propform").first();e.wrap($("<div>").addClass("collapse")),$(this).children("legend").first().addClass("closed").on("click",function(){e.parent().collapse("toggle"),$(this).toggleClass("closed")})}),$(".propform > .prop.block:not(.row)",t).each(function(){$(this).addClass("form-group row").each(function(){$("label",this).addClass("col-form-label").wrap($('<div class="col-sm-4">')),$("input,select,textarea",this).wrap($('<div class="col-sm-8">')),$(i,this).addClass("form-control")})}),$("td.rowbuttons > a",t).addClass("btn"),$("form.tabbed,div.tabbed",t).each(function(n,e){var i=[],t=$("<ul>").attr({class:"nav nav-tabs",role:"tablist"});$(this).addClass("tab-content").children("fieldset").each(function(e,t){var e=t.id||"tab"+n+"-"+e,a=$(t).data("navlink-class");$(t).addClass("tab-pane").attr({id:e,role:"tabpanel"}),a=$("<li>").addClass("nav-item").append($("<a>").addClass("nav-link"+(a?" "+a:"")).attr({role:"tab",href:"#"+e}).text($("legend",t).first().text()).click(function(e){return $(this).tab("show"),M(e),!1})),$("legend",t).first().hide(),i.push(a)}),t.append(i).insertBefore(e),$("a.nav-link",t).first().click()}),$("input[type=file]:not(.custom-file-input)",t).each(function(){var t=rcmail.gettext("choosefile"+(this.multiple?"s":"")),e=$("<label>").attr({class:"custom-file-label","data-browse":rcmail.gettext("browse")}).text(t);$(this).addClass("custom-file-input").wrap('<div class="custom-file">'),$(this).on("change",function(){var e=t;this.files.length&&(e=this.files[0].name,1<this.files.length)&&(e+=", ..."),$(this).next().text(e)}).parent().append(e)}),$("table:not(.table,.compact-table,.propform,.listing,.ui-datepicker-calendar)",t).filter(function(){return!$(this).parent().is(".propform")&&!$(this).parents("#message-header,.message-htmlpart,.message-partheaders,.boxinformation,.raw-tables").length}).each(function(){var e=$(this).addClass("table");e.parent().addClass("table-responsive-sm"),e.find("thead").addClass("thead-default")}),$("input.pretty-checkbox, .propform input[type=checkbox], .form-check input[type=checkbox], .popupmenu.form input[type=checkbox], .menu input[type=checkbox]",t).each(function(){A(this)}),$(t).is(".actionrow")&&$("input[type=checkbox]",t).each(function(){A(this)}),$(".input-group-combo > select",t).first().on("change",function(){function e(){t[t.next().is(":visible")?"removeClass":"addClass"]("alone")}var t=$(this);setTimeout(e,50),setTimeout(e,2e3)}).trigger("change"),$("#message-objects",t).children(":not(.ui.alert)").add(".part-notice").each(function(){var e=String($(this).removeClass("notice part-notice").attr("class")).split(/\s/)[0]||"warning";re(this,e),$(this).addClass("box"+e),$("a",this).addClass("btn btn-primary btn-sm")}),$(".error",t).addClass("is-invalid"),"login"==rcmail.env.task&&t==document&&($("#rcmloginsubmit").addClass("btn-lg text-uppercase w-100"),$("#rcmloginoauth").addClass("btn btn-secondary btn-lg w-100"),$("#login-form table tr").each(function(){var e=$("input,select",this),t=$("label",this),a=e.data("icon"),n=$("<i>").attr("class","input-group-text icon "+e.attr("name").replace("_",""));a&&n.addClass(a),$(this).addClass("form-group row"),t.parent().css("display","none"),e.addClass(e.is("select")?"custom-select":"form-control").attr("placeholder",t.text()).before($('<span class="input-group-prepend">').append(n)).parent().addClass("input-group input-group-lg")})),$("select:not([multiple])",t).each(function(){_e(this)})}function J(e){var i,o,t,a=[],n=$("#"+e.id).parent().is(".html-editor");e.config.plugins+=" autoresize",Ce()&&(e.config.toolbar="undo redo | link image styleselect"),"mail"==rcmail.task&&"compose"==rcmail.env.action&&(i=!1,o=$("#compose-content > form"),t=function(e){"Tab"==e.key&&e.shiftKey&&$("#compose-content > form").scrollTop(0)},a.push(function(e){e.on("keypress",t)}),$("#composebody").on("keypress",t),o.on("scroll",function(){var e=$(".tox-editor-container",o),t=e.find(".tox-toolbar-overlord"),a=e.offset(),n=o.offset().top;a&&a.top-n<0?(t.css({position:"fixed",top:n+"px",width:e.width()+"px"}),i=!0):(i&&($("#compose-subject").focus(),i=!1),t.css({position:"relative",top:0,width:"auto"}))}),$(window).resize(function(){o.trigger("scroll")})),n&&(e.config.toolbar="plaintext | "+e.config.toolbar,e.config.setup_callback=function(t){t.ui.registry.addButton("plaintext",{tooltip:rcmail.gettext("plaintoggle"),icon:"close",onAction:function(e){rcmail.command("toggle-editor",{id:t.id,html:!1},"",e.originalEvent)&&$("#"+t.id).parent().removeClass("ishtml")}})}),a.push(function(e){e.on("OpenWindow",function(e){function t(e){var t=$(n).find(".tox-dialog__body"),a=$(n).find(".tox-dialog__footer").find("button");e||(4===a.length?t.closest(".tox-dialog").addClass("tox-search-dialog"):2==a.length&&a.first().insertAfter(a[1])),t.find(".tox-checkbox > input").each(function(){A(this)}),t.find(".tox-textarea,.tox-textfield").addClass("form-control")}var n=$(".tox-dialog:last")[0];window.MutationObserver&&new MutationObserver(t).observe($(".tox-dialog__body-content",n)[0],{childList:!0}),t()})}),rcmail.addEventListener("editor-load",function(e){$.each(a,function(){this(e.ref.editor)})})}function Q(t){var e;$("ul",t.obj).addClass("menu listing iconized"),$(t.obj).addClass("popupmenu popover"),E(t.obj),$("input",t.obj).addClass("form-control"),I()&&$(t.obj).is(".googie_window")&&(e=rcmail.gettext("close"),e=$("<a>").attr("class","button icon cancel").text(e).click(function(e){e.stopPropagation(),$(".popover-overlay").remove(),$(t.obj).hide()}),$('<h3 class="popover-header">').append(e).prependTo(t.obj),$(".popover-overlay").length||$("<div>").attr("class","popover-overlay").appendTo("body").click(function(){$(this).remove()}),$("ul,button",t.obj).click(function(e){$(e.target).is("input")||$(".popover-overlay").remove()}))}function X(a){if(v&&$.each(K,function(e,t){a.command==t.command&&parent.$("#"+t.button_id)[a.status?"removeClass":"addClass"]("disabled")}),"mail"==rcmail.task)switch(a.command){case"reply-list":var e;1==rcmail.env.reply_all_mode&&(e=rcmail.gettext(a.status?"replylist":"replyall"),$(".toolbar a.reply-all").attr("title",e).find(".inner").text(e));break;case"compose-encrypted":$(".toolbar a.encrypt").parent().show();break;case"compose-encrypted-signed":$("#encryption-menu-button").show()}}function Z(){var e=$(window).width(),t=e<=480?"phone":1200<e?"large":768<e?"normal":"small";B=e<=1024,m=t}function T(){Z(),ee();var e,t=D(),a=$(document.documentElement);a[0].className.match(/layout-([a-z]+)/)?RegExp.$1!=t.mode&&a.removeClass("layout-"+RegExp.$1).addClass("layout-"+t.mode):a.addClass("layout-"+t.mode),t.touch&&!a.is(".touch")?a.addClass("touch"):!t.touch&&a.is(".touch")&&a.removeClass("touch"),(e=I())?(rcmail.set_env(g.small_screen_config),rcmail.enable_command("extwin",!1)):(rcmail.set_env(g.config),rcmail.enable_command("extwin",!0)),$.each(Y,function(){$(this)[e?"hide":"show"]()}),rcmail.triggerEvent("skin-resize",{mode:m})}function ee(){if(!v||_.sidebar.length||_.list.length){switch(m){case"phone":ae(),j(!1);break;case"small":ae(),j(!0);break;case"normal":var e;_.list.length&&(e=_.list.is(g.last_selected)||!_.sidebar.is(g.last_selected)&&!_.sidebar.is(".layout-sticky"),_.list[e?"removeClass":"addClass"]("hidden")),_.sidebar.length&&(e=!_.list.length||_.sidebar.is(g.last_selected)||_.sidebar.is(".layout-sticky"),_.sidebar[e?"removeClass":"addClass"]("hidden")),_.content.removeClass("hidden"),j(!0),ne(),_.list.length&&$(".header > ul.menu",_.list).addClass("popupmenu");break;case"large":$.each(_,function(e,t){t.removeClass("hidden")}),ne(),_.list&&$(".header > ul.menu.popupmenu",_.list).removeClass("popupmenu")}te(m),L(),bw.webkit&&bw.ipad&&bw.agent.match(/OS 9/)&&$(".iframe-wrapper").each(function(){var e=$(this).height();e&&$(this).children("iframe").height(e)})}else L()}function te(e){var t=rcmail.env.additional_logos;t&&($("#logo").data("src-default")||$("#logo").data("src-default",$("#logo").attr("src")),"phone"==e&&"dark"==h&&t["small-dark"]?$("#logo").attr("src",t["small-dark"]):"phone"==e&&t.small?$("#logo").attr("src",t.small):"dark"==h&&t.dark?$("#logo").attr("src",t.dark):$("#logo").attr("src",$("#logo").data("src-default")))}function L(){$("#layout > div > .header").each(function(){var e,t=0,a=0,n={left:0,right:0};$(this).children(":visible:not(.position-absolute)").each(function(){!e&&$(this).is(".header-title")?e=$(this):n[e?"right":"left"]+=this.offsetWidth}),n.left<=0+n.right?a=n.right+(t=0)-n.left:t=n.left-((a=0)+n.right),$(e).css({"margin-right":t+"px","margin-left":a+"px","padding-right":"0px"})})}function ae(){var e,t=!1;_.content.length&&(e=t=_.content.is(g.last_selected),_.content[e?"removeClass":"addClass"]("hidden"),$(".header > ul.menu",_.content).addClass("popupmenu")),_.list.length&&(e=!t&&_.list.is(g.last_selected),_.list[e?"removeClass":"addClass"]("hidden"),$(".header > ul.menu",_.list).addClass("popupmenu")),_.sidebar.length&&(e=!t&&(_.sidebar.is(g.last_selected)||!_.list.length),_.sidebar[e?"removeClass":"addClass"]("hidden")),t&&k.back_list.show()}function ne(){k.back_list.filter(function(){return 0==$(this).parents("#layout-sidebar").length}).hide(),$("ul.menu.popupmenu").removeClass("popupmenu")}function ie(e){_.list.addClass("hidden"),_.sidebar.removeClass("hidden"),e&&_.sidebar.addClass("layout-sticky"),"small"!=m&&"phone"!=m||_.content.addClass("hidden"),L(),g.last_selected=_.sidebar[0]}function oe(e){_.list.length||_.sidebar.length?(_.sidebar.addClass("hidden").removeClass("layout-sticky"),_.list.removeClass("hidden"),"small"!=m&&"phone"!=m||(g.last_selected=_.list[0]||_.sidebar[0],ee(),rcmail.show_contentframe(!1),$("[data-list]",_.list).each(function(){var e=$(this).data("list");rcmail[e]&&(rcmail[e].clear_selection?rcmail[e].clear_selection():rcmail[e].select&&rcmail[e].select())})),e&&_.list.children(".scroller").scrollTop(0),g.last_selected=_.list[0]):history.back(),L()}function j(e){e?("phone"==m&&($('<div id="menu-overlay" class="popover-overlay">').on("click",function(){j(!1)}).appendTo("body"),g.menu_initialized||(g.menu_initialized=!0,$("a",_.menu).on("click",function(e){"phone"==m&&j()})),_.menu.addClass("popover")),_.menu.removeClass("hidden")):($("#menu-overlay").remove(),_.menu.addClass("hidden").removeClass("popover"))}function se(e){"loading"==e.type&&$(".iframe-loader:visible").length?rcmail.hide_message(e.object):(re(e.object,e.type,!0),$(e.object).attr("role","alert"))}function re(e,t,a){var n="ui alert",i=!$(e).is(".noicon");a&&i&&!$(e).is(".aligned-buttons")&&$(e).html($("<span>").html($(e).html())),(a={information:"alert-info",notice:"alert-info",confirmation:"alert-success",warning:"alert-warning",error:"alert-danger",loading:"alert-info loading",uploading:"alert-info loading",vcardattachment:"alert-info"}[t=t.split(" ")[0]])&&(n+=" "+a,i)&&$("<i>").attr("class","icon").prependTo(e),$(e).addClass(n)}function le(i){function e(){$(i).is(".open")&&s.click()}function o(){$(i)[a.val()||"mail"==rcmail.task&&$("#s_interval").val()||rcmail.gui_objects.search_filter&&"ALL"!=$(rcmail.gui_objects.search_filter).val()||rcmail.gui_objects.foldersfilter&&"---"!=$(rcmail.gui_objects.foldersfilter).val()?"addClass":"removeClass"]("active"),t[rcmail.gui_objects.search_filter&&"UNSEEN"==$(rcmail.gui_objects.search_filter).val()?"addClass":"removeClass"]("selected")}var t=$(),s=$("a.button.options",i),a=$("input:not([type=hidden])",i),n=a.attr("placeholder");$("form",i);a.is("#mailsearchform")&&(t=$("<a>").attr({class:"button unread",href:"#",role:"button",title:rcmail.gettext("showunread")}).on("click",function(e){$(rcmail.gui_objects.search_filter).val($(e.target).is(".selected")?"ALL":"UNSEEN"),rcmail.command("search")}).insertBefore(s)),s.on("click",function(e){var t=$(this).data("target"),a=$("#"+t),n=$(i).is(".open");a.length&&(n||(p[t]?p[t](a.get(0),this,e):"function"==typeof window[t]&&window[t](a.get(0),this,e)),a.next()[n?"show":"hide"](),a.toggleClass("hidden"),$(".floating-action-buttons").toggleClass("hidden"),$(i).toggleClass("open"),$("button.search",a).off("click.search").on("click.search",function(){s.click(),o()}))}),a.on("input change",o).on("focus blur",function(e){a.attr("placeholder","blur"==e.type?n:"")}),$("a.reset",i).on("click",function(e){a.val("").change().trigger("keyup.treelist",{keyCode:27}),$(i).is(".open")&&s.click(),rcmail.gui_objects.search_filter&&$(rcmail.gui_objects.search_filter).val("ALL"),rcmail.gui_objects.foldersfilter&&($(rcmail.gui_objects.foldersfilter).val("---").change(),rcmail.folder_filter("---")),o()}),rcmail.addEventListener("init",o).addEventListener("responsebeforesearch",o).addEventListener("beforelist",e).addEventListener("afterlist",o).addEventListener("beforesearch",e)}function z(o,a){if(v&&I())return parent.UI.popup_init(o,a||window);a=a||window;var s,r=$(o).data("popup"),n=$(a.$("#"+r).get(0)),e=n,t=$(o).attr("title");$(o).attr({"aria-haspopup":"true","aria-expanded":"false","aria-owns":r}).popover({content:function(){return a!=window&&(n=e.clone(!0,!0)).attr("id",r+"-clone").appendTo(document.body).find("li > a").attr("onclick","").off("click").on("click",function(e){return $(this).is(".disabled")||($(o).popover("hide"),a.$("#"+$(this).attr("id")).click()),!1}),n.get(0)},trigger:$(o).data("popup-trigger")||"click",placement:$(o).data("popup-pos")||"bottom",animation:!0,boundary:"window",html:!0}).on("show.bs.popover",function(e){var t=n.data("popup-init");r&&b[r]&&(b[r].transitioning=!0),t&&p[t]?p[t](n.get(0),o,e):t&&a[t]&&a[t](n.get(0),o,e),s=$("div.popover:visible").length+1,n.removeClass("hidden").attr("aria-hidden",!1).find('[aria-haspopup="true"]').data("level",s+1).off("click.popup").on("click.popup",function(e){e.stopPropagation()}),I()||n.css("max-height",Math.min(539,$(window).height()-30))}).on("shown.bs.popover",function(e){var t,a,n=I(),i=$("#"+$(o).attr("aria-describedby"));s=$(o).data("level")||1,n&&(a=1<s?"back":"close",t=rcmail.gettext(a),a="button icon "+("back"==a?"back":"cancel"),$(".popover-header",i).empty().append($("<a>").attr("class",a).text(t).on("click",function(e){$(o).popover("hide"),1<s&&e.stopPropagation()}).on("mousedown",function(e){e.stopPropagation()}))),$.each(b,function(e,t){$(t.target).data("level")==s&&e!=r&&O(e)}),"key"==$(o).data("event")&&(i.off("keydown.popup").on("keydown.popup","a.active",function(e){var t,a,n="next";switch(e.which){case 27:case 9:return $(o).popover("toggle").focus(),!1;case 38:case 63232:n="previous";case 40:case 63233:for(t=e.target.parentNode;t=t[n+"Sibling"];)if(a=$(t).children(".active")[0]){a.focus();break}return!1}}),i.find("a.active").first().focus()),r&&b[r]&&(b[r].transitioning=!1),n&&!$(".popover-overlay").length&&$("<div>").attr("class","popover-overlay").appendTo("body").click(function(){$(this).remove()}),$(".popover-body",i).addClass("webkit-scroller")}).on("hide.bs.popover",function(){1==s&&$(".popover-overlay").remove(),r&&b[r]&&n.is(":visible")&&(b[r].transitioning=!0),setTimeout(function(){/-clone$/.test(n.attr("id"))?n.remove():n.attr("aria-hidden",!0).addClass("hidden").appendTo(n.data("popup-parent")||document.body),$(".popover-body:empty").each(function(){$(this).parent().remove()}),r&&b[r]&&delete b[r]},200)}).on("click",function(){$(this).data("event","mouse")}).on("keydown",function(e){if(e.originalEvent)switch(e.originalEvent.which){case 13:case 32:e.preventDefault(),$(this).data("event","key").popover("toggle");break;case 27:$(this).popover("hide")}}),t&&$(o).attr("title",t),!I()&&n.is(".toolbar")||n.attr("aria-hidden","true"),n.data("button",o),n.data("editable")&&n.on("click mousedown",function(e){e.stopPropagation()})}function M(t){f&&f>(new Date).getTime()-250||$(".popover.show").each(function(){var e=$(".popover-body",this).children().first().data("button");e&&t.target!=e&&!$(e).find(t.target).length&&"string"!=typeof e&&$(e).popover("hide"),e||$(this).remove()})}function ce(e){if(e&&e.name&&(!e.props||!1!==e.props.skinable)){if(v&&I())return e.win||(e.win=window),parent.UI.menu_toggle(e);if("messagelistmenu"==e.name){var t=$("#listoptions-menu"),n=(t.width(),t.clone(!0));$('select[name="sort_col"]',n).val(rcmail.env.sort_col||""),$('select[name="sort_ord"]',n).val(rcmail.env.sort_order||"ASC"),$('select[name="mode"]',n).val(rcmail.env.threading?"threads":"list"),$("select",n).each(function(){this.id=this.id+"-clone"}),$("label",n).each(function(){$(this).attr("for",$(this).attr("for")+"-clone")}),n=rcmail.simple_dialog(n,"listoptionstitle",function(e){rcube_event.is_keyboard(e.originalEvent)&&$("#listmenulink").focus();var e=$('select[name="sort_col"]',n).val(),t=$('select[name="sort_ord"]',n).val(),a=$('select[name="mode"]',n).val();return rcmail.set_list_options([],e,t,"threads"==a?1:0),!0},{closeOnEscape:!0,minWidth:400})}else if("menu-open"==e.event){var a,i,t=$("ul",e.obj).first(),o=e.props&&e.props.link?e.props.link:e.originalEvent.target;if(!t.length)return;$(o).is("span")&&(o=$(o).parents("a,li")[0]),e.name.match(/^drag/)&&(i=rcube_event.get_mouse_pos(e.originalEvent),o=$("<a>").css({position:"absolute",left:i.x,top:i.y,height:"1px",width:"1px",visibility:"hidden"}).appendTo(document.body).get(0)),i=$(o).data("popup-pos")||"right","folder-selector"==e.name?t.addClass("listing folderlist"):"addressbook-selector"==e.name||"contactgroup-selector"==e.name?t.addClass("listing contactlist"):t.hasClass("menu")&&t.addClass("listing"),"pagejump-selector"==e.name&&(t.addClass("simplelist"),e.obj.addClass("simplelist"),i="top"),b[e.name]&&O(e.name,e.originalEvent),(a=function(){if(b[e.name]&&b[e.name].transitioning)return setTimeout(a,50);$(o).data("popup")||($(o).data({event:rcube_event.is_keyboard(e.originalEvent)?"key":"mouse",popup:e.name,"popup-pos":i,"popup-trigger":"manual"}),z(o,e.win)),b[e.name]={target:o},setTimeout(function(){$(o).popover("show")},1)})()}else O(e.name,e.originalEvent);e.originalEvent.stopPropagation()}}function O(e,t){var a=function(e){var t;b[e]?t=b[e].target:(t=$("#"+e).data("button"))||(e.match(/(?!-)menu$/)&&(e=e.substr(0,e.length-4)),t=$("#"+e+"-menu").data("button"));return t}(e);e.match(/^drag/)?$(a).popover("dispose").remove():($(a).popover("hide"),"forwardmenu"==e&&M(t))}function de(e){$("[aria-owns="+e+"]").popover("dispose").data("popup",null)}function ue(e){var t="mail.show.envelope",a=ye(t),a=e?!a:a,n=a?"summary":"details",i=$("div.header-content");$("div.header-links").find("a.headers-details,a.headers-summary").removeClass().addClass("headers-"+n).text(rcmail.gettext(n)),i[a?"addClass":"removeClass"]("details-view"),e&&Ee(t,a)}function pe(e){$(e).find(".proplist > li.with-sublist").each(function(){$(this).find(":not(.proplist) input")[0].checked=0<$(this).children(".proplist").find("input:checked").length})}function me(e,t){var a=$("#composestatusbar"),n=a.find("a.button.icon."+e);t?n.length||$("<a>").attr("class","button icon "+e).on("click",function(){ie()}).appendTo(a):n.remove()}function he(e,t,a){var n=$(t).parent().attr("id").replace(/^attach/,"");return $.each(["open","download","rename"],function(){var t=this;$("#attachmenu"+t,e).off("click").attr("onclick","").click(function(e){return rcmail.command(t+"-attachment",n,this,e.originalEvent)})}),rcmail.command("menu-open",{menu:"attachmentmenu",id:n},e,a)}function fe(e){var t,a,n;(e=$(e)).is(".no-menu")||e.children(".dropdown").length||(t=rcmail.gettext("options"),a=e.find("a.filename"),n=$("<a>").attr({href:"#",tabindex:a.attr("tabindex")||0,title:t,class:"button icon dropdown skip-content"}).on("click",function(e){return he($("#attachmentmenu"),n,e)}).append($("<span>").attr("class","inner").text(t)),a.length?n.insertAfter(a):n.appendTo(e))}function ve(e,n,t,a){var i=$(n).attr("href").replace(/^mailto:/,"");return i.indexOf("@")<0||(e.find("a").off("click").removeClass("active"),rcmail.env.has_writeable_addressbook&&$(".addressbook",e).addClass("active").on("click",function(e){var t=i,a=$(n).filter(".rcmContactAddress").text(),t=t.split("?")[0].split(",")[0].replace(/(^<|>$)/g,"");return a&&(t='"'+(a=a.replace("<"+t+">","")).trim()+'" <'+t+">"),rcmail.command("add-contact",t,this,e.originalEvent)}),$(".compose",e).addClass("active").on("click",function(e){return a?(n.onclick=a,$(n).trigger("click",[!0]),n.onclick=null):rcmail.command("compose",i,this,e.originalEvent),!1}),rcmail.command("menu-open",{menu:"mailto-menu",link:n},n,t.originalEvent))}function ge(t){var e=$("#quotadisplay"),a=e.find(".bar"),n=t.total?t.percent:0;0<n&&n<10&&(n=10),(a=a.length?a:$('<span class="bar"><span class="value"></span></span>').appendTo(e)).find(".value").css("width",n+"%")[90<=n?"addClass":"removeClass"]("warning"),e.attr({"data-original-title":"",title:e.find(".count").attr("title")}),t.table?e.css("cursor","pointer").data("popup-pos","top").off("click").on("click",function(e){rcmail.simple_dialog(t.table,"quota",null,{cancel_button:"close"})}):e.tooltip("dispose").tooltip({trigger:I()?"click":"hover"})}function $e(a){a=a.replace(/[,;\s]*[\r\n]+/g,",").trim();var n=[],e='(\\S+|("[^"]+"))@\\S+',i=new RegExp("(<"+e+">)"),o=new RegExp("("+e+")"),e=a.match(/(?=\S)[^",;]*(?:"[^\\"]*(?:\\[,;\S][^\\"]*)*"[^",;]*)*/g);return $.each(e||[],function(){if(this.length&&(i.test(this)||o.test(this))){var e,t=this;for(a=a.replace(t,"");t.length&&0===t.indexOf(RegExp.$1)&&(e=RegExp.$1,n.push({name:"",email:e.replace(/(^<|>$)/g,"").replace(/[^\p{L}]$/giu,"")}),t=t.replace(e,"").trim(),i.test(t)||o.test(t)););e!=RegExp.$1&&RegExp.$1&&(e=RegExp.$1,n.push({name:t.replace(e,"").trim(),email:e.replace(/(^<|>$)/g,"")}))}}),a=a.replace(/[,;]+/,",").replace(/^[,;\s]+/,""),{recipients:n,text:a}}function S(e){var t;(e=$(e)).length&&(t=$('<div class="iframe-loader">').append($('<div class="spinner spinner-border" role="status">').append($('<span class="sr-only">').text(rcmail.gettext("loading")))),e.on("load error loaded",function(){setTimeout(function(){t.remove()},500)}).parent().append(t),F)&&e.parent().addClass("ios-scroll")}function A(e){var t,a;(e=$(e)).is(".custom-control-input")||((a=e.attr("id"))||(a="icochk"+ ++g.checkboxes,e.attr("id",a)),e.parent().is("label")?(t=e.parent(),e=e.detach(),t.before(e)):t=$("<label>"),t.attr({for:a,class:"custom-control-label",title:e.attr("title")||""}).on("click",function(e){e.stopPropagation()}),e.addClass("form-check-input custom-control-input").wrap('<div class="custom-control custom-switch">').parent().append(t))}function be(e){var t,e=$(e.row).find("input[id^=icochk]");e.length&&(t="icochk"+ ++g.checkboxes,e.attr("id",t).next("label").attr("for",t))}function _e(u){var p,m,h;bw.iphone||bw.ipad||(u=$(u)).is(".pretty-select")||(p="select"+u.attr("id")+u.attr("name"),m=function(){if(u[0].ownerDocument.defaultView.$(".select-menu .listing").data("ident")==p)return!0},h=function(){var e=m();return u.popover("dispose").focus(),!e},u.addClass("pretty-select custom-select form-control").on("mousedown keydown",function(e){var a,s,r,n,l,t,i,o,c,d;if(!(u=$(e.target)).prop("disabled"))return 9==e.which?(h(),!0):27==e.which||"mousedown"==e.type&&m()?h():(u.focus(),u.prop("disabled",!0),setTimeout(function(){u.prop("disabled",!1)},0),e.stopPropagation(),"mousedown"==e.type||13==e.which||32==e.which||40==e.which||63233==e.which?(a=e,r=-1,n=[],l=[],e=u.closest(".ui-dialog")[0],t=(document.documentElement.clientHeight||$(document.body).height())-75,i=$(document.body).width()-20,o=Math.min(u.outerWidth(),i),c=u.val(),I()||(t*=.5),M(a),$("option",u).each(function(){var e=$(this).text(),t=$('<a href="#">').data("value",this.value).addClass(this.disabled?"disabled":"active"+(this.value==c?" selected":""));e.length?(t.text(e),l.push(this.disabled?"":e.charAt(0).toLowerCase())):(t.html(" "),l.push("")),n.push($("<li>").append(t))}),d=$('<ul class="listing selectable iconized">').attr("data-ident",p).data("button",u[0]).append(n).on("click","a.active",function(){var e=$(this).data("value"),t=h();return u.val(e).change(),t}).on("keydown","a.active",function(e){var t,a,n,i,o="next";switch(e.which){case 27:case 9:return h();case 13:case 32:return $(this).click(),!1;case 38:case 63232:o="previous";case 40:case 63233:for(t=e.target.parentNode;t=t[o+"Sibling"];)if(i=$(t).children(".active")[0]){i.focus();break}return!1;default:(a=e.originalEvent.key)&&1==a.length&&(a=a.toLowerCase(),s!=a&&(r=-1),(-1<(n=l.indexOf(a,r+1))||-1<(n=l.indexOf(a)))&&d.find("a").eq(n).focus(),s=a,r=n)}}),u.popover("dispose").popover({container:e||document.body,content:d[0],placement:"bottom",trigger:"manual",boundary:"viewport",html:!0,offset:"0,2",sanitize:!1,template:'<div class="popover select-menu" style="min-width: '+o+"px; max-width: "+i+'px"><div class="popover-header"></div><div class="popover-body" style="max-height: '+t+'px"></div></div>'}).on("shown.bs.popover",function(){u.focus(),d.parent().prev().empty().append($('<a class="button icon cancel">').text(rcmail.gettext("close")).on("click",function(e){return e.stopPropagation(),h()}));var e,t=d.find("a.selected").first();t.focus().length?(e=d.parent(),r=d.find("a").index(t[0]),s=l[r],bw.mz&&5<r&&e.scrollTop(e.scrollTop()+e.height()/2-20)):rcube_event.is_keyboard(a)&&d.find("a.active").first().focus(),d.on("mousedown",function(e){e.stopPropagation()})}).popover("show"),f=(new Date).getTime(),!1):void 0)}))}function ke(a,e,t,n,i){var o=$('<div class="input-group"><input type="text" class="form-control"><span class="input-group-append"><a class="icon reset input-group-text" href="#"></a></span></div>'),s=o.find("input").attr({value:e,name:n.name+"[]",size:$(n).data("size"),title:n.title,placeholder:n.placeholder}).keydown(function(e){if(13==e.which){var t=ke(a,"",(new Date).getTime(),n,s.parent());$("input",t).focus()}else if((8==e.which||46==e.which)&&""==s.val()){t=s.parent();if(1<a.children().length)return(t.prev().length?t.prev():t.next()).children("input").focus(),t.remove(),!1}});return o.find("a.reset").click(function(){var e=$(this.parentNode.parentNode);1<a.children().length?($("input",e.next().length?e.next():e.prev()).focus(),e.remove()):$("input",e).val("").focus()}),o.find("input,a").on("focus",function(){a.addClass("focused")}).on("blur",function(){a.removeClass("focused")}),i?i.after(o):o.appendTo(a),o}function we(i){function o(e){i.css({width:Math.max(100,e),flex:"none"})}var e=i.find(".scroller .listing").first().attr("id"),s=rcmail.env.task+"."+(e||rcmail.env.action+"."+i.attr("id")),e=ye(s),r=i.is(".sidebar-right");i[r?"prev":"next"]().length&&($('<div class="column-resizer">').addClass(r?"inverted":null).appendTo(i).on("mousedown",function(e){var a,t=$(this),n=i.position().left;t.addClass("active"),document.body.style.userSelect="none",$(document).on("mousemove.resizer",function(t){clearTimeout(a),a=setTimeout(function(){r&&(n=i.position().left);var e=rcube_event.get_mouse_pos(t).x,e=r?i.width()+(n-e):e-n;o(e)},5)}).on("mouseup.resizer",function(){$(document).off(".resizer"),$("iframe").off(".resizer"),document.body.style.userSelect="auto",t.removeClass("active"),Ee(s,i.width())})}),e)&&o(e)}function xe(e,t,a,n){function i(e){$(e).css({color:$(document.body).css("color"),backgroundColor:$(document.body).css("background-color")})}var o,s="dark"==h&&/_task=mail/.test(e)&&/_action=viewsource/.test(e);if(!I()||!0===n)return/_task=mail/.test(e)&&/_action=get/.test(e)&&(t=!0),o=g.open_window.call(rcmail,e,t,a),s&&$(o).on("load",function(){i(o.document.body)}),o;e=rcmail.add_url(e,"_framed",1),e=rcmail.add_url(e,"_extwin",1);var n="",t={cancel_button:"close",width:768,height:768},r=$("<iframe>").attr({id:"windowframe",src:e});return/_action=([a-z_]+)/.test(e)&&(a=rcmail.labels[RegExp.$1])&&(n=a),/_frame=1/.test(e)&&(t.dialogClass="no-titlebar"),s&&r.on("load",function(){i(r[0].contentWindow.document.body)}),rcmail.simple_dialog(r,n,null,t),!0}function D(){var e;return v?{mode:(e=$(parent.document.documentElement))[0].className.match(/layout-([a-z]+)/)?RegExp.$1:m,touch:e.is(".touch")}:{mode:m,touch:B}}function I(){var e=D();return"phone"==e.mode||"small"==e.mode}function Ce(){return D().touch}function ye(e){var t;return null==(a=a||rcmail.local_storage_get_item("prefs.elastic",{}))[e]&&null!=(t=rcmail.get_cookie(e))&&(a[e]=t,rcmail.local_storage_set_item("prefs.elastic",a))&&rcmail.set_cookie(e,t,new Date),a[e]}function Ee(e,t){a[e]=t,rcmail.local_storage_set_item("prefs.elastic",a)||rcmail.set_cookie(e,t,!1)}$.ui&&$.widget("ui.dialog",$.ui.dialog,{open:function(){$(this.element).is(".iframe")&&(this.options.width=Math.max(576,this.options.width)),this._super();var e=this,t=$(e.uiDialog),a=t.width(),n=t.height(),i=$(window).width(),o=$(window).height();return i<=480?t.css({width:"100%",height:"100%"}):(o<n&&t.css("height","100%"),i<a&&t.css("width","100%")),$(document).click(),S($("div.popup > iframe",t)),E(e.uiDialog),this},close:function(){return this._super(),$(".select-menu:visible").remove(),this}}),k.menu.on("click",function(){return j(!0),!1}),k.back_sidebar.on("click",function(){return ie(),!1}),k.back_list.on("click",function(){return oe(),!1}),k.back_content.on("click",function(){var e=!0;return _.list.addClass("hidden"),_.sidebar.addClass("hidden"),_.content.removeClass("hidden"),e&&_.sidebar.removeClass("layout-sticky"),L(),g.last_selected=_.content[0],!1}),$(".searchbar").each(function(){le(this)}),!v||rcmail.env.extwin||parent.$(".ui-dialog:visible").length?v||(w=(w=_.content.find(".boxtitle").first().detach().text())||$("h1.voice").first().text())&&_.content.find(".header > .header-title").text(w):(w=$("h1.voice").first().text())&&parent.$("#layout-content > .header > .header-title:not(.constant)").text(w),v||!_.content.length||_.content.is(".no-navbar")||_.content.children(".frame-content").length||(g.frame_nav=$('<div class="footer menu toolbar content-frame-navigation hide-nav-buttons">').append($('<a class="button prev">').append($('<span class="inner"></span>').text(rcmail.gettext("previous")))).append($('<span class="buttons">')).append($('<a class="button next">').append($('<span class="inner"></span>').text(rcmail.gettext("next")))).appendTo(_.content)),$("a[data-content-button]").each(function(){V.push(C($(this)))}),$(".formbuttons").filter(function(){return!$(this).parent(".searchoptions").length}).find("button").each(function(){var e=$(this);(v||e.parents("#layout-content").length)&&(e.is(".cancel")?e.addClass("hidden"):V.push(C(e)))}),(v?parent.UI:p).register_content_buttons(V),(x=rcmail.gui_objects.messageform)&&(x=$('form[name="'+x+'"]'),$("#_cc, #_bcc, #_replyto, #_followupto",$(".compose-headers")).each(function(){$(this).on("change",function(){$("#compose"+$(this).attr("id"))[this.value?"removeClass":"addClass"]("hidden")})}),$("#compose-options").find("textarea,input,select").each(function(){var e=$("<input>").attr({type:"hidden",name:$(this).attr("name")}).appendTo(x);$(this).attr("tabindex",2).on("change",function(){e.val("checkbox"!=this.type||this.checked?$(this).val():"")}).change()})),$("[data-recipient-input]").each(function(){function i(e){return e=$e(e=(e||r.val()).replace(/[,;\s]+$/,"")),$.each(e.recipients,function(){c(this.name,this.email)}),r.val(e.text),l(),0<e.recipients.length}var e,o,r,t,l,c;e=this,t="",l=function(){$(e).val(o.text()+r.val())},c=function(e,t,a){var n=$('<li class="recipient">'),i=$('<span class="name">').html(function(e){var t,a,n="",i=e.length;'"'!=e.charAt(0)&&-1<e.indexOf('"')&&(e='"'+e.replace("\\","\\\\").replace('"','\\"')+'"');for(t=0;t<i;t++)switch(a=e.charAt(t)){case'"':0<t&&t<i-1?n+='"':n+='<span class="quotes">'+a+"</span>";break;case"\\":n+='<span class="quotes">'+a+"</span>","\\"==e.charAt(t+1)&&(n+=a,t++);break;case"<":n+="<";break;case">":n+=">";break;default:n+=a}return n}(e||t)).on("dblclick",function(e){var t,a,n,i;e=e,t=c,a=$(e.target).parents(".recipient"),n=a.text().replace(/,+$/,""),i=$("<input>").attr({type:"text","data-submit":"true"}).val(n),e=$("<label>").text(rcmail.gettext("recipient")).append(i),rcmail.simple_dialog(e,"recipientedit",function(){var e=i.val();if(e){if(e!=n){if(1!=(e=$e(e)).recipients.length)return!1;t(e.recipients[0].name,e.recipients[0].email,a)}return!0}})}),o=$('<span class="email">'),s=$("<a>").attr({class:"button icon remove"}).click(function(){return n.remove(),l(),r.focus(),!1});e&&(t=" <"+t+">"),o.text((e?t:"")+","),n.attr("title",e?e+t:null).append([i,o,s]),a?a.replaceWith(n):n.insertBefore(r.parent()),l()},r=$("<input>").attr({type:"text",tabindex:$(e).attr("tabindex")}).on("paste change",function(e,t,a){var n=this.value;!1!==a&&("paste"==e.type?(a=(e.originalEvent.clipboardData||window.clipboardData).getData("text")||"",n=n.substring(0,this.selectionStart)+a+n.substring(this.selectionEnd),e.preventDefault()):t&&(a=o.find("li.recipient").last()).length&&-1<this.value.indexOf(a.text().replace(/[ ,]+$/,""))&&a.remove(),i(n))}).on("keydown",function(e){return 8!=e.keyCode||r.val().length?!((" "==e.key||","==e.key||";"==e.key||"Enter"==e.key&&!rcmail.ksearch_visible())&&i())&&void 0:(o.children("li.recipient").last().remove(),l(),!1)}).on("blur",function(){o.removeClass("focus")}).on("focus mousedown",function(){o.addClass("focus")}),o=$("<ul>").addClass("form-control recipient-input ac-input rounded-left").append($('<li class="input">').append(r)).on("mouseup",function(){t=window.getSelection().toString()}).on("click",function(){t.length||r.focus()}).sortable({appendTo:document.body,items:"> .recipient",connectWith:".recipient-input",receive:function(e,t){var a=o.text();o.find(".recipient").remove(),i(a),t.sender&&t.sender.find("input").change()}}),$(e).css({position:"absolute",opacity:0,left:"-5000px",width:"10px"}).attr("tabindex",-1).after(o).on("focus",function(e){r.focus(),e.preventDefault()}).on("change",function(){$("li.recipient",o).remove(),r.val(this.value).change()}).change(),rcmail.init_address_input_events(r)}),$(".image-upload").each(function(){function e(){var e=-1!=(n.currentSrc||n.src).indexOf(rcmail.env.photo_placeholder);$(t)[e?"removeClass":"addClass"]("changed")}var t,a,n;t=this,a=$("<a>").attr({class:"icon button delete",href:"#"}).click(function(e){return rcmail.command("delete-photo","",this,e),!1}),n=$(t).find("img")[0],$(t).append(a).click(function(){rcmail.upload_input("upload-form")}),e(),$(n).on("load",e)}),$("textarea[data-html-editor]").each(function(){var e,i,o,t=this,a=!1,n=$(t),s=n.parent(),r=n.is("[readonly],[disabled]"),l=$('<a class="mce-i-html" href="#" tabindex="-1"></a>').attr({title:rcmail.gettext("htmltoggle"),disabled:r}).on("click",function(e){!r&&rcmail.command("toggle-editor",{id:n.attr("id"),html:!0},"",e.originalEvent)&&s.addClass("ishtml")}).on("keydown",function(e){if(9==e.which)return n.focus(),!1}),c=$('<div class="editor-toolbar">').append(l),d=(s.is("td")?(e=$('input[type="checkbox"]',s.parent().next()),a=!0):e=n.next("select.hidden"),t);function u(){if(!d.scrollHeight)return setTimeout(u,250);var e,t,a,n;i||(i=parseInt($(d).css("padding-top"))+parseInt($(d).css("padding-bottom"))+2,o=$(d).height()),d.scrollHeight-i<=o||(t=0,$(d).parents().each(function(){if(0<this.scrollTop)return t=(e=this).scrollTop,!1}),a=$(d).outerHeight(),$(d).outerHeight(0),n=Math.max(o,d.scrollHeight),$(d).outerHeight(a),n!==a&&$(d).height(n),t&&(e.scrollTop=t))}$(d).on("input",u).trigger("input"),1==e.length&&(s.addClass("html-editor"),n.after(c).data("control",e).on("keydown",function(e){e.altKey&&121==e.which&&l.focus()}),a)&&(e.parents("tr").first().hide(),s.prev().hide(),s.addClass("col-sm-12"))}),$("#dragmessage-menu,#dragcontact-menu").each(function(){rcmail.gui_object("dragmenu",this.id)}),$("#taskmenu > a").each(function(){var e,t,a;/button-([a-z]+)/.test(this.className)&&(t=RegExp.$1,(a=y(this.id))&&(e=a.data)&&(e.sel&&(e.sel=e.sel.replace("button-selected","selected")+" "+t),e.act&&(e.act+=" "+t),rcmail.buttons[a.command][a.index]=e,rcmail.init_button(a.command,e)),$(this).addClass(t),$(".button-inner",this).addClass("inner")),$(this).on("mouseover",function(){rcube_webmail.long_subject_title(this,0,$("span.inner",this))})}),$(".listbutton").each(function(){var e=y(this.id);$(this).addClass("button").removeClass("listbutton"),e.data.sel&&(e.data.sel=e.data.sel.replace("listbutton","button")),e.data.act&&(e.data.act=e.data.act.replace("listbutton","button")),rcmail.buttons[e.command][e.index]=e.data,rcmail.init_button(e.command,e.data)}),$("[data-hidden]").each(function(){for(var e,t=$(this).data("hidden"),a=$(this).parent("li"),n=/(large|big|small|phone|lbs)/g;e=n.exec(t);)$(a.length?a:this).addClass("hidden-"+e[1])}),$("[data-list]").each(function(){$("input[type=checkbox]",this).each(function(){A(this)})}),v&&$(".formcontent").each(function(){$(this).next(".formbuttons").length&&$(this).parent().addClass("formcontainer")}),$("#attachment-list + a.zipdownload").appendTo(".header-links"),(F=$("html").is(".ipad,.iphone"))&&$(".iframe-wrapper, .scroller").addClass("ios-scroll"),$("html").filter(".ipad,.iphone,.webkit.mobile,.webkit.tablet").addClass("webkit-scroller").length&&$(_.menu).addClass("webkit-scroller"),$(".treelist").each(function(){function e(){$(t)[0<$(".treetoggle",t).length?"removeClass":"addClass"]("notree")}var t=this;window.MutationObserver&&new MutationObserver(e).observe(t,{childList:!0,subtree:!0}),e(),$("li.mailbox > a").on("mouseover",function(){rcube_webmail.long_subject_title_ex(this)})}),T()}window.rcmail?(rcmail.show_menu=function(e,t,a){var n="object"==typeof e?e.menu:e,i=$("#"+n);return rcmail.triggerEvent(!1===t?"menu-close":"menu-open",{name:n,obj:i,props:e="string"==typeof e?{menu:n}:e,originalEvent:a})},rcmail.hide_menu=function(e,t){return rcmail.triggerEvent("menu-close",{name:e,props:{menu:e},originalEvent:t})}):(rcmail=parent.rcmail,rcube_webmail=parent.rcube_webmail,bw={});var rcmail,rcube_webmail,bw,__newInst,UI=new rcube_elastic_ui;$&&$.datepicker&&(__newInst=$.datepicker._newInst,$.extend($.datepicker,{_newInst:function(e,t){e=__newInst.call(this,e,t);return e.inline||UI.datepicker_init(e.dpDiv),e}}));
|