Mercurial > hg > rc1
view plugins/managesieve/managesieve.min.js @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
line wrap: on
line source
/** * (Manage)Sieve Filters plugin * * @licstart The following is the entire license notice for the * JavaScript code in this file. * * Copyright (c) 2012-2014, The Roundcube Dev Team * * The JavaScript code in this page is free software: you can redistribute it * and/or modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * * @licend The above is the entire license notice * for the JavaScript code in this file. */ window.rcmail&&rcmail.addEventListener("init",function(a){"mail"==rcmail.env.task&&("show"!=rcmail.env.action?rcmail.env.message_commands.push("managesieve-create"):rcmail.enable_command("managesieve-create",!0));"mail"!=rcmail.env.task&&!rcmail.env.action.startsWith("plugin.managesieve")||rcmail.env.framed||(rcmail.env.ms_tip_layer=$('<div id="managesieve-tip" class="popupmenu"></div>'),rcmail.env.ms_tip_layer.appendTo(document.body));rcmail.register_command("plugin.managesieve-save",function(){rcmail.managesieve_save()}); rcmail.register_command("plugin.managesieve-act",function(){rcmail.managesieve_act()});rcmail.register_command("plugin.managesieve-add",function(){rcmail.managesieve_add()});rcmail.register_command("plugin.managesieve-del",function(){rcmail.managesieve_del()});rcmail.register_command("plugin.managesieve-move",function(){rcmail.managesieve_move()});rcmail.register_command("plugin.managesieve-setadd",function(){rcmail.managesieve_setadd()});rcmail.register_command("plugin.managesieve-setdel",function(){rcmail.managesieve_setdel()}); rcmail.register_command("plugin.managesieve-setact",function(){rcmail.managesieve_setact()});rcmail.register_command("plugin.managesieve-setget",function(){rcmail.managesieve_setget()});rcmail.register_command("plugin.managesieve-seteditraw",function(){rcmail.managesieve_seteditraw()});rcmail.env.action.startsWith("plugin.managesieve")&&(rcmail.gui_objects.sieveform?(rcmail.enable_command("plugin.managesieve-save",!0),sieve_form_init()):rcmail.gui_objects.sievesetrawform?(rcmail.enable_command("plugin.managesieve-save", !0),sieve_raw_editor_init()):rcmail.enable_command("plugin.managesieve-add","plugin.managesieve-setadd",!rcmail.env.sieveconnerror),a=rcmail.env.currentset,rcmail.gui_objects.filterslist&&(rcmail.filters_list=new rcube_list_widget(rcmail.gui_objects.filterslist,{multiselect:!1,draggable:!0,keyboard:!0}),rcmail.filters_list.addEventListener("select",function(a){rcmail.managesieve_select(a)}).addEventListener("dragstart",function(a){rcmail.managesieve_dragstart(a)}).addEventListener("dragend",function(a){rcmail.managesieve_dragend(a)}).addEventListener("initrow", function(a){a.obj.onmouseover=function(){rcmail.managesieve_focus_filter(a)};a.obj.onmouseout=function(){rcmail.managesieve_unfocus_filter(a)}}).init()),rcmail.gui_objects.filtersetslist&&(rcmail.filtersets_list=new rcube_list_widget(rcmail.gui_objects.filtersetslist,{multiselect:!1,draggable:!1,keyboard:!0}),rcmail.filtersets_list.init().focus(),null!=a&&(a=rcmail.managesieve_setid(a),rcmail.filtersets_list.select(a)),rcmail.filtersets_list.addEventListener("select",function(a){rcmail.managesieve_setselect(a)}), a=rcmail.filtersets_list.rowcount,rcmail.enable_command("plugin.managesieve-set",!0),rcmail.enable_command("plugin.managesieve-setact","plugin.managesieve-setget",0<a),rcmail.enable_command("plugin.managesieve-setdel",1<a),rcmail.enable_command("plugin.managesieve-seteditraw",0<a&&rcmail.env.raw_sieve_editor),$("tr",rcmail.gui_objects.filtersetslist).each(function(a,c){rcmail.managesieve_fixdragend(c)})));rcmail.gui_objects.sieveform&&rcmail.env.rule_disabled&&$("#disabled").attr("checked",!0)}); rcube_webmail.prototype.managesieve_add=function(){this.load_managesieveframe("",!0)};rcube_webmail.prototype.managesieve_del=function(){var a=this.filters_list.get_single_selection();if(confirm(this.get_label("managesieve.filterdeleteconfirm"))){var b=this.set_busy(!0,"loading");this.http_post("plugin.managesieve-action","_act=delete&_fid="+this.filters_list.rows[a].uid,b)}}; rcube_webmail.prototype.managesieve_act=function(){var a=this.filters_list.get_single_selection(),b=this.set_busy(!0,"loading");this.http_post("plugin.managesieve-action","_act=act&_fid="+this.filters_list.rows[a].uid,b)};rcube_webmail.prototype.managesieve_select=function(a){var b=a.get_single_selection();null!=b&&(b=a.rows[b].uid,this.load_managesieveframe("_fid="+b));this.enable_command("plugin.managesieve-act","plugin.managesieve-del","undefined"!=typeof b&&null!=b)}; rcube_webmail.prototype.managesieve_setselect=function(a){this.show_contentframe(!1);this.filters_list.clear(!0);this.enable_command("plugin.managesieve-setdel",1<a.rowcount);this.enable_command("plugin.managesieve-setact","plugin.managesieve-setget",0<a.rowcount);this.enable_command("plugin.managesieve-seteditraw",0<a.rowcount&&this.env.raw_sieve_editor);a=a.get_single_selection();null!=a&&this.managesieve_list(this.env.filtersets[a])}; rcube_webmail.prototype.managesieve_rowid=function(a){var b,c=this.filters_list.rows;for(b in c)if(null!=c[b]&&c[b].uid==a)return b};rcube_webmail.prototype.managesieve_setid=function(a){for(var b in this.env.filtersets)if(this.env.filtersets[b]==a)return b};rcube_webmail.prototype.managesieve_list=function(a){var b=this.set_busy(!0,"loading");this.http_post("plugin.managesieve-action","_act=list&_set="+urlencode(a),b)}; rcube_webmail.prototype.managesieve_setget=function(){var a=this.filtersets_list.get_single_selection();this.goto_url("plugin.managesieve-action",{_act:"setget",_set:this.env.filtersets[a]},!1,!0)};rcube_webmail.prototype.managesieve_setact=function(){var a=this.filtersets_list.get_single_selection(),b=this.set_busy(!0,"loading"),c=this.env.filtersets[a];a=$("#rcmrow"+a).hasClass("disabled")?"setact":"deact";this.http_post("plugin.managesieve-action","_act="+a+"&_set="+urlencode(c),b)}; rcube_webmail.prototype.managesieve_setdel=function(){if(!confirm(this.get_label("managesieve.setdeleteconfirm")))return!1;var a=this.filtersets_list.get_single_selection(),b=this.set_busy(!0,"loading");this.http_post("plugin.managesieve-action","_act=setdel&_set="+urlencode(this.env.filtersets[a]),b)};rcube_webmail.prototype.managesieve_seteditraw=function(){var a=this.filtersets_list.get_single_selection();this.load_managesieveframe("_seteditraw=1&_set="+urlencode(this.env.filtersets[a]),!0)}; rcube_webmail.prototype.managesieve_setadd=function(){this.load_managesieveframe("_newset=1",!0)}; rcube_webmail.prototype.managesieve_updatelist=function(a,b){this.set_busy(!0);switch(a){case "del":var c=b.id;a=this.filters_list;a.remove_row(this.managesieve_rowid(b.id));this.show_contentframe(!1);this.reset_filters_list();$("tr",this.filters_list.list).each(function(){if("none"==this.style.display)$(this).detach();else{var a=this.id.substr(6);$(this).off();a>c&&(this.uid=a-1,$(this).attr("id","rcmrow"+this.uid))}});a.init();break;case "update":var d=$("#rcmrow"+this.managesieve_rowid(b.id)); b.name&&$("td",d).text(b.name);b.disabled?d.addClass("disabled"):d.removeClass("disabled");$("#disabled",$("iframe").contents()).prop("checked",b.disabled);break;case "add":a=this.filters_list;d=$('<tr><td class="name"></td></tr>');$("td",d).text(b.name);d.attr("id","rcmrow"+b.id);b.disabled&&d.addClass("disabled");a.insert_row(d.get(0));a.highlight_row(b.id);this.enable_command("plugin.managesieve-del","plugin.managesieve-act",!0);break;case "list":a=this.filters_list;b.clear&&a.clear();for(d in b.list){var e= b.list[d];var g=document.createElement("TR");var l=document.createElement("TD");$(l).text(e.name);l.className="name";g.id="rcmrow"+e.id;e["class"]&&(g.className=e["class"]);g.appendChild(l);a.insert_row(g)}b.set?a.highlight_row(b.set):this.enable_command("plugin.managesieve-del","plugin.managesieve-act",!1);break;case "setact":c=this.managesieve_setid(b.name);d=$("#rcmrow"+c);b.active?(b.all&&$("tr",this.gui_objects.filtersetslist).addClass("disabled"),d.removeClass("disabled")):d.addClass("disabled"); break;case "setdel":c=this.managesieve_setid(b.name);this.filtersets_list.remove_row(c);this.filters_list.clear();this.show_contentframe(!1);this.enable_command("plugin.managesieve-setdel","plugin.managesieve-setact","plugin.managesieve-setget",!1);delete this.env.filtersets[c];break;case "setadd":c="S"+(new Date).getTime();a=this.filtersets_list;d=$('<tr class="disabled"><td class="name"></td></tr>');$("td",d).text(b.name);d.attr("id","rcmrow"+c);this.env.filtersets[c]=b.name;a.insert_row(d.get(0)); b.index!=a.rowcount-1&&(d.detach(),b=$("tr:visible",a.list).get(b.index),d.insertBefore(b));a.select(c);this.managesieve_fixdragend(d);break;case "refresh":this.reset_filters_list(!0)}this.set_busy(!1)};rcube_webmail.prototype.reset_filters_list=function(a){this.filters_list.clear_selection();this.enable_command("plugin.managesieve-act","plugin.managesieve-del",!1);a&&(a=this.filtersets_list.get_single_selection(),this.filters_list.clear(!0),this.managesieve_list(this.env.filtersets[a]))}; rcube_webmail.prototype.load_managesieveframe=function(a,b){b&&this.reset_filters_list();this.env.contentframe&&window.frames&&window.frames[this.env.contentframe]&&(b=this.set_busy(!0,"loading"),target=window.frames[this.env.contentframe],target.location.href=this.env.comm_path+"&_action=plugin.managesieve-action&_framed=1&_unlock="+b+(a?"&"+a:""))};rcube_webmail.prototype.managesieve_dragstart=function(a){a=this.filters_list.get_single_selection();this.drag_active=!0;this.drag_filter=a}; rcube_webmail.prototype.managesieve_dragend=function(a){this.drag_active&&(this.drag_filter_target&&(a=this.set_busy(!0,"loading"),this.show_contentframe(!1),this.http_post("plugin.managesieve-action","_act=move&_fid="+this.drag_filter+"&_to="+this.drag_filter_target,a)),this.drag_active=!1)};rcube_webmail.prototype.managesieve_fixdragend=function(a){var b=this;$(a).on("mouseup"+(bw.iphone||bw.ipad?" touchend":""),function(a){b.drag_active&&b.filters_list.drag_mouse_up(a)})}; rcube_webmail.prototype.managesieve_focus_filter=function(a){var b=a.id.replace(/^rcmrow/,"");this.drag_active&&b!=this.drag_filter&&(this.drag_filter_target=b,$(a.obj).addClass(b<this.drag_filter?"filtermoveup":"filtermovedown"))};rcube_webmail.prototype.managesieve_unfocus_filter=function(a){this.drag_active&&($(a.obj).removeClass("filtermoveup filtermovedown"),this.drag_filter_target=null)}; rcube_webmail.prototype.managesieve_save=function(){if("plugin.managesieve-vacation"==this.env.action){var a=$(this.gui_objects.sieveform).serialize();this.http_post("plugin.managesieve-vacation",a,this.display_message(this.get_label("managesieve.vacation.saving"),"loading"))}else this.gui_objects.sieveform?(parent.rcmail&&parent.rcmail.filters_list&&"filtersetform"!=this.gui_objects.sieveform.name&&(a=parent.rcmail.filters_list.get_single_selection(),null!=a&&(this.gui_objects.sieveform.elements._fid.value= parent.rcmail.filters_list.rows[a].uid)),this.gui_objects.sieveform.submit()):this.gui_objects.sievesetrawform&&this.gui_objects.sievesetrawform.submit()};rcube_webmail.prototype.managesieve_ruleadd=function(a){this.http_post("plugin.managesieve-action","_act=ruleadd&_rid="+a)}; rcube_webmail.prototype.managesieve_rulefill=function(a,b,c){if(""!=a){var d=document.getElementById("rules"),e=document.createElement("div");this.managesieve_insertrow(d,e,c);e.setAttribute("id","rulerow"+b);e.className="rulerow";e.innerHTML=a;$('textarea[data-type="list"]',e).each(function(){smart_field_init(this)});this.managesieve_formbuttons(d)}}; rcube_webmail.prototype.managesieve_ruledel=function(a){!$("#ruledel"+a).hasClass("disabled")&&confirm(this.get_label("managesieve.ruledeleteconfirm"))&&(a=document.getElementById("rulerow"+a),a.parentNode.removeChild(a),this.managesieve_formbuttons(document.getElementById("rules")))};rcube_webmail.prototype.managesieve_actionadd=function(a){this.http_post("plugin.managesieve-action","_act=actionadd&_aid="+a)}; rcube_webmail.prototype.managesieve_actionfill=function(a,b,c){if(""!=a){var d=document.getElementById("actions"),e=document.createElement("div");this.managesieve_insertrow(d,e,c);e.className="actionrow";e.setAttribute("id","actionrow"+b);e.innerHTML=a;$('textarea[data-type="list"]',e).each(function(){smart_field_init(this)});this.managesieve_formbuttons(d)}}; rcube_webmail.prototype.managesieve_actiondel=function(a){!$("#actiondel"+a).hasClass("disabled")&&confirm(this.get_label("managesieve.actiondeleteconfirm"))&&(a=document.getElementById("actionrow"+a),a.parentNode.removeChild(a),this.managesieve_formbuttons(document.getElementById("actions")))}; rcube_webmail.prototype.managesieve_insertrow=function(a,b,c){for(var d=0;d<a.childNodes.length&&a.childNodes[d].id!=("rules"==a.id?"rulerow":"actionrow")+c;d++);a.childNodes[d+1]?a.insertBefore(b,a.childNodes[d+1]):a.appendChild(b)}; rcube_webmail.prototype.managesieve_formbuttons=function(a){var b,c=[];for(b=0;b<a.childNodes.length;b++)"rules"==a.id&&a.childNodes[b].id?/rulerow/.test(a.childNodes[b].id)&&c.push("ruledel"+a.childNodes[b].id.replace(/rulerow/,"")):a.childNodes[b].id&&/actionrow/.test(a.childNodes[b].id)&&c.push("actiondel"+a.childNodes[b].id.replace(/actionrow/,""));for(b=0;b<c.length;b++)a=document.getElementById(c[b]),0<b||1<c.length?$(a).removeClass("disabled"):$(a).addClass("disabled")}; rcube_webmail.prototype.managesieve_vacation_addresses=function(a){var b=this.set_busy(!0,"loading");this.http_post("plugin.managesieve-action",{_act:"addresses",_aid:a},b)};rcube_webmail.prototype.managesieve_vacation_addresses_update=function(a,b){a=$("#vacation_addresses,#action_addresses"+(a||""));smart_field_reset(a.get(0),b)}; function rule_header_select(a){var b=document.getElementById("header"+a),c=document.getElementById("rule_size"+a),d=document.getElementById("rule_message"+a),e=document.getElementById("rule_op"+a),g=document.getElementById("custom_header"+a+"_list"),l=document.getElementById("custom_var"+a+"_list"),k=document.getElementById("rule_mod"+a),m=document.getElementById("rule_trans"+a),q=document.getElementById("rule_comp"+a),r=document.getElementById("rule_date_part"+a),t=document.getElementById("rule_date_header_div"+ a),n=$("#rule_op"+a),f=b.value,p=[e,g,l,k,m,q,c];"size"==f?(d&&p.push(d),$.each(p,function(){this.style.display="none"}),c.style.display="inline"):"message"==f&&d?($.each(p,function(){this.style.display="none"}),d.style.display="inline"):(g.style.display="..."!=f?"none":"inline-block",l.style.display="string"!=f?"none":"inline-block",c.style.display="none",e.style.display="inline",q.style.display="",k.style.display="body"==f||"currentdate"==f||"date"==f||"string"==f?"none":"block",m.style.display= "body"==f?"block":"none",d&&(d.style.display="message"==f?"block":"none"));r&&(r.style.display="currentdate"==f||"date"==f?"inline":"none");t&&(t.style.display="date"==f?"":"none");$('[value="exists"],[value="notexists"]',n).prop("disabled","string"==f);n.val()||n.val("contains");rule_op_select(e,a,f);rule_mod_select(a,f);b.style.width="..."==f?"40px":""} function rule_op_select(a,b,c){var d=document.getElementById("rule_target"+b+"_list");c||(c=document.getElementById("header"+b).value);d.style.display=a.value.match(/^(exists|notexists)$/)||c.match(/^(size|message)$/)?"none":"inline-block"}function rule_trans_select(a){var b=document.getElementById("rule_trans_op"+a);document.getElementById("rule_trans_type"+a).style.display="content"!=b.value?"none":"inline"} function rule_mod_select(a,b){var c=document.getElementById("rule_mod_op"+a),d=document.getElementById("rule_mod_type"+a),e=document.getElementById("rule_duplicate_div"+a),g=document.getElementById("rule_index_div"+a);b||(b=document.getElementById("header"+a).value);d.style.display="address"!=c.value&&"envelope"!=c.value?"none":"inline";g&&(g.style.display=b.match(/^(body|currentdate|size|message|string)$/)||"envelope"==c.value?"none":"");e&&(e.style.display="message"==b?"":"none")} function rule_join_radio(a){$("#rules").css("display","any"==a?"none":"block")}function rule_adv_switch(a,b){b=$(b);var c=b.hasClass("hide");a=$("#rule_advanced"+a);c?(a.hide(),b.removeClass("hide").addClass("show")):(a.show(),b.removeClass("show").addClass("hide"))} function action_type_select(a){var b=document.getElementById("action_type"+a).value,c={};a={mailbox:document.getElementById("action_mailbox"+a),target:document.getElementById("redirect_target"+a),target_area:document.getElementById("action_target_area"+a),flags:document.getElementById("action_flags"+a),vacation:document.getElementById("action_vacation"+a),set:document.getElementById("action_set"+a),notify:document.getElementById("action_notify"+a)};"fileinto"==b||"fileinto_copy"==b?c.mailbox=1:"redirect"== b||"redirect_copy"==b?c.target=1:b.match(/^reject|ereject$/)?c.target_area=1:b.match(/^(add|set|remove)flag$/)?c.flags=1:"vacation"==b?c.vacation=1:"set"==b?c.set=1:"notify"==b&&(c.notify=1);for(var d in a)a[d].style.display=c[d]?"inline":"none"}function vacation_action_select(){var a=$("#vacation_action").val();$("#action_target_span")["discard"==a||"keep"==a?"hide":"show"]()} function smart_field_init(a){var b=a.id+"_list",c=$('<span class="listarea"></span>'),d=a.value?a.value.split("\n"):[""];$("#"+b).length||($.each(d,function(b,d){c.append(smart_field_row(d,a.name,b,$(a).data("size")))}),c.attr("id",b),a=$(a),a.attr("disabled")?c.hide():a.prop("disabled",!0),a.after(c),a.hasClass("error")&&(c.addClass("error"),rcmail.managesieve_tip_register([[b,a.data("tip")]])))} function smart_field_row(a,b,c,d){c=$('<span class="listelement"><span class="reset"></span><input type="text"></span>');a={value:a,name:b+"[]"};d&&(a.size=d);$("input",c).attr(a).keydown(function(a){var b=$(this);if(13==a.which){a=b.attr("name").replace(/\[\]$/,"");var c=(new Date).getTime();a=smart_field_row("",a,c,d);b.parent().after(a);$("input",a).focus()}else if((8==a.which||46==a.which)&&""==b.val()&&(b=b.parent(),1<b.parent().children().length))return b.prev().length?b.prev().children("input").focus(): b.next().children("input").focus(),b.remove(),!1});$('span[class="reset"]',c).click(function(){var a=$(this.parentNode);1<a.parent().children().length?a.remove():$("input",a).val("").focus()});return c}function smart_field_reset(a,b){b=b.length?b:[""];area=$("#"+(a.id+"_list"));area.empty();$.each(b,function(b,d){area.append(smart_field_row(d,a.name,b,$(a).data("size")))})} rcube_webmail.prototype.managesieve_tip_register=function(a){var b,c=parent.rcmail,d=c?parent.rcmail.env.ms_tip_layer:rcmail.env.ms_tip_layer;for(b in a)$("#"+a[b][0]).data("tip",a[b][1]).mouseleave(function(a){d.hide()}).mouseenter(function(a){a=$(this);var b=a.offset(),e=b.left,k=b.top-12,m=a.width();c&&(b=$("mail"==rcmail.env.task?"#sievefilterform > iframe":"#filter-box",parent.document).offset(),k+=b.top,e+=b.left);d.html(a.data("tip"));k-=d.height();d.css({left:e,top:k,minWidth:m-2+"px"}).show()})}; function sieve_formattime(a,b){var c,d="",e=rcmail.env.time_format||"H:i";for(c=0;c<e.length;c++){var g=e.charAt(c);switch(g){case "a":d+=12<=a?"pm":"am";break;case "A":d+=12<=a?"PM":"AM";break;case "g":case "h":d+=("h"==g&&10>a?"0":"")+a;break;case "G":d+=a;break;case "H":d+=(10>a?"0":"")+a;break;case "i":d+=(10>b?"0":"")+b;break;case "s":d+="00";default:d+=g}}return d} function sieve_form_init(){var a=rcmail.gui_objects.sieveform;"plugin.managesieve"==rcmail.env.action&&"mail"==rcmail.env.task&&parent.rcmail.managesieve_dialog_resize(a);$('input[type="text"]:first',a).focus();$('textarea[data-type="list"]',a).each(function(){smart_field_init(this)});$('[name="_header[]"]',a).each(function(){/([0-9]+)$/.test(this.id)&&rule_header_select(RegExp.$1)});$.datepicker&&rcmail.env.date_format&&($.datepicker.setDefaults({dateFormat:rcmail.env.date_format,changeMonth:!0, showOtherMonths:!0,selectOtherMonths:!0,onSelect:function(a){$(this).focus().val(a)}}),$("input.datepicker").datepicker());$("#vacation_timefrom, #vacation_timeto").attr("autocomplete","off").autocomplete({delay:100,minLength:1,source:function(a,c){var b=[];for(a=0;24>a;a++)b.push(sieve_formattime(a,0));b.push(sieve_formattime(23,59));return c(b)},open:function(a,c){a=$(this);var b=a.val();c=a.autocomplete("widget").css("width","10em");var e=a.data("ui-autocomplete").menu;b&&b.length&&c.children().each(function(){var a= $(this);0==a.text().indexOf(b)&&e._scrollIntoView(a)})},select:function(a,c){$(this).val(c.item.value);return!1}}).click(function(){$(this).autocomplete("search",$(this).val()||" ")});$("input.error").each(function(){String(this.id).match(/([0-9]+)$/)&&$("#ruleadv"+RegExp.$1+".show").click()})}var cmeditor;function cmCreateErrorElem(a){var b=document.createElement("div");b.style.color="#822";b.innerHTML="\u25cf";b.title=a;return b} function cmScrollToError(){var a=$(".CodeMirror-lines .line-error"),b=$(".CodeMirror-scroll");a.parent();b.scrollTop(a.offset().top-b.offset().top-Math.round(b.height()/2))} function sieve_raw_editor_init(){var a=document.getElementById("rawfiltersettxt");a&&!cmeditor&&(cmeditor=CodeMirror.fromTextArea(a,{mode:"sieve",lineNumbers:!0,gutters:["CodeMirror-linenumbers","errorGutter"],styleActiveLine:!0}),$.each(rcmail.env.sieve_errors||[],function(a,c){var b=Number(c.line)-1;cmeditor.addLineClass(b,"background","line-error");cmeditor.setGutterMarker(b,"errorGutter",cmCreateErrorElem(c.msg));a||cmScrollToError()}))} rcube_webmail.prototype.managesieve_create=function(a){if(!a&&"show"!=this.env.action){var b=this.message_list.get_single_selection();a=this.set_busy(!0,"loading");this.http_post("plugin.managesieve-action",{_uid:b},a)}else if(this.env.sieve_headers&&this.env.sieve_headers.length){var c={},d=$("#sievefilterform");d.length||(d=$('<div id="sievefilterform"></div>'),$("body").append(d));a="<fieldset><legend>"+this.get_label("managesieve.usedata")+"</legend><ul>";for(b in this.env.sieve_headers)a+='<li><input type="checkbox" name="headers[]" id="sievehdr'+ b+'" value="'+b+'" checked="checked" /><label for="sievehdr'+b+'">'+this.env.sieve_headers[b][0]+":</label> "+this.env.sieve_headers[b][1]+"</li>";d.html(a+"</ul></fieldset>");c[this.get_label("managesieve.nextstep")]=function(){var a=$('input[name="headers[]"]:checked',d);if(a.length){var b=rcmail.get_task_url("mail");b=rcmail.add_url(b,"_action","plugin.managesieve");b=rcmail.add_url(b,"_framed",1);a.map(function(){var a=rcmail.env.sieve_headers[this.value];b=rcmail.add_url(b,"r["+this.value+"]", a[0]+":"+a[1])});a=$("<iframe>").attr({src:b,frameborder:0});d.empty().append(a).dialog("widget").resize();c={};c[rcmail.get_label("save")]=function(){$("iframe",d).get(0).contentWindow.rcmail.managesieve_save()};d.dialog("option","buttons",c)}else alert(rcmail.get_label("managesieve.nodata"))};d.dialog({modal:!1,resizable:!0,closeOnEscape:!0,title:this.get_label("managesieve.newfilter"),close:function(){rcmail.managesieve_dialog_close()},buttons:c,minWidth:600,minHeight:300,height:250}).show();this.env.managesieve_dialog= d}};rcube_webmail.prototype.managesieve_dialog_close=function(){var a=this.env.managesieve_dialog;a.html("");a.dialog("destroy").hide()};rcube_webmail.prototype.managesieve_dialog_resize=function(a){var b=this.env.managesieve_dialog,c=$(window),d=$(a);width=$("fieldset:first",a).width();height=d.height();w=c.width();h=c.height();b.dialog("option",{height:Math.min(h-20,height+120),width:Math.min(w-20,width+65)})};