1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * Roundcube functions for default skin interface
- *
- * @licstart The following is the entire license notice for the
- * JavaScript code in this file.
- *
- * Copyright (c) 2006-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.
- */
- function rcube_init_settings_tabs(){var a,b;b=$("#tabsbar");var c=$("span:last",b),d="#settingstabpreferences",e=window.rcmail&&rcmail.env.action?rcmail.env.action:null;c&&"settingstababout"!=c.attr("id")&&(a=$("#settingstababout"))&&(b=a.clone(!0),a.remove(),c.after(b));e&&(d="#settingstab"+(0<e.indexOf("identity")?"identities":e.replace(/\./g,"")));$(d).addClass("tablink-selected");$("a",d).removeAttr("onclick").click(function(){return!1})}
- function rcube_init_tabs(a,b){var c=$("#"+a),d=c.children("fieldset");if(d.length){b=b?b:0;d.each(function(a){a!=b&&$(this).hide()});var e=$("<div>").addClass("tabsbar").appendTo(c);d.each(function(c){var d,k,l=$(this),h=l.children("legend");k=$("<a>").text(h.text()).attr("href","#");d=$("<span>").attr({id:"tab"+c,"class":"tablink"}).click(function(){rcube_show_tab(a,c);return!1});h.remove();l.addClass("tabbed");c==b&&d.addClass("tablink-selected");d.append(k).appendTo(e)})}}
- function rcube_show_tab(a,b){$("#"+a).children("fieldset").each(function(a){$(this)[b==a?"show":"hide"]();$("#tab"+a).toggleClass("tablink-selected",a==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 a,b;for(b in this.popups)a=$("#"+this.popups[b].id),a.length?this.popups[b].obj=a:delete this.popups[b]}
- rcube_mail_ui.prototype={show_popup:function(a,b,c){var d;!this.popups[a]&&(d=$("#"+a))&&d.length&&(this.popups[a]=$.extend(c,{id:a,obj:d}));return"function"==typeof this[a]?this[a](b):this.show_popupmenu(a,b)},show_popupmenu:function(a,b){var c=this.popups[a].obj,d=this.popups[a].above,e=$(this.popups[a].link?this.popups[a].link:rcube_find_object(a+"link"));"undefined"==typeof b?b=c.is(":visible")?!1:!0:this.popups[a].toggle&&b&&this.popups[a].obj.is(":visible")&&(b=!1);if(b&&e.length){var f=e.parent(),
- g=$(window),f=f.hasClass("dropbutton")?f.offset():e.offset();!d&&f.top+e.height()+c.height()>g.height()&&(d=!0);f.left+c.width()>g.width()&&(f.left=g.width()-c.width()-30);c.css({left:f.left,top:f.top+(d?-c.height():e.height())})}c[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",!0);this.show_popupmenu("forwardmenu",
- a)},uploadmenu:function(a){"object"==typeof a&&(a=!1);if(!a)try{$("#attachment-form form")[0].reset()}catch(b){}rcmail.mailvelope_editor||(this.show_popupmenu("uploadmenu",a),!document.all&&this.popups.uploadmenu.obj.is(":visible")&&$("#attachment-form input[type=file]").click())},searchmenu:function(a){var b=this.popups.searchmenu.obj,c=rcube_find_object("searchmenulink");"undefined"==typeof a&&(a=b.is(":visible")?!1:!0);if(a&&c){var d=$(c).offset();b.css({left:d.left,top:d.top+c.offsetHeight+2});
- if(rcmail.env.search_mods){var e,f,c=$('input:checkbox[name="s_mods[]"]',b),d=rcmail.env.mailbox,g=rcmail.env.search_mods,k=rcmail.env.search_scope||"base";"mail"==rcmail.env.task?(g=g[d]?g[d]:g["*"],f="text",$('input:radio[name="s_scope"]').prop("checked",!1).filter("#s_scope_"+k).prop("checked",!0)):f="*";if(g[f])c.map(function(){this.checked=!0;this.disabled=this.value!=f});else for(e in c.prop("disabled",!1).prop("checked",!1),g)$("#s_mod_"+e).prop("checked",!0)}}b[a?"show":"hide"]()},set_searchmod:function(a){var b,
- c;b=rcmail.env.task;var d=rcmail.env.search_mods,e=rcmail.env.mailbox;"all"==$('input[name="s_scope"]:checked').val()&&(e="*");d||(d={});"mail"==b?(d[e]||(d[e]=rcube_clone_object(d["*"])),c=d[e],b="text"):(c=d,b="*");a.checked?c[a.value]=1:delete c[a.value];a.value==b&&$('input:checkbox[name="s_mods[]"]').map(function(){this!=a&&(this.checked=!0,a.checked?(this.disabled=!0,delete c[this.value]):(this.disabled=!1,c[this.value]=1))});rcmail.set_searchmods(c)},show_listmenu:function(a){var b=this,c=
- {},d=$("#listmenu");d.is(":visible")?d.dialog("close",a.originalEvent):($('input[name="sort_col"][value="'+rcmail.env.sort_col+'"]').prop("checked",!0),$('input[name="sort_ord"][value="DESC"]').prop("checked","DESC"==rcmail.env.sort_order),$('input[name="sort_ord"][value="ASC"]').prop("checked","DESC"!=rcmail.env.sort_order),$('input[name="view"][value="thread"]').prop("checked",rcmail.env.threading?!0:!1),$('input[name="view"][value="list"]').prop("checked",rcmail.env.threading?!1:!0),$('input[name="list_col[]"]').each(function(){$(this).prop("checked",
- -1!=$.inArray(this.value,rcmail.env.listcols))}),c[rcmail.gettext("save")]=function(a){d.dialog("close",a);b.save_listmenu()},d.dialog({modal:!0,resizable:!1,closeOnEscape:!0,title:null,open:function(a){var b=0;$("#listmenu fieldset").each(function(){var a=$(this).height();a>b&&(b=a)}).css("min-height",b+"px").height(b);setTimeout(function(){d.find("a, input:not(:disabled)").not("[aria-disabled=true]").first().focus()},100)},close:function(a){d.dialog("destroy").hide();a.originalEvent&&rcube_event.is_keyboard(a.originalEvent)&&
- $("#listmenulink").focus()},buttons:c,minWidth:500,width:d.width()+20}).show())},save_listmenu:function(){var a=$('input[name="sort_col"]:checked').val(),b=$('input[name="sort_ord"]:checked').val(),c=$('input[name="view"]:checked').val(),d=$('input[name="list_col[]"]:checked').map(function(){return this.value}).get();rcmail.set_list_options(d,a,b,"thread"==c?1:0)},spellmenu:function(a){var b,c,d=rcmail.spellcheck_lang(),e=this.popups.spellmenu.obj,f=$("ul",e);if(!f.length){f=$("<ul>");for(i in rcmail.env.spell_langs)c=
- $("<li>"),b=$('<a href="#"></a>').text(rcmail.env.spell_langs[i]).addClass("active").data("lang",i).click(function(){rcmail.spellcheck_lang_set($(this).data("lang"))}),b.appendTo(c),c.appendTo(f);f.appendTo(e)}$("li",f).each(function(){var a=$("a",this);a.data("lang")==d?a.addClass("selected"):a.hasClass("selected")&&a.removeClass("selected")});this.show_popupmenu("spellmenu",a)},show_attachmentmenu:function(a,b){var c=a.parentNode.id.replace(/^attach/,"");$("#attachmenuopen").off("click").attr("onclick",
- "").click(function(a){return rcmail.command("open-attachment",c,this)});$("#attachmenudownload").off("click").attr("onclick","").click(function(){rcmail.command("download-attachment",c,this)});this.popups.attachmentmenu.link=a;rcmail.command("menu-open",{menu:"attachmentmenu",id:c},a,b)},menu_open:function(a){a&&"messagelistmenu"==a.name&&this.show_listmenu()},body_mouseup:function(a){var b=a.target;ref=this;$.each(this.popups,function(c,d){!d.obj.is(":visible")||b==rcube_find_object(c+"link")||d.toggle||
- b==d.obj.get(0)||d.editable&&ref.target_overlaps(b,d.id)||d.sticky&&rcube_mouse_is_over(a,rcube_find_object(d.id))||$(b).is(".folder-selector-link")||$(b).children(".folder-selector-link").length||window.setTimeout('rcmail_ui.show_popup("'+c+'",false);',50)})},target_overlaps:function(a,b){for(var c=rcube_find_object(b);a.parentNode;){if(a.parentNode==c)return!0;a=a.parentNode}return!1},body_keydown:function(a){if(27==a.keyCode)for(var b in this.popups)this.popups[b].obj.is(":visible")&&this.show_popup(b,
- !1)},switch_preview_pane:function(a){var b,c=$("#mailpreviewframe");a.checked?(rcmail.env.contentframe="messagecontframe",mailviewsplit.layer?(mailviewsplit.resize(),mailviewsplit.layer.elm.style.display=""):mailviewsplit.init(),bw.opera&&$("#messagelistcontainer").css({height:""}),c.show(),(b=rcmail.message_list.get_single_selection())&&rcmail.show_message(b,!1,!0)):(c.hide(),bw.ie7?(b=document.getElementById("mailcontframe"),b.style.bottom=0,b.style.height=parseInt(b.parentNode.offsetHeight)+"px"):
- ($("#mailcontframe").css({height:"auto",bottom:0}),bw.opera&&$("#messagelistcontainer").css({height:"auto"})),mailviewsplit.layer&&(mailviewsplit.layer.elm.style.display="none"),rcmail.env.contentframe=null,rcmail.show_contentframe(!1));rcmail.command("save-pref",{name:"preview_pane",value:a.checked?1:0})},init_compose_form:function(){var a,b,c,d=["cc","bcc","replyto","followupto"],e=document.getElementById("compose-div"),f=document.getElementById("compose-headers-div");for(a=0;a<d.length;a++)b=d[a],
- c=$("#_"+b),c.length&&(c.on("change",{v:b},function(a){this.value&&rcmail_ui.show_header_form(a.data.v)}),""!=c.val()&&rcmail_ui.show_header_form(b));bw.ie&&(rcube_find_object("form").onkeydown=function(a){27==rcube_event.get_keycode(a)&&rcube_event.cancel(a)});$(window).resize(function(){rcmail_ui.resize_compose_body()});$("#compose-container").resize(function(){rcmail_ui.resize_compose_body()});e.style.top=parseInt(f.offsetHeight,10)+3+"px";$(window).resize();$("#contacts-table").css("top",$("#directorylist").height()+
- 24+"px");$("#quicksearchbox").keydown(function(a){13==rcube_event.get_keycode(a)&&rcmail.command("search")})},resize_compose_body:function(){var a=$("#compose-div .boxlistcontent"),b=a.width()-6,a=a.height()-2,c=bw.ie||bw.opera?4:0;$("#compose-body_ifr").width(b+6).height(a-1-$("div.mce-toolbar").height());$("#compose-body").width(b-c).height(a);$("#googie_edit_layer").width(b).height(a)},resize_compose_body_ev:function(){window.setTimeout(function(){rcmail_ui.resize_compose_body()},100)},show_header_form:function(a){var b,
- c=document.getElementById(a+"-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(a=document.getElementById("compose-"+a))b=document.getElementById("compose-div"),c=document.getElementById("compose-headers-div"),$(a).show(),b.style.top=parseInt(c.offsetHeight,10)+3+"px",this.resize_compose_body();return!1},hide_header_form:function(a){var b,c=document.getElementById(a+"-link"),d=c.parentNode.getElementsByTagName("a");
- c.style.display="";for(c=0;c<d.length;c++)if("none"!=d[c].style.display)for(var e=c+1;e<d.length;e++)if("none"!=d[e].style.display&&(b=this.next_sibling(d[c]))){b.style.display="";break}document.getElementById("_"+a).value="";if(a=document.getElementById("compose-"+a))b=document.getElementById("compose-div"),d=document.getElementById("compose-headers-div"),a.style.display="none",b.style.top=parseInt(d.offsetHeight,10)+1+"px",this.resize_compose_body();return!1},next_sibling:function(a){for(a=a.nextSibling;a&&
- 3==a.nodeType;)a=a.nextSibling;return a},prev_sibling:function(a){for(a=a.previousSibling;a&&3==a.nodeType;)a=a.previousSibling;return a},enable_command:function(a){"reply-list"==a.command&&1==rcmail.env.reply_all_mode?(a=rcmail.gettext(a.status?"replylist":"replyall"),$("a.button.replyAll").attr("title",a)):"compose-encrypted"==a.command&&$("#messagetoolbar > a.encrypt").show()},folder_search_init:function(a){$(".boxtitle a.search",a).click(function(b){var c=$(".boxtitle",a),d=$(".listsearchbox",
- a),e=d.is(":visible")?-1:1,f=24+($("select",d).length?24:0);d.slideToggle({duration:160,progress:function(b,d){0>e&&(d=1-d);$(".boxlistcontent",a).css("top",c.outerHeight()+f*d+"px")},complete:function(){d.toggleClass("expanded");d.is(":visible")?d.find("input[type=text]").focus():$("a.reset",d).click()}});return!1})}};
- function rcube_layer(a,b){this.name=a;this.create=function(a){var b=a.x?a.x:0,e=a.y?a.y:0,f=a.width,g=a.height,k=a.zindex,l=a.vis;a=a.parent;var h=document.createElement("DIV");h.id=this.name;h.style.position="absolute";h.style.visibility=l?2==l?"inherit":"visible":"hidden";h.style.left=b+"px";h.style.top=e+"px";f&&(h.style.width=f.toString().match(/\%$/)?f:f+"px");g&&(h.style.height=g.toString().match(/\%$/)?g:g+"px");k&&(h.style.zIndex=k);a?a.appendChild(h):document.body.appendChild(h);this.elm=
- h};null!=b?(this.create(b),this.name=this.elm.id):this.elm=document.getElementById(a);if(!this.elm)return!1;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="visible"==this.css.visibility||"show"==this.css.visibility||"inherit"==this.css.visibility?!0:!1;this.move=function(a,b){this.x=a;this.y=b;this.css.left=Math.round(this.x)+"px";this.css.top=Math.round(this.y)+
- "px"};this.resize=function(a,b){this.css.width=a+"px";this.css.height=b+"px";this.width=a;this.height=b};this.show=function(a){1==a?(this.css.visibility="visible",this.visible=!0):2==a?(this.css.visibility="inherit",this.visible=!0):(this.css.visibility="hidden",this.visible=!1)};this.write=function(a){this.elm.innerHTML=a}}
- function rcmail_scroller(a,b,c){var d=this;this.list=$(a);this.top=$(b);this.bottom=$(c);this.step_size=6;this.step_time=20;this.delay=500;this.top.mouseenter(function(){d.ts=window.setTimeout(function(){d.scroll("down")},d.delay)}).mouseout(function(){d.ts&&window.clearTimeout(d.ts)});this.bottom.mouseenter(function(){d.ts=window.setTimeout(function(){d.scroll("up")},d.delay)}).mouseout(function(){d.ts&&window.clearTimeout(d.ts)});this.scroll=function(a){var b=this,c=this.step_size;rcmail.drag_active&&
- ("down"==a&&(c*=-1),this.list.get(0).scrollTop+=c,this.ts=window.setTimeout(function(){b.scroll(a)},this.step_time))}}
- function rcube_render_mailboxlist(){var a=$("#mailboxlist > li > a, #mailboxlist ul:visible > li > a");a.length>(bw.ie&&9>bw.vendver?40:100)||a.each(function(){var a=$(this),c=a.data("text");c||(c=a.text().replace(/\s+\([0-9]+\)$/,""),a.data("text",c));if(!(6>c.length)){var d=fit_string_to_size(c,a,a.width()-a.children("span.unreadcount").width()-16);d!=c&&a.attr("title",c);a.contents().filter(function(){return 3==this.nodeType}).get(0).data=d}})}
- function fit_string_to_size(a,b,c){var d,e,f=a;rcmail.env.tmp_span?b=rcmail.env.tmp_span:(b=$("<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=b);e=$(b);e.text(f);d=b.offsetWidth;if(d>c){c=Math.max(1,Math.floor((d-c)/d*a.length/2));for(var g=d=f=Math.floor(a.length/2);;){d=f-c;g=f+c;e.text(a.substring(0,d)+"..."+a.substring(g));if(3>d||b.offsetWidth)break;c++}f=a.substring(0,d)+
- "..."+a.substring(g)}return f}function update_quota(a){percent_indicator(rcmail.gui_objects.quotadisplay,a);if(a.table){var b=$("#quotamenu");b.length||(b=$('<div id="quotamenu" class="popupmenu">').appendTo($("body")));b.html(a.table);$("#quotaimg").css("cursor","pointer").off("click").on("click",function(a){return rcmail.command("menu-open","quotamenu",a.target,a)})}}
- function percent_indicator(a,b){if(!b||!a)return!1;var c=b.width?b.width:rcmail.env.indicator_width?rcmail.env.indicator_width:100,d=b.height?b.height:rcmail.env.indicator_height?rcmail.env.indicator_height:14,e=b.percent?Math.abs(parseInt(b.percent)):0,f=parseInt(e/100*c),g=$(a).position();g.top=Math.max(0,g.top);g.left=Math.max(0,g.left);rcmail.env.indicator_width=c;rcmail.env.indicator_height=d;f>c&&(f=c,e=100);b.title&&(b.title=rcmail.get_label("quota")+": "+b.title);var k=$("<div>");k.css({position:"absolute",
- top:g.top,left:g.left,width:c+"px",height:d+"px",zIndex:100,lineHeight:d+"px"}).attr("title",b.title).addClass("quota_text").html(e+"%");var l=$("<div>");l.css({position:"absolute",top:g.top+1,left:g.left+1,width:f+"px",height:d+"px",zIndex:99});f=$("<div>");f.css({position:"absolute",top:g.top+1,left:g.left+1,width:c+"px",height:d+"px",zIndex:98}).addClass("quota_bg");80<=e?(k.addClass(" quota_text_high"),l.addClass("quota_high")):55<=e?(k.addClass(" quota_text_mid"),l.addClass("quota_mid")):(k.addClass(" quota_text_low"),
- l.addClass("quota_low"));$(a).html("").append(l).append(f).append(k);$("#quotaimg").attr("title",b.title)}var rcmail_editor_settings={},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(){rcmail.env.quota_content&&update_quota(rcmail.env.quota_content);rcmail.addEventListener("setquota",update_quota);rcube_webmail.set_iframe_events({mouseup:function(a){return rcmail_ui.body_mouseup(a)}});if("mail"==rcmail.env.task)if(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"),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",!1)})),rcmail.init_pagejumper("#pagejumper"),bw.ie&&rcmail.message_list&&$(window).resize(function(){setTimeout(function(){rcmail.message_list.resize()},10)}),"compose"==rcmail.env.action)rcmail_ui.init_compose_form(),rcmail.addEventListener("compose-encrypted",function(a){$("a.button.encrypt")[a.active?"addClass":"removeClass"]("selected");
- $("select[name='editorSelector']").prop("disabled",a.active);$("a.button.attach, a.button.responses, a.button.attach, #uploadmenulink")[a.active?"addClass":"removeClass"]("buttonPas disabled");$("#responseslist a.insertresponse")[a.active?"removeClass":"addClass"]("active")});else{if("show"==rcmail.env.action||"preview"==rcmail.env.action)$('#attachment-list > li[id^="attach"]').each(function(){$(this).append($('<a class="drop"></a>').on("click keypress",function(a){if("keypress"!=a.type||13==a.which)return rcmail_ui.show_attachmentmenu(this,
- a),!1}))}),$(window).resize(function(){var a=$("#messagebody.mailvelope");if(a.length){var b=$("#messageframe"),b=(b.length?b.height()+b.offset().top-25:$(this).height())-a.offset().top-20;a.height(b)}})}else"addressbook"==rcmail.env.task?rcmail.addEventListener("afterupload-photo",function(){rcmail_ui.show_popup("uploadform",!1)}).gui_object("dragmenu","dragmenu"):"settings"==rcmail.env.task&&"folders"==rcmail.env.action&&rcmail_ui.folder_search_init($("#folder-manager"))})};
|