/** * jQuery EasyUI 1.3.5 * * Copyright (c) 2009-2013 www.jeasyui.com. All rights reserved. * * Licensed under the GPL or commercial licenses * To use it on other terms please contact us: info@jeasyui.com * http://www.gnu.org/licenses/gpl.txt * http://www.jeasyui.com/license_commercial.php * */ (function($){ function _1(_2){ var _3=$(_2); _3.addClass("tree"); return _3; }; function _4(_5){ var _6=$.data(_5,"tree").options; $(_5).unbind().bind("mouseover",function(e){ var tt=$(e.target); var _7=tt.closest("div.tree-node"); if(!_7.length){ return; } _7.addClass("tree-node-hover"); if(tt.hasClass("tree-hit")){ if(tt.hasClass("tree-expanded")){ tt.addClass("tree-expanded-hover"); }else{ tt.addClass("tree-collapsed-hover"); } } e.stopPropagation(); }).bind("mouseout",function(e){ var tt=$(e.target); var _8=tt.closest("div.tree-node"); if(!_8.length){ return; } _8.removeClass("tree-node-hover"); if(tt.hasClass("tree-hit")){ if(tt.hasClass("tree-expanded")){ tt.removeClass("tree-expanded-hover"); }else{ tt.removeClass("tree-collapsed-hover"); } } e.stopPropagation(); }).bind("click",function(e){ var tt=$(e.target); var _9=tt.closest("div.tree-node"); if(!_9.length){ return; } if(tt.hasClass("tree-hit")){ _7e(_5,_9[0]); return false; }else{ if(tt.hasClass("tree-checkbox")){ _32(_5,_9[0],!tt.hasClass("tree-checkbox1")); return false; }else{ _d6(_5,_9[0]); _6.onClick.call(_5,_c(_5,_9[0])); } } e.stopPropagation(); }).bind("dblclick",function(e){ var _a=$(e.target).closest("div.tree-node"); if(!_a.length){ return; } _d6(_5,_a[0]); _6.onDblClick.call(_5,_c(_5,_a[0])); e.stopPropagation(); }).bind("contextmenu",function(e){ var _b=$(e.target).closest("div.tree-node"); if(!_b.length){ return; } _6.onContextMenu.call(_5,e,_c(_5,_b[0])); e.stopPropagation(); }); }; function _d(_e){ var _f=$.data(_e,"tree").options; _f.dnd=false; var _10=$(_e).find("div.tree-node"); _10.draggable("disable"); _10.css("cursor","pointer"); }; function _11(_12){ var _13=$.data(_12,"tree"); var _14=_13.options; var _15=_13.tree; _13.disabledNodes=[]; _14.dnd=true; _15.find("div.tree-node").draggable({disabled:false,revert:true,cursor:"pointer",proxy:function(_16){ var p=$("
").appendTo("body"); p.html(" "+$(_16).find(".tree-title").html()); p.hide(); return p; },deltaX:15,deltaY:15,onBeforeDrag:function(e){ if(_14.onBeforeDrag.call(_12,_c(_12,this))==false){ return false; } if($(e.target).hasClass("tree-hit")||$(e.target).hasClass("tree-checkbox")){ return false; } if(e.which!=1){ return false; } $(this).next("ul").find("div.tree-node").droppable({accept:"no-accept"}); var _17=$(this).find("span.tree-indent"); if(_17.length){ e.data.offsetWidth-=_17.length*_17.width(); } },onStartDrag:function(){ $(this).draggable("proxy").css({left:-10000,top:-10000}); _14.onStartDrag.call(_12,_c(_12,this)); var _18=_c(_12,this); if(_18.id==undefined){ _18.id="easyui_tree_node_id_temp"; _54(_12,_18); } _13.draggingNodeId=_18.id; },onDrag:function(e){ var x1=e.pageX,y1=e.pageY,x2=e.data.startX,y2=e.data.startY; var d=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); if(d>3){ $(this).draggable("proxy").show(); } this.pageY=e.pageY; },onStopDrag:function(){ $(this).next("ul").find("div.tree-node").droppable({accept:"div.tree-node"}); for(var i=0;i<_13.disabledNodes.length;i++){ $(_13.disabledNodes[i]).droppable("enable"); } _13.disabledNodes=[]; var _19=_c9(_12,_13.draggingNodeId); if(_19&&_19.id=="easyui_tree_node_id_temp"){ _19.id=""; _54(_12,_19); } _14.onStopDrag.call(_12,_19); }}).droppable({accept:"div.tree-node",onDragEnter:function(e,_1a){ if(_14.onDragEnter.call(_12,this,_c(_12,_1a))==false){ _1b(_1a,false); $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); $(this).droppable("disable"); _13.disabledNodes.push(this); } },onDragOver:function(e,_1c){ if($(this).droppable("options").disabled){ return; } var _1d=_1c.pageY; var top=$(this).offset().top; var _1e=top+$(this).outerHeight(); _1b(_1c,true); $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); if(_1d>top+(_1e-top)/2){ if(_1e-_1d<5){ $(this).addClass("tree-node-bottom"); }else{ $(this).addClass("tree-node-append"); } }else{ if(_1d-top<5){ $(this).addClass("tree-node-top"); }else{ $(this).addClass("tree-node-append"); } } if(_14.onDragOver.call(_12,this,_c(_12,_1c))==false){ _1b(_1c,false); $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); $(this).droppable("disable"); _13.disabledNodes.push(this); } },onDragLeave:function(e,_1f){ _1b(_1f,false); $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); _14.onDragLeave.call(_12,this,_c(_12,_1f)); },onDrop:function(e,_20){ var _21=this; var _22,_23; if($(this).hasClass("tree-node-append")){ _22=_24; _23="append"; }else{ _22=_25; _23=$(this).hasClass("tree-node-top")?"top":"bottom"; } if(_14.onBeforeDrop.call(_12,_21,_c2(_12,_20),_23)==false){ $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); return; } _22(_20,_21,_23); $(this).removeClass("tree-node-append tree-node-top tree-node-bottom"); }}); function _1b(_26,_27){ var _28=$(_26).draggable("proxy").find("span.tree-dnd-icon"); _28.removeClass("tree-dnd-yes tree-dnd-no").addClass(_27?"tree-dnd-yes":"tree-dnd-no"); }; function _24(_29,_2a){ if(_c(_12,_2a).state=="closed"){ _72(_12,_2a,function(){ _2b(); }); }else{ _2b(); } function _2b(){ var _2c=$(_12).tree("pop",_29); $(_12).tree("append",{parent:_2a,data:[_2c]}); _14.onDrop.call(_12,_2a,_2c,"append"); }; }; function _25(_2d,_2e,_2f){ var _30={}; if(_2f=="top"){ _30.before=_2e; }else{ _30.after=_2e; } var _31=$(_12).tree("pop",_2d); _30.data=_31; $(_12).tree("insert",_30); _14.onDrop.call(_12,_2e,_31,_2f); }; }; function _32(_33,_34,_35){ var _36=$.data(_33,"tree").options; if(!_36.checkbox){ return; } var _37=_c(_33,_34); if(_36.onBeforeCheck.call(_33,_37,_35)==false){ return; } var _38=$(_34); var ck=_38.find(".tree-checkbox"); ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2"); if(_35){ ck.addClass("tree-checkbox1"); }else{ ck.addClass("tree-checkbox0"); } if(_36.cascadeCheck){ _39(_38); _3a(_38); } _36.onCheck.call(_33,_37,_35); function _3a(_3b){ var _3c=_3b.next().find(".tree-checkbox"); _3c.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2"); if(_3b.find(".tree-checkbox").hasClass("tree-checkbox1")){ _3c.addClass("tree-checkbox1"); }else{ _3c.addClass("tree-checkbox0"); } }; function _39(_3d){ var _3e=_89(_33,_3d[0]); if(_3e){ var ck=$(_3e.target).find(".tree-checkbox"); ck.removeClass("tree-checkbox0 tree-checkbox1 tree-checkbox2"); if(_3f(_3d)){ ck.addClass("tree-checkbox1"); }else{ if(_40(_3d)){ ck.addClass("tree-checkbox0"); }else{ ck.addClass("tree-checkbox2"); } } _39($(_3e.target)); } function _3f(n){ var ck=n.find(".tree-checkbox"); if(ck.hasClass("tree-checkbox0")||ck.hasClass("tree-checkbox2")){ return false; } var b=true; n.parent().siblings().each(function(){ if(!$(this).children("div.tree-node").children(".tree-checkbox").hasClass("tree-checkbox1")){ b=false; } }); return b; }; function _40(n){ var ck=n.find(".tree-checkbox"); if(ck.hasClass("tree-checkbox1")||ck.hasClass("tree-checkbox2")){ return false; } var b=true; n.parent().siblings().each(function(){ if(!$(this).children("div.tree-node").children(".tree-checkbox").hasClass("tree-checkbox0")){ b=false; } }); return b; }; }; }; function _41(_42,_43){ var _44=$.data(_42,"tree").options; if(!_44.checkbox){ return; } var _45=$(_43); if(_46(_42,_43)){ var ck=_45.find(".tree-checkbox"); if(ck.length){ if(ck.hasClass("tree-checkbox1")){ _32(_42,_43,true); }else{ _32(_42,_43,false); } }else{ if(_44.onlyLeafCheck){ $("").insertBefore(_45.find(".tree-title")); } } }else{ var ck=_45.find(".tree-checkbox"); if(_44.onlyLeafCheck){ ck.remove(); }else{ if(ck.hasClass("tree-checkbox1")){ _32(_42,_43,true); }else{ if(ck.hasClass("tree-checkbox2")){ var _47=true; var _48=true; var _49=_4a(_42,_43); for(var i=0;i<_49.length;i++){ if(_49[i].checked){ _48=false; }else{ _47=false; } } if(_47){ _32(_42,_43,true); } if(_48){ _32(_42,_43,false); } } } } } }; function _4b(_4c,ul,_4d,_4e){ var _4f=$.data(_4c,"tree"); var _50=_4f.options; var _51=$(ul).prevAll("div.tree-node:first"); _4d=_50.loadFilter.call(_4c,_4d,_51[0]); var _52=_53(_4c,"domId",_51.attr("id")); if(!_4e){ _52?_52.children=_4d:_4f.data=_4d; $(ul).empty(); }else{ if(_52){ _52.children?_52.children=_52.children.concat(_4d):_52.children=_4d; }else{ _4f.data=_4f.data.concat(_4d); } } _50.view.render.call(_50.view,_4c,ul,_4d); if(_50.dnd){ _11(_4c); } if(_52){ _54(_4c,_52); } var _55=[]; var _56=[]; for(var i=0;i<_4d.length;i++){ var _57=_4d[i]; if(!_57.checked){ _55.push(_57); } } _58(_4d,function(_59){ if(_59.checked){ _56.push(_59); } }); if(_55.length){ _32(_4c,$("#"+_55[0].domId)[0],false); } for(var i=0;i<_56.length;i++){ _32(_4c,$("#"+_56[i].domId)[0],true); } setTimeout(function(){ _5a(_4c,_4c); },0); _50.onLoadSuccess.call(_4c,_52,_4d); }; function _5a(_5b,ul,_5c){ var _5d=$.data(_5b,"tree").options; if(_5d.lines){ $(_5b).addClass("tree-lines"); }else{ $(_5b).removeClass("tree-lines"); return; } if(!_5c){ _5c=true; $(_5b).find("span.tree-indent").removeClass("tree-line tree-join tree-joinbottom"); $(_5b).find("div.tree-node").removeClass("tree-node-last tree-root-first tree-root-one"); var _5e=$(_5b).tree("getRoots"); if(_5e.length>1){ $(_5e[0].target).addClass("tree-root-first"); }else{ if(_5e.length==1){ $(_5e[0].target).addClass("tree-root-one"); } } } $(ul).children("li").each(function(){ var _5f=$(this).children("div.tree-node"); var ul=_5f.next("ul"); if(ul.length){ if($(this).next().length){ _60(_5f); } _5a(_5b,ul,_5c); }else{ _61(_5f); } }); var _62=$(ul).children("li:last").children("div.tree-node").addClass("tree-node-last"); _62.children("span.tree-join").removeClass("tree-join").addClass("tree-joinbottom"); function _61(_63,_64){ var _65=_63.find("span.tree-icon"); _65.prev("span.tree-indent").addClass("tree-join"); }; function _60(_66){ var _67=_66.find("span.tree-indent, span.tree-hit").length; _66.next().find("div.tree-node").each(function(){ $(this).children("span:eq("+(_67-1)+")").addClass("tree-line"); }); }; }; function _68(_69,ul,_6a,_6b){ var _6c=$.data(_69,"tree").options; _6a=_6a||{}; var _6d=null; if(_69!=ul){ var _6e=$(ul).prev(); _6d=_c(_69,_6e[0]); } if(_6c.onBeforeLoad.call(_69,_6d,_6a)==false){ return; } var _6f=$(ul).prev().children("span.tree-folder"); _6f.addClass("tree-loading"); var _70=_6c.loader.call(_69,_6a,function(_71){ _6f.removeClass("tree-loading"); _4b(_69,ul,_71); if(_6b){ _6b(); } },function(){ _6f.removeClass("tree-loading"); _6c.onLoadError.apply(_69,arguments); if(_6b){ _6b(); } }); if(_70==false){ _6f.removeClass("tree-loading"); } }; function _72(_73,_74,_75){ var _76=$.data(_73,"tree").options; var hit=$(_74).children("span.tree-hit"); if(hit.length==0){ return; } if(hit.hasClass("tree-expanded")){ return; } var _77=_c(_73,_74); if(_76.onBeforeExpand.call(_73,_77)==false){ return; } hit.removeClass("tree-collapsed tree-collapsed-hover").addClass("tree-expanded"); hit.next().addClass("tree-folder-open"); var ul=$(_74).next(); if(ul.length){ if(_76.animate){ ul.slideDown("normal",function(){ _77.state="open"; _76.onExpand.call(_73,_77); if(_75){ _75(); } }); }else{ ul.css("display","block"); _77.state="open"; _76.onExpand.call(_73,_77); if(_75){ _75(); } } }else{ var _78=$(" ").insertAfter(_74); _68(_73,_78[0],{id:_77.id},function(){ if(_78.is(":empty")){ _78.remove(); } if(_76.animate){ _78.slideDown("normal",function(){ _77.state="open"; _76.onExpand.call(_73,_77); if(_75){ _75(); } }); }else{ _78.css("display","block"); _77.state="open"; _76.onExpand.call(_73,_77); if(_75){ _75(); } } }); } }; function _79(_7a,_7b){ var _7c=$.data(_7a,"tree").options; var hit=$(_7b).children("span.tree-hit"); if(hit.length==0){ return; } if(hit.hasClass("tree-collapsed")){ return; } var _7d=_c(_7a,_7b); if(_7c.onBeforeCollapse.call(_7a,_7d)==false){ return; } hit.removeClass("tree-expanded tree-expanded-hover").addClass("tree-collapsed"); hit.next().removeClass("tree-folder-open"); var ul=$(_7b).next(); if(_7c.animate){ ul.slideUp("normal",function(){ _7d.state="closed"; _7c.onCollapse.call(_7a,_7d); }); }else{ ul.css("display","none"); _7d.state="closed"; _7c.onCollapse.call(_7a,_7d); } }; function _7e(_7f,_80){ var hit=$(_80).children("span.tree-hit"); if(hit.length==0){ return; } if(hit.hasClass("tree-expanded")){ _79(_7f,_80); }else{ _72(_7f,_80); } }; function _81(_82,_83){ var _84=_4a(_82,_83); if(_83){ _84.unshift(_c(_82,_83)); } for(var i=0;i<_84.length;i++){ _72(_82,_84[i].target); } }; function _85(_86,_87){ var _88=[]; var p=_89(_86,_87); while(p){ _88.unshift(p); p=_89(_86,p.target); } for(var i=0;i<_88.length;i++){ _72(_86,_88[i].target); } }; function _8a(_8b,_8c){ var c=$(_8b).parent(); while(c[0].tagName!="BODY"&&c.css("overflow-y")!="auto"){ c=c.parent(); } var n=$(_8c); var _8d=n.offset().top; if(c[0].tagName!="BODY"){ var _8e=c.offset().top; if(_8d<_8e){ c.scrollTop(c.scrollTop()+_8d-_8e); }else{ if(_8d+n.outerHeight()>_8e+c.outerHeight()-18){ c.scrollTop(c.scrollTop()+_8d+n.outerHeight()-_8e-c.outerHeight()+18); } } }else{ c.scrollTop(_8d); } }; function _8f(_90,_91){ var _92=_4a(_90,_91); if(_91){ _92.unshift(_c(_90,_91)); } for(var i=0;i<_92.length;i++){ _79(_90,_92[i].target); } }; function _93(_94,_95){ var _96=$(_95.parent); var _97=_95.data; if(!_97){ return; } _97=$.isArray(_97)?_97:[_97]; if(!_97.length){ return; } var ul; if(_96.length==0){ ul=$(_94); }else{ if(_46(_94,_96[0])){ var _98=_96.find("span.tree-icon"); _98.removeClass("tree-file").addClass("tree-folder tree-folder-open"); var hit=$("").insertBefore(_98); if(hit.prev().length){ hit.prev().remove(); } } ul=_96.next(); if(!ul.length){ ul=$("