|
|
@ -1,3 +1,4 @@ |
|
|
|
|
|
|
|
/* eslint-disable */ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* JQuery zTree excheck v3.5.18 |
|
|
|
* JQuery zTree excheck v3.5.18 |
|
|
|
* http://zTree.me/
|
|
|
|
* http://zTree.me/
|
|
|
@ -10,7 +11,7 @@ |
|
|
|
* email: hunter.z@263.net |
|
|
|
* email: hunter.z@263.net |
|
|
|
* Date: 2015-06-18 |
|
|
|
* Date: 2015-06-18 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
(function($){ |
|
|
|
(function ($) { |
|
|
|
//default consts of excheck
|
|
|
|
//default consts of excheck
|
|
|
|
var _consts = { |
|
|
|
var _consts = { |
|
|
|
event: { |
|
|
|
event: { |
|
|
@ -55,8 +56,8 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
callback: { |
|
|
|
callback: { |
|
|
|
beforeCheck:null, |
|
|
|
beforeCheck: null, |
|
|
|
onCheck:null |
|
|
|
onCheck: null |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
//default root of excheck
|
|
|
|
//default root of excheck
|
|
|
@ -65,9 +66,10 @@ |
|
|
|
r.radioCheckedList = []; |
|
|
|
r.radioCheckedList = []; |
|
|
|
}, |
|
|
|
}, |
|
|
|
//default cache of excheck
|
|
|
|
//default cache of excheck
|
|
|
|
_initCache = function(treeId) {}, |
|
|
|
_initCache = function (treeId) { |
|
|
|
|
|
|
|
}, |
|
|
|
//default bind event of excheck
|
|
|
|
//default bind event of excheck
|
|
|
|
_bindEvent = function(setting) { |
|
|
|
_bindEvent = function (setting) { |
|
|
|
var o = setting.treeObj, |
|
|
|
var o = setting.treeObj, |
|
|
|
c = consts.event; |
|
|
|
c = consts.event; |
|
|
|
o.bind(c.CHECK, function (event, srcEvent, treeId, node) { |
|
|
|
o.bind(c.CHECK, function (event, srcEvent, treeId, node) { |
|
|
@ -75,13 +77,13 @@ |
|
|
|
tools.apply(setting.callback.onCheck, [event, treeId, node]); |
|
|
|
tools.apply(setting.callback.onCheck, [event, treeId, node]); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
_unbindEvent = function(setting) { |
|
|
|
_unbindEvent = function (setting) { |
|
|
|
var o = setting.treeObj, |
|
|
|
var o = setting.treeObj, |
|
|
|
c = consts.event; |
|
|
|
c = consts.event; |
|
|
|
o.unbind(c.CHECK); |
|
|
|
o.unbind(c.CHECK); |
|
|
|
}, |
|
|
|
}, |
|
|
|
//default event proxy of excheck
|
|
|
|
//default event proxy of excheck
|
|
|
|
_eventProxy = function(e) { |
|
|
|
_eventProxy = function (e) { |
|
|
|
var target = e.target, |
|
|
|
var target = e.target, |
|
|
|
setting = data.getSetting(e.data.treeId), |
|
|
|
setting = data.getSetting(e.data.treeId), |
|
|
|
tId = "", node = null, |
|
|
|
tId = "", node = null, |
|
|
@ -89,22 +91,22 @@ |
|
|
|
nodeEventCallback = null, treeEventCallback = null; |
|
|
|
nodeEventCallback = null, treeEventCallback = null; |
|
|
|
|
|
|
|
|
|
|
|
if (tools.eqs(e.type, "mouseover")) { |
|
|
|
if (tools.eqs(e.type, "mouseover")) { |
|
|
|
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { |
|
|
|
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { |
|
|
|
tId = tools.getNodeMainDom(target).id; |
|
|
|
tId = tools.getNodeMainDom(target).id; |
|
|
|
nodeEventType = "mouseoverCheck"; |
|
|
|
nodeEventType = "mouseoverCheck"; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (tools.eqs(e.type, "mouseout")) { |
|
|
|
} else if (tools.eqs(e.type, "mouseout")) { |
|
|
|
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { |
|
|
|
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { |
|
|
|
tId = tools.getNodeMainDom(target).id; |
|
|
|
tId = tools.getNodeMainDom(target).id; |
|
|
|
nodeEventType = "mouseoutCheck"; |
|
|
|
nodeEventType = "mouseoutCheck"; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (tools.eqs(e.type, "click")) { |
|
|
|
} else if (tools.eqs(e.type, "click")) { |
|
|
|
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) { |
|
|
|
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode" + consts.id.CHECK) !== null) { |
|
|
|
tId = tools.getNodeMainDom(target).id; |
|
|
|
tId = tools.getNodeMainDom(target).id; |
|
|
|
nodeEventType = "checkNode"; |
|
|
|
nodeEventType = "checkNode"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (tId.length>0) { |
|
|
|
if (tId.length > 0) { |
|
|
|
node = data.getNodeCache(setting, tId); |
|
|
|
node = data.getNodeCache(setting, tId); |
|
|
|
switch (nodeEventType) { |
|
|
|
switch (nodeEventType) { |
|
|
|
case "checkNode" : |
|
|
|
case "checkNode" : |
|
|
@ -126,10 +128,10 @@ |
|
|
|
treeEventType: treeEventType, |
|
|
|
treeEventType: treeEventType, |
|
|
|
treeEventCallback: treeEventCallback |
|
|
|
treeEventCallback: treeEventCallback |
|
|
|
}; |
|
|
|
}; |
|
|
|
return proxyResult |
|
|
|
return proxyResult; |
|
|
|
}, |
|
|
|
}, |
|
|
|
//default init node of excheck
|
|
|
|
//default init node of excheck
|
|
|
|
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { |
|
|
|
_initNode = function (setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) { |
|
|
|
if (!n) return; |
|
|
|
if (!n) return; |
|
|
|
var checkedKey = setting.data.key.checked; |
|
|
|
var checkedKey = setting.data.key.checked; |
|
|
|
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true"); |
|
|
|
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true"); |
|
|
@ -143,24 +145,26 @@ |
|
|
|
n.halfCheck = !!n.halfCheck; |
|
|
|
n.halfCheck = !!n.halfCheck; |
|
|
|
n.check_Child_State = -1; |
|
|
|
n.check_Child_State = -1; |
|
|
|
n.check_Focus = false; |
|
|
|
n.check_Focus = false; |
|
|
|
n.getCheckStatus = function() {return data.getCheckStatus(setting, n);}; |
|
|
|
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 && n[checkedKey]) { |
|
|
|
var r = data.getRoot(setting); |
|
|
|
var r = data.getRoot(setting); |
|
|
|
r.radioCheckedList.push(n); |
|
|
|
r.radioCheckedList.push(n); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
//add dom for check
|
|
|
|
//add dom for check
|
|
|
|
_beforeA = function(setting, node, html) { |
|
|
|
_beforeA = function (setting, node, html) { |
|
|
|
var checkedKey = setting.data.key.checked; |
|
|
|
var checkedKey = setting.data.key.checked; |
|
|
|
if (setting.check.enable) { |
|
|
|
if (setting.check.enable) { |
|
|
|
data.makeChkFlag(setting, node); |
|
|
|
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>"); |
|
|
|
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>"); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
//update zTreeObj, add method of check
|
|
|
|
//update zTreeObj, add method of check
|
|
|
|
_zTreeTools = function(setting, zTreeTools) { |
|
|
|
_zTreeTools = function (setting, zTreeTools) { |
|
|
|
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) { |
|
|
|
zTreeTools.checkNode = function (node, checked, checkTypeFlag, callbackFlag) { |
|
|
|
var checkedKey = this.setting.data.key.checked; |
|
|
|
var checkedKey = this.setting.data.key.checked; |
|
|
|
if (node.chkDisabled === true) return; |
|
|
|
if (node.chkDisabled === true) return; |
|
|
|
if (checked !== true && checked !== false) { |
|
|
|
if (checked !== true && checked !== false) { |
|
|
@ -183,33 +187,33 @@ |
|
|
|
this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]); |
|
|
|
this.setting.treeObj.trigger(consts.event.CHECK, [null, this.setting.treeId, node]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
zTreeTools.checkAllNodes = function(checked) { |
|
|
|
zTreeTools.checkAllNodes = function (checked) { |
|
|
|
view.repairAllChk(this.setting, !!checked); |
|
|
|
view.repairAllChk(this.setting, !!checked); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
zTreeTools.getCheckedNodes = function(checked) { |
|
|
|
zTreeTools.getCheckedNodes = function (checked) { |
|
|
|
var childKey = this.setting.data.key.children; |
|
|
|
var childKey = this.setting.data.key.children; |
|
|
|
checked = (checked !== false); |
|
|
|
checked = (checked !== false); |
|
|
|
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked); |
|
|
|
return data.getTreeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey], checked); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
zTreeTools.getChangeCheckedNodes = function() { |
|
|
|
zTreeTools.getChangeCheckedNodes = function () { |
|
|
|
var childKey = this.setting.data.key.children; |
|
|
|
var childKey = this.setting.data.key.children; |
|
|
|
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]); |
|
|
|
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(this.setting)[childKey]); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) { |
|
|
|
zTreeTools.setChkDisabled = function (node, disabled, inheritParent, inheritChildren) { |
|
|
|
disabled = !!disabled; |
|
|
|
disabled = !!disabled; |
|
|
|
inheritParent = !!inheritParent; |
|
|
|
inheritParent = !!inheritParent; |
|
|
|
inheritChildren = !!inheritChildren; |
|
|
|
inheritChildren = !!inheritChildren; |
|
|
|
view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); |
|
|
|
view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren); |
|
|
|
view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); |
|
|
|
view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var _updateNode = zTreeTools.updateNode; |
|
|
|
var _updateNode = zTreeTools.updateNode; |
|
|
|
zTreeTools.updateNode = function(node, checkTypeFlag) { |
|
|
|
zTreeTools.updateNode = function (node, checkTypeFlag) { |
|
|
|
if (_updateNode) _updateNode.apply(zTreeTools, arguments); |
|
|
|
if (_updateNode) _updateNode.apply(zTreeTools, arguments); |
|
|
|
if (!node || !this.setting.check.enable) return; |
|
|
|
if (!node || !this.setting.check.enable) return; |
|
|
|
var nObj = $$(node, this.setting); |
|
|
|
var nObj = $$(node, this.setting); |
|
|
@ -219,21 +223,22 @@ |
|
|
|
view.setChkClass(this.setting, checkObj, node); |
|
|
|
view.setChkClass(this.setting, checkObj, node); |
|
|
|
view.repairParentChkClassWithSelf(this.setting, node); |
|
|
|
view.repairParentChkClassWithSelf(this.setting, node); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
//method of operate data
|
|
|
|
//method of operate data
|
|
|
|
_data = { |
|
|
|
_data = { |
|
|
|
getRadioCheckedList: function(setting) { |
|
|
|
getRadioCheckedList: function (setting) { |
|
|
|
var checkedList = data.getRoot(setting).radioCheckedList; |
|
|
|
var checkedList = data.getRoot(setting).radioCheckedList; |
|
|
|
for (var i=0, j=checkedList.length; i<j; i++) { |
|
|
|
for (var i = 0, j = checkedList.length; i < j; i++) { |
|
|
|
if(!data.getNodeCache(setting, checkedList[i].tId)) { |
|
|
|
if (!data.getNodeCache(setting, checkedList[i].tId)) { |
|
|
|
checkedList.splice(i, 1); |
|
|
|
checkedList.splice(i, 1); |
|
|
|
i--; j--; |
|
|
|
i--; |
|
|
|
|
|
|
|
j--; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return checkedList; |
|
|
|
return checkedList; |
|
|
|
}, |
|
|
|
}, |
|
|
|
getCheckStatus: function(setting, node) { |
|
|
|
getCheckStatus: function (setting, node) { |
|
|
|
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null; |
|
|
|
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null; |
|
|
|
var checkedKey = setting.data.key.checked, |
|
|
|
var checkedKey = setting.data.key.checked, |
|
|
|
r = { |
|
|
|
r = { |
|
|
@ -242,7 +247,7 @@ |
|
|
|
}; |
|
|
|
}; |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
}, |
|
|
|
}, |
|
|
|
getTreeCheckedNodes: function(setting, nodes, checked, results) { |
|
|
|
getTreeCheckedNodes: function (setting, nodes, checked, results) { |
|
|
|
if (!nodes) return []; |
|
|
|
if (!nodes) return []; |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
@ -251,18 +256,18 @@ |
|
|
|
for (var i = 0, l = nodes.length; i < l; i++) { |
|
|
|
for (var i = 0, l = nodes.length; i < l; i++) { |
|
|
|
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { |
|
|
|
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) { |
|
|
|
results.push(nodes[i]); |
|
|
|
results.push(nodes[i]); |
|
|
|
if(onlyOne) { |
|
|
|
if (onlyOne) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results); |
|
|
|
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results); |
|
|
|
if(onlyOne && results.length > 0) { |
|
|
|
if (onlyOne && results.length > 0) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return results; |
|
|
|
return results; |
|
|
|
}, |
|
|
|
}, |
|
|
|
getTreeChangeCheckedNodes: function(setting, nodes, results) { |
|
|
|
getTreeChangeCheckedNodes: function (setting, nodes, results) { |
|
|
|
if (!nodes) return []; |
|
|
|
if (!nodes) return []; |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
checkedKey = setting.data.key.checked; |
|
|
|
checkedKey = setting.data.key.checked; |
|
|
@ -275,7 +280,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
return results; |
|
|
|
return results; |
|
|
|
}, |
|
|
|
}, |
|
|
|
makeChkFlag: function(setting, node) { |
|
|
|
makeChkFlag: function (setting, node) { |
|
|
|
if (!node) return; |
|
|
|
if (!node) return; |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
@ -292,11 +297,12 @@ |
|
|
|
} else if (cNode[checkedKey]) { |
|
|
|
} else if (cNode[checkedKey]) { |
|
|
|
tmp = 2; |
|
|
|
tmp = 2; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tmp = cNode.check_Child_State > 0 ? 2:0; |
|
|
|
tmp = cNode.check_Child_State > 0 ? 2 : 0; |
|
|
|
} |
|
|
|
} |
|
|
|
if (tmp == 2) { |
|
|
|
if (tmp == 2) { |
|
|
|
chkFlag = 2; break; |
|
|
|
chkFlag = 2; |
|
|
|
} else if (tmp == 0){ |
|
|
|
break; |
|
|
|
|
|
|
|
} else if (tmp == 0) { |
|
|
|
chkFlag = 0; |
|
|
|
chkFlag = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (setting.check.chkStyle == consts.checkbox.STYLE) { |
|
|
|
} else if (setting.check.chkStyle == consts.checkbox.STYLE) { |
|
|
@ -304,17 +310,20 @@ |
|
|
|
tmp = cNode.check_Child_State; |
|
|
|
tmp = cNode.check_Child_State; |
|
|
|
} else if (cNode.halfCheck === true) { |
|
|
|
} else if (cNode.halfCheck === true) { |
|
|
|
tmp = 1; |
|
|
|
tmp = 1; |
|
|
|
} else if (cNode[checkedKey] ) { |
|
|
|
} else if (cNode[checkedKey]) { |
|
|
|
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; |
|
|
|
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tmp = (cNode.check_Child_State > 0) ? 1 : 0; |
|
|
|
tmp = (cNode.check_Child_State > 0) ? 1 : 0; |
|
|
|
} |
|
|
|
} |
|
|
|
if (tmp === 1) { |
|
|
|
if (tmp === 1) { |
|
|
|
chkFlag = 1; break; |
|
|
|
chkFlag = 1; |
|
|
|
|
|
|
|
break; |
|
|
|
} else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { |
|
|
|
} else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) { |
|
|
|
chkFlag = 1; break; |
|
|
|
chkFlag = 1; |
|
|
|
|
|
|
|
break; |
|
|
|
} else if (chkFlag === 2 && tmp > -1 && tmp < 2) { |
|
|
|
} else if (chkFlag === 2 && tmp > -1 && tmp < 2) { |
|
|
|
chkFlag = 1; break; |
|
|
|
chkFlag = 1; |
|
|
|
|
|
|
|
break; |
|
|
|
} else if (tmp > -1) { |
|
|
|
} else if (tmp > -1) { |
|
|
|
chkFlag = tmp; |
|
|
|
chkFlag = tmp; |
|
|
|
} |
|
|
|
} |
|
|
@ -325,9 +334,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
//method of event proxy
|
|
|
|
//method of event proxy
|
|
|
|
_event = { |
|
|
|
_event = {}, |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
//method of event handler
|
|
|
|
//method of event handler
|
|
|
|
_handler = { |
|
|
|
_handler = { |
|
|
|
onCheckNode: function (event, node) { |
|
|
|
onCheckNode: function (event, node) { |
|
|
@ -343,7 +350,7 @@ |
|
|
|
setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); |
|
|
|
setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
}, |
|
|
|
}, |
|
|
|
onMouseoverCheck: function(event, node) { |
|
|
|
onMouseoverCheck: function (event, node) { |
|
|
|
if (node.chkDisabled === true) return false; |
|
|
|
if (node.chkDisabled === true) return false; |
|
|
|
var setting = data.getSetting(event.data.treeId), |
|
|
|
var setting = data.getSetting(event.data.treeId), |
|
|
|
checkObj = $$(node, consts.id.CHECK, setting); |
|
|
|
checkObj = $$(node, consts.id.CHECK, setting); |
|
|
@ -351,7 +358,7 @@ |
|
|
|
view.setChkClass(setting, checkObj, node); |
|
|
|
view.setChkClass(setting, checkObj, node); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
}, |
|
|
|
}, |
|
|
|
onMouseoutCheck: function(event, node) { |
|
|
|
onMouseoutCheck: function (event, node) { |
|
|
|
if (node.chkDisabled === true) return false; |
|
|
|
if (node.chkDisabled === true) return false; |
|
|
|
var setting = data.getSetting(event.data.treeId), |
|
|
|
var setting = data.getSetting(event.data.treeId), |
|
|
|
checkObj = $$(node, consts.id.CHECK, setting); |
|
|
|
checkObj = $$(node, consts.id.CHECK, setting); |
|
|
@ -361,12 +368,10 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
//method of tools for zTree
|
|
|
|
//method of tools for zTree
|
|
|
|
_tools = { |
|
|
|
_tools = {}, |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
//method of operate ztree dom
|
|
|
|
//method of operate ztree dom
|
|
|
|
_view = { |
|
|
|
_view = { |
|
|
|
checkNodeRelation: function(setting, node) { |
|
|
|
checkNodeRelation: function (setting, node) { |
|
|
|
var pNode, i, l, |
|
|
|
var pNode, i, l, |
|
|
|
childKey = setting.data.key.children, |
|
|
|
childKey = setting.data.key.children, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
@ -375,7 +380,7 @@ |
|
|
|
var checkedList = data.getRadioCheckedList(setting); |
|
|
|
var checkedList = data.getRadioCheckedList(setting); |
|
|
|
if (node[checkedKey]) { |
|
|
|
if (node[checkedKey]) { |
|
|
|
if (setting.check.radioType == r.TYPE_ALL) { |
|
|
|
if (setting.check.radioType == r.TYPE_ALL) { |
|
|
|
for (i = checkedList.length-1; i >= 0; i--) { |
|
|
|
for (i = checkedList.length - 1; i >= 0; i--) { |
|
|
|
pNode = checkedList[i]; |
|
|
|
pNode = checkedList[i]; |
|
|
|
if (pNode[checkedKey] && pNode != node) { |
|
|
|
if (pNode[checkedKey] && pNode != node) { |
|
|
|
pNode[checkedKey] = false; |
|
|
|
pNode[checkedKey] = false; |
|
|
@ -408,10 +413,10 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { |
|
|
|
if (node[checkedKey] && (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.Y.indexOf("s") > -1)) { |
|
|
|
view.setSonNodeCheckBox(setting, node, true); |
|
|
|
view.setSonNodeCheckBox(setting, node, true); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) { |
|
|
|
if (!node[checkedKey] && (!node[childKey] || node[childKey].length == 0 || setting.check.chkboxType.N.indexOf("s") > -1)) { |
|
|
|
view.setSonNodeCheckBox(setting, node, false); |
|
|
|
view.setSonNodeCheckBox(setting, node, false); |
|
|
|
} |
|
|
|
} |
|
|
|
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { |
|
|
|
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) { |
|
|
@ -422,7 +427,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
makeChkClass: function(setting, node) { |
|
|
|
makeChkClass: function (setting, node) { |
|
|
|
var checkedKey = setting.data.key.checked, |
|
|
|
var checkedKey = setting.data.key.checked, |
|
|
|
c = consts.checkbox, r = consts.radio, |
|
|
|
c = consts.checkbox, r = consts.radio, |
|
|
|
checkboxType = setting.check.chkboxType; |
|
|
|
checkboxType = setting.check.chkboxType; |
|
|
@ -433,9 +438,9 @@ |
|
|
|
} else if (node.halfCheck) { |
|
|
|
} else if (node.halfCheck) { |
|
|
|
fullStyle = c.PART; |
|
|
|
fullStyle = c.PART; |
|
|
|
} else if (setting.check.chkStyle == r.STYLE) { |
|
|
|
} else if (setting.check.chkStyle == r.STYLE) { |
|
|
|
fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART; |
|
|
|
fullStyle = (node.check_Child_State < 1) ? c.FULL : c.PART; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) || notEffectByOtherNode ? c.FULL:c.PART) : ((node.check_Child_State < 1 || notEffectByOtherNode)? c.FULL:c.PART); |
|
|
|
fullStyle = node[checkedKey] ? ((node.check_Child_State === 2 || node.check_Child_State === -1) || notEffectByOtherNode ? c.FULL : c.PART) : ((node.check_Child_State < 1 || notEffectByOtherNode) ? c.FULL : c.PART); |
|
|
|
} |
|
|
|
} |
|
|
|
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; |
|
|
|
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle; |
|
|
|
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; |
|
|
|
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName; |
|
|
@ -457,12 +462,12 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
return chClass + (node.disabled ? " disabled" : ""); |
|
|
|
return chClass + (node.disabled ? " disabled" : ""); |
|
|
|
}, |
|
|
|
}, |
|
|
|
repairAllChk: function(setting, checked) { |
|
|
|
repairAllChk: function (setting, checked) { |
|
|
|
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { |
|
|
|
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) { |
|
|
|
var checkedKey = setting.data.key.checked, |
|
|
|
var checkedKey = setting.data.key.checked, |
|
|
|
childKey = setting.data.key.children, |
|
|
|
childKey = setting.data.key.children, |
|
|
|
root = data.getRoot(setting); |
|
|
|
root = data.getRoot(setting); |
|
|
|
for (var i = 0, l = root[childKey].length; i<l ; i++) { |
|
|
|
for (var i = 0, l = root[childKey].length; i < l; i++) { |
|
|
|
var node = root[childKey][i]; |
|
|
|
var node = root[childKey][i]; |
|
|
|
if (node.nocheck !== true && node.chkDisabled !== true) { |
|
|
|
if (node.nocheck !== true && node.chkDisabled !== true) { |
|
|
|
node[checkedKey] = checked; |
|
|
|
node[checkedKey] = checked; |
|
|
@ -471,7 +476,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
repairChkClass: function(setting, node) { |
|
|
|
repairChkClass: function (setting, node) { |
|
|
|
if (!node) return; |
|
|
|
if (!node) return; |
|
|
|
data.makeChkFlag(setting, node); |
|
|
|
data.makeChkFlag(setting, node); |
|
|
|
if (node.nocheck !== true) { |
|
|
|
if (node.nocheck !== true) { |
|
|
@ -479,13 +484,13 @@ |
|
|
|
view.setChkClass(setting, checkObj, node); |
|
|
|
view.setChkClass(setting, checkObj, node); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
repairParentChkClass: function(setting, node) { |
|
|
|
repairParentChkClass: function (setting, node) { |
|
|
|
if (!node || !node.parentTId) return; |
|
|
|
if (!node || !node.parentTId) return; |
|
|
|
var pNode = node.getParentNode(); |
|
|
|
var pNode = node.getParentNode(); |
|
|
|
view.repairChkClass(setting, pNode); |
|
|
|
view.repairChkClass(setting, pNode); |
|
|
|
view.repairParentChkClass(setting, pNode); |
|
|
|
view.repairParentChkClass(setting, pNode); |
|
|
|
}, |
|
|
|
}, |
|
|
|
repairParentChkClassWithSelf: function(setting, node) { |
|
|
|
repairParentChkClassWithSelf: function (setting, node) { |
|
|
|
if (!node) return; |
|
|
|
if (!node) return; |
|
|
|
var childKey = setting.data.key.children; |
|
|
|
var childKey = setting.data.key.children; |
|
|
|
if (node[childKey] && node[childKey].length > 0) { |
|
|
|
if (node[childKey] && node[childKey].length > 0) { |
|
|
@ -494,7 +499,7 @@ |
|
|
|
view.repairParentChkClass(setting, node); |
|
|
|
view.repairParentChkClass(setting, node); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
repairSonChkDisabled: function(setting, node, chkDisabled, inherit) { |
|
|
|
repairSonChkDisabled: function (setting, node, chkDisabled, inherit) { |
|
|
|
if (!node) return; |
|
|
|
if (!node) return; |
|
|
|
var childKey = setting.data.key.children; |
|
|
|
var childKey = setting.data.key.children; |
|
|
|
if (node.chkDisabled != chkDisabled) { |
|
|
|
if (node.chkDisabled != chkDisabled) { |
|
|
@ -508,7 +513,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
repairParentChkDisabled: function(setting, node, chkDisabled, inherit) { |
|
|
|
repairParentChkDisabled: function (setting, node, chkDisabled, inherit) { |
|
|
|
if (!node) return; |
|
|
|
if (!node) return; |
|
|
|
if (node.chkDisabled != chkDisabled && inherit) { |
|
|
|
if (node.chkDisabled != chkDisabled && inherit) { |
|
|
|
node.chkDisabled = chkDisabled; |
|
|
|
node.chkDisabled = chkDisabled; |
|
|
@ -516,7 +521,7 @@ |
|
|
|
view.repairChkClass(setting, node); |
|
|
|
view.repairChkClass(setting, node); |
|
|
|
view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); |
|
|
|
view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setChkClass: function(setting, obj, node) { |
|
|
|
setChkClass: function (setting, obj, node) { |
|
|
|
if (!obj) return; |
|
|
|
if (!obj) return; |
|
|
|
if (node.nocheck === true) { |
|
|
|
if (node.nocheck === true) { |
|
|
|
obj.hide(); |
|
|
|
obj.hide(); |
|
|
@ -525,7 +530,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
obj.attr('class', view.makeChkClass(setting, node)); |
|
|
|
obj.attr('class', view.makeChkClass(setting, node)); |
|
|
|
}, |
|
|
|
}, |
|
|
|
setParentNodeCheckBox: function(setting, node, value, srcNode) { |
|
|
|
setParentNodeCheckBox: function (setting, node, value, srcNode) { |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
|
checkObj = $$(node, consts.id.CHECK, setting); |
|
|
|
checkObj = $$(node, consts.id.CHECK, setting); |
|
|
@ -555,7 +560,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
setSonNodeCheckBox: function(setting, node, value, srcNode) { |
|
|
|
setSonNodeCheckBox: function (setting, node, value, srcNode) { |
|
|
|
if (!node) return; |
|
|
|
if (!node) return; |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
var childKey = setting.data.key.children, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
|
checkedKey = setting.data.key.checked, |
|
|
@ -618,22 +623,22 @@ |
|
|
|
data.addZTreeTools(_zTreeTools); |
|
|
|
data.addZTreeTools(_zTreeTools); |
|
|
|
|
|
|
|
|
|
|
|
var _createNodes = view.createNodes; |
|
|
|
var _createNodes = view.createNodes; |
|
|
|
view.createNodes = function(setting, level, nodes, parentNode) { |
|
|
|
view.createNodes = function (setting, level, nodes, parentNode) { |
|
|
|
if (_createNodes) _createNodes.apply(view, arguments); |
|
|
|
if (_createNodes) _createNodes.apply(view, arguments); |
|
|
|
if (!nodes) return; |
|
|
|
if (!nodes) return; |
|
|
|
view.repairParentChkClassWithSelf(setting, parentNode); |
|
|
|
view.repairParentChkClassWithSelf(setting, parentNode); |
|
|
|
} |
|
|
|
}; |
|
|
|
var _removeNode = view.removeNode; |
|
|
|
var _removeNode = view.removeNode; |
|
|
|
view.removeNode = function(setting, node) { |
|
|
|
view.removeNode = function (setting, node) { |
|
|
|
var parentNode = node.getParentNode(); |
|
|
|
var parentNode = node.getParentNode(); |
|
|
|
if (_removeNode) _removeNode.apply(view, arguments); |
|
|
|
if (_removeNode) _removeNode.apply(view, arguments); |
|
|
|
if (!node || !parentNode) return; |
|
|
|
if (!node || !parentNode) return; |
|
|
|
view.repairChkClass(setting, parentNode); |
|
|
|
view.repairChkClass(setting, parentNode); |
|
|
|
view.repairParentChkClass(setting, parentNode); |
|
|
|
view.repairParentChkClass(setting, parentNode); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var _appendNodes = view.appendNodes; |
|
|
|
var _appendNodes = view.appendNodes; |
|
|
|
view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) { |
|
|
|
view.appendNodes = function (setting, level, nodes, parentNode, initFlag, openFlag) { |
|
|
|
var html = ""; |
|
|
|
var html = ""; |
|
|
|
if (_appendNodes) { |
|
|
|
if (_appendNodes) { |
|
|
|
html = _appendNodes.apply(view, arguments); |
|
|
|
html = _appendNodes.apply(view, arguments); |
|
|
@ -642,5 +647,5 @@ |
|
|
|
data.makeChkFlag(setting, parentNode); |
|
|
|
data.makeChkFlag(setting, parentNode); |
|
|
|
} |
|
|
|
} |
|
|
|
return html; |
|
|
|
return html; |
|
|
|
} |
|
|
|
}; |
|
|
|
})(BI.jQuery); |
|
|
|
})(BI.jQuery); |