(function(f){var B={event:{DRAG:"ztree_drag",DROP:"ztree_drop",REMOVE:"ztree_remove",RENAME:"ztree_rename"},id:{EDIT:"_edit",INPUT:"_input",REMOVE:"_remove"},move:{TYPE_INNER:"inner",TYPE_PREV:"prev",TYPE_NEXT:"next"},node:{CURSELECTED_EDIT:"curSelectedNode_Edit",TMPTARGET_TREE:"tmpTargetzTree",TMPTARGET_NODE:"tmpTargetNode"}},l={edit:{enable:false,editNameSelectAll:false,showRemoveBtn:true,showRenameBtn:true,removeTitle:"remove",renameTitle:"rename",drag:{autoExpandTrigger:false,isCopy:true,isMove:true,prev:true,next:true,inner:true,minMoveSize:5,borderMax:10,borderMin:-5,maxShowNodeNum:5,autoOpenTime:500}},view:{addHoverDom:null,removeHoverDom:null},callback:{beforeDrag:null,beforeDragOpen:null,beforeDrop:null,beforeEditName:null,beforeRename:null,onDrag:null,onDrop:null,onRename:null}},w=function(C){var D=z.getRoot(C);D.curEditNode=null;D.curEditInput=null;D.curHoverNode=null;D.dragFlag=0;D.dragNodeShowBefore=[];D.dragMaskList=new Array();D.showHoverDom=true},c=function(C){},m=function(C){var D=C.treeObj;var E=p.event;D.bind(E.RENAME,function(F,H,G){u.apply(C.callback.onRename,[F,H,G])});D.bind(E.REMOVE,function(F,H,G){u.apply(C.callback.onRemove,[F,H,G])});D.bind(E.DRAG,function(G,F,I,H){u.apply(C.callback.onDrag,[F,I,H])});D.bind(E.DROP,function(I,H,K,J,L,G,F){u.apply(C.callback.onDrop,[H,K,J,L,G,F])})},y=function(C){var D=C.treeObj;var E=p.event;D.unbind(E.RENAME);D.unbind(E.REMOVE);D.unbind(E.DRAG);D.unbind(E.DROP)},n=function(J){var K=J.target,N=z.getSetting(J.data.treeId),L=J.relatedTarget,H="",D=null,E="",I="",C=null,G=null,F=null;if(u.eqs(J.type,"mouseover")){F=u.getMDom(N,K,[{tagName:"a",attrName:"treeNode"+p.id.A}]);if(F){H=F.parentNode.id;E="hoverOverNode"}}else{if(u.eqs(J.type,"mouseout")){F=u.getMDom(N,L,[{tagName:"a",attrName:"treeNode"+p.id.A}]);if(!F){H="remove";E="hoverOutNode"}}else{if(u.eqs(J.type,"mousedown")){F=u.getMDom(N,K,[{tagName:"a",attrName:"treeNode"+p.id.A}]);if(F){H=F.parentNode.id;E="mousedownNode"}}}}if(H.length>0){D=z.getNodeCache(N,H);switch(E){case"mousedownNode":C=k.onMousedownNode;break;case"hoverOverNode":C=k.onHoverOverNode;break;case"hoverOutNode":C=k.onHoverOutNode;break}}var M={stop:false,node:D,nodeEventType:E,nodeEventCallback:C,treeEventType:I,treeEventCallback:G};return M},v=function(E,I,H,C,G,D,F){if(!H){return}H.isHover=false;H.editNameFlag=false},j=function(D,C){C.cancelEditName=function(F){var E=z.getRoot(D),G=D.data.key.name,H=E.curEditNode;if(!E.curEditNode){return}i.cancelCurEditNode(D,F?F:H[G])};C.copyNode=function(I,H,G,J){if(!H){return null}if(I&&!I.isParent&&D.data.keep.leaf&&G===p.move.TYPE_INNER){return null}var E=u.clone(H);if(!I){I=null;G=p.move.TYPE_INNER}if(G==p.move.TYPE_INNER){function F(){i.addNodes(D,I,[E],J)}if(u.canAsync(D,I)){i.asyncNode(D,I,J,F)}else{F()}}else{i.addNodes(D,I.parentNode,[E],J);i.moveNode(D,I,E,G,false,J)}return E};C.editName=function(E){if(!E||!E.tId||E!==z.getNodeCache(D,E.tId)){return}if(E.parentTId){i.expandCollapseParentNode(D,E.getParentNode(),true)}i.editNode(D,E)};C.moveNode=function(G,F,E,I){if(!F){return F}if(G&&!G.isParent&&D.data.keep.leaf&&E===p.move.TYPE_INNER){return null}else{if(G&&((F.parentTId==G.tId&&E==p.move.TYPE_INNER)||f("#"+F.tId).find("#"+G.tId).length>0)){return null}else{if(!G){G=null}}}function H(){i.moveNode(D,G,F,E,false,I)}if(u.canAsync(D,G)&&E===p.move.TYPE_INNER){i.asyncNode(D,G,I,H)}else{H()}return F};C.setEditable=function(E){D.edit.enable=E;return this.refresh()}},o={setSonNodeLevel:function(F,C,H){if(!H){return}var G=F.data.key.children;H.level=(C)?C.level+1:0;if(!H[G]){return}for(var E=0,D=H[G].length;E1){var ar=P[0].parentTId?P[0].getParentNode()[aM]:z.getNodes(N);aF=[];for(aW=0,aS=ar.length;aW-1&&(ah+1)!==aW){ae=false}aF.push(ar[aW]);ah=aW}if(P.length===aF.length){P=aF;break}}}if(ae){C=P[0].getPreNode();G=P[P.length-1].getNextNode()}V=f("");for(aW=0,aS=P.length;aW0);i.removeTreeDom(N,au);aN=f("
  • ");aN.append(f("#"+au.tId+p.id.A).clone());aN.css("padding","0");aN.children("#"+au.tId+p.id.A).removeClass(p.node.CURSELECTED);V.append(aN);if(aW==N.edit.drag.maxShowNodeNum-1){aN=f("
  • ...
  • ");V.append(aN);break}}V.attr("id",P[0].tId+p.id.UL+"_tmp");V.addClass(N.treeObj.attr("class"));V.appendTo("body");J=f("");J.attr("id","zTreeMove_arrow_tmp");J.appendTo("body");N.treeObj.trigger(p.event.DRAG,[a1,N.treeId,P])}if(S.dragFlag==1){if(X&&J.attr("id")==a1.target.id&&M&&(a1.clientX+ac.scrollLeft()+2)>(f("#"+M+p.id.A,X).offset().left)){var a0=f("#"+M+p.id.A,X);a1.target=(a0.length>0)?a0.get(0):a1.target}else{if(X){X.removeClass(p.node.TMPTARGET_TREE);if(M){f("#"+M+p.id.A,X).removeClass(p.node.TMPTARGET_NODE+"_"+p.move.TYPE_PREV).removeClass(p.node.TMPTARGET_NODE+"_"+B.move.TYPE_NEXT).removeClass(p.node.TMPTARGET_NODE+"_"+B.move.TYPE_INNER)}}}X=null;M=null;Y=false;aa=N;var aX=z.getSettings();for(var aO in aX){if(aX[aO].treeId&&aX[aO].edit.enable&&aX[aO].treeId!=N.treeId&&(a1.target.id==aX[aO].treeId||f(a1.target).parents("#"+aX[aO].treeId).length>0)){Y=true;aa=aX[aO]}}var aq=ac.scrollTop(),aZ=ac.scrollLeft(),af=aa.treeObj.offset(),az=aa.treeObj.get(0).scrollHeight,aP=aa.treeObj.get(0).scrollWidth,aY=(a1.clientY+aq-af.top),aL=(aa.treeObj.height()+af.top-a1.clientY-aq),aG=(a1.clientX+aZ-af.left),ap=(aa.treeObj.width()+af.left-a1.clientX-aZ),at=(aYN.edit.drag.borderMin),a2=(aLN.edit.drag.borderMin),aJ=(aGN.edit.drag.borderMin),an=(apN.edit.drag.borderMin),ag=aY>N.edit.drag.borderMin&&aL>N.edit.drag.borderMin&&aG>N.edit.drag.borderMin&&ap>N.edit.drag.borderMin,aD=(at&&aa.treeObj.scrollTop()<=0),aC=(a2&&(aa.treeObj.scrollTop()+aa.treeObj.height()+10)>=az),aj=(aJ&&aa.treeObj.scrollLeft()<=0),ax=(an&&(aa.treeObj.scrollLeft()+aa.treeObj.width()+10)>=aP);if(a1.target.id&&aa.treeObj.find("#"+a1.target.id).length>0){var ao=a1.target;while(ao&&ao.tagName&&!u.eqs(ao.tagName,"li")&&ao.id!=aa.treeId){ao=ao.parentNode}var aw=true;for(aW=0,aS=P.length;aW0){aw=false;break}}}if(aw){if(a1.target.id&&(a1.target.id==(ao.id+p.id.A)||f(a1.target).parents("#"+ao.id+p.id.A).length>0)){X=f(ao);M=ao.id}}}au=P[0];if(ag&&(a1.target.id==aa.treeId||f(a1.target).parents("#"+aa.treeId).length>0)){if(!X&&(a1.target.id==aa.treeId||aD||aC||aj||ax)&&(Y||(!Y&&au.parentTId))){X=aa.treeObj}if(at){aa.treeObj.scrollTop(aa.treeObj.scrollTop()-10)}else{if(a2){aa.treeObj.scrollTop(aa.treeObj.scrollTop()+10)}}if(aJ){aa.treeObj.scrollLeft(aa.treeObj.scrollLeft()-10)}else{if(an){aa.treeObj.scrollLeft(aa.treeObj.scrollLeft()+10)}}if(X&&X!=aa.treeObj&&X.offset().left=-0.2)&&aH){aB=1-J.width();aA=aT-J.height()/2;D=p.move.TYPE_PREV}else{if((am==0||ai>=am&&ai<=1.2)&&ak){aB=1-J.width();aA=(aR==null||(aK.isParent&&aK.open))?(aT+ay.height()-J.height()/2):(aR.offset().top-J.height()/2);D=p.move.TYPE_NEXT}else{aB=5-J.width();aA=aT;D=p.move.TYPE_INNER}}J.css({display:"block",top:aA+"px",left:(aV+aB)+"px"});ay.addClass(p.node.TMPTARGET_NODE+"_"+D);if(Q!=M||F!=D){K=(new Date()).getTime()}if(aK&&aK.isParent&&D==p.move.TYPE_INNER){var av=true;if(window.zTreeMoveTimer&&window.zTreeMoveTargetNodeTId!==aK.tId){clearTimeout(window.zTreeMoveTimer);window.zTreeMoveTargetNodeTId=null}else{if(window.zTreeMoveTimer&&window.zTreeMoveTargetNodeTId===aK.tId){av=false}}if(av){window.zTreeMoveTimer=setTimeout(function(){if(D!=p.move.TYPE_INNER){return}if(aK&&aK.isParent&&!aK.open&&(new Date()).getTime()-K>aa.edit.drag.autoOpenTime&&u.apply(aa.callback.beforeDragOpen,[aa.treeId,aK],true)){i.switchNode(aa,aK);if(aa.edit.drag.autoExpandTrigger){aa.treeObj.trigger(p.event.EXPAND,[aa.treeId,aK])}}},aa.edit.drag.autoOpenTime+50);window.zTreeMoveTargetNodeTId=aK.tId}}}}else{D=p.move.TYPE_INNER;if(X&&u.apply(aa.edit.drag.inner,[aa.treeId,P,null],!!aa.edit.drag.inner)){X.addClass(p.node.TMPTARGET_TREE)}else{X=null}J.css({display:"none"});if(window.zTreeMoveTimer){clearTimeout(window.zTreeMoveTimer);window.zTreeMoveTargetNodeTId=null}}Q=M;F=D}return false}ac.bind("mouseup",ab);function ab(ak){if(window.zTreeMoveTimer){clearTimeout(window.zTreeMoveTimer);window.zTreeMoveTargetNodeTId=null}Q=null;F=null;ac.unbind("mousemove",L);ac.unbind("mouseup",ab);ac.unbind("selectstart",E);f("body").css("cursor","auto");if(X){X.removeClass(p.node.TMPTARGET_TREE);if(M){f("#"+M+p.id.A,X).removeClass(p.node.TMPTARGET_NODE+"_"+p.move.TYPE_PREV).removeClass(p.node.TMPTARGET_NODE+"_"+B.move.TYPE_NEXT).removeClass(p.node.TMPTARGET_NODE+"_"+B.move.TYPE_INNER)}}u.showIfameMask(N,false);S.showHoverDom=true;if(S.dragFlag==0){return}S.dragFlag=0;var ai,ae,aj;for(ai=0,ae=P.length;ai0)}f("#"+ag[0].tId).focus().blur();N.treeObj.trigger(p.event.DROP,[ak,aa.treeId,ag,af,D,ad])}if(D==p.move.TYPE_INNER&&u.canAsync(aa,af)){i.asyncNode(aa,af,false,ah)}else{ah()}}else{for(ai=0,ae=P.length;ai0)}N.treeObj.trigger(p.event.DROP,[ak,N.treeId,P,null,null,null])}}ac.bind("selectstart",E);function E(){return false}if(O.preventDefault){O.preventDefault()}return true}},h={getAbs:function(C){var D=C.getBoundingClientRect();return[D.left,D.top]},inputFocus:function(C){if(C.get(0)){C.focus();u.setCursorPosition(C.get(0),C.val().length)}},inputSelect:function(C){if(C.get(0)){C.focus();C.select()}},setCursorPosition:function(D,E){if(D.setSelectionRange){D.focus();D.setSelectionRange(E,E)}else{if(D.createTextRange){var C=D.createTextRange();C.collapse(true);C.moveEnd("character",E);C.moveStart("character",E);C.select()}}},showIfameMask:function(J,H){var G=z.getRoot(J);while(G.dragMaskList.length>0){G.dragMaskList[0].remove();G.dragMaskList.shift()}if(H){var K=f("iframe");for(var F=0,D=K.length;F");I.appendTo("body");G.dragMaskList.push(I)}}}},d={addEditBtn:function(D,E){if(E.editNameFlag||f("#"+E.tId+p.id.EDIT).length>0){return}if(!u.apply(D.edit.showRenameBtn,[D.treeId,E],D.edit.showRenameBtn)){return}var F=f("#"+E.tId+p.id.A),C="";F.append(C);f("#"+E.tId+p.id.EDIT).bind("click",function(){if(!u.uCanDo(D)||u.apply(D.callback.beforeEditName,[D.treeId,E],true)==false){return false}i.editNode(D,E);return false}).show()},addRemoveBtn:function(C,D){if(D.editNameFlag||f("#"+D.tId+p.id.REMOVE).length>0){return}if(!u.apply(C.edit.showRemoveBtn,[C.treeId,D],C.edit.showRemoveBtn)){return}var F=f("#"+D.tId+p.id.A),E="";F.append(E);f("#"+D.tId+p.id.REMOVE).bind("click",function(){if(!u.uCanDo(C)||u.apply(C.callback.beforeRemove,[C.treeId,D],true)==false){return false}i.removeNode(C,D);C.treeObj.trigger(p.event.REMOVE,[C.treeId,D]);return false}).bind("mousedown",function(G){return true}).show()},addHoverDom:function(C,D){if(z.getRoot(C).showHoverDom){D.isHover=true;if(C.edit.enable){i.addEditBtn(C,D);i.addRemoveBtn(C,D)}u.apply(C.view.addHoverDom,[C.treeId,D])}},cancelCurEditNode:function(H,F){var D=z.getRoot(H),G=H.data.key.name,I=D.curEditNode;if(I){var E=D.curEditInput;var C=F?F:E.val();if(!F&&u.apply(H.callback.beforeRename,[H.treeId,I,C],true)===false){return false}else{I[G]=C?C:E.val();if(!F){H.treeObj.trigger(p.event.RENAME,[H.treeId,I])}}var J=f("#"+I.tId+p.id.A);J.removeClass(p.node.CURSELECTED_EDIT);E.unbind();i.setNodeName(H,I);I.editNameFlag=false;D.curEditNode=null;D.curEditInput=null;i.selectNode(H,I,false)}D.noSelection=true;return true},editNode:function(F,G){var C=z.getRoot(F);i.editNodeBlur=false;if(z.isSelectedNode(F,G)&&C.curEditNode==G&&G.editNameFlag){setTimeout(function(){u.inputFocus(C.curEditInput)},0);return}var E=F.data.key.name;G.editNameFlag=true;i.removeTreeDom(F,G);i.cancelCurEditNode(F);i.selectNode(F,G,false);f("#"+G.tId+p.id.SPAN).html("");var D=f("#"+G.tId+p.id.INPUT);D.attr("value",G[E]);if(F.edit.editNameSelectAll){u.inputSelect(D)}else{u.inputFocus(D)}D.bind("blur",function(H){if(!i.editNodeBlur){i.cancelCurEditNode(F)}}).bind("keydown",function(H){if(H.keyCode=="13"){i.editNodeBlur=true;i.cancelCurEditNode(F,null,true)}else{if(H.keyCode=="27"){i.cancelCurEditNode(F,G[E])}}}).bind("click",function(H){return false}).bind("dblclick",function(H){return false});f("#"+G.tId+p.id.A).addClass(p.node.CURSELECTED_EDIT);C.curEditInput=D;C.noSelection=false;C.curEditNode=G},moveNode:function(M,F,P,E,aa,G){var R=z.getRoot(M),K=M.data.key.children;if(F==P){return}if(M.data.keep.leaf&&F&&!F.isParent&&E==p.move.TYPE_INNER){return}var U=(P.parentTId?P.getParentNode():R),O=(F===null||F==R);if(O&&F===null){F=R}if(O){E=p.move.TYPE_INNER}var C=(F.parentTId?F.getParentNode():R);if(E!=p.move.TYPE_PREV&&E!=p.move.TYPE_NEXT){E=p.move.TYPE_INNER}if(E==p.move.TYPE_INNER){if(O){P.parentTId=null}else{if(!F.isParent){F.isParent=true;F.open=!!F.open;i.setNodeLineIcos(M,F)}P.parentTId=F.tId}}var H,J;if(O){H=M.treeObj;J=H}else{if(!G&&E==p.move.TYPE_INNER){i.expandCollapseNode(M,F,true,false)}else{if(!G){i.expandCollapseNode(M,F.getParentNode(),true,false)}}H=f("#"+F.tId);J=f("#"+F.tId+p.id.UL);if(!!H.get(0)&&!J.get(0)){var Y=[];i.makeUlHtml(M,F,Y,"");H.append(Y.join(""))}J=f("#"+F.tId+p.id.UL)}var W=f("#"+P.tId);if(!W.get(0)){W=i.appendNodes(M,P.level,[P],null,false,true).join("")}else{if(!H.get(0)){W.remove()}}if(J.get(0)&&E==p.move.TYPE_INNER){J.append(W)}else{if(H.get(0)&&E==p.move.TYPE_PREV){H.before(W)}else{if(H.get(0)&&E==p.move.TYPE_NEXT){H.after(W)}}}var T,S,I=-1,V=0,Z=null,D=null,X=P.level;if(P.isFirstNode){I=0;if(U[K].length>1){Z=U[K][1];Z.isFirstNode=true}}else{if(P.isLastNode){I=U[K].length-1;Z=U[K][I-1];Z.isLastNode=true}else{for(T=0,S=U[K].length;T=0){U[K].splice(I,1)}if(E!=p.move.TYPE_INNER){for(T=0,S=C[K].length;T0){D=F[K][F[K].length-1];D.isLastNode=false}F[K].splice(F[K].length,0,P);P.isLastNode=true;P.isFirstNode=(F[K].length==1)}else{if(F.isFirstNode&&E==p.move.TYPE_PREV){C[K].splice(V,0,P);D=F;D.isFirstNode=false;P.parentTId=F.parentTId;P.isFirstNode=true;P.isLastNode=false}else{if(F.isLastNode&&E==p.move.TYPE_NEXT){C[K].splice(V+1,0,P);D=F;D.isLastNode=false;P.parentTId=F.parentTId;P.isFirstNode=false;P.isLastNode=true}else{if(E==p.move.TYPE_PREV){C[K].splice(V,0,P)}else{C[K].splice(V+1,0,P)}P.parentTId=F.parentTId;P.isFirstNode=false;P.isLastNode=false}}}z.fixPIdKeyValue(M,P);z.setSonNodeLevel(M,P.getParentNode(),P);i.setNodeLineIcos(M,P);i.repairNodeLevelClass(M,P,X);if(!M.data.keep.parent&&U[K].length<1){U.isParent=false;U.open=false;var N=f("#"+U.tId+p.id.UL),Q=f("#"+U.tId+p.id.SWITCH),L=f("#"+U.tId+p.id.ICON);i.replaceSwitchClass(U,Q,p.folder.DOCU);i.replaceIcoClass(U,L,p.folder.DOCU);N.css("display","none")}else{if(Z){i.setNodeLineIcos(M,Z)}}if(D){i.setNodeLineIcos(M,D)}if(!!M.check&&M.check.enable&&i.repairChkClass){i.repairChkClass(M,U);i.repairParentChkClassWithSelf(M,U);if(U!=P.parent){i.repairParentChkClassWithSelf(M,P)}}if(!G){i.expandCollapseParentNode(M,P.getParentNode(),true,aa)}},removeEditBtn:function(C){f("#"+C.tId+p.id.EDIT).unbind().remove()},removeRemoveBtn:function(C){f("#"+C.tId+p.id.REMOVE).unbind().remove()},removeTreeDom:function(C,D){D.isHover=false;i.removeEditBtn(D);i.removeRemoveBtn(D);u.apply(C.view.removeHoverDom,[C.treeId,D])},repairNodeLevelClass:function(D,F,E){if(E===F.level){return}var G=f("#"+F.tId),J=f("#"+F.tId+p.id.A),I=f("#"+F.tId+p.id.UL),C=p.className.LEVEL+E,H=p.className.LEVEL+F.level;G.removeClass(C);G.addClass(H);J.removeClass(C);J.addClass(H);I.removeClass(C);I.addClass(H)}},s={tools:h,view:d,event:g,data:o};f.extend(true,f.fn.zTree.consts,B);f.extend(true,f.fn.zTree._z,s);var b=f.fn.zTree,u=b._z.tools,p=b.consts,i=b._z.view,z=b._z.data,r=b._z.event;z.exSetting(l);z.addInitBind(m);z.addInitUnBind(y);z.addInitCache(c);z.addInitNode(v);z.addInitProxy(n);z.addInitRoot(w);z.addZTreeTools(j);var t=i.cancelPreSelectedNode;i.cancelPreSelectedNode=function(E,F){var G=z.getRoot(E).curSelectedList;for(var D=0,C=G.length;D