tvbox/ui.min.js

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,n,t,i,o,s,r,e,l,c,d,u,p,m,h,f,v=this,g="normal",b="light",_=!1,k=!1,w=rcmail.is_framed(),x={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}},C={},y=[],E=[],T={menu:$("#layout-menu"),sidebar:$("#layout-sidebar"),list:$("#layout-list"),content:$("#layout-content")},L={menu:$("a.task-menu-button"),back_sidebar:$("a.back-sidebar-button"),back_list:$("a.back-list-button"),back_content:$("a.back-content-button")};function j(t,e,a,n){var i=!0,o=$("<a>"),s=t.attr("id")||(new Date).getTime(),r=s+"-clone",l=t[0].className+(a?" "+a:"");return e?(a=t.data("popup"))&&(o.data({popup:a,"toggle-button":t.data("toggle-button")}),G(o[0]),i=!1,rcmail.register_menu_button(o[0],a)):(l=l.replace("btn-primary","primary").replace(/(btn[a-z-]*|button|disabled)/g,"").trim(),l+=" button"+(n?"":" disabled")),o.attr({id:r,href:"#",class:l}).append($('<span class="inner">').text(t.text())),i&&o.on("click",function(e){t.click()}),w&&!e?(o.data("target",t),E.push($.extend({button_id:r},z(t[0].id)))):(s=s,r=r,l=l.replace(" disabled",""),(s=z(s))&&rcmail.register_button(s.command,r,s.data.type,l,s.data.sel)),o}function z(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 M(){$("[data-list]").filter("ul,table").each(function(){var e,t,a,n,i,o=$(this),s=o.data("list");rcmail[s]&&rcmail[s].multiselect&&((a=(t=(e=o.parents("layout-sidebar,#layout-list,#layout-content").last()).find(".header")).find("ul")).length?(i=a.find("a.select").data("toggle-button"))&&(i=$("#"+i)):a=t,rcmail[s].enable_checkbox_selection(),!0===$e("list-selection")&&o.addClass("withselection"),i||(i=$("<a>").attr({class:"button selection disabled",role:"button",title:rcmail.gettext("select")}).on("click",function(){UI.toggle_list_selection(this,o.attr("id"))}).append($('<span class="inner">').text(rcmail.gettext("select"))),a.is(".menu")?(i.prependTo(a).wrap('<li role="menuitem">'),T.content&&(n=j(i,!0,"hidden-big hidden-large"),$('<li role="menuitem">').append(n).appendTo("#toolbar-menu"),i=i.add(n))):(n=o.data("list-select-replace"))?$(n).replaceWith(i):(i.appendTo(a).addClass("icon"),e.is("#layout-sidebar")||i.addClass("toolbar-button"))),rcmail.addEventListener("listupdate",function(e){e.list&&e.list==rcmail[s]&&(e.rowcount?i.addClass("active").removeClass("disabled").attr("tabindex",0):i.removeClass("active").addClass("disabled").attr("tabindex",-1))})),_&&rcmail[s]&&("function"==typeof rcmail[s].draggable?rcmail[s].draggable("destroy"):"boolean"==typeof rcmail[s].draggable&&(rcmail[s].draggable=!1),rcmail[s].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");if(!rcmail.env.search_request&&!rcmail.env.qsearch&&t&&!a.children(":visible").length)return e=i.data("label-ext"),a=i.data("create-command"),!e||a&&!rcmail.commands[a]||(t+=" "+e),void n.text(t).removeClass("hidden");n.addClass("hidden")},t=function(){if(rcmail.busy||!i.is(":visible"))return setTimeout(t,250);clearTimeout(x.list_timer),x.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(){ie(this)});function t(e){"phone"==g&&rcmail.display_message(rcmail.gettext(e),"confirmation")}var e,a;rcmail.addEventListener("fileappended",function(e){e.attachment.complete&&(ie(e.item),"text/vcard"==e.attachment.mimetype&&rcmail.commands["attach-vcard"]&&t("vcard_attachments.vcardattached"))}).addEventListener("managesieve.insertrow",function(e){O(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(){ae("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",T.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||oe($("#mailto-menu"),a,e,n)})}),ee())):"settings"==rcmail.task&&(rcmail.addEventListener("identity-encryption-show",function(e){O(e.container)}),rcmail.addEventListener("identity-encryption-update",function(e){O(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(){R(),rcmail.env.compose_focus_elem&&$(rcmail.env.compose_focus_elem).focus()}):R();var n,i=rcmail.env.date_format_localized;i&&(n=function(e){$(e).filter(".datepicker").attr("placeholder",i),$(e).parent().find("select").each(function(){ue(this)})},$("input.datepicker").each(function(){n(this)}),rcmail.addEventListener("insert-edit-field",n))}function O(t){var e,a,n;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(){K(this,e,!0)})}),t!=document&&1==$(".popup",t).children().length&&((n=$(".popup",t).children().first()).is("img")?$(".popup",t).addClass("justified"):n.is("label")&&(e=n.find("input").detach(),a=n.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 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 a=t.id||"tab"+n+"-"+e,e=$(t).data("navlink-class");$(t).addClass("tab-pane").attr({id:a,role:"tabpanel"}),a=$("<li>").addClass("nav-item").append($("<a>").addClass("nav-link"+(e?" "+e:"")).attr({role:"tab",href:"#"+a}).text($("legend",t).first().text()).click(function(e){return $(this).tab("show"),J(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(){ce(this)}),$(t).is(".actionrow")&&$("input[type=checkbox]",t).each(function(){ce(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";K(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(){ue(this)})}function S(e){var i,o,t,a=[],n=$("#"+e.id).parent().is(".html-editor");e.config.plugins+=" autoresize",ge()&&(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(){ce(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 A(t){var e;$("ul",t.obj).addClass("menu listing iconized"),$(t.obj).addClass("popupmenu popover"),O(t.obj),$("input",t.obj).addClass("form-control"),ve()&&$(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 D(a){if(w&&$.each(E,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 I(){var e=$(window).width(),t=e<=480?"phone":1200<e?"large":768<e?"normal":"small";_=e<=1024,g=t}function R(){var e;I(),N(),function(){var e=fe(),t=$(document.documentElement);t[0].className.match(/layout-([a-z]+)/)?RegExp.$1!=e.mode&&t.removeClass("layout-"+RegExp.$1).addClass("layout-"+e.mode):t.addClass("layout-"+e.mode);e.touch&&!t.is(".touch")?t.addClass("touch"):!e.touch&&t.is(".touch")&&t.removeClass("touch")}(),(e=ve())?(rcmail.set_env(x.small_screen_config),rcmail.enable_command("extwin",!1)):(rcmail.set_env(x.config),rcmail.enable_command("extwin",!0)),$.each(y,function(){$(this)[e?"hide":"show"]()}),rcmail.triggerEvent("skin-resize",{mode:g})}function N(){if(!w||T.sidebar.length||T.list.length){switch(g){case"phone":U(),F(!1);break;case"small":U(),F(!0);break;case"normal":!function(){var e;T.list.length&&(e=T.list.is(x.last_selected)||!T.sidebar.is(x.last_selected)&&!T.sidebar.is(".layout-sticky"),T.list[e?"removeClass":"addClass"]("hidden"));T.sidebar.length&&(e=!T.list.length||T.sidebar.is(x.last_selected)||T.sidebar.is(".layout-sticky"),T.sidebar[e?"removeClass":"addClass"]("hidden"));T.content.removeClass("hidden"),F(!0),q(),T.list.length&&$(".header > ul.menu",T.list).addClass("popupmenu")}();break;case"large":$.each(T,function(e,t){t.removeClass("hidden")}),q(),T.list&&$(".header > ul.menu.popupmenu",T.list).removeClass("popupmenu")}W(g),P(),bw.webkit&&bw.ipad&&bw.agent.match(/OS 9/)&&$(".iframe-wrapper").each(function(){var e=$(this).height();e&&$(this).children("iframe").height(e)})}else P()}function W(e){var t=rcmail.env.additional_logos;t&&($("#logo").data("src-default")||$("#logo").data("src-default",$("#logo").attr("src")),"phone"==e&&"dark"==b&&t["small-dark"]?$("#logo").attr("src",t["small-dark"]):"phone"==e&&t.small?$("#logo").attr("src",t.small):"dark"==b&&t.dark?$("#logo").attr("src",t.dark):$("#logo").attr("src",$("#logo").data("src-default")))}function P(){$("#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")?n[e?"right":"left"]+=this.offsetWidth:e=$(this)}),0+n.right>=n.left?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 U(){var e,t=!1;T.content.length&&(e=t=T.content.is(x.last_selected),T.content[e?"removeClass":"addClass"]("hidden"),$(".header > ul.menu",T.content).addClass("popupmenu")),T.list.length&&(e=!t&&T.list.is(x.last_selected),T.list[e?"removeClass":"addClass"]("hidden"),$(".header > ul.menu",T.list).addClass("popupmenu")),T.sidebar.length&&(e=!t&&(T.sidebar.is(x.last_selected)||!T.list.length),T.sidebar[e?"removeClass":"addClass"]("hidden")),t&&L.back_list.show()}function q(){L.back_list.filter(function(){return 0==$(this).parents("#layout-sidebar").length}).hide(),$("ul.menu.popupmenu").removeClass("popupmenu")}function H(e){T.list.addClass("hidden"),T.sidebar.removeClass("hidden"),e&&T.sidebar.addClass("layout-sticky"),"small"!=g&&"phone"!=g||T.content.addClass("hidden"),P(),x.last_selected=T.sidebar[0]}function B(e){T.list.length||T.sidebar.length?(T.sidebar.addClass("hidden").removeClass("layout-sticky"),T.list.removeClass("hidden"),"small"!=g&&"phone"!=g||(x.last_selected=T.list[0]||T.sidebar[0],N(),rcmail.show_contentframe(!1),$("[data-list]",T.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&&T.list.children(".scroller").scrollTop(0),x.last_selected=T.list[0]):history.back(),P()}function F(e){e?("phone"==g&&($('<div id="menu-overlay" class="popover-overlay">').on("click",function(){F(!1)}).appendTo("body"),x.menu_initialized||(x.menu_initialized=!0,$("a",T.menu).on("click",function(e){"phone"==g&&F()})),T.menu.addClass("popover")),T.menu.removeClass("hidden")):($("#menu-overlay").remove(),T.menu.addClass("hidden").removeClass("popover"))}function Y(e){"loading"==e.type&&$(".iframe-loader:visible").length?rcmail.hide_message(e.object):(K(e.object,e.type,!0),$(e.object).attr("role","alert"))}function K(e,t,a){var n="ui alert",i=!$(e).is(".noicon");a&&i&&!$(e).is(".aligned-buttons")&&$(e).html($("<span>").html($(e).html())),(t={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+=" "+t,i&&$("<i>").attr("class","icon").prependTo(e)),$(e).addClass(n)}function V(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())?"removeClass":"addClass"]("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||(v[t]?v[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 G(o,a){if(w&&ve())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&&C[r]&&(C[r].transitioning=!0),t&&v[t]?v[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()}),ve()||n.css("max-height",Math.min(539,$(window).height()-30))}).on("shown.bs.popover",function(e){var t,a,n=ve(),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(C,function(e,t){$(t.target).data("level")==s&&e!=r&&X(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&&C[r]&&(C[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&&C[r]&&n.is(":visible")&&(C[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&&C[r]&&delete C[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),!ve()&&n.is(".toolbar")||n.attr("aria-hidden","true"),n.data("button",o),n.data("editable")&&n.on("click mousedown",function(e){e.stopPropagation()})}function J(t){n&&n>(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 Q(e){if(e&&e.name&&(!e.props||!1!==e.props.skinable)){if(w&&ve())return e.win||(e.win=window),parent.UI.menu_toggle(e);if("messagelistmenu"==e.name)!function(){var e=$("#listoptions-menu"),n=(e.width(),e.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 t=$('select[name="sort_col"]',n).val(),a=$('select[name="sort_ord"]',n).val(),e=$('select[name="mode"]',n).val();return rcmail.set_list_options([],t,a,"threads"==e?1:0),!0},{closeOnEscape:!0,minWidth:400})}();else if("menu-open"==e.event){var t,a,n=$("ul",e.obj).first(),i=e.props&&e.props.link?e.props.link:e.originalEvent.target;if(!n.length)return;$(i).is("span")&&(i=$(i).parents("a,li")[0]),e.name.match(/^drag/)&&(a=rcube_event.get_mouse_pos(e.originalEvent),i=$("<a>").css({position:"absolute",left:a.x,top:a.y,height:"1px",width:"1px",visibility:"hidden"}).appendTo(document.body).get(0)),a=$(i).data("popup-pos")||"right","folder-selector"==e.name?n.addClass("listing folderlist"):"addressbook-selector"==e.name||"contactgroup-selector"==e.name?n.addClass("listing contactlist"):n.hasClass("menu")&&n.addClass("listing"),"pagejump-selector"==e.name&&(n.addClass("simplelist"),e.obj.addClass("simplelist"),a="top"),C[e.name]&&X(e.name,e.originalEvent),(t=function(){if(C[e.name]&&C[e.name].transitioning)return setTimeout(t,50);$(i).data("popup")||($(i).data({event:rcube_event.is_keyboard(e.originalEvent)?"key":"mouse",popup:e.name,"popup-pos":a,"popup-trigger":"manual"}),G(i,e.win)),C[e.name]={target:i},setTimeout(function(){$(i).popover("show")},1)})()}else X(e.name,e.originalEvent);e.originalEvent.stopPropagation()}}function X(e,t){var a=function(e){var t;C[e]?t=C[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&&J(t))}function Z(e){$("[aria-owns="+e+"]").popover("dispose").data("popup",null)}function ee(e){var t="mail.show.envelope",a=$e(t),n=e?!a:a,i=n?"summary":"details",a=$("div.header-content");$("div.header-links").find("a.headers-details,a.headers-summary").removeClass().addClass("headers-"+i).text(rcmail.gettext(i)),a[n?"addClass":"removeClass"]("details-view"),e&&be(t,n)}function te(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 ae(e,t){var a=$("#composestatusbar"),n=a.find("a.button.icon."+e);t?n.length||$("<a>").attr("class","button icon "+e).on("click",function(){H()}).appendTo(a):n.remove()}function ne(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 ie(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 ne($("#attachmentmenu"),n,e)}).append($("<span>").attr("class","inner").text(t)),a.length?n.insertAfter(a):n.appendTo(e))}function oe(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 se(t){var e=$("#quotadisplay"),a=e.find(".bar"),n=t.total?t.percent:0;0<n&&n<10&&(n=10),(a=!a.length?$('<span class="bar"><span class="value"></span></span>').appendTo(e):a).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:ve()?"click":"hover"})}function re(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(/[^a-z]$/gi,"")}),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 le(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),k&&e.parent().addClass("ios-scroll"))}function ce(e){var t,a;(e=$(e)).is(".custom-control-input")||((a=e.attr("id"))||(a="icochk"+ ++x.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 de(e){var t=$(e.row).find("input[id^=icochk]");t.length&&(e="icochk"+ ++x.checkboxes,t.attr("id",e).next("label").attr("for",e))}function ue(u){var p,t,m;bw.iphone||bw.ipad||(u=$(u)).is(".pretty-select")||(p="select"+u.attr("id")+u.attr("name"),t=function(){if(u[0].ownerDocument.defaultView.$(".select-menu .listing").data("ident")==p)return!0},m=function(){var e=t();return u.popover("dispose").focus(),!e},u.addClass("pretty-select custom-select form-control").on("mousedown keydown",function(e){if(!(u=$(e.target)).prop("disabled"))return 9==e.which?(m(),!0):27==e.which||"mousedown"==e.type&&t()?m():(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?(function(a){var s,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();ve()||(t*=.5),J(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("&nbsp;"),l.push("")),n.push($("<li>").append(t))});var 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=m();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 m();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(),m()}));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")}(e),n=(new Date).getTime(),!1):void 0)}))}function pe(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=pe(a,"",(new Date).getTime(),n,s.parent());$("input",t).focus()}else if((8==e.which||46==e.which)&&""==s.val()){e=s.parent();if(1<a.children().length)return(e.prev().length?e.prev():e.next()).children("input").focus(),e.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 me(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=$e(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"),be(s,i.width())})}),e&&o(e))}function he(e,t,a,n){function i(e){$(e).css({color:$(document.body).css("color"),backgroundColor:$(document.body).css("background-color")})}var o="dark"==b&&/_task=mail/.test(e)&&/_action=viewsource/.test(e);if(!ve()||!0===n){/_task=mail/.test(e)&&/_action=get/.test(e)&&(t=!0);var s=x.open_window.call(rcmail,e,t,a);return o&&$(s).on("load",function(){i(s.document.body)}),s}e=rcmail.add_url(e,"_framed",1),e=rcmail.add_url(e,"_extwin",1);var r,t="",a={cancel_button:"close",width:768,height:768},l=$("<iframe>").attr({id:"windowframe",src:e});return/_action=([a-z_]+)/.test(e)&&(r=rcmail.labels[RegExp.$1])&&(t=r),/_frame=1/.test(e)&&(a.dialogClass="no-titlebar"),o&&l.on("load",function(){i(l[0].contentWindow.document.body)}),rcmail.simple_dialog(l,t,null,a),!0}function fe(){if(w){var e=$(parent.document.documentElement);return{mode:e[0].className.match(/layout-([a-z]+)/)?RegExp.$1:g,touch:e.is(".touch")}}return{mode:g,touch:_}}function ve(){var e=fe();return"phone"==e.mode||"small"==e.mode}function ge(){return fe().touch}function $e(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 be(e,t){a[e]=t,rcmail.local_storage_set_item("prefs.elastic",a)||rcmail.set_cookie(e,t,!1)}this.register_content_buttons=function(e){{var t;x.frame_nav&&e&&e.length&&(t=x.frame_nav.children(".buttons"),y=[],$.each(e,function(){this.data("target")&&y.push(this.data("target"))}),t.html("").append(e))}},this.menu_hide=X,this.menu_toggle=Q,this.menu_destroy=Z,this.popup_init=G,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=ee,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(e){var t,a="*",n=$('input[name="s_mods[]"]',e),i=$("#s_scope",e),o=$("#s_interval",e),s=rcmail.env.mailbox,r=rcmail.env.search_mods,l=rcmail.env.search_scope||"base";$(e).data("initialized")||($(e).data("initialized",!0),n.length&&(n.on("change",function(){!function(e,t){var a,n,i={},o=$('input[name="s_mods[]"]',e),s=rcmail.env.task,r=rcmail.env.search_mods||{},l=rcmail.env.mailbox;"mail"==s?(r[l]||(r[l]=rcube_clone_object(r["*"])),n=r[l],a="text",i={sender:["from","replyto","followupto"],recipient:["to","cc","bcc"]}):(n=r,a="*");t.checked?n[t.value]=1:delete n[t.value];t.value==a?o.not(t).each(function(){this.checked=!0,t.checked?(this.disabled=!0,delete n[this.value]):(this.disabled=!1,this.value in i||(n[this.value]=1))}):t.value in i?(delete n[t.value],o.filter(function(){return-1!=$.inArray(this.value,i[t.value])}).each(function(){t.checked?(this.checked=!0,n[this.value]=1):(this.checked=!1,delete n[this.value])})):i.sender&&te(e);rcmail.set_searchmods(n)}(e,this)}),rcmail.addEventListener("beforesearch",function(){rcmail.env.search_scope=i.val(),rcmail.env.search_interval=o.val()})),$(e).find(".proplist > li > a.dropdown").on("click",function(){var e=$(this).next();e[e.is(".d-none")?"removeClass":"addClass"]("d-none")}));if(i.val(l),r)if("mail"==rcmail.env.task&&(r=r[s]||r["*"],a="text"),r[a])n.map(function(){this.checked=!0,this.disabled=this.value!=a});else for(t in n.prop("disabled",!1).prop("checked",!1),r)n.filter('[value="'+t+'"]').prop("checked",!0);te(e)},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=ae,this.attachmentmenu=ne,this.mailtomenu=oe,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(){if(t.action)return t.action(),void 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=B,this.show_sidebar=H,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){pe($(".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){pe(n,t,0,a)})},this.form_errors=function(e){$.each(e,function(){var e=$("#"+this[0]).addClass("is-invalid");if("list"==e.data("type"))return e.data("error-msg",this[2]),void $("#"+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=V,this.pretty_checkbox=ce,this.pretty_select=ue,this.datepicker_init=function(e){window.MutationObserver&&$(e).not("[data-observed]").each(function(){var n,i=!0,o=w?parent:window;$(this).attr("data-observed","1"),w&&($(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(),w&&$.datepicker._hideDatepicker()}),i=a):t.addedNodes.length&&(o.UI.bootstrap_style(t.target),w&&(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=O,this.toggle_list_selection=function(e,t){$(e).is(".active")&&be("list-selection",$("#"+t).toggleClass("withselection").is(".withselection"))},this.get_screen_mode=function(){return g},this.is_mobile=ve,this.is_touch=ge,I(),function(){(function(){var e,t,a,n,i;"print"!=rcmail.env.action&&(e=rcmail.get_cookie("colorMode"),t=window.matchMedia("(prefers-color-scheme: dark)"),a=function(){rcmail.set_cookie("colorMode","",new Date)},n=function(){try{$(this.contentWindow.document).find("html")["dark"==b?"addClass":"removeClass"]("dark-mode")}catch(e){}},!(i=function(){"dark"==b?($("#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")),W(g),$("iframe").each(n)})!==rcmail.env.dark_mode_support?($("#taskmenu a.theme").on("click",function(){b=$(this).is(".dark")?"dark":"light",i(),rcmail.set_cookie("colorMode",b,!1)}),t.addListener(function(e){b=e.matches?"dark":"light",i(),a()}),e?b=e:t.matches&&(b="dark"),i(),$("iframe").on("load",n)):"dark"==e&&(a(),$("iframe").each(n)))})(),x.last_selected=$("#layout > div.selected")[0],!x.last_selected&&T.content.length&&$.each(["sidebar","list","content"],function(){if(T[this].length)return x.last_selected=T[this][0],T[this].addClass("selected"),!1});{var n;$(window).on("resize",function(){clearTimeout(x.resize_timeout),x.resize_timeout=setTimeout(function(){R()},25)}),x.open_window=rcmail.open_window,rcmail.open_window=he,rcmail.addEventListener("message",Y).addEventListener("menu-open",Q).addEventListener("menu-close",Q).addEventListener("editor-init",S).addEventListener("autocomplete_create",A).addEventListener("googiespell_create",A).addEventListener("setquota",se).addEventListener("enable-command",D).addEventListener("destroy-entity-selector",function(e){Z(e.name)}).addEventListener("clonerow",de).addEventListener("init",M),(T.list.length||T.content.length)&&ve()&&(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(j(e,!1,!1,!0))}),n.length&&$('<div class="floating-action-buttons">').append(n).appendTo(T.list.length?T.list:T.content))}T.sidebar.length&&me(T.sidebar);T.list.length&&me(T.list)}(),O(),x.got_smart_toolbar||(x.got_smart_toolbar=!0,i=[],o=[],s=fe(),r=function(e,t,a){var n=$('<li role="menuitem">');(e=a?j($(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)},T.content.find(".header > .menu").each(function(){var e=$(this);e.children().each(function(){r(this,i)}),e.remove()}),T.list.find(".header > .menu").each(function(){var e=$(this);t=e.next(),e.children().each(function(){"large"!=s.mode&&$(this).data("popup-pos","right"),r(this,i,!0),r(this,o)}),e.remove()}),$('ul[data-menu="toolbar-small"] > li > a').each(function(){var e=$(this).clone();e.attr("id",this.id+"_clone"),i.push($('<li role="menuitem">').addClass("hidden-big").append(e))}),o.length&&(l=T.list.children(".header"),c={class:"menu toolbar popupmenu listing iconized",id:"toolbar-list-menu"},d=$('<a class="button icon toolbar-list-button" href="#list-menu">').attr({"data-popup":"toolbar-list-menu"}),e=$("<ul>").attr(c).data("popup-parent",l).append(o),t.length?e.insertBefore(t):l.append(e),l.append(d)),i.length&&(l=T.content.children(".header"),c={class:"menu toolbar popupmenu listing iconized",id:"toolbar-menu"},d=$('<a class="button icon toolbar-menu-button" href="#menu">').attr({"data-popup":"toolbar-menu"}),l.append($("<ul>").attr(c).data("popup-parent",l).append(i)).append(d),T.list.find("a.toolbar-menu-button").click(function(e){e.stopPropagation(),d.click()}))),T.list.length&&(u=x.last_selected,p=function(e){"string"==typeof e&&e.length||(e=$("h1.voice").text()||$("title").text()||""),T.content.find(".header > .header-title").text(e)},m=function(e,t,a,n){var i,o,s,r,l,c;ve()&&x.frame_nav&&(i=e,(e=t).match(/_action=(create|add)/)||e.match(/_nav=hide/)?$(x.frame_nav).addClass("hide-nav-buttons"):(t=$("[data-list]",T.list).data("list"))&&(o=rcmail[t])?($(x.frame_nav).removeClass("hide-nav-buttons hidden"),(e=o.get_single_selection())&&(o.rows&&o.rows[e]&&!o.rows[e].expanded?o.expand_row(i,e):o.get_node&&(c=o.get_node(e))&&c.collapsed&&o.expand(e)),l=$("#"+rcmail.env.contentframe),c=$("a.button.next",x.frame_nav).off("click").addClass("disabled"),e=$("a.button.prev",x.frame_nav).off("click").addClass("disabled"),((r=o.get_next())||rcmail.env.current_page<rcmail.env.pagecount)&&c.removeClass("disabled").on("click",function(){x.content_lock=!0,le(l),r?o.select(r):(rcmail.env.list_uid="FIRST",rcmail.command("nextpage"))}),((s=o.get_prev())&&("*"!=s||"subscription_list"!=t)||1<rcmail.env.current_page)&&e.removeClass("disabled").on("click",function(){x.content_lock=!0,le(l),s?o.select(s):(rcmail.env.list_uid="LAST",rcmail.command("previouspage"))})):$(x.frame_nav).is(".hide-nav-buttons")&&!$(".buttons",x.frame_nav).children().length&&$(x.frame_nav).addClass("hidden")),a&&!T.content.is(":visible")?x.last_selected=T.content[0]:a||x.last_selected==u||x.content_lock||(x.last_selected=u),N(),p(n&&a?n:null),x.content_lock=!1},h=function(e){"large"!=g&&!x.content_lock&&e.force&&B(),x.content_lock=!1,e.title&&$(".header > .header-title",T.list).text(e.title)},f=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:""),h(t)},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){}m(e,a,n)}),rcmail.addEventListener("afterlist",f).addEventListener("afterlistgroup",f).addEventListener("afterlistsearch",f).addEventListener("show-list",function(e){e.force=!0,h(e)}).addEventListener("show-content",function(e){e.obj&&!$(e.obj).is("iframe")&&($(e.scrollElement||e.obj).scrollTop(0),ve()&&le(e.obj)),m(e.event||new Event,"_action="+(e.mode||"edit"),!0,e.title)})),$("[data-popup]").each(function(){G(this)}),$(document).on("click",J),rcube_webmail.set_iframe_events({mousedown:J,touchstart:J}),function(){var e,t,a=[];$.ui&&$.widget("ui.dialog",$.ui.dialog,{open:function(){return $(this.element).is(".iframe")&&(this.options.width=Math.max(576,this.options.width)),this._super(),function(e){var t=$(e.uiDialog),a=t.width(),n=t.height(),i=$(window).width(),o=$(window).height();i<=480?t.css({width:"100%",height:"100%"}):(o<n&&t.css("height","100%"),i<a&&t.css("width","100%"));$(document).click(),le($("div.popup > iframe",t)),O(e.uiDialog)}(this),this},close:function(){return this._super(),$(".select-menu:visible").remove(),this}}),L.menu.on("click",function(){return F(!0),!1}),L.back_sidebar.on("click",function(){return H(),!1}),L.back_list.on("click",function(){return B(),!1}),L.back_content.on("click",function(){return function(e){T.list.addClass("hidden"),T.sidebar.addClass("hidden"),T.content.removeClass("hidden"),e&&T.sidebar.removeClass("layout-sticky");P(),x.last_selected=T.content[0]}(!0),!1}),$(".searchbar").each(function(){V(this)}),!w||rcmail.env.extwin||parent.$(".ui-dialog:visible").length?w||(e=(e=T.content.find(".boxtitle").first().detach().text())||$("h1.voice").first().text())&&T.content.find(".header > .header-title").text(e):(e=$("h1.voice").first().text())&&parent.$("#layout-content > .header > .header-title:not(.constant)").text(e);w||!T.content.length||T.content.is(".no-navbar")||T.content.children(".frame-content").length||(x.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(T.content));$("a[data-content-button]").each(function(){a.push(j($(this)))}),$(".formbuttons").filter(function(){return!$(this).parent(".searchoptions").length}).find("button").each(function(){var e=$(this);(w||e.parents("#layout-content").length)&&(e.is(".cancel")?e.addClass("hidden"):a.push(j(e)))}),(w?parent.UI:v).register_content_buttons(a),(t=rcmail.gui_objects.messageform)&&(t=$('form[name="'+t+'"]'),$("#_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(t);$(this).attr("tabindex",2).on("change",function(){e.val("checkbox"!=this.type||this.checked?$(this).val():"")}).change()}));$("[data-recipient-input]").each(function(){function o(e){return e=re(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,s,r,t,l,c;e=this,t="",l=function(){$(e).val(s.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'"':if(0<t&&t<i-1){n+='"';break}n+='<span class="quotes">'+a+"</span>";break;case"\\":n+='<span class="quotes">'+a+"</span>","\\"==e.charAt(t+1)&&(n+=a,t++);break;case"<":n+="&lt;";break;case">":n+="&gt;";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=re(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,i=this.value;!1!==a&&("paste"==e.type?(a=(e.originalEvent.clipboardData||window.clipboardData).getData("text")||"",i=i.substring(0,this.selectionStart)+a+i.substring(this.selectionEnd),e.preventDefault()):t&&(n=s.find("li.recipient").last()).length&&-1<this.value.indexOf(n.text().replace(/[ ,]+$/,""))&&n.remove(),o(i))}).on("keydown",function(e){return 8!=e.keyCode||r.val().length?!((" "==e.key||","==e.key||";"==e.key||"Enter"==e.key&&!rcmail.ksearch_visible())&&o())&&void 0:(s.children("li.recipient").last().remove(),l(),!1)}).on("blur",function(){s.removeClass("focus")}).on("focus mousedown",function(){s.addClass("focus")}),s=$("<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=s.text();s.find(".recipient").remove(),o(a),t.sender&&t.sender.find("input").change()}}),$(e).css({position:"absolute",opacity:0,left:"-5000px",width:"10px"}).attr("tabindex",-1).after(s).on("focus",function(e){r.focus(),e.preventDefault()}).on("change",function(){$("li.recipient",s).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(){!function(e){var t,a=!1,n=$(e),i=n.parent(),o=n.is("[readonly],[disabled]"),s=$('<a class="mce-i-html" href="#" tabindex="-1"></a>').attr({title:rcmail.gettext("htmltoggle"),disabled:o}).on("click",function(e){!o&&rcmail.command("toggle-editor",{id:n.attr("id"),html:!0},"",e.originalEvent)&&i.addClass("ishtml")}).on("keydown",function(e){if(9==e.which)return n.focus(),!1}),r=$('<div class="editor-toolbar">').append(s);i.is("td")?(t=$('input[type="checkbox"]',i.parent().next()),a=!0):t=n.next("select.hidden");(function(i){function o(){if(!i.scrollHeight)return setTimeout(o,250);var e,t,a,n;s||(s=parseInt($(i).css("padding-top"))+parseInt($(i).css("padding-bottom"))+2,r=$(i).height()),i.scrollHeight-s<=r||(t=0,$(i).parents().each(function(){if(0<this.scrollTop)return t=(e=this).scrollTop,!1}),a=$(i).outerHeight(),$(i).outerHeight(0),n=Math.max(r,i.scrollHeight),$(i).outerHeight(a),n!==a&&$(i).height(n),t&&(e.scrollTop=t))}var s,r;$(i).on("input",o).trigger("input")})(e),1==t.length&&(i.addClass("html-editor"),n.after(r).data("control",t).on("keydown",function(e){e.altKey&&121==e.which&&s.focus()}),a&&(t.parents("tr").first().hide(),i.prev().hide(),i.addClass("col-sm-12")))}(this)}),$("#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=z(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=z(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(){ce(this)})}),w&&$(".formcontent").each(function(){$(this).next(".formbuttons").length&&$(this).parent().addClass("formcontainer")});$("#attachment-list + a.zipdownload").appendTo(".header-links"),(k=$("html").is(".ipad,.iphone"))&&$(".iframe-wrapper, .scroller").addClass("ios-scroll");$("html").filter(".ipad,.iphone,.webkit.mobile,.webkit.tablet").addClass("webkit-scroller").length&&$(T.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)})})}(),R()}var rcmail,rcube_webmail,bw;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 __newInst,UI=new rcube_elastic_ui;$&&$.datepicker&&(__newInst=$.datepicker._newInst,$.extend($.datepicker,{_newInst:function(e,t){t=__newInst.call(this,e,t);return t.inline||UI.datepicker_init(t.dpDiv),t}}));