jquery.ztree.exhide-3.5.min.js 5.22 KB
/*
 * JQuery zTree exHideNodes 3.5.12
 * http://zTree.me/
 *
 * Copyright (c) 2010 Hunter.z
 *
 * Licensed same as jquery - MIT License
 * http://www.opensource.org/licenses/mit-license.php
 *
 * email: hunter.z@263.net
 * Date: 2013-03-11
 */
(function(i){i.extend(!0,i.fn.zTree._z,{view:{clearOldFirstNode:function(c,a){for(var b=a.getNextNode();b;){if(b.isFirstNode){b.isFirstNode=!1;f.setNodeLineIcos(c,b);break}if(b.isLastNode)break;b=b.getNextNode()}},clearOldLastNode:function(c,a){for(var b=a.getPreNode();b;){if(b.isLastNode){b.isLastNode=!1;f.setNodeLineIcos(c,b);break}if(b.isFirstNode)break;b=b.getPreNode()}},makeDOMNodeMainBefore:function(c,a,b){c.push("<li ",b.isHidden?"style='display:none;' ":"","id='",b.tId,"' class='",l.className.LEVEL,
b.level,"' tabindex='0' hidefocus='true' treenode>")},showNode:function(c,a){a.isHidden=!1;e.initShowForExCheck(c,a);i("#"+a.tId).show()},showNodes:function(c,a,b){if(a&&a.length!=0){var d={},h,j;for(h=0,j=a.length;h<j;h++){var g=a[h];if(!d[g.parentTId]){var i=g.getParentNode();d[g.parentTId]=i===null?e.getRoot(c):g.getParentNode()}f.showNode(c,g,b)}for(var k in d)a=d[k][c.data.key.children],f.setFirstNodeForShow(c,a),f.setLastNodeForShow(c,a)}},hideNode:function(c,a){a.isHidden=!0;a.isFirstNode=
!1;a.isLastNode=!1;e.initHideForExCheck(c,a);f.cancelPreSelectedNode(c,a);i("#"+a.tId).hide()},hideNodes:function(c,a,b){if(a&&a.length!=0){var d={},h,j;for(h=0,j=a.length;h<j;h++){var g=a[h];if((g.isFirstNode||g.isLastNode)&&!d[g.parentTId]){var i=g.getParentNode();d[g.parentTId]=i===null?e.getRoot(c):g.getParentNode()}f.hideNode(c,g,b)}for(var k in d)a=d[k][c.data.key.children],f.setFirstNodeForHide(c,a),f.setLastNodeForHide(c,a)}},setFirstNode:function(c,a){var b=c.data.key.children,d=a[b].length;
d>0&&!a[b][0].isHidden?a[b][0].isFirstNode=!0:d>0&&f.setFirstNodeForHide(c,a[b])},setLastNode:function(c,a){var b=c.data.key.children,d=a[b].length;d>0&&!a[b][0].isHidden?a[b][d-1].isLastNode=!0:d>0&&f.setLastNodeForHide(c,a[b])},setFirstNodeForHide:function(c,a){var b,d,h;for(d=0,h=a.length;d<h;d++){b=a[d];if(b.isFirstNode)break;if(!b.isHidden&&!b.isFirstNode){b.isFirstNode=!0;f.setNodeLineIcos(c,b);break}else b=null}return b},setFirstNodeForShow:function(c,a){var b,d,h,e,g;for(d=0,h=a.length;d<
h;d++)if(b=a[d],!e&&!b.isHidden&&b.isFirstNode){e=b;break}else if(!e&&!b.isHidden&&!b.isFirstNode)b.isFirstNode=!0,e=b,f.setNodeLineIcos(c,b);else if(e&&b.isFirstNode){b.isFirstNode=!1;g=b;f.setNodeLineIcos(c,b);break}return{"new":e,old:g}},setLastNodeForHide:function(c,a){var b,d;for(d=a.length-1;d>=0;d--){b=a[d];if(b.isLastNode)break;if(!b.isHidden&&!b.isLastNode){b.isLastNode=!0;f.setNodeLineIcos(c,b);break}else b=null}return b},setLastNodeForShow:function(c,a){var b,d,e,j;for(d=a.length-1;d>=
0;d--)if(b=a[d],!e&&!b.isHidden&&b.isLastNode){e=b;break}else if(!e&&!b.isHidden&&!b.isLastNode)b.isLastNode=!0,e=b,f.setNodeLineIcos(c,b);else if(e&&b.isLastNode){b.isLastNode=!1;j=b;f.setNodeLineIcos(c,b);break}return{"new":e,old:j}}},data:{initHideForExCheck:function(c,a){if(a.isHidden&&c.check&&c.check.enable){if(typeof a._nocheck=="undefined")a._nocheck=!!a.nocheck,a.nocheck=!0;a.check_Child_State=-1;f.repairParentChkClassWithSelf&&f.repairParentChkClassWithSelf(c,a)}},initShowForExCheck:function(c,
a){if(!a.isHidden&&c.check&&c.check.enable){if(typeof a._nocheck!="undefined")a.nocheck=a._nocheck,delete a._nocheck;if(f.setChkClass){var b=i("#"+a.tId+l.id.CHECK);f.setChkClass(c,b,a)}f.repairParentChkClassWithSelf&&f.repairParentChkClassWithSelf(c,a)}}}});var k=i.fn.zTree,t=k._z.tools,l=k.consts,f=k._z.view,e=k._z.data;e.addInitNode(function(c,a,b){if(typeof b.isHidden=="string")b.isHidden=t.eqs(b.isHidden,"true");b.isHidden=!!b.isHidden;e.initHideForExCheck(c,b)});e.addBeforeA(function(){});e.addZTreeTools(function(c,
a){a.showNodes=function(a,b){f.showNodes(c,a,b)};a.showNode=function(a,b){a&&f.showNodes(c,[a],b)};a.hideNodes=function(a,b){f.hideNodes(c,a,b)};a.hideNode=function(a,b){a&&f.hideNodes(c,[a],b)};var b=a.checkNode;if(b)a.checkNode=function(c,e,f,g){(!c||!c.isHidden)&&b.apply(a,arguments)}});var m=e.initNode;e.tmpHideParent=-1;e.initNode=function(c,a,b,d,h,j,g){if(e.tmpHideParent!==d){e.tmpHideParent=d;var i=(d?d:e.getRoot(c))[c.data.key.children];e.tmpHideFirstNode=f.setFirstNodeForHide(c,i);e.tmpHideLastNode=
f.setLastNodeForHide(c,i);f.setNodeLineIcos(c,e.tmpHideFirstNode);f.setNodeLineIcos(c,e.tmpHideLastNode)}h=e.tmpHideFirstNode===b;j=e.tmpHideLastNode===b;m&&m.apply(e,arguments);j&&f.clearOldLastNode(c,b)};var n=e.makeChkFlag;if(n)e.makeChkFlag=function(c,a){(!a||!a.isHidden)&&n.apply(e,arguments)};var o=e.getTreeCheckedNodes;if(o)e.getTreeCheckedNodes=function(c,a,b,d){if(a&&a.length>0){var f=a[0].getParentNode();if(f&&f.isHidden)return[]}return o.apply(e,arguments)};var p=e.getTreeChangeCheckedNodes;
if(p)e.getTreeChangeCheckedNodes=function(c,a,b){if(a&&a.length>0){var d=a[0].getParentNode();if(d&&d.isHidden)return[]}return p.apply(e,arguments)};var q=f.expandCollapseSonNode;if(q)f.expandCollapseSonNode=function(c,a,b,d,e){(!a||!a.isHidden)&&q.apply(f,arguments)};var r=f.setSonNodeCheckBox;if(r)f.setSonNodeCheckBox=function(c,a,b,d){(!a||!a.isHidden)&&r.apply(f,arguments)};var s=f.repairParentChkClassWithSelf;if(s)f.repairParentChkClassWithSelf=function(c,a){(!a||!a.isHidden)&&s.apply(f,arguments)}})(jQuery);