提交 ad144cf5 编写于 作者: Z zTree-github

* [修改] setting.async.autoParam / otherParam 支持 function

   * [修改] isParent / isHidden 允许自定义属性名称 setting.data.key.isParent / isHidden
上级 37132d1e
......@@ -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.31 API 文档</em></h1><p></p>
<h1><em>zTree v3.5.32 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.31 API Document</em></h1><p></p>
<h1><em>zTree v3.5.32 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;">
......
......@@ -133,6 +133,8 @@ var apiContent = {
{id:510, pId:50, t:"key", name:"key : {", open:true},
{id:5101, pId:510, t:"checked", name:"checked : \"checked\",", iconSkin:"check", showAPI:true},
{id:5102, pId:510, t:"children", name:"children : \"children\",", iconSkin:"core", showAPI:true},
{id:5106, pId:510, t:"isParent", name:"isParent : \"isParent\",", iconSkin:"core", showAPI:true},
{id:5107, pId:510, t:"isHidden", name:"isHidden : \"isHidden\",", iconSkin:"hide", showAPI:true},
{id:5103, pId:510, t:"name", name:"name : \"name\",", iconSkin:"core", showAPI:true},
{id:5104, pId:510, t:"title", name:"title : \"\"", iconSkin:"core", showAPI:true},
{id:5105, pId:510, t:"url", name:"url : \"url\"", iconSkin:"core", showAPI:true},
......
此差异已折叠。
<div class="apiDetail">
<div>
<h2><span>Array(String)</span><span class="path">setting.async.</span>autoParam</h2>
<h2><span>Array(String) / Function(treeId, treeNode)</span><span class="path">setting.async.</span>autoParam</h2>
<h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js ]</span></h3>
<div class="desc">
<p></p>
......@@ -14,6 +14,16 @@
<p>1、将需要作为参数提交的属性名称,制作成 Array 即可,例如:["id", "name"]</p>
<p>2、可以设置提交时的参数名称,例如 server 只接受 zId : ["id=zId"]</p>
</div>
<h3>Function 参数说明</h3>
<div class="desc">
<h4><b>treeId</b><span>String</span></h4>
<p>对应 zTree 的 <b class="highlight_red">treeId</b>,便于用户操控</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>需要异步加载子节点的的父节点 JSON 数据对象</p>
<p class="highlight_red">针对根进行异步加载时,treeNode = null</p>
<h4 class="topLine"><b>返回值</b><span>Array(String)</span></h4>
<p>返回值同 Array(String) 格式的数据</p>
</div>
<h3>setting 举例</h3>
<h4>1. 设置 id 属性为自动提交的参数</h4>
<pre xmlns=""><code>var setting = {
......
<div class="apiDetail">
<div>
<h2><span>Array(String) / JSON</span><span class="path">setting.async.</span>otherParam</h2>
<h2><span>Array(String) / JSON / Function(treeId, treeNode)</span><span class="path">setting.async.</span>otherParam</h2>
<h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js ]</span></h3>
<div class="desc">
<p></p>
......@@ -17,6 +17,16 @@
<div class="desc">
<p>直接用 JSON 格式制作键值对,例如:{ key1:value1, key2:value2 }</p>
</div>
<h3>Function 参数说明</h3>
<div class="desc">
<h4><b>treeId</b><span>String</span></h4>
<p>对应 zTree 的 <b class="highlight_red">treeId</b>,便于用户操控</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>需要异步加载子节点的的父节点 JSON 数据对象</p>
<p class="highlight_red">针对根进行异步加载时,treeNode = null</p>
<h4 class="topLine"><b>返回值</b><span>Array(String) || JSON</span></h4>
<p>返回值同 Array(String) || JSON 格式的数据</p>
</div>
<h3>setting 举例</h3>
<h4>1. 设置 Array(String) 格式的参数</h4>
<pre xmlns=""><code>var setting = {
......
<div class="apiDetail">
<div>
<h2><span>String</span><span class="path">setting.data.key.</span>isHidden</h2>
<h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.exhide</span> js ]</span></h3>
<div class="desc">
<p></p>
<div class="longdesc">
<p>zTree 节点数据保存节点是否隐藏的属性名称。</p>
<p>默认值:"isHidden"</p>
<p class="highlight_red">v3.5.32+</p>
</div>
</div>
<h3>setting 举例</h3>
<h4>1. 设置 zTree 显示节点时,将 treeNode 的 hidden 属性当做节点是否隐藏的属性名称</h4>
<pre xmlns=""><code>var setting = {
data: {
key: {
isHidden: "hidden"
}
}
};
......</code></pre>
</div>
</div>
\ No newline at end of file
<div class="apiDetail">
<div>
<h2><span>String</span><span class="path">setting.data.key.</span>isParent</h2>
<h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.core</span> 核心 js ]</span></h3>
<div class="desc">
<p></p>
<div class="longdesc">
<p>zTree 节点数据保存节点是否为父节点的属性名称。</p>
<p>默认值:"isParent"</p>
<p class="highlight_red">v3.5.32+</p>
</div>
</div>
<h3>setting 举例</h3>
<h4>1. 设置 zTree 显示节点时,将 treeNode 的 parent 属性当做节点是否为父节点的属性名称</h4>
<pre xmlns=""><code>var setting = {
data: {
key: {
isParent: "parent"
}
}
};
......</code></pre>
</div>
</div>
\ No newline at end of file
<div class="apiDetail">
<div>
<h2><span>Array(String)</span><span class="path">setting.async.</span>autoParam</h2>
<h2><span>Array(String) / Function(treeId, treeNode)</span><span class="path">setting.async.</span>autoParam</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>
......@@ -17,6 +17,16 @@
<p>1. Put the attribute name(s) of node to the array. For example: ["id", "name"]</p>
<p>2. You can rename the parameter name as sent to the server. For example: server only accepts "zId" -- ["id=zId"]</p>
</div>
<h3>Function Parameter Descriptions</h3>
<div class="desc">
<h4><b>treeId</b><span>String</span></h4>
<p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>Parent node's JSON data object</p>
<p class="highlight_red">When asynchronously loading the root, the treeNode = null</p>
<h4 class="topLine"><b>Return </b><span>Array(String)</span></h4>
<p>Return value is same as 'Array(String) Format'</p>
</div>
<h3>Examples of setting</h3>
<h4>1. set auto commit 'id' attribute</h4>
<pre xmlns=""><code>var setting = {
......
<div class="apiDetail">
<div>
<h2><span>Array(String) / JSON</span><span class="path">setting.async.</span>otherParam</h2>
<h2><span>Array(String) / JSON / Function(treeId, treeNode)</span><span class="path">setting.async.</span>otherParam</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>
......@@ -17,6 +17,16 @@
<div class="desc">
<p>Use JSON hash data to set the key-value pairs. e.g. { key1:value1, key2:value2 }</p>
</div>
<h3>Function Parameter Descriptions</h3>
<div class="desc">
<h4><b>treeId</b><span>String</span></h4>
<p>zTree unique identifier: <b class="highlight_red">treeId</b>.</p>
<h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
<p>Parent node's JSON data object</p>
<p class="highlight_red">When asynchronously loading the root, the treeNode = null</p>
<h4 class="topLine"><b>Return </b><span>Array(String) || JSON</span></h4>
<p>Return value is same as 'Array(String) || JSON Format'</p>
</div>
<h3>Examples of setting</h3>
<h4>1. Using Array(String) Format</h4>
<pre xmlns=""><code>var setting = {
......
<div class="apiDetail">
<div>
<h2><span>String</span><span class="path">setting.data.key.</span>isHidden</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>
<div class="longdesc">
<p>The node data's attribute to save whether the node is the parent node.</p>
<p>Default: "isHidden"</p>
<p class="highlight_red">v3.5.32+</p>
</div>
</div>
<h3>Examples of setting</h3>
<h4>1. Set the 'hidden' attribute to save whether the node is the parent node.</h4>
<pre xmlns=""><code>var setting = {
data: {
key: {
isHidden: "hidden"
}
}
};
......</code></pre>
</div>
</div>
\ No newline at end of file
<div class="apiDetail">
<div>
<h2><span>String</span><span class="path">setting.data.key.</span>isParent</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>
<div class="longdesc">
<p>The node data's attribute to save whether the node is the parent node.</p>
<p>Default: "isParent"</p>
<p class="highlight_red">v3.5.32+</p>
</div>
</div>
<h3>Examples of setting</h3>
<h4>1. Set the 'parent' attribute to save whether the node is the parent node.</h4>
<pre xmlns=""><code>var setting = {
data: {
key: {
isParent: "parent"
}
}
};
......</code></pre>
</div>
</div>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
/*
* JQuery zTree excheck v3.5.31
* JQuery zTree excheck v3.5.32
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-12-28
* Date: 2018-01-06
*/
(function($){
//default consts of excheck
......@@ -131,10 +131,9 @@
//default init node of excheck
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
if (!n) return;
var checkedKey = setting.data.key.checked;
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
n[checkedKey] = !!n[checkedKey];
n.checkedOld = n[checkedKey];
var checked = data.nodeChecked(setting, n);
checked = data.nodeChecked(setting, n, checked);
n.checkedOld = checked;
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
......@@ -145,14 +144,13 @@
n.check_Focus = false;
n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && n[checkedKey] ) {
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && checked) {
var r = data.getRoot(setting);
r.radioCheckedList.push(n);
}
},
//add dom for check
_beforeA = function(setting, node, html) {
var checkedKey = setting.data.key.checked;
if (setting.check.enable) {
data.makeChkFlag(setting, node);
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>");
......@@ -161,20 +159,20 @@
//update zTreeObj, add method of check
_zTreeTools = function(setting, zTreeTools) {
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
var checkedKey = this.setting.data.key.checked;
var nodeChecked = data.nodeChecked(setting, node);
if (node.chkDisabled === true) return;
if (checked !== true && checked !== false) {
checked = !node[checkedKey];
checked = !nodeChecked;
}
callbackFlag = !!callbackFlag;
if (node[checkedKey] === checked && !checkTypeFlag) {
if (nodeChecked === checked && !checkTypeFlag) {
return;
} else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
return;
}
if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
node[checkedKey] = checked;
data.nodeChecked(setting, node, checked);
var checkObj = $$(node, consts.id.CHECK, this.setting);
if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
view.setChkClass(this.setting, checkObj, node);
......@@ -190,14 +188,14 @@
}
zTreeTools.getCheckedNodes = function(checked) {
var childKey = this.setting.data.key.children;
checked = (checked !== false);
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked);
var checked = (checked !== false);
var children = data.nodeChildren(setting, data.getRoot(this.setting));
return data.getTreeCheckedNodes(this.setting, children, checked);
}
zTreeTools.getChangeCheckedNodes = function() {
var childKey = this.setting.data.key.children;
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]);
var children = data.nodeChildren(setting, data.getRoot(this.setting));
return data.getTreeChangeCheckedNodes(this.setting, children);
}
zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
......@@ -235,27 +233,28 @@
},
getCheckStatus: function(setting, node) {
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
var checkedKey = setting.data.key.checked,
var checked = data.nodeChecked(setting, node),
r = {
checked: node[checkedKey],
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)))
checked: checked,
half: node.halfCheck ? node.halfCheck : (setting.check.chkStyle == consts.radio.STYLE ? (node.check_Child_State === 2) : (checked ? (node.check_Child_State > -1 && node.check_Child_State < 2) : (node.check_Child_State > 0)))
};
return r;
},
getTreeCheckedNodes: function(setting, nodes, checked, results) {
if (!nodes) return [];
var childKey = setting.data.key.children,
checkedKey = setting.data.key.checked,
onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
var onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
results = !results ? [] : results;
for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
results.push(nodes[i]);
var node = nodes[i];
var children = data.nodeChildren(setting, node);
var nodeChecked = data.nodeChecked(setting, node);
if (node.nocheck !== true && node.chkDisabled !== true && nodeChecked == checked) {
results.push(node);
if(onlyOne) {
break;
}
}
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
data.getTreeCheckedNodes(setting, children, checked, results);
if(onlyOne && results.length > 0) {
break;
}
......@@ -264,32 +263,33 @@
},
getTreeChangeCheckedNodes: function(setting, nodes, results) {
if (!nodes) return [];
var childKey = setting.data.key.children,
checkedKey = setting.data.key.checked;
results = !results ? [] : results;
for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
results.push(nodes[i]);
var node = nodes[i];
var children = data.nodeChildren(setting, node);
var nodeChecked = data.nodeChecked(setting, node);
if (node.nocheck !== true && node.chkDisabled !== true && nodeChecked != node.checkedOld) {
results.push(node);
}
data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
data.getTreeChangeCheckedNodes(setting, children, results);
}
return results;
},
makeChkFlag: function(setting, node) {
if (!node) return;
var childKey = setting.data.key.children,
checkedKey = setting.data.key.checked,
chkFlag = -1;
if (node[childKey]) {
for (var i = 0, l = node[childKey].length; i < l; i++) {
var cNode = node[childKey][i];
var chkFlag = -1;
var children = data.nodeChildren(setting, node);
if (children) {
for (var i = 0, l = children.length; i < l; i++) {
var cNode = children[i];
var nodeChecked = data.nodeChecked(setting, cNode);
var tmp = -1;
if (setting.check.chkStyle == consts.radio.STYLE) {
if (cNode.nocheck === true || cNode.chkDisabled === true) {
tmp = cNode.check_Child_State;
} else if (cNode.halfCheck === true) {
tmp = 2;
} else if (cNode[checkedKey]) {
} else if (nodeChecked) {
tmp = 2;
} else {
tmp = cNode.check_Child_State > 0 ? 2:0;
......@@ -304,7 +304,7 @@
tmp = cNode.check_Child_State;
} else if (cNode.halfCheck === true) {
tmp = 1;
} else if (cNode[checkedKey] ) {
} else if (nodeChecked) {
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
} else {
tmp = (cNode.check_Child_State > 0) ? 1 : 0;
......@@ -332,10 +332,10 @@
_handler = {
onCheckNode: function (event, node) {
if (node.chkDisabled === true) return false;
var setting = data.getSetting(event.data.treeId),
checkedKey = setting.data.key.checked;
var setting = data.getSetting(event.data.treeId);
if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
node[checkedKey] = !node[checkedKey];
var nodeChecked = data.nodeChecked(setting, node);
data.nodeChecked(setting, node, !nodeChecked);
view.checkNodeRelation(setting, node);
var checkObj = $$(node, consts.id.CHECK, setting);
view.setChkClass(setting, checkObj, node);
......@@ -368,17 +368,17 @@
_view = {
checkNodeRelation: function(setting, node) {
var pNode, i, l,
childKey = setting.data.key.children,
checkedKey = setting.data.key.checked,
r = consts.radio;
var nodeChecked = data.nodeChecked(setting, node);
if (setting.check.chkStyle == r.STYLE) {
var checkedList = data.getRadioCheckedList(setting);
if (node[checkedKey]) {
if (nodeChecked) {
if (setting.check.radioType == r.TYPE_ALL) {
for (i = checkedList.length-1; i >= 0; i--) {
pNode = checkedList[i];
if (pNode[checkedKey] && pNode != node) {
pNode[checkedKey] = false;
var pNodeChecked = data.nodeChecked(setting, pNode);
if (pNodeChecked && pNode != node) {
data.nodeChecked(setting, pNode, false);
checkedList.splice(i, 1);
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
......@@ -390,10 +390,12 @@
checkedList.push(node);
} else {
var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
for (i = 0, l = parentNode[childKey].length; i < l; i++) {
pNode = parentNode[childKey][i];
if (pNode[checkedKey] && pNode != node) {
pNode[checkedKey] = false;
var children = data.nodeChildren(setting, parentNode);
for (i = 0, l = children.length; i < l; i++) {
pNode = children[i];
var pNodeChecked = data.nodeChecked(setting, pNode);
if (pNodeChecked && pNode != node) {
data.nodeChecked(setting, pNode, false);
view.setChkClass(setting, $$(pNode, consts.id.CHECK, setting), pNode);
}
}
......@@ -408,24 +410,25 @@
}
} else {
if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
var children = data.nodeChildren(setting, node);
if (nodeChecked && (!children || children.length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
view.setSonNodeCheckBox(setting, node, true);
}
if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
if (!nodeChecked && (!children || children.length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
view.setSonNodeCheckBox(setting, node, false);
}
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
if (nodeChecked && setting.check.chkboxType.Y.indexOf("p") > -1) {
view.setParentNodeCheckBox(setting, node, true);
}
if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
if (!nodeChecked && setting.check.chkboxType.N.indexOf("p") > -1) {
view.setParentNodeCheckBox(setting, node, false);
}
}
},
makeChkClass: function(setting, node) {
var checkedKey = setting.data.key.checked,
c = consts.checkbox, r = consts.radio,
var c = consts.checkbox, r = consts.radio,
fullStyle = "";
var nodeChecked = data.nodeChecked(setting, node);
if (node.chkDisabled === true) {
fullStyle = c.DISABLED;
} else if (node.halfCheck) {
......@@ -433,21 +436,20 @@
} else if (setting.check.chkStyle == r.STYLE) {
fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
} else {
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);
fullStyle = nodeChecked ? ((node.check_Child_State === 2 || node.check_Child_State === -1) ? c.FULL:c.PART) : ((node.check_Child_State < 1)? c.FULL:c.PART);
}
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
var chkName = setting.check.chkStyle + "_" + (nodeChecked ? c.TRUE : c.FALSE) + "_" + fullStyle;
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName;
},
repairAllChk: function(setting, checked) {
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
var checkedKey = setting.data.key.checked,
childKey = setting.data.key.children,
root = data.getRoot(setting);
for (var i = 0, l = root[childKey].length; i<l ; i++) {
var node = root[childKey][i];
var root = data.getRoot(setting);
var children = data.nodeChildren(setting, root);
for (var i = 0, l = children.length; i<l ; i++) {
var node = children[i];
if (node.nocheck !== true && node.chkDisabled !== true) {
node[checkedKey] = checked;
data.nodeChecked(setting, node, checked);
}
view.setSonNodeCheckBox(setting, node, checked);
}
......@@ -469,23 +471,23 @@
},
repairParentChkClassWithSelf: function(setting, node) {
if (!node) return;
var childKey = setting.data.key.children;
if (node[childKey] && node[childKey].length > 0) {
view.repairParentChkClass(setting, node[childKey][0]);
var children = data.nodeChildren(setting, node);
if (children && children.length > 0) {
view.repairParentChkClass(setting, children[0]);
} else {
view.repairParentChkClass(setting, node);
}
},
repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
if (!node) return;
var childKey = setting.data.key.children;
if (node.chkDisabled != chkDisabled) {
if (node.chkDisabled != chkDisabled) {
node.chkDisabled = chkDisabled;
}
view.repairChkClass(setting, node);
if (node[childKey] && inherit) {
for (var i = 0, l = node[childKey].length; i < l; i++) {
var sNode = node[childKey][i];
var children = data.nodeChildren(setting, node);
if (children && inherit) {
for (var i = 0, l = children.length; i < l; i++) {
var sNode = children[i];
view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
}
}
......@@ -508,13 +510,11 @@
obj.attr('class', view.makeChkClass(setting, node));
},
setParentNodeCheckBox: function(setting, node, value, srcNode) {
var childKey = setting.data.key.children,
checkedKey = setting.data.key.checked,
checkObj = $$(node, consts.id.CHECK, setting);
var checkObj = $$(node, consts.id.CHECK, setting);
if (!srcNode) srcNode = node;
data.makeChkFlag(setting, node);
if (node.nocheck !== true && node.chkDisabled !== true) {
node[checkedKey] = value;
data.nodeChecked(setting, node, value);
view.setChkClass(setting, checkObj, node);
if (setting.check.autoCheckTrigger && node != srcNode) {
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
......@@ -523,10 +523,12 @@
if (node.parentTId) {
var pSign = true;
if (!value) {
var pNodes = node.getParentNode()[childKey];
var pNodes = data.nodeChildren(setting, node.getParentNode());
for (var i = 0, l = pNodes.length; i < l; i++) {
if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
|| ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
var pNode = pNodes[i];
var nodeChecked = data.nodeChecked(setting, pNode);
if ((pNode.nocheck !== true && pNode.chkDisabled !== true && nodeChecked)
|| ((pNode.nocheck === true || pNode.chkDisabled === true) && pNode.check_Child_State > 0)) {
pSign = false;
break;
}
......@@ -539,15 +541,14 @@
},
setSonNodeCheckBox: function(setting, node, value, srcNode) {
if (!node) return;
var childKey = setting.data.key.children,
checkedKey = setting.data.key.checked,
checkObj = $$(node, consts.id.CHECK, setting);
var checkObj = $$(node, consts.id.CHECK, setting);
if (!srcNode) srcNode = node;
var hasDisable = false;
if (node[childKey]) {
for (var i = 0, l = node[childKey].length; i < l; i++) {
var sNode = node[childKey][i];
var children = data.nodeChildren(setting, node);
if (children) {
for (var i = 0, l = children.length; i < l; i++) {
var sNode = children[i];
view.setSonNodeCheckBox(setting, sNode, value, srcNode);
if (sNode.chkDisabled === true) hasDisable = true;
}
......@@ -558,8 +559,8 @@
data.makeChkFlag(setting, node);
}
if (node.nocheck !== true && node.chkDisabled !== true) {
node[checkedKey] = value;
if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
data.nodeChecked(setting, node, value);
if (!hasDisable) node.check_Child_State = (children && children.length > 0) ? (value ? 2 : 0) : -1;
} else {
node.check_Child_State = -1;
}
......@@ -589,6 +590,21 @@
event = zt._z.event,
$$ = tools.$;
data.nodeChecked = function(setting, node, newChecked) {
if (!node) {
return false;
}
var key = setting.data.key.checked;
if (typeof newChecked !== 'undefined') {
if (typeof newChecked === "string") {
newChecked = tools.eqs(checked, "true");
}
newChecked = !!newChecked;
node[key] = newChecked;
}
return node[key];
};
data.exSetting(_setting);
data.addInitBind(_bindEvent);
data.addInitUnBind(_unbindEvent);
......
此差异已折叠。
/*
* JQuery zTree exedit v3.5.31
* JQuery zTree exedit v3.5.32
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,7 +8,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-12-28
* Date: 2018-01-06
*/
(function($){
//default consts of exedit
......@@ -183,7 +183,8 @@
}
zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) {
if (!node) return null;
if (targetNode && !targetNode.isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null;
var isParent = data.nodeIsParent(setting, targetNode);
if (targetNode && !isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null;
var _this = this,
newNode = tools.clone(node);
if (!targetNode) {
......@@ -213,7 +214,8 @@
}
zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) {
if (!node) return node;
if (targetNode && !targetNode.isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) {
var isParent = data.nodeIsParent(setting, targetNode);
if (targetNode && !isParent && this.setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) {
return null;
} else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $$(node, this.setting).find("#" + targetNode.tId).length > 0)) {
return null;
......@@ -240,11 +242,11 @@
_data = {
setSonNodeLevel: function(setting, parentNode, node) {
if (!node) return;
var childKey = setting.data.key.children;
var children = data.nodeChildren(setting, node);
node.level = (parentNode)? parentNode.level + 1 : 0;
if (!node[childKey]) return;
for (var i = 0, l = node[childKey].length; i < l; i++) {
if (node[childKey][i]) data.setSonNodeLevel(setting, node, node[childKey][i]);
if (!children) return;
for (var i = 0, l = children.length; i < l; i++) {
if (children[i]) data.setSonNodeLevel(setting, node, children[i]);
}
}
},
......@@ -323,8 +325,7 @@
&& Math.abs(mouseDownY - event.clientY) < setting.edit.drag.minMoveSize) {
return true;
}
var i, l, tmpNode, tmpDom, tmpNodes,
childKey = setting.data.key.children;
var i, l, tmpNode, tmpDom, tmpNodes;
body.css("cursor", "pointer");
if (root.dragFlag == 0) {
......@@ -338,7 +339,7 @@
root.dragNodeShowBefore = [];
}
tmpNode = nodes[i];
if (tmpNode.isParent && tmpNode.open) {
if (data.nodeIsParent(setting, tmpNode) && tmpNode.open) {
view.expandCollapseNode(setting, tmpNode, !tmpNode.open);
root.dragNodeShowBefore[tmpNode.tId] = true;
} else {
......@@ -353,7 +354,7 @@
//sort
var isOrder = true, lastIndex = -1;
if (nodes.length>1) {
var pNodes = nodes[0].parentTId ? nodes[0].getParentNode()[childKey] : data.getNodes(setting);
var pNodes = nodes[0].parentTId ? data.nodeChildren(setting, nodes[0].getParentNode()) : data.getNodes(setting);
tmpNodes = [];
for (i=0, l=pNodes.length; i<l; i++) {
if (root.dragNodeShowBefore[pNodes[i].tId] !== undefined) {
......@@ -514,7 +515,7 @@
isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId),
canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev),
canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next),
canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !tmpTargetNode.isParent) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner);
canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !data.nodeIsParent(setting, tmpTargetNode)) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner);
function clearMove() {
tmpTarget = null;
......@@ -545,7 +546,7 @@
moveType = consts.move.TYPE_PREV;
} else if ((nextPercent==0 || dY_percent>=nextPercent && dY_percent<=1.2) && canNext) {
dX = 1 - tmpArrow.width();
dY = (tmpNextA == null || (tmpTargetNode.isParent && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height()/2) : (tmpNextA.offset().top - tmpArrow.height()/2);
dY = (tmpNextA == null || (data.nodeIsParent(setting, tmpTargetNode) && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height()/2) : (tmpNextA.offset().top - tmpArrow.height()/2);
moveType = consts.move.TYPE_NEXT;
} else if (canInner) {
dX = 5 - tmpArrow.width();
......@@ -566,7 +567,7 @@
if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) {
startTime = (new Date()).getTime();
}
if (tmpTargetNode && tmpTargetNode.isParent && moveType == consts.move.TYPE_INNER) {
if (tmpTargetNode && data.nodeIsParent(setting, tmpTargetNode) && moveType == consts.move.TYPE_INNER) {
var startTimer = true;
if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) {
clearTimeout(window.zTreeMoveTimer);
......@@ -577,7 +578,7 @@
if (startTimer) {
window.zTreeMoveTimer = setTimeout(function() {
if (moveType != consts.move.TYPE_INNER) return;
if (tmpTargetNode && tmpTargetNode.isParent && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime
if (tmpTargetNode && data.nodeIsParent(setting, tmpTargetNode) && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime
&& tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) {
view.switchNode(targetSetting, tmpTargetNode);
if (targetSetting.edit.drag.autoExpandTrigger) {
......@@ -639,7 +640,7 @@
var i, l, tmpNode;
for (i=0, l=nodes.length; i<l; i++) {
tmpNode = nodes[i];
if (tmpNode.isParent && root.dragNodeShowBefore[tmpNode.tId] && !tmpNode.open) {
if (data.nodeIsParent(setting, tmpNode) && root.dragNodeShowBefore[tmpNode.tId] && !tmpNode.open) {
view.expandCollapseNode(setting, tmpNode, !tmpNode.open);
delete root.dragNodeShowBefore[tmpNode.tId];
}
......@@ -831,17 +832,16 @@
},
cancelCurEditNode: function (setting, forceName, isCancel) {
var root = data.getRoot(setting),
nameKey = setting.data.key.name,
node = root.curEditNode;
if (node) {
var inputObj = root.curEditInput,
newName = forceName ? forceName:(isCancel ? node[nameKey]: inputObj.val());
newName = forceName ? forceName:(isCancel ? data.nodeName(setting, node): inputObj.val());
if (tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName, isCancel], true) === false) {
return false;
}
node[nameKey] = newName;
var aObj = $$(node, consts.id.A, setting);
data.nodeName(setting, node, newName);
var aObj = $$(node, consts.id.A, setting);
aObj.removeClass(consts.node.CURSELECTED_EDIT);
inputObj.unbind();
view.setNodeName(setting, node);
......@@ -849,7 +849,7 @@
root.curEditNode = null;
root.curEditInput = null;
view.selectNode(setting, node, false);
setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node, isCancel]);
setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node, isCancel]);
}
root.noSelection = true;
return true;
......@@ -861,14 +861,13 @@
setTimeout(function() {tools.inputFocus(root.curEditInput);}, 0);
return;
}
var nameKey = setting.data.key.name;
node.editNameFlag = true;
view.removeTreeDom(setting, node);
view.cancelCurEditNode(setting);
view.selectNode(setting, node, false);
$$(node, consts.id.SPAN, setting).html("<input type=text class='rename' id='" + node.tId + consts.id.INPUT + "' treeNode" + consts.id.INPUT + " >");
var inputObj = $$(node, consts.id.INPUT, setting);
inputObj.attr("value", node[nameKey]);
inputObj.attr("value", data.nodeName(setting, node));
if (setting.edit.editNameSelectAll) {
tools.inputSelect(inputObj);
} else {
......@@ -898,10 +897,9 @@
root.curEditNode = node;
},
moveNode: function(setting, targetNode, node, moveType, animateFlag, isSilent) {
var root = data.getRoot(setting),
childKey = setting.data.key.children;
var root = data.getRoot(setting);
if (targetNode == node) return;
if (setting.data.keep.leaf && targetNode && !targetNode.isParent && moveType == consts.move.TYPE_INNER) return;
if (setting.data.keep.leaf && targetNode && !data.nodeIsParent(setting, targetNode) && moveType == consts.move.TYPE_INNER) return;
var oldParentNode = (node.parentTId ? node.getParentNode(): root),
targetNodeIsRoot = (targetNode === null || targetNode == root);
if (targetNodeIsRoot && targetNode === null) targetNode = root;
......@@ -917,8 +915,8 @@
//parentTId of root node is null
node.parentTId = null;
} else {
if (!targetNode.isParent) {
targetNode.isParent = true;
if (!data.nodeIsParent(setting, targetNode)) {
data.nodeIsParent(setting, targetNode, true);
targetNode.open = !!targetNode.open;
view.setNodeLineIcos(setting, targetNode);
}
......@@ -967,43 +965,48 @@
oldNeighbor = null,
newNeighbor = null,
oldLevel = node.level;
var oldChildren = data.nodeChildren(setting, oldParentNode);
var targetParentChildren = data.nodeChildren(setting, targetParentNode);
var targetChildren = data.nodeChildren(setting, targetNode);
if (node.isFirstNode) {
tmpSrcIndex = 0;
if (oldParentNode[childKey].length > 1 ) {
oldNeighbor = oldParentNode[childKey][1];
if (oldChildren.length > 1 ) {
oldNeighbor = oldChildren[1];
oldNeighbor.isFirstNode = true;
}
} else if (node.isLastNode) {
tmpSrcIndex = oldParentNode[childKey].length -1;
oldNeighbor = oldParentNode[childKey][tmpSrcIndex - 1];
tmpSrcIndex = oldChildren.length -1;
oldNeighbor = oldChildren[tmpSrcIndex - 1];
oldNeighbor.isLastNode = true;
} else {
for (i = 0, l = oldParentNode[childKey].length; i < l; i++) {
if (oldParentNode[childKey][i].tId == node.tId) {
for (i = 0, l = oldChildren.length; i < l; i++) {
if (oldChildren[i].tId == node.tId) {
tmpSrcIndex = i;
break;
}
}
}
if (tmpSrcIndex >= 0) {
oldParentNode[childKey].splice(tmpSrcIndex, 1);
oldChildren.splice(tmpSrcIndex, 1);
}
if (moveType != consts.move.TYPE_INNER) {
for (i = 0, l = targetParentNode[childKey].length; i < l; i++) {
if (targetParentNode[childKey][i].tId == targetNode.tId) tmpTargetIndex = i;
for (i = 0, l = targetParentChildren.length; i < l; i++) {
if (targetParentChildren[i].tId == targetNode.tId) tmpTargetIndex = i;
}
}
if (moveType == consts.move.TYPE_INNER) {
if (!targetNode[childKey]) targetNode[childKey] = new Array();
if (targetNode[childKey].length > 0) {
newNeighbor = targetNode[childKey][targetNode[childKey].length - 1];
if (!targetChildren) {
targetChildren = data.nodeChildren(setting, targetNode, []);
}
if (targetChildren.length > 0) {
newNeighbor = targetChildren[targetChildren.length - 1];
newNeighbor.isLastNode = false;
}
targetNode[childKey].splice(targetNode[childKey].length, 0, node);
targetChildren.splice(targetChildren.length, 0, node);
node.isLastNode = true;
node.isFirstNode = (targetNode[childKey].length == 1);
node.isFirstNode = (targetChildren.length == 1);
} else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) {
targetParentNode[childKey].splice(tmpTargetIndex, 0, node);
targetParentChildren.splice(tmpTargetIndex, 0, node);
newNeighbor = targetNode;
newNeighbor.isFirstNode = false;
node.parentTId = targetNode.parentTId;
......@@ -1011,7 +1014,7 @@
node.isLastNode = false;
} else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) {
targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node);
targetParentChildren.splice(tmpTargetIndex + 1, 0, node);
newNeighbor = targetNode;
newNeighbor.isLastNode = false;
node.parentTId = targetNode.parentTId;
......@@ -1020,9 +1023,9 @@
} else {
if (moveType == consts.move.TYPE_PREV) {
targetParentNode[childKey].splice(tmpTargetIndex, 0, node);
targetParentChildren.splice(tmpTargetIndex, 0, node);
} else {
targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node);
targetParentChildren.splice(tmpTargetIndex + 1, 0, node);
}
node.parentTId = targetNode.parentTId;
node.isFirstNode = false;
......@@ -1033,12 +1036,12 @@
//repair node what been moved
view.setNodeLineIcos(setting, node);
view.repairNodeLevelClass(setting, node, oldLevel)
view.repairNodeLevelClass(setting, node, oldLevel);
//repair node's old parentNode dom
if (!setting.data.keep.parent && oldParentNode[childKey].length < 1) {
if (!setting.data.keep.parent && oldChildren.length < 1) {
//old parentNode has no child nodes
oldParentNode.isParent = false;
data.nodeIsParent(setting, oldParentNode, false);
oldParentNode.open = false;
var tmp_ulObj = $$(oldParentNode, consts.id.UL, setting),
tmp_switchObj = $$(oldParentNode, consts.id.SWITCH, setting),
......
此差异已折叠。
/*
* JQuery zTree exHideNodes v3.5.31
* JQuery zTree exHideNodes v3.5.32
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,13 +8,20 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-12-28
* Date: 2018-01-06
*/
(function($){
var _setting = {
data: {
key: {
isHidden: "isHidden"
}
}
};
//default init node of exLib
var _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
if (typeof n.isHidden == "string") n.isHidden = tools.eqs(n.isHidden, "true");
n.isHidden = !!n.isHidden;
var isHidden = data.isHidden(setting, n);
data.isHidden(setting, n, isHidden);
data.initHideForExCheck(setting, n);
},
//add dom for check
......@@ -43,7 +50,7 @@
var _checkNode = zTreeTools.checkNode;
if (_checkNode) {
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
if (!!node && !!node.isHidden) {
if (!!node && !!data.isHidden(setting, node)) {
return;
}
_checkNode.apply(zTreeTools, arguments);
......@@ -53,7 +60,8 @@
//method of operate data
_data = {
initHideForExCheck: function(setting, n) {
if (n.isHidden && setting.check && setting.check.enable) {
var isHidden = data.isHidden(setting, n);
if (isHidden && setting.check && setting.check.enable) {
if(typeof n._nocheck == "undefined") {
n._nocheck = !!n.nocheck
n.nocheck = true;
......@@ -65,7 +73,8 @@
}
},
initShowForExCheck: function(setting, n) {
if (!n.isHidden && setting.check && setting.check.enable) {
var isHidden = data.isHidden(setting, n);
if (!isHidden && setting.check && setting.check.enable) {
if(typeof n._nocheck != "undefined") {
n.nocheck = n._nocheck;
delete n._nocheck;
......@@ -113,10 +122,11 @@
}
},
makeDOMNodeMainBefore: function(html, setting, node) {
html.push("<li ", (node.isHidden ? "style='display:none;' " : ""), "id='", node.tId, "' class='", consts.className.LEVEL, node.level,"' tabindex='0' hidefocus='true' treenode>");
var isHidden = data.isHidden(setting, node);
html.push("<li ", (isHidden ? "style='display:none;' " : ""), "id='", node.tId, "' class='", consts.className.LEVEL, node.level,"' tabindex='0' hidefocus='true' treenode>");
},
showNode: function(setting, node, options) {
node.isHidden = false;
data.isHidden(setting, node, false);
data.initShowForExCheck(setting, node);
$$(node, setting).show();
},
......@@ -134,13 +144,13 @@
view.showNode(setting, n, options);
}
for (var tId in pList) {
var children = pList[tId][setting.data.key.children];
var children = data.nodeChildren(setting, pList[tId]);
view.setFirstNodeForShow(setting, children);
view.setLastNodeForShow(setting, children);
}
},
hideNode: function(setting, node, options) {
node.isHidden = true;
data.isHidden(setting, node, true);
node.isFirstNode = false;
node.isLastNode = false;
data.initHideForExCheck(setting, node);
......@@ -161,25 +171,27 @@
view.hideNode(setting, n, options);
}
for (var tId in pList) {
var children = pList[tId][setting.data.key.children];
var children = data.nodeChildren(setting, pList[tId]);
view.setFirstNodeForHide(setting, children);
view.setLastNodeForHide(setting, children);
}
},
setFirstNode: function(setting, parentNode) {
var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
if (childLength > 0 && !parentNode[childKey][0].isHidden) {
parentNode[childKey][0].isFirstNode = true;
} else if (childLength > 0) {
view.setFirstNodeForHide(setting, parentNode[childKey]);
var children = data.nodeChildren(setting, parentNode);
var isHidden = data.isHidden(setting, children[0], false);
if (children.length > 0 && !isHidden) {
children[0].isFirstNode = true;
} else if (children.length > 0) {
view.setFirstNodeForHide(setting, children);
}
},
setLastNode: function(setting, parentNode) {
var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
if (childLength > 0 && !parentNode[childKey][0].isHidden) {
parentNode[childKey][childLength - 1].isLastNode = true;
} else if (childLength > 0) {
view.setLastNodeForHide(setting, parentNode[childKey]);
var children = data.nodeChildren(setting, parentNode);
var isHidden = data.isHidden(setting, children[0]);
if (children.length > 0 && !isHidden) {
children[children.length - 1].isLastNode = true;
} else if (children.length > 0) {
view.setLastNodeForHide(setting, children);
}
},
setFirstNodeForHide: function(setting, nodes) {
......@@ -189,7 +201,8 @@
if (n.isFirstNode) {
break;
}
if (!n.isHidden && !n.isFirstNode) {
var isHidden = data.isHidden(setting, n);
if (!isHidden && !n.isFirstNode) {
n.isFirstNode = true;
view.setNodeLineIcos(setting, n);
break;
......@@ -203,10 +216,11 @@
var n,i,j, first, old;
for(i=0, j=nodes.length; i<j; i++) {
n = nodes[i];
if (!first && !n.isHidden && n.isFirstNode) {
var isHidden = data.isHidden(setting, n);
if (!first && !isHidden && n.isFirstNode) {
first = n;
break;
} else if (!first && !n.isHidden && !n.isFirstNode) {
} else if (!first && !isHidden && !n.isFirstNode) {
n.isFirstNode = true;
first = n;
view.setNodeLineIcos(setting, n);
......@@ -228,7 +242,8 @@
if (n.isLastNode) {
break;
}
if (!n.isHidden && !n.isLastNode) {
var isHidden = data.isHidden(setting, n);
if (!isHidden && !n.isLastNode) {
n.isLastNode = true;
view.setNodeLineIcos(setting, n);
break;
......@@ -242,10 +257,11 @@
var n,i,j, last, old;
for (i=nodes.length-1; i>=0; i--) {
n = nodes[i];
if (!last && !n.isHidden && n.isLastNode) {
var isHidden = data.isHidden(setting, n);
if (!last && !isHidden && n.isLastNode) {
last = n;
break;
} else if (!last && !n.isHidden && !n.isLastNode) {
} else if (!last && !isHidden && !n.isLastNode) {
n.isLastNode = true;
last = n;
view.setNodeLineIcos(setting, n);
......@@ -276,6 +292,22 @@
event = zt._z.event,
$$ = tools.$;
data.isHidden = function(setting, node, newIsHidden) {
if (!node) {
return false;
}
var key = setting.data.key.isHidden;
if (typeof newIsHidden !== 'undefined') {
if (typeof newIsHidden === "string") {
newIsHidden = tools.eqs(checked, "true");
}
newIsHidden = !!newIsHidden;
node[key] = newIsHidden;
}
return node[key];
};
data.exSetting(_setting);
data.addInitNode(_initNode);
data.addBeforeA(_beforeA);
data.addZTreeTools(_zTreeTools);
......@@ -302,7 +334,7 @@
var _makeChkFlag = data.makeChkFlag;
if (!!_makeChkFlag) {
data.makeChkFlag = function(setting, node) {
if (!!node && !!node.isHidden) {
if (!!node && !!data.isHidden(setting, node)) {
return;
}
_makeChkFlag.apply(data, arguments);
......@@ -314,7 +346,7 @@
data.getTreeCheckedNodes = function(setting, nodes, checked, results) {
if (!!nodes && nodes.length > 0) {
var p = nodes[0].getParentNode();
if (!!p && !!p.isHidden) {
if (!!p && !!data.isHidden(setting, p)) {
return [];
}
}
......@@ -327,7 +359,7 @@
data.getTreeChangeCheckedNodes = function(setting, nodes, results) {
if (!!nodes && nodes.length > 0) {
var p = nodes[0].getParentNode();
if (!!p && !!p.isHidden) {
if (!!p && !!data.isHidden(setting, p)) {
return [];
}
}
......@@ -338,7 +370,7 @@
var _expandCollapseSonNode = view.expandCollapseSonNode;
if (!!_expandCollapseSonNode) {
view.expandCollapseSonNode = function(setting, node, expandFlag, animateFlag, callback) {
if (!!node && !!node.isHidden) {
if (!!node && !!data.isHidden(setting, node)) {
return;
}
_expandCollapseSonNode.apply(view, arguments);
......@@ -348,7 +380,7 @@
var _setSonNodeCheckBox = view.setSonNodeCheckBox;
if (!!_setSonNodeCheckBox) {
view.setSonNodeCheckBox = function(setting, node, value, srcNode) {
if (!!node && !!node.isHidden) {
if (!!node && !!data.isHidden(setting, node)) {
return;
}
_setSonNodeCheckBox.apply(view, arguments);
......@@ -358,7 +390,7 @@
var _repairParentChkClassWithSelf = view.repairParentChkClassWithSelf;
if (!!_repairParentChkClassWithSelf) {
view.repairParentChkClassWithSelf = function(setting, node) {
if (!!node && !!node.isHidden) {
if (!!node && !!data.isHidden(setting, node)) {
return;
}
_repairParentChkClassWithSelf.apply(view, arguments);
......
/*
* JQuery zTree exHideNodes v3.5.31
* JQuery zTree exHideNodes v3.5.32
* http://treejs.cn/
*
* Copyright (c) 2010 Hunter.z
......@@ -8,15 +8,16 @@
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2017-12-28
* Date: 2018-01-06
*/
(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=
!1;f.initHideForExCheck(c,a);d.cancelPreSelectedNode(c,a);j(a,c).hide()},hideNodes: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((h.isFirstNode||h.isLastNode)&&!e[h.parentTId]){var i=h.getParentNode();e[h.parentTId]=i===null?f.getRoot(c):h.getParentNode()}d.hideNode(c,h,b)}for(var j in e)a=e[j][c.data.key.children],d.setFirstNodeForHide(c,a),d.setLastNodeForHide(c,a)}},setFirstNode:function(c,a){var b=c.data.key.children,e=a[b].length;e>0&&!a[b][0].isHidden?
a[b][0].isFirstNode=!0:e>0&&d.setFirstNodeForHide(c,a[b])},setLastNode:function(c,a){var b=c.data.key.children,e=a[b].length;e>0&&!a[b][0].isHidden?a[b][e-1].isLastNode=!0:e>0&&d.setLastNodeForHide(c,a[b])},setFirstNodeForHide:function(c,a){var b,e,g;for(e=0,g=a.length;e<g;e++){b=a[e];if(b.isFirstNode)break;if(!b.isHidden&&!b.isFirstNode){b.isFirstNode=!0;d.setNodeLineIcos(c,b);break}else b=null}return b},setFirstNodeForShow:function(c,a){var b,e,g,f,h;for(e=0,g=a.length;e<g;e++)if(b=a[e],!f&&!b.isHidden&&
b.isFirstNode){f=b;break}else if(!f&&!b.isHidden&&!b.isFirstNode)b.isFirstNode=!0,f=b,d.setNodeLineIcos(c,b);else if(f&&b.isFirstNode){b.isFirstNode=!1;h=b;d.setNodeLineIcos(c,b);break}return{"new":f,old:h}},setLastNodeForHide:function(c,a){var b,e;for(e=a.length-1;e>=0;e--){b=a[e];if(b.isLastNode)break;if(!b.isHidden&&!b.isLastNode){b.isLastNode=!0;d.setNodeLineIcos(c,b);break}else b=null}return b},setLastNodeForShow:function(c,a){var b,e,g,f;for(e=a.length-1;e>=0;e--)if(b=a[e],!g&&!b.isHidden&&
b.isLastNode){g=b;break}else if(!g&&!b.isHidden&&!b.isLastNode)b.isLastNode=!0,g=b,d.setNodeLineIcos(c,b);else if(g&&b.isLastNode){b.isLastNode=!1;f=b;d.setNodeLineIcos(c,b);break}return{"new":g,old:f}}},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;d.repairParentChkClassWithSelf&&d.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(d.setChkClass){var b=j(a,l.id.CHECK,c);d.setChkClass(c,b,a)}d.repairParentChkClassWithSelf&&d.repairParentChkClassWithSelf(c,a)}}}});var i=i.fn.zTree,m=i._z.tools,l=i.consts,d=i._z.view,f=i._z.data,j=m.$;f.addInitNode(function(c,a,b){if(typeof b.isHidden=="string")b.isHidden=m.eqs(b.isHidden,"true");b.isHidden=!!b.isHidden;f.initHideForExCheck(c,b)});f.addBeforeA(function(){});f.addZTreeTools(function(c,a){a.showNodes=
function(a,b){d.showNodes(c,a,b)};a.showNode=function(a,b){a&&d.showNodes(c,[a],b)};a.hideNodes=function(a,b){d.hideNodes(c,a,b)};a.hideNode=function(a,b){a&&d.hideNodes(c,[a],b)};var b=a.checkNode;if(b)a.checkNode=function(c,d,f,h){(!c||!c.isHidden)&&b.apply(a,arguments)}});var n=f.initNode;f.initNode=function(c,a,b,e,g,i,h){var j=(e?e:f.getRoot(c))[c.data.key.children];f.tmpHideFirstNode=d.setFirstNodeForHide(c,j);f.tmpHideLastNode=d.setLastNodeForHide(c,j);h&&(d.setNodeLineIcos(c,f.tmpHideFirstNode),
d.setNodeLineIcos(c,f.tmpHideLastNode));g=f.tmpHideFirstNode===b;i=f.tmpHideLastNode===b;n&&n.apply(f,arguments);h&&i&&d.clearOldLastNode(c,b,h)};var o=f.makeChkFlag;if(o)f.makeChkFlag=function(c,a){(!a||!a.isHidden)&&o.apply(f,arguments)};var p=f.getTreeCheckedNodes;if(p)f.getTreeCheckedNodes=function(c,a,b,e){if(a&&a.length>0){var d=a[0].getParentNode();if(d&&d.isHidden)return[]}return p.apply(f,arguments)};var q=f.getTreeChangeCheckedNodes;if(q)f.getTreeChangeCheckedNodes=function(c,a,b){if(a&&
a.length>0){var d=a[0].getParentNode();if(d&&d.isHidden)return[]}return q.apply(f,arguments)};var r=d.expandCollapseSonNode;if(r)d.expandCollapseSonNode=function(c,a,b,e,f){(!a||!a.isHidden)&&r.apply(d,arguments)};var s=d.setSonNodeCheckBox;if(s)d.setSonNodeCheckBox=function(c,a,b,e){(!a||!a.isHidden)&&s.apply(d,arguments)};var t=d.repairParentChkClassWithSelf;if(t)d.repairParentChkClassWithSelf=function(c,a){(!a||!a.isHidden)&&t.apply(d,arguments)}})(jQuery);
(function(j){j.extend(!0,j.fn.zTree._z,{view:{clearOldFirstNode:function(c,a){for(var b=a.getNextNode();b;){if(b.isFirstNode){b.isFirstNode=!1;e.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&&e.setNodeLineIcos(c,a);break}if(a.isFirstNode)break;a=a.getPreNode()}},makeDOMNodeMainBefore:function(c,a,b){a=d.isHidden(a,b);c.push("<li ",a?"style='display:none;' ":"","id='",b.tId,"' class='",
l.className.LEVEL,b.level,"' tabindex='0' hidefocus='true' treenode>")},showNode:function(c,a){d.isHidden(c,a,!1);d.initShowForExCheck(c,a);k(a,c).show()},showNodes:function(c,a,b){if(a&&a.length!=0){var f={},g,i;for(g=0,i=a.length;g<i;g++){var h=a[g];if(!f[h.parentTId]){var u=h.getParentNode();f[h.parentTId]=u===null?d.getRoot(c):h.getParentNode()}e.showNode(c,h,b)}for(var j in f)a=d.nodeChildren(c,f[j]),e.setFirstNodeForShow(c,a),e.setLastNodeForShow(c,a)}},hideNode:function(c,a){d.isHidden(c,a,
!0);a.isFirstNode=!1;a.isLastNode=!1;d.initHideForExCheck(c,a);e.cancelPreSelectedNode(c,a);k(a,c).hide()},hideNodes:function(c,a,b){if(a&&a.length!=0){var f={},g,i;for(g=0,i=a.length;g<i;g++){var h=a[g];if((h.isFirstNode||h.isLastNode)&&!f[h.parentTId]){var j=h.getParentNode();f[h.parentTId]=j===null?d.getRoot(c):h.getParentNode()}e.hideNode(c,h,b)}for(var k in f)a=d.nodeChildren(c,f[k]),e.setFirstNodeForHide(c,a),e.setLastNodeForHide(c,a)}},setFirstNode:function(c,a){var b=d.nodeChildren(c,a),f=
d.isHidden(c,b[0],!1);b.length>0&&!f?b[0].isFirstNode=!0:b.length>0&&e.setFirstNodeForHide(c,b)},setLastNode:function(c,a){var b=d.nodeChildren(c,a),f=d.isHidden(c,b[0]);b.length>0&&!f?b[b.length-1].isLastNode=!0:b.length>0&&e.setLastNodeForHide(c,b)},setFirstNodeForHide:function(c,a){var b,f,g;for(f=0,g=a.length;f<g;f++){b=a[f];if(b.isFirstNode)break;if(!d.isHidden(c,b)&&!b.isFirstNode){b.isFirstNode=!0;e.setNodeLineIcos(c,b);break}else b=null}return b},setFirstNodeForShow:function(c,a){var b,f,
g,i,h;for(f=0,g=a.length;f<g;f++){b=a[f];var j=d.isHidden(c,b);if(!i&&!j&&b.isFirstNode){i=b;break}else if(!i&&!j&&!b.isFirstNode)b.isFirstNode=!0,i=b,e.setNodeLineIcos(c,b);else if(i&&b.isFirstNode){b.isFirstNode=!1;h=b;e.setNodeLineIcos(c,b);break}}return{"new":i,old:h}},setLastNodeForHide:function(c,a){var b,f;for(f=a.length-1;f>=0;f--){b=a[f];if(b.isLastNode)break;if(!d.isHidden(c,b)&&!b.isLastNode){b.isLastNode=!0;e.setNodeLineIcos(c,b);break}else b=null}return b},setLastNodeForShow:function(c,
a){var b,f,g,i;for(f=a.length-1;f>=0;f--){b=a[f];var h=d.isHidden(c,b);if(!g&&!h&&b.isLastNode){g=b;break}else if(!g&&!h&&!b.isLastNode)b.isLastNode=!0,g=b,e.setNodeLineIcos(c,b);else if(g&&b.isLastNode){b.isLastNode=!1;i=b;e.setNodeLineIcos(c,b);break}}return{"new":g,old:i}}},data:{initHideForExCheck:function(c,a){if(d.isHidden(c,a)&&c.check&&c.check.enable){if(typeof a._nocheck=="undefined")a._nocheck=!!a.nocheck,a.nocheck=!0;a.check_Child_State=-1;e.repairParentChkClassWithSelf&&e.repairParentChkClassWithSelf(c,
a)}},initShowForExCheck:function(c,a){if(!d.isHidden(c,a)&&c.check&&c.check.enable){if(typeof a._nocheck!="undefined")a.nocheck=a._nocheck,delete a._nocheck;if(e.setChkClass){var b=k(a,l.id.CHECK,c);e.setChkClass(c,b,a)}e.repairParentChkClassWithSelf&&e.repairParentChkClassWithSelf(c,a)}}}});var j=j.fn.zTree,m=j._z.tools,l=j.consts,e=j._z.view,d=j._z.data,k=m.$;d.isHidden=function(c,a,b){if(!a)return!1;c=c.data.key.isHidden;typeof b!=="undefined"&&(typeof b==="string"&&(b=m.eqs(checked,"true")),a[c]=
!!b);return a[c]};d.exSetting({data:{key:{isHidden:"isHidden"}}});d.addInitNode(function(c,a,b){a=d.isHidden(c,b);d.isHidden(c,b,a);d.initHideForExCheck(c,b)});d.addBeforeA(function(){});d.addZTreeTools(function(c,a){a.showNodes=function(a,b){e.showNodes(c,a,b)};a.showNode=function(a,b){a&&e.showNodes(c,[a],b)};a.hideNodes=function(a,b){e.hideNodes(c,a,b)};a.hideNode=function(a,b){a&&e.hideNodes(c,[a],b)};var b=a.checkNode;if(b)a.checkNode=function(f,e,i,h){(!f||!d.isHidden(c,f))&&b.apply(a,arguments)}});
var n=d.initNode;d.initNode=function(c,a,b,f,g,i,h){var j=(f?f:d.getRoot(c))[c.data.key.children];d.tmpHideFirstNode=e.setFirstNodeForHide(c,j);d.tmpHideLastNode=e.setLastNodeForHide(c,j);h&&(e.setNodeLineIcos(c,d.tmpHideFirstNode),e.setNodeLineIcos(c,d.tmpHideLastNode));g=d.tmpHideFirstNode===b;i=d.tmpHideLastNode===b;n&&n.apply(d,arguments);h&&i&&e.clearOldLastNode(c,b,h)};var o=d.makeChkFlag;if(o)d.makeChkFlag=function(c,a){(!a||!d.isHidden(c,a))&&o.apply(d,arguments)};var p=d.getTreeCheckedNodes;
if(p)d.getTreeCheckedNodes=function(c,a,b,f){if(a&&a.length>0){var e=a[0].getParentNode();if(e&&d.isHidden(c,e))return[]}return p.apply(d,arguments)};var q=d.getTreeChangeCheckedNodes;if(q)d.getTreeChangeCheckedNodes=function(c,a,b){if(a&&a.length>0){var e=a[0].getParentNode();if(e&&d.isHidden(c,e))return[]}return q.apply(d,arguments)};var r=e.expandCollapseSonNode;if(r)e.expandCollapseSonNode=function(c,a,b,f,g){(!a||!d.isHidden(c,a))&&r.apply(e,arguments)};var s=e.setSonNodeCheckBox;if(s)e.setSonNodeCheckBox=
function(c,a,b,f){(!a||!d.isHidden(c,a))&&s.apply(e,arguments)};var t=e.repairParentChkClassWithSelf;if(t)e.repairParentChkClassWithSelf=function(c,a){(!a||!d.isHidden(c,a))&&t.apply(e,arguments)}})(jQuery);
......@@ -13,6 +13,10 @@
</font>
*2018.01.06* v3.5.32
* [修改] setting.async.autoParam / otherParam 支持 function
* [修改] isParent / isHidden 允许自定义属性名称 setting.data.key.isParent / isHidden
*2017.12.28* v3.5.31
* [修改] 初始化节点数据的规则,支持 treeNode { name: "Node2", children: []}, 情况下自动设置为 isParent = true
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册