提交 9912b29c 编写于 作者: Z ztree

* 【修改】addNodes 方法支持直接添加新节点到任意位置 addNodes(parentNode, index, newNodes, isSilent)

 * 【修改】selectstart 事件未解绑导致的内存泄漏
上级 0dd61354
jQuery Tree Plugin ---- zTree
============
last verson : 3.5.18
last verson : 3.5.19
**Donate to zTree** : http://www.ztree.me/v3/donate.php
......
......@@ -35,7 +35,7 @@
<div class="ieSuggest">浏览本网站建议您使用 Chrome、FireFox、Opera、IE9 等浏览器(只要不是 IE6 7 8 就行), 速度会更快,画面会更炫!</div>
<div class="google_plus"><g:plusone></g:plusone></div>
<div class="header-text">
<h1><em>zTree v3.5.18 API 文档</em></h1><p></p>
<h1><em>zTree v3.5.19 API 文档</em></h1><p></p>
<p>all.js = core + excheck + exedit ( 不包括 exhide ); 发现错误请及时通知,谢谢。</p>
</div>
<ul class="shortcuts language" style="top:0;">
......
......@@ -34,7 +34,7 @@
<div class="ieSuggest">If you use the Chrome / FireFox / Opera / IE9 browser will be even more dazzling effect!</div>
<div class="google_plus"><g:plusone></g:plusone></div>
<div class="header-text">
<h1><em>zTree v3.5.18 API Document</em></h1><p></p>
<h1><em>zTree v3.5.19 API Document</em></h1><p></p>
<p>all.js = core + excheck + exedit ( without exhide ); if you found some mistakes please contact me.</p>
</div>
<ul class="shortcuts language" style="top:0;">
......
......@@ -238,7 +238,7 @@ var apiContent = {
{id:3, pId:0, name:""},
{id:4, pId:0, t:"zTreeObj", name:"zTreeObj : {", open:true},
{id:401, pId:4, t:"setting", name:"setting", iconSkin:"core", showAPI:true},
{id:402, pId:4, t:"addNodes", name:"addNodes (parentNode, newNodes, isSilent)", iconSkin:"core", showAPI:true},
{id:402, pId:4, t:"addNodes", name:"addNodes (parentNode, index, newNodes, isSilent)", iconSkin:"core", showAPI:true},
{id:403, pId:4, t:"cancelEditName", name:"cancelEditName (newName)", iconSkin:"edit", showAPI:true},
{id:404, pId:4, t:"cancelSelectedNode", name:"cancelSelectedNode (node)", iconSkin:"core", showAPI:true},
{id:405, pId:4, t:"checkAllNodes", name:"checkAllNodes (checked)", iconSkin:"check", showAPI:true},
......
此差异已折叠。
<div class="apiDetail">
<div>
<h2><span>Function(parentNode, newNodes, isSilent)</span><span class="path">zTreeObj.</span>addNodes</h2>
<h2><span>Function(parentNode, [index], newNodes, isSilent)</span><span class="path">zTreeObj.</span>addNodes</h2>
<h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 扩展 js ]</span></h3>
<div class="desc">
<p></p>
......@@ -15,6 +15,11 @@
<h4><b>parentNode</b><span>JSON</span></h4>
<p>指定的父节点,如果增加根节点,请设置 parentNode 为 null 即可。</p>
<p class="highlight_red">请务必保证此节点数据对象 是 zTree 内部的数据对象</p>
<h4><b>[index]</b><span>Number</span></h4>
<p>新节点插入的位置(从 0 开始)</p>
<p>index = -1 时,插入到最后</p>
<p>此参数可忽略</p>
<p class="highlight_red">v3.5.19+</p>
<h4 class="topLine"><b>newNodes</b><span>JSON / Array(JSON)</span></h4>
<p>需要增加的节点数据 JSON 对象集合,数据只需要满足 zTree 的节点数据必需的属性即可,详细请参考“treeNode 节点数据详解”</p>
<p class="highlight_red">1、v3.x 支持单独添加一个节点,即如果只新增一个节点,不用必须包在数组中</p>
......
<div class="apiDetail">
<div>
<h2><span>Function(parentNode, newNodes, isSilent)</span><span class="path">zTreeObj.</span>addNodes</h2>
<h2><span>Function(parentNode, [index], newNodes, isSilent)</span><span class="path">zTreeObj.</span>addNodes</h2>
<h3>Overview<span class="h3_info">[ depends on <span class="highlight_green">jquery.ztree.core</span> js ]</span></h3>
<div class="desc">
<p></p>
......@@ -15,6 +15,11 @@
<h4><b>parentNode</b><span>JSON</span></h4>
<p>The additional node's parent node. If additional node is root node, please the parentNode is null.</p>
<p class="highlight_red">Please ensure this node data object is a data object within zTree.</p>
<h4><b>[index]</b><span>Number</span></h4>
<p>The index of the parentNode's children where the newnodes will be added (the value start from 0)</p>
<p>When index = -1, the newnodes will be added to the last</p>
<p>This parameter can be ignore.</p>
<p class="highlight_red">v3.5.19+</p>
<h4 class="topLine"><b>newNodes</b><span>JSON / Array(JSON)</span></h4>
<p>The node data's JSON object collection which need to increase, refer to 'treeNode treeNode data details'</p>
<p class="highlight_red">1. zTree v3.x support to add single node, that is, if you only add a node, you can don't use the array.</p>
......
/*-------------------------------------
zTree Style
version: 3.5.18
version: 3.5.19
author: Hunter.z
email: hunter.z@263.net
website: http://code.google.com/p/jquerytree/
......
/*
* JQuery zTree core v3.5.18
* JQuery zTree core v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -9,7 +9,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function($){
var settings = {}, roots = {}, caches = {},
......@@ -366,15 +366,30 @@
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) {
addNodesData: function(setting, parentNode, index, nodes) {
var childKey = setting.data.key.children, params;
if (!parentNode[childKey]) {
parentNode[childKey] = [];
index = -1;
} else if (index >= parentNode[childKey].length) {
index = -1;
}
if (parentNode[childKey].length > 0 && index === 0) {
parentNode[childKey][0].isFirstNode = false;
view.setNodeLineIcos(setting, parentNode[childKey][0]);
} else if (parentNode[childKey].length > 0 && index < 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);
if (index<0) {
parentNode[childKey] = parentNode[childKey].concat(nodes);
} else {
params = [index, 0].concat(nodes);
parentNode[childKey].splice.apply(parentNode[childKey], params);
}
},
addSelectedNode: function(setting, node) {
var root = data.getRoot(setting);
......@@ -644,11 +659,7 @@
o = setting.treeObj;
if (!setting.view.txtSelectedEnable) {
// for can't select text
o.bind('selectstart', function(e){
var node
var n = e.originalEvent.srcElement.nodeName.toLowerCase();
return (n === "input" || n === "textarea" );
}).css({
o.bind('selectstart', handler.onSelectStart).css({
"-moz-user-select":"-moz-none"
});
}
......@@ -662,13 +673,14 @@
},
unbindTree: function(setting) {
var o = setting.treeObj;
o.unbind('click', event.proxy)
.unbind('dblclick', event.proxy)
.unbind('mouseover', event.proxy)
.unbind('mouseout', event.proxy)
.unbind('mousedown', event.proxy)
.unbind('mouseup', event.proxy)
.unbind('contextmenu', event.proxy);
o.unbind('selectstart', handler.onSelectStart)
.unbind('click', event.proxy)
.unbind('dblclick', event.proxy)
.unbind('mouseover', event.proxy)
.unbind('mouseout', event.proxy)
.unbind('mousedown', event.proxy)
.unbind('mouseup', event.proxy)
.unbind('contextmenu', event.proxy);
},
doProxy: function(e) {
var results = [];
......@@ -754,6 +766,10 @@
tools.apply(setting.callback.onRightClick, [event, setting.treeId, node]);
}
return (typeof setting.callback.onRightClick) != "function";
},
onSelectStart: function(e){
var n = e.originalEvent.srcElement.nodeName.toLowerCase();
return (n === "input" || n === "textarea" );
}
},
//method of tools for zTree
......@@ -817,7 +833,7 @@
},
//method of operate ztree dom
view = {
addNodes: function(setting, parentNode, newNodes, isSilent) {
addNodes: function(setting, parentNode, index, newNodes, isSilent) {
if (setting.data.keep.leaf && parentNode && !parentNode.isParent) {
return;
}
......@@ -841,27 +857,34 @@
});
}
data.addNodesData(setting, parentNode, newNodes);
view.createNodes(setting, parentNode.level + 1, newNodes, parentNode);
data.addNodesData(setting, parentNode, index, newNodes);
view.createNodes(setting, parentNode.level + 1, newNodes, parentNode, index);
if (!isSilent) {
view.expandCollapseParentNode(setting, parentNode, true);
}
} else {
data.addNodesData(setting, data.getRoot(setting), newNodes);
view.createNodes(setting, 0, newNodes, null);
data.addNodesData(setting, data.getRoot(setting), index, newNodes);
view.createNodes(setting, 0, newNodes, null, index);
}
},
appendNodes: function(setting, level, nodes, parentNode, initFlag, openFlag) {
appendNodes: function(setting, level, nodes, parentNode, index, initFlag, openFlag) {
if (!nodes) return [];
var html = [],
childKey = setting.data.key.children;
var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting),
tmpPChild = tmpPNode[childKey],
isFirstNode, isLastNode;
if (!tmpPChild || index >= tmpPChild.length) {
index = -1;
}
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
if (initFlag) {
var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting),
tmpPChild = tmpPNode[childKey],
isFirstNode = ((tmpPChild.length == nodes.length) && (i == 0)),
isLastNode = (i == (nodes.length - 1));
isFirstNode = ((index===0 || tmpPChild.length == nodes.length) && (i == 0));
isLastNode = (index < 0 && i == (nodes.length - 1));
data.initNode(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag);
data.addNodeCache(setting, node);
}
......@@ -869,7 +892,7 @@
var childHtml = [];
if (node[childKey] && node[childKey].length > 0) {
//make child html first, because checkType
childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open);
childHtml = view.appendNodes(setting, level + 1, node[childKey], node, -1, initFlag, openFlag && node.open);
}
if (openFlag) {
......@@ -903,7 +926,7 @@
ulObj.remove();
}
var childKey = setting.data.key.children,
childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true);
childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, -1, false, true);
view.makeUlHtml(setting, node, html, childHtml.join(''));
nObj.append(html.join(''));
},
......@@ -975,9 +998,9 @@
view.setNodeLineIcos(setting, node);
if (newNodes && newNodes !== "") {
newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes);
view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent);
view.addNodes(setting, node, -1, !!newNodes ? tools.clone(newNodes) : [], !!isSilent);
} else {
view.addNodes(setting, node, [], !!isSilent);
view.addNodes(setting, node, -1, [], !!isSilent);
}
setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]);
tools.apply(callback);
......@@ -1022,21 +1045,36 @@
}
}
},
createNodes: function(setting, level, nodes, parentNode) {
createNodes: function(setting, level, nodes, parentNode, index) {
if (!nodes || nodes.length == 0) return;
var root = data.getRoot(setting),
childKey = setting.data.key.children,
openFlag = !parentNode || parentNode.open || !!$$(parentNode[childKey][0], setting).get(0);
root.createdNodes = [];
var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag);
var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, index, true, openFlag),
parentObj, nextObj;
if (!parentNode) {
setting.treeObj.append(zTreeHtml.join(''));
parentObj = setting.treeObj;
//setting.treeObj.append(zTreeHtml.join(''));
} else {
var ulObj = $$(parentNode, consts.id.UL, setting);
if (ulObj.get(0)) {
ulObj.append(zTreeHtml.join(''));
parentObj = ulObj;
//ulObj.append(zTreeHtml.join(''));
}
}
if (parentObj) {
if (index >= 0) {
nextObj = parentObj.children()[index];
}
if (index >=0 && nextObj) {
$(nextObj).before(zTreeHtml.join(''));
} else {
parentObj.append(zTreeHtml.join(''));
}
}
view.createNodeCallback(setting);
},
destroy: function(setting) {
......@@ -1520,13 +1558,24 @@
var zTreeTools = {
setting : setting,
addNodes : function(parentNode, newNodes, isSilent) {
if (!newNodes) return null;
addNodes : function(parentNode, index, newNodes, isSilent) {
if (!parentNode) parentNode = null;
if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null;
var i = parseInt(index, 10);
if (isNaN(i)) {
isSilent = !!newNodes;
newNodes = index;
index = -1;
} else {
index = i;
}
if (!newNodes) return null;
var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]);
function addCallback() {
view.addNodes(setting, parentNode, xNewNodes, (isSilent==true));
view.addNodes(setting, parentNode, index, xNewNodes, (isSilent==true));
}
if (tools.canAsync(setting, parentNode)) {
......@@ -1649,7 +1698,7 @@
data.initRoot(setting);
root[setting.data.key.children] = nodes
data.initCache(setting);
view.createNodes(setting, 0, root[setting.data.key.children]);
view.createNodes(setting, 0, root[setting.data.key.children], null, -1);
},
removeChildNodes : function(node) {
if (!node) return null;
......@@ -1703,7 +1752,7 @@
data.setZTreeTools(setting, zTreeTools);
if (root[childKey] && root[childKey].length > 0) {
view.createNodes(setting, 0, root[childKey]);
view.createNodes(setting, 0, root[childKey], null, -1);
} else if (setting.async.enable && setting.async.url && setting.async.url !== '') {
view.asyncNode(setting);
}
......@@ -1716,7 +1765,7 @@
consts = zt.consts;
})(jQuery);
/*
* JQuery zTree excheck v3.5.18
* JQuery zTree excheck v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -1725,7 +1774,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function($){
//default consts of excheck
......@@ -2317,7 +2366,7 @@
data.addZTreeTools(_zTreeTools);
var _createNodes = view.createNodes;
view.createNodes = function(setting, level, nodes, parentNode) {
view.createNodes = function(setting, level, nodes, parentNode, index) {
if (_createNodes) _createNodes.apply(view, arguments);
if (!nodes) return;
view.repairParentChkClassWithSelf(setting, parentNode);
......@@ -2332,7 +2381,7 @@
}
var _appendNodes = view.appendNodes;
view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) {
view.appendNodes = function(setting, level, nodes, parentNode, index, initFlag, openFlag) {
var html = "";
if (_appendNodes) {
html = _appendNodes.apply(view, arguments);
......@@ -2344,7 +2393,7 @@
}
})(jQuery);
/*
* JQuery zTree exedit v3.5.18
* JQuery zTree exedit v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -2353,7 +2402,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function($){
//default consts of exedit
......@@ -3291,7 +3340,7 @@
}
var nodeDom = $$(node, setting);
if (!nodeDom.get(0)) {
nodeDom = view.appendNodes(setting, node.level, [node], null, false, true).join('');
nodeDom = view.appendNodes(setting, node.level, [node], null, -1, false, true).join('');
} else if (!targetObj.get(0)) {
nodeDom.remove();
}
......@@ -3485,7 +3534,7 @@
}
var _createNodes = view.createNodes;
view.createNodes = function(setting, level, nodes, parentNode) {
view.createNodes = function(setting, level, nodes, parentNode, index) {
if (_createNodes) {
_createNodes.apply(view, arguments);
}
......
此差异已折叠。
/*
* JQuery zTree core v3.5.18
* JQuery zTree core v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function($){
var settings = {}, roots = {}, caches = {},
......@@ -365,15 +365,30 @@
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) {
addNodesData: function(setting, parentNode, index, nodes) {
var childKey = setting.data.key.children, params;
if (!parentNode[childKey]) {
parentNode[childKey] = [];
index = -1;
} else if (index >= parentNode[childKey].length) {
index = -1;
}
if (parentNode[childKey].length > 0 && index === 0) {
parentNode[childKey][0].isFirstNode = false;
view.setNodeLineIcos(setting, parentNode[childKey][0]);
} else if (parentNode[childKey].length > 0 && index < 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);
if (index<0) {
parentNode[childKey] = parentNode[childKey].concat(nodes);
} else {
params = [index, 0].concat(nodes);
parentNode[childKey].splice.apply(parentNode[childKey], params);
}
},
addSelectedNode: function(setting, node) {
var root = data.getRoot(setting);
......@@ -643,11 +658,7 @@
o = setting.treeObj;
if (!setting.view.txtSelectedEnable) {
// for can't select text
o.bind('selectstart', function(e){
var node
var n = e.originalEvent.srcElement.nodeName.toLowerCase();
return (n === "input" || n === "textarea" );
}).css({
o.bind('selectstart', handler.onSelectStart).css({
"-moz-user-select":"-moz-none"
});
}
......@@ -661,13 +672,14 @@
},
unbindTree: function(setting) {
var o = setting.treeObj;
o.unbind('click', event.proxy)
.unbind('dblclick', event.proxy)
.unbind('mouseover', event.proxy)
.unbind('mouseout', event.proxy)
.unbind('mousedown', event.proxy)
.unbind('mouseup', event.proxy)
.unbind('contextmenu', event.proxy);
o.unbind('selectstart', handler.onSelectStart)
.unbind('click', event.proxy)
.unbind('dblclick', event.proxy)
.unbind('mouseover', event.proxy)
.unbind('mouseout', event.proxy)
.unbind('mousedown', event.proxy)
.unbind('mouseup', event.proxy)
.unbind('contextmenu', event.proxy);
},
doProxy: function(e) {
var results = [];
......@@ -753,6 +765,10 @@
tools.apply(setting.callback.onRightClick, [event, setting.treeId, node]);
}
return (typeof setting.callback.onRightClick) != "function";
},
onSelectStart: function(e){
var n = e.originalEvent.srcElement.nodeName.toLowerCase();
return (n === "input" || n === "textarea" );
}
},
//method of tools for zTree
......@@ -816,7 +832,7 @@
},
//method of operate ztree dom
view = {
addNodes: function(setting, parentNode, newNodes, isSilent) {
addNodes: function(setting, parentNode, index, newNodes, isSilent) {
if (setting.data.keep.leaf && parentNode && !parentNode.isParent) {
return;
}
......@@ -840,27 +856,34 @@
});
}
data.addNodesData(setting, parentNode, newNodes);
view.createNodes(setting, parentNode.level + 1, newNodes, parentNode);
data.addNodesData(setting, parentNode, index, newNodes);
view.createNodes(setting, parentNode.level + 1, newNodes, parentNode, index);
if (!isSilent) {
view.expandCollapseParentNode(setting, parentNode, true);
}
} else {
data.addNodesData(setting, data.getRoot(setting), newNodes);
view.createNodes(setting, 0, newNodes, null);
data.addNodesData(setting, data.getRoot(setting), index, newNodes);
view.createNodes(setting, 0, newNodes, null, index);
}
},
appendNodes: function(setting, level, nodes, parentNode, initFlag, openFlag) {
appendNodes: function(setting, level, nodes, parentNode, index, initFlag, openFlag) {
if (!nodes) return [];
var html = [],
childKey = setting.data.key.children;
var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting),
tmpPChild = tmpPNode[childKey],
isFirstNode, isLastNode;
if (!tmpPChild || index >= tmpPChild.length) {
index = -1;
}
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
if (initFlag) {
var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting),
tmpPChild = tmpPNode[childKey],
isFirstNode = ((tmpPChild.length == nodes.length) && (i == 0)),
isLastNode = (i == (nodes.length - 1));
isFirstNode = ((index===0 || tmpPChild.length == nodes.length) && (i == 0));
isLastNode = (index < 0 && i == (nodes.length - 1));
data.initNode(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag);
data.addNodeCache(setting, node);
}
......@@ -868,7 +891,7 @@
var childHtml = [];
if (node[childKey] && node[childKey].length > 0) {
//make child html first, because checkType
childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open);
childHtml = view.appendNodes(setting, level + 1, node[childKey], node, -1, initFlag, openFlag && node.open);
}
if (openFlag) {
......@@ -902,7 +925,7 @@
ulObj.remove();
}
var childKey = setting.data.key.children,
childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true);
childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, -1, false, true);
view.makeUlHtml(setting, node, html, childHtml.join(''));
nObj.append(html.join(''));
},
......@@ -974,9 +997,9 @@
view.setNodeLineIcos(setting, node);
if (newNodes && newNodes !== "") {
newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes);
view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent);
view.addNodes(setting, node, -1, !!newNodes ? tools.clone(newNodes) : [], !!isSilent);
} else {
view.addNodes(setting, node, [], !!isSilent);
view.addNodes(setting, node, -1, [], !!isSilent);
}
setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]);
tools.apply(callback);
......@@ -1021,21 +1044,36 @@
}
}
},
createNodes: function(setting, level, nodes, parentNode) {
createNodes: function(setting, level, nodes, parentNode, index) {
if (!nodes || nodes.length == 0) return;
var root = data.getRoot(setting),
childKey = setting.data.key.children,
openFlag = !parentNode || parentNode.open || !!$$(parentNode[childKey][0], setting).get(0);
root.createdNodes = [];
var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag);
var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, index, true, openFlag),
parentObj, nextObj;
if (!parentNode) {
setting.treeObj.append(zTreeHtml.join(''));
parentObj = setting.treeObj;
//setting.treeObj.append(zTreeHtml.join(''));
} else {
var ulObj = $$(parentNode, consts.id.UL, setting);
if (ulObj.get(0)) {
ulObj.append(zTreeHtml.join(''));
parentObj = ulObj;
//ulObj.append(zTreeHtml.join(''));
}
}
if (parentObj) {
if (index >= 0) {
nextObj = parentObj.children()[index];
}
if (index >=0 && nextObj) {
$(nextObj).before(zTreeHtml.join(''));
} else {
parentObj.append(zTreeHtml.join(''));
}
}
view.createNodeCallback(setting);
},
destroy: function(setting) {
......@@ -1519,13 +1557,24 @@
var zTreeTools = {
setting : setting,
addNodes : function(parentNode, newNodes, isSilent) {
if (!newNodes) return null;
addNodes : function(parentNode, index, newNodes, isSilent) {
if (!parentNode) parentNode = null;
if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null;
var i = parseInt(index, 10);
if (isNaN(i)) {
isSilent = !!newNodes;
newNodes = index;
index = -1;
} else {
index = i;
}
if (!newNodes) return null;
var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]);
function addCallback() {
view.addNodes(setting, parentNode, xNewNodes, (isSilent==true));
view.addNodes(setting, parentNode, index, xNewNodes, (isSilent==true));
}
if (tools.canAsync(setting, parentNode)) {
......@@ -1648,7 +1697,7 @@
data.initRoot(setting);
root[setting.data.key.children] = nodes
data.initCache(setting);
view.createNodes(setting, 0, root[setting.data.key.children]);
view.createNodes(setting, 0, root[setting.data.key.children], null, -1);
},
removeChildNodes : function(node) {
if (!node) return null;
......@@ -1702,7 +1751,7 @@
data.setZTreeTools(setting, zTreeTools);
if (root[childKey] && root[childKey].length > 0) {
view.createNodes(setting, 0, root[childKey]);
view.createNodes(setting, 0, root[childKey], null, -1);
} else if (setting.async.enable && setting.async.url && setting.async.url !== '') {
view.asyncNode(setting);
}
......
此差异已折叠。
/*
* JQuery zTree excheck v3.5.18
* JQuery zTree excheck v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function($){
//default consts of excheck
......@@ -600,7 +600,7 @@
data.addZTreeTools(_zTreeTools);
var _createNodes = view.createNodes;
view.createNodes = function(setting, level, nodes, parentNode) {
view.createNodes = function(setting, level, nodes, parentNode, index) {
if (_createNodes) _createNodes.apply(view, arguments);
if (!nodes) return;
view.repairParentChkClassWithSelf(setting, parentNode);
......@@ -615,7 +615,7 @@
}
var _appendNodes = view.appendNodes;
view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) {
view.appendNodes = function(setting, level, nodes, parentNode, index, initFlag, openFlag) {
var html = "";
if (_appendNodes) {
html = _appendNodes.apply(view, arguments);
......
/*
* JQuery zTree excheck v3.5.18
* JQuery zTree excheck v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,27 +8,27 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function(m){var p,q,r,o={event:{CHECK:"ztree_check"},id:{CHECK:"_check"},checkbox:{STYLE:"checkbox",DEFAULT:"chk",DISABLED:"disable",FALSE:"false",TRUE:"true",FULL:"full",PART:"part",FOCUS:"focus"},radio:{STYLE:"radio",TYPE_ALL:"all",TYPE_LEVEL:"level"}},v={check:{enable:!1,autoCheckTrigger:!1,chkStyle:o.checkbox.STYLE,nocheckInherit:!1,chkDisabledInherit:!1,radioType:o.radio.TYPE_LEVEL,chkboxType:{Y:"ps",N:"ps"}},data:{key:{checked:"checked"}},callback:{beforeCheck:null,onCheck:null}};p=function(c,
a){if(a.chkDisabled===!0)return!1;var b=f.getSetting(c.data.treeId),d=b.data.key.checked;if(k.apply(b.callback.beforeCheck,[b.treeId,a],!0)==!1)return!0;a[d]=!a[d];e.checkNodeRelation(b,a);d=n(a,j.id.CHECK,b);e.setChkClass(b,d,a);e.repairParentChkClassWithSelf(b,a);b.treeObj.trigger(j.event.CHECK,[c,b.treeId,a]);return!0};q=function(c,a){if(a.chkDisabled===!0)return!1;var b=f.getSetting(c.data.treeId),d=n(a,j.id.CHECK,b);a.check_Focus=!0;e.setChkClass(b,d,a);return!0};r=function(c,a){if(a.chkDisabled===
!0)return!1;var b=f.getSetting(c.data.treeId),d=n(a,j.id.CHECK,b);a.check_Focus=!1;e.setChkClass(b,d,a);return!0};m.extend(!0,m.fn.zTree.consts,o);m.extend(!0,m.fn.zTree._z,{tools:{},view:{checkNodeRelation:function(c,a){var b,d,h,i=c.data.key.children,l=c.data.key.checked;b=j.radio;if(c.check.chkStyle==b.STYLE){var g=f.getRadioCheckedList(c);if(a[l])if(c.check.radioType==b.TYPE_ALL){for(d=g.length-1;d>=0;d--)b=g[d],b[l]&&b!=a&&(b[l]=!1,g.splice(d,1),e.setChkClass(c,n(b,j.id.CHECK,c),b),b.parentTId!=
a.parentTId&&e.repairParentChkClassWithSelf(c,b));g.push(a)}else{g=a.parentTId?a.getParentNode():f.getRoot(c);for(d=0,h=g[i].length;d<h;d++)b=g[i][d],b[l]&&b!=a&&(b[l]=!1,e.setChkClass(c,n(b,j.id.CHECK,c),b))}else if(c.check.radioType==b.TYPE_ALL)for(d=0,h=g.length;d<h;d++)if(a==g[d]){g.splice(d,1);break}}else a[l]&&(!a[i]||a[i].length==0||c.check.chkboxType.Y.indexOf("s")>-1)&&e.setSonNodeCheckBox(c,a,!0),!a[l]&&(!a[i]||a[i].length==0||c.check.chkboxType.N.indexOf("s")>-1)&&e.setSonNodeCheckBox(c,
a){if(a.chkDisabled===!0)return!1;var b=g.getSetting(c.data.treeId),d=b.data.key.checked;if(k.apply(b.callback.beforeCheck,[b.treeId,a],!0)==!1)return!0;a[d]=!a[d];e.checkNodeRelation(b,a);d=n(a,j.id.CHECK,b);e.setChkClass(b,d,a);e.repairParentChkClassWithSelf(b,a);b.treeObj.trigger(j.event.CHECK,[c,b.treeId,a]);return!0};q=function(c,a){if(a.chkDisabled===!0)return!1;var b=g.getSetting(c.data.treeId),d=n(a,j.id.CHECK,b);a.check_Focus=!0;e.setChkClass(b,d,a);return!0};r=function(c,a){if(a.chkDisabled===
!0)return!1;var b=g.getSetting(c.data.treeId),d=n(a,j.id.CHECK,b);a.check_Focus=!1;e.setChkClass(b,d,a);return!0};m.extend(!0,m.fn.zTree.consts,o);m.extend(!0,m.fn.zTree._z,{tools:{},view:{checkNodeRelation:function(c,a){var b,d,h,i=c.data.key.children,l=c.data.key.checked;b=j.radio;if(c.check.chkStyle==b.STYLE){var f=g.getRadioCheckedList(c);if(a[l])if(c.check.radioType==b.TYPE_ALL){for(d=f.length-1;d>=0;d--)b=f[d],b[l]&&b!=a&&(b[l]=!1,f.splice(d,1),e.setChkClass(c,n(b,j.id.CHECK,c),b),b.parentTId!=
a.parentTId&&e.repairParentChkClassWithSelf(c,b));f.push(a)}else{f=a.parentTId?a.getParentNode():g.getRoot(c);for(d=0,h=f[i].length;d<h;d++)b=f[i][d],b[l]&&b!=a&&(b[l]=!1,e.setChkClass(c,n(b,j.id.CHECK,c),b))}else if(c.check.radioType==b.TYPE_ALL)for(d=0,h=f.length;d<h;d++)if(a==f[d]){f.splice(d,1);break}}else a[l]&&(!a[i]||a[i].length==0||c.check.chkboxType.Y.indexOf("s")>-1)&&e.setSonNodeCheckBox(c,a,!0),!a[l]&&(!a[i]||a[i].length==0||c.check.chkboxType.N.indexOf("s")>-1)&&e.setSonNodeCheckBox(c,
a,!1),a[l]&&c.check.chkboxType.Y.indexOf("p")>-1&&e.setParentNodeCheckBox(c,a,!0),!a[l]&&c.check.chkboxType.N.indexOf("p")>-1&&e.setParentNodeCheckBox(c,a,!1)},makeChkClass:function(c,a){var b=c.data.key.checked,d=j.checkbox,h=j.radio,i="",i=a.chkDisabled===!0?d.DISABLED:a.halfCheck?d.PART:c.check.chkStyle==h.STYLE?a.check_Child_State<1?d.FULL:d.PART:a[b]?a.check_Child_State===2||a.check_Child_State===-1?d.FULL:d.PART:a.check_Child_State<1?d.FULL:d.PART,b=c.check.chkStyle+"_"+(a[b]?d.TRUE:d.FALSE)+
"_"+i,b=a.check_Focus&&a.chkDisabled!==!0?b+"_"+d.FOCUS:b;return j.className.BUTTON+" "+d.DEFAULT+" "+b},repairAllChk:function(c,a){if(c.check.enable&&c.check.chkStyle===j.checkbox.STYLE)for(var b=c.data.key.checked,d=c.data.key.children,h=f.getRoot(c),i=0,l=h[d].length;i<l;i++){var g=h[d][i];g.nocheck!==!0&&g.chkDisabled!==!0&&(g[b]=a);e.setSonNodeCheckBox(c,g,a)}},repairChkClass:function(c,a){if(a&&(f.makeChkFlag(c,a),a.nocheck!==!0)){var b=n(a,j.id.CHECK,c);e.setChkClass(c,b,a)}},repairParentChkClass:function(c,
"_"+i,b=a.check_Focus&&a.chkDisabled!==!0?b+"_"+d.FOCUS:b;return j.className.BUTTON+" "+d.DEFAULT+" "+b},repairAllChk:function(c,a){if(c.check.enable&&c.check.chkStyle===j.checkbox.STYLE)for(var b=c.data.key.checked,d=c.data.key.children,h=g.getRoot(c),i=0,l=h[d].length;i<l;i++){var f=h[d][i];f.nocheck!==!0&&f.chkDisabled!==!0&&(f[b]=a);e.setSonNodeCheckBox(c,f,a)}},repairChkClass:function(c,a){if(a&&(g.makeChkFlag(c,a),a.nocheck!==!0)){var b=n(a,j.id.CHECK,c);e.setChkClass(c,b,a)}},repairParentChkClass:function(c,
a){if(a&&a.parentTId){var b=a.getParentNode();e.repairChkClass(c,b);e.repairParentChkClass(c,b)}},repairParentChkClassWithSelf:function(c,a){if(a){var b=c.data.key.children;a[b]&&a[b].length>0?e.repairParentChkClass(c,a[b][0]):e.repairParentChkClass(c,a)}},repairSonChkDisabled:function(c,a,b,d){if(a){var h=c.data.key.children;if(a.chkDisabled!=b)a.chkDisabled=b;e.repairChkClass(c,a);if(a[h]&&d)for(var i=0,l=a[h].length;i<l;i++)e.repairSonChkDisabled(c,a[h][i],b,d)}},repairParentChkDisabled:function(c,
a,b,d){if(a){if(a.chkDisabled!=b&&d)a.chkDisabled=b;e.repairChkClass(c,a);e.repairParentChkDisabled(c,a.getParentNode(),b,d)}},setChkClass:function(c,a,b){a&&(b.nocheck===!0?a.hide():a.show(),a.attr("class",e.makeChkClass(c,b)))},setParentNodeCheckBox:function(c,a,b,d){var h=c.data.key.children,i=c.data.key.checked,l=n(a,j.id.CHECK,c);d||(d=a);f.makeChkFlag(c,a);a.nocheck!==!0&&a.chkDisabled!==!0&&(a[i]=b,e.setChkClass(c,l,a),c.check.autoCheckTrigger&&a!=d&&c.treeObj.trigger(j.event.CHECK,[null,c.treeId,
a]));if(a.parentTId){l=!0;if(!b)for(var h=a.getParentNode()[h],g=0,k=h.length;g<k;g++)if(h[g].nocheck!==!0&&h[g].chkDisabled!==!0&&h[g][i]||(h[g].nocheck===!0||h[g].chkDisabled===!0)&&h[g].check_Child_State>0){l=!1;break}l&&e.setParentNodeCheckBox(c,a.getParentNode(),b,d)}},setSonNodeCheckBox:function(c,a,b,d){if(a){var h=c.data.key.children,i=c.data.key.checked,l=n(a,j.id.CHECK,c);d||(d=a);var g=!1;if(a[h])for(var k=0,m=a[h].length;k<m&&a.chkDisabled!==!0;k++){var o=a[h][k];e.setSonNodeCheckBox(c,
o,b,d);o.chkDisabled===!0&&(g=!0)}if(a!=f.getRoot(c)&&a.chkDisabled!==!0){g&&a.nocheck!==!0&&f.makeChkFlag(c,a);if(a.nocheck!==!0&&a.chkDisabled!==!0){if(a[i]=b,!g)a.check_Child_State=a[h]&&a[h].length>0?b?2:0:-1}else a.check_Child_State=-1;e.setChkClass(c,l,a);c.check.autoCheckTrigger&&a!=d&&a.nocheck!==!0&&a.chkDisabled!==!0&&c.treeObj.trigger(j.event.CHECK,[null,c.treeId,a])}}}},event:{},data:{getRadioCheckedList:function(c){for(var a=f.getRoot(c).radioCheckedList,b=0,d=a.length;b<d;b++)f.getNodeCache(c,
a,b,d){if(a){if(a.chkDisabled!=b&&d)a.chkDisabled=b;e.repairChkClass(c,a);e.repairParentChkDisabled(c,a.getParentNode(),b,d)}},setChkClass:function(c,a,b){a&&(b.nocheck===!0?a.hide():a.show(),a.attr("class",e.makeChkClass(c,b)))},setParentNodeCheckBox:function(c,a,b,d){var h=c.data.key.children,i=c.data.key.checked,l=n(a,j.id.CHECK,c);d||(d=a);g.makeChkFlag(c,a);a.nocheck!==!0&&a.chkDisabled!==!0&&(a[i]=b,e.setChkClass(c,l,a),c.check.autoCheckTrigger&&a!=d&&c.treeObj.trigger(j.event.CHECK,[null,c.treeId,
a]));if(a.parentTId){l=!0;if(!b)for(var h=a.getParentNode()[h],f=0,k=h.length;f<k;f++)if(h[f].nocheck!==!0&&h[f].chkDisabled!==!0&&h[f][i]||(h[f].nocheck===!0||h[f].chkDisabled===!0)&&h[f].check_Child_State>0){l=!1;break}l&&e.setParentNodeCheckBox(c,a.getParentNode(),b,d)}},setSonNodeCheckBox:function(c,a,b,d){if(a){var h=c.data.key.children,i=c.data.key.checked,l=n(a,j.id.CHECK,c);d||(d=a);var f=!1;if(a[h])for(var k=0,m=a[h].length;k<m&&a.chkDisabled!==!0;k++){var o=a[h][k];e.setSonNodeCheckBox(c,
o,b,d);o.chkDisabled===!0&&(f=!0)}if(a!=g.getRoot(c)&&a.chkDisabled!==!0){f&&a.nocheck!==!0&&g.makeChkFlag(c,a);if(a.nocheck!==!0&&a.chkDisabled!==!0){if(a[i]=b,!f)a.check_Child_State=a[h]&&a[h].length>0?b?2:0:-1}else a.check_Child_State=-1;e.setChkClass(c,l,a);c.check.autoCheckTrigger&&a!=d&&a.nocheck!==!0&&a.chkDisabled!==!0&&c.treeObj.trigger(j.event.CHECK,[null,c.treeId,a])}}}},event:{},data:{getRadioCheckedList:function(c){for(var a=g.getRoot(c).radioCheckedList,b=0,d=a.length;b<d;b++)g.getNodeCache(c,
a[b].tId)||(a.splice(b,1),b--,d--);return a},getCheckStatus:function(c,a){if(!c.check.enable||a.nocheck||a.chkDisabled)return null;var b=c.data.key.checked;return{checked:a[b],half:a.halfCheck?a.halfCheck:c.check.chkStyle==j.radio.STYLE?a.check_Child_State===2:a[b]?a.check_Child_State>-1&&a.check_Child_State<2:a.check_Child_State>0}},getTreeCheckedNodes:function(c,a,b,d){if(!a)return[];for(var h=c.data.key.children,i=c.data.key.checked,e=b&&c.check.chkStyle==j.radio.STYLE&&c.check.radioType==j.radio.TYPE_ALL,
d=!d?[]:d,g=0,k=a.length;g<k;g++){if(a[g].nocheck!==!0&&a[g].chkDisabled!==!0&&a[g][i]==b&&(d.push(a[g]),e))break;f.getTreeCheckedNodes(c,a[g][h],b,d);if(e&&d.length>0)break}return d},getTreeChangeCheckedNodes:function(c,a,b){if(!a)return[];for(var d=c.data.key.children,h=c.data.key.checked,b=!b?[]:b,i=0,e=a.length;i<e;i++)a[i].nocheck!==!0&&a[i].chkDisabled!==!0&&a[i][h]!=a[i].checkedOld&&b.push(a[i]),f.getTreeChangeCheckedNodes(c,a[i][d],b);return b},makeChkFlag:function(c,a){if(a){var b=c.data.key.children,
d=c.data.key.checked,h=-1;if(a[b])for(var i=0,e=a[b].length;i<e;i++){var g=a[b][i],f=-1;if(c.check.chkStyle==j.radio.STYLE)if(f=g.nocheck===!0||g.chkDisabled===!0?g.check_Child_State:g.halfCheck===!0?2:g[d]?2:g.check_Child_State>0?2:0,f==2){h=2;break}else f==0&&(h=0);else if(c.check.chkStyle==j.checkbox.STYLE)if(f=g.nocheck===!0||g.chkDisabled===!0?g.check_Child_State:g.halfCheck===!0?1:g[d]?g.check_Child_State===-1||g.check_Child_State===2?2:1:g.check_Child_State>0?1:0,f===1){h=1;break}else if(f===
2&&h>-1&&i>0&&f!==h){h=1;break}else if(h===2&&f>-1&&f<2){h=1;break}else f>-1&&(h=f)}a.check_Child_State=h}}}});var m=m.fn.zTree,k=m._z.tools,j=m.consts,e=m._z.view,f=m._z.data,n=k.$;f.exSetting(v);f.addInitBind(function(c){c.treeObj.bind(j.event.CHECK,function(a,b,d,h){a.srcEvent=b;k.apply(c.callback.onCheck,[a,d,h])})});f.addInitUnBind(function(c){c.treeObj.unbind(j.event.CHECK)});f.addInitCache(function(){});f.addInitNode(function(c,a,b,d){if(b){a=c.data.key.checked;typeof b[a]=="string"&&(b[a]=
k.eqs(b[a],"true"));b[a]=!!b[a];b.checkedOld=b[a];if(typeof b.nocheck=="string")b.nocheck=k.eqs(b.nocheck,"true");b.nocheck=!!b.nocheck||c.check.nocheckInherit&&d&&!!d.nocheck;if(typeof b.chkDisabled=="string")b.chkDisabled=k.eqs(b.chkDisabled,"true");b.chkDisabled=!!b.chkDisabled||c.check.chkDisabledInherit&&d&&!!d.chkDisabled;if(typeof b.halfCheck=="string")b.halfCheck=k.eqs(b.halfCheck,"true");b.halfCheck=!!b.halfCheck;b.check_Child_State=-1;b.check_Focus=!1;b.getCheckStatus=function(){return f.getCheckStatus(c,
b)};c.check.chkStyle==j.radio.STYLE&&c.check.radioType==j.radio.TYPE_ALL&&b[a]&&f.getRoot(c).radioCheckedList.push(b)}});f.addInitProxy(function(c){var a=c.target,b=f.getSetting(c.data.treeId),d="",h=null,e="",l=null;if(k.eqs(c.type,"mouseover")){if(b.check.enable&&k.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+j.id.CHECK)!==null)d=k.getNodeMainDom(a).id,e="mouseoverCheck"}else if(k.eqs(c.type,"mouseout")){if(b.check.enable&&k.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+j.id.CHECK)!==null)d=
k.getNodeMainDom(a).id,e="mouseoutCheck"}else if(k.eqs(c.type,"click")&&b.check.enable&&k.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+j.id.CHECK)!==null)d=k.getNodeMainDom(a).id,e="checkNode";if(d.length>0)switch(h=f.getNodeCache(b,d),e){case "checkNode":l=p;break;case "mouseoverCheck":l=q;break;case "mouseoutCheck":l=r}return{stop:e==="checkNode",node:h,nodeEventType:e,nodeEventCallback:l,treeEventType:"",treeEventCallback:null}},!0);f.addInitRoot(function(c){f.getRoot(c).radioCheckedList=[]});
f.addBeforeA(function(c,a,b){c.check.enable&&(f.makeChkFlag(c,a),b.push("<span ID='",a.tId,j.id.CHECK,"' class='",e.makeChkClass(c,a),"' treeNode",j.id.CHECK,a.nocheck===!0?" style='display:none;'":"","></span>"))});f.addZTreeTools(function(c,a){a.checkNode=function(a,b,c,f){var g=this.setting.data.key.checked;if(a.chkDisabled!==!0&&(b!==!0&&b!==!1&&(b=!a[g]),f=!!f,(a[g]!==b||c)&&!(f&&k.apply(this.setting.callback.beforeCheck,[this.setting.treeId,a],!0)==!1)&&k.uCanDo(this.setting)&&this.setting.check.enable&&
a.nocheck!==!0))a[g]=b,b=n(a,j.id.CHECK,this.setting),(c||this.setting.check.chkStyle===j.radio.STYLE)&&e.checkNodeRelation(this.setting,a),e.setChkClass(this.setting,b,a),e.repairParentChkClassWithSelf(this.setting,a),f&&this.setting.treeObj.trigger(j.event.CHECK,[null,this.setting.treeId,a])};a.checkAllNodes=function(a){e.repairAllChk(this.setting,!!a)};a.getCheckedNodes=function(a){var b=this.setting.data.key.children;return f.getTreeCheckedNodes(this.setting,f.getRoot(this.setting)[b],a!==!1)};
a.getChangeCheckedNodes=function(){var a=this.setting.data.key.children;return f.getTreeChangeCheckedNodes(this.setting,f.getRoot(this.setting)[a])};a.setChkDisabled=function(a,b,c,f){b=!!b;c=!!c;e.repairSonChkDisabled(this.setting,a,b,!!f);e.repairParentChkDisabled(this.setting,a.getParentNode(),b,c)};var b=a.updateNode;a.updateNode=function(c,f){b&&b.apply(a,arguments);if(c&&this.setting.check.enable&&n(c,this.setting).get(0)&&k.uCanDo(this.setting)){var i=n(c,j.id.CHECK,this.setting);(f==!0||this.setting.check.chkStyle===
j.radio.STYLE)&&e.checkNodeRelation(this.setting,c);e.setChkClass(this.setting,i,c);e.repairParentChkClassWithSelf(this.setting,c)}}});var s=e.createNodes;e.createNodes=function(c,a,b,d){s&&s.apply(e,arguments);b&&e.repairParentChkClassWithSelf(c,d)};var t=e.removeNode;e.removeNode=function(c,a){var b=a.getParentNode();t&&t.apply(e,arguments);a&&b&&(e.repairChkClass(c,b),e.repairParentChkClass(c,b))};var u=e.appendNodes;e.appendNodes=function(c,a,b,d,h,i){var j="";u&&(j=u.apply(e,arguments));d&&f.makeChkFlag(c,
d);return j}})(jQuery);
d=!d?[]:d,f=0,k=a.length;f<k;f++){if(a[f].nocheck!==!0&&a[f].chkDisabled!==!0&&a[f][i]==b&&(d.push(a[f]),e))break;g.getTreeCheckedNodes(c,a[f][h],b,d);if(e&&d.length>0)break}return d},getTreeChangeCheckedNodes:function(c,a,b){if(!a)return[];for(var d=c.data.key.children,h=c.data.key.checked,b=!b?[]:b,i=0,e=a.length;i<e;i++)a[i].nocheck!==!0&&a[i].chkDisabled!==!0&&a[i][h]!=a[i].checkedOld&&b.push(a[i]),g.getTreeChangeCheckedNodes(c,a[i][d],b);return b},makeChkFlag:function(c,a){if(a){var b=c.data.key.children,
d=c.data.key.checked,h=-1;if(a[b])for(var i=0,e=a[b].length;i<e;i++){var f=a[b][i],g=-1;if(c.check.chkStyle==j.radio.STYLE)if(g=f.nocheck===!0||f.chkDisabled===!0?f.check_Child_State:f.halfCheck===!0?2:f[d]?2:f.check_Child_State>0?2:0,g==2){h=2;break}else g==0&&(h=0);else if(c.check.chkStyle==j.checkbox.STYLE)if(g=f.nocheck===!0||f.chkDisabled===!0?f.check_Child_State:f.halfCheck===!0?1:f[d]?f.check_Child_State===-1||f.check_Child_State===2?2:1:f.check_Child_State>0?1:0,g===1){h=1;break}else if(g===
2&&h>-1&&i>0&&g!==h){h=1;break}else if(h===2&&g>-1&&g<2){h=1;break}else g>-1&&(h=g)}a.check_Child_State=h}}}});var m=m.fn.zTree,k=m._z.tools,j=m.consts,e=m._z.view,g=m._z.data,n=k.$;g.exSetting(v);g.addInitBind(function(c){c.treeObj.bind(j.event.CHECK,function(a,b,d,h){a.srcEvent=b;k.apply(c.callback.onCheck,[a,d,h])})});g.addInitUnBind(function(c){c.treeObj.unbind(j.event.CHECK)});g.addInitCache(function(){});g.addInitNode(function(c,a,b,d){if(b){a=c.data.key.checked;typeof b[a]=="string"&&(b[a]=
k.eqs(b[a],"true"));b[a]=!!b[a];b.checkedOld=b[a];if(typeof b.nocheck=="string")b.nocheck=k.eqs(b.nocheck,"true");b.nocheck=!!b.nocheck||c.check.nocheckInherit&&d&&!!d.nocheck;if(typeof b.chkDisabled=="string")b.chkDisabled=k.eqs(b.chkDisabled,"true");b.chkDisabled=!!b.chkDisabled||c.check.chkDisabledInherit&&d&&!!d.chkDisabled;if(typeof b.halfCheck=="string")b.halfCheck=k.eqs(b.halfCheck,"true");b.halfCheck=!!b.halfCheck;b.check_Child_State=-1;b.check_Focus=!1;b.getCheckStatus=function(){return g.getCheckStatus(c,
b)};c.check.chkStyle==j.radio.STYLE&&c.check.radioType==j.radio.TYPE_ALL&&b[a]&&g.getRoot(c).radioCheckedList.push(b)}});g.addInitProxy(function(c){var a=c.target,b=g.getSetting(c.data.treeId),d="",h=null,e="",l=null;if(k.eqs(c.type,"mouseover")){if(b.check.enable&&k.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+j.id.CHECK)!==null)d=k.getNodeMainDom(a).id,e="mouseoverCheck"}else if(k.eqs(c.type,"mouseout")){if(b.check.enable&&k.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+j.id.CHECK)!==null)d=
k.getNodeMainDom(a).id,e="mouseoutCheck"}else if(k.eqs(c.type,"click")&&b.check.enable&&k.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+j.id.CHECK)!==null)d=k.getNodeMainDom(a).id,e="checkNode";if(d.length>0)switch(h=g.getNodeCache(b,d),e){case "checkNode":l=p;break;case "mouseoverCheck":l=q;break;case "mouseoutCheck":l=r}return{stop:e==="checkNode",node:h,nodeEventType:e,nodeEventCallback:l,treeEventType:"",treeEventCallback:null}},!0);g.addInitRoot(function(c){g.getRoot(c).radioCheckedList=[]});
g.addBeforeA(function(c,a,b){c.check.enable&&(g.makeChkFlag(c,a),b.push("<span ID='",a.tId,j.id.CHECK,"' class='",e.makeChkClass(c,a),"' treeNode",j.id.CHECK,a.nocheck===!0?" style='display:none;'":"","></span>"))});g.addZTreeTools(function(c,a){a.checkNode=function(a,b,c,g){var f=this.setting.data.key.checked;if(a.chkDisabled!==!0&&(b!==!0&&b!==!1&&(b=!a[f]),g=!!g,(a[f]!==b||c)&&!(g&&k.apply(this.setting.callback.beforeCheck,[this.setting.treeId,a],!0)==!1)&&k.uCanDo(this.setting)&&this.setting.check.enable&&
a.nocheck!==!0))a[f]=b,b=n(a,j.id.CHECK,this.setting),(c||this.setting.check.chkStyle===j.radio.STYLE)&&e.checkNodeRelation(this.setting,a),e.setChkClass(this.setting,b,a),e.repairParentChkClassWithSelf(this.setting,a),g&&this.setting.treeObj.trigger(j.event.CHECK,[null,this.setting.treeId,a])};a.checkAllNodes=function(a){e.repairAllChk(this.setting,!!a)};a.getCheckedNodes=function(a){var b=this.setting.data.key.children;return g.getTreeCheckedNodes(this.setting,g.getRoot(this.setting)[b],a!==!1)};
a.getChangeCheckedNodes=function(){var a=this.setting.data.key.children;return g.getTreeChangeCheckedNodes(this.setting,g.getRoot(this.setting)[a])};a.setChkDisabled=function(a,b,c,g){b=!!b;c=!!c;e.repairSonChkDisabled(this.setting,a,b,!!g);e.repairParentChkDisabled(this.setting,a.getParentNode(),b,c)};var b=a.updateNode;a.updateNode=function(c,g){b&&b.apply(a,arguments);if(c&&this.setting.check.enable&&n(c,this.setting).get(0)&&k.uCanDo(this.setting)){var i=n(c,j.id.CHECK,this.setting);(g==!0||this.setting.check.chkStyle===
j.radio.STYLE)&&e.checkNodeRelation(this.setting,c);e.setChkClass(this.setting,i,c);e.repairParentChkClassWithSelf(this.setting,c)}}});var s=e.createNodes;e.createNodes=function(c,a,b,d,g){s&&s.apply(e,arguments);b&&e.repairParentChkClassWithSelf(c,d)};var t=e.removeNode;e.removeNode=function(c,a){var b=a.getParentNode();t&&t.apply(e,arguments);a&&b&&(e.repairChkClass(c,b),e.repairParentChkClass(c,b))};var u=e.appendNodes;e.appendNodes=function(c,a,b,d,h,i,j){var f="";u&&(f=u.apply(e,arguments));
d&&g.makeChkFlag(c,d);return f}})(jQuery);
/*
* JQuery zTree exedit v3.5.18
* JQuery zTree exedit v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function($){
//default consts of exedit
......@@ -946,7 +946,7 @@
}
var nodeDom = $$(node, setting);
if (!nodeDom.get(0)) {
nodeDom = view.appendNodes(setting, node.level, [node], null, false, true).join('');
nodeDom = view.appendNodes(setting, node.level, [node], null, -1, false, true).join('');
} else if (!targetObj.get(0)) {
nodeDom.remove();
}
......@@ -1140,7 +1140,7 @@
}
var _createNodes = view.createNodes;
view.createNodes = function(setting, level, nodes, parentNode) {
view.createNodes = function(setting, level, nodes, parentNode, index) {
if (_createNodes) {
_createNodes.apply(view, arguments);
}
......
/*
* JQuery zTree exedit v3.5.18
* JQuery zTree exedit v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function(w){var I={event:{DRAG:"ztree_drag",DROP:"ztree_drop",RENAME:"ztree_rename",DRAGMOVE:"ztree_dragmove"},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"}},x={onHoverOverNode:function(b,a){var c=m.getSetting(b.data.treeId),d=m.getRoot(c);if(d.curHoverNode!=a)x.onHoverOutNode(b);d.curHoverNode=a;f.addHoverDom(c,a)},onHoverOutNode:function(b){var b=
m.getSetting(b.data.treeId),a=m.getRoot(b);if(a.curHoverNode&&!m.isSelectedNode(b,a.curHoverNode))f.removeTreeDom(b,a.curHoverNode),a.curHoverNode=null},onMousedownNode:function(b,a){function c(b){if(C.dragFlag==0&&Math.abs(N-b.clientX)<e.edit.drag.minMoveSize&&Math.abs(O-b.clientY)<e.edit.drag.minMoveSize)return!0;var a,c,n,k,i;i=e.data.key.children;M.css("cursor","pointer");if(C.dragFlag==0){if(g.apply(e.callback.beforeDrag,[e.treeId,l],!0)==!1)return r(b),!0;for(a=0,c=l.length;a<c;a++){if(a==0)C.dragNodeShowBefore=
......@@ -36,18 +36,18 @@ a);b.treeObj.trigger(d.event.REMOVE,[b.treeId,a]);return!1}).bind("mousedown",fu
j.unbind();f.setNodeName(b,i);i.editNameFlag=!1;r.curEditNode=null;r.curEditInput=null;f.selectNode(b,i,!1);b.treeObj.trigger(d.event.RENAME,[b.treeId,i,c])}return r.noSelection=!0},editNode:function(b,a){var c=m.getRoot(b);f.editNodeBlur=!1;if(m.isSelectedNode(b,a)&&c.curEditNode==a&&a.editNameFlag)setTimeout(function(){g.inputFocus(c.curEditInput)},0);else{var r=b.data.key.name;a.editNameFlag=!0;f.removeTreeDom(b,a);f.cancelCurEditNode(b);f.selectNode(b,a,!1);o(a,d.id.SPAN,b).html("<input type=text class='rename' id='"+
a.tId+d.id.INPUT+"' treeNode"+d.id.INPUT+" >");var k=o(a,d.id.INPUT,b);k.attr("value",a[r]);b.edit.editNameSelectAll?g.inputSelect(k):g.inputFocus(k);k.bind("blur",function(){f.editNodeBlur||f.cancelCurEditNode(b)}).bind("keydown",function(a){a.keyCode=="13"?(f.editNodeBlur=!0,f.cancelCurEditNode(b)):a.keyCode=="27"&&f.cancelCurEditNode(b,null,!0)}).bind("click",function(){return!1}).bind("dblclick",function(){return!1});o(a,d.id.A,b).addClass(d.node.CURSELECTED_EDIT);c.curEditInput=k;c.noSelection=
!1;c.curEditNode=a}},moveNode:function(b,a,c,r,k,i){var j=m.getRoot(b),e=b.data.key.children;if(a!=c&&(!b.data.keep.leaf||!a||a.isParent||r!=d.move.TYPE_INNER)){var g=c.parentTId?c.getParentNode():j,t=a===null||a==j;t&&a===null&&(a=j);if(t)r=d.move.TYPE_INNER;j=a.parentTId?a.getParentNode():j;if(r!=d.move.TYPE_PREV&&r!=d.move.TYPE_NEXT)r=d.move.TYPE_INNER;if(r==d.move.TYPE_INNER)if(t)c.parentTId=null;else{if(!a.isParent)a.isParent=!0,a.open=!!a.open,f.setNodeLineIcos(b,a);c.parentTId=a.tId}var p;
t?p=t=b.treeObj:(!i&&r==d.move.TYPE_INNER?f.expandCollapseNode(b,a,!0,!1):i||f.expandCollapseNode(b,a.getParentNode(),!0,!1),t=o(a,b),p=o(a,d.id.UL,b),t.get(0)&&!p.get(0)&&(p=[],f.makeUlHtml(b,a,p,""),t.append(p.join(""))),p=o(a,d.id.UL,b));var q=o(c,b);q.get(0)?t.get(0)||q.remove():q=f.appendNodes(b,c.level,[c],null,!1,!0).join("");p.get(0)&&r==d.move.TYPE_INNER?p.append(q):t.get(0)&&r==d.move.TYPE_PREV?t.before(q):t.get(0)&&r==d.move.TYPE_NEXT&&t.after(q);var l=-1,w=0,x=null,t=null,D=c.level;if(c.isFirstNode){if(l=
0,g[e].length>1)x=g[e][1],x.isFirstNode=!0}else if(c.isLastNode)l=g[e].length-1,x=g[e][l-1],x.isLastNode=!0;else for(p=0,q=g[e].length;p<q;p++)if(g[e][p].tId==c.tId){l=p;break}l>=0&&g[e].splice(l,1);if(r!=d.move.TYPE_INNER)for(p=0,q=j[e].length;p<q;p++)j[e][p].tId==a.tId&&(w=p);if(r==d.move.TYPE_INNER){a[e]||(a[e]=[]);if(a[e].length>0)t=a[e][a[e].length-1],t.isLastNode=!1;a[e].splice(a[e].length,0,c);c.isLastNode=!0;c.isFirstNode=a[e].length==1}else a.isFirstNode&&r==d.move.TYPE_PREV?(j[e].splice(w,
0,c),t=a,t.isFirstNode=!1,c.parentTId=a.parentTId,c.isFirstNode=!0,c.isLastNode=!1):a.isLastNode&&r==d.move.TYPE_NEXT?(j[e].splice(w+1,0,c),t=a,t.isLastNode=!1,c.parentTId=a.parentTId,c.isFirstNode=!1,c.isLastNode=!0):(r==d.move.TYPE_PREV?j[e].splice(w,0,c):j[e].splice(w+1,0,c),c.parentTId=a.parentTId,c.isFirstNode=!1,c.isLastNode=!1);m.fixPIdKeyValue(b,c);m.setSonNodeLevel(b,c.getParentNode(),c);f.setNodeLineIcos(b,c);f.repairNodeLevelClass(b,c,D);!b.data.keep.parent&&g[e].length<1?(g.isParent=!1,
g.open=!1,a=o(g,d.id.UL,b),r=o(g,d.id.SWITCH,b),e=o(g,d.id.ICON,b),f.replaceSwitchClass(g,r,d.folder.DOCU),f.replaceIcoClass(g,e,d.folder.DOCU),a.css("display","none")):x&&f.setNodeLineIcos(b,x);t&&f.setNodeLineIcos(b,t);b.check&&b.check.enable&&f.repairChkClass&&(f.repairChkClass(b,g),f.repairParentChkClassWithSelf(b,g),g!=c.parent&&f.repairParentChkClassWithSelf(b,c));i||f.expandCollapseParentNode(b,c.getParentNode(),!0,k)}},removeEditBtn:function(b,a){o(a,d.id.EDIT,b).unbind().remove()},removeRemoveBtn:function(b,
a){o(a,d.id.REMOVE,b).unbind().remove()},removeTreeDom:function(b,a){a.isHover=!1;f.removeEditBtn(b,a);f.removeRemoveBtn(b,a);g.apply(b.view.removeHoverDom,[b.treeId,a])},repairNodeLevelClass:function(b,a,c){if(c!==a.level){var f=o(a,b),g=o(a,d.id.A,b),b=o(a,d.id.UL,b),c=d.className.LEVEL+c,a=d.className.LEVEL+a.level;f.removeClass(c);f.addClass(a);g.removeClass(c);g.addClass(a);b.removeClass(c);b.addClass(a)}},selectNodes:function(b,a){for(var c=0,d=a.length;c<d;c++)f.selectNode(b,a[c],c>0)}},event:{},
data:{setSonNodeLevel:function(b,a,c){if(c){var d=b.data.key.children;c.level=a?a.level+1:0;if(c[d])for(var a=0,f=c[d].length;a<f;a++)c[d][a]&&m.setSonNodeLevel(b,c,c[d][a])}}}});var H=w.fn.zTree,g=H._z.tools,d=H.consts,f=H._z.view,m=H._z.data,o=g.$;m.exSetting({edit:{enable:!1,editNameSelectAll:!1,showRemoveBtn:!0,showRenameBtn:!0,removeTitle:"remove",renameTitle:"rename",drag:{autoExpandTrigger:!1,isCopy:!0,isMove:!0,prev:!0,next:!0,inner:!0,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,onDragMove:null,onDrop:null,onRename:null}});m.addInitBind(function(b){var a=b.treeObj,c=d.event;a.bind(c.RENAME,function(a,c,d,f){g.apply(b.callback.onRename,[a,c,d,f])});a.bind(c.DRAG,function(a,c,d,f){g.apply(b.callback.onDrag,[c,d,f])});a.bind(c.DRAGMOVE,function(a,c,d,f){g.apply(b.callback.onDragMove,[c,d,f])});a.bind(c.DROP,
function(a,c,d,f,e,m,o){g.apply(b.callback.onDrop,[c,d,f,e,m,o])})});m.addInitUnBind(function(b){var b=b.treeObj,a=d.event;b.unbind(a.RENAME);b.unbind(a.DRAG);b.unbind(a.DRAGMOVE);b.unbind(a.DROP)});m.addInitCache(function(){});m.addInitNode(function(b,a,c){if(c)c.isHover=!1,c.editNameFlag=!1});m.addInitProxy(function(b){var a=b.target,c=m.getSetting(b.data.treeId),f=b.relatedTarget,k="",i=null,j="",e=null,o=null;if(g.eqs(b.type,"mouseover")){if(o=g.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+d.id.A}]))k=
g.getNodeMainDom(o).id,j="hoverOverNode"}else if(g.eqs(b.type,"mouseout"))o=g.getMDom(c,f,[{tagName:"a",attrName:"treeNode"+d.id.A}]),o||(k="remove",j="hoverOutNode");else if(g.eqs(b.type,"mousedown")&&(o=g.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+d.id.A}])))k=g.getNodeMainDom(o).id,j="mousedownNode";if(k.length>0)switch(i=m.getNodeCache(c,k),j){case "mousedownNode":e=x.onMousedownNode;break;case "hoverOverNode":e=x.onHoverOverNode;break;case "hoverOutNode":e=x.onHoverOutNode}return{stop:!1,
node:i,nodeEventType:j,nodeEventCallback:e,treeEventType:"",treeEventCallback:null}});m.addInitRoot(function(b){var b=m.getRoot(b),a=m.getRoots();b.curEditNode=null;b.curEditInput=null;b.curHoverNode=null;b.dragFlag=0;b.dragNodeShowBefore=[];b.dragMaskList=[];a.showHoverDom=!0});m.addZTreeTools(function(b,a){a.cancelEditName=function(a){m.getRoot(this.setting).curEditNode&&f.cancelCurEditNode(this.setting,a?a:null,!0)};a.copyNode=function(a,b,k,i){if(!b)return null;if(a&&!a.isParent&&this.setting.data.keep.leaf&&
k===d.move.TYPE_INNER)return null;var j=this,e=g.clone(b);if(!a)a=null,k=d.move.TYPE_INNER;k==d.move.TYPE_INNER?(b=function(){f.addNodes(j.setting,a,[e],i)},g.canAsync(this.setting,a)?f.asyncNode(this.setting,a,i,b):b()):(f.addNodes(this.setting,a.parentNode,[e],i),f.moveNode(this.setting,a,e,k,!1,i));return e};a.editName=function(a){a&&a.tId&&a===m.getNodeCache(this.setting,a.tId)&&(a.parentTId&&f.expandCollapseParentNode(this.setting,a.getParentNode(),!0),f.editNode(this.setting,a))};a.moveNode=
function(a,b,k,i){function j(){f.moveNode(e.setting,a,b,k,!1,i)}if(!b)return b;if(a&&!a.isParent&&this.setting.data.keep.leaf&&k===d.move.TYPE_INNER)return null;else if(a&&(b.parentTId==a.tId&&k==d.move.TYPE_INNER||o(b,this.setting).find("#"+a.tId).length>0))return null;else a||(a=null);var e=this;g.canAsync(this.setting,a)&&k===d.move.TYPE_INNER?f.asyncNode(this.setting,a,i,j):j();return b};a.setEditable=function(a){this.setting.edit.enable=a;return this.refresh()}});var N=f.cancelPreSelectedNode;
f.cancelPreSelectedNode=function(b,a){for(var c=m.getRoot(b).curSelectedList,d=0,g=c.length;d<g;d++)if(!a||a===c[d])if(f.removeTreeDom(b,c[d]),a)break;N&&N.apply(f,arguments)};var O=f.createNodes;f.createNodes=function(b,a,c,d){O&&O.apply(f,arguments);c&&f.repairParentChkClassWithSelf&&f.repairParentChkClassWithSelf(b,d)};var V=f.makeNodeUrl;f.makeNodeUrl=function(b,a){return b.edit.enable?null:V.apply(f,arguments)};var L=f.removeNode;f.removeNode=function(b,a){var c=m.getRoot(b);if(c.curEditNode===
a)c.curEditNode=null;L&&L.apply(f,arguments)};var P=f.selectNode;f.selectNode=function(b,a,c){var d=m.getRoot(b);if(m.isSelectedNode(b,a)&&d.curEditNode==a&&a.editNameFlag)return!1;P&&P.apply(f,arguments);f.addHoverDom(b,a);return!0};var Q=g.uCanDo;g.uCanDo=function(b,a){var c=m.getRoot(b);if(a&&(g.eqs(a.type,"mouseover")||g.eqs(a.type,"mouseout")||g.eqs(a.type,"mousedown")||g.eqs(a.type,"mouseup")))return!0;if(c.curEditNode)f.editNodeBlur=!1,c.curEditInput.focus();return!c.curEditNode&&(Q?Q.apply(f,
arguments):!0)}})(jQuery);
t?p=t=b.treeObj:(!i&&r==d.move.TYPE_INNER?f.expandCollapseNode(b,a,!0,!1):i||f.expandCollapseNode(b,a.getParentNode(),!0,!1),t=o(a,b),p=o(a,d.id.UL,b),t.get(0)&&!p.get(0)&&(p=[],f.makeUlHtml(b,a,p,""),t.append(p.join(""))),p=o(a,d.id.UL,b));var q=o(c,b);q.get(0)?t.get(0)||q.remove():q=f.appendNodes(b,c.level,[c],null,-1,!1,!0).join("");p.get(0)&&r==d.move.TYPE_INNER?p.append(q):t.get(0)&&r==d.move.TYPE_PREV?t.before(q):t.get(0)&&r==d.move.TYPE_NEXT&&t.after(q);var l=-1,w=0,x=null,t=null,D=c.level;
if(c.isFirstNode){if(l=0,g[e].length>1)x=g[e][1],x.isFirstNode=!0}else if(c.isLastNode)l=g[e].length-1,x=g[e][l-1],x.isLastNode=!0;else for(p=0,q=g[e].length;p<q;p++)if(g[e][p].tId==c.tId){l=p;break}l>=0&&g[e].splice(l,1);if(r!=d.move.TYPE_INNER)for(p=0,q=j[e].length;p<q;p++)j[e][p].tId==a.tId&&(w=p);if(r==d.move.TYPE_INNER){a[e]||(a[e]=[]);if(a[e].length>0)t=a[e][a[e].length-1],t.isLastNode=!1;a[e].splice(a[e].length,0,c);c.isLastNode=!0;c.isFirstNode=a[e].length==1}else a.isFirstNode&&r==d.move.TYPE_PREV?
(j[e].splice(w,0,c),t=a,t.isFirstNode=!1,c.parentTId=a.parentTId,c.isFirstNode=!0,c.isLastNode=!1):a.isLastNode&&r==d.move.TYPE_NEXT?(j[e].splice(w+1,0,c),t=a,t.isLastNode=!1,c.parentTId=a.parentTId,c.isFirstNode=!1,c.isLastNode=!0):(r==d.move.TYPE_PREV?j[e].splice(w,0,c):j[e].splice(w+1,0,c),c.parentTId=a.parentTId,c.isFirstNode=!1,c.isLastNode=!1);m.fixPIdKeyValue(b,c);m.setSonNodeLevel(b,c.getParentNode(),c);f.setNodeLineIcos(b,c);f.repairNodeLevelClass(b,c,D);!b.data.keep.parent&&g[e].length<
1?(g.isParent=!1,g.open=!1,a=o(g,d.id.UL,b),r=o(g,d.id.SWITCH,b),e=o(g,d.id.ICON,b),f.replaceSwitchClass(g,r,d.folder.DOCU),f.replaceIcoClass(g,e,d.folder.DOCU),a.css("display","none")):x&&f.setNodeLineIcos(b,x);t&&f.setNodeLineIcos(b,t);b.check&&b.check.enable&&f.repairChkClass&&(f.repairChkClass(b,g),f.repairParentChkClassWithSelf(b,g),g!=c.parent&&f.repairParentChkClassWithSelf(b,c));i||f.expandCollapseParentNode(b,c.getParentNode(),!0,k)}},removeEditBtn:function(b,a){o(a,d.id.EDIT,b).unbind().remove()},
removeRemoveBtn:function(b,a){o(a,d.id.REMOVE,b).unbind().remove()},removeTreeDom:function(b,a){a.isHover=!1;f.removeEditBtn(b,a);f.removeRemoveBtn(b,a);g.apply(b.view.removeHoverDom,[b.treeId,a])},repairNodeLevelClass:function(b,a,c){if(c!==a.level){var f=o(a,b),g=o(a,d.id.A,b),b=o(a,d.id.UL,b),c=d.className.LEVEL+c,a=d.className.LEVEL+a.level;f.removeClass(c);f.addClass(a);g.removeClass(c);g.addClass(a);b.removeClass(c);b.addClass(a)}},selectNodes:function(b,a){for(var c=0,d=a.length;c<d;c++)f.selectNode(b,
a[c],c>0)}},event:{},data:{setSonNodeLevel:function(b,a,c){if(c){var d=b.data.key.children;c.level=a?a.level+1:0;if(c[d])for(var a=0,f=c[d].length;a<f;a++)c[d][a]&&m.setSonNodeLevel(b,c,c[d][a])}}}});var H=w.fn.zTree,g=H._z.tools,d=H.consts,f=H._z.view,m=H._z.data,o=g.$;m.exSetting({edit:{enable:!1,editNameSelectAll:!1,showRemoveBtn:!0,showRenameBtn:!0,removeTitle:"remove",renameTitle:"rename",drag:{autoExpandTrigger:!1,isCopy:!0,isMove:!0,prev:!0,next:!0,inner:!0,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,onDragMove:null,onDrop:null,onRename:null}});m.addInitBind(function(b){var a=b.treeObj,c=d.event;a.bind(c.RENAME,function(a,c,d,f){g.apply(b.callback.onRename,[a,c,d,f])});a.bind(c.DRAG,function(a,c,d,f){g.apply(b.callback.onDrag,[c,d,f])});a.bind(c.DRAGMOVE,function(a,c,d,f){g.apply(b.callback.onDragMove,[c,
d,f])});a.bind(c.DROP,function(a,c,d,f,e,m,o){g.apply(b.callback.onDrop,[c,d,f,e,m,o])})});m.addInitUnBind(function(b){var b=b.treeObj,a=d.event;b.unbind(a.RENAME);b.unbind(a.DRAG);b.unbind(a.DRAGMOVE);b.unbind(a.DROP)});m.addInitCache(function(){});m.addInitNode(function(b,a,c){if(c)c.isHover=!1,c.editNameFlag=!1});m.addInitProxy(function(b){var a=b.target,c=m.getSetting(b.data.treeId),f=b.relatedTarget,k="",i=null,j="",e=null,o=null;if(g.eqs(b.type,"mouseover")){if(o=g.getMDom(c,a,[{tagName:"a",
attrName:"treeNode"+d.id.A}]))k=g.getNodeMainDom(o).id,j="hoverOverNode"}else if(g.eqs(b.type,"mouseout"))o=g.getMDom(c,f,[{tagName:"a",attrName:"treeNode"+d.id.A}]),o||(k="remove",j="hoverOutNode");else if(g.eqs(b.type,"mousedown")&&(o=g.getMDom(c,a,[{tagName:"a",attrName:"treeNode"+d.id.A}])))k=g.getNodeMainDom(o).id,j="mousedownNode";if(k.length>0)switch(i=m.getNodeCache(c,k),j){case "mousedownNode":e=x.onMousedownNode;break;case "hoverOverNode":e=x.onHoverOverNode;break;case "hoverOutNode":e=
x.onHoverOutNode}return{stop:!1,node:i,nodeEventType:j,nodeEventCallback:e,treeEventType:"",treeEventCallback:null}});m.addInitRoot(function(b){var b=m.getRoot(b),a=m.getRoots();b.curEditNode=null;b.curEditInput=null;b.curHoverNode=null;b.dragFlag=0;b.dragNodeShowBefore=[];b.dragMaskList=[];a.showHoverDom=!0});m.addZTreeTools(function(b,a){a.cancelEditName=function(a){m.getRoot(this.setting).curEditNode&&f.cancelCurEditNode(this.setting,a?a:null,!0)};a.copyNode=function(a,b,k,i){if(!b)return null;
if(a&&!a.isParent&&this.setting.data.keep.leaf&&k===d.move.TYPE_INNER)return null;var j=this,e=g.clone(b);if(!a)a=null,k=d.move.TYPE_INNER;k==d.move.TYPE_INNER?(b=function(){f.addNodes(j.setting,a,[e],i)},g.canAsync(this.setting,a)?f.asyncNode(this.setting,a,i,b):b()):(f.addNodes(this.setting,a.parentNode,[e],i),f.moveNode(this.setting,a,e,k,!1,i));return e};a.editName=function(a){a&&a.tId&&a===m.getNodeCache(this.setting,a.tId)&&(a.parentTId&&f.expandCollapseParentNode(this.setting,a.getParentNode(),
!0),f.editNode(this.setting,a))};a.moveNode=function(a,b,k,i){function j(){f.moveNode(e.setting,a,b,k,!1,i)}if(!b)return b;if(a&&!a.isParent&&this.setting.data.keep.leaf&&k===d.move.TYPE_INNER)return null;else if(a&&(b.parentTId==a.tId&&k==d.move.TYPE_INNER||o(b,this.setting).find("#"+a.tId).length>0))return null;else a||(a=null);var e=this;g.canAsync(this.setting,a)&&k===d.move.TYPE_INNER?f.asyncNode(this.setting,a,i,j):j();return b};a.setEditable=function(a){this.setting.edit.enable=a;return this.refresh()}});
var N=f.cancelPreSelectedNode;f.cancelPreSelectedNode=function(b,a){for(var c=m.getRoot(b).curSelectedList,d=0,g=c.length;d<g;d++)if(!a||a===c[d])if(f.removeTreeDom(b,c[d]),a)break;N&&N.apply(f,arguments)};var O=f.createNodes;f.createNodes=function(b,a,c,d,g){O&&O.apply(f,arguments);c&&f.repairParentChkClassWithSelf&&f.repairParentChkClassWithSelf(b,d)};var V=f.makeNodeUrl;f.makeNodeUrl=function(b,a){return b.edit.enable?null:V.apply(f,arguments)};var L=f.removeNode;f.removeNode=function(b,a){var c=
m.getRoot(b);if(c.curEditNode===a)c.curEditNode=null;L&&L.apply(f,arguments)};var P=f.selectNode;f.selectNode=function(b,a,c){var d=m.getRoot(b);if(m.isSelectedNode(b,a)&&d.curEditNode==a&&a.editNameFlag)return!1;P&&P.apply(f,arguments);f.addHoverDom(b,a);return!0};var Q=g.uCanDo;g.uCanDo=function(b,a){var c=m.getRoot(b);if(a&&(g.eqs(a.type,"mouseover")||g.eqs(a.type,"mouseout")||g.eqs(a.type,"mousedown")||g.eqs(a.type,"mouseup")))return!0;if(c.curEditNode)f.editNodeBlur=!1,c.curEditInput.focus();
return!c.curEditNode&&(Q?Q.apply(f,arguments):!0)}})(jQuery);
/*
* JQuery zTree exHideNodes v3.5.18
* JQuery zTree exHideNodes v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(function($){
//default init node of exLib
......
/*
* JQuery zTree exHideNodes v3.5.18
* JQuery zTree exHideNodes v3.5.19
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2015-08-26
* Date: 2015-10-22
*/
(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;d.setNodeLineIcos(c,b);break}if(b.isLastNode)break;b=b.getNextNode()}},clearOldLastNode:function(c,a,b){for(a=a.getPreNode();a;){if(a.isLastNode){a.isLastNode=!1;b&&d.setNodeLineIcos(c,a);break}if(a.isFirstNode)break;a=a.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;f.initShowForExCheck(c,a);j(a,c).show()},showNodes:function(c,a,b){if(a&&a.length!=0){var e={},g,k;for(g=0,k=a.length;g<k;g++){var h=a[g];if(!e[h.parentTId]){var i=h.getParentNode();e[h.parentTId]=i===null?f.getRoot(c):h.getParentNode()}d.showNode(c,h,b)}for(var j in e)a=e[j][c.data.key.children],d.setFirstNodeForShow(c,a),d.setLastNodeForShow(c,a)}},hideNode:function(c,a){a.isHidden=!0;a.isFirstNode=!1;a.isLastNode=
......
......@@ -13,6 +13,10 @@
</font>
*2015.10.22* v3.5.19
* 【修改】addNodes 方法支持直接添加新节点到任意位置 addNodes(parentNode, index, newNodes, isSilent)
* 【修改】selectstart 事件未解绑导致的内存泄漏
*2015.08.26* v3.5.18
* 【修改】onSelected/onUnSelected 回调参数,由 (event, treeId, node) 修改为 (treeId, node);另外 删除 已选择的节点时,也会触发 onUnSelected 回调
* 【增加】Allow nodes to specify their own icon using an 'icon' property of the 'setting.data.key'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册