Mercurial > hg > rc2
comparison skins/classic/functions.min.js @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:52:31 -0500 |
parents | |
children | bf99236cc5cd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4681f974d28b |
---|---|
1 function rcube_init_settings_tabs(){var d,b,a=$("#tabsbar"),f=$("span:last",a),c="#settingstabpreferences",e=window.rcmail&&rcmail.env.action?rcmail.env.action:null;if(f&&f.attr("id")!="settingstababout"&&(d=$("#settingstababout"))){b=d.clone(true);d.remove();f.after(b)}if(e){c="#settingstab"+(e.indexOf("identity")>0?"identities":e.replace(/\./g,""))}$(c).addClass("tablink-selected");$("a",c).removeAttr("onclick").click(function(){return false})}function rcube_init_tabs(e,d){var c=$("#"+e),a=c.children("fieldset");if(!a.length){return}d=d?d:0;a.each(function(f){if(f!=d){$(this).hide()}});var b=$("<div>").addClass("tabsbar").appendTo(c);a.each(function(f){var j,g,k=$(this),h=k.children("legend");g=$("<a>").text(h.text()).attr("href","#");j=$("<span>").attr({id:"tab"+f,"class":"tablink"}).click(function(){rcube_show_tab(e,f);return false});h.remove();k.addClass("tabbed");if(f==d){j.addClass("tablink-selected")}j.append(g).appendTo(b)})}function rcube_show_tab(c,b){var a=$("#"+c).children("fieldset");a.each(function(d){$(this)[b==d?"show":"hide"]();$("#tab"+d).toggleClass("tablink-selected",d==b)})}function rcube_mail_ui(){this.popups={markmenu:{id:"markmessagemenu"},replyallmenu:{id:"replyallmenu"},forwardmenu:{id:"forwardmenu",editable:1},searchmenu:{id:"searchmenu",editable:1},messagemenu:{id:"messagemenu"},attachmentmenu:{id:"attachmentmenu"},dragmenu:{id:"dragmenu",sticky:1},groupmenu:{id:"groupoptionsmenu",above:1},mailboxmenu:{id:"mailboxoptionsmenu",above:1},composemenu:{id:"composeoptionsmenu",editable:1,overlap:1},spellmenu:{id:"spellmenu"},responsesmenu:{id:"responsesmenu"},uploadmenu:{id:"attachment-form",editable:1,above:1,toggle:!bw.ie&&!bw.linux},uploadform:{id:"upload-form",editable:1,toggle:!bw.ie&&!bw.linux}};var b;for(var a in this.popups){b=$("#"+this.popups[a].id);if(b.length){this.popups[a].obj=b}else{delete this.popups[a]}}}rcube_mail_ui.prototype={show_popup:function(b,a,c){var d;if(!this.popups[b]&&(d=$("#"+b))&&d.length){this.popups[b]=$.extend(c,{id:b,obj:d})}if(typeof this[b]=="function"){return this[b](a)}else{return this.show_popupmenu(b,a)}},show_popupmenu:function(c,b){var g=this.popups[c].obj,a=this.popups[c].above,e=$(this.popups[c].link?this.popups[c].link:rcube_find_object(c+"link"));if(typeof b=="undefined"){b=g.is(":visible")?false:true}else{if(this.popups[c].toggle&&b&&this.popups[c].obj.is(":visible")){b=false}}if(b&&e.length){var d=e.parent(),f=$(window),h=d.hasClass("dropbutton")?d.offset():e.offset();if(!a&&h.top+e.height()+g.height()>f.height()){a=true}if(h.left+g.width()>f.width()){h.left=f.width()-g.width()-30}g.css({left:h.left,top:(h.top+(a?-g.height():e.height()))})}g[b?"show":"hide"]()},dragmenu:function(a){this.popups.dragmenu.obj[a?"show":"hide"]()},forwardmenu:function(a){$("input[name='forwardtype'][value="+(rcmail.env.forward_attachment?1:0)+"]",this.popups.forwardmenu.obj).prop("checked",true);this.show_popupmenu("forwardmenu",a)},uploadmenu:function(a){if(typeof a=="object"){a=false}if(!a){try{$("#attachment-form form")[0].reset()}catch(b){}}this.show_popupmenu("uploadmenu",a);if(!document.all&&this.popups.uploadmenu.obj.is(":visible")){$("#attachment-form input[type=file]").click()}},searchmenu:function(h){var d=this.popups.searchmenu.obj,c=rcube_find_object("searchmenulink");if(typeof h=="undefined"){h=d.is(":visible")?false:true}if(h&&c){var f=$(c).offset();d.css({left:f.left,top:(f.top+c.offsetHeight+2)});if(rcmail.env.search_mods){var b,g,e=$('input:checkbox[name="s_mods[]"]',d),a=rcmail.env.mailbox,j=rcmail.env.search_mods,k=rcmail.env.search_scope||"base";if(rcmail.env.task=="mail"){j=j[a]?j[a]:j["*"];g="text";$('input:radio[name="s_scope"]').prop("checked",false).filter("#s_scope_"+k).prop("checked",true)}else{g="*"}if(j[g]){e.map(function(){this.checked=true;this.disabled=this.value!=g})}else{e.prop("disabled",false).prop("checked",false);for(b in j){$("#s_mod_"+b).prop("checked",true)}}}}d[h?"show":"hide"]()},set_searchmod:function(f){var d,a,b=rcmail.env.task,e=rcmail.env.search_mods,g=rcmail.env.mailbox,c=$('input[name="s_scope"]:checked').val();if(c=="all"){g="*"}if(!e){e={}}if(b=="mail"){if(!e[g]){e[g]=rcube_clone_object(e["*"])}a=e[g];d="text"}else{a=e;d="*"}if(!f.checked){delete (a[f.value])}else{a[f.value]=1}if(f.value==d){$('input:checkbox[name="s_mods[]"]').map(function(){if(this==f){return}this.checked=true;if(f.checked){this.disabled=true;delete a[this.value]}else{this.disabled=false;a[this.value]=1}})}rcmail.set_searchmods(a)},show_listmenu:function(d){var a=this,b={},c=$("#listmenu");if(c.is(":visible")){c.dialog("close",d.originalEvent);return}$('input[name="sort_col"][value="'+rcmail.env.sort_col+'"]').prop("checked",true);$('input[name="sort_ord"][value="DESC"]').prop("checked",rcmail.env.sort_order=="DESC");$('input[name="sort_ord"][value="ASC"]').prop("checked",rcmail.env.sort_order!="DESC");$('input[name="view"][value="thread"]').prop("checked",rcmail.env.threading?true:false);$('input[name="view"][value="list"]').prop("checked",rcmail.env.threading?false:true);$('input[name="list_col[]"]').each(function(){$(this).prop("checked",$.inArray(this.value,rcmail.env.listcols)!=-1)});b[rcmail.gettext("save")]=function(f){c.dialog("close",f);a.save_listmenu()};c.dialog({modal:true,resizable:false,closeOnEscape:true,title:null,open:function(f){var g=0;$("#listmenu fieldset").each(function(){var e=$(this).height();if(e>g){g=e}}).css("min-height",g+"px").height(g);setTimeout(function(){c.find("a, input:not(:disabled)").not("[aria-disabled=true]").first().focus()},100)},close:function(f){c.dialog("destroy").hide();if(f.originalEvent&&rcube_event.is_keyboard(f.originalEvent)){$("#listmenulink").focus()}},buttons:b,minWidth:500,width:c.width()+20}).show()},save_listmenu:function(){var c=$('input[name="sort_col"]:checked').val(),b=$('input[name="sort_ord"]:checked').val(),a=$('input[name="view"]:checked').val(),d=$('input[name="list_col[]"]:checked').map(function(){return this.value}).get();rcmail.set_list_options(d,c,b,a=="thread"?1:0)},spellmenu:function(b){var d,a,f=rcmail.spellcheck_lang(),e=this.popups.spellmenu.obj,c=$("ul",e);if(!c.length){c=$("<ul>");for(i in rcmail.env.spell_langs){a=$("<li>");d=$('<a href="#"></a>').text(rcmail.env.spell_langs[i]).addClass("active").data("lang",i).click(function(){rcmail.spellcheck_lang_set($(this).data("lang"))});d.appendTo(a);a.appendTo(c)}c.appendTo(e)}$("li",c).each(function(){var g=$("a",this);if(g.data("lang")==f){g.addClass("selected")}else{if(g.hasClass("selected")){g.removeClass("selected")}}});this.show_popupmenu("spellmenu",b)},show_attachmentmenu:function(b,a){var c=b.parentNode.id.replace(/^attach/,"");$("#attachmenuopen").unbind("click").attr("onclick","").click(function(d){return rcmail.command("open-attachment",c,this)});$("#attachmenudownload").unbind("click").attr("onclick","").click(function(){rcmail.command("download-attachment",c,this)});this.popups.attachmentmenu.link=b;rcmail.command("menu-open",{menu:"attachmentmenu",id:c},b,a)},menu_open:function(a){if(a&&a.name=="messagelistmenu"){this.show_listmenu()}},body_mouseup:function(b){var a=b.target;ref=this;$.each(this.popups,function(d,c){if(c.obj.is(":visible")&&a!=rcube_find_object(d+"link")&&!c.toggle&&a!=c.obj.get(0)&&(!c.editable||!ref.target_overlaps(a,c.id))&&(!c.sticky||!rcube_mouse_is_over(b,rcube_find_object(c.id)))&&!$(a).is(".folder-selector-link")&&!$(a).children(".folder-selector-link").length){window.setTimeout('rcmail_ui.show_popup("'+d+'",false);',50)}})},target_overlaps:function(c,a){var b=rcube_find_object(a);while(c.parentNode){if(c.parentNode==b){return true}c=c.parentNode}return false},body_keydown:function(b){if(b.keyCode==27){for(var a in this.popups){if(this.popups[a].obj.is(":visible")){this.show_popup(a,false)}}}},switch_preview_pane:function(d){var b,c=$("#mailpreviewframe");if(d.checked){rcmail.env.contentframe="messagecontframe";if(mailviewsplit.layer){mailviewsplit.resize();mailviewsplit.layer.elm.style.display=""}else{mailviewsplit.init()}if(bw.opera){$("#messagelistcontainer").css({height:""})}c.show();if(b=rcmail.message_list.get_single_selection()){rcmail.show_message(b,false,true)}}else{c.hide();if(bw.ie7){var a=document.getElementById("mailcontframe");a.style.bottom=0;a.style.height=parseInt(a.parentNode.offsetHeight)+"px"}else{$("#mailcontframe").css({height:"auto",bottom:0});if(bw.opera){$("#messagelistcontainer").css({height:"auto"})}}if(mailviewsplit.layer){mailviewsplit.layer.elm.style.display="none"}rcmail.env.contentframe=null;rcmail.show_contentframe(false)}rcmail.command("save-pref",{name:"preview_pane",value:(d.checked?1:0)})},init_compose_form:function(){var e,c,g,b=["cc","bcc","replyto","followupto"],h=document.getElementById("compose-div"),a=document.getElementById("compose-headers-div");for(e=0;e<b.length;e++){c=b[e];g=$("#_"+c);if(g.length){g.on("change",{v:c},function(f){if(this.value){rcmail_ui.show_header_form(f.data.v)}});if(g.val()!=""){rcmail_ui.show_header_form(c)}}}if(bw.ie){var d=rcube_find_object("form");d.onkeydown=function(f){if(rcube_event.get_keycode(f)==27){rcube_event.cancel(f)}}}$(window).resize(function(){rcmail_ui.resize_compose_body()});$("#compose-container").resize(function(){rcmail_ui.resize_compose_body()});h.style.top=(parseInt(a.offsetHeight,10)+3)+"px";$(window).resize();$("#contacts-table").css("top",$("#directorylist").height()+24+"px");$("#quicksearchbox").keydown(function(f){if(rcube_event.get_keycode(f)==13){rcmail.command("search")}})},resize_compose_body:function(){var d=$("#compose-div .boxlistcontent"),b=d.width()-6,c=d.height()-2,a=bw.ie||bw.opera?4:0;$("#compose-body_ifr").width(b+6).height(c-1-$("div.mce-toolbar").height());$("#compose-body").width(b-a).height(c);$("#googie_edit_layer").width(b).height(c)},resize_compose_body_ev:function(){window.setTimeout(function(){rcmail_ui.resize_compose_body()},100)},show_header_form:function(f){var d,b,c=document.getElementById(f+"-link");if((b=this.next_sibling(c))){b.style.display="none"}else{if((b=this.prev_sibling(c))){b.style.display="none"}}c.style.display="none";if((d=document.getElementById("compose-"+f))){var e=document.getElementById("compose-div"),a=document.getElementById("compose-headers-div");$(d).show();e.style.top=(parseInt(a.offsetHeight,10)+3)+"px";this.resize_compose_body()}return false},hide_header_form:function(b){var l,g,f=document.getElementById(b+"-link"),h=f.parentNode,k=h.getElementsByTagName("a");f.style.display="";for(var e=0;e<k.length;e++){if(k[e].style.display!="none"){for(var d=e+1;d<k.length;d++){if(k[d].style.display!="none"){if((g=this.next_sibling(k[e]))){g.style.display="";break}}}}}document.getElementById("_"+b).value="";if((l=document.getElementById("compose-"+b))){var a=document.getElementById("compose-div"),c=document.getElementById("compose-headers-div");l.style.display="none";a.style.top=(parseInt(c.offsetHeight,10)+1)+"px";this.resize_compose_body()}return false},next_sibling:function(b){var a=b.nextSibling;while(a&&a.nodeType==3){a=a.nextSibling}return a},prev_sibling:function(b){var a=b.previousSibling;while(a&&a.nodeType==3){a=a.previousSibling}return a},enable_command:function(b){if(b.command=="reply-list"&&rcmail.env.reply_all_mode==1){var a=rcmail.gettext(b.status?"replylist":"replyall");$("a.button.replyAll").attr("title",a)}},folder_search_init:function(a){$(".boxtitle a.search",a).click(function(f){var g=$(".boxtitle",a),d=$(".listsearchbox",a),c=d.is(":visible")?-1:1,b=24+($("select",d).length?24:0);d.slideToggle({duration:160,progress:function(h,e){if(c<0){e=1-e}$(".boxlistcontent",a).css("top",(g.outerHeight()+b*e)+"px")},complete:function(){d.toggleClass("expanded");if(d.is(":visible")){d.find("input[type=text]").focus()}else{$("a.reset",d).click()}}});return false})}};function rcube_layer(b,a){this.name=b;this.create=function(n){var d=(n.x)?n.x:0,m=(n.y)?n.y:0,k=n.width,f=n.height,g=n.zindex,c=n.vis,j=n.parent,e=document.createElement("DIV");e.id=this.name;e.style.position="absolute";e.style.visibility=(c)?(c==2)?"inherit":"visible":"hidden";e.style.left=d+"px";e.style.top=m+"px";if(k){e.style.width=k.toString().match(/\%$/)?k:k+"px"}if(f){e.style.height=f.toString().match(/\%$/)?f:f+"px"}if(g){e.style.zIndex=g}if(j){j.appendChild(e)}else{document.body.appendChild(e)}this.elm=e};if(a!=null){this.create(a);this.name=this.elm.id}else{this.elm=document.getElementById(b)}if(!this.elm){return false}this.css=this.elm.style;this.event=this.elm;this.width=this.elm.offsetWidth;this.height=this.elm.offsetHeight;this.x=parseInt(this.elm.offsetLeft);this.y=parseInt(this.elm.offsetTop);this.visible=(this.css.visibility=="visible"||this.css.visibility=="show"||this.css.visibility=="inherit")?true:false;this.move=function(c,d){this.x=c;this.y=d;this.css.left=Math.round(this.x)+"px";this.css.top=Math.round(this.y)+"px"};this.resize=function(c,d){this.css.width=c+"px";this.css.height=d+"px";this.width=c;this.height=d};this.show=function(c){if(c==1){this.css.visibility="visible";this.visible=true}else{if(c==2){this.css.visibility="inherit";this.visible=true}else{this.css.visibility="hidden";this.visible=false}}};this.write=function(c){this.elm.innerHTML=c}}function rcmail_scroller(c,d,a){var b=this;this.list=$(c);this.top=$(d);this.bottom=$(a);this.step_size=6;this.step_time=20;this.delay=500;this.top.mouseenter(function(){b.ts=window.setTimeout(function(){b.scroll("down")},b.delay)}).mouseout(function(){if(b.ts){window.clearTimeout(b.ts)}});this.bottom.mouseenter(function(){b.ts=window.setTimeout(function(){b.scroll("up")},b.delay)}).mouseout(function(){if(b.ts){window.clearTimeout(b.ts)}});this.scroll=function(e){var g=this,f=this.step_size;if(!rcmail.drag_active){return}if(e=="down"){f*=-1}this.list.get(0).scrollTop+=f;this.ts=window.setTimeout(function(){g.scroll(e)},this.step_time)}}function iframe_events(){try{var b=this.contentDocument?this.contentDocument:this.contentWindow?this.contentWindow.document:null;$(b).mouseup(function(c){rcmail_ui.body_mouseup(c)})}catch(a){}}function rcube_render_mailboxlist(){var a=$("#mailboxlist > li > a, #mailboxlist ul:visible > li > a");if(a.length>(bw.ie&&bw.vendver<9?40:100)){return}a.each(function(){var c=$(this),d=c.data("text");if(!d){d=c.text().replace(/\s+\([0-9]+\)$/,"");c.data("text",d)}if(d.length<6){return}var b=fit_string_to_size(d,c,c.width()-c.children("span.unreadcount").width()-16);if(b!=d){c.attr("title",d)}c.contents().filter(function(){return(this.nodeType==3)}).get(0).data=b})}function fit_string_to_size(f,b,e){var l,k,g,m=f,a="...";if(!rcmail.env.tmp_span){k=$("<b>").css({visibility:"hidden",padding:"0px","font-family":b.css("font-family"),"font-size":b.css("font-size")}).appendTo($("body",document)).get(0);rcmail.env.tmp_span=k}else{k=rcmail.env.tmp_span}g=$(k);g.text(m);l=k.offsetWidth;if(l>e){var h=Math.max(1,Math.floor(f.length*((l-e)/l)/2)),j=Math.floor(f.length/2),d=j,c=j;while(true){d=j-h;c=j+h;g.text(f.substring(0,d)+a+f.substring(c));if(d<3||k.offsetWidth){break}h++}m=f.substring(0,d)+a+f.substring(c)}return m}function update_quota(a){percent_indicator(rcmail.gui_objects.quotadisplay,a);if(a.table){var b=$("#quotamenu");if(!b.length){b=$('<div id="quotamenu" class="popupmenu">').appendTo($("body"))}b.html(a.table);$("#quotaimg").css("cursor","pointer").off("click").on("click",function(c){return rcmail.command("menu-open","quotamenu",c.target,c)})}}function percent_indicator(e,f){if(!f||!e){return false}var m=80,a=55,b=f.width?f.width:rcmail.env.indicator_width?rcmail.env.indicator_width:100,l=f.height?f.height:rcmail.env.indicator_height?rcmail.env.indicator_height:14,c=f.percent?Math.abs(parseInt(f.percent)):0,g=parseInt(c/100*b),k=$(e).position();k.top=Math.max(0,k.top);k.left=Math.max(0,k.left);rcmail.env.indicator_width=b;rcmail.env.indicator_height=l;if(g>b){g=b;c=100}if(f.title){f.title=rcmail.get_label("quota")+": "+f.title}var d=$("<div>");d.css({position:"absolute",top:k.top,left:k.left,width:b+"px",height:l+"px",zIndex:100,lineHeight:l+"px"}).attr("title",f.title).addClass("quota_text").html(c+"%");var j=$("<div>");j.css({position:"absolute",top:k.top+1,left:k.left+1,width:g+"px",height:l+"px",zIndex:99});var h=$("<div>");h.css({position:"absolute",top:k.top+1,left:k.left+1,width:b+"px",height:l+"px",zIndex:98}).addClass("quota_bg");if(c>=m){d.addClass(" quota_text_high");j.addClass("quota_high")}else{if(c>=a){d.addClass(" quota_text_mid");j.addClass("quota_mid")}else{d.addClass(" quota_text_low");j.addClass("quota_low")}}$(e).html("").append(j).append(h).append(d);$("#quotaimg").attr("title",f.title)}var rcmail_editor_settings={};var rcmail_ui;function rcube_init_mail_ui(){rcmail_ui=new rcube_mail_ui();$(document.body).mouseup(function(a){rcmail_ui.body_mouseup(a)}).mousedown(function(a){rcmail_ui.body_keydown(a)});rcmail.addEventListener("init",function(){if(rcmail.env.quota_content){update_quota(rcmail.env.quota_content)}rcmail.addEventListener("setquota",update_quota);$("iframe").load(iframe_events).contents().mouseup(function(a){rcmail_ui.body_mouseup(a)});if(rcmail.env.task=="mail"){rcmail.addEventListener("enable-command","enable_command",rcmail_ui).addEventListener("menu-open","menu_open",rcmail_ui).addEventListener("aftersend-attachment","uploadmenu",rcmail_ui).addEventListener("aftertoggle-editor","resize_compose_body_ev",rcmail_ui).gui_object("dragmenu","dragmenu");if(rcmail.gui_objects.mailboxlist){rcmail.treelist.addEventListener("expand",rcube_render_mailboxlist);rcmail.addEventListener("responseaftermark",rcube_render_mailboxlist).addEventListener("responseaftergetunread",rcube_render_mailboxlist).addEventListener("responseaftercheck-recent",rcube_render_mailboxlist).addEventListener("responseafterrefresh",rcube_render_mailboxlist).addEventListener("afterimport-messages",function(){rcmail_ui.show_popup("uploadform",false)})}if(bw.ie&&rcmail.message_list){$(window).resize(function(){setTimeout(function(){rcmail.message_list.resize()},10)})}if(rcmail.env.action=="compose"){rcmail_ui.init_compose_form()}else{if(rcmail.env.action=="show"||rcmail.env.action=="preview"){$('#attachment-list > li[id^="attach"]').each(function(){$(this).append($('<a class="drop"></a>').bind("click keypress",function(a){if(a.type!="keypress"||a.which==13){rcmail_ui.show_attachmentmenu(this,a);return false}}))})}}}else{if(rcmail.env.task=="addressbook"){rcmail.addEventListener("afterupload-photo",function(){rcmail_ui.show_popup("uploadform",false)}).gui_object("dragmenu","dragmenu")}else{if(rcmail.env.task=="settings"){if(rcmail.env.action=="folders"){rcmail_ui.folder_search_init($("#folder-manager"))}}}}})}; |