/*
* JQuery zTree core 3.4
* http://zTree.me/
*
* Copyright (c) 2010 Hunter.z
*
* Licensed same as jquery - MIT License
* http://www.opensource.org/licenses/mit-license.php
*
* email: hunter.z@263.net
* Date: 2012-09-03
*/
(function($){
var settings = {}, roots = {}, caches = {},
//default consts of core
_consts = {
event: {
NODECREATED: "ztree_nodeCreated",
CLICK: "ztree_click",
EXPAND: "ztree_expand",
COLLAPSE: "ztree_collapse",
ASYNC_SUCCESS: "ztree_async_success",
ASYNC_ERROR: "ztree_async_error"
},
id: {
A: "_a",
ICON: "_ico",
SPAN: "_span",
SWITCH: "_switch",
UL: "_ul"
},
line: {
ROOT: "root",
ROOTS: "roots",
CENTER: "center",
BOTTOM: "bottom",
NOLINE: "noline",
LINE: "line"
},
folder: {
OPEN: "open",
CLOSE: "close",
DOCU: "docu"
},
node: {
CURSELECTED: "curSelectedNode"
}
},
//default setting of core
_setting = {
treeId: "",
treeObj: null,
view: {
addDiyDom: null,
autoCancelSelected: true,
dblClickExpand: true,
expandSpeed: "fast",
fontCss: {},
nameIsHTML: false,
selectedMulti: true,
showIcon: true,
showLine: true,
showTitle: true
},
data: {
key: {
children: "children",
name: "name",
title: "",
url: "url"
},
simpleData: {
enable: false,
idKey: "id",
pIdKey: "pId",
rootPId: null
},
keep: {
parent: false,
leaf: false
}
},
async: {
enable: false,
contentType: "application/x-www-form-urlencoded",
type: "post",
dataType: "text",
url: "",
autoParam: [],
otherParam: [],
dataFilter: null
},
callback: {
beforeAsync:null,
beforeClick:null,
beforeRightClick:null,
beforeMouseDown:null,
beforeMouseUp:null,
beforeExpand:null,
beforeCollapse:null,
beforeRemove:null,
onAsyncError:null,
onAsyncSuccess:null,
onNodeCreated:null,
onClick:null,
onRightClick:null,
onMouseDown:null,
onMouseUp:null,
onExpand:null,
onCollapse:null,
onRemove:null
}
},
//default root of core
//zTree use root to save full data
_initRoot = function (setting) {
var r = data.getRoot(setting);
if (!r) {
r = {};
data.setRoot(setting, r);
}
r[setting.data.key.children] = [];
r.expandTriggerFlag = false;
r.curSelectedList = [];
r.noSelection = true;
r.createdNodes = [];
r.zId = 0;
},
//default cache of core
_initCache = function(setting) {
var c = data.getCache(setting);
if (!c) {
c = {};
data.setCache(setting, c);
}
c.nodes = [];
c.doms = [];
},
//default bindEvent of core
_bindEvent = function(setting) {
var o = setting.treeObj,
c = consts.event;
o.bind(c.NODECREATED, function (event, treeId, node) {
tools.apply(setting.callback.onNodeCreated, [event, treeId, node]);
});
o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) {
tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]);
});
o.bind(c.EXPAND, function (event, treeId, node) {
tools.apply(setting.callback.onExpand, [event, treeId, node]);
});
o.bind(c.COLLAPSE, function (event, treeId, node) {
tools.apply(setting.callback.onCollapse, [event, treeId, node]);
});
o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) {
tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]);
});
o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) {
tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]);
});
},
_unbindEvent = function(setting) {
var o = setting.treeObj,
c = consts.event;
o.unbind(c.NODECREATED)
.unbind(c.CLICK)
.unbind(c.EXPAND)
.unbind(c.COLLAPSE)
.unbind(c.ASYNC_SUCCESS)
.unbind(c.ASYNC_ERROR);
},
//default event proxy of core
_eventProxy = function(event) {
var target = event.target,
setting = data.getSetting(event.data.treeId),
tId = "", node = null,
nodeEventType = "", treeEventType = "",
nodeEventCallback = null, treeEventCallback = null,
tmp = null;
if (tools.eqs(event.type, "mousedown")) {
treeEventType = "mousedown";
} else if (tools.eqs(event.type, "mouseup")) {
treeEventType = "mouseup";
} else if (tools.eqs(event.type, "contextmenu")) {
treeEventType = "contextmenu";
} else if (tools.eqs(event.type, "click")) {
if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) {
tId = ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)).id;
nodeEventType = "switchNode";
} else {
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
if (tmp) {
tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;
nodeEventType = "clickNode";
}
}
} else if (tools.eqs(event.type, "dblclick")) {
treeEventType = "dblclick";
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
if (tmp) {
tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;
nodeEventType = "switchNode";
}
}
if (treeEventType.length > 0 && tId.length == 0) {
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
if (tmp) {tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;}
}
// event to node
if (tId.length>0) {
node = data.getNodeCache(setting, tId);
switch (nodeEventType) {
case "switchNode" :
if (!node.isParent) {
nodeEventType = "";
} else if (tools.eqs(event.type, "click")
|| (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) {
nodeEventCallback = handler.onSwitchNode;
} else {
nodeEventType = "";
}
break;
case "clickNode" :
nodeEventCallback = handler.onClickNode;
break;
}
}
// event to zTree
switch (treeEventType) {
case "mousedown" :
treeEventCallback = handler.onZTreeMousedown;
break;
case "mouseup" :
treeEventCallback = handler.onZTreeMouseup;
break;
case "dblclick" :
treeEventCallback = handler.onZTreeDblclick;
break;
case "contextmenu" :
treeEventCallback = handler.onZTreeContextmenu;
break;
}
var proxyResult = {
stop: false,
node: node,
nodeEventType: nodeEventType,
nodeEventCallback: nodeEventCallback,
treeEventType: treeEventType,
treeEventCallback: treeEventCallback
};
return proxyResult
},
//default init node of core
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
if (!n) return;
var r = data.getRoot(setting),
childKey = setting.data.key.children;
n.level = level;
n.tId = setting.treeId + "_" + (++r.zId);
n.parentTId = parentNode ? parentNode.tId : null;
if (n[childKey] && n[childKey].length > 0) {
if (typeof n.open == "string") n.open = tools.eqs(n.open, "true");
n.open = !!n.open;
n.isParent = true;
n.zAsync = true;
} else {
n.open = false;
if (typeof n.isParent == "string") n.isParent = tools.eqs(n.isParent, "true");
n.isParent = !!n.isParent;
n.zAsync = !n.isParent;
}
n.isFirstNode = isFirstNode;
n.isLastNode = isLastNode;
n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);};
n.getPreNode = function() {return data.getPreNode(setting, n);};
n.getNextNode = function() {return data.getNextNode(setting, n);};
n.isAjaxing = false;
data.fixPIdKeyValue(setting, n);
},
_init = {
bind: [_bindEvent],
unbind: [_unbindEvent],
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
region.zip (19个子文件)
region
css
zTreeStyle
img
diy
5.png 710B
9.png 467B
1_close.png 601B
1_open.png 580B
6.png 432B
2.png 570B
7.png 534B
4.png 399B
8.png 529B
3.png 762B
zTreeStandard.gif 5KB
line_conn.gif 45B
zTreeStandard.png 11KB
loading.gif 381B
zTreeStyle.css 6KB
demo.css 2KB
regionAccHall.js 13KB
jquery.ztree.core-3.4.js 56KB
regionAccHall.jsp 8KB
共 19 条
- 1
资源评论
- zhaosen08262015-01-04还好,解决了我的问题
- liudan8182013-01-13不怎么好用,没有刚才下的好...
- chensb1232015-03-06还好,解决了我的问题
chenqifa2009
- 粉丝: 16
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功