tocmd 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,68 +0,0 @@
1
- /*
2
- * JQuery zTree core 3.5.02
3
- * http://zTree.me/
4
- *
5
- * Copyright (c) 2010 Hunter.z
6
- *
7
- * Licensed same as jquery - MIT License
8
- * http://www.opensource.org/licenses/mit-license.php
9
- *
10
- * email: hunter.z@263.net
11
- * Date: 2013-01-28
12
- */
13
- (function(k){var F,G,H,I,J,K,r={},L={},t={},M={treeId:"",treeObj:null,view:{addDiyDom:null,autoCancelSelected:!0,dblClickExpand:!0,expandSpeed:"fast",fontCss:{},nameIsHTML:!1,selectedMulti:!0,showIcon:!0,showLine:!0,showTitle:!0},data:{key:{children:"children",name:"name",title:"",url:"url"},simpleData:{enable:!1,idKey:"id",pIdKey:"pId",rootPId:null},keep:{parent:!1,leaf:!1}},async:{enable:!1,contentType:"application/x-www-form-urlencoded",type:"post",dataType:"text",url:"",autoParam:[],otherParam:[],
14
- 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}},u=[function(b){var a=b.treeObj,c=e.event;a.bind(c.NODECREATED,function(a,c,g){j.apply(b.callback.onNodeCreated,[a,c,g])});
15
- a.bind(c.CLICK,function(a,c,g,l,h){j.apply(b.callback.onClick,[c,g,l,h])});a.bind(c.EXPAND,function(a,c,g){j.apply(b.callback.onExpand,[a,c,g])});a.bind(c.COLLAPSE,function(a,c,g){j.apply(b.callback.onCollapse,[a,c,g])});a.bind(c.ASYNC_SUCCESS,function(a,c,g,l){j.apply(b.callback.onAsyncSuccess,[a,c,g,l])});a.bind(c.ASYNC_ERROR,function(a,c,g,l,h,e){j.apply(b.callback.onAsyncError,[a,c,g,l,h,e])})}],v=[function(b){var a=e.event;b.treeObj.unbind(a.NODECREATED).unbind(a.CLICK).unbind(a.EXPAND).unbind(a.COLLAPSE).unbind(a.ASYNC_SUCCESS).unbind(a.ASYNC_ERROR)}],
16
- w=[function(b){var a=h.getCache(b);a||(a={},h.setCache(b,a));a.nodes=[];a.doms=[]}],x=[function(b,a,c,d,f,g){if(c){var l=h.getRoot(b),e=b.data.key.children;c.level=a;c.tId=b.treeId+"_"+ ++l.zId;c.parentTId=d?d.tId:null;if(c[e]&&c[e].length>0){if(typeof c.open=="string")c.open=j.eqs(c.open,"true");c.open=!!c.open;c.isParent=!0;c.zAsync=!0}else{c.open=!1;if(typeof c.isParent=="string")c.isParent=j.eqs(c.isParent,"true");c.isParent=!!c.isParent;c.zAsync=!c.isParent}c.isFirstNode=f;c.isLastNode=g;c.getParentNode=
17
- function(){return h.getNodeCache(b,c.parentTId)};c.getPreNode=function(){return h.getPreNode(b,c)};c.getNextNode=function(){return h.getNextNode(b,c)};c.isAjaxing=!1;h.fixPIdKeyValue(b,c)}}],y=[function(b){var a=b.target,c=h.getSetting(b.data.treeId),d="",f=null,g="",l="",i=null,n=null,p=null;if(j.eqs(b.type,"mousedown"))l="mousedown";else if(j.eqs(b.type,"mouseup"))l="mouseup";else if(j.eqs(b.type,"contextmenu"))l="contextmenu";else if(j.eqs(b.type,"click"))if(j.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+
18
- e.id.SWITCH)!==null)d=(k(a).parent("li").get(0)||k(a).parentsUntil("li").parent().get(0)).id,g="switchNode";else{if(p=j.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+e.id.A}]))d=(k(p).parent("li").get(0)||k(p).parentsUntil("li").parent().get(0)).id,g="clickNode"}else if(j.eqs(b.type,"dblclick")&&(l="dblclick",p=j.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+e.id.A}])))d=(k(p).parent("li").get(0)||k(p).parentsUntil("li").parent().get(0)).id,g="switchNode";if(l.length>0&&d.length==0&&(p=j.getMDom(c,
19
- a,[{tagName:"a",attrName:"treeNode"+e.id.A}])))d=(k(p).parent("li").get(0)||k(p).parentsUntil("li").parent().get(0)).id;if(d.length>0)switch(f=h.getNodeCache(c,d),g){case "switchNode":f.isParent?j.eqs(b.type,"click")||j.eqs(b.type,"dblclick")&&j.apply(c.view.dblClickExpand,[c.treeId,f],c.view.dblClickExpand)?i=F:g="":g="";break;case "clickNode":i=G}switch(l){case "mousedown":n=H;break;case "mouseup":n=I;break;case "dblclick":n=J;break;case "contextmenu":n=K}return{stop:!1,node:f,nodeEventType:g,nodeEventCallback:i,
20
- treeEventType:l,treeEventCallback:n}}],z=[function(b){var a=h.getRoot(b);a||(a={},h.setRoot(b,a));a[b.data.key.children]=[];a.expandTriggerFlag=!1;a.curSelectedList=[];a.noSelection=!0;a.createdNodes=[];a.zId=0;a._ver=(new Date).getTime()}],A=[],B=[],C=[],D=[],E=[],h={addNodeCache:function(b,a){h.getCache(b).nodes[h.getNodeCacheId(a.tId)]=a},getNodeCacheId:function(b){return b.substring(b.lastIndexOf("_")+1)},addAfterA:function(b){B.push(b)},addBeforeA:function(b){A.push(b)},addInnerAfterA:function(b){D.push(b)},
21
- addInnerBeforeA:function(b){C.push(b)},addInitBind:function(b){u.push(b)},addInitUnBind:function(b){v.push(b)},addInitCache:function(b){w.push(b)},addInitNode:function(b){x.push(b)},addInitProxy:function(b){y.push(b)},addInitRoot:function(b){z.push(b)},addNodesData:function(b,a,c){var d=b.data.key.children;a[d]||(a[d]=[]);if(a[d].length>0)a[d][a[d].length-1].isLastNode=!1,i.setNodeLineIcos(b,a[d][a[d].length-1]);a.isParent=!0;a[d]=a[d].concat(c)},addSelectedNode:function(b,a){var c=h.getRoot(b);h.isSelectedNode(b,
22
- a)||c.curSelectedList.push(a)},addCreatedNode:function(b,a){(b.callback.onNodeCreated||b.view.addDiyDom)&&h.getRoot(b).createdNodes.push(a)},addZTreeTools:function(b){E.push(b)},exSetting:function(b){k.extend(!0,M,b)},fixPIdKeyValue:function(b,a){b.data.simpleData.enable&&(a[b.data.simpleData.pIdKey]=a.parentTId?a.getParentNode()[b.data.simpleData.idKey]:b.data.simpleData.rootPId)},getAfterA:function(b,a,c){for(var d=0,f=B.length;d<f;d++)B[d].apply(this,arguments)},getBeforeA:function(b,a,c){for(var d=
23
- 0,f=A.length;d<f;d++)A[d].apply(this,arguments)},getInnerAfterA:function(b,a,c){for(var d=0,f=D.length;d<f;d++)D[d].apply(this,arguments)},getInnerBeforeA:function(b,a,c){for(var d=0,f=C.length;d<f;d++)C[d].apply(this,arguments)},getCache:function(b){return t[b.treeId]},getNextNode:function(b,a){if(!a)return null;for(var c=b.data.key.children,d=a.parentTId?a.getParentNode():h.getRoot(b),f=0,g=d[c].length-1;f<=g;f++)if(d[c][f]===a)return f==g?null:d[c][f+1];return null},getNodeByParam:function(b,a,
24
- c,d){if(!a||!c)return null;for(var f=b.data.key.children,g=0,l=a.length;g<l;g++){if(a[g][c]==d)return a[g];var e=h.getNodeByParam(b,a[g][f],c,d);if(e)return e}return null},getNodeCache:function(b,a){if(!a)return null;var c=t[b.treeId].nodes[h.getNodeCacheId(a)];return c?c:null},getNodeName:function(b,a){return""+a[b.data.key.name]},getNodeTitle:function(b,a){return""+a[b.data.key.title===""?b.data.key.name:b.data.key.title]},getNodes:function(b){return h.getRoot(b)[b.data.key.children]},getNodesByParam:function(b,
25
- a,c,d){if(!a||!c)return[];for(var f=b.data.key.children,g=[],l=0,e=a.length;l<e;l++)a[l][c]==d&&g.push(a[l]),g=g.concat(h.getNodesByParam(b,a[l][f],c,d));return g},getNodesByParamFuzzy:function(b,a,c,d){if(!a||!c)return[];for(var f=b.data.key.children,g=[],l=0,e=a.length;l<e;l++)typeof a[l][c]=="string"&&a[l][c].indexOf(d)>-1&&g.push(a[l]),g=g.concat(h.getNodesByParamFuzzy(b,a[l][f],c,d));return g},getNodesByFilter:function(b,a,c,d,f){if(!a)return d?null:[];for(var g=b.data.key.children,l=d?null:
26
- [],e=0,i=a.length;e<i;e++){if(j.apply(c,[a[e],f],!1)){if(d)return a[e];l.push(a[e])}var k=h.getNodesByFilter(b,a[e][g],c,d,f);if(d&&k)return k;l=d?k:l.concat(k)}return l},getPreNode:function(b,a){if(!a)return null;for(var c=b.data.key.children,d=a.parentTId?a.getParentNode():h.getRoot(b),f=0,g=d[c].length;f<g;f++)if(d[c][f]===a)return f==0?null:d[c][f-1];return null},getRoot:function(b){return b?L[b.treeId]:null},getSetting:function(b){return r[b]},getSettings:function(){return r},getZTreeTools:function(b){return(b=
27
- this.getRoot(this.getSetting(b)))?b.treeTools:null},initCache:function(b){for(var a=0,c=w.length;a<c;a++)w[a].apply(this,arguments)},initNode:function(b,a,c,d,f,g){for(var l=0,e=x.length;l<e;l++)x[l].apply(this,arguments)},initRoot:function(b){for(var a=0,c=z.length;a<c;a++)z[a].apply(this,arguments)},isSelectedNode:function(b,a){for(var c=h.getRoot(b),d=0,f=c.curSelectedList.length;d<f;d++)if(a===c.curSelectedList[d])return!0;return!1},removeNodeCache:function(b,a){var c=b.data.key.children;if(a[c])for(var d=
28
- 0,f=a[c].length;d<f;d++)arguments.callee(b,a[c][d]);h.getCache(b).nodes[h.getNodeCacheId(a.tId)]=null},removeSelectedNode:function(b,a){for(var c=h.getRoot(b),d=0,f=c.curSelectedList.length;d<f;d++)if(a===c.curSelectedList[d]||!h.getNodeCache(b,c.curSelectedList[d].tId))c.curSelectedList.splice(d,1),d--,f--},setCache:function(b,a){t[b.treeId]=a},setRoot:function(b,a){L[b.treeId]=a},setZTreeTools:function(b,a){for(var c=0,d=E.length;c<d;c++)E[c].apply(this,arguments)},transformToArrayFormat:function(b,
29
- a){if(!a)return[];var c=b.data.key.children,d=[];if(j.isArray(a))for(var f=0,g=a.length;f<g;f++)d.push(a[f]),a[f][c]&&(d=d.concat(h.transformToArrayFormat(b,a[f][c])));else d.push(a),a[c]&&(d=d.concat(h.transformToArrayFormat(b,a[c])));return d},transformTozTreeFormat:function(b,a){var c,d,f=b.data.simpleData.idKey,g=b.data.simpleData.pIdKey,e=b.data.key.children;if(!f||f==""||!a)return[];if(j.isArray(a)){var h=[],i=[];for(c=0,d=a.length;c<d;c++)i[a[c][f]]=a[c];for(c=0,d=a.length;c<d;c++)i[a[c][g]]&&
30
- a[c][f]!=a[c][g]?(i[a[c][g]][e]||(i[a[c][g]][e]=[]),i[a[c][g]][e].push(a[c])):h.push(a[c]);return h}else return[a]}},m={bindEvent:function(b){for(var a=0,c=u.length;a<c;a++)u[a].apply(this,arguments)},unbindEvent:function(b){for(var a=0,c=v.length;a<c;a++)v[a].apply(this,arguments)},bindTree:function(b){var a={treeId:b.treeId},b=b.treeObj;b.bind("selectstart",function(a){a=a.srcElement.nodeName.toLowerCase();return a==="input"||a==="textarea"}).css({"-moz-user-select":"-moz-none"});b.bind("click",
31
- a,m.proxy);b.bind("dblclick",a,m.proxy);b.bind("mouseover",a,m.proxy);b.bind("mouseout",a,m.proxy);b.bind("mousedown",a,m.proxy);b.bind("mouseup",a,m.proxy);b.bind("contextmenu",a,m.proxy)},unbindTree:function(b){b.treeObj.unbind("click",m.proxy).unbind("dblclick",m.proxy).unbind("mouseover",m.proxy).unbind("mouseout",m.proxy).unbind("mousedown",m.proxy).unbind("mouseup",m.proxy).unbind("contextmenu",m.proxy)},doProxy:function(b){for(var a=[],c=0,d=y.length;c<d;c++){var f=y[c].apply(this,arguments);
32
- a.push(f);if(f.stop)break}return a},proxy:function(b){var a=h.getSetting(b.data.treeId);if(!j.uCanDo(a,b))return!0;for(var a=m.doProxy(b),c=!0,d=0,f=a.length;d<f;d++){var g=a[d];g.nodeEventCallback&&(c=g.nodeEventCallback.apply(g,[b,g.node])&&c);g.treeEventCallback&&(c=g.treeEventCallback.apply(g,[b,g.node])&&c)}return c}};F=function(b,a){var c=h.getSetting(b.data.treeId);if(a.open){if(j.apply(c.callback.beforeCollapse,[c.treeId,a],!0)==!1)return!0}else if(j.apply(c.callback.beforeExpand,[c.treeId,
33
- a],!0)==!1)return!0;h.getRoot(c).expandTriggerFlag=!0;i.switchNode(c,a);return!0};G=function(b,a){var c=h.getSetting(b.data.treeId),d=c.view.autoCancelSelected&&b.ctrlKey&&h.isSelectedNode(c,a)?0:c.view.autoCancelSelected&&b.ctrlKey&&c.view.selectedMulti?2:1;if(j.apply(c.callback.beforeClick,[c.treeId,a,d],!0)==!1)return!0;d===0?i.cancelPreSelectedNode(c,a):i.selectNode(c,a,d===2);c.treeObj.trigger(e.event.CLICK,[b,c.treeId,a,d]);return!0};H=function(b,a){var c=h.getSetting(b.data.treeId);j.apply(c.callback.beforeMouseDown,
34
- [c.treeId,a],!0)&&j.apply(c.callback.onMouseDown,[b,c.treeId,a]);return!0};I=function(b,a){var c=h.getSetting(b.data.treeId);j.apply(c.callback.beforeMouseUp,[c.treeId,a],!0)&&j.apply(c.callback.onMouseUp,[b,c.treeId,a]);return!0};J=function(b,a){var c=h.getSetting(b.data.treeId);j.apply(c.callback.beforeDblClick,[c.treeId,a],!0)&&j.apply(c.callback.onDblClick,[b,c.treeId,a]);return!0};K=function(b,a){var c=h.getSetting(b.data.treeId);j.apply(c.callback.beforeRightClick,[c.treeId,a],!0)&&j.apply(c.callback.onRightClick,
35
- [b,c.treeId,a]);return typeof c.callback.onRightClick!="function"};var j={apply:function(b,a,c){return typeof b=="function"?b.apply(N,a?a:[]):c},canAsync:function(b,a){var c=b.data.key.children;return b.async.enable&&a&&a.isParent&&!(a.zAsync||a[c]&&a[c].length>0)},clone:function(b){if(b===null)return null;var a=b.constructor===Array?[]:{},c;for(c in b)a[c]=b[c]instanceof Date?new Date(b[c].getTime()):typeof b[c]==="object"?arguments.callee(b[c]):b[c];return a},eqs:function(b,a){return b.toLowerCase()===
36
- a.toLowerCase()},isArray:function(b){return Object.prototype.toString.apply(b)==="[object Array]"},getMDom:function(b,a,c){if(!a)return null;for(;a&&a.id!==b.treeId;){for(var d=0,f=c.length;a.tagName&&d<f;d++)if(j.eqs(a.tagName,c[d].tagName)&&a.getAttribute(c[d].attrName)!==null)return a;a=a.parentNode}return null},uCanDo:function(){return!0}},i={addNodes:function(b,a,c,d){if(!b.data.keep.leaf||!a||a.isParent)if(j.isArray(c)||(c=[c]),b.data.simpleData.enable&&(c=h.transformTozTreeFormat(b,c)),a){var f=
37
- k("#"+a.tId+e.id.SWITCH),g=k("#"+a.tId+e.id.ICON),l=k("#"+a.tId+e.id.UL);if(!a.open)i.replaceSwitchClass(a,f,e.folder.CLOSE),i.replaceIcoClass(a,g,e.folder.CLOSE),a.open=!1,l.css({display:"none"});h.addNodesData(b,a,c);i.createNodes(b,a.level+1,c,a);d||i.expandCollapseParentNode(b,a,!0)}else h.addNodesData(b,h.getRoot(b),c),i.createNodes(b,0,c,null)},appendNodes:function(b,a,c,d,f,g){if(!c)return[];for(var e=[],j=b.data.key.children,k=0,m=c.length;k<m;k++){var o=c[k];if(f){var s=(d?d:h.getRoot(b))[j].length==
38
- c.length&&k==0;h.initNode(b,a,o,d,s,k==c.length-1,g);h.addNodeCache(b,o)}s=[];o[j]&&o[j].length>0&&(s=i.appendNodes(b,a+1,o[j],o,f,g&&o.open));g&&(i.makeDOMNodeMainBefore(e,b,o),i.makeDOMNodeLine(e,b,o),h.getBeforeA(b,o,e),i.makeDOMNodeNameBefore(e,b,o),h.getInnerBeforeA(b,o,e),i.makeDOMNodeIcon(e,b,o),h.getInnerAfterA(b,o,e),i.makeDOMNodeNameAfter(e,b,o),h.getAfterA(b,o,e),o.isParent&&o.open&&i.makeUlHtml(b,o,e,s.join("")),i.makeDOMNodeMainAfter(e,b,o),h.addCreatedNode(b,o))}return e},appendParentULDom:function(b,
39
- a){var c=[],d=k("#"+a.tId),f=k("#"+a.tId+e.id.UL),g=i.appendNodes(b,a.level+1,a[b.data.key.children],a,!1,!0);i.makeUlHtml(b,a,c,g.join(""));!d.get(0)&&a.parentTId&&(i.appendParentULDom(b,a.getParentNode()),d=k("#"+a.tId));f.get(0)&&f.remove();d.append(c.join(""))},asyncNode:function(b,a,c,d){var f,g;if(a&&!a.isParent)return j.apply(d),!1;else if(a&&a.isAjaxing)return!1;else if(j.apply(b.callback.beforeAsync,[b.treeId,a],!0)==!1)return j.apply(d),!1;if(a)a.isAjaxing=!0,k("#"+a.tId+e.id.ICON).attr({style:"",
40
- "class":"button ico_loading"});var l={};for(f=0,g=b.async.autoParam.length;a&&f<g;f++){var q=b.async.autoParam[f].split("="),n=q;q.length>1&&(n=q[1],q=q[0]);l[n]=a[q]}if(j.isArray(b.async.otherParam))for(f=0,g=b.async.otherParam.length;f<g;f+=2)l[b.async.otherParam[f]]=b.async.otherParam[f+1];else for(var m in b.async.otherParam)l[m]=b.async.otherParam[m];var o=h.getRoot(b)._ver;k.ajax({contentType:b.async.contentType,type:b.async.type,url:j.apply(b.async.url,[b.treeId,a],b.async.url),data:l,dataType:b.async.dataType,
41
- success:function(f){if(o==h.getRoot(b)._ver){var g=[];try{g=!f||f.length==0?[]:typeof f=="string"?eval("("+f+")"):f}catch(l){g=f}if(a)a.isAjaxing=null,a.zAsync=!0;i.setNodeLineIcos(b,a);g&&g!==""?(g=j.apply(b.async.dataFilter,[b.treeId,a,g],g),i.addNodes(b,a,g?j.clone(g):[],!!c)):i.addNodes(b,a,[],!!c);b.treeObj.trigger(e.event.ASYNC_SUCCESS,[b.treeId,a,f]);j.apply(d)}},error:function(c,d,f){if(o==h.getRoot(b)._ver){if(a)a.isAjaxing=null;i.setNodeLineIcos(b,a);b.treeObj.trigger(e.event.ASYNC_ERROR,
42
- [b.treeId,a,c,d,f])}}});return!0},cancelPreSelectedNode:function(b,a){for(var c=h.getRoot(b).curSelectedList,d=c.length-1;d>=0;d--)if(!a||a===c[d])if(k("#"+c[d].tId+e.id.A).removeClass(e.node.CURSELECTED),a){h.removeSelectedNode(b,a);break}if(!a)h.getRoot(b).curSelectedList=[]},createNodeCallback:function(b){if(b.callback.onNodeCreated||b.view.addDiyDom)for(var a=h.getRoot(b);a.createdNodes.length>0;){var c=a.createdNodes.shift();j.apply(b.view.addDiyDom,[b.treeId,c]);b.callback.onNodeCreated&&b.treeObj.trigger(e.event.NODECREATED,
43
- [b.treeId,c])}},createNodes:function(b,a,c,d){if(c&&c.length!=0){var f=h.getRoot(b),g=b.data.key.children,g=!d||d.open||!!k("#"+d[g][0].tId).get(0);f.createdNodes=[];a=i.appendNodes(b,a,c,d,!0,g);d?(d=k("#"+d.tId+e.id.UL),d.get(0)&&d.append(a.join(""))):b.treeObj.append(a.join(""));i.createNodeCallback(b)}},destroy:function(b){b&&(h.initCache(b),h.initRoot(b),m.unbindTree(b),m.unbindEvent(b),b.treeObj.empty())},expandCollapseNode:function(b,a,c,d,f){var g=h.getRoot(b),l=b.data.key.children;if(a){if(g.expandTriggerFlag){var q=
44
- f,f=function(){q&&q();a.open?b.treeObj.trigger(e.event.EXPAND,[b.treeId,a]):b.treeObj.trigger(e.event.COLLAPSE,[b.treeId,a])};g.expandTriggerFlag=!1}if(!a.open&&a.isParent&&(!k("#"+a.tId+e.id.UL).get(0)||a[l]&&a[l].length>0&&!k("#"+a[l][0].tId).get(0)))i.appendParentULDom(b,a),i.createNodeCallback(b);if(a.open==c)j.apply(f,[]);else{var c=k("#"+a.tId+e.id.UL),g=k("#"+a.tId+e.id.SWITCH),n=k("#"+a.tId+e.id.ICON);a.isParent?(a.open=!a.open,a.iconOpen&&a.iconClose&&n.attr("style",i.makeNodeIcoStyle(b,
45
- a)),a.open?(i.replaceSwitchClass(a,g,e.folder.OPEN),i.replaceIcoClass(a,n,e.folder.OPEN),d==!1||b.view.expandSpeed==""?(c.show(),j.apply(f,[])):a[l]&&a[l].length>0?c.slideDown(b.view.expandSpeed,f):(c.show(),j.apply(f,[]))):(i.replaceSwitchClass(a,g,e.folder.CLOSE),i.replaceIcoClass(a,n,e.folder.CLOSE),d==!1||b.view.expandSpeed==""||!(a[l]&&a[l].length>0)?(c.hide(),j.apply(f,[])):c.slideUp(b.view.expandSpeed,f))):j.apply(f,[])}}else j.apply(f,[])},expandCollapseParentNode:function(b,a,c,d,f){a&&(a.parentTId?
46
- (i.expandCollapseNode(b,a,c,d),a.parentTId&&i.expandCollapseParentNode(b,a.getParentNode(),c,d,f)):i.expandCollapseNode(b,a,c,d,f))},expandCollapseSonNode:function(b,a,c,d,f){var g=h.getRoot(b),e=b.data.key.children,g=a?a[e]:g[e],e=a?!1:d,j=h.getRoot(b).expandTriggerFlag;h.getRoot(b).expandTriggerFlag=!1;if(g)for(var k=0,m=g.length;k<m;k++)g[k]&&i.expandCollapseSonNode(b,g[k],c,e);h.getRoot(b).expandTriggerFlag=j;i.expandCollapseNode(b,a,c,d,f)},makeDOMNodeIcon:function(b,a,c){var d=h.getNodeName(a,
47
- c),d=a.view.nameIsHTML?d:d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");b.push("<span id='",c.tId,e.id.ICON,"' title='' treeNode",e.id.ICON," class='",i.makeNodeIcoClass(a,c),"' style='",i.makeNodeIcoStyle(a,c),"'></span><span id='",c.tId,e.id.SPAN,"'>",d,"</span>")},makeDOMNodeLine:function(b,a,c){b.push("<span id='",c.tId,e.id.SWITCH,"' title='' class='",i.makeNodeLineClass(a,c),"' treeNode",e.id.SWITCH,"></span>")},makeDOMNodeMainAfter:function(b){b.push("</li>")},makeDOMNodeMainBefore:function(b,
48
- a,c){b.push("<li id='",c.tId,"' class='level",c.level,"' tabindex='0' hidefocus='true' treenode>")},makeDOMNodeNameAfter:function(b){b.push("</a>")},makeDOMNodeNameBefore:function(b,a,c){var d=h.getNodeTitle(a,c),f=i.makeNodeUrl(a,c),g=i.makeNodeFontCss(a,c),l=[],k;for(k in g)l.push(k,":",g[k],";");b.push("<a id='",c.tId,e.id.A,"' class='level",c.level,"' treeNode",e.id.A,' onclick="',c.click||"",'" ',f!=null&&f.length>0?"href='"+f+"'":""," target='",i.makeNodeTarget(c),"' style='",l.join(""),"'");
49
- j.apply(a.view.showTitle,[a.treeId,c],a.view.showTitle)&&d&&b.push("title='",d.replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"'");b.push(">")},makeNodeFontCss:function(b,a){var c=j.apply(b.view.fontCss,[b.treeId,a],b.view.fontCss);return c&&typeof c!="function"?c:{}},makeNodeIcoClass:function(b,a){var c=["ico"];a.isAjaxing||(c[0]=(a.iconSkin?a.iconSkin+"_":"")+c[0],a.isParent?c.push(a.open?e.folder.OPEN:e.folder.CLOSE):c.push(e.folder.DOCU));return"button "+c.join("_")},makeNodeIcoStyle:function(b,
50
- a){var c=[];if(!a.isAjaxing){var d=a.isParent&&a.iconOpen&&a.iconClose?a.open?a.iconOpen:a.iconClose:a.icon;d&&c.push("background:url(",d,") 0 0 no-repeat;");(b.view.showIcon==!1||!j.apply(b.view.showIcon,[b.treeId,a],!0))&&c.push("width:0px;height:0px;")}return c.join("")},makeNodeLineClass:function(b,a){var c=[];b.view.showLine?a.level==0&&a.isFirstNode&&a.isLastNode?c.push(e.line.ROOT):a.level==0&&a.isFirstNode?c.push(e.line.ROOTS):a.isLastNode?c.push(e.line.BOTTOM):c.push(e.line.CENTER):c.push(e.line.NOLINE);
51
- a.isParent?c.push(a.open?e.folder.OPEN:e.folder.CLOSE):c.push(e.folder.DOCU);return i.makeNodeLineClassEx(a)+c.join("_")},makeNodeLineClassEx:function(b){return"button level"+b.level+" switch "},makeNodeTarget:function(b){return b.target||"_blank"},makeNodeUrl:function(b,a){var c=b.data.key.url;return a[c]?a[c]:null},makeUlHtml:function(b,a,c,d){c.push("<ul id='",a.tId,e.id.UL,"' class='level",a.level," ",i.makeUlLineClass(b,a),"' style='display:",a.open?"block":"none","'>");c.push(d);c.push("</ul>")},
52
- makeUlLineClass:function(b,a){return b.view.showLine&&!a.isLastNode?e.line.LINE:""},removeChildNodes:function(b,a){if(a){var c=b.data.key.children,d=a[c];if(d){for(var f=0,g=d.length;f<g;f++)h.removeNodeCache(b,d[f]);h.removeSelectedNode(b);delete a[c];b.data.keep.parent?k("#"+a.tId+e.id.UL).empty():(a.isParent=!1,a.open=!1,c=k("#"+a.tId+e.id.SWITCH),d=k("#"+a.tId+e.id.ICON),i.replaceSwitchClass(a,c,e.folder.DOCU),i.replaceIcoClass(a,d,e.folder.DOCU),k("#"+a.tId+e.id.UL).remove())}}},setFirstNode:function(b,
53
- a){var c=b.data.key.children;if(a[c].length>0)a[c][0].isFirstNode=!0},setLastNode:function(b,a){var c=b.data.key.children,d=a[c].length;if(d>0)a[c][d-1].isLastNode=!0},removeNode:function(b,a){var c=h.getRoot(b),d=b.data.key.children,f=a.parentTId?a.getParentNode():c;a.isFirstNode=!1;a.isLastNode=!1;a.getPreNode=function(){return null};a.getNextNode=function(){return null};if(h.getNodeCache(b,a.tId)){k("#"+a.tId).remove();h.removeNodeCache(b,a);h.removeSelectedNode(b,a);for(var g=0,l=f[d].length;g<
54
- l;g++)if(f[d][g].tId==a.tId){f[d].splice(g,1);break}i.setFirstNode(b,f);i.setLastNode(b,f);var j,g=f[d].length;if(!b.data.keep.parent&&g==0)f.isParent=!1,f.open=!1,g=k("#"+f.tId+e.id.UL),l=k("#"+f.tId+e.id.SWITCH),j=k("#"+f.tId+e.id.ICON),i.replaceSwitchClass(f,l,e.folder.DOCU),i.replaceIcoClass(f,j,e.folder.DOCU),g.css("display","none");else if(b.view.showLine&&g>0){var n=f[d][g-1],g=k("#"+n.tId+e.id.UL),l=k("#"+n.tId+e.id.SWITCH);j=k("#"+n.tId+e.id.ICON);f==c?f[d].length==1?i.replaceSwitchClass(n,
55
- l,e.line.ROOT):(c=k("#"+f[d][0].tId+e.id.SWITCH),i.replaceSwitchClass(f[d][0],c,e.line.ROOTS),i.replaceSwitchClass(n,l,e.line.BOTTOM)):i.replaceSwitchClass(n,l,e.line.BOTTOM);g.removeClass(e.line.LINE)}}},replaceIcoClass:function(b,a,c){if(a&&!b.isAjaxing&&(b=a.attr("class"),b!=void 0)){b=b.split("_");switch(c){case e.folder.OPEN:case e.folder.CLOSE:case e.folder.DOCU:b[b.length-1]=c}a.attr("class",b.join("_"))}},replaceSwitchClass:function(b,a,c){if(a){var d=a.attr("class");if(d!=void 0){d=d.split("_");
56
- switch(c){case e.line.ROOT:case e.line.ROOTS:case e.line.CENTER:case e.line.BOTTOM:case e.line.NOLINE:d[0]=i.makeNodeLineClassEx(b)+c;break;case e.folder.OPEN:case e.folder.CLOSE:case e.folder.DOCU:d[1]=c}a.attr("class",d.join("_"));c!==e.folder.DOCU?a.removeAttr("disabled"):a.attr("disabled","disabled")}}},selectNode:function(b,a,c){c||i.cancelPreSelectedNode(b);k("#"+a.tId+e.id.A).addClass(e.node.CURSELECTED);h.addSelectedNode(b,a)},setNodeFontCss:function(b,a){var c=k("#"+a.tId+e.id.A),d=i.makeNodeFontCss(b,
57
- a);d&&c.css(d)},setNodeLineIcos:function(b,a){if(a){var c=k("#"+a.tId+e.id.SWITCH),d=k("#"+a.tId+e.id.UL),f=k("#"+a.tId+e.id.ICON),g=i.makeUlLineClass(b,a);g.length==0?d.removeClass(e.line.LINE):d.addClass(g);c.attr("class",i.makeNodeLineClass(b,a));a.isParent?c.removeAttr("disabled"):c.attr("disabled","disabled");f.removeAttr("style");f.attr("style",i.makeNodeIcoStyle(b,a));f.attr("class",i.makeNodeIcoClass(b,a))}},setNodeName:function(b,a){var c=h.getNodeTitle(b,a),d=k("#"+a.tId+e.id.SPAN);d.empty();
58
- b.view.nameIsHTML?d.html(h.getNodeName(b,a)):d.text(h.getNodeName(b,a));j.apply(b.view.showTitle,[b.treeId,a],b.view.showTitle)&&k("#"+a.tId+e.id.A).attr("title",!c?"":c)},setNodeTarget:function(b){k("#"+b.tId+e.id.A).attr("target",i.makeNodeTarget(b))},setNodeUrl:function(b,a){var c=k("#"+a.tId+e.id.A),d=i.makeNodeUrl(b,a);d==null||d.length==0?c.removeAttr("href"):c.attr("href",d)},switchNode:function(b,a){a.open||!j.canAsync(b,a)?i.expandCollapseNode(b,a,!a.open):b.async.enable?i.asyncNode(b,a)||
59
- i.expandCollapseNode(b,a,!a.open):a&&i.expandCollapseNode(b,a,!a.open)}};k.fn.zTree={consts:{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"}},
60
- _z:{tools:j,view:i,event:m,data:h},getZTreeObj:function(b){return(b=h.getZTreeTools(b))?b:null},destroy:function(b){if(b&&b.length>0)i.destroy(h.getSetting(b));else for(var a in r)i.destroy(r[a])},init:function(b,a,c){var d=j.clone(M);k.extend(!0,d,a);d.treeId=b.attr("id");d.treeObj=b;d.treeObj.empty();r[d.treeId]=d;if(typeof document.body.style.maxHeight==="undefined")d.view.expandSpeed="";h.initRoot(d);b=h.getRoot(d);a=d.data.key.children;c=c?j.clone(j.isArray(c)?c:[c]):[];b[a]=d.data.simpleData.enable?
61
- h.transformTozTreeFormat(d,c):c;h.initCache(d);m.unbindTree(d);m.bindTree(d);m.unbindEvent(d);m.bindEvent(d);c={setting:d,addNodes:function(a,b,c){function e(){i.addNodes(d,a,h,c==!0)}if(!b)return null;a||(a=null);if(a&&!a.isParent&&d.data.keep.leaf)return null;var h=j.clone(j.isArray(b)?b:[b]);j.canAsync(d,a)?i.asyncNode(d,a,c,e):e();return h},cancelSelectedNode:function(a){i.cancelPreSelectedNode(this.setting,a)},destroy:function(){i.destroy(this.setting)},expandAll:function(a){a=!!a;i.expandCollapseSonNode(this.setting,
62
- null,a,!0);return a},expandNode:function(a,b,c,e,n){if(!a||!a.isParent)return null;b!==!0&&b!==!1&&(b=!a.open);if((n=!!n)&&b&&j.apply(d.callback.beforeExpand,[d.treeId,a],!0)==!1)return null;else if(n&&!b&&j.apply(d.callback.beforeCollapse,[d.treeId,a],!0)==!1)return null;b&&a.parentTId&&i.expandCollapseParentNode(this.setting,a.getParentNode(),b,!1);if(b===a.open&&!c)return null;h.getRoot(d).expandTriggerFlag=n;if(c)i.expandCollapseSonNode(this.setting,a,b,!0,function(){if(e!==!1)try{k("#"+a.tId).focus().blur()}catch(b){}});
63
- else if(a.open=!b,i.switchNode(this.setting,a),e!==!1)try{k("#"+a.tId).focus().blur()}catch(m){}return b},getNodes:function(){return h.getNodes(this.setting)},getNodeByParam:function(a,b,c){return!a?null:h.getNodeByParam(this.setting,c?c[this.setting.data.key.children]:h.getNodes(this.setting),a,b)},getNodeByTId:function(a){return h.getNodeCache(this.setting,a)},getNodesByParam:function(a,b,c){return!a?null:h.getNodesByParam(this.setting,c?c[this.setting.data.key.children]:h.getNodes(this.setting),
64
- a,b)},getNodesByParamFuzzy:function(a,b,c){return!a?null:h.getNodesByParamFuzzy(this.setting,c?c[this.setting.data.key.children]:h.getNodes(this.setting),a,b)},getNodesByFilter:function(a,b,c,d){b=!!b;return!a||typeof a!="function"?b?null:[]:h.getNodesByFilter(this.setting,c?c[this.setting.data.key.children]:h.getNodes(this.setting),a,b,d)},getNodeIndex:function(a){if(!a)return null;for(var b=d.data.key.children,c=a.parentTId?a.getParentNode():h.getRoot(this.setting),e=0,i=c[b].length;e<i;e++)if(c[b][e]==
65
- a)return e;return-1},getSelectedNodes:function(){for(var a=[],b=h.getRoot(this.setting).curSelectedList,c=0,d=b.length;c<d;c++)a.push(b[c]);return a},isSelectedNode:function(a){return h.isSelectedNode(this.setting,a)},reAsyncChildNodes:function(a,b,c){if(this.setting.async.enable){var j=!a;j&&(a=h.getRoot(this.setting));if(b=="refresh"){for(var b=this.setting.data.key.children,m=0,p=a[b]?a[b].length:0;m<p;m++)h.removeNodeCache(d,a[b][m]);h.removeSelectedNode(d);a[b]=[];j?this.setting.treeObj.empty():
66
- k("#"+a.tId+e.id.UL).empty()}i.asyncNode(this.setting,j?null:a,!!c)}},refresh:function(){this.setting.treeObj.empty();var a=h.getRoot(this.setting),b=a[this.setting.data.key.children];h.initRoot(this.setting);a[this.setting.data.key.children]=b;h.initCache(this.setting);i.createNodes(this.setting,0,a[this.setting.data.key.children])},removeChildNodes:function(a){if(!a)return null;var b=a[d.data.key.children];i.removeChildNodes(d,a);return b?b:null},removeNode:function(a,b){a&&(b=!!b,b&&j.apply(d.callback.beforeRemove,
67
- [d.treeId,a],!0)==!1||(i.removeNode(d,a),b&&this.setting.treeObj.trigger(e.event.REMOVE,[d.treeId,a])))},selectNode:function(a,b){if(a&&j.uCanDo(this.setting)){b=d.view.selectedMulti&&b;if(a.parentTId)i.expandCollapseParentNode(this.setting,a.getParentNode(),!0,!1,function(){try{k("#"+a.tId).focus().blur()}catch(b){}});else try{k("#"+a.tId).focus().blur()}catch(c){}i.selectNode(this.setting,a,b)}},transformTozTreeNodes:function(a){return h.transformTozTreeFormat(this.setting,a)},transformToArray:function(a){return h.transformToArrayFormat(this.setting,
68
- a)},updateNode:function(a){a&&k("#"+a.tId).get(0)&&j.uCanDo(this.setting)&&(i.setNodeName(this.setting,a),i.setNodeTarget(a),i.setNodeUrl(this.setting,a),i.setNodeLineIcos(this.setting,a),i.setNodeFontCss(this.setting,a))}};b.treeTools=c;h.setZTreeTools(d,c);b[a]&&b[a].length>0?i.createNodes(d,0,b[a]):d.async.enable&&d.async.url&&d.async.url!==""&&i.asyncNode(d);return c}};var N=k.fn.zTree,e=N.consts})(jQuery);
@@ -1,624 +0,0 @@
1
- /*
2
- * JQuery zTree excheck 3.5.02
3
- * http://zTree.me/
4
- *
5
- * Copyright (c) 2010 Hunter.z
6
- *
7
- * Licensed same as jquery - MIT License
8
- * http://www.opensource.org/licenses/mit-license.php
9
- *
10
- * email: hunter.z@263.net
11
- * Date: 2013-01-28
12
- */
13
- (function($){
14
- //default consts of excheck
15
- var _consts = {
16
- event: {
17
- CHECK: "ztree_check"
18
- },
19
- id: {
20
- CHECK: "_check"
21
- },
22
- checkbox: {
23
- STYLE: "checkbox",
24
- DEFAULT: "chk",
25
- DISABLED: "disable",
26
- FALSE: "false",
27
- TRUE: "true",
28
- FULL: "full",
29
- PART: "part",
30
- FOCUS: "focus"
31
- },
32
- radio: {
33
- STYLE: "radio",
34
- TYPE_ALL: "all",
35
- TYPE_LEVEL: "level"
36
- }
37
- },
38
- //default setting of excheck
39
- _setting = {
40
- check: {
41
- enable: false,
42
- autoCheckTrigger: false,
43
- chkStyle: _consts.checkbox.STYLE,
44
- nocheckInherit: false,
45
- chkDisabledInherit: false,
46
- radioType: _consts.radio.TYPE_LEVEL,
47
- chkboxType: {
48
- "Y": "ps",
49
- "N": "ps"
50
- }
51
- },
52
- data: {
53
- key: {
54
- checked: "checked"
55
- }
56
- },
57
- callback: {
58
- beforeCheck:null,
59
- onCheck:null
60
- }
61
- },
62
- //default root of excheck
63
- _initRoot = function (setting) {
64
- var r = data.getRoot(setting);
65
- r.radioCheckedList = [];
66
- },
67
- //default cache of excheck
68
- _initCache = function(treeId) {},
69
- //default bind event of excheck
70
- _bindEvent = function(setting) {
71
- var o = setting.treeObj,
72
- c = consts.event;
73
- o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
74
- tools.apply(setting.callback.onCheck, [!!srcEvent?srcEvent : event, treeId, node]);
75
- });
76
- },
77
- _unbindEvent = function(setting) {
78
- var o = setting.treeObj,
79
- c = consts.event;
80
- o.unbind(c.CHECK);
81
- },
82
- //default event proxy of excheck
83
- _eventProxy = function(e) {
84
- var target = e.target,
85
- setting = data.getSetting(e.data.treeId),
86
- tId = "", node = null,
87
- nodeEventType = "", treeEventType = "",
88
- nodeEventCallback = null, treeEventCallback = null;
89
-
90
- if (tools.eqs(e.type, "mouseover")) {
91
- if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
92
- tId = target.parentNode.id;
93
- nodeEventType = "mouseoverCheck";
94
- }
95
- } else if (tools.eqs(e.type, "mouseout")) {
96
- if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
97
- tId = target.parentNode.id;
98
- nodeEventType = "mouseoutCheck";
99
- }
100
- } else if (tools.eqs(e.type, "click")) {
101
- if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
102
- tId = target.parentNode.id;
103
- nodeEventType = "checkNode";
104
- }
105
- }
106
- if (tId.length>0) {
107
- node = data.getNodeCache(setting, tId);
108
- switch (nodeEventType) {
109
- case "checkNode" :
110
- nodeEventCallback = _handler.onCheckNode;
111
- break;
112
- case "mouseoverCheck" :
113
- nodeEventCallback = _handler.onMouseoverCheck;
114
- break;
115
- case "mouseoutCheck" :
116
- nodeEventCallback = _handler.onMouseoutCheck;
117
- break;
118
- }
119
- }
120
- var proxyResult = {
121
- stop: false,
122
- node: node,
123
- nodeEventType: nodeEventType,
124
- nodeEventCallback: nodeEventCallback,
125
- treeEventType: treeEventType,
126
- treeEventCallback: treeEventCallback
127
- };
128
- return proxyResult
129
- },
130
- //default init node of excheck
131
- _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
132
- if (!n) return;
133
- var checkedKey = setting.data.key.checked;
134
- if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
135
- n[checkedKey] = !!n[checkedKey];
136
- n.checkedOld = n[checkedKey];
137
- if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
138
- n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
139
- if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
140
- n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
141
- if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
142
- n.halfCheck = !!n.halfCheck;
143
- n.check_Child_State = -1;
144
- n.check_Focus = false;
145
- n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
146
- },
147
- //add dom for check
148
- _beforeA = function(setting, node, html) {
149
- var checkedKey = setting.data.key.checked;
150
- if (setting.check.enable) {
151
- data.makeChkFlag(setting, node);
152
- if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && node[checkedKey] ) {
153
- var r = data.getRoot(setting);
154
- r.radioCheckedList.push(node);
155
- }
156
- html.push("<span ID='", node.tId, consts.id.CHECK, "' class='", view.makeChkClass(setting, node), "' treeNode", consts.id.CHECK, (node.nocheck === true?" style='display:none;'":""),"></span>");
157
- }
158
- },
159
- //update zTreeObj, add method of check
160
- _zTreeTools = function(setting, zTreeTools) {
161
- zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
162
- var checkedKey = this.setting.data.key.checked;
163
- if (node.chkDisabled === true) return;
164
- if (checked !== true && checked !== false) {
165
- checked = !node[checkedKey];
166
- }
167
- callbackFlag = !!callbackFlag;
168
-
169
- if (node[checkedKey] === checked && !checkTypeFlag) {
170
- return;
171
- } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
172
- return;
173
- }
174
- if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
175
- node[checkedKey] = checked;
176
- var checkObj = $("#" + node.tId + consts.id.CHECK);
177
- if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
178
- view.setChkClass(this.setting, checkObj, node);
179
- view.repairParentChkClassWithSelf(this.setting, node);
180
- if (callbackFlag) {
181
- setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
182
- }
183
- }
184
- }
185
-
186
- zTreeTools.checkAllNodes = function(checked) {
187
- view.repairAllChk(this.setting, !!checked);
188
- }
189
-
190
- zTreeTools.getCheckedNodes = function(checked) {
191
- var childKey = this.setting.data.key.children;
192
- checked = (checked !== false);
193
- return data.getTreeCheckedNodes(this.setting, data.getRoot(setting)[childKey], checked);
194
- }
195
-
196
- zTreeTools.getChangeCheckedNodes = function() {
197
- var childKey = this.setting.data.key.children;
198
- return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(setting)[childKey]);
199
- }
200
-
201
- zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
202
- disabled = !!disabled;
203
- inheritParent = !!inheritParent;
204
- inheritChildren = !!inheritChildren;
205
- view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
206
- view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
207
- }
208
-
209
- var _updateNode = zTreeTools.updateNode;
210
- zTreeTools.updateNode = function(node, checkTypeFlag) {
211
- if (_updateNode) _updateNode.apply(zTreeTools, arguments);
212
- if (!node || !this.setting.check.enable) return;
213
- var nObj = $("#" + node.tId);
214
- if (nObj.get(0) && tools.uCanDo(this.setting)) {
215
- var checkObj = $("#" + node.tId + consts.id.CHECK);
216
- if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
217
- view.setChkClass(this.setting, checkObj, node);
218
- view.repairParentChkClassWithSelf(this.setting, node);
219
- }
220
- }
221
- },
222
- //method of operate data
223
- _data = {
224
- getRadioCheckedList: function(setting) {
225
- var checkedList = data.getRoot(setting).radioCheckedList;
226
- for (var i=0, j=checkedList.length; i<j; i++) {
227
- if(!data.getNodeCache(setting, checkedList[i].tId)) {
228
- checkedList.splice(i, 1);
229
- i--; j--;
230
- }
231
- }
232
- return checkedList;
233
- },
234
- getCheckStatus: function(setting, node) {
235
- if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
236
- var checkedKey = setting.data.key.checked,
237
- r = {
238
- checked: node[checkedKey],
239
- half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (node[checkedKey] ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0)))
240
- };
241
- return r;
242
- },
243
- getTreeCheckedNodes: function(setting, nodes, checked, results) {
244
- if (!nodes) return [];
245
- var childKey = setting.data.key.children,
246
- checkedKey = setting.data.key.checked,
247
- onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
248
- results = !results ? [] : results;
249
- for (var i = 0, l = nodes.length; i < l; i++) {
250
- if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
251
- results.push(nodes[i]);
252
- if(onlyOne) {
253
- break;
254
- }
255
- }
256
- data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
257
- if(onlyOne && results.length > 0) {
258
- break;
259
- }
260
- }
261
- return results;
262
- },
263
- getTreeChangeCheckedNodes: function(setting, nodes, results) {
264
- if (!nodes) return [];
265
- var childKey = setting.data.key.children,
266
- checkedKey = setting.data.key.checked;
267
- results = !results ? [] : results;
268
- for (var i = 0, l = nodes.length; i < l; i++) {
269
- if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
270
- results.push(nodes[i]);
271
- }
272
- data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
273
- }
274
- return results;
275
- },
276
- makeChkFlag: function(setting, node) {
277
- if (!node) return;
278
- var childKey = setting.data.key.children,
279
- checkedKey = setting.data.key.checked,
280
- chkFlag = -1;
281
- if (node[childKey]) {
282
- for (var i = 0, l = node[childKey].length; i < l; i++) {
283
- var cNode = node[childKey][i];
284
- var tmp = -1;
285
- if (setting.check.chkStyle == consts.radio.STYLE) {
286
- if (cNode.nocheck === true || cNode.chkDisabled === true) {
287
- tmp = cNode.check_Child_State;
288
- } else if (cNode.halfCheck === true) {
289
- tmp = 2;
290
- } else if (cNode[checkedKey]) {
291
- tmp = 2;
292
- } else {
293
- tmp = cNode.check_Child_State > 0 ? 2:0;
294
- }
295
- if (tmp == 2) {
296
- chkFlag = 2; break;
297
- } else if (tmp == 0){
298
- chkFlag = 0;
299
- }
300
- } else if (setting.check.chkStyle == consts.checkbox.STYLE) {
301
- if (cNode.nocheck === true || cNode.chkDisabled === true) {
302
- tmp = cNode.check_Child_State;
303
- } else if (cNode.halfCheck === true) {
304
- tmp = 1;
305
- } else if (cNode[checkedKey] ) {
306
- tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
307
- } else {
308
- tmp = (cNode.check_Child_State > 0) ? 1 : 0;
309
- }
310
- if (tmp === 1) {
311
- chkFlag = 1; break;
312
- } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
313
- chkFlag = 1; break;
314
- } else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
315
- chkFlag = 1; break;
316
- } else if (tmp > -1) {
317
- chkFlag = tmp;
318
- }
319
- }
320
- }
321
- }
322
- node.check_Child_State = chkFlag;
323
- }
324
- },
325
- //method of event proxy
326
- _event = {
327
-
328
- },
329
- //method of event handler
330
- _handler = {
331
- onCheckNode: function (event, node) {
332
- if (node.chkDisabled === true) return false;
333
- var setting = data.getSetting(event.data.treeId),
334
- checkedKey = setting.data.key.checked;
335
- if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
336
- node[checkedKey] = !node[checkedKey];
337
- view.checkNodeRelation(setting, node);
338
- var checkObj = $("#" + node.tId + consts.id.CHECK);
339
- view.setChkClass(setting, checkObj, node);
340
- view.repairParentChkClassWithSelf(setting, node);
341
- setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
342
- return true;
343
- },
344
- onMouseoverCheck: function(event, node) {
345
- if (node.chkDisabled === true) return false;
346
- var setting = data.getSetting(event.data.treeId),
347
- checkObj = $("#" + node.tId + consts.id.CHECK);
348
- node.check_Focus = true;
349
- view.setChkClass(setting, checkObj, node);
350
- return true;
351
- },
352
- onMouseoutCheck: function(event, node) {
353
- if (node.chkDisabled === true) return false;
354
- var setting = data.getSetting(event.data.treeId),
355
- checkObj = $("#" + node.tId + consts.id.CHECK);
356
- node.check_Focus = false;
357
- view.setChkClass(setting, checkObj, node);
358
- return true;
359
- }
360
- },
361
- //method of tools for zTree
362
- _tools = {
363
-
364
- },
365
- //method of operate ztree dom
366
- _view = {
367
- checkNodeRelation: function(setting, node) {
368
- var pNode, i, l,
369
- childKey = setting.data.key.children,
370
- checkedKey = setting.data.key.checked,
371
- r = consts.radio;
372
- if (setting.check.chkStyle == r.STYLE) {
373
- var checkedList = data.getRadioCheckedList(setting);
374
- if (node[checkedKey]) {
375
- if (setting.check.radioType == r.TYPE_ALL) {
376
- for (i = checkedList.length-1; i >= 0; i--) {
377
- pNode = checkedList[i];
378
- pNode[checkedKey] = false;
379
- checkedList.splice(i, 1);
380
-
381
- view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode);
382
- if (pNode.parentTId != node.parentTId) {
383
- view.repairParentChkClassWithSelf(setting, pNode);
384
- }
385
- }
386
- checkedList.push(node);
387
- } else {
388
- var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
389
- for (i = 0, l = parentNode[childKey].length; i < l; i++) {
390
- pNode = parentNode[childKey][i];
391
- if (pNode[checkedKey] && pNode != node) {
392
- pNode[checkedKey] = false;
393
- view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode);
394
- }
395
- }
396
- }
397
- } else if (setting.check.radioType == r.TYPE_ALL) {
398
- for (i = 0, l = checkedList.length; i < l; i++) {
399
- if (node == checkedList[i]) {
400
- checkedList.splice(i, 1);
401
- break;
402
- }
403
- }
404
- }
405
-
406
- } else {
407
- if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
408
- view.setSonNodeCheckBox(setting, node, true);
409
- }
410
- if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
411
- view.setSonNodeCheckBox(setting, node, false);
412
- }
413
- if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
414
- view.setParentNodeCheckBox(setting, node, true);
415
- }
416
- if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
417
- view.setParentNodeCheckBox(setting, node, false);
418
- }
419
- }
420
- },
421
- makeChkClass: function(setting, node) {
422
- var checkedKey = setting.data.key.checked,
423
- c = consts.checkbox, r = consts.radio,
424
- fullStyle = "";
425
- if (node.chkDisabled === true) {
426
- fullStyle = c.DISABLED;
427
- } else if (node.halfCheck) {
428
- fullStyle = c.PART;
429
- } else if (setting.check.chkStyle == r.STYLE) {
430
- fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
431
- } else {
432
- fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART);
433
- }
434
- var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
435
- chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
436
- return "button " + c.DEFAULT + " " + chkName;
437
- },
438
- repairAllChk: function(setting, checked) {
439
- if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
440
- var checkedKey = setting.data.key.checked,
441
- childKey = setting.data.key.children,
442
- root = data.getRoot(setting);
443
- for (var i = 0, l = root[childKey].length; i<l ; i++) {
444
- var node = root[childKey][i];
445
- if (node.nocheck !== true && node.chkDisabled !== true) {
446
- node[checkedKey] = checked;
447
- }
448
- view.setSonNodeCheckBox(setting, node, checked);
449
- }
450
- }
451
- },
452
- repairChkClass: function(setting, node) {
453
- if (!node) return;
454
- data.makeChkFlag(setting, node);
455
- if (node.nocheck !== true) {
456
- var checkObj = $("#" + node.tId + consts.id.CHECK);
457
- view.setChkClass(setting, checkObj, node);
458
- }
459
- },
460
- repairParentChkClass: function(setting, node) {
461
- if (!node || !node.parentTId) return;
462
- var pNode = node.getParentNode();
463
- view.repairChkClass(setting, pNode);
464
- view.repairParentChkClass(setting, pNode);
465
- },
466
- repairParentChkClassWithSelf: function(setting, node) {
467
- if (!node) return;
468
- var childKey = setting.data.key.children;
469
- if (node[childKey] && node[childKey].length > 0) {
470
- view.repairParentChkClass(setting, node[childKey][0]);
471
- } else {
472
- view.repairParentChkClass(setting, node);
473
- }
474
- },
475
- repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
476
- if (!node) return;
477
- var childKey = setting.data.key.children;
478
- if (node.chkDisabled != chkDisabled) {
479
- node.chkDisabled = chkDisabled;
480
- }
481
- view.repairChkClass(setting, node);
482
- if (node[childKey] && inherit) {
483
- for (var i = 0, l = node[childKey].length; i < l; i++) {
484
- var sNode = node[childKey][i];
485
- view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
486
- }
487
- }
488
- },
489
- repairParentChkDisabled: function(setting, node, chkDisabled, inherit) {
490
- if (!node) return;
491
- if (node.chkDisabled != chkDisabled && inherit) {
492
- node.chkDisabled = chkDisabled;
493
- }
494
- view.repairChkClass(setting, node);
495
- view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
496
- },
497
- setChkClass: function(setting, obj, node) {
498
- if (!obj) return;
499
- if (node.nocheck === true) {
500
- obj.hide();
501
- } else {
502
- obj.show();
503
- }
504
- obj.removeClass();
505
- obj.addClass(view.makeChkClass(setting, node));
506
- },
507
- setParentNodeCheckBox: function(setting, node, value, srcNode) {
508
- var childKey = setting.data.key.children,
509
- checkedKey = setting.data.key.checked,
510
- checkObj = $("#" + node.tId + consts.id.CHECK);
511
- if (!srcNode) srcNode = node;
512
- data.makeChkFlag(setting, node);
513
- if (node.nocheck !== true && node.chkDisabled !== true) {
514
- node[checkedKey] = value;
515
- view.setChkClass(setting, checkObj, node);
516
- if (setting.check.autoCheckTrigger && node != srcNode) {
517
- setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
518
- }
519
- }
520
- if (node.parentTId) {
521
- var pSign = true;
522
- if (!value) {
523
- var pNodes = node.getParentNode()[childKey];
524
- for (var i = 0, l = pNodes.length; i < l; i++) {
525
- if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
526
- || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
527
- pSign = false;
528
- break;
529
- }
530
- }
531
- }
532
- if (pSign) {
533
- view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
534
- }
535
- }
536
- },
537
- setSonNodeCheckBox: function(setting, node, value, srcNode) {
538
- if (!node) return;
539
- var childKey = setting.data.key.children,
540
- checkedKey = setting.data.key.checked,
541
- checkObj = $("#" + node.tId + consts.id.CHECK);
542
- if (!srcNode) srcNode = node;
543
-
544
- var hasDisable = false;
545
- if (node[childKey]) {
546
- for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) {
547
- var sNode = node[childKey][i];
548
- view.setSonNodeCheckBox(setting, sNode, value, srcNode);
549
- if (sNode.chkDisabled === true) hasDisable = true;
550
- }
551
- }
552
-
553
- if (node != data.getRoot(setting) && node.chkDisabled !== true) {
554
- if (hasDisable && node.nocheck !== true) {
555
- data.makeChkFlag(setting, node);
556
- }
557
- if (node.nocheck !== true && node.chkDisabled !== true) {
558
- node[checkedKey] = value;
559
- if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
560
- } else {
561
- node.check_Child_State = -1;
562
- }
563
- view.setChkClass(setting, checkObj, node);
564
- if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
565
- setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
566
- }
567
- }
568
-
569
- }
570
- },
571
-
572
- _z = {
573
- tools: _tools,
574
- view: _view,
575
- event: _event,
576
- data: _data
577
- };
578
- $.extend(true, $.fn.zTree.consts, _consts);
579
- $.extend(true, $.fn.zTree._z, _z);
580
-
581
- var zt = $.fn.zTree,
582
- tools = zt._z.tools,
583
- consts = zt.consts,
584
- view = zt._z.view,
585
- data = zt._z.data,
586
- event = zt._z.event;
587
-
588
- data.exSetting(_setting);
589
- data.addInitBind(_bindEvent);
590
- data.addInitUnBind(_unbindEvent);
591
- data.addInitCache(_initCache);
592
- data.addInitNode(_initNode);
593
- data.addInitProxy(_eventProxy);
594
- data.addInitRoot(_initRoot);
595
- data.addBeforeA(_beforeA);
596
- data.addZTreeTools(_zTreeTools);
597
-
598
- var _createNodes = view.createNodes;
599
- view.createNodes = function(setting, level, nodes, parentNode) {
600
- if (_createNodes) _createNodes.apply(view, arguments);
601
- if (!nodes) return;
602
- view.repairParentChkClassWithSelf(setting, parentNode);
603
- }
604
- var _removeNode = view.removeNode;
605
- view.removeNode = function(setting, node) {
606
- var parentNode = node.getParentNode();
607
- if (_removeNode) _removeNode.apply(view, arguments);
608
- if (!node || !parentNode) return;
609
- view.repairChkClass(setting, parentNode);
610
- view.repairParentChkClass(setting, parentNode);
611
- }
612
-
613
- var _appendNodes = view.appendNodes;
614
- view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) {
615
- var html = "";
616
- if (_appendNodes) {
617
- html = _appendNodes.apply(view, arguments);
618
- }
619
- if (parentNode) {
620
- data.makeChkFlag(setting, parentNode);
621
- }
622
- return html;
623
- }
624
- })(jQuery);