HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/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) 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(ha,g){var I,J,K;function w(a,b,d){var c;if(c=k[a]){c.collapsed="undefined"==typeof d||d;var f=l(c.id,!0);f.attr("aria-expanded",c.collapsed?"false":"true");f.children("ul").first()[c.collapsed?"hide":"show"]();f.children("div.treetoggle").removeClass("collapsed expanded").addClass(c.collapsed?"collapsed":"expanded");t.triggerEvent("toggle",c);if(b&&c.children)for(f=0;f<c.children.length;f++)w(c.children[f].id,b,d);t.triggerEvent(c.collapsed?"collapse":"expand",c);b=
c.collapsed;g.save_state&&window.rcmail&&(d="treelist-"+R,u||(u=rcmail.local_storage_get_item(d,{})),u[a]!=b&&(u[a]=b,rcmail.local_storage_set_item(d,u)))}}function S(a,b){w(a,b,!1)}function E(a){if(!1!==t.triggerEvent("beforeselect",k[a])&&(h&&(l(h,!0).removeClass("selected").removeAttr("aria-selected"),m&&l(h).removeClass("selected").removeAttr("aria-selected"),h=null),a)){var b=l(a,!0);b.length&&(b.addClass("selected").attr("aria-selected","true"),h=a,m&&l(a).addClass("selected").attr("aria-selected",
"true"),T(b));t.triggerEvent("select",k[a])}}function U(){return h}function V(a,b){return l(a,b).get(0)}function W(a,b){var d,c,f=a.get(0).id,ia=a.children().first().text().toUpperCase();a.parent().children("li"+b).each(function(a,b){0==a&&(d=b);if(b.id!=f)if(b.id!=f&&ia>=$(b).children().first().text().toUpperCase())c=b;else return!1});c?a.insertAfter(c):d&&d.id!=f&&a.insertBefore(d);p=F(e,0)}function X(a,b){a=String(a).toLowerCase();if(!a.length)return A();if(a==B&&!b)return 0;var d=[],c=function(b){$.each(b,
function(b,f){if(!f.virtual&&!f.deleted&&0<=String(f.text).toLowerCase().indexOf(a)&&0>d.indexOf(f.id)){b=l(f.id);if(b.data("filtered"))return;$("<li>").attr("id",b.attr("id")+"--xsR").attr("class",b.attr("class")).addClass("searchresult__").append(b.children(":not(div.treetoggle,ul)").clone(!0,!0)).appendTo(e);d.push(f.id)}f.children&&f.children.length&&c(f.children)})};m&&($(e).children("li.searchresult__").remove(),m=!1);$(e).children("li").hide().removeClass("selected");c(p);m=!0;t.triggerEvent("search",
{query:a,last:B,count:d.length,ids:d,execute:b||!1});B=a;return d.count}function A(a){L&&L.val("");$(e).children("li.searchresult__").remove();$(e).children("li").filter(function(){return!$(this).data("filtered")}).show();m=!1;t.triggerEvent("search",{query:!1,last:B});B="";h&&!a&&E(h)}function z(a,b,d){if(!a.deleted){var c=$("<li>").attr("id",g.id_prefix+(g.id_encode?g.id_encode(a.id):a.id)).attr("role","treeitem").addClass((a.classes||[]).join(" ")).data("id",a.id);d?(d.replaceWith(c),b&&c.appendTo(b)):
c.appendTo(b);"string"==typeof a.html?c.html(a.html):"object"==typeof a.html&&c.append(a.html);a.text||(a.text=c.children().first().text());a.virtual&&c.addClass("virtual");a.id==h&&c.addClass("selected");if(a.children&&a.children.length)for(c.attr("aria-expanded",a.collapsed?"false":"true"),$('<div class="treetoggle '+(a.collapsed?"collapsed":"expanded")+'">&nbsp;</div>').appendTo(c),b=$("<ul>").appendTo(c).attr("class",a.childlistclass).attr("role","group"),a.collapsed&&b.hide(),d=0;d<a.children.length;d++)a.children[d].level=
a.level+1,z(a.children[d],b);return c}}function F(a,b){var d=[];a.children("li").each(function(a,f){f=$(f);var c=f.children("ul"),e={id:n(f),classes:String(f.attr("class")).split(" "),virtual:f.hasClass("virtual"),level:b,html:f.children().first().get(0).outerHTML,text:f.children().first().text(),children:F(c,b+1)};c.length&&(e.childlistclass=c.attr("class"));e.children.length&&(void 0===e.collapsed&&(e.collapsed="none"==c.css("display")),a=Y(e.id,e.collapsed),void 0!==a&&(e.collapsed=a,c[a?"hide":
"show"]()),f.children("div.treetoggle").length||$('<div class="treetoggle '+(e.collapsed?"collapsed":"expanded")+'">&nbsp;</div>').appendTo(f),f.attr("aria-expanded",e.collapsed?"false":"true"));f.hasClass("selected")&&(f.attr("aria-selected","true"),h=e.id);f.data("id",e.id);f.attr("role","treeitem").attr("aria-level",e.level+1);e.virtual&&f.children("a").first().attr("tabindex","0");d.push(e);k[e.id]=e});a.attr("role",0==b?"tree":"group");return d}function Z(a){a.id&&(k[a.id]=a);for(var b=0;a.children&&
b<a.children.length;b++)Z(a.children[b])}function n(a){a=String(a.attr("id")).replace(new RegExp("^"+g.id_prefix||"%"),"").replace(/--xsR$/,"");return g.id_decode?g.id_decode(a):a}function l(a,b){a=g.id_encode?g.id_encode(a):a;return $("#"+g.id_prefix+a+(m&&!b?"--xsR":""),e)}function T(a){var b=e.parent(),d=b.scrollTop(),c=a.offset().top-b.offset().top;(0>c||c+a.height()>b.height())&&b.scrollTop(c+d)}function Y(a){if(g.save_state&&window.rcmail)return u||(u=rcmail.local_storage_get_item("treelist-"+
R,{})),u[a]}function aa(a,b,d){var c=a[0>b?"prev":"next"]();0<b&&!d&&a.children("ul[role=group]:visible").length?a.children("ul").children("li").first().find("a").first().focus():0>b&&!d&&c.children("ul[role=group]:visible").length?c.children("ul").children("li").last().find("a").first().focus():c.length&&c.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 M(a){if(a||!x){x=!0;var b,d=e.offset();ba=bw.ie?0:
window.pageYOffset;y=e.parent().scrollTop();d.top+=y;I=d.left;J=d.top;K=d.left+e.width();ca=d.top+e.height();G=[];for(var c in k)a=l(c),(a=a.children().first().get(0))&&(b=a.offsetHeight)&&(d=$(a).offset(),d.top+=y,G[c]={x1:d.left,y1:d.top,x2:d.left+a.offsetWidth,y2:d.top+b,on:c==v});if(e.height()>e.parent().height())e.parent().on("mousemove.treelist",function(a){var b=0;a=rcube_event.get_mouse_pos(a);a.y-=e.parent().offset().top;25>a.y&&0<y?b=-1:a.y>e.parent().height()-25&&(b=1);x&&0!=b?q||(q=window.setTimeout(function(){da(b)},
g.scroll_delay)):q&&(window.clearTimeout(q),q=null)}).on("mouseleave.treelist",function(){q&&(window.clearTimeout(q),q=null)})}}function ea(){e.parent().off(".treelist");$("li.droptarget",e).removeClass("droptarget");x&&(x=!1,q=null,r&&(clearTimeout(r),v=r=null))}function da(a){if(x){var b=y;e.parent().get(0).scrollTop+=g.scroll_step*a;y=e.parent().scrollTop();q=null;y!=b&&(q=window.setTimeout(function(){da(a)},g.scroll_speed))}}function fa(a,b){var d=bw.ie?-document.documentElement.scrollTop:ba,
c=e.parent().scrollTop(),f=null;a.top=a.y+c-d;if(a.x<I||a.x>=K||a.top<J||a.top>=ca)return b&&$("li.droptarget",e).removeClass("droptarget"),f;for(var h in G)d=G[h],a.x>=d.x1&&a.x<d.x2&&a.top>=d.y1&&a.top<d.y2?(f=k[h],f.children&&f.children.length&&f.collapsed&&g.autoexpand&&v!=h?(r&&clearTimeout(r),v=h,r=setTimeout(function(){S(v);M(!0);v=null;C&&$.ui.ddmanager.prepareOffsets($.ui.ddmanager.current,null)},g.autoexpand)):r&&v!=h&&(clearTimeout(r),r=v=null),g.check_droptarget(f)?(b&&(l(h).addClass("droptarget"),
d.on=!0),f=h):f=null):d.on&&(l(h).removeClass("droptarget"),d.on=!1);return f}function N(a){a||(a={});if("string"==$.type(a))return"destroy"==a&&(C=null),$("li:not(.virtual)",e).droppable(a),this;O=a;var b=$.extend({greedy:!0,tolerance:"pointer",hoverClass:"droptarget",addClasses:!1},a);b.activate=function(b,c){M();C=c;a.activate&&a.activate(b,c)};b.deactivate=function(b,c){ea();C=null;a.deactivate&&a.deactivate(b,c)};b.over=function(b,c){fa(rcube_event.get_mouse_pos(b),!1);a.over&&a.over(b,c)};$("li:not(.virtual)",
e).droppable(b);return this}function P(a){a||(a={});if("string"==$.type(a))return"destroy"==a&&(H=null),$("li:not(.virtual)",e).draggable(a),this;Q=a;a=$.extend({appendTo:"body",revert:"invalid",iframeFix:!0,addClasses:!1,cursorAt:{left:-20,top:5},create:function(a,d){H=d},helper:function(a){return $("<div>").attr("id","rcmdraglayer").text($.trim($(a.target).first().text()))}},a);$("li:not(.virtual)",e).draggable(a);return this}g=$.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}},g||{});var e=$(ha),p=g.data||[],k={},h=null,x=!1,m=!1,B="",D=!1;var ca=K=J=I=void 0;var G=[],r,v,ba=0,y=0,q,u,C,H,Q,O,R=e.attr("id")||g.id_prefix||"0",t=this;this.container=e;this.expand=S;this.collapse=w;this.expand_all=function(){$.each(k,function(a,b){0<b.children.length&&b.collapsed&&w(a,!1,!1)})};this.collapse_all=function(){$.each(k,function(a,b){0<b.children.length&&
!b.collapsed&&w(a)})};this.select=E;this.render=function(){if(!1!==t.triggerEvent("renderBefore",p)){e.html("");for(var a=0;a<p.length;a++)p[a].level=0,z(p[a],e);t.triggerEvent("renderAfter",e)}};this.reset=function(a,b){b||E("");p=[];k={};x=!1;a?(Q&&(H&&P("destroy"),P(Q)),O&&(C&&N("destroy"),N(O)),p=F(e,0)):e.html("");A(b)};this.drag_start=M;this.drag_end=ea;this.intersects=fa;this.droppable=N;this.draggable=P;this.is_draggable=function(){return!!H};this.update=function(a,b,d){var c,f,g=k[a];if(g){var h=
l(a);var m=h.parent();if(b.id||b.html||b.children||b.classes||b.parent)b.parent&&(c=k[b.parent])?(m.closest("li").length&&(f=k[n(m.closest("li"))])&&(f.children=$.grep(f.children,function(a,b){return a.id!=g.id})),m=l(b.parent).children("ul").first(),c.children||(c.children=[]),c.children.push(g)):void 0!==b.parent&&(m=e),$.extend(g,b),h=z(g,m,h);g.id!=a&&(delete k[a],k[g.id]=g);d&&W(h,"string"==typeof d?'[class~="'+d+'"]':"")}};this.insert=function(a,b,d){var c=b?k[b]:null;search_=m;k[a.id]||(state=
Y(a.id,a.collapsed),void 0!==state&&(a.collapsed=state),c?(a.level=c.level+1,c.children||(c.children=[]),m=!1,c.children.push(a),b=l(b),1==c.children.length?(z(c,null,b),c=l(a.id)):c=z(a,b.children("ul").first()),search_&&(m=search_,c.is(":visible")||$("<li>").attr("id",c.attr("id")+"--xsR").attr("class",c.attr("class")).addClass("searchresult__").append(c.children().first().clone(!0,!0)).appendTo(e))):(a.level=0,p.push(a),c=z(a,e)),k[a.id]=a,"object"==typeof a.html&&(k[a.id].html=l(a.id,!0).children()),
d&&W(c,"string"==typeof d?'[class~="'+d+'"]':""))};this.remove=function(a){var b;if(b=k[a]){var d=l(a,!0);var c=d.parent();d.remove();b.deleted=!0;delete k[a];m&&l(a,!1).remove();c.children().length||(c.parent().find("div.treetoggle").remove(),c.remove());return!0}return!1};this.get_item=V;this.get_node=function(a){return k[a]};this.get_selection=U;this.in_selection=function(a){return h==a};this.get_next=function(){var a;if(h&&(a=l(h))){var b=a.children("ul").children("li").first();if(b.length)return n(b);
b=a.next();if(b.length)return n(b);for(;(a=a.parent("ul").parent("li"))&&a.length;)if(b=a.next(),b.length)return n(b)}};this.get_prev=function(){var a;if(h&&(a=l(h))){var b=a.prev();var d=b.find("li").last();if(d.length)return n(d);if(b.length)return n(b);a=a.parent().parent();if(a.length&&a.is("li"))return n(a)}};this.get_single_selection=U;this.is_search=function(){return m};this.reset_search=A;if(e.length){g.data?Z({children:p}):p=F(e,0);h&&T(l(h,!0));e.attr("role","tree").on("focusin",function(a){D=
!0}).on("focusout",function(a){D=!1}).on("click","div.treetoggle",function(a){var b=n($(this).parent()),d;(d=k[b])&&w(b,void 0,!d.collapsed);a.stopPropagation()}).on("click","li",function(a){if($(a.target).is("input"))return!0;var b=g.selectable?k[n($(this))]:null;b&&(b.virtual||E(b.id),a.stopPropagation())}).on("mousedown","a",function(a){var b=$(a.target),d=k[n(b.closest("li"))];if(d&&d.virtual&&!b.attr("href"))return a.preventDefault(),a.stopPropagation(),!1});if(g.searchbox){var L=$(g.searchbox).off("keyup.treelist").on("keyup.treelist",
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:A();break;case 38:case 37:case 39:case 40:break;default:X(this.value,!1)}}).attr("autocomplete","off");L.parent().find("a.reset").off("click.treelist").on("click.treelist",function(a){A();return!1})}$(document.body).on("keydown",function(a){var b=a.target||{},d=rcube_event.get_keycode(a);if(!D||"INPUT"==b.nodeName&&38!=d&&40!=d||"TEXTAREA"==
b.nodeName||"SELECT"==b.nodeName)return!0;switch(d){case 38:case 40:case 63232:case 63233:return b=g.keyboard?e.find(":focus").closest("li"):[],b.length&&aa(b,mod=38==d||63232==d?-1:1),rcube_event.cancel(a);case 37:case 39:var c;b=e.find(":focus").closest("li");if(b.length&&(b=n(b),(c=k[b])&&c.children.length&&c.collapsed!=(37==d))){a=rcube_event.get_modifier(a)==SHIFT_KEY;var f;(f=k[b])&&w(b,a,!f.collapsed)}return!1;case 9:g.keyboard&&g.tabexit&&(f=rcube_event.get_modifier(a)==SHIFT_KEY?"first":
"last",f=e.find("li[role=treeitem]:has(a)")[f]().find("a:"+f),f.length&&(a=e.parent().get(0)||{scrollTop:0},d=a.scrollTop||a.scrollY,f.focus(),a.scrollTop=d))}return!0});g.parent_focus&&e.parent(":not(body)").click(function(a){if($(a.target).is("input"))return!0;!D&&h?$(V(h)).find(":focusable").first().focus():D||e.children("li").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;