HEX
Server: Apache
System: Linux server3230.server-vps.com 5.15.0-46-generic #49-Ubuntu SMP Thu Aug 4 18:03:25 UTC 2022 x86_64
User: lzgqnjwu (1002)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //usr/share/roundcube/program/js/treelist.min.js
/**
 * Roundcube Treelist Widget
 *
 * This file is part of the Roundcube Webmail client
 *
 * @licstart  The following is the entire license notice for the
 * JavaScript code in this file.
 *
 * Copyright (c) 2013-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 (GNU GPL) as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option)
 * any later version.  The code is distributed WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
 *
 * As additional permission under GNU GPL version 3 section 7, you
 * may distribute non-source (e.g., minimized or compacted) forms of
 * that code without the copy of the GNU GPL normally required by
 * section 4, provided you include this license notice and a URL
 * through which recipients can access the Corresponding Source.
 *
 * @licend  The above is the entire license notice
 * for the JavaScript code in this file.
 *
 * @author Thomas Bruederli <roundcube@gmail.com>
 * @requires jquery.js, common.js
 */
function rcube_treelist_widget(fa,e){var J,K,L,M;function A(a,b,c){var d;if(d=h[a]){d.collapsed="undefined"==typeof c||c;var g=k(d.id,!0);g.attr("aria-expanded",d.collapsed?"false":"true");g.children("ul").first()[d.collapsed?"hide":"show"]();g.children("div.treetoggle").removeClass("collapsed expanded").addClass(d.collapsed?"collapsed":"expanded");s.triggerEvent("toggle",d);if(b&&d.children)for(g=0;g<d.children.length;g++)A(d.children[g].id,b,c);s.triggerEvent(d.collapsed?"collapse":"expand",d);
b=d.collapsed;e.save_state&&window.rcmail&&(c="treelist-"+T,t||(t=rcmail.local_storage_get_item(c,{})),t[a]!=b&&(t[a]=b,rcmail.local_storage_set_item(c,t)))}}function U(a,b){A(a,b,!1)}function F(a){if(!1!==s.triggerEvent("beforeselect",h[a])&&(m&&(k(m,!0).removeClass("selected").removeAttr("aria-selected"),l&&k(m).removeClass("selected").removeAttr("aria-selected"),m=null),a)){var b=k(a,!0);if(b.length){b.addClass("selected").attr("aria-selected","true");m=a;l&&k(a).addClass("selected").attr("aria-selected",
"true");var c=f.parent(),d=c.scrollTop(),g=b.offset().top-c.offset().top;(0>g||g+b.height()>c.height())&&c.scrollTop(g+d)}s.triggerEvent("select",h[a])}}function V(a,b){return k(a,b).get(0)}function W(a,b){var c,d,g=a.get(0).id,e=a.children().first().text().toUpperCase();a.parent().children("li"+b).each(function(a,b){0==a&&(c=b);if(b.id!=g)if(b.id!=g&&e>=$(b).children().first().text().toUpperCase())d=b;else return!1});d?a.insertAfter(d):c&&c.id!=g&&a.insertBefore(c);p=G(f,0)}function X(a,b){a=String(a).toLowerCase();
if(!a.length)return B();if(a==C&&!b)return 0;var c=[],d=function(b){$.each(b,function(b,g){var e;if(!g.virtual&&!g.deleted&&0<=String(g.text).toLowerCase().indexOf(a)&&0>c.indexOf(g.id)){e=k(g.id);if(e.data("filtered"))return;$("<li>").attr("id",e.attr("id")+"--xsR").attr("class",e.attr("class")).addClass("searchresult__").append(e.children(":not(div.treetoggle,ul)").clone(!0,!0)).appendTo(f);c.push(g.id)}g.children&&g.children.length&&d(g.children)})};l&&($(f).children("li.searchresult__").remove(),
l=!1);$(f).children("li").hide().removeClass("selected");d(p);l=!0;C=a;s.triggerEvent("search",{query:a,last:C,count:c.length,ids:c,execute:b||!1});return c.count}function B(){H&&H.val("");$(f).children("li.searchresult__").remove();$(f).children("li").filter(function(){return!$(this).data("filtered")}).show();l=!1;s.triggerEvent("search",{query:!1,last:C});C="";m&&F(m)}function y(a,b,c){if(!a.deleted){var d=$("<li>").attr("id",e.id_prefix+(e.id_encode?e.id_encode(a.id):a.id)).attr("role","treeitem").addClass((a.classes||
[]).join(" ")).data("id",a.id);c?(c.replaceWith(d),b&&d.appendTo(b)):d.appendTo(b);"string"==typeof a.html?d.html(a.html):"object"==typeof a.html&&d.append(a.html);a.text||(a.text=d.children().first().text());a.virtual&&d.addClass("virtual");a.id==m&&d.addClass("selected");if(a.children&&a.children.length)for(d.attr("aria-expanded",a.collapsed?"false":"true"),$('<div class="treetoggle '+(a.collapsed?"collapsed":"expanded")+'">&nbsp;</div>').appendTo(d),b=$("<ul>").appendTo(d).attr("class",a.childlistclass).attr("role",
"group"),a.collapsed&&b.hide(),c=0;c<a.children.length;c++)a.children[c].level=a.level+1,y(a.children[c],b);return d}}function G(a,b){var c=[];a.children("li").each(function(a,g){var f,e=$(g),k=e.children("ul"),n={id:z(e),classes:String(e.attr("class")).split(" "),virtual:e.hasClass("virtual"),level:b,html:e.children().first().get(0).outerHTML,text:e.children().first().text(),children:G(k,b+1)};k.length&&(n.childlistclass=k.attr("class"));n.children.length&&(void 0===n.collapsed&&(n.collapsed="none"==
k.css("display")),f=Y(n.id,n.collapsed),void 0!==f&&(n.collapsed=f,k[f?"hide":"show"]()),e.children("div.treetoggle").length||$('<div class="treetoggle '+(n.collapsed?"collapsed":"expanded")+'">&nbsp;</div>').appendTo(e),e.attr("aria-expanded",n.collapsed?"false":"true"));e.hasClass("selected")&&(e.attr("aria-selected","true"),m=n.id);e.data("id",n.id);e.attr("role","treeitem").attr("aria-level",n.level+1);n.virtual&&e.children("a:first").attr("tabindex","0");c.push(n);h[n.id]=n});a.attr("role",0==
b?"tree":"group");return c}function Z(a){a.id&&(h[a.id]=a);for(var b=0;a.children&&b<a.children.length;b++)Z(a.children[b])}function z(a){a=String(a.attr("id")).replace(RegExp("^"+e.id_prefix||"%"),"").replace(/--xsR$/,"");return e.id_decode?e.id_decode(a):a}function k(a,b){var c=e.id_encode?e.id_encode(a):a;return $("#"+e.id_prefix+c+(l&&!b?"--xsR":""),f)}function Y(a){if(e.save_state&&window.rcmail)return t||(t=rcmail.local_storage_get_item("treelist-"+T,{})),t[a]}function ga(a){var b=a.target||
{},c=rcube_event.get_keycode(a);if(!D||"INPUT"==b.nodeName&&38!=c&&40!=c||"TEXTAREA"==b.nodeName||"SELECT"==b.nodeName)return!0;switch(c){case 38:case 40:case 63232:case 63233:return b=e.keyboard?f.find(":focus").closest("li"):[],b.length&&aa(b,mod=38==c||63232==c?-1:1),rcube_event.cancel(a);case 37:case 39:var d,b=f.find(":focus").closest("li");if(b.length&&(b=z(b),(d=h[b])&&d.children.length&&d.collapsed!=(37==c))){a=rcube_event.get_modifier(a)==SHIFT_KEY;var g;(g=h[b])&&A(b,a,!g.collapsed)}return!1;
case 9:e.keyboard&&e.tabexit&&(g=rcube_event.get_modifier(a)==SHIFT_KEY?"first":"last",g=f.find("li[role=treeitem]:has(a)")[g]().find("a:"+g),g.length&&(a=f.parent().get(0)||{scrollTop:0},c=a.scrollTop||a.scrollY,g.focus(),a.scrollTop=c))}return!0}function aa(a,b,c){var d=a[0>b?"prev":"next"]();0<b&&!c&&a.children("ul[role=group]:visible").length?a.children("ul").children("li:first").find("a:first").focus():0>b&&!c&&d.children("ul[role=group]:visible").length?d.children("ul").children("li:last").find("a:first").focus():
d.length&&d.find("a:first").focus().length||(a=a.parent().closest("li[role=treeitem]"),a.length&&(0>b?a.find("a:first").focus():aa(a,b,!0)))}function N(a){if(a||!w){w=!0;var b,c=f.offset();ba=bw.ie?0:window.pageYOffset;x=f.parent().scrollTop();c.top+=x;J=c.left;K=c.top;L=c.left+f.width();M=c.top+f.height();I=[];for(var d in h)if(a=k(d),a=a.children().first().get(0),b=a.offsetHeight)c=$(a).offset(),c.top+=x,I[d]={x1:c.left,y1:c.top,x2:c.left+a.offsetWidth,y2:c.top+b,on:d==v};f.height()>f.parent().height()&&
f.parent().mousemove(function(a){var b=0;a=rcube_event.get_mouse_pos(a);a.y-=f.parent().offset().top;25>a.y&&0<x?b=-1:a.y>f.parent().height()-25&&(b=1);w&&0!=b?q||(q=window.setTimeout(function(){ca(b)},e.scroll_delay)):q&&(window.clearTimeout(q),q=null)}).mouseleave(function(){q&&(window.clearTimeout(q),q=null)})}}function da(){w&&(w=!1,q=null,r&&(clearTimeout(r),v=r=null),$("li.droptarget",f).removeClass("droptarget"))}function ca(a){if(w){var b=x;f.parent().get(0).scrollTop+=e.scroll_step*a;x=f.parent().scrollTop();
q=null;x!=b&&(q=window.setTimeout(function(){ca(a)},e.scroll_speed))}}function ea(a,b){var c=bw.ie?-document.documentElement.scrollTop:ba,d=f.parent().scrollTop(),g=null;a.top=a.y+d-c;if(a.x<J||a.x>=L||a.top<K||a.top>=M)return b&&$("li.droptarget",f).removeClass("droptarget"),g;for(var u in I)c=I[u],a.x>=c.x1&&a.x<c.x2&&a.top>=c.y1&&a.top<c.y2?(g=h[u],g.children&&g.children.length&&g.collapsed&&e.autoexpand&&v!=u?(r&&clearTimeout(r),v=u,r=setTimeout(function(){U(v);N(!0);v=null;E&&$.ui.ddmanager.prepareOffsets($.ui.ddmanager.current,
null)},e.autoexpand)):r&&v!=u&&(clearTimeout(r),r=v=null),e.check_droptarget(g)?(b&&(k(u).addClass("droptarget"),c.on=!0),g=u):g=null):c.on&&(k(u).removeClass("droptarget"),c.on=!1);return g}function O(a){a||(a={});if("string"==$.type(a))return"destroy"==a&&(E=null),$("li:not(.virtual)",f).droppable(a),this;P=a;var b=$.extend({greedy:!0,tolerance:"pointer",hoverClass:"droptarget",addClasses:!1},a);b.activate=function(b,d){N();E=d;a.activate&&a.activate(b,d)};b.deactivate=function(b,d){da();E=null;
a.deactivate&&a.deactivate(b,d)};b.over=function(b,d){ea(rcube_event.get_mouse_pos(b),!1);a.over&&a.over(b,d)};$("li:not(.virtual)",f).droppable(b);return this}function Q(a){a||(a={});if("string"==$.type(a))return"destroy"==a&&(R=null),$("li:not(.virtual)",f).draggable(a),this;S=a;a=$.extend({appendTo:"body",revert:"invalid",iframeFix:!0,addClasses:!1,cursorAt:{left:-20,top:5},create:function(a,c){R=c},helper:function(a){return $("<div>").attr("id","rcmdraglayer").text($.trim($(a.target).first().text()))}},
a);$("li:not(.virtual)",f).draggable(a);return this}e=$.extend({id_prefix:"",autoexpand:1E3,selectable:!1,scroll_delay:500,scroll_step:5,scroll_speed:20,save_state:!1,keyboard:!0,tabexit:!0,parent_focus:!1,check_droptarget:function(a){return!a.virtual}},e||{});var f=$(fa),p=e.data||[],h={},m=null,w=!1,l=!1,C="",D=!1;M=L=K=J=void 0;var I=[],r,v,ba=0,x=0,q,H,t,E,R,S,P,T=f.attr("id")||e.id_prefix||"0",s=this;this.container=f;this.expand=U;this.collapse=A;this.select=F;this.render=function(){if(!1!==
s.triggerEvent("renderBefore",p)){f.html("");for(var a=0;a<p.length;a++)p[a].level=0,y(p[a],f);s.triggerEvent("renderAfter",f)}};this.reset=function(a){F("");p=[];h={};w=!1;a?(S&&(R&&Q("destroy"),Q(S)),P&&(E&&O("destroy"),O(P)),p=G(f,0)):f.html("");B()};this.drag_start=N;this.drag_end=da;this.intersects=ea;this.droppable=O;this.draggable=Q;this.update=function(a,b,c){var d,g,e,m,l=h[a];if(l){d=k(a);g=d.parent();if(b.id||b.html||b.children||b.classes||b.parent)b.parent&&(e=h[b.parent])?(g.closest("li").length&&
(m=h[z(g.closest("li"))])&&(m.children=$.grep(m.children,function(a,b){return a.id!=l.id})),g=k(b.parent).children("ul").first(),e.children||(e.children=[]),e.children.push(l)):void 0!==b.parent&&(g=f),$.extend(l,b),d=y(l,g,d);l.id!=a&&(delete h[a],h[l.id]=l);c&&W(d,"string"==typeof c?'[class~="'+c+'"]':"")}};this.insert=function(a,b,c){var d;d=b?h[b]:null;search_=l;h[a.id]||(state=Y(a.id,a.collapsed),void 0!==state&&(a.collapsed=state),d?(a.level=d.level+1,d.children||(d.children=[]),l=!1,d.children.push(a),
b=k(b),1==d.children.length?(y(d,null,b),d=k(a.id)):d=y(a,b.children("ul").first()),search_&&(l=search_,d.is(":visible")||$("<li>").attr("id",d.attr("id")+"--xsR").attr("class",d.attr("class")).addClass("searchresult__").append(d.children().first().clone(!0,!0)).appendTo(f))):(a.level=0,p.push(a),d=y(a,f)),h[a.id]=a,"object"==typeof a.html&&(h[a.id].html=k(a.id,!0).children()),c&&W(d,"string"==typeof c?'[class~="'+c+'"]':""))};this.remove=function(a){var b,c;return(b=h[a])?(c=k(a,!0),c.remove(),b.deleted=
!0,delete h[a],l&&k(a,!1).remove(),!0):!1};this.get_item=V;this.get_node=function(a){return h[a]};this.get_selection=function(){return m};this.is_search=function(){return l};this.reset_search=B;f.length&&(e.data?Z({children:p}):p=G(f,0),f.on("click","div.treetoggle",function(a){var b=z($(this).parent()),c;(c=h[b])&&A(b,void 0,!c.collapsed);a.stopPropagation()}),f.on("click","li",function(a){if($(a.target).is("input"))return!0;var b=e.selectable?h[z($(this))]:null;b&&!b.virtual&&(F(b.id),a.stopPropagation())}),
f.on("mousedown","a",function(a){var b=$(a.target),c=h[z(b.closest("li"))];if(c&&c.virtual&&!b.attr("href"))return a.preventDefault(),a.stopPropagation(),!1}),e.searchbox&&(H=$(e.searchbox).on("keyup",function(a){var b=rcube_event.get_keycode(a);rcube_event.get_modifier(a);switch(b){case 9:break;case 13:return X(this.value,!0),rcube_event.cancel(a);case 27:B();break;case 38:case 37:case 39:case 40:break;default:X(this.value,!1)}}).attr("autocomplete","off"),H.parent().find("a.reset").click(function(a){B();
return!1})),f.on("focusin",function(a){D=!0}).on("focusout",function(a){D=!1}),f.attr("role","tree"),$(document.body).bind("keydown",ga),e.parent_focus&&f.parent(":not(body)").click(function(a){!D&&m?$(V(m)).find(":focusable").first().focus():D||f.children("li:has(:focusable)").first().find(":focusable").first().focus()}))}rcube_treelist_widget.prototype.addEventListener=rcube_event_engine.prototype.addEventListener;rcube_treelist_widget.prototype.removeEventListener=rcube_event_engine.prototype.removeEventListener;
rcube_treelist_widget.prototype.triggerEvent=rcube_event_engine.prototype.triggerEvent;