|
|
@ -10,8 +10,8 @@ |
|
|
|
* 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: { |
|
|
|
CHECK: "ztree_check" |
|
|
|
CHECK: "ztree_check" |
|
|
@ -35,7 +35,7 @@ |
|
|
|
TYPE_LEVEL: "level" |
|
|
|
TYPE_LEVEL: "level" |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// default setting of excheck
|
|
|
|
//default setting of excheck
|
|
|
|
_setting = { |
|
|
|
_setting = { |
|
|
|
check: { |
|
|
|
check: { |
|
|
|
enable: false, |
|
|
|
enable: false, |
|
|
@ -45,8 +45,8 @@ |
|
|
|
chkDisabledInherit: false, |
|
|
|
chkDisabledInherit: false, |
|
|
|
radioType: _consts.radio.TYPE_LEVEL, |
|
|
|
radioType: _consts.radio.TYPE_LEVEL, |
|
|
|
chkboxType: { |
|
|
|
chkboxType: { |
|
|
|
Y: "ps", |
|
|
|
"Y": "ps", |
|
|
|
N: "ps" |
|
|
|
"N": "ps" |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
data: { |
|
|
|
data: { |
|
|
@ -55,19 +55,19 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
callback: { |
|
|
|
callback: { |
|
|
|
beforeCheck: null, |
|
|
|
beforeCheck:null, |
|
|
|
onCheck: null |
|
|
|
onCheck:null |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// default root of excheck
|
|
|
|
//default root of excheck
|
|
|
|
_initRoot = function (setting) { |
|
|
|
_initRoot = function (setting) { |
|
|
|
var r = data.getRoot(setting); |
|
|
|
var r = data.getRoot(setting); |
|
|
|
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 +75,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 +89,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,41 +126,41 @@ |
|
|
|
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"); |
|
|
|
n[checkedKey] = !!n[checkedKey]; |
|
|
|
n[checkedKey] = !!n[checkedKey]; |
|
|
|
n.checkedOld = n[checkedKey]; |
|
|
|
n.checkedOld = n[checkedKey]; |
|
|
|
if (typeof n.nocheck === "string") n.nocheck = tools.eqs(n.nocheck, "true"); |
|
|
|
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true"); |
|
|
|
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); |
|
|
|
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck); |
|
|
|
if (typeof n.chkDisabled === "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); |
|
|
|
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true"); |
|
|
|
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); |
|
|
|
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled); |
|
|
|
if (typeof n.halfCheck === "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); |
|
|
|
if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true"); |
|
|
|
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 +183,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,13 +219,13 @@ |
|
|
|
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--; |
|
|
@ -233,7 +233,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
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 +242,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, |
|
|
@ -262,7 +262,7 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
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 +275,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 +292,11 @@ |
|
|
|
} 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; break; |
|
|
|
} else if (tmp == 0) { |
|
|
|
} else if (tmp == 0){ |
|
|
|
chkFlag = 0; |
|
|
|
chkFlag = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (setting.check.chkStyle == consts.checkbox.STYLE) { |
|
|
|
} else if (setting.check.chkStyle == consts.checkbox.STYLE) { |
|
|
@ -324,11 +324,11 @@ |
|
|
|
node.check_Child_State = chkFlag; |
|
|
|
node.check_Child_State = chkFlag; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 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) { |
|
|
|
if (node.chkDisabled === true) return false; |
|
|
|
if (node.chkDisabled === true) return false; |
|
|
@ -343,7 +343,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 +351,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); |
|
|
@ -360,13 +360,13 @@ |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 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 +375,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 +408,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 +422,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, |
|
|
|
fullStyle = ""; |
|
|
|
fullStyle = ""; |
|
|
@ -431,20 +431,20 @@ |
|
|
|
} 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) ? c.FULL : c.PART) : ((node.check_Child_State < 1) ? c.FULL : c.PART); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
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; |
|
|
|
return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; |
|
|
|
return consts.className.BUTTON + " " + c.DEFAULT + " " + chkName; |
|
|
|
}, |
|
|
|
}, |
|
|
|
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; |
|
|
@ -453,7 +453,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) { |
|
|
@ -461,13 +461,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) { |
|
|
@ -476,7 +476,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) { |
|
|
@ -490,7 +490,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; |
|
|
@ -498,16 +498,16 @@ |
|
|
|
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(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
obj.show(); |
|
|
|
obj.show(); |
|
|
|
} |
|
|
|
} |
|
|
|
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); |
|
|
@ -537,7 +537,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, |
|
|
@ -600,22 +600,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); |
|
|
@ -624,5 +624,5 @@ |
|
|
|
data.makeChkFlag(setting, parentNode); |
|
|
|
data.makeChkFlag(setting, parentNode); |
|
|
|
} |
|
|
|
} |
|
|
|
return html; |
|
|
|
return html; |
|
|
|
}; |
|
|
|
} |
|
|
|
})(jQuery); |
|
|
|
})(jQuery); |