(function($){var settings={},roots={},caches={},_consts={className:{BUTTON:"button",LEVEL:"level",ICO_LOADING:"ico_loading",SWITCH:"switch"},event:{NODECREATED:"ztree_nodeCreated",CLICK:"ztree_click",EXPAND:"ztree_expand",COLLAPSE:"ztree_collapse",ASYNC_SUCCESS:"ztree_async_success",ASYNC_ERROR:"ztree_async_error"},id:{A:"_a",ICON:"_ico",SPAN:"_span",SWITCH:"_switch",UL:"_ul"},line:{ROOT:"root",ROOTS:"roots",CENTER:"center",BOTTOM:"bottom",NOLINE:"noline",LINE:"line"},folder:{OPEN:"open",CLOSE:"close",DOCU:"docu"},node:{CURSELECTED:"curSelectedNode"}},_setting={treeId:"",treeObj:null,view:{addDiyDom:null,autoCancelSelected:true,dblClickExpand:true,expandSpeed:"fast",fontCss:{},nameIsHTML:false,selectedMulti:true,showIcon:true,showLine:true,showTitle:true},data:{key:{children:"children",name:"name",title:"",url:"url"},simpleData:{enable:false,idKey:"id",pIdKey:"pId",rootPId:null},keep:{parent:false,leaf:false}},async:{enable:false,contentType:"application/x-www-form-urlencoded",type:"post",dataType:"text",url:"",autoParam:[],otherParam:[],dataFilter:null},callback:{beforeAsync:null,beforeClick:null,beforeDblClick:null,beforeRightClick:null,beforeMouseDown:null,beforeMouseUp:null,beforeExpand:null,beforeCollapse:null,beforeRemove:null,onAsyncError:null,onAsyncSuccess:null,onNodeCreated:null,onClick:null,onDblClick:null,onRightClick:null,onMouseDown:null,onMouseUp:null,onExpand:null,onCollapse:null,onRemove:null}},_initRoot=function(setting){var r=data.getRoot(setting);if(!r){r={};data.setRoot(setting,r)}r[setting.data.key.children]=[];r.expandTriggerFlag=false;r.curSelectedList=[];r.noSelection=true;r.createdNodes=[];r.zId=0;r._ver=(new Date()).getTime()},_initCache=function(setting){var c=data.getCache(setting);if(!c){c={};data.setCache(setting,c)}c.nodes=[];c.doms=[]},_bindEvent=function(setting){var o=setting.treeObj,c=consts.event;o.bind(c.NODECREATED,function(event,treeId,node){tools.apply(setting.callback.onNodeCreated,[event,treeId,node])});o.bind(c.CLICK,function(event,srcEvent,treeId,node,clickFlag){tools.apply(setting.callback.onClick,[srcEvent,treeId,node,clickFlag])});o.bind(c.EXPAND,function(event,treeId,node){tools.apply(setting.callback.onExpand,[event,treeId,node])});o.bind(c.COLLAPSE,function(event,treeId,node){tools.apply(setting.callback.onCollapse,[event,treeId,node])});o.bind(c.ASYNC_SUCCESS,function(event,treeId,node,msg){tools.apply(setting.callback.onAsyncSuccess,[event,treeId,node,msg])});o.bind(c.ASYNC_ERROR,function(event,treeId,node,XMLHttpRequest,textStatus,errorThrown){tools.apply(setting.callback.onAsyncError,[event,treeId,node,XMLHttpRequest,textStatus,errorThrown])})},_unbindEvent=function(setting){var o=setting.treeObj,c=consts.event;o.unbind(c.NODECREATED).unbind(c.CLICK).unbind(c.EXPAND).unbind(c.COLLAPSE).unbind(c.ASYNC_SUCCESS).unbind(c.ASYNC_ERROR)},_eventProxy=function(event){var target=event.target,setting=data.getSetting(event.data.treeId),tId="",node=null,nodeEventType="",treeEventType="",nodeEventCallback=null,treeEventCallback=null,tmp=null;if(tools.eqs(event.type,"mousedown")){treeEventType="mousedown"}else{if(tools.eqs(event.type,"mouseup")){treeEventType="mouseup"}else{if(tools.eqs(event.type,"contextmenu")){treeEventType="contextmenu"}else{if(tools.eqs(event.type,"click")){if(tools.eqs(target.tagName,"span")&&target.getAttribute("treeNode"+consts.id.SWITCH)!==null){tId=($(target).parent("li").get(0)||$(target).parentsUntil("li").parent().get(0)).id;nodeEventType="switchNode"}else{tmp=tools.getMDom(setting,target,[{tagName:"a",attrName:"treeNode"+consts.id.A}]);if(tmp){tId=($(tmp).parent("li").get(0)||$(tmp).parentsUntil("li").parent().get(0)).id;nodeEventType="clickNode"}}}else{if(tools.eqs(event.type,"dblclick")){treeEventType="dblclick";tmp=tools.getMDom(setting,target,[{tagName:"a",attrName:"treeNode"+consts.id.A}]);if(tmp){tId=($(tmp).parent("li").get(0)||$(tmp).parentsUntil("li").parent().get(0)).id;nodeEventType="switchNode"}}}}}}if(treeEventType.length>0&&tId.length==0){tmp=tools.getMDom(setting,target,[{tagName:"a",attrName:"treeNode"+consts.id.A}]);if(tmp){tId=($(tmp).parent("li").get(0)||$(tmp).parentsUntil("li").parent().get(0)).id}}if(tId.length>0){node=data.getNodeCache(setting,tId);switch(nodeEventType){case"switchNode":if(!node.isParent){nodeEventType=""}else{if(tools.eqs(event.type,"click")||(tools.eqs(event.type,"dblclick")&&tools.apply(setting.view.dblClickExpand,[setting.treeId,node],setting.view.dblClickExpand))){nodeEventCallback=handler.onSwitchNode}else{nodeEventType=""}}break;case"clickNode":nodeEventCallback=handler.onClickNode;break}}switch(treeEventType){case"mousedown":treeEventCallback=handler.onZTreeMousedown;break;case"mouseup":treeEventCallback=handler.onZTreeMouseup;break;case"dblclick":treeEventCallback=handler.onZTreeDblclick;break;case"contextmenu":treeEventCallback=handler.onZTreeContextmenu;break}var proxyResult={stop:false,node:node,nodeEventType:nodeEventType,nodeEventCallback:nodeEventCallback,treeEventType:treeEventType,treeEventCallback:treeEventCallback};return proxyResult},_initNode=function(setting,level,n,parentNode,isFirstNode,isLastNode,openFlag){if(!n){return}var r=data.getRoot(setting),childKey=setting.data.key.children;n.level=level;n.tId=setting.treeId+"_"+(++r.zId);n.parentTId=parentNode?parentNode.tId:null;if(n[childKey]&&n[childKey].length>0){if(typeof n.open=="string"){n.open=tools.eqs(n.open,"true")}n.open=!!n.open;n.isParent=true;n.zAsync=true}else{n.open=false;if(typeof n.isParent=="string"){n.isParent=tools.eqs(n.isParent,"true")}n.isParent=!!n.isParent;n.zAsync=!n.isParent}n.isFirstNode=isFirstNode;n.isLastNode=isLastNode;n.getParentNode=function(){return data.getNodeCache(setting,n.parentTId)};n.getPreNode=function(){return data.getPreNode(setting,n)};n.getNextNode=function(){return data.getNextNode(setting,n)};n.isAjaxing=false;data.fixPIdKeyValue(setting,n)},_init={bind:[_bindEvent],unbind:[_unbindEvent],caches:[_initCache],nodes:[_initNode],proxys:[_eventProxy],roots:[_initRoot],beforeA:[],afterA:[],innerBeforeA:[],innerAfterA:[],zTreeTools:[]},data={addNodeCache:function(setting,node){data.getCache(setting).nodes[data.getNodeCacheId(node.tId)]=node},getNodeCacheId:function(tId){return tId.substring(tId.lastIndexOf("_")+1)},addAfterA:function(afterA){_init.afterA.push(afterA)},addBeforeA:function(beforeA){_init.beforeA.push(beforeA)},addInnerAfterA:function(innerAfterA){_init.innerAfterA.push(innerAfterA)},addInnerBeforeA:function(innerBeforeA){_init.innerBeforeA.push(innerBeforeA)},addInitBind:function(bindEvent){_init.bind.push(bindEvent)},addInitUnBind:function(unbindEvent){_init.unbind.push(unbindEvent)},addInitCache:function(initCache){_init.caches.push(initCache)},addInitNode:function(initNode){_init.nodes.push(initNode)},addInitProxy:function(initProxy){_init.proxys.push(initProxy)},addInitRoot:function(initRoot){_init.roots.push(initRoot)},addNodesData:function(setting,parentNode,nodes){var childKey=setting.data.key.children;if(!parentNode[childKey]){parentNode[childKey]=[]}if(parentNode[childKey].length>0){parentNode[childKey][parentNode[childKey].length-1].isLastNode=false;view.setNodeLineIcos(setting,parentNode[childKey][parentNode[childKey].length-1])}parentNode.isParent=true;parentNode[childKey]=parentNode[childKey].concat(nodes)},addSelectedNode:function(setting,node){var root=data.getRoot(setting);if(!data.isSelectedNode(setting,node)){root.curSelectedList.push(node)}},addCreatedNode:function(setting,node){if(!!setting.callback.onNodeCreated||!!setting.view.addDiyDom){var root=data.getRoot(setting);root.createdNodes.push(node)}},addZTreeTools:function(zTreeTools){_init.zTreeTools.push(zTreeTools)},exSetting:function(s){$.extend(true,_setting,s)},fixPIdKeyValue:function(setting,node){if(setting.data.simpleData.enable){node[setting.data.simpleData.pIdKey]=node.parentTId?node.getParentNode()[setting.data.simpleData.idKey]:setting.data.simpleData.rootPId}},getAfterA:function(setting,node,array){for(var i=0,j=_init.afterA.length;i-1){result.push(nodes[i])}result=result.concat(data.getNodesByParamFuzzy(setting,nodes[i][childKey],key,value))}return result},getNodesByFilter:function(setting,nodes,filter,isSingle,invokeParam){if(!nodes){return(isSingle?null:[])}var childKey=setting.data.key.children,result=isSingle?null:[];for(var i=0,l=nodes.length;i0)))},clone:function(obj){if(obj===null){return null}var o=obj.constructor===Array?[]:{};for(var i in obj){o[i]=(obj[i] instanceof Date)?new Date(obj[i].getTime()):(typeof obj[i]==="object"?arguments.callee(obj[i]):obj[i])}return o},eqs:function(str1,str2){return str1.toLowerCase()===str2.toLowerCase()},isArray:function(arr){return Object.prototype.toString.apply(arr)==="[object Array]"},getMDom:function(setting,curDom,targetExpr){if(!curDom){return null}while(curDom&&curDom.id!==setting.treeId){for(var i=0,l=targetExpr.length;curDom.tagName&&i0){childHtml=view.appendNodes(setting,level+1,node[childKey],node,initFlag,openFlag&&node.open)}if(openFlag){view.makeDOMNodeMainBefore(html,setting,node);view.makeDOMNodeLine(html,setting,node);data.getBeforeA(setting,node,html);view.makeDOMNodeNameBefore(html,setting,node);data.getInnerBeforeA(setting,node,html);view.makeDOMNodeIcon(html,setting,node);data.getInnerAfterA(setting,node,html);view.makeDOMNodeNameAfter(html,setting,node);data.getAfterA(setting,node,html);if(node.isParent&&node.open){view.makeUlHtml(setting,node,html,childHtml.join(""))}view.makeDOMNodeMainAfter(html,setting,node);data.addCreatedNode(setting,node)}}return html},appendParentULDom:function(setting,node){var html=[],nObj=$("#"+node.tId),ulObj=$("#"+node.tId+consts.id.UL),childKey=setting.data.key.children,childHtml=view.appendNodes(setting,node.level+1,node[childKey],node,false,true);view.makeUlHtml(setting,node,html,childHtml.join(""));if(!nObj.get(0)&&!!node.parentTId){view.appendParentULDom(setting,node.getParentNode());nObj=$("#"+node.tId)}if(ulObj.get(0)){ulObj.remove()}nObj.append(html.join(""))},asyncNode:function(setting,node,isSilent,callback){var i,l;if(node&&!node.isParent){tools.apply(callback);return false}else{if(node&&node.isAjaxing){return false}else{if(tools.apply(setting.callback.beforeAsync,[setting.treeId,node],true)==false){tools.apply(callback);return false}}}if(node){node.isAjaxing=true;var icoObj=$("#"+node.tId+consts.id.ICON);icoObj.attr({style:"","class":consts.className.BUTTON+" "+consts.className.ICO_LOADING})}var tmpParam={};for(i=0,l=setting.async.autoParam.length;node&&i1){spKey=pKey[1];pKey=pKey[0]}tmpParam[spKey]=node[pKey]}if(tools.isArray(setting.async.otherParam)){for(i=0,l=setting.async.otherParam.length;i=i;j--){if(!node||node===list[j]){$("#"+list[j].tId+consts.id.A).removeClass(consts.node.CURSELECTED);if(node){data.removeSelectedNode(setting,node);break}}}if(!node){data.getRoot(setting).curSelectedList=[]}},createNodeCallback:function(setting){if(!!setting.callback.onNodeCreated||!!setting.view.addDiyDom){var root=data.getRoot(setting);while(root.createdNodes.length>0){var node=root.createdNodes.shift();tools.apply(setting.view.addDiyDom,[setting.treeId,node]);if(!!setting.callback.onNodeCreated){setting.treeObj.trigger(consts.event.NODECREATED,[setting.treeId,node])}}}},createNodes:function(setting,level,nodes,parentNode){if(!nodes||nodes.length==0){return}var root=data.getRoot(setting),childKey=setting.data.key.children,openFlag=!parentNode||parentNode.open||!!$("#"+parentNode[childKey][0].tId).get(0);root.createdNodes=[];var zTreeHtml=view.appendNodes(setting,level,nodes,parentNode,true,openFlag);if(!parentNode){setting.treeObj.append(zTreeHtml.join(""))}else{var ulObj=$("#"+parentNode.tId+consts.id.UL);if(ulObj.get(0)){ulObj.append(zTreeHtml.join(""))}}view.createNodeCallback(setting)},destroy:function(setting){if(!setting){return}data.initCache(setting);data.initRoot(setting);event.unbindTree(setting);event.unbindEvent(setting);setting.treeObj.empty()},expandCollapseNode:function(setting,node,expandFlag,animateFlag,callback){var root=data.getRoot(setting),childKey=setting.data.key.children;if(!node){tools.apply(callback,[]);return}if(root.expandTriggerFlag){var _callback=callback;callback=function(){if(_callback){_callback()}if(node.open){setting.treeObj.trigger(consts.event.EXPAND,[setting.treeId,node])}else{setting.treeObj.trigger(consts.event.COLLAPSE,[setting.treeId,node])}};root.expandTriggerFlag=false}if(!node.open&&node.isParent&&((!$("#"+node.tId+consts.id.UL).get(0))||(node[childKey]&&node[childKey].length>0&&!$("#"+node[childKey][0].tId).get(0)))){view.appendParentULDom(setting,node);view.createNodeCallback(setting)}if(node.open==expandFlag){tools.apply(callback,[]);return}var ulObj=$("#"+node.tId+consts.id.UL),switchObj=$("#"+node.tId+consts.id.SWITCH),icoObj=$("#"+node.tId+consts.id.ICON);if(node.isParent){node.open=!node.open;if(node.iconOpen&&node.iconClose){icoObj.attr("style",view.makeNodeIcoStyle(setting,node))}if(node.open){view.replaceSwitchClass(node,switchObj,consts.folder.OPEN);view.replaceIcoClass(node,icoObj,consts.folder.OPEN);if(animateFlag==false||setting.view.expandSpeed==""){ulObj.show();tools.apply(callback,[])}else{if(node[childKey]&&node[childKey].length>0){ulObj.slideDown(setting.view.expandSpeed,callback)}else{ulObj.show();tools.apply(callback,[])}}}else{view.replaceSwitchClass(node,switchObj,consts.folder.CLOSE);view.replaceIcoClass(node,icoObj,consts.folder.CLOSE);if(animateFlag==false||setting.view.expandSpeed==""||!(node[childKey]&&node[childKey].length>0)){ulObj.hide();tools.apply(callback,[])}else{ulObj.slideUp(setting.view.expandSpeed,callback)}}}else{tools.apply(callback,[])}},expandCollapseParentNode:function(setting,node,expandFlag,animateFlag,callback){if(!node){return}if(!node.parentTId){view.expandCollapseNode(setting,node,expandFlag,animateFlag,callback);return}else{view.expandCollapseNode(setting,node,expandFlag,animateFlag)}if(node.parentTId){view.expandCollapseParentNode(setting,node.getParentNode(),expandFlag,animateFlag,callback)}},expandCollapseSonNode:function(setting,node,expandFlag,animateFlag,callback){var root=data.getRoot(setting),childKey=setting.data.key.children,treeNodes=(node)?node[childKey]:root[childKey],selfAnimateSign=(node)?false:animateFlag,expandTriggerFlag=data.getRoot(setting).expandTriggerFlag;data.getRoot(setting).expandTriggerFlag=false;if(treeNodes){for(var i=0,l=treeNodes.length;i/g,">");html.push("",name,"")},makeDOMNodeLine:function(html,setting,node){html.push("")},makeDOMNodeMainAfter:function(html,setting,node){html.push("")},makeDOMNodeMainBefore:function(html,setting,node){html.push("
  • ")},makeDOMNodeNameAfter:function(html,setting,node){html.push("")},makeDOMNodeNameBefore:function(html,setting,node){var title=data.getNodeTitle(setting,node),url=view.makeNodeUrl(setting,node),fontcss=view.makeNodeFontCss(setting,node),fontStyle=[];for(var f in fontcss){fontStyle.push(f,":",fontcss[f],";")}html.push("0)?"href='"+url+"'":"")," target='",view.makeNodeTarget(node),"' style='",fontStyle.join(""),"'");if(tools.apply(setting.view.showTitle,[setting.treeId,node],setting.view.showTitle)&&title){html.push("title='",title.replace(/'/g,"'").replace(//g,">"),"'")}html.push(">")},makeNodeFontCss:function(setting,node){var fontCss=tools.apply(setting.view.fontCss,[setting.treeId,node],setting.view.fontCss);return(fontCss&&((typeof fontCss)!="function"))?fontCss:{}},makeNodeIcoClass:function(setting,node){var icoCss=["ico"];if(!node.isAjaxing){icoCss[0]=(node.iconSkin?node.iconSkin+"_":"")+icoCss[0];if(node.isParent){icoCss.push(node.open?consts.folder.OPEN:consts.folder.CLOSE)}else{icoCss.push(consts.folder.DOCU)}}return consts.className.BUTTON+" "+icoCss.join("_")},makeNodeIcoStyle:function(setting,node){var icoStyle=[];if(!node.isAjaxing){var icon=(node.isParent&&node.iconOpen&&node.iconClose)?(node.open?node.iconOpen:node.iconClose):node.icon;if(icon){icoStyle.push("background:url(",icon,") 0 0 no-repeat;")}if(setting.view.showIcon==false||!tools.apply(setting.view.showIcon,[setting.treeId,node],true)){icoStyle.push("width:0px;height:0px;")}}return icoStyle.join("")},makeNodeLineClass:function(setting,node){var lineClass=[];if(setting.view.showLine){if(node.level==0&&node.isFirstNode&&node.isLastNode){lineClass.push(consts.line.ROOT)}else{if(node.level==0&&node.isFirstNode){lineClass.push(consts.line.ROOTS)}else{if(node.isLastNode){lineClass.push(consts.line.BOTTOM) }else{lineClass.push(consts.line.CENTER)}}}}else{lineClass.push(consts.line.NOLINE)}if(node.isParent){lineClass.push(node.open?consts.folder.OPEN:consts.folder.CLOSE)}else{lineClass.push(consts.folder.DOCU)}return view.makeNodeLineClassEx(node)+lineClass.join("_")},makeNodeLineClassEx:function(node){return consts.className.BUTTON+" "+consts.className.LEVEL+node.level+" "+consts.className.SWITCH+" "},makeNodeTarget:function(node){return(node.target||"_blank")},makeNodeUrl:function(setting,node){var urlKey=setting.data.key.url;return node[urlKey]?node[urlKey]:null},makeUlHtml:function(setting,node,html,content){html.push("
      ");html.push(content);html.push("
    ")},makeUlLineClass:function(setting,node){return((setting.view.showLine&&!node.isLastNode)?consts.line.LINE:"")},removeChildNodes:function(setting,node){if(!node){return}var childKey=setting.data.key.children,nodes=node[childKey];if(!nodes){return}for(var i=0,l=nodes.length;i0){parentNode[childKey][0].isFirstNode=true}},setLastNode:function(setting,parentNode){var childKey=setting.data.key.children,childLength=parentNode[childKey].length;if(childLength>0){parentNode[childKey][childLength-1].isLastNode=true}},removeNode:function(setting,node){var root=data.getRoot(setting),childKey=setting.data.key.children,parentNode=(node.parentTId)?node.getParentNode():root;node.isFirstNode=false;node.isLastNode=false;node.getPreNode=function(){return null};node.getNextNode=function(){return null};if(!data.getNodeCache(setting,node.tId)){return}$("#"+node.tId).remove();data.removeNodeCache(setting,node);data.removeSelectedNode(setting,node);for(var i=0,l=parentNode[childKey].length;i0){var newLast=parentNode[childKey][childLength-1];tmp_ulObj=$("#"+newLast.tId+consts.id.UL);tmp_switchObj=$("#"+newLast.tId+consts.id.SWITCH);tmp_icoObj=$("#"+newLast.tId+consts.id.ICON);if(parentNode==root){if(parentNode[childKey].length==1){view.replaceSwitchClass(newLast,tmp_switchObj,consts.line.ROOT)}else{var tmp_first_switchObj=$("#"+parentNode[childKey][0].tId+consts.id.SWITCH);view.replaceSwitchClass(parentNode[childKey][0],tmp_first_switchObj,consts.line.ROOTS);view.replaceSwitchClass(newLast,tmp_switchObj,consts.line.BOTTOM)}}else{view.replaceSwitchClass(newLast,tmp_switchObj,consts.line.BOTTOM)}tmp_ulObj.removeClass(consts.line.LINE)}}},replaceIcoClass:function(node,obj,newName){if(!obj||node.isAjaxing){return}var tmpName=obj.attr("class");if(tmpName==undefined){return}var tmpList=tmpName.split("_");switch(newName){case consts.folder.OPEN:case consts.folder.CLOSE:case consts.folder.DOCU:tmpList[tmpList.length-1]=newName;break}obj.attr("class",tmpList.join("_"))},replaceSwitchClass:function(node,obj,newName){if(!obj){return}var tmpName=obj.attr("class");if(tmpName==undefined){return}var tmpList=tmpName.split("_");switch(newName){case consts.line.ROOT:case consts.line.ROOTS:case consts.line.CENTER:case consts.line.BOTTOM:case consts.line.NOLINE:tmpList[0]=view.makeNodeLineClassEx(node)+newName;break;case consts.folder.OPEN:case consts.folder.CLOSE:case consts.folder.DOCU:tmpList[1]=newName;break}obj.attr("class",tmpList.join("_"));if(newName!==consts.folder.DOCU){obj.removeAttr("disabled")}else{obj.attr("disabled","disabled")}},selectNode:function(setting,node,addFlag){if(!addFlag){view.cancelPreSelectedNode(setting)}$("#"+node.tId+consts.id.A).addClass(consts.node.CURSELECTED);data.addSelectedNode(setting,node)},setNodeFontCss:function(setting,treeNode){var aObj=$("#"+treeNode.tId+consts.id.A),fontCss=view.makeNodeFontCss(setting,treeNode);if(fontCss){aObj.css(fontCss)}},setNodeLineIcos:function(setting,node){if(!node){return}var switchObj=$("#"+node.tId+consts.id.SWITCH),ulObj=$("#"+node.tId+consts.id.UL),icoObj=$("#"+node.tId+consts.id.ICON),ulLine=view.makeUlLineClass(setting,node);if(ulLine.length==0){ulObj.removeClass(consts.line.LINE)}else{ulObj.addClass(ulLine)}switchObj.attr("class",view.makeNodeLineClass(setting,node));if(node.isParent){switchObj.removeAttr("disabled")}else{switchObj.attr("disabled","disabled")}icoObj.removeAttr("style");icoObj.attr("style",view.makeNodeIcoStyle(setting,node));icoObj.attr("class",view.makeNodeIcoClass(setting,node))},setNodeName:function(setting,node){var title=data.getNodeTitle(setting,node),nObj=$("#"+node.tId+consts.id.SPAN);nObj.empty();if(setting.view.nameIsHTML){nObj.html(data.getNodeName(setting,node))}else{nObj.text(data.getNodeName(setting,node))}if(tools.apply(setting.view.showTitle,[setting.treeId,node],setting.view.showTitle)){var aObj=$("#"+node.tId+consts.id.A);aObj.attr("title",!title?"":title)}},setNodeTarget:function(node){var aObj=$("#"+node.tId+consts.id.A);aObj.attr("target",view.makeNodeTarget(node))},setNodeUrl:function(setting,node){var aObj=$("#"+node.tId+consts.id.A),url=view.makeNodeUrl(setting,node);if(url==null||url.length==0){aObj.removeAttr("href")}else{aObj.attr("href",url)}},switchNode:function(setting,node){if(node.open||!tools.canAsync(setting,node)){view.expandCollapseNode(setting,node,!node.open)}else{if(setting.async.enable){if(!view.asyncNode(setting,node)){view.expandCollapseNode(setting,node,!node.open);return}}else{if(node){view.expandCollapseNode(setting,node,!node.open)}}}}};$.fn.zTree={consts:_consts,_z:{tools:tools,view:view,event:event,data:data},getZTreeObj:function(treeId){var o=data.getZTreeTools(treeId);return o?o:null},destroy:function(treeId){if(!!treeId&&treeId.length>0){view.destroy(data.getSetting(treeId))}else{for(var s in settings){view.destroy(settings[s])}}},init:function(obj,zSetting,zNodes){var setting=tools.clone(_setting);$.extend(true,setting,zSetting);setting.treeId=obj.attr("id");setting.treeObj=obj;setting.treeObj.empty();settings[setting.treeId]=setting;if(typeof document.body.style.maxHeight==="undefined"){setting.view.expandSpeed=""}data.initRoot(setting);var root=data.getRoot(setting),childKey=setting.data.key.children;zNodes=zNodes?tools.clone(tools.isArray(zNodes)?zNodes:[zNodes]):[];if(setting.data.simpleData.enable){root[childKey]=data.transformTozTreeFormat(setting,zNodes)}else{root[childKey]=zNodes}data.initCache(setting);event.unbindTree(setting);event.bindTree(setting);event.unbindEvent(setting);event.bindEvent(setting);var zTreeTools={setting:setting,addNodes:function(parentNode,newNodes,isSilent){if(!newNodes){return null}if(!parentNode){parentNode=null}if(parentNode&&!parentNode.isParent&&setting.data.keep.leaf){return null}var xNewNodes=tools.clone(tools.isArray(newNodes)?newNodes:[newNodes]);function addCallback(){view.addNodes(setting,parentNode,xNewNodes,(isSilent==true))}if(tools.canAsync(setting,parentNode)){view.asyncNode(setting,parentNode,isSilent,addCallback)}else{addCallback()}return xNewNodes},cancelSelectedNode:function(node){view.cancelPreSelectedNode(this.setting,node)},destroy:function(){view.destroy(this.setting)},expandAll:function(expandFlag){expandFlag=!!expandFlag;view.expandCollapseSonNode(this.setting,null,expandFlag,true);return expandFlag},expandNode:function(node,expandFlag,sonSign,focus,callbackFlag){if(!node||!node.isParent){return null}if(expandFlag!==true&&expandFlag!==false){expandFlag=!node.open}callbackFlag=!!callbackFlag;if(callbackFlag&&expandFlag&&(tools.apply(setting.callback.beforeExpand,[setting.treeId,node],true)==false)){return null}else{if(callbackFlag&&!expandFlag&&(tools.apply(setting.callback.beforeCollapse,[setting.treeId,node],true)==false)){return null}}if(expandFlag&&node.parentTId){view.expandCollapseParentNode(this.setting,node.getParentNode(),expandFlag,false)}if(expandFlag===node.open&&!sonSign){return null}data.getRoot(setting).expandTriggerFlag=callbackFlag;if(sonSign){view.expandCollapseSonNode(this.setting,node,expandFlag,true,function(){if(focus!==false){try{$("#"+node.tId).focus().blur()}catch(e){}}})}else{node.open=!expandFlag;view.switchNode(this.setting,node);if(focus!==false){try{$("#"+node.tId).focus().blur()}catch(e){}}}return expandFlag},getNodes:function(){return data.getNodes(this.setting)},getNodeByParam:function(key,value,parentNode){if(!key){return null}return data.getNodeByParam(this.setting,parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting),key,value)},getNodeByTId:function(tId){return data.getNodeCache(this.setting,tId)},getNodesByParam:function(key,value,parentNode){if(!key){return null}return data.getNodesByParam(this.setting,parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting),key,value)},getNodesByParamFuzzy:function(key,value,parentNode){if(!key){return null}return data.getNodesByParamFuzzy(this.setting,parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting),key,value)},getNodesByFilter:function(filter,isSingle,parentNode,invokeParam){isSingle=!!isSingle;if(!filter||(typeof filter!="function")){return(isSingle?null:[])}return data.getNodesByFilter(this.setting,parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting),filter,isSingle,invokeParam)},getNodeIndex:function(node){if(!node){return null}var childKey=setting.data.key.children,parentNode=(node.parentTId)?node.getParentNode():data.getRoot(this.setting);for(var i=0,l=parentNode[childKey].length;i0){view.createNodes(setting,0,root[childKey])}else{if(setting.async.enable&&setting.async.url&&setting.async.url!==""){view.asyncNode(setting)}}return zTreeTools}};var zt=$.fn.zTree,consts=zt.consts})(jQuery);