tocmd 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/tocmd +70 -0
- data/lib/mdpreview/markdown_render.rb +45 -0
- data/lib/mdpreview/translator.rb +237 -0
- data/lib/mdpreview/version.rb +3 -0
- data/lib/mdpreview.rb +18 -0
- data/test/mdptest.rb +100 -0
- data/vendor/cur.file +6 -0
- data/vendor/meta.js +1 -0
- data/vendor/template.html +0 -0
- data/vendor/toc/css/demo.css +33 -0
- data/vendor/toc/css/zTreeStyle/img/diy/1_close.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/1_open.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/2.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/3.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/4.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/5.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/6.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/7.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/8.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/9.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/line_conn.gif +0 -0
- data/vendor/toc/css/zTreeStyle/img/loading.gif +0 -0
- data/vendor/toc/css/zTreeStyle/img/zTreeStandard.gif +0 -0
- data/vendor/toc/css/zTreeStyle/img/zTreeStandard.png +0 -0
- data/vendor/toc/css/zTreeStyle/zTreeStyle.css +97 -0
- data/vendor/toc/js/jquery-1.4.4.min.js +167 -0
- data/vendor/toc/js/jquery.ztree.all-3.5.js +3447 -0
- data/vendor/toc/js/jquery.ztree.all-3.5.min.js +157 -0
- data/vendor/toc/js/jquery.ztree.core-3.5.js +1644 -0
- data/vendor/toc/js/jquery.ztree.core-3.5.min.js +68 -0
- data/vendor/toc/js/jquery.ztree.excheck-3.5.js +624 -0
- data/vendor/toc/js/jquery.ztree.excheck-3.5.min.js +33 -0
- data/vendor/toc/js/jquery.ztree.exedit-3.5.js +1178 -0
- data/vendor/toc/js/jquery.ztree.exedit-3.5.min.js +52 -0
- data/vendor/toc/js/jquery.ztree.exhide-3.5.js +362 -0
- data/vendor/toc/js/jquery.ztree.exhide-3.5.min.js +22 -0
- data/vendor/toc/js/jquery.ztree_toc.js +224 -0
- data/vendor/toc/js/jquery.ztree_toc.min.js +4 -0
- data/vendor/toc/style/Clearness Dark.css +146 -0
- data/vendor/toc/style/Clearness.css +147 -0
- data/vendor/toc/style/GitHub.css +90 -0
- data/vendor/toc/style/GitHub2.css +297 -0
- data/vendor/toc/style/github-bf51422f4bb36427d391e4b75a1daa083c2d840e.css +1 -0
- data/vendor/toc/style/github2-d731afd4f624c99a4b19ad69f3083cd6d02b81d5.css +1 -0
- data/vendor/toc/style/makedownpad.css +285 -0
- metadata +90 -0
@@ -0,0 +1,3447 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* JQuery zTree core 3.5.02
|
4
|
+
* http://zTree.me/
|
5
|
+
*
|
6
|
+
* Copyright (c) 2010 Hunter.z
|
7
|
+
*
|
8
|
+
* Licensed same as jquery - MIT License
|
9
|
+
* http://www.opensource.org/licenses/mit-license.php
|
10
|
+
*
|
11
|
+
* email: hunter.z@263.net
|
12
|
+
* Date: 2013-01-28
|
13
|
+
*/
|
14
|
+
(function($){
|
15
|
+
var settings = {}, roots = {}, caches = {},
|
16
|
+
//default consts of core
|
17
|
+
_consts = {
|
18
|
+
event: {
|
19
|
+
NODECREATED: "ztree_nodeCreated",
|
20
|
+
CLICK: "ztree_click",
|
21
|
+
EXPAND: "ztree_expand",
|
22
|
+
COLLAPSE: "ztree_collapse",
|
23
|
+
ASYNC_SUCCESS: "ztree_async_success",
|
24
|
+
ASYNC_ERROR: "ztree_async_error"
|
25
|
+
},
|
26
|
+
id: {
|
27
|
+
A: "_a",
|
28
|
+
ICON: "_ico",
|
29
|
+
SPAN: "_span",
|
30
|
+
SWITCH: "_switch",
|
31
|
+
UL: "_ul"
|
32
|
+
},
|
33
|
+
line: {
|
34
|
+
ROOT: "root",
|
35
|
+
ROOTS: "roots",
|
36
|
+
CENTER: "center",
|
37
|
+
BOTTOM: "bottom",
|
38
|
+
NOLINE: "noline",
|
39
|
+
LINE: "line"
|
40
|
+
},
|
41
|
+
folder: {
|
42
|
+
OPEN: "open",
|
43
|
+
CLOSE: "close",
|
44
|
+
DOCU: "docu"
|
45
|
+
},
|
46
|
+
node: {
|
47
|
+
CURSELECTED: "curSelectedNode"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
//default setting of core
|
51
|
+
_setting = {
|
52
|
+
treeId: "",
|
53
|
+
treeObj: null,
|
54
|
+
view: {
|
55
|
+
addDiyDom: null,
|
56
|
+
autoCancelSelected: true,
|
57
|
+
dblClickExpand: true,
|
58
|
+
expandSpeed: "fast",
|
59
|
+
fontCss: {},
|
60
|
+
nameIsHTML: false,
|
61
|
+
selectedMulti: true,
|
62
|
+
showIcon: true,
|
63
|
+
showLine: true,
|
64
|
+
showTitle: true
|
65
|
+
},
|
66
|
+
data: {
|
67
|
+
key: {
|
68
|
+
children: "children",
|
69
|
+
name: "name",
|
70
|
+
title: "",
|
71
|
+
url: "url"
|
72
|
+
},
|
73
|
+
simpleData: {
|
74
|
+
enable: false,
|
75
|
+
idKey: "id",
|
76
|
+
pIdKey: "pId",
|
77
|
+
rootPId: null
|
78
|
+
},
|
79
|
+
keep: {
|
80
|
+
parent: false,
|
81
|
+
leaf: false
|
82
|
+
}
|
83
|
+
},
|
84
|
+
async: {
|
85
|
+
enable: false,
|
86
|
+
contentType: "application/x-www-form-urlencoded",
|
87
|
+
type: "post",
|
88
|
+
dataType: "text",
|
89
|
+
url: "",
|
90
|
+
autoParam: [],
|
91
|
+
otherParam: [],
|
92
|
+
dataFilter: null
|
93
|
+
},
|
94
|
+
callback: {
|
95
|
+
beforeAsync:null,
|
96
|
+
beforeClick:null,
|
97
|
+
beforeDblClick:null,
|
98
|
+
beforeRightClick:null,
|
99
|
+
beforeMouseDown:null,
|
100
|
+
beforeMouseUp:null,
|
101
|
+
beforeExpand:null,
|
102
|
+
beforeCollapse:null,
|
103
|
+
beforeRemove:null,
|
104
|
+
|
105
|
+
onAsyncError:null,
|
106
|
+
onAsyncSuccess:null,
|
107
|
+
onNodeCreated:null,
|
108
|
+
onClick:null,
|
109
|
+
onDblClick:null,
|
110
|
+
onRightClick:null,
|
111
|
+
onMouseDown:null,
|
112
|
+
onMouseUp:null,
|
113
|
+
onExpand:null,
|
114
|
+
onCollapse:null,
|
115
|
+
onRemove:null
|
116
|
+
}
|
117
|
+
},
|
118
|
+
//default root of core
|
119
|
+
//zTree use root to save full data
|
120
|
+
_initRoot = function (setting) {
|
121
|
+
var r = data.getRoot(setting);
|
122
|
+
if (!r) {
|
123
|
+
r = {};
|
124
|
+
data.setRoot(setting, r);
|
125
|
+
}
|
126
|
+
r[setting.data.key.children] = [];
|
127
|
+
r.expandTriggerFlag = false;
|
128
|
+
r.curSelectedList = [];
|
129
|
+
r.noSelection = true;
|
130
|
+
r.createdNodes = [];
|
131
|
+
r.zId = 0;
|
132
|
+
r._ver = (new Date()).getTime();
|
133
|
+
},
|
134
|
+
//default cache of core
|
135
|
+
_initCache = function(setting) {
|
136
|
+
var c = data.getCache(setting);
|
137
|
+
if (!c) {
|
138
|
+
c = {};
|
139
|
+
data.setCache(setting, c);
|
140
|
+
}
|
141
|
+
c.nodes = [];
|
142
|
+
c.doms = [];
|
143
|
+
},
|
144
|
+
//default bindEvent of core
|
145
|
+
_bindEvent = function(setting) {
|
146
|
+
var o = setting.treeObj,
|
147
|
+
c = consts.event;
|
148
|
+
o.bind(c.NODECREATED, function (event, treeId, node) {
|
149
|
+
tools.apply(setting.callback.onNodeCreated, [event, treeId, node]);
|
150
|
+
});
|
151
|
+
|
152
|
+
o.bind(c.CLICK, function (event, srcEvent, treeId, node, clickFlag) {
|
153
|
+
tools.apply(setting.callback.onClick, [srcEvent, treeId, node, clickFlag]);
|
154
|
+
});
|
155
|
+
|
156
|
+
o.bind(c.EXPAND, function (event, treeId, node) {
|
157
|
+
tools.apply(setting.callback.onExpand, [event, treeId, node]);
|
158
|
+
});
|
159
|
+
|
160
|
+
o.bind(c.COLLAPSE, function (event, treeId, node) {
|
161
|
+
tools.apply(setting.callback.onCollapse, [event, treeId, node]);
|
162
|
+
});
|
163
|
+
|
164
|
+
o.bind(c.ASYNC_SUCCESS, function (event, treeId, node, msg) {
|
165
|
+
tools.apply(setting.callback.onAsyncSuccess, [event, treeId, node, msg]);
|
166
|
+
});
|
167
|
+
|
168
|
+
o.bind(c.ASYNC_ERROR, function (event, treeId, node, XMLHttpRequest, textStatus, errorThrown) {
|
169
|
+
tools.apply(setting.callback.onAsyncError, [event, treeId, node, XMLHttpRequest, textStatus, errorThrown]);
|
170
|
+
});
|
171
|
+
},
|
172
|
+
_unbindEvent = function(setting) {
|
173
|
+
var o = setting.treeObj,
|
174
|
+
c = consts.event;
|
175
|
+
o.unbind(c.NODECREATED)
|
176
|
+
.unbind(c.CLICK)
|
177
|
+
.unbind(c.EXPAND)
|
178
|
+
.unbind(c.COLLAPSE)
|
179
|
+
.unbind(c.ASYNC_SUCCESS)
|
180
|
+
.unbind(c.ASYNC_ERROR);
|
181
|
+
},
|
182
|
+
//default event proxy of core
|
183
|
+
_eventProxy = function(event) {
|
184
|
+
var target = event.target,
|
185
|
+
setting = data.getSetting(event.data.treeId),
|
186
|
+
tId = "", node = null,
|
187
|
+
nodeEventType = "", treeEventType = "",
|
188
|
+
nodeEventCallback = null, treeEventCallback = null,
|
189
|
+
tmp = null;
|
190
|
+
|
191
|
+
if (tools.eqs(event.type, "mousedown")) {
|
192
|
+
treeEventType = "mousedown";
|
193
|
+
} else if (tools.eqs(event.type, "mouseup")) {
|
194
|
+
treeEventType = "mouseup";
|
195
|
+
} else if (tools.eqs(event.type, "contextmenu")) {
|
196
|
+
treeEventType = "contextmenu";
|
197
|
+
} else if (tools.eqs(event.type, "click")) {
|
198
|
+
if (tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.SWITCH) !== null) {
|
199
|
+
tId = ($(target).parent("li").get(0) || $(target).parentsUntil("li").parent().get(0)).id;
|
200
|
+
nodeEventType = "switchNode";
|
201
|
+
} else {
|
202
|
+
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
|
203
|
+
if (tmp) {
|
204
|
+
tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;
|
205
|
+
nodeEventType = "clickNode";
|
206
|
+
}
|
207
|
+
}
|
208
|
+
} else if (tools.eqs(event.type, "dblclick")) {
|
209
|
+
treeEventType = "dblclick";
|
210
|
+
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
|
211
|
+
if (tmp) {
|
212
|
+
tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;
|
213
|
+
nodeEventType = "switchNode";
|
214
|
+
}
|
215
|
+
}
|
216
|
+
if (treeEventType.length > 0 && tId.length == 0) {
|
217
|
+
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
|
218
|
+
if (tmp) {tId = ($(tmp).parent("li").get(0) || $(tmp).parentsUntil("li").parent().get(0)).id;}
|
219
|
+
}
|
220
|
+
// event to node
|
221
|
+
if (tId.length>0) {
|
222
|
+
node = data.getNodeCache(setting, tId);
|
223
|
+
switch (nodeEventType) {
|
224
|
+
case "switchNode" :
|
225
|
+
if (!node.isParent) {
|
226
|
+
nodeEventType = "";
|
227
|
+
} else if (tools.eqs(event.type, "click")
|
228
|
+
|| (tools.eqs(event.type, "dblclick") && tools.apply(setting.view.dblClickExpand, [setting.treeId, node], setting.view.dblClickExpand))) {
|
229
|
+
nodeEventCallback = handler.onSwitchNode;
|
230
|
+
} else {
|
231
|
+
nodeEventType = "";
|
232
|
+
}
|
233
|
+
break;
|
234
|
+
case "clickNode" :
|
235
|
+
nodeEventCallback = handler.onClickNode;
|
236
|
+
break;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
// event to zTree
|
240
|
+
switch (treeEventType) {
|
241
|
+
case "mousedown" :
|
242
|
+
treeEventCallback = handler.onZTreeMousedown;
|
243
|
+
break;
|
244
|
+
case "mouseup" :
|
245
|
+
treeEventCallback = handler.onZTreeMouseup;
|
246
|
+
break;
|
247
|
+
case "dblclick" :
|
248
|
+
treeEventCallback = handler.onZTreeDblclick;
|
249
|
+
break;
|
250
|
+
case "contextmenu" :
|
251
|
+
treeEventCallback = handler.onZTreeContextmenu;
|
252
|
+
break;
|
253
|
+
}
|
254
|
+
var proxyResult = {
|
255
|
+
stop: false,
|
256
|
+
node: node,
|
257
|
+
nodeEventType: nodeEventType,
|
258
|
+
nodeEventCallback: nodeEventCallback,
|
259
|
+
treeEventType: treeEventType,
|
260
|
+
treeEventCallback: treeEventCallback
|
261
|
+
};
|
262
|
+
return proxyResult
|
263
|
+
},
|
264
|
+
//default init node of core
|
265
|
+
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
|
266
|
+
if (!n) return;
|
267
|
+
var r = data.getRoot(setting),
|
268
|
+
childKey = setting.data.key.children;
|
269
|
+
n.level = level;
|
270
|
+
n.tId = setting.treeId + "_" + (++r.zId);
|
271
|
+
n.parentTId = parentNode ? parentNode.tId : null;
|
272
|
+
if (n[childKey] && n[childKey].length > 0) {
|
273
|
+
if (typeof n.open == "string") n.open = tools.eqs(n.open, "true");
|
274
|
+
n.open = !!n.open;
|
275
|
+
n.isParent = true;
|
276
|
+
n.zAsync = true;
|
277
|
+
} else {
|
278
|
+
n.open = false;
|
279
|
+
if (typeof n.isParent == "string") n.isParent = tools.eqs(n.isParent, "true");
|
280
|
+
n.isParent = !!n.isParent;
|
281
|
+
n.zAsync = !n.isParent;
|
282
|
+
}
|
283
|
+
n.isFirstNode = isFirstNode;
|
284
|
+
n.isLastNode = isLastNode;
|
285
|
+
n.getParentNode = function() {return data.getNodeCache(setting, n.parentTId);};
|
286
|
+
n.getPreNode = function() {return data.getPreNode(setting, n);};
|
287
|
+
n.getNextNode = function() {return data.getNextNode(setting, n);};
|
288
|
+
n.isAjaxing = false;
|
289
|
+
data.fixPIdKeyValue(setting, n);
|
290
|
+
},
|
291
|
+
_init = {
|
292
|
+
bind: [_bindEvent],
|
293
|
+
unbind: [_unbindEvent],
|
294
|
+
caches: [_initCache],
|
295
|
+
nodes: [_initNode],
|
296
|
+
proxys: [_eventProxy],
|
297
|
+
roots: [_initRoot],
|
298
|
+
beforeA: [],
|
299
|
+
afterA: [],
|
300
|
+
innerBeforeA: [],
|
301
|
+
innerAfterA: [],
|
302
|
+
zTreeTools: []
|
303
|
+
},
|
304
|
+
//method of operate data
|
305
|
+
data = {
|
306
|
+
addNodeCache: function(setting, node) {
|
307
|
+
data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = node;
|
308
|
+
},
|
309
|
+
getNodeCacheId: function(tId) {
|
310
|
+
return tId.substring(tId.lastIndexOf("_")+1);
|
311
|
+
},
|
312
|
+
addAfterA: function(afterA) {
|
313
|
+
_init.afterA.push(afterA);
|
314
|
+
},
|
315
|
+
addBeforeA: function(beforeA) {
|
316
|
+
_init.beforeA.push(beforeA);
|
317
|
+
},
|
318
|
+
addInnerAfterA: function(innerAfterA) {
|
319
|
+
_init.innerAfterA.push(innerAfterA);
|
320
|
+
},
|
321
|
+
addInnerBeforeA: function(innerBeforeA) {
|
322
|
+
_init.innerBeforeA.push(innerBeforeA);
|
323
|
+
},
|
324
|
+
addInitBind: function(bindEvent) {
|
325
|
+
_init.bind.push(bindEvent);
|
326
|
+
},
|
327
|
+
addInitUnBind: function(unbindEvent) {
|
328
|
+
_init.unbind.push(unbindEvent);
|
329
|
+
},
|
330
|
+
addInitCache: function(initCache) {
|
331
|
+
_init.caches.push(initCache);
|
332
|
+
},
|
333
|
+
addInitNode: function(initNode) {
|
334
|
+
_init.nodes.push(initNode);
|
335
|
+
},
|
336
|
+
addInitProxy: function(initProxy) {
|
337
|
+
_init.proxys.push(initProxy);
|
338
|
+
},
|
339
|
+
addInitRoot: function(initRoot) {
|
340
|
+
_init.roots.push(initRoot);
|
341
|
+
},
|
342
|
+
addNodesData: function(setting, parentNode, nodes) {
|
343
|
+
var childKey = setting.data.key.children;
|
344
|
+
if (!parentNode[childKey]) parentNode[childKey] = [];
|
345
|
+
if (parentNode[childKey].length > 0) {
|
346
|
+
parentNode[childKey][parentNode[childKey].length - 1].isLastNode = false;
|
347
|
+
view.setNodeLineIcos(setting, parentNode[childKey][parentNode[childKey].length - 1]);
|
348
|
+
}
|
349
|
+
parentNode.isParent = true;
|
350
|
+
parentNode[childKey] = parentNode[childKey].concat(nodes);
|
351
|
+
},
|
352
|
+
addSelectedNode: function(setting, node) {
|
353
|
+
var root = data.getRoot(setting);
|
354
|
+
if (!data.isSelectedNode(setting, node)) {
|
355
|
+
root.curSelectedList.push(node);
|
356
|
+
}
|
357
|
+
},
|
358
|
+
addCreatedNode: function(setting, node) {
|
359
|
+
if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) {
|
360
|
+
var root = data.getRoot(setting);
|
361
|
+
root.createdNodes.push(node);
|
362
|
+
}
|
363
|
+
},
|
364
|
+
addZTreeTools: function(zTreeTools) {
|
365
|
+
_init.zTreeTools.push(zTreeTools);
|
366
|
+
},
|
367
|
+
exSetting: function(s) {
|
368
|
+
$.extend(true, _setting, s);
|
369
|
+
},
|
370
|
+
fixPIdKeyValue: function(setting, node) {
|
371
|
+
if (setting.data.simpleData.enable) {
|
372
|
+
node[setting.data.simpleData.pIdKey] = node.parentTId ? node.getParentNode()[setting.data.simpleData.idKey] : setting.data.simpleData.rootPId;
|
373
|
+
}
|
374
|
+
},
|
375
|
+
getAfterA: function(setting, node, array) {
|
376
|
+
for (var i=0, j=_init.afterA.length; i<j; i++) {
|
377
|
+
_init.afterA[i].apply(this, arguments);
|
378
|
+
}
|
379
|
+
},
|
380
|
+
getBeforeA: function(setting, node, array) {
|
381
|
+
for (var i=0, j=_init.beforeA.length; i<j; i++) {
|
382
|
+
_init.beforeA[i].apply(this, arguments);
|
383
|
+
}
|
384
|
+
},
|
385
|
+
getInnerAfterA: function(setting, node, array) {
|
386
|
+
for (var i=0, j=_init.innerAfterA.length; i<j; i++) {
|
387
|
+
_init.innerAfterA[i].apply(this, arguments);
|
388
|
+
}
|
389
|
+
},
|
390
|
+
getInnerBeforeA: function(setting, node, array) {
|
391
|
+
for (var i=0, j=_init.innerBeforeA.length; i<j; i++) {
|
392
|
+
_init.innerBeforeA[i].apply(this, arguments);
|
393
|
+
}
|
394
|
+
},
|
395
|
+
getCache: function(setting) {
|
396
|
+
return caches[setting.treeId];
|
397
|
+
},
|
398
|
+
getNextNode: function(setting, node) {
|
399
|
+
if (!node) return null;
|
400
|
+
var childKey = setting.data.key.children,
|
401
|
+
p = node.parentTId ? node.getParentNode() : data.getRoot(setting);
|
402
|
+
for (var i=0, l=p[childKey].length-1; i<=l; i++) {
|
403
|
+
if (p[childKey][i] === node) {
|
404
|
+
return (i==l ? null : p[childKey][i+1]);
|
405
|
+
}
|
406
|
+
}
|
407
|
+
return null;
|
408
|
+
},
|
409
|
+
getNodeByParam: function(setting, nodes, key, value) {
|
410
|
+
if (!nodes || !key) return null;
|
411
|
+
var childKey = setting.data.key.children;
|
412
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
413
|
+
if (nodes[i][key] == value) {
|
414
|
+
return nodes[i];
|
415
|
+
}
|
416
|
+
var tmp = data.getNodeByParam(setting, nodes[i][childKey], key, value);
|
417
|
+
if (tmp) return tmp;
|
418
|
+
}
|
419
|
+
return null;
|
420
|
+
},
|
421
|
+
getNodeCache: function(setting, tId) {
|
422
|
+
if (!tId) return null;
|
423
|
+
var n = caches[setting.treeId].nodes[data.getNodeCacheId(tId)];
|
424
|
+
return n ? n : null;
|
425
|
+
},
|
426
|
+
getNodeName: function(setting, node) {
|
427
|
+
var nameKey = setting.data.key.name;
|
428
|
+
return "" + node[nameKey];
|
429
|
+
},
|
430
|
+
getNodeTitle: function(setting, node) {
|
431
|
+
var t = setting.data.key.title === "" ? setting.data.key.name : setting.data.key.title;
|
432
|
+
return "" + node[t];
|
433
|
+
},
|
434
|
+
getNodes: function(setting) {
|
435
|
+
return data.getRoot(setting)[setting.data.key.children];
|
436
|
+
},
|
437
|
+
getNodesByParam: function(setting, nodes, key, value) {
|
438
|
+
if (!nodes || !key) return [];
|
439
|
+
var childKey = setting.data.key.children,
|
440
|
+
result = [];
|
441
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
442
|
+
if (nodes[i][key] == value) {
|
443
|
+
result.push(nodes[i]);
|
444
|
+
}
|
445
|
+
result = result.concat(data.getNodesByParam(setting, nodes[i][childKey], key, value));
|
446
|
+
}
|
447
|
+
return result;
|
448
|
+
},
|
449
|
+
getNodesByParamFuzzy: function(setting, nodes, key, value) {
|
450
|
+
if (!nodes || !key) return [];
|
451
|
+
var childKey = setting.data.key.children,
|
452
|
+
result = [];
|
453
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
454
|
+
if (typeof nodes[i][key] == "string" && nodes[i][key].indexOf(value)>-1) {
|
455
|
+
result.push(nodes[i]);
|
456
|
+
}
|
457
|
+
result = result.concat(data.getNodesByParamFuzzy(setting, nodes[i][childKey], key, value));
|
458
|
+
}
|
459
|
+
return result;
|
460
|
+
},
|
461
|
+
getNodesByFilter: function(setting, nodes, filter, isSingle, invokeParam) {
|
462
|
+
if (!nodes) return (isSingle ? null : []);
|
463
|
+
var childKey = setting.data.key.children,
|
464
|
+
result = isSingle ? null : [];
|
465
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
466
|
+
if (tools.apply(filter, [nodes[i], invokeParam], false)) {
|
467
|
+
if (isSingle) {return nodes[i];}
|
468
|
+
result.push(nodes[i]);
|
469
|
+
}
|
470
|
+
var tmpResult = data.getNodesByFilter(setting, nodes[i][childKey], filter, isSingle, invokeParam);
|
471
|
+
if (isSingle && !!tmpResult) {return tmpResult;}
|
472
|
+
result = isSingle ? tmpResult : result.concat(tmpResult);
|
473
|
+
}
|
474
|
+
return result;
|
475
|
+
},
|
476
|
+
getPreNode: function(setting, node) {
|
477
|
+
if (!node) return null;
|
478
|
+
var childKey = setting.data.key.children,
|
479
|
+
p = node.parentTId ? node.getParentNode() : data.getRoot(setting);
|
480
|
+
for (var i=0, l=p[childKey].length; i<l; i++) {
|
481
|
+
if (p[childKey][i] === node) {
|
482
|
+
return (i==0 ? null : p[childKey][i-1]);
|
483
|
+
}
|
484
|
+
}
|
485
|
+
return null;
|
486
|
+
},
|
487
|
+
getRoot: function(setting) {
|
488
|
+
return setting ? roots[setting.treeId] : null;
|
489
|
+
},
|
490
|
+
getSetting: function(treeId) {
|
491
|
+
return settings[treeId];
|
492
|
+
},
|
493
|
+
getSettings: function() {
|
494
|
+
return settings;
|
495
|
+
},
|
496
|
+
getZTreeTools: function(treeId) {
|
497
|
+
var r = this.getRoot(this.getSetting(treeId));
|
498
|
+
return r ? r.treeTools : null;
|
499
|
+
},
|
500
|
+
initCache: function(setting) {
|
501
|
+
for (var i=0, j=_init.caches.length; i<j; i++) {
|
502
|
+
_init.caches[i].apply(this, arguments);
|
503
|
+
}
|
504
|
+
},
|
505
|
+
initNode: function(setting, level, node, parentNode, preNode, nextNode) {
|
506
|
+
for (var i=0, j=_init.nodes.length; i<j; i++) {
|
507
|
+
_init.nodes[i].apply(this, arguments);
|
508
|
+
}
|
509
|
+
},
|
510
|
+
initRoot: function(setting) {
|
511
|
+
for (var i=0, j=_init.roots.length; i<j; i++) {
|
512
|
+
_init.roots[i].apply(this, arguments);
|
513
|
+
}
|
514
|
+
},
|
515
|
+
isSelectedNode: function(setting, node) {
|
516
|
+
var root = data.getRoot(setting);
|
517
|
+
for (var i=0, j=root.curSelectedList.length; i<j; i++) {
|
518
|
+
if(node === root.curSelectedList[i]) return true;
|
519
|
+
}
|
520
|
+
return false;
|
521
|
+
},
|
522
|
+
removeNodeCache: function(setting, node) {
|
523
|
+
var childKey = setting.data.key.children;
|
524
|
+
if (node[childKey]) {
|
525
|
+
for (var i=0, l=node[childKey].length; i<l; i++) {
|
526
|
+
arguments.callee(setting, node[childKey][i]);
|
527
|
+
}
|
528
|
+
}
|
529
|
+
data.getCache(setting).nodes[data.getNodeCacheId(node.tId)] = null;
|
530
|
+
},
|
531
|
+
removeSelectedNode: function(setting, node) {
|
532
|
+
var root = data.getRoot(setting);
|
533
|
+
for (var i=0, j=root.curSelectedList.length; i<j; i++) {
|
534
|
+
if(node === root.curSelectedList[i] || !data.getNodeCache(setting, root.curSelectedList[i].tId)) {
|
535
|
+
root.curSelectedList.splice(i, 1);
|
536
|
+
i--;j--;
|
537
|
+
}
|
538
|
+
}
|
539
|
+
},
|
540
|
+
setCache: function(setting, cache) {
|
541
|
+
caches[setting.treeId] = cache;
|
542
|
+
},
|
543
|
+
setRoot: function(setting, root) {
|
544
|
+
roots[setting.treeId] = root;
|
545
|
+
},
|
546
|
+
setZTreeTools: function(setting, zTreeTools) {
|
547
|
+
for (var i=0, j=_init.zTreeTools.length; i<j; i++) {
|
548
|
+
_init.zTreeTools[i].apply(this, arguments);
|
549
|
+
}
|
550
|
+
},
|
551
|
+
transformToArrayFormat: function (setting, nodes) {
|
552
|
+
if (!nodes) return [];
|
553
|
+
var childKey = setting.data.key.children,
|
554
|
+
r = [];
|
555
|
+
if (tools.isArray(nodes)) {
|
556
|
+
for (var i=0, l=nodes.length; i<l; i++) {
|
557
|
+
r.push(nodes[i]);
|
558
|
+
if (nodes[i][childKey])
|
559
|
+
r = r.concat(data.transformToArrayFormat(setting, nodes[i][childKey]));
|
560
|
+
}
|
561
|
+
} else {
|
562
|
+
r.push(nodes);
|
563
|
+
if (nodes[childKey])
|
564
|
+
r = r.concat(data.transformToArrayFormat(setting, nodes[childKey]));
|
565
|
+
}
|
566
|
+
return r;
|
567
|
+
},
|
568
|
+
transformTozTreeFormat: function(setting, sNodes) {
|
569
|
+
var i,l,
|
570
|
+
key = setting.data.simpleData.idKey,
|
571
|
+
parentKey = setting.data.simpleData.pIdKey,
|
572
|
+
childKey = setting.data.key.children;
|
573
|
+
if (!key || key=="" || !sNodes) return [];
|
574
|
+
|
575
|
+
if (tools.isArray(sNodes)) {
|
576
|
+
var r = [];
|
577
|
+
var tmpMap = [];
|
578
|
+
for (i=0, l=sNodes.length; i<l; i++) {
|
579
|
+
tmpMap[sNodes[i][key]] = sNodes[i];
|
580
|
+
}
|
581
|
+
for (i=0, l=sNodes.length; i<l; i++) {
|
582
|
+
if (tmpMap[sNodes[i][parentKey]] && sNodes[i][key] != sNodes[i][parentKey]) {
|
583
|
+
if (!tmpMap[sNodes[i][parentKey]][childKey])
|
584
|
+
tmpMap[sNodes[i][parentKey]][childKey] = [];
|
585
|
+
tmpMap[sNodes[i][parentKey]][childKey].push(sNodes[i]);
|
586
|
+
} else {
|
587
|
+
r.push(sNodes[i]);
|
588
|
+
}
|
589
|
+
}
|
590
|
+
return r;
|
591
|
+
}else {
|
592
|
+
return [sNodes];
|
593
|
+
}
|
594
|
+
}
|
595
|
+
},
|
596
|
+
//method of event proxy
|
597
|
+
event = {
|
598
|
+
bindEvent: function(setting) {
|
599
|
+
for (var i=0, j=_init.bind.length; i<j; i++) {
|
600
|
+
_init.bind[i].apply(this, arguments);
|
601
|
+
}
|
602
|
+
},
|
603
|
+
unbindEvent: function(setting) {
|
604
|
+
for (var i=0, j=_init.unbind.length; i<j; i++) {
|
605
|
+
_init.unbind[i].apply(this, arguments);
|
606
|
+
}
|
607
|
+
},
|
608
|
+
bindTree: function(setting) {
|
609
|
+
var eventParam = {
|
610
|
+
treeId: setting.treeId
|
611
|
+
},
|
612
|
+
o = setting.treeObj;
|
613
|
+
// for can't select text
|
614
|
+
o.bind('selectstart', function(e){
|
615
|
+
var n = e.srcElement.nodeName.toLowerCase();
|
616
|
+
return (n === "input" || n === "textarea" );
|
617
|
+
}
|
618
|
+
).css({
|
619
|
+
"-moz-user-select":"-moz-none"
|
620
|
+
});
|
621
|
+
o.bind('click', eventParam, event.proxy);
|
622
|
+
o.bind('dblclick', eventParam, event.proxy);
|
623
|
+
o.bind('mouseover', eventParam, event.proxy);
|
624
|
+
o.bind('mouseout', eventParam, event.proxy);
|
625
|
+
o.bind('mousedown', eventParam, event.proxy);
|
626
|
+
o.bind('mouseup', eventParam, event.proxy);
|
627
|
+
o.bind('contextmenu', eventParam, event.proxy);
|
628
|
+
},
|
629
|
+
unbindTree: function(setting) {
|
630
|
+
var o = setting.treeObj;
|
631
|
+
o.unbind('click', event.proxy)
|
632
|
+
.unbind('dblclick', event.proxy)
|
633
|
+
.unbind('mouseover', event.proxy)
|
634
|
+
.unbind('mouseout', event.proxy)
|
635
|
+
.unbind('mousedown', event.proxy)
|
636
|
+
.unbind('mouseup', event.proxy)
|
637
|
+
.unbind('contextmenu', event.proxy);
|
638
|
+
},
|
639
|
+
doProxy: function(e) {
|
640
|
+
var results = [];
|
641
|
+
for (var i=0, j=_init.proxys.length; i<j; i++) {
|
642
|
+
var proxyResult = _init.proxys[i].apply(this, arguments);
|
643
|
+
results.push(proxyResult);
|
644
|
+
if (proxyResult.stop) {
|
645
|
+
break;
|
646
|
+
}
|
647
|
+
}
|
648
|
+
return results;
|
649
|
+
},
|
650
|
+
proxy: function(e) {
|
651
|
+
var setting = data.getSetting(e.data.treeId);
|
652
|
+
if (!tools.uCanDo(setting, e)) return true;
|
653
|
+
var results = event.doProxy(e),
|
654
|
+
r = true, x = false;
|
655
|
+
for (var i=0, l=results.length; i<l; i++) {
|
656
|
+
var proxyResult = results[i];
|
657
|
+
if (proxyResult.nodeEventCallback) {
|
658
|
+
x = true;
|
659
|
+
r = proxyResult.nodeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r;
|
660
|
+
}
|
661
|
+
if (proxyResult.treeEventCallback) {
|
662
|
+
x = true;
|
663
|
+
r = proxyResult.treeEventCallback.apply(proxyResult, [e, proxyResult.node]) && r;
|
664
|
+
}
|
665
|
+
}
|
666
|
+
return r;
|
667
|
+
}
|
668
|
+
},
|
669
|
+
//method of event handler
|
670
|
+
handler = {
|
671
|
+
onSwitchNode: function (event, node) {
|
672
|
+
var setting = data.getSetting(event.data.treeId);
|
673
|
+
if (node.open) {
|
674
|
+
if (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false) return true;
|
675
|
+
data.getRoot(setting).expandTriggerFlag = true;
|
676
|
+
view.switchNode(setting, node);
|
677
|
+
} else {
|
678
|
+
if (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false) return true;
|
679
|
+
data.getRoot(setting).expandTriggerFlag = true;
|
680
|
+
view.switchNode(setting, node);
|
681
|
+
}
|
682
|
+
return true;
|
683
|
+
},
|
684
|
+
onClickNode: function (event, node) {
|
685
|
+
var setting = data.getSetting(event.data.treeId),
|
686
|
+
clickFlag = ( (setting.view.autoCancelSelected && event.ctrlKey) && data.isSelectedNode(setting, node)) ? 0 : (setting.view.autoCancelSelected && event.ctrlKey && setting.view.selectedMulti) ? 2 : 1;
|
687
|
+
if (tools.apply(setting.callback.beforeClick, [setting.treeId, node, clickFlag], true) == false) return true;
|
688
|
+
if (clickFlag === 0) {
|
689
|
+
view.cancelPreSelectedNode(setting, node);
|
690
|
+
} else {
|
691
|
+
view.selectNode(setting, node, clickFlag === 2);
|
692
|
+
}
|
693
|
+
setting.treeObj.trigger(consts.event.CLICK, [event, setting.treeId, node, clickFlag]);
|
694
|
+
return true;
|
695
|
+
},
|
696
|
+
onZTreeMousedown: function(event, node) {
|
697
|
+
var setting = data.getSetting(event.data.treeId);
|
698
|
+
if (tools.apply(setting.callback.beforeMouseDown, [setting.treeId, node], true)) {
|
699
|
+
tools.apply(setting.callback.onMouseDown, [event, setting.treeId, node]);
|
700
|
+
}
|
701
|
+
return true;
|
702
|
+
},
|
703
|
+
onZTreeMouseup: function(event, node) {
|
704
|
+
var setting = data.getSetting(event.data.treeId);
|
705
|
+
if (tools.apply(setting.callback.beforeMouseUp, [setting.treeId, node], true)) {
|
706
|
+
tools.apply(setting.callback.onMouseUp, [event, setting.treeId, node]);
|
707
|
+
}
|
708
|
+
return true;
|
709
|
+
},
|
710
|
+
onZTreeDblclick: function(event, node) {
|
711
|
+
var setting = data.getSetting(event.data.treeId);
|
712
|
+
if (tools.apply(setting.callback.beforeDblClick, [setting.treeId, node], true)) {
|
713
|
+
tools.apply(setting.callback.onDblClick, [event, setting.treeId, node]);
|
714
|
+
}
|
715
|
+
return true;
|
716
|
+
},
|
717
|
+
onZTreeContextmenu: function(event, node) {
|
718
|
+
var setting = data.getSetting(event.data.treeId);
|
719
|
+
if (tools.apply(setting.callback.beforeRightClick, [setting.treeId, node], true)) {
|
720
|
+
tools.apply(setting.callback.onRightClick, [event, setting.treeId, node]);
|
721
|
+
}
|
722
|
+
return (typeof setting.callback.onRightClick) != "function";
|
723
|
+
}
|
724
|
+
},
|
725
|
+
//method of tools for zTree
|
726
|
+
tools = {
|
727
|
+
apply: function(fun, param, defaultValue) {
|
728
|
+
if ((typeof fun) == "function") {
|
729
|
+
return fun.apply(zt, param?param:[]);
|
730
|
+
}
|
731
|
+
return defaultValue;
|
732
|
+
},
|
733
|
+
canAsync: function(setting, node) {
|
734
|
+
var childKey = setting.data.key.children;
|
735
|
+
return (setting.async.enable && node && node.isParent && !(node.zAsync || (node[childKey] && node[childKey].length > 0)));
|
736
|
+
},
|
737
|
+
clone: function (obj){
|
738
|
+
if (obj === null) return null;
|
739
|
+
var o = obj.constructor === Array ? [] : {};
|
740
|
+
for(var i in obj){
|
741
|
+
o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()) : (typeof obj[i] === "object" ? arguments.callee(obj[i]) : obj[i]);
|
742
|
+
}
|
743
|
+
return o;
|
744
|
+
},
|
745
|
+
eqs: function(str1, str2) {
|
746
|
+
return str1.toLowerCase() === str2.toLowerCase();
|
747
|
+
},
|
748
|
+
isArray: function(arr) {
|
749
|
+
return Object.prototype.toString.apply(arr) === "[object Array]";
|
750
|
+
},
|
751
|
+
getMDom: function (setting, curDom, targetExpr) {
|
752
|
+
if (!curDom) return null;
|
753
|
+
while (curDom && curDom.id !== setting.treeId) {
|
754
|
+
for (var i=0, l=targetExpr.length; curDom.tagName && i<l; i++) {
|
755
|
+
if (tools.eqs(curDom.tagName, targetExpr[i].tagName) && curDom.getAttribute(targetExpr[i].attrName) !== null) {
|
756
|
+
return curDom;
|
757
|
+
}
|
758
|
+
}
|
759
|
+
curDom = curDom.parentNode;
|
760
|
+
}
|
761
|
+
return null;
|
762
|
+
},
|
763
|
+
uCanDo: function(setting, e) {
|
764
|
+
return true;
|
765
|
+
}
|
766
|
+
},
|
767
|
+
//method of operate ztree dom
|
768
|
+
view = {
|
769
|
+
addNodes: function(setting, parentNode, newNodes, isSilent) {
|
770
|
+
if (setting.data.keep.leaf && parentNode && !parentNode.isParent) {
|
771
|
+
return;
|
772
|
+
}
|
773
|
+
if (!tools.isArray(newNodes)) {
|
774
|
+
newNodes = [newNodes];
|
775
|
+
}
|
776
|
+
if (setting.data.simpleData.enable) {
|
777
|
+
newNodes = data.transformTozTreeFormat(setting, newNodes);
|
778
|
+
}
|
779
|
+
if (parentNode) {
|
780
|
+
var target_switchObj = $("#" + parentNode.tId + consts.id.SWITCH),
|
781
|
+
target_icoObj = $("#" + parentNode.tId + consts.id.ICON),
|
782
|
+
target_ulObj = $("#" + parentNode.tId + consts.id.UL);
|
783
|
+
|
784
|
+
if (!parentNode.open) {
|
785
|
+
view.replaceSwitchClass(parentNode, target_switchObj, consts.folder.CLOSE);
|
786
|
+
view.replaceIcoClass(parentNode, target_icoObj, consts.folder.CLOSE);
|
787
|
+
parentNode.open = false;
|
788
|
+
target_ulObj.css({
|
789
|
+
"display": "none"
|
790
|
+
});
|
791
|
+
}
|
792
|
+
|
793
|
+
data.addNodesData(setting, parentNode, newNodes);
|
794
|
+
view.createNodes(setting, parentNode.level + 1, newNodes, parentNode);
|
795
|
+
if (!isSilent) {
|
796
|
+
view.expandCollapseParentNode(setting, parentNode, true);
|
797
|
+
}
|
798
|
+
} else {
|
799
|
+
data.addNodesData(setting, data.getRoot(setting), newNodes);
|
800
|
+
view.createNodes(setting, 0, newNodes, null);
|
801
|
+
}
|
802
|
+
},
|
803
|
+
appendNodes: function(setting, level, nodes, parentNode, initFlag, openFlag) {
|
804
|
+
if (!nodes) return [];
|
805
|
+
var html = [],
|
806
|
+
childKey = setting.data.key.children;
|
807
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
808
|
+
var node = nodes[i];
|
809
|
+
if (initFlag) {
|
810
|
+
var tmpPNode = (parentNode) ? parentNode: data.getRoot(setting),
|
811
|
+
tmpPChild = tmpPNode[childKey],
|
812
|
+
isFirstNode = ((tmpPChild.length == nodes.length) && (i == 0)),
|
813
|
+
isLastNode = (i == (nodes.length - 1));
|
814
|
+
data.initNode(setting, level, node, parentNode, isFirstNode, isLastNode, openFlag);
|
815
|
+
data.addNodeCache(setting, node);
|
816
|
+
}
|
817
|
+
|
818
|
+
var childHtml = [];
|
819
|
+
if (node[childKey] && node[childKey].length > 0) {
|
820
|
+
//make child html first, because checkType
|
821
|
+
childHtml = view.appendNodes(setting, level + 1, node[childKey], node, initFlag, openFlag && node.open);
|
822
|
+
}
|
823
|
+
if (openFlag) {
|
824
|
+
|
825
|
+
view.makeDOMNodeMainBefore(html, setting, node);
|
826
|
+
view.makeDOMNodeLine(html, setting, node);
|
827
|
+
data.getBeforeA(setting, node, html);
|
828
|
+
view.makeDOMNodeNameBefore(html, setting, node);
|
829
|
+
data.getInnerBeforeA(setting, node, html);
|
830
|
+
view.makeDOMNodeIcon(html, setting, node);
|
831
|
+
data.getInnerAfterA(setting, node, html);
|
832
|
+
view.makeDOMNodeNameAfter(html, setting, node);
|
833
|
+
data.getAfterA(setting, node, html);
|
834
|
+
if (node.isParent && node.open) {
|
835
|
+
view.makeUlHtml(setting, node, html, childHtml.join(''));
|
836
|
+
}
|
837
|
+
view.makeDOMNodeMainAfter(html, setting, node);
|
838
|
+
data.addCreatedNode(setting, node);
|
839
|
+
}
|
840
|
+
}
|
841
|
+
return html;
|
842
|
+
},
|
843
|
+
appendParentULDom: function(setting, node) {
|
844
|
+
var html = [],
|
845
|
+
nObj = $("#" + node.tId),
|
846
|
+
ulObj = $("#" + node.tId + consts.id.UL),
|
847
|
+
childKey = setting.data.key.children,
|
848
|
+
childHtml = view.appendNodes(setting, node.level+1, node[childKey], node, false, true);
|
849
|
+
view.makeUlHtml(setting, node, html, childHtml.join(''));
|
850
|
+
if (!nObj.get(0) && !!node.parentTId) {
|
851
|
+
view.appendParentULDom(setting, node.getParentNode());
|
852
|
+
nObj = $("#" + node.tId);
|
853
|
+
}
|
854
|
+
if (ulObj.get(0)) {
|
855
|
+
ulObj.remove();
|
856
|
+
}
|
857
|
+
nObj.append(html.join(''));
|
858
|
+
},
|
859
|
+
asyncNode: function(setting, node, isSilent, callback) {
|
860
|
+
var i, l;
|
861
|
+
if (node && !node.isParent) {
|
862
|
+
tools.apply(callback);
|
863
|
+
return false;
|
864
|
+
} else if (node && node.isAjaxing) {
|
865
|
+
return false;
|
866
|
+
} else if (tools.apply(setting.callback.beforeAsync, [setting.treeId, node], true) == false) {
|
867
|
+
tools.apply(callback);
|
868
|
+
return false;
|
869
|
+
}
|
870
|
+
if (node) {
|
871
|
+
node.isAjaxing = true;
|
872
|
+
var icoObj = $("#" + node.tId + consts.id.ICON);
|
873
|
+
icoObj.attr({"style":"", "class":"button ico_loading"});
|
874
|
+
}
|
875
|
+
|
876
|
+
var tmpParam = {};
|
877
|
+
for (i = 0, l = setting.async.autoParam.length; node && i < l; i++) {
|
878
|
+
var pKey = setting.async.autoParam[i].split("="), spKey = pKey;
|
879
|
+
if (pKey.length>1) {
|
880
|
+
spKey = pKey[1];
|
881
|
+
pKey = pKey[0];
|
882
|
+
}
|
883
|
+
tmpParam[spKey] = node[pKey];
|
884
|
+
}
|
885
|
+
if (tools.isArray(setting.async.otherParam)) {
|
886
|
+
for (i = 0, l = setting.async.otherParam.length; i < l; i += 2) {
|
887
|
+
tmpParam[setting.async.otherParam[i]] = setting.async.otherParam[i + 1];
|
888
|
+
}
|
889
|
+
} else {
|
890
|
+
for (var p in setting.async.otherParam) {
|
891
|
+
tmpParam[p] = setting.async.otherParam[p];
|
892
|
+
}
|
893
|
+
}
|
894
|
+
|
895
|
+
var _tmpV = data.getRoot(setting)._ver;
|
896
|
+
$.ajax({
|
897
|
+
contentType: setting.async.contentType,
|
898
|
+
type: setting.async.type,
|
899
|
+
url: tools.apply(setting.async.url, [setting.treeId, node], setting.async.url),
|
900
|
+
data: tmpParam,
|
901
|
+
dataType: setting.async.dataType,
|
902
|
+
success: function(msg) {
|
903
|
+
if (_tmpV != data.getRoot(setting)._ver) {
|
904
|
+
return;
|
905
|
+
}
|
906
|
+
var newNodes = [];
|
907
|
+
try {
|
908
|
+
if (!msg || msg.length == 0) {
|
909
|
+
newNodes = [];
|
910
|
+
} else if (typeof msg == "string") {
|
911
|
+
newNodes = eval("(" + msg + ")");
|
912
|
+
} else {
|
913
|
+
newNodes = msg;
|
914
|
+
}
|
915
|
+
} catch(err) {
|
916
|
+
newNodes = msg;
|
917
|
+
}
|
918
|
+
|
919
|
+
if (node) {
|
920
|
+
node.isAjaxing = null;
|
921
|
+
node.zAsync = true;
|
922
|
+
}
|
923
|
+
view.setNodeLineIcos(setting, node);
|
924
|
+
if (newNodes && newNodes !== "") {
|
925
|
+
newNodes = tools.apply(setting.async.dataFilter, [setting.treeId, node, newNodes], newNodes);
|
926
|
+
view.addNodes(setting, node, !!newNodes ? tools.clone(newNodes) : [], !!isSilent);
|
927
|
+
} else {
|
928
|
+
view.addNodes(setting, node, [], !!isSilent);
|
929
|
+
}
|
930
|
+
setting.treeObj.trigger(consts.event.ASYNC_SUCCESS, [setting.treeId, node, msg]);
|
931
|
+
tools.apply(callback);
|
932
|
+
},
|
933
|
+
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
934
|
+
if (_tmpV != data.getRoot(setting)._ver) {
|
935
|
+
return;
|
936
|
+
}
|
937
|
+
if (node) node.isAjaxing = null;
|
938
|
+
view.setNodeLineIcos(setting, node);
|
939
|
+
setting.treeObj.trigger(consts.event.ASYNC_ERROR, [setting.treeId, node, XMLHttpRequest, textStatus, errorThrown]);
|
940
|
+
}
|
941
|
+
});
|
942
|
+
return true;
|
943
|
+
},
|
944
|
+
cancelPreSelectedNode: function (setting, node) {
|
945
|
+
var list = data.getRoot(setting).curSelectedList;
|
946
|
+
for (var i=0, j=list.length-1; j>=i; j--) {
|
947
|
+
if (!node || node === list[j]) {
|
948
|
+
$("#" + list[j].tId + consts.id.A).removeClass(consts.node.CURSELECTED);
|
949
|
+
if (node) {
|
950
|
+
data.removeSelectedNode(setting, node);
|
951
|
+
break;
|
952
|
+
}
|
953
|
+
}
|
954
|
+
}
|
955
|
+
if (!node) data.getRoot(setting).curSelectedList = [];
|
956
|
+
},
|
957
|
+
createNodeCallback: function(setting) {
|
958
|
+
if (!!setting.callback.onNodeCreated || !!setting.view.addDiyDom) {
|
959
|
+
var root = data.getRoot(setting);
|
960
|
+
while (root.createdNodes.length>0) {
|
961
|
+
var node = root.createdNodes.shift();
|
962
|
+
tools.apply(setting.view.addDiyDom, [setting.treeId, node]);
|
963
|
+
if (!!setting.callback.onNodeCreated) {
|
964
|
+
setting.treeObj.trigger(consts.event.NODECREATED, [setting.treeId, node]);
|
965
|
+
}
|
966
|
+
}
|
967
|
+
}
|
968
|
+
},
|
969
|
+
createNodes: function(setting, level, nodes, parentNode) {
|
970
|
+
if (!nodes || nodes.length == 0) return;
|
971
|
+
var root = data.getRoot(setting),
|
972
|
+
childKey = setting.data.key.children,
|
973
|
+
openFlag = !parentNode || parentNode.open || !!$("#" + parentNode[childKey][0].tId).get(0);
|
974
|
+
root.createdNodes = [];
|
975
|
+
var zTreeHtml = view.appendNodes(setting, level, nodes, parentNode, true, openFlag);
|
976
|
+
if (!parentNode) {
|
977
|
+
setting.treeObj.append(zTreeHtml.join(''));
|
978
|
+
} else {
|
979
|
+
var ulObj = $("#" + parentNode.tId + consts.id.UL);
|
980
|
+
if (ulObj.get(0)) {
|
981
|
+
ulObj.append(zTreeHtml.join(''));
|
982
|
+
}
|
983
|
+
}
|
984
|
+
view.createNodeCallback(setting);
|
985
|
+
},
|
986
|
+
destroy: function(setting) {
|
987
|
+
if (!setting) return;
|
988
|
+
data.initCache(setting);
|
989
|
+
data.initRoot(setting);
|
990
|
+
event.unbindTree(setting);
|
991
|
+
event.unbindEvent(setting);
|
992
|
+
setting.treeObj.empty();
|
993
|
+
},
|
994
|
+
expandCollapseNode: function(setting, node, expandFlag, animateFlag, callback) {
|
995
|
+
var root = data.getRoot(setting),
|
996
|
+
childKey = setting.data.key.children;
|
997
|
+
if (!node) {
|
998
|
+
tools.apply(callback, []);
|
999
|
+
return;
|
1000
|
+
}
|
1001
|
+
if (root.expandTriggerFlag) {
|
1002
|
+
var _callback = callback;
|
1003
|
+
callback = function(){
|
1004
|
+
if (_callback) _callback();
|
1005
|
+
if (node.open) {
|
1006
|
+
setting.treeObj.trigger(consts.event.EXPAND, [setting.treeId, node]);
|
1007
|
+
} else {
|
1008
|
+
setting.treeObj.trigger(consts.event.COLLAPSE, [setting.treeId, node]);
|
1009
|
+
}
|
1010
|
+
};
|
1011
|
+
root.expandTriggerFlag = false;
|
1012
|
+
}
|
1013
|
+
if (!node.open && node.isParent && ((!$("#" + node.tId + consts.id.UL).get(0)) || (node[childKey] && node[childKey].length>0 && !$("#" + node[childKey][0].tId).get(0)))) {
|
1014
|
+
view.appendParentULDom(setting, node);
|
1015
|
+
view.createNodeCallback(setting);
|
1016
|
+
}
|
1017
|
+
if (node.open == expandFlag) {
|
1018
|
+
tools.apply(callback, []);
|
1019
|
+
return;
|
1020
|
+
}
|
1021
|
+
var ulObj = $("#" + node.tId + consts.id.UL),
|
1022
|
+
switchObj = $("#" + node.tId + consts.id.SWITCH),
|
1023
|
+
icoObj = $("#" + node.tId + consts.id.ICON);
|
1024
|
+
|
1025
|
+
if (node.isParent) {
|
1026
|
+
node.open = !node.open;
|
1027
|
+
if (node.iconOpen && node.iconClose) {
|
1028
|
+
icoObj.attr("style", view.makeNodeIcoStyle(setting, node));
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
if (node.open) {
|
1032
|
+
view.replaceSwitchClass(node, switchObj, consts.folder.OPEN);
|
1033
|
+
view.replaceIcoClass(node, icoObj, consts.folder.OPEN);
|
1034
|
+
if (animateFlag == false || setting.view.expandSpeed == "") {
|
1035
|
+
ulObj.show();
|
1036
|
+
tools.apply(callback, []);
|
1037
|
+
} else {
|
1038
|
+
if (node[childKey] && node[childKey].length > 0) {
|
1039
|
+
ulObj.slideDown(setting.view.expandSpeed, callback);
|
1040
|
+
} else {
|
1041
|
+
ulObj.show();
|
1042
|
+
tools.apply(callback, []);
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
} else {
|
1046
|
+
view.replaceSwitchClass(node, switchObj, consts.folder.CLOSE);
|
1047
|
+
view.replaceIcoClass(node, icoObj, consts.folder.CLOSE);
|
1048
|
+
if (animateFlag == false || setting.view.expandSpeed == "" || !(node[childKey] && node[childKey].length > 0)) {
|
1049
|
+
ulObj.hide();
|
1050
|
+
tools.apply(callback, []);
|
1051
|
+
} else {
|
1052
|
+
ulObj.slideUp(setting.view.expandSpeed, callback);
|
1053
|
+
}
|
1054
|
+
}
|
1055
|
+
} else {
|
1056
|
+
tools.apply(callback, []);
|
1057
|
+
}
|
1058
|
+
},
|
1059
|
+
expandCollapseParentNode: function(setting, node, expandFlag, animateFlag, callback) {
|
1060
|
+
if (!node) return;
|
1061
|
+
if (!node.parentTId) {
|
1062
|
+
view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback);
|
1063
|
+
return;
|
1064
|
+
} else {
|
1065
|
+
view.expandCollapseNode(setting, node, expandFlag, animateFlag);
|
1066
|
+
}
|
1067
|
+
if (node.parentTId) {
|
1068
|
+
view.expandCollapseParentNode(setting, node.getParentNode(), expandFlag, animateFlag, callback);
|
1069
|
+
}
|
1070
|
+
},
|
1071
|
+
expandCollapseSonNode: function(setting, node, expandFlag, animateFlag, callback) {
|
1072
|
+
var root = data.getRoot(setting),
|
1073
|
+
childKey = setting.data.key.children,
|
1074
|
+
treeNodes = (node) ? node[childKey]: root[childKey],
|
1075
|
+
selfAnimateSign = (node) ? false : animateFlag,
|
1076
|
+
expandTriggerFlag = data.getRoot(setting).expandTriggerFlag;
|
1077
|
+
data.getRoot(setting).expandTriggerFlag = false;
|
1078
|
+
if (treeNodes) {
|
1079
|
+
for (var i = 0, l = treeNodes.length; i < l; i++) {
|
1080
|
+
if (treeNodes[i]) view.expandCollapseSonNode(setting, treeNodes[i], expandFlag, selfAnimateSign);
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
data.getRoot(setting).expandTriggerFlag = expandTriggerFlag;
|
1084
|
+
view.expandCollapseNode(setting, node, expandFlag, animateFlag, callback );
|
1085
|
+
},
|
1086
|
+
makeDOMNodeIcon: function(html, setting, node) {
|
1087
|
+
var nameStr = data.getNodeName(setting, node),
|
1088
|
+
name = setting.view.nameIsHTML ? nameStr : nameStr.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
1089
|
+
html.push("<span id='", node.tId, consts.id.ICON,
|
1090
|
+
"' title='' treeNode", consts.id.ICON," class='", view.makeNodeIcoClass(setting, node),
|
1091
|
+
"' style='", view.makeNodeIcoStyle(setting, node), "'></span><span id='", node.tId, consts.id.SPAN,
|
1092
|
+
"'>",name,"</span>");
|
1093
|
+
},
|
1094
|
+
makeDOMNodeLine: function(html, setting, node) {
|
1095
|
+
html.push("<span id='", node.tId, consts.id.SWITCH, "' title='' class='", view.makeNodeLineClass(setting, node), "' treeNode", consts.id.SWITCH,"></span>");
|
1096
|
+
},
|
1097
|
+
makeDOMNodeMainAfter: function(html, setting, node) {
|
1098
|
+
html.push("</li>");
|
1099
|
+
},
|
1100
|
+
makeDOMNodeMainBefore: function(html, setting, node) {
|
1101
|
+
html.push("<li id='", node.tId, "' class='level", node.level,"' tabindex='0' hidefocus='true' treenode>");
|
1102
|
+
},
|
1103
|
+
makeDOMNodeNameAfter: function(html, setting, node) {
|
1104
|
+
html.push("</a>");
|
1105
|
+
},
|
1106
|
+
makeDOMNodeNameBefore: function(html, setting, node) {
|
1107
|
+
var title = data.getNodeTitle(setting, node),
|
1108
|
+
url = view.makeNodeUrl(setting, node),
|
1109
|
+
fontcss = view.makeNodeFontCss(setting, node),
|
1110
|
+
fontStyle = [];
|
1111
|
+
for (var f in fontcss) {
|
1112
|
+
fontStyle.push(f, ":", fontcss[f], ";");
|
1113
|
+
}
|
1114
|
+
html.push("<a id='", node.tId, consts.id.A, "' class='level", node.level,"' treeNode", consts.id.A," onclick=\"", (node.click || ''),
|
1115
|
+
"\" ", ((url != null && url.length > 0) ? "href='" + url + "'" : ""), " target='",view.makeNodeTarget(node),"' style='", fontStyle.join(''),
|
1116
|
+
"'");
|
1117
|
+
if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle) && title) {html.push("title='", title.replace(/'/g,"'").replace(/</g,'<').replace(/>/g,'>'),"'");}
|
1118
|
+
html.push(">");
|
1119
|
+
},
|
1120
|
+
makeNodeFontCss: function(setting, node) {
|
1121
|
+
var fontCss = tools.apply(setting.view.fontCss, [setting.treeId, node], setting.view.fontCss);
|
1122
|
+
return (fontCss && ((typeof fontCss) != "function")) ? fontCss : {};
|
1123
|
+
},
|
1124
|
+
makeNodeIcoClass: function(setting, node) {
|
1125
|
+
var icoCss = ["ico"];
|
1126
|
+
if (!node.isAjaxing) {
|
1127
|
+
icoCss[0] = (node.iconSkin ? node.iconSkin + "_" : "") + icoCss[0];
|
1128
|
+
if (node.isParent) {
|
1129
|
+
icoCss.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE);
|
1130
|
+
} else {
|
1131
|
+
icoCss.push(consts.folder.DOCU);
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
return "button " + icoCss.join('_');
|
1135
|
+
},
|
1136
|
+
makeNodeIcoStyle: function(setting, node) {
|
1137
|
+
var icoStyle = [];
|
1138
|
+
if (!node.isAjaxing) {
|
1139
|
+
var icon = (node.isParent && node.iconOpen && node.iconClose) ? (node.open ? node.iconOpen : node.iconClose) : node.icon;
|
1140
|
+
if (icon) icoStyle.push("background:url(", icon, ") 0 0 no-repeat;");
|
1141
|
+
if (setting.view.showIcon == false || !tools.apply(setting.view.showIcon, [setting.treeId, node], true)) {
|
1142
|
+
icoStyle.push("width:0px;height:0px;");
|
1143
|
+
}
|
1144
|
+
}
|
1145
|
+
return icoStyle.join('');
|
1146
|
+
},
|
1147
|
+
makeNodeLineClass: function(setting, node) {
|
1148
|
+
var lineClass = [];
|
1149
|
+
if (setting.view.showLine) {
|
1150
|
+
if (node.level == 0 && node.isFirstNode && node.isLastNode) {
|
1151
|
+
lineClass.push(consts.line.ROOT);
|
1152
|
+
} else if (node.level == 0 && node.isFirstNode) {
|
1153
|
+
lineClass.push(consts.line.ROOTS);
|
1154
|
+
} else if (node.isLastNode) {
|
1155
|
+
lineClass.push(consts.line.BOTTOM);
|
1156
|
+
} else {
|
1157
|
+
lineClass.push(consts.line.CENTER);
|
1158
|
+
}
|
1159
|
+
} else {
|
1160
|
+
lineClass.push(consts.line.NOLINE);
|
1161
|
+
}
|
1162
|
+
if (node.isParent) {
|
1163
|
+
lineClass.push(node.open ? consts.folder.OPEN : consts.folder.CLOSE);
|
1164
|
+
} else {
|
1165
|
+
lineClass.push(consts.folder.DOCU);
|
1166
|
+
}
|
1167
|
+
return view.makeNodeLineClassEx(node) + lineClass.join('_');
|
1168
|
+
},
|
1169
|
+
makeNodeLineClassEx: function(node) {
|
1170
|
+
return "button level" + node.level + " switch ";
|
1171
|
+
},
|
1172
|
+
makeNodeTarget: function(node) {
|
1173
|
+
return (node.target || "_blank");
|
1174
|
+
},
|
1175
|
+
makeNodeUrl: function(setting, node) {
|
1176
|
+
var urlKey = setting.data.key.url;
|
1177
|
+
return node[urlKey] ? node[urlKey] : null;
|
1178
|
+
},
|
1179
|
+
makeUlHtml: function(setting, node, html, content) {
|
1180
|
+
html.push("<ul id='", node.tId, consts.id.UL, "' class='level", node.level, " ", view.makeUlLineClass(setting, node), "' style='display:", (node.open ? "block": "none"),"'>");
|
1181
|
+
html.push(content);
|
1182
|
+
html.push("</ul>");
|
1183
|
+
},
|
1184
|
+
makeUlLineClass: function(setting, node) {
|
1185
|
+
return ((setting.view.showLine && !node.isLastNode) ? consts.line.LINE : "");
|
1186
|
+
},
|
1187
|
+
removeChildNodes: function(setting, node) {
|
1188
|
+
if (!node) return;
|
1189
|
+
var childKey = setting.data.key.children,
|
1190
|
+
nodes = node[childKey];
|
1191
|
+
if (!nodes) return;
|
1192
|
+
|
1193
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
1194
|
+
data.removeNodeCache(setting, nodes[i]);
|
1195
|
+
}
|
1196
|
+
data.removeSelectedNode(setting);
|
1197
|
+
delete node[childKey];
|
1198
|
+
|
1199
|
+
if (!setting.data.keep.parent) {
|
1200
|
+
node.isParent = false;
|
1201
|
+
node.open = false;
|
1202
|
+
var tmp_switchObj = $("#" + node.tId + consts.id.SWITCH),
|
1203
|
+
tmp_icoObj = $("#" + node.tId + consts.id.ICON);
|
1204
|
+
view.replaceSwitchClass(node, tmp_switchObj, consts.folder.DOCU);
|
1205
|
+
view.replaceIcoClass(node, tmp_icoObj, consts.folder.DOCU);
|
1206
|
+
$("#" + node.tId + consts.id.UL).remove();
|
1207
|
+
} else {
|
1208
|
+
$("#" + node.tId + consts.id.UL).empty();
|
1209
|
+
}
|
1210
|
+
},
|
1211
|
+
setFirstNode: function(setting, parentNode) {
|
1212
|
+
var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
|
1213
|
+
if ( childLength > 0) {
|
1214
|
+
parentNode[childKey][0].isFirstNode = true;
|
1215
|
+
}
|
1216
|
+
},
|
1217
|
+
setLastNode: function(setting, parentNode) {
|
1218
|
+
var childKey = setting.data.key.children, childLength = parentNode[childKey].length;
|
1219
|
+
if ( childLength > 0) {
|
1220
|
+
parentNode[childKey][childLength - 1].isLastNode = true;
|
1221
|
+
}
|
1222
|
+
},
|
1223
|
+
removeNode: function(setting, node) {
|
1224
|
+
var root = data.getRoot(setting),
|
1225
|
+
childKey = setting.data.key.children,
|
1226
|
+
parentNode = (node.parentTId) ? node.getParentNode() : root;
|
1227
|
+
|
1228
|
+
node.isFirstNode = false;
|
1229
|
+
node.isLastNode = false;
|
1230
|
+
node.getPreNode = function() {return null;};
|
1231
|
+
node.getNextNode = function() {return null;};
|
1232
|
+
|
1233
|
+
if (!data.getNodeCache(setting, node.tId)) {
|
1234
|
+
return;
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
$("#" + node.tId).remove();
|
1238
|
+
data.removeNodeCache(setting, node);
|
1239
|
+
data.removeSelectedNode(setting, node);
|
1240
|
+
|
1241
|
+
for (var i = 0, l = parentNode[childKey].length; i < l; i++) {
|
1242
|
+
if (parentNode[childKey][i].tId == node.tId) {
|
1243
|
+
parentNode[childKey].splice(i, 1);
|
1244
|
+
break;
|
1245
|
+
}
|
1246
|
+
}
|
1247
|
+
view.setFirstNode(setting, parentNode);
|
1248
|
+
view.setLastNode(setting, parentNode);
|
1249
|
+
|
1250
|
+
var tmp_ulObj,tmp_switchObj,tmp_icoObj,
|
1251
|
+
childLength = parentNode[childKey].length;
|
1252
|
+
|
1253
|
+
//repair nodes old parent
|
1254
|
+
if (!setting.data.keep.parent && childLength == 0) {
|
1255
|
+
//old parentNode has no child nodes
|
1256
|
+
parentNode.isParent = false;
|
1257
|
+
parentNode.open = false;
|
1258
|
+
tmp_ulObj = $("#" + parentNode.tId + consts.id.UL);
|
1259
|
+
tmp_switchObj = $("#" + parentNode.tId + consts.id.SWITCH);
|
1260
|
+
tmp_icoObj = $("#" + parentNode.tId + consts.id.ICON);
|
1261
|
+
view.replaceSwitchClass(parentNode, tmp_switchObj, consts.folder.DOCU);
|
1262
|
+
view.replaceIcoClass(parentNode, tmp_icoObj, consts.folder.DOCU);
|
1263
|
+
tmp_ulObj.css("display", "none");
|
1264
|
+
|
1265
|
+
} else if (setting.view.showLine && childLength > 0) {
|
1266
|
+
//old parentNode has child nodes
|
1267
|
+
var newLast = parentNode[childKey][childLength - 1];
|
1268
|
+
tmp_ulObj = $("#" + newLast.tId + consts.id.UL);
|
1269
|
+
tmp_switchObj = $("#" + newLast.tId + consts.id.SWITCH);
|
1270
|
+
tmp_icoObj = $("#" + newLast.tId + consts.id.ICON);
|
1271
|
+
if (parentNode == root) {
|
1272
|
+
if (parentNode[childKey].length == 1) {
|
1273
|
+
//node was root, and ztree has only one root after move node
|
1274
|
+
view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.ROOT);
|
1275
|
+
} else {
|
1276
|
+
var tmp_first_switchObj = $("#" + parentNode[childKey][0].tId + consts.id.SWITCH);
|
1277
|
+
view.replaceSwitchClass(parentNode[childKey][0], tmp_first_switchObj, consts.line.ROOTS);
|
1278
|
+
view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM);
|
1279
|
+
}
|
1280
|
+
} else {
|
1281
|
+
view.replaceSwitchClass(newLast, tmp_switchObj, consts.line.BOTTOM);
|
1282
|
+
}
|
1283
|
+
tmp_ulObj.removeClass(consts.line.LINE);
|
1284
|
+
}
|
1285
|
+
},
|
1286
|
+
replaceIcoClass: function(node, obj, newName) {
|
1287
|
+
if (!obj || node.isAjaxing) return;
|
1288
|
+
var tmpName = obj.attr("class");
|
1289
|
+
if (tmpName == undefined) return;
|
1290
|
+
var tmpList = tmpName.split("_");
|
1291
|
+
switch (newName) {
|
1292
|
+
case consts.folder.OPEN:
|
1293
|
+
case consts.folder.CLOSE:
|
1294
|
+
case consts.folder.DOCU:
|
1295
|
+
tmpList[tmpList.length-1] = newName;
|
1296
|
+
break;
|
1297
|
+
}
|
1298
|
+
obj.attr("class", tmpList.join("_"));
|
1299
|
+
},
|
1300
|
+
replaceSwitchClass: function(node, obj, newName) {
|
1301
|
+
if (!obj) return;
|
1302
|
+
var tmpName = obj.attr("class");
|
1303
|
+
if (tmpName == undefined) return;
|
1304
|
+
var tmpList = tmpName.split("_");
|
1305
|
+
switch (newName) {
|
1306
|
+
case consts.line.ROOT:
|
1307
|
+
case consts.line.ROOTS:
|
1308
|
+
case consts.line.CENTER:
|
1309
|
+
case consts.line.BOTTOM:
|
1310
|
+
case consts.line.NOLINE:
|
1311
|
+
tmpList[0] = view.makeNodeLineClassEx(node) + newName;
|
1312
|
+
break;
|
1313
|
+
case consts.folder.OPEN:
|
1314
|
+
case consts.folder.CLOSE:
|
1315
|
+
case consts.folder.DOCU:
|
1316
|
+
tmpList[1] = newName;
|
1317
|
+
break;
|
1318
|
+
}
|
1319
|
+
obj.attr("class", tmpList.join("_"));
|
1320
|
+
if (newName !== consts.folder.DOCU) {
|
1321
|
+
obj.removeAttr("disabled");
|
1322
|
+
} else {
|
1323
|
+
obj.attr("disabled", "disabled");
|
1324
|
+
}
|
1325
|
+
},
|
1326
|
+
selectNode: function(setting, node, addFlag) {
|
1327
|
+
if (!addFlag) {
|
1328
|
+
view.cancelPreSelectedNode(setting);
|
1329
|
+
}
|
1330
|
+
$("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED);
|
1331
|
+
data.addSelectedNode(setting, node);
|
1332
|
+
},
|
1333
|
+
setNodeFontCss: function(setting, treeNode) {
|
1334
|
+
var aObj = $("#" + treeNode.tId + consts.id.A),
|
1335
|
+
fontCss = view.makeNodeFontCss(setting, treeNode);
|
1336
|
+
if (fontCss) {
|
1337
|
+
aObj.css(fontCss);
|
1338
|
+
}
|
1339
|
+
},
|
1340
|
+
setNodeLineIcos: function(setting, node) {
|
1341
|
+
if (!node) return;
|
1342
|
+
var switchObj = $("#" + node.tId + consts.id.SWITCH),
|
1343
|
+
ulObj = $("#" + node.tId + consts.id.UL),
|
1344
|
+
icoObj = $("#" + node.tId + consts.id.ICON),
|
1345
|
+
ulLine = view.makeUlLineClass(setting, node);
|
1346
|
+
if (ulLine.length==0) {
|
1347
|
+
ulObj.removeClass(consts.line.LINE);
|
1348
|
+
} else {
|
1349
|
+
ulObj.addClass(ulLine);
|
1350
|
+
}
|
1351
|
+
switchObj.attr("class", view.makeNodeLineClass(setting, node));
|
1352
|
+
if (node.isParent) {
|
1353
|
+
switchObj.removeAttr("disabled");
|
1354
|
+
} else {
|
1355
|
+
switchObj.attr("disabled", "disabled");
|
1356
|
+
}
|
1357
|
+
icoObj.removeAttr("style");
|
1358
|
+
icoObj.attr("style", view.makeNodeIcoStyle(setting, node));
|
1359
|
+
icoObj.attr("class", view.makeNodeIcoClass(setting, node));
|
1360
|
+
},
|
1361
|
+
setNodeName: function(setting, node) {
|
1362
|
+
var title = data.getNodeTitle(setting, node),
|
1363
|
+
nObj = $("#" + node.tId + consts.id.SPAN);
|
1364
|
+
nObj.empty();
|
1365
|
+
if (setting.view.nameIsHTML) {
|
1366
|
+
nObj.html(data.getNodeName(setting, node));
|
1367
|
+
} else {
|
1368
|
+
nObj.text(data.getNodeName(setting, node));
|
1369
|
+
}
|
1370
|
+
if (tools.apply(setting.view.showTitle, [setting.treeId, node], setting.view.showTitle)) {
|
1371
|
+
var aObj = $("#" + node.tId + consts.id.A);
|
1372
|
+
aObj.attr("title", !title ? "" : title);
|
1373
|
+
}
|
1374
|
+
},
|
1375
|
+
setNodeTarget: function(node) {
|
1376
|
+
var aObj = $("#" + node.tId + consts.id.A);
|
1377
|
+
aObj.attr("target", view.makeNodeTarget(node));
|
1378
|
+
},
|
1379
|
+
setNodeUrl: function(setting, node) {
|
1380
|
+
var aObj = $("#" + node.tId + consts.id.A),
|
1381
|
+
url = view.makeNodeUrl(setting, node);
|
1382
|
+
if (url == null || url.length == 0) {
|
1383
|
+
aObj.removeAttr("href");
|
1384
|
+
} else {
|
1385
|
+
aObj.attr("href", url);
|
1386
|
+
}
|
1387
|
+
},
|
1388
|
+
switchNode: function(setting, node) {
|
1389
|
+
if (node.open || !tools.canAsync(setting, node)) {
|
1390
|
+
view.expandCollapseNode(setting, node, !node.open);
|
1391
|
+
} else if (setting.async.enable) {
|
1392
|
+
if (!view.asyncNode(setting, node)) {
|
1393
|
+
view.expandCollapseNode(setting, node, !node.open);
|
1394
|
+
return;
|
1395
|
+
}
|
1396
|
+
} else if (node) {
|
1397
|
+
view.expandCollapseNode(setting, node, !node.open);
|
1398
|
+
}
|
1399
|
+
}
|
1400
|
+
};
|
1401
|
+
// zTree defind
|
1402
|
+
$.fn.zTree = {
|
1403
|
+
consts : _consts,
|
1404
|
+
_z : {
|
1405
|
+
tools: tools,
|
1406
|
+
view: view,
|
1407
|
+
event: event,
|
1408
|
+
data: data
|
1409
|
+
},
|
1410
|
+
getZTreeObj: function(treeId) {
|
1411
|
+
var o = data.getZTreeTools(treeId);
|
1412
|
+
return o ? o : null;
|
1413
|
+
},
|
1414
|
+
destroy: function(treeId) {
|
1415
|
+
if (!!treeId && treeId.length > 0) {
|
1416
|
+
view.destroy(data.getSetting(treeId));
|
1417
|
+
} else {
|
1418
|
+
for(var s in settings) {
|
1419
|
+
view.destroy(settings[s]);
|
1420
|
+
}
|
1421
|
+
}
|
1422
|
+
},
|
1423
|
+
init: function(obj, zSetting, zNodes) {
|
1424
|
+
var setting = tools.clone(_setting);
|
1425
|
+
$.extend(true, setting, zSetting);
|
1426
|
+
setting.treeId = obj.attr("id");
|
1427
|
+
setting.treeObj = obj;
|
1428
|
+
setting.treeObj.empty();
|
1429
|
+
settings[setting.treeId] = setting;
|
1430
|
+
//For some older browser,(e.g., ie6)
|
1431
|
+
if(typeof document.body.style.maxHeight === "undefined") {
|
1432
|
+
setting.view.expandSpeed = "";
|
1433
|
+
}
|
1434
|
+
data.initRoot(setting);
|
1435
|
+
var root = data.getRoot(setting),
|
1436
|
+
childKey = setting.data.key.children;
|
1437
|
+
zNodes = zNodes ? tools.clone(tools.isArray(zNodes)? zNodes : [zNodes]) : [];
|
1438
|
+
if (setting.data.simpleData.enable) {
|
1439
|
+
root[childKey] = data.transformTozTreeFormat(setting, zNodes);
|
1440
|
+
} else {
|
1441
|
+
root[childKey] = zNodes;
|
1442
|
+
}
|
1443
|
+
|
1444
|
+
data.initCache(setting);
|
1445
|
+
event.unbindTree(setting);
|
1446
|
+
event.bindTree(setting);
|
1447
|
+
event.unbindEvent(setting);
|
1448
|
+
event.bindEvent(setting);
|
1449
|
+
|
1450
|
+
var zTreeTools = {
|
1451
|
+
setting : setting,
|
1452
|
+
addNodes : function(parentNode, newNodes, isSilent) {
|
1453
|
+
if (!newNodes) return null;
|
1454
|
+
if (!parentNode) parentNode = null;
|
1455
|
+
if (parentNode && !parentNode.isParent && setting.data.keep.leaf) return null;
|
1456
|
+
var xNewNodes = tools.clone(tools.isArray(newNodes)? newNodes: [newNodes]);
|
1457
|
+
function addCallback() {
|
1458
|
+
view.addNodes(setting, parentNode, xNewNodes, (isSilent==true));
|
1459
|
+
}
|
1460
|
+
|
1461
|
+
if (tools.canAsync(setting, parentNode)) {
|
1462
|
+
view.asyncNode(setting, parentNode, isSilent, addCallback);
|
1463
|
+
} else {
|
1464
|
+
addCallback();
|
1465
|
+
}
|
1466
|
+
return xNewNodes;
|
1467
|
+
},
|
1468
|
+
cancelSelectedNode : function(node) {
|
1469
|
+
view.cancelPreSelectedNode(this.setting, node);
|
1470
|
+
},
|
1471
|
+
destroy : function() {
|
1472
|
+
view.destroy(this.setting);
|
1473
|
+
},
|
1474
|
+
expandAll : function(expandFlag) {
|
1475
|
+
expandFlag = !!expandFlag;
|
1476
|
+
view.expandCollapseSonNode(this.setting, null, expandFlag, true);
|
1477
|
+
return expandFlag;
|
1478
|
+
},
|
1479
|
+
expandNode : function(node, expandFlag, sonSign, focus, callbackFlag) {
|
1480
|
+
if (!node || !node.isParent) return null;
|
1481
|
+
if (expandFlag !== true && expandFlag !== false) {
|
1482
|
+
expandFlag = !node.open;
|
1483
|
+
}
|
1484
|
+
callbackFlag = !!callbackFlag;
|
1485
|
+
|
1486
|
+
if (callbackFlag && expandFlag && (tools.apply(setting.callback.beforeExpand, [setting.treeId, node], true) == false)) {
|
1487
|
+
return null;
|
1488
|
+
} else if (callbackFlag && !expandFlag && (tools.apply(setting.callback.beforeCollapse, [setting.treeId, node], true) == false)) {
|
1489
|
+
return null;
|
1490
|
+
}
|
1491
|
+
if (expandFlag && node.parentTId) {
|
1492
|
+
view.expandCollapseParentNode(this.setting, node.getParentNode(), expandFlag, false);
|
1493
|
+
}
|
1494
|
+
if (expandFlag === node.open && !sonSign) {
|
1495
|
+
return null;
|
1496
|
+
}
|
1497
|
+
|
1498
|
+
data.getRoot(setting).expandTriggerFlag = callbackFlag;
|
1499
|
+
if (sonSign) {
|
1500
|
+
view.expandCollapseSonNode(this.setting, node, expandFlag, true, function() {
|
1501
|
+
if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}}
|
1502
|
+
});
|
1503
|
+
} else {
|
1504
|
+
node.open = !expandFlag;
|
1505
|
+
view.switchNode(this.setting, node);
|
1506
|
+
if (focus !== false) {try{$("#" + node.tId).focus().blur();}catch(e){}}
|
1507
|
+
}
|
1508
|
+
return expandFlag;
|
1509
|
+
},
|
1510
|
+
getNodes : function() {
|
1511
|
+
return data.getNodes(this.setting);
|
1512
|
+
},
|
1513
|
+
getNodeByParam : function(key, value, parentNode) {
|
1514
|
+
if (!key) return null;
|
1515
|
+
return data.getNodeByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value);
|
1516
|
+
},
|
1517
|
+
getNodeByTId : function(tId) {
|
1518
|
+
return data.getNodeCache(this.setting, tId);
|
1519
|
+
},
|
1520
|
+
getNodesByParam : function(key, value, parentNode) {
|
1521
|
+
if (!key) return null;
|
1522
|
+
return data.getNodesByParam(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value);
|
1523
|
+
},
|
1524
|
+
getNodesByParamFuzzy : function(key, value, parentNode) {
|
1525
|
+
if (!key) return null;
|
1526
|
+
return data.getNodesByParamFuzzy(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), key, value);
|
1527
|
+
},
|
1528
|
+
getNodesByFilter: function(filter, isSingle, parentNode, invokeParam) {
|
1529
|
+
isSingle = !!isSingle;
|
1530
|
+
if (!filter || (typeof filter != "function")) return (isSingle ? null : []);
|
1531
|
+
return data.getNodesByFilter(this.setting, parentNode?parentNode[this.setting.data.key.children]:data.getNodes(this.setting), filter, isSingle, invokeParam);
|
1532
|
+
},
|
1533
|
+
getNodeIndex : function(node) {
|
1534
|
+
if (!node) return null;
|
1535
|
+
var childKey = setting.data.key.children,
|
1536
|
+
parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(this.setting);
|
1537
|
+
for (var i=0, l = parentNode[childKey].length; i < l; i++) {
|
1538
|
+
if (parentNode[childKey][i] == node) return i;
|
1539
|
+
}
|
1540
|
+
return -1;
|
1541
|
+
},
|
1542
|
+
getSelectedNodes : function() {
|
1543
|
+
var r = [], list = data.getRoot(this.setting).curSelectedList;
|
1544
|
+
for (var i=0, l=list.length; i<l; i++) {
|
1545
|
+
r.push(list[i]);
|
1546
|
+
}
|
1547
|
+
return r;
|
1548
|
+
},
|
1549
|
+
isSelectedNode : function(node) {
|
1550
|
+
return data.isSelectedNode(this.setting, node);
|
1551
|
+
},
|
1552
|
+
reAsyncChildNodes : function(parentNode, reloadType, isSilent) {
|
1553
|
+
if (!this.setting.async.enable) return;
|
1554
|
+
var isRoot = !parentNode;
|
1555
|
+
if (isRoot) {
|
1556
|
+
parentNode = data.getRoot(this.setting);
|
1557
|
+
}
|
1558
|
+
if (reloadType=="refresh") {
|
1559
|
+
var childKey = this.setting.data.key.children;
|
1560
|
+
for (var i = 0, l = parentNode[childKey] ? parentNode[childKey].length : 0; i < l; i++) {
|
1561
|
+
data.removeNodeCache(setting, parentNode[childKey][i]);
|
1562
|
+
}
|
1563
|
+
data.removeSelectedNode(setting);
|
1564
|
+
parentNode[childKey] = [];
|
1565
|
+
if (isRoot) {
|
1566
|
+
this.setting.treeObj.empty();
|
1567
|
+
} else {
|
1568
|
+
var ulObj = $("#" + parentNode.tId + consts.id.UL);
|
1569
|
+
ulObj.empty();
|
1570
|
+
}
|
1571
|
+
}
|
1572
|
+
view.asyncNode(this.setting, isRoot? null:parentNode, !!isSilent);
|
1573
|
+
},
|
1574
|
+
refresh : function() {
|
1575
|
+
this.setting.treeObj.empty();
|
1576
|
+
var root = data.getRoot(this.setting),
|
1577
|
+
nodes = root[this.setting.data.key.children]
|
1578
|
+
data.initRoot(this.setting);
|
1579
|
+
root[this.setting.data.key.children] = nodes
|
1580
|
+
data.initCache(this.setting);
|
1581
|
+
view.createNodes(this.setting, 0, root[this.setting.data.key.children]);
|
1582
|
+
},
|
1583
|
+
removeChildNodes : function(node) {
|
1584
|
+
if (!node) return null;
|
1585
|
+
var childKey = setting.data.key.children,
|
1586
|
+
nodes = node[childKey];
|
1587
|
+
view.removeChildNodes(setting, node);
|
1588
|
+
return nodes ? nodes : null;
|
1589
|
+
},
|
1590
|
+
removeNode : function(node, callbackFlag) {
|
1591
|
+
if (!node) return;
|
1592
|
+
callbackFlag = !!callbackFlag;
|
1593
|
+
if (callbackFlag && tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return;
|
1594
|
+
view.removeNode(setting, node);
|
1595
|
+
if (callbackFlag) {
|
1596
|
+
this.setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]);
|
1597
|
+
}
|
1598
|
+
},
|
1599
|
+
selectNode : function(node, addFlag) {
|
1600
|
+
if (!node) return;
|
1601
|
+
if (tools.uCanDo(this.setting)) {
|
1602
|
+
addFlag = setting.view.selectedMulti && addFlag;
|
1603
|
+
if (node.parentTId) {
|
1604
|
+
view.expandCollapseParentNode(this.setting, node.getParentNode(), true, false, function() {
|
1605
|
+
try{$("#" + node.tId).focus().blur();}catch(e){}
|
1606
|
+
});
|
1607
|
+
} else {
|
1608
|
+
try{$("#" + node.tId).focus().blur();}catch(e){}
|
1609
|
+
}
|
1610
|
+
view.selectNode(this.setting, node, addFlag);
|
1611
|
+
}
|
1612
|
+
},
|
1613
|
+
transformTozTreeNodes : function(simpleNodes) {
|
1614
|
+
return data.transformTozTreeFormat(this.setting, simpleNodes);
|
1615
|
+
},
|
1616
|
+
transformToArray : function(nodes) {
|
1617
|
+
return data.transformToArrayFormat(this.setting, nodes);
|
1618
|
+
},
|
1619
|
+
updateNode : function(node, checkTypeFlag) {
|
1620
|
+
if (!node) return;
|
1621
|
+
var nObj = $("#" + node.tId);
|
1622
|
+
if (nObj.get(0) && tools.uCanDo(this.setting)) {
|
1623
|
+
view.setNodeName(this.setting, node);
|
1624
|
+
view.setNodeTarget(node);
|
1625
|
+
view.setNodeUrl(this.setting, node);
|
1626
|
+
view.setNodeLineIcos(this.setting, node);
|
1627
|
+
view.setNodeFontCss(this.setting, node);
|
1628
|
+
}
|
1629
|
+
}
|
1630
|
+
}
|
1631
|
+
root.treeTools = zTreeTools;
|
1632
|
+
data.setZTreeTools(setting, zTreeTools);
|
1633
|
+
|
1634
|
+
if (root[childKey] && root[childKey].length > 0) {
|
1635
|
+
view.createNodes(setting, 0, root[childKey]);
|
1636
|
+
} else if (setting.async.enable && setting.async.url && setting.async.url !== '') {
|
1637
|
+
view.asyncNode(setting);
|
1638
|
+
}
|
1639
|
+
return zTreeTools;
|
1640
|
+
}
|
1641
|
+
};
|
1642
|
+
|
1643
|
+
var zt = $.fn.zTree,
|
1644
|
+
consts = zt.consts;
|
1645
|
+
})(jQuery);
|
1646
|
+
/*
|
1647
|
+
* JQuery zTree excheck 3.5.02
|
1648
|
+
* http://zTree.me/
|
1649
|
+
*
|
1650
|
+
* Copyright (c) 2010 Hunter.z
|
1651
|
+
*
|
1652
|
+
* Licensed same as jquery - MIT License
|
1653
|
+
* http://www.opensource.org/licenses/mit-license.php
|
1654
|
+
*
|
1655
|
+
* email: hunter.z@263.net
|
1656
|
+
* Date: 2013-01-28
|
1657
|
+
*/
|
1658
|
+
(function($){
|
1659
|
+
//default consts of excheck
|
1660
|
+
var _consts = {
|
1661
|
+
event: {
|
1662
|
+
CHECK: "ztree_check"
|
1663
|
+
},
|
1664
|
+
id: {
|
1665
|
+
CHECK: "_check"
|
1666
|
+
},
|
1667
|
+
checkbox: {
|
1668
|
+
STYLE: "checkbox",
|
1669
|
+
DEFAULT: "chk",
|
1670
|
+
DISABLED: "disable",
|
1671
|
+
FALSE: "false",
|
1672
|
+
TRUE: "true",
|
1673
|
+
FULL: "full",
|
1674
|
+
PART: "part",
|
1675
|
+
FOCUS: "focus"
|
1676
|
+
},
|
1677
|
+
radio: {
|
1678
|
+
STYLE: "radio",
|
1679
|
+
TYPE_ALL: "all",
|
1680
|
+
TYPE_LEVEL: "level"
|
1681
|
+
}
|
1682
|
+
},
|
1683
|
+
//default setting of excheck
|
1684
|
+
_setting = {
|
1685
|
+
check: {
|
1686
|
+
enable: false,
|
1687
|
+
autoCheckTrigger: false,
|
1688
|
+
chkStyle: _consts.checkbox.STYLE,
|
1689
|
+
nocheckInherit: false,
|
1690
|
+
chkDisabledInherit: false,
|
1691
|
+
radioType: _consts.radio.TYPE_LEVEL,
|
1692
|
+
chkboxType: {
|
1693
|
+
"Y": "ps",
|
1694
|
+
"N": "ps"
|
1695
|
+
}
|
1696
|
+
},
|
1697
|
+
data: {
|
1698
|
+
key: {
|
1699
|
+
checked: "checked"
|
1700
|
+
}
|
1701
|
+
},
|
1702
|
+
callback: {
|
1703
|
+
beforeCheck:null,
|
1704
|
+
onCheck:null
|
1705
|
+
}
|
1706
|
+
},
|
1707
|
+
//default root of excheck
|
1708
|
+
_initRoot = function (setting) {
|
1709
|
+
var r = data.getRoot(setting);
|
1710
|
+
r.radioCheckedList = [];
|
1711
|
+
},
|
1712
|
+
//default cache of excheck
|
1713
|
+
_initCache = function(treeId) {},
|
1714
|
+
//default bind event of excheck
|
1715
|
+
_bindEvent = function(setting) {
|
1716
|
+
var o = setting.treeObj,
|
1717
|
+
c = consts.event;
|
1718
|
+
o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
|
1719
|
+
tools.apply(setting.callback.onCheck, [!!srcEvent?srcEvent : event, treeId, node]);
|
1720
|
+
});
|
1721
|
+
},
|
1722
|
+
_unbindEvent = function(setting) {
|
1723
|
+
var o = setting.treeObj,
|
1724
|
+
c = consts.event;
|
1725
|
+
o.unbind(c.CHECK);
|
1726
|
+
},
|
1727
|
+
//default event proxy of excheck
|
1728
|
+
_eventProxy = function(e) {
|
1729
|
+
var target = e.target,
|
1730
|
+
setting = data.getSetting(e.data.treeId),
|
1731
|
+
tId = "", node = null,
|
1732
|
+
nodeEventType = "", treeEventType = "",
|
1733
|
+
nodeEventCallback = null, treeEventCallback = null;
|
1734
|
+
|
1735
|
+
if (tools.eqs(e.type, "mouseover")) {
|
1736
|
+
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
1737
|
+
tId = target.parentNode.id;
|
1738
|
+
nodeEventType = "mouseoverCheck";
|
1739
|
+
}
|
1740
|
+
} else if (tools.eqs(e.type, "mouseout")) {
|
1741
|
+
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
1742
|
+
tId = target.parentNode.id;
|
1743
|
+
nodeEventType = "mouseoutCheck";
|
1744
|
+
}
|
1745
|
+
} else if (tools.eqs(e.type, "click")) {
|
1746
|
+
if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
|
1747
|
+
tId = target.parentNode.id;
|
1748
|
+
nodeEventType = "checkNode";
|
1749
|
+
}
|
1750
|
+
}
|
1751
|
+
if (tId.length>0) {
|
1752
|
+
node = data.getNodeCache(setting, tId);
|
1753
|
+
switch (nodeEventType) {
|
1754
|
+
case "checkNode" :
|
1755
|
+
nodeEventCallback = _handler.onCheckNode;
|
1756
|
+
break;
|
1757
|
+
case "mouseoverCheck" :
|
1758
|
+
nodeEventCallback = _handler.onMouseoverCheck;
|
1759
|
+
break;
|
1760
|
+
case "mouseoutCheck" :
|
1761
|
+
nodeEventCallback = _handler.onMouseoutCheck;
|
1762
|
+
break;
|
1763
|
+
}
|
1764
|
+
}
|
1765
|
+
var proxyResult = {
|
1766
|
+
stop: false,
|
1767
|
+
node: node,
|
1768
|
+
nodeEventType: nodeEventType,
|
1769
|
+
nodeEventCallback: nodeEventCallback,
|
1770
|
+
treeEventType: treeEventType,
|
1771
|
+
treeEventCallback: treeEventCallback
|
1772
|
+
};
|
1773
|
+
return proxyResult
|
1774
|
+
},
|
1775
|
+
//default init node of excheck
|
1776
|
+
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
|
1777
|
+
if (!n) return;
|
1778
|
+
var checkedKey = setting.data.key.checked;
|
1779
|
+
if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
|
1780
|
+
n[checkedKey] = !!n[checkedKey];
|
1781
|
+
n.checkedOld = n[checkedKey];
|
1782
|
+
if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
|
1783
|
+
n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
|
1784
|
+
if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
|
1785
|
+
n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
|
1786
|
+
if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
|
1787
|
+
n.halfCheck = !!n.halfCheck;
|
1788
|
+
n.check_Child_State = -1;
|
1789
|
+
n.check_Focus = false;
|
1790
|
+
n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
|
1791
|
+
},
|
1792
|
+
//add dom for check
|
1793
|
+
_beforeA = function(setting, node, html) {
|
1794
|
+
var checkedKey = setting.data.key.checked;
|
1795
|
+
if (setting.check.enable) {
|
1796
|
+
data.makeChkFlag(setting, node);
|
1797
|
+
if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && node[checkedKey] ) {
|
1798
|
+
var r = data.getRoot(setting);
|
1799
|
+
r.radioCheckedList.push(node);
|
1800
|
+
}
|
1801
|
+
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>");
|
1802
|
+
}
|
1803
|
+
},
|
1804
|
+
//update zTreeObj, add method of check
|
1805
|
+
_zTreeTools = function(setting, zTreeTools) {
|
1806
|
+
zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
|
1807
|
+
var checkedKey = this.setting.data.key.checked;
|
1808
|
+
if (node.chkDisabled === true) return;
|
1809
|
+
if (checked !== true && checked !== false) {
|
1810
|
+
checked = !node[checkedKey];
|
1811
|
+
}
|
1812
|
+
callbackFlag = !!callbackFlag;
|
1813
|
+
|
1814
|
+
if (node[checkedKey] === checked && !checkTypeFlag) {
|
1815
|
+
return;
|
1816
|
+
} else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
|
1817
|
+
return;
|
1818
|
+
}
|
1819
|
+
if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
|
1820
|
+
node[checkedKey] = checked;
|
1821
|
+
var checkObj = $("#" + node.tId + consts.id.CHECK);
|
1822
|
+
if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
1823
|
+
view.setChkClass(this.setting, checkObj, node);
|
1824
|
+
view.repairParentChkClassWithSelf(this.setting, node);
|
1825
|
+
if (callbackFlag) {
|
1826
|
+
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
1827
|
+
}
|
1828
|
+
}
|
1829
|
+
}
|
1830
|
+
|
1831
|
+
zTreeTools.checkAllNodes = function(checked) {
|
1832
|
+
view.repairAllChk(this.setting, !!checked);
|
1833
|
+
}
|
1834
|
+
|
1835
|
+
zTreeTools.getCheckedNodes = function(checked) {
|
1836
|
+
var childKey = this.setting.data.key.children;
|
1837
|
+
checked = (checked !== false);
|
1838
|
+
return data.getTreeCheckedNodes(this.setting, data.getRoot(setting)[childKey], checked);
|
1839
|
+
}
|
1840
|
+
|
1841
|
+
zTreeTools.getChangeCheckedNodes = function() {
|
1842
|
+
var childKey = this.setting.data.key.children;
|
1843
|
+
return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(setting)[childKey]);
|
1844
|
+
}
|
1845
|
+
|
1846
|
+
zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
|
1847
|
+
disabled = !!disabled;
|
1848
|
+
inheritParent = !!inheritParent;
|
1849
|
+
inheritChildren = !!inheritChildren;
|
1850
|
+
view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
|
1851
|
+
view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
|
1852
|
+
}
|
1853
|
+
|
1854
|
+
var _updateNode = zTreeTools.updateNode;
|
1855
|
+
zTreeTools.updateNode = function(node, checkTypeFlag) {
|
1856
|
+
if (_updateNode) _updateNode.apply(zTreeTools, arguments);
|
1857
|
+
if (!node || !this.setting.check.enable) return;
|
1858
|
+
var nObj = $("#" + node.tId);
|
1859
|
+
if (nObj.get(0) && tools.uCanDo(this.setting)) {
|
1860
|
+
var checkObj = $("#" + node.tId + consts.id.CHECK);
|
1861
|
+
if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
|
1862
|
+
view.setChkClass(this.setting, checkObj, node);
|
1863
|
+
view.repairParentChkClassWithSelf(this.setting, node);
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
},
|
1867
|
+
//method of operate data
|
1868
|
+
_data = {
|
1869
|
+
getRadioCheckedList: function(setting) {
|
1870
|
+
var checkedList = data.getRoot(setting).radioCheckedList;
|
1871
|
+
for (var i=0, j=checkedList.length; i<j; i++) {
|
1872
|
+
if(!data.getNodeCache(setting, checkedList[i].tId)) {
|
1873
|
+
checkedList.splice(i, 1);
|
1874
|
+
i--; j--;
|
1875
|
+
}
|
1876
|
+
}
|
1877
|
+
return checkedList;
|
1878
|
+
},
|
1879
|
+
getCheckStatus: function(setting, node) {
|
1880
|
+
if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
|
1881
|
+
var checkedKey = setting.data.key.checked,
|
1882
|
+
r = {
|
1883
|
+
checked: node[checkedKey],
|
1884
|
+
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)))
|
1885
|
+
};
|
1886
|
+
return r;
|
1887
|
+
},
|
1888
|
+
getTreeCheckedNodes: function(setting, nodes, checked, results) {
|
1889
|
+
if (!nodes) return [];
|
1890
|
+
var childKey = setting.data.key.children,
|
1891
|
+
checkedKey = setting.data.key.checked,
|
1892
|
+
onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
|
1893
|
+
results = !results ? [] : results;
|
1894
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
1895
|
+
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
|
1896
|
+
results.push(nodes[i]);
|
1897
|
+
if(onlyOne) {
|
1898
|
+
break;
|
1899
|
+
}
|
1900
|
+
}
|
1901
|
+
data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
|
1902
|
+
if(onlyOne && results.length > 0) {
|
1903
|
+
break;
|
1904
|
+
}
|
1905
|
+
}
|
1906
|
+
return results;
|
1907
|
+
},
|
1908
|
+
getTreeChangeCheckedNodes: function(setting, nodes, results) {
|
1909
|
+
if (!nodes) return [];
|
1910
|
+
var childKey = setting.data.key.children,
|
1911
|
+
checkedKey = setting.data.key.checked;
|
1912
|
+
results = !results ? [] : results;
|
1913
|
+
for (var i = 0, l = nodes.length; i < l; i++) {
|
1914
|
+
if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
|
1915
|
+
results.push(nodes[i]);
|
1916
|
+
}
|
1917
|
+
data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
|
1918
|
+
}
|
1919
|
+
return results;
|
1920
|
+
},
|
1921
|
+
makeChkFlag: function(setting, node) {
|
1922
|
+
if (!node) return;
|
1923
|
+
var childKey = setting.data.key.children,
|
1924
|
+
checkedKey = setting.data.key.checked,
|
1925
|
+
chkFlag = -1;
|
1926
|
+
if (node[childKey]) {
|
1927
|
+
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
1928
|
+
var cNode = node[childKey][i];
|
1929
|
+
var tmp = -1;
|
1930
|
+
if (setting.check.chkStyle == consts.radio.STYLE) {
|
1931
|
+
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
1932
|
+
tmp = cNode.check_Child_State;
|
1933
|
+
} else if (cNode.halfCheck === true) {
|
1934
|
+
tmp = 2;
|
1935
|
+
} else if (cNode[checkedKey]) {
|
1936
|
+
tmp = 2;
|
1937
|
+
} else {
|
1938
|
+
tmp = cNode.check_Child_State > 0 ? 2:0;
|
1939
|
+
}
|
1940
|
+
if (tmp == 2) {
|
1941
|
+
chkFlag = 2; break;
|
1942
|
+
} else if (tmp == 0){
|
1943
|
+
chkFlag = 0;
|
1944
|
+
}
|
1945
|
+
} else if (setting.check.chkStyle == consts.checkbox.STYLE) {
|
1946
|
+
if (cNode.nocheck === true || cNode.chkDisabled === true) {
|
1947
|
+
tmp = cNode.check_Child_State;
|
1948
|
+
} else if (cNode.halfCheck === true) {
|
1949
|
+
tmp = 1;
|
1950
|
+
} else if (cNode[checkedKey] ) {
|
1951
|
+
tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
|
1952
|
+
} else {
|
1953
|
+
tmp = (cNode.check_Child_State > 0) ? 1 : 0;
|
1954
|
+
}
|
1955
|
+
if (tmp === 1) {
|
1956
|
+
chkFlag = 1; break;
|
1957
|
+
} else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
|
1958
|
+
chkFlag = 1; break;
|
1959
|
+
} else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
|
1960
|
+
chkFlag = 1; break;
|
1961
|
+
} else if (tmp > -1) {
|
1962
|
+
chkFlag = tmp;
|
1963
|
+
}
|
1964
|
+
}
|
1965
|
+
}
|
1966
|
+
}
|
1967
|
+
node.check_Child_State = chkFlag;
|
1968
|
+
}
|
1969
|
+
},
|
1970
|
+
//method of event proxy
|
1971
|
+
_event = {
|
1972
|
+
|
1973
|
+
},
|
1974
|
+
//method of event handler
|
1975
|
+
_handler = {
|
1976
|
+
onCheckNode: function (event, node) {
|
1977
|
+
if (node.chkDisabled === true) return false;
|
1978
|
+
var setting = data.getSetting(event.data.treeId),
|
1979
|
+
checkedKey = setting.data.key.checked;
|
1980
|
+
if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
|
1981
|
+
node[checkedKey] = !node[checkedKey];
|
1982
|
+
view.checkNodeRelation(setting, node);
|
1983
|
+
var checkObj = $("#" + node.tId + consts.id.CHECK);
|
1984
|
+
view.setChkClass(setting, checkObj, node);
|
1985
|
+
view.repairParentChkClassWithSelf(setting, node);
|
1986
|
+
setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
|
1987
|
+
return true;
|
1988
|
+
},
|
1989
|
+
onMouseoverCheck: function(event, node) {
|
1990
|
+
if (node.chkDisabled === true) return false;
|
1991
|
+
var setting = data.getSetting(event.data.treeId),
|
1992
|
+
checkObj = $("#" + node.tId + consts.id.CHECK);
|
1993
|
+
node.check_Focus = true;
|
1994
|
+
view.setChkClass(setting, checkObj, node);
|
1995
|
+
return true;
|
1996
|
+
},
|
1997
|
+
onMouseoutCheck: function(event, node) {
|
1998
|
+
if (node.chkDisabled === true) return false;
|
1999
|
+
var setting = data.getSetting(event.data.treeId),
|
2000
|
+
checkObj = $("#" + node.tId + consts.id.CHECK);
|
2001
|
+
node.check_Focus = false;
|
2002
|
+
view.setChkClass(setting, checkObj, node);
|
2003
|
+
return true;
|
2004
|
+
}
|
2005
|
+
},
|
2006
|
+
//method of tools for zTree
|
2007
|
+
_tools = {
|
2008
|
+
|
2009
|
+
},
|
2010
|
+
//method of operate ztree dom
|
2011
|
+
_view = {
|
2012
|
+
checkNodeRelation: function(setting, node) {
|
2013
|
+
var pNode, i, l,
|
2014
|
+
childKey = setting.data.key.children,
|
2015
|
+
checkedKey = setting.data.key.checked,
|
2016
|
+
r = consts.radio;
|
2017
|
+
if (setting.check.chkStyle == r.STYLE) {
|
2018
|
+
var checkedList = data.getRadioCheckedList(setting);
|
2019
|
+
if (node[checkedKey]) {
|
2020
|
+
if (setting.check.radioType == r.TYPE_ALL) {
|
2021
|
+
for (i = checkedList.length-1; i >= 0; i--) {
|
2022
|
+
pNode = checkedList[i];
|
2023
|
+
pNode[checkedKey] = false;
|
2024
|
+
checkedList.splice(i, 1);
|
2025
|
+
|
2026
|
+
view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode);
|
2027
|
+
if (pNode.parentTId != node.parentTId) {
|
2028
|
+
view.repairParentChkClassWithSelf(setting, pNode);
|
2029
|
+
}
|
2030
|
+
}
|
2031
|
+
checkedList.push(node);
|
2032
|
+
} else {
|
2033
|
+
var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
|
2034
|
+
for (i = 0, l = parentNode[childKey].length; i < l; i++) {
|
2035
|
+
pNode = parentNode[childKey][i];
|
2036
|
+
if (pNode[checkedKey] && pNode != node) {
|
2037
|
+
pNode[checkedKey] = false;
|
2038
|
+
view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode);
|
2039
|
+
}
|
2040
|
+
}
|
2041
|
+
}
|
2042
|
+
} else if (setting.check.radioType == r.TYPE_ALL) {
|
2043
|
+
for (i = 0, l = checkedList.length; i < l; i++) {
|
2044
|
+
if (node == checkedList[i]) {
|
2045
|
+
checkedList.splice(i, 1);
|
2046
|
+
break;
|
2047
|
+
}
|
2048
|
+
}
|
2049
|
+
}
|
2050
|
+
|
2051
|
+
} else {
|
2052
|
+
if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
|
2053
|
+
view.setSonNodeCheckBox(setting, node, true);
|
2054
|
+
}
|
2055
|
+
if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
|
2056
|
+
view.setSonNodeCheckBox(setting, node, false);
|
2057
|
+
}
|
2058
|
+
if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
|
2059
|
+
view.setParentNodeCheckBox(setting, node, true);
|
2060
|
+
}
|
2061
|
+
if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
|
2062
|
+
view.setParentNodeCheckBox(setting, node, false);
|
2063
|
+
}
|
2064
|
+
}
|
2065
|
+
},
|
2066
|
+
makeChkClass: function(setting, node) {
|
2067
|
+
var checkedKey = setting.data.key.checked,
|
2068
|
+
c = consts.checkbox, r = consts.radio,
|
2069
|
+
fullStyle = "";
|
2070
|
+
if (node.chkDisabled === true) {
|
2071
|
+
fullStyle = c.DISABLED;
|
2072
|
+
} else if (node.halfCheck) {
|
2073
|
+
fullStyle = c.PART;
|
2074
|
+
} else if (setting.check.chkStyle == r.STYLE) {
|
2075
|
+
fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
|
2076
|
+
} else {
|
2077
|
+
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);
|
2078
|
+
}
|
2079
|
+
var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
|
2080
|
+
chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
|
2081
|
+
return "button " + c.DEFAULT + " " + chkName;
|
2082
|
+
},
|
2083
|
+
repairAllChk: function(setting, checked) {
|
2084
|
+
if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
|
2085
|
+
var checkedKey = setting.data.key.checked,
|
2086
|
+
childKey = setting.data.key.children,
|
2087
|
+
root = data.getRoot(setting);
|
2088
|
+
for (var i = 0, l = root[childKey].length; i<l ; i++) {
|
2089
|
+
var node = root[childKey][i];
|
2090
|
+
if (node.nocheck !== true && node.chkDisabled !== true) {
|
2091
|
+
node[checkedKey] = checked;
|
2092
|
+
}
|
2093
|
+
view.setSonNodeCheckBox(setting, node, checked);
|
2094
|
+
}
|
2095
|
+
}
|
2096
|
+
},
|
2097
|
+
repairChkClass: function(setting, node) {
|
2098
|
+
if (!node) return;
|
2099
|
+
data.makeChkFlag(setting, node);
|
2100
|
+
if (node.nocheck !== true) {
|
2101
|
+
var checkObj = $("#" + node.tId + consts.id.CHECK);
|
2102
|
+
view.setChkClass(setting, checkObj, node);
|
2103
|
+
}
|
2104
|
+
},
|
2105
|
+
repairParentChkClass: function(setting, node) {
|
2106
|
+
if (!node || !node.parentTId) return;
|
2107
|
+
var pNode = node.getParentNode();
|
2108
|
+
view.repairChkClass(setting, pNode);
|
2109
|
+
view.repairParentChkClass(setting, pNode);
|
2110
|
+
},
|
2111
|
+
repairParentChkClassWithSelf: function(setting, node) {
|
2112
|
+
if (!node) return;
|
2113
|
+
var childKey = setting.data.key.children;
|
2114
|
+
if (node[childKey] && node[childKey].length > 0) {
|
2115
|
+
view.repairParentChkClass(setting, node[childKey][0]);
|
2116
|
+
} else {
|
2117
|
+
view.repairParentChkClass(setting, node);
|
2118
|
+
}
|
2119
|
+
},
|
2120
|
+
repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
|
2121
|
+
if (!node) return;
|
2122
|
+
var childKey = setting.data.key.children;
|
2123
|
+
if (node.chkDisabled != chkDisabled) {
|
2124
|
+
node.chkDisabled = chkDisabled;
|
2125
|
+
}
|
2126
|
+
view.repairChkClass(setting, node);
|
2127
|
+
if (node[childKey] && inherit) {
|
2128
|
+
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
2129
|
+
var sNode = node[childKey][i];
|
2130
|
+
view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
|
2131
|
+
}
|
2132
|
+
}
|
2133
|
+
},
|
2134
|
+
repairParentChkDisabled: function(setting, node, chkDisabled, inherit) {
|
2135
|
+
if (!node) return;
|
2136
|
+
if (node.chkDisabled != chkDisabled && inherit) {
|
2137
|
+
node.chkDisabled = chkDisabled;
|
2138
|
+
}
|
2139
|
+
view.repairChkClass(setting, node);
|
2140
|
+
view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
|
2141
|
+
},
|
2142
|
+
setChkClass: function(setting, obj, node) {
|
2143
|
+
if (!obj) return;
|
2144
|
+
if (node.nocheck === true) {
|
2145
|
+
obj.hide();
|
2146
|
+
} else {
|
2147
|
+
obj.show();
|
2148
|
+
}
|
2149
|
+
obj.removeClass();
|
2150
|
+
obj.addClass(view.makeChkClass(setting, node));
|
2151
|
+
},
|
2152
|
+
setParentNodeCheckBox: function(setting, node, value, srcNode) {
|
2153
|
+
var childKey = setting.data.key.children,
|
2154
|
+
checkedKey = setting.data.key.checked,
|
2155
|
+
checkObj = $("#" + node.tId + consts.id.CHECK);
|
2156
|
+
if (!srcNode) srcNode = node;
|
2157
|
+
data.makeChkFlag(setting, node);
|
2158
|
+
if (node.nocheck !== true && node.chkDisabled !== true) {
|
2159
|
+
node[checkedKey] = value;
|
2160
|
+
view.setChkClass(setting, checkObj, node);
|
2161
|
+
if (setting.check.autoCheckTrigger && node != srcNode) {
|
2162
|
+
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
2163
|
+
}
|
2164
|
+
}
|
2165
|
+
if (node.parentTId) {
|
2166
|
+
var pSign = true;
|
2167
|
+
if (!value) {
|
2168
|
+
var pNodes = node.getParentNode()[childKey];
|
2169
|
+
for (var i = 0, l = pNodes.length; i < l; i++) {
|
2170
|
+
if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
|
2171
|
+
|| ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
|
2172
|
+
pSign = false;
|
2173
|
+
break;
|
2174
|
+
}
|
2175
|
+
}
|
2176
|
+
}
|
2177
|
+
if (pSign) {
|
2178
|
+
view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
|
2179
|
+
}
|
2180
|
+
}
|
2181
|
+
},
|
2182
|
+
setSonNodeCheckBox: function(setting, node, value, srcNode) {
|
2183
|
+
if (!node) return;
|
2184
|
+
var childKey = setting.data.key.children,
|
2185
|
+
checkedKey = setting.data.key.checked,
|
2186
|
+
checkObj = $("#" + node.tId + consts.id.CHECK);
|
2187
|
+
if (!srcNode) srcNode = node;
|
2188
|
+
|
2189
|
+
var hasDisable = false;
|
2190
|
+
if (node[childKey]) {
|
2191
|
+
for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) {
|
2192
|
+
var sNode = node[childKey][i];
|
2193
|
+
view.setSonNodeCheckBox(setting, sNode, value, srcNode);
|
2194
|
+
if (sNode.chkDisabled === true) hasDisable = true;
|
2195
|
+
}
|
2196
|
+
}
|
2197
|
+
|
2198
|
+
if (node != data.getRoot(setting) && node.chkDisabled !== true) {
|
2199
|
+
if (hasDisable && node.nocheck !== true) {
|
2200
|
+
data.makeChkFlag(setting, node);
|
2201
|
+
}
|
2202
|
+
if (node.nocheck !== true && node.chkDisabled !== true) {
|
2203
|
+
node[checkedKey] = value;
|
2204
|
+
if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
|
2205
|
+
} else {
|
2206
|
+
node.check_Child_State = -1;
|
2207
|
+
}
|
2208
|
+
view.setChkClass(setting, checkObj, node);
|
2209
|
+
if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
|
2210
|
+
setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
|
2211
|
+
}
|
2212
|
+
}
|
2213
|
+
|
2214
|
+
}
|
2215
|
+
},
|
2216
|
+
|
2217
|
+
_z = {
|
2218
|
+
tools: _tools,
|
2219
|
+
view: _view,
|
2220
|
+
event: _event,
|
2221
|
+
data: _data
|
2222
|
+
};
|
2223
|
+
$.extend(true, $.fn.zTree.consts, _consts);
|
2224
|
+
$.extend(true, $.fn.zTree._z, _z);
|
2225
|
+
|
2226
|
+
var zt = $.fn.zTree,
|
2227
|
+
tools = zt._z.tools,
|
2228
|
+
consts = zt.consts,
|
2229
|
+
view = zt._z.view,
|
2230
|
+
data = zt._z.data,
|
2231
|
+
event = zt._z.event;
|
2232
|
+
|
2233
|
+
data.exSetting(_setting);
|
2234
|
+
data.addInitBind(_bindEvent);
|
2235
|
+
data.addInitUnBind(_unbindEvent);
|
2236
|
+
data.addInitCache(_initCache);
|
2237
|
+
data.addInitNode(_initNode);
|
2238
|
+
data.addInitProxy(_eventProxy);
|
2239
|
+
data.addInitRoot(_initRoot);
|
2240
|
+
data.addBeforeA(_beforeA);
|
2241
|
+
data.addZTreeTools(_zTreeTools);
|
2242
|
+
|
2243
|
+
var _createNodes = view.createNodes;
|
2244
|
+
view.createNodes = function(setting, level, nodes, parentNode) {
|
2245
|
+
if (_createNodes) _createNodes.apply(view, arguments);
|
2246
|
+
if (!nodes) return;
|
2247
|
+
view.repairParentChkClassWithSelf(setting, parentNode);
|
2248
|
+
}
|
2249
|
+
var _removeNode = view.removeNode;
|
2250
|
+
view.removeNode = function(setting, node) {
|
2251
|
+
var parentNode = node.getParentNode();
|
2252
|
+
if (_removeNode) _removeNode.apply(view, arguments);
|
2253
|
+
if (!node || !parentNode) return;
|
2254
|
+
view.repairChkClass(setting, parentNode);
|
2255
|
+
view.repairParentChkClass(setting, parentNode);
|
2256
|
+
}
|
2257
|
+
|
2258
|
+
var _appendNodes = view.appendNodes;
|
2259
|
+
view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) {
|
2260
|
+
var html = "";
|
2261
|
+
if (_appendNodes) {
|
2262
|
+
html = _appendNodes.apply(view, arguments);
|
2263
|
+
}
|
2264
|
+
if (parentNode) {
|
2265
|
+
data.makeChkFlag(setting, parentNode);
|
2266
|
+
}
|
2267
|
+
return html;
|
2268
|
+
}
|
2269
|
+
})(jQuery);
|
2270
|
+
/*
|
2271
|
+
* JQuery zTree exedit 3.5.02
|
2272
|
+
* http://zTree.me/
|
2273
|
+
*
|
2274
|
+
* Copyright (c) 2010 Hunter.z
|
2275
|
+
*
|
2276
|
+
* Licensed same as jquery - MIT License
|
2277
|
+
* http://www.opensource.org/licenses/mit-license.php
|
2278
|
+
*
|
2279
|
+
* email: hunter.z@263.net
|
2280
|
+
* Date: 2013-01-28
|
2281
|
+
*/
|
2282
|
+
(function($){
|
2283
|
+
//default consts of exedit
|
2284
|
+
var _consts = {
|
2285
|
+
event: {
|
2286
|
+
DRAG: "ztree_drag",
|
2287
|
+
DROP: "ztree_drop",
|
2288
|
+
REMOVE: "ztree_remove",
|
2289
|
+
RENAME: "ztree_rename"
|
2290
|
+
},
|
2291
|
+
id: {
|
2292
|
+
EDIT: "_edit",
|
2293
|
+
INPUT: "_input",
|
2294
|
+
REMOVE: "_remove"
|
2295
|
+
},
|
2296
|
+
move: {
|
2297
|
+
TYPE_INNER: "inner",
|
2298
|
+
TYPE_PREV: "prev",
|
2299
|
+
TYPE_NEXT: "next"
|
2300
|
+
},
|
2301
|
+
node: {
|
2302
|
+
CURSELECTED_EDIT: "curSelectedNode_Edit",
|
2303
|
+
TMPTARGET_TREE: "tmpTargetzTree",
|
2304
|
+
TMPTARGET_NODE: "tmpTargetNode"
|
2305
|
+
}
|
2306
|
+
},
|
2307
|
+
//default setting of exedit
|
2308
|
+
_setting = {
|
2309
|
+
edit: {
|
2310
|
+
enable: false,
|
2311
|
+
editNameSelectAll: false,
|
2312
|
+
showRemoveBtn: true,
|
2313
|
+
showRenameBtn: true,
|
2314
|
+
removeTitle: "remove",
|
2315
|
+
renameTitle: "rename",
|
2316
|
+
drag: {
|
2317
|
+
autoExpandTrigger: false,
|
2318
|
+
isCopy: true,
|
2319
|
+
isMove: true,
|
2320
|
+
prev: true,
|
2321
|
+
next: true,
|
2322
|
+
inner: true,
|
2323
|
+
minMoveSize: 5,
|
2324
|
+
borderMax: 10,
|
2325
|
+
borderMin: -5,
|
2326
|
+
maxShowNodeNum: 5,
|
2327
|
+
autoOpenTime: 500
|
2328
|
+
}
|
2329
|
+
},
|
2330
|
+
view: {
|
2331
|
+
addHoverDom: null,
|
2332
|
+
removeHoverDom: null
|
2333
|
+
},
|
2334
|
+
callback: {
|
2335
|
+
beforeDrag:null,
|
2336
|
+
beforeDragOpen:null,
|
2337
|
+
beforeDrop:null,
|
2338
|
+
beforeEditName:null,
|
2339
|
+
beforeRename:null,
|
2340
|
+
onDrag:null,
|
2341
|
+
onDrop:null,
|
2342
|
+
onRename:null
|
2343
|
+
}
|
2344
|
+
},
|
2345
|
+
//default root of exedit
|
2346
|
+
_initRoot = function (setting) {
|
2347
|
+
var r = data.getRoot(setting);
|
2348
|
+
r.curEditNode = null;
|
2349
|
+
r.curEditInput = null;
|
2350
|
+
r.curHoverNode = null;
|
2351
|
+
r.dragFlag = 0;
|
2352
|
+
r.dragNodeShowBefore = [];
|
2353
|
+
r.dragMaskList = new Array();
|
2354
|
+
r.showHoverDom = true;
|
2355
|
+
},
|
2356
|
+
//default cache of exedit
|
2357
|
+
_initCache = function(treeId) {},
|
2358
|
+
//default bind event of exedit
|
2359
|
+
_bindEvent = function(setting) {
|
2360
|
+
var o = setting.treeObj;
|
2361
|
+
var c = consts.event;
|
2362
|
+
o.bind(c.RENAME, function (event, treeId, treeNode) {
|
2363
|
+
tools.apply(setting.callback.onRename, [event, treeId, treeNode]);
|
2364
|
+
});
|
2365
|
+
|
2366
|
+
o.bind(c.REMOVE, function (event, treeId, treeNode) {
|
2367
|
+
tools.apply(setting.callback.onRemove, [event, treeId, treeNode]);
|
2368
|
+
});
|
2369
|
+
|
2370
|
+
o.bind(c.DRAG, function (event, srcEvent, treeId, treeNodes) {
|
2371
|
+
tools.apply(setting.callback.onDrag, [srcEvent, treeId, treeNodes]);
|
2372
|
+
});
|
2373
|
+
|
2374
|
+
o.bind(c.DROP, function (event, srcEvent, treeId, treeNodes, targetNode, moveType, isCopy) {
|
2375
|
+
tools.apply(setting.callback.onDrop, [srcEvent, treeId, treeNodes, targetNode, moveType, isCopy]);
|
2376
|
+
});
|
2377
|
+
},
|
2378
|
+
_unbindEvent = function(setting) {
|
2379
|
+
var o = setting.treeObj;
|
2380
|
+
var c = consts.event;
|
2381
|
+
o.unbind(c.RENAME);
|
2382
|
+
o.unbind(c.REMOVE);
|
2383
|
+
o.unbind(c.DRAG);
|
2384
|
+
o.unbind(c.DROP);
|
2385
|
+
},
|
2386
|
+
//default event proxy of exedit
|
2387
|
+
_eventProxy = function(e) {
|
2388
|
+
var target = e.target,
|
2389
|
+
setting = data.getSetting(e.data.treeId),
|
2390
|
+
relatedTarget = e.relatedTarget,
|
2391
|
+
tId = "", node = null,
|
2392
|
+
nodeEventType = "", treeEventType = "",
|
2393
|
+
nodeEventCallback = null, treeEventCallback = null,
|
2394
|
+
tmp = null;
|
2395
|
+
|
2396
|
+
if (tools.eqs(e.type, "mouseover")) {
|
2397
|
+
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
|
2398
|
+
if (tmp) {
|
2399
|
+
tId = tmp.parentNode.id;
|
2400
|
+
nodeEventType = "hoverOverNode";
|
2401
|
+
}
|
2402
|
+
} else if (tools.eqs(e.type, "mouseout")) {
|
2403
|
+
tmp = tools.getMDom(setting, relatedTarget, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
|
2404
|
+
if (!tmp) {
|
2405
|
+
tId = "remove";
|
2406
|
+
nodeEventType = "hoverOutNode";
|
2407
|
+
}
|
2408
|
+
} else if (tools.eqs(e.type, "mousedown")) {
|
2409
|
+
tmp = tools.getMDom(setting, target, [{tagName:"a", attrName:"treeNode"+consts.id.A}]);
|
2410
|
+
if (tmp) {
|
2411
|
+
tId = tmp.parentNode.id;
|
2412
|
+
nodeEventType = "mousedownNode";
|
2413
|
+
}
|
2414
|
+
}
|
2415
|
+
if (tId.length>0) {
|
2416
|
+
node = data.getNodeCache(setting, tId);
|
2417
|
+
switch (nodeEventType) {
|
2418
|
+
case "mousedownNode" :
|
2419
|
+
nodeEventCallback = _handler.onMousedownNode;
|
2420
|
+
break;
|
2421
|
+
case "hoverOverNode" :
|
2422
|
+
nodeEventCallback = _handler.onHoverOverNode;
|
2423
|
+
break;
|
2424
|
+
case "hoverOutNode" :
|
2425
|
+
nodeEventCallback = _handler.onHoverOutNode;
|
2426
|
+
break;
|
2427
|
+
}
|
2428
|
+
}
|
2429
|
+
var proxyResult = {
|
2430
|
+
stop: false,
|
2431
|
+
node: node,
|
2432
|
+
nodeEventType: nodeEventType,
|
2433
|
+
nodeEventCallback: nodeEventCallback,
|
2434
|
+
treeEventType: treeEventType,
|
2435
|
+
treeEventCallback: treeEventCallback
|
2436
|
+
};
|
2437
|
+
return proxyResult
|
2438
|
+
},
|
2439
|
+
//default init node of exedit
|
2440
|
+
_initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
|
2441
|
+
if (!n) return;
|
2442
|
+
n.isHover = false;
|
2443
|
+
n.editNameFlag = false;
|
2444
|
+
},
|
2445
|
+
//update zTreeObj, add method of edit
|
2446
|
+
_zTreeTools = function(setting, zTreeTools) {
|
2447
|
+
zTreeTools.cancelEditName = function(newName) {
|
2448
|
+
var root = data.getRoot(setting),
|
2449
|
+
nameKey = setting.data.key.name,
|
2450
|
+
node = root.curEditNode;
|
2451
|
+
if (!root.curEditNode) return;
|
2452
|
+
view.cancelCurEditNode(setting, newName?newName:node[nameKey]);
|
2453
|
+
}
|
2454
|
+
zTreeTools.copyNode = function(targetNode, node, moveType, isSilent) {
|
2455
|
+
if (!node) return null;
|
2456
|
+
if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) return null;
|
2457
|
+
var newNode = tools.clone(node);
|
2458
|
+
if (!targetNode) {
|
2459
|
+
targetNode = null;
|
2460
|
+
moveType = consts.move.TYPE_INNER;
|
2461
|
+
}
|
2462
|
+
if (moveType == consts.move.TYPE_INNER) {
|
2463
|
+
function copyCallback() {
|
2464
|
+
view.addNodes(setting, targetNode, [newNode], isSilent);
|
2465
|
+
}
|
2466
|
+
|
2467
|
+
if (tools.canAsync(setting, targetNode)) {
|
2468
|
+
view.asyncNode(setting, targetNode, isSilent, copyCallback);
|
2469
|
+
} else {
|
2470
|
+
copyCallback();
|
2471
|
+
}
|
2472
|
+
} else {
|
2473
|
+
view.addNodes(setting, targetNode.parentNode, [newNode], isSilent);
|
2474
|
+
view.moveNode(setting, targetNode, newNode, moveType, false, isSilent);
|
2475
|
+
}
|
2476
|
+
return newNode;
|
2477
|
+
}
|
2478
|
+
zTreeTools.editName = function(node) {
|
2479
|
+
if (!node || !node.tId || node !== data.getNodeCache(setting, node.tId)) return;
|
2480
|
+
if (node.parentTId) view.expandCollapseParentNode(setting, node.getParentNode(), true);
|
2481
|
+
view.editNode(setting, node)
|
2482
|
+
}
|
2483
|
+
zTreeTools.moveNode = function(targetNode, node, moveType, isSilent) {
|
2484
|
+
if (!node) return node;
|
2485
|
+
if (targetNode && !targetNode.isParent && setting.data.keep.leaf && moveType === consts.move.TYPE_INNER) {
|
2486
|
+
return null;
|
2487
|
+
} else if (targetNode && ((node.parentTId == targetNode.tId && moveType == consts.move.TYPE_INNER) || $("#" + node.tId).find("#" + targetNode.tId).length > 0)) {
|
2488
|
+
return null;
|
2489
|
+
} else if (!targetNode) {
|
2490
|
+
targetNode = null;
|
2491
|
+
}
|
2492
|
+
function moveCallback() {
|
2493
|
+
view.moveNode(setting, targetNode, node, moveType, false, isSilent);
|
2494
|
+
}
|
2495
|
+
if (tools.canAsync(setting, targetNode)) {
|
2496
|
+
view.asyncNode(setting, targetNode, isSilent, moveCallback);
|
2497
|
+
} else {
|
2498
|
+
moveCallback();
|
2499
|
+
}
|
2500
|
+
return node;
|
2501
|
+
}
|
2502
|
+
zTreeTools.setEditable = function(editable) {
|
2503
|
+
setting.edit.enable = editable;
|
2504
|
+
return this.refresh();
|
2505
|
+
}
|
2506
|
+
},
|
2507
|
+
//method of operate data
|
2508
|
+
_data = {
|
2509
|
+
setSonNodeLevel: function(setting, parentNode, node) {
|
2510
|
+
if (!node) return;
|
2511
|
+
var childKey = setting.data.key.children;
|
2512
|
+
node.level = (parentNode)? parentNode.level + 1 : 0;
|
2513
|
+
if (!node[childKey]) return;
|
2514
|
+
for (var i = 0, l = node[childKey].length; i < l; i++) {
|
2515
|
+
if (node[childKey][i]) data.setSonNodeLevel(setting, node, node[childKey][i]);
|
2516
|
+
}
|
2517
|
+
}
|
2518
|
+
},
|
2519
|
+
//method of event proxy
|
2520
|
+
_event = {
|
2521
|
+
|
2522
|
+
},
|
2523
|
+
//method of event handler
|
2524
|
+
_handler = {
|
2525
|
+
onHoverOverNode: function(event, node) {
|
2526
|
+
var setting = data.getSetting(event.data.treeId),
|
2527
|
+
root = data.getRoot(setting);
|
2528
|
+
if (root.curHoverNode != node) {
|
2529
|
+
_handler.onHoverOutNode(event);
|
2530
|
+
}
|
2531
|
+
root.curHoverNode = node;
|
2532
|
+
view.addHoverDom(setting, node);
|
2533
|
+
},
|
2534
|
+
onHoverOutNode: function(event, node) {
|
2535
|
+
var setting = data.getSetting(event.data.treeId),
|
2536
|
+
root = data.getRoot(setting);
|
2537
|
+
if (root.curHoverNode && !data.isSelectedNode(setting, root.curHoverNode)) {
|
2538
|
+
view.removeTreeDom(setting, root.curHoverNode);
|
2539
|
+
root.curHoverNode = null;
|
2540
|
+
}
|
2541
|
+
},
|
2542
|
+
onMousedownNode: function(eventMouseDown, _node) {
|
2543
|
+
var i,l,
|
2544
|
+
setting = data.getSetting(eventMouseDown.data.treeId),
|
2545
|
+
root = data.getRoot(setting);
|
2546
|
+
//right click can't drag & drop
|
2547
|
+
if (eventMouseDown.button == 2 || !setting.edit.enable || (!setting.edit.drag.isCopy && !setting.edit.drag.isMove)) return true;
|
2548
|
+
|
2549
|
+
//input of edit node name can't drag & drop
|
2550
|
+
var target = eventMouseDown.target,
|
2551
|
+
_nodes = data.getRoot(setting).curSelectedList,
|
2552
|
+
nodes = [];
|
2553
|
+
if (!data.isSelectedNode(setting, _node)) {
|
2554
|
+
nodes = [_node];
|
2555
|
+
} else {
|
2556
|
+
for (i=0, l=_nodes.length; i<l; i++) {
|
2557
|
+
if (_nodes[i].editNameFlag && tools.eqs(target.tagName, "input") && target.getAttribute("treeNode"+consts.id.INPUT) !== null) {
|
2558
|
+
return true;
|
2559
|
+
}
|
2560
|
+
nodes.push(_nodes[i]);
|
2561
|
+
if (nodes[0].parentTId !== _nodes[i].parentTId) {
|
2562
|
+
nodes = [_node];
|
2563
|
+
break;
|
2564
|
+
}
|
2565
|
+
}
|
2566
|
+
}
|
2567
|
+
|
2568
|
+
view.editNodeBlur = true;
|
2569
|
+
view.cancelCurEditNode(setting, null, true);
|
2570
|
+
|
2571
|
+
|
2572
|
+
var doc = $(document), curNode, tmpArrow, tmpTarget,
|
2573
|
+
isOtherTree = false,
|
2574
|
+
targetSetting = setting,
|
2575
|
+
preNode, nextNode,
|
2576
|
+
preTmpTargetNodeId = null,
|
2577
|
+
preTmpMoveType = null,
|
2578
|
+
tmpTargetNodeId = null,
|
2579
|
+
moveType = consts.move.TYPE_INNER,
|
2580
|
+
mouseDownX = eventMouseDown.clientX,
|
2581
|
+
mouseDownY = eventMouseDown.clientY,
|
2582
|
+
startTime = (new Date()).getTime();
|
2583
|
+
|
2584
|
+
if (tools.uCanDo(setting)) {
|
2585
|
+
doc.bind("mousemove", _docMouseMove);
|
2586
|
+
}
|
2587
|
+
function _docMouseMove(event) {
|
2588
|
+
//avoid start drag after click node
|
2589
|
+
if (root.dragFlag == 0 && Math.abs(mouseDownX - event.clientX) < setting.edit.drag.minMoveSize
|
2590
|
+
&& Math.abs(mouseDownY - event.clientY) < setting.edit.drag.minMoveSize) {
|
2591
|
+
return true;
|
2592
|
+
}
|
2593
|
+
var i, l, tmpNode, tmpDom, tmpNodes,
|
2594
|
+
childKey = setting.data.key.children;
|
2595
|
+
$("body").css("cursor", "pointer");
|
2596
|
+
|
2597
|
+
if (root.dragFlag == 0) {
|
2598
|
+
if (tools.apply(setting.callback.beforeDrag, [setting.treeId, nodes], true) == false) {
|
2599
|
+
_docMouseUp(event);
|
2600
|
+
return true;
|
2601
|
+
}
|
2602
|
+
|
2603
|
+
for (i=0, l=nodes.length; i<l; i++) {
|
2604
|
+
if (i==0) {
|
2605
|
+
root.dragNodeShowBefore = [];
|
2606
|
+
}
|
2607
|
+
tmpNode = nodes[i];
|
2608
|
+
if (tmpNode.isParent && tmpNode.open) {
|
2609
|
+
view.expandCollapseNode(setting, tmpNode, !tmpNode.open);
|
2610
|
+
root.dragNodeShowBefore[tmpNode.tId] = true;
|
2611
|
+
} else {
|
2612
|
+
root.dragNodeShowBefore[tmpNode.tId] = false;
|
2613
|
+
}
|
2614
|
+
}
|
2615
|
+
|
2616
|
+
root.dragFlag = 1;
|
2617
|
+
root.showHoverDom = false;
|
2618
|
+
tools.showIfameMask(setting, true);
|
2619
|
+
|
2620
|
+
//sort
|
2621
|
+
var isOrder = true, lastIndex = -1;
|
2622
|
+
if (nodes.length>1) {
|
2623
|
+
var pNodes = nodes[0].parentTId ? nodes[0].getParentNode()[childKey] : data.getNodes(setting);
|
2624
|
+
tmpNodes = [];
|
2625
|
+
for (i=0, l=pNodes.length; i<l; i++) {
|
2626
|
+
if (root.dragNodeShowBefore[pNodes[i].tId] !== undefined) {
|
2627
|
+
if (isOrder && lastIndex > -1 && (lastIndex+1) !== i) {
|
2628
|
+
isOrder = false;
|
2629
|
+
}
|
2630
|
+
tmpNodes.push(pNodes[i]);
|
2631
|
+
lastIndex = i;
|
2632
|
+
}
|
2633
|
+
if (nodes.length === tmpNodes.length) {
|
2634
|
+
nodes = tmpNodes;
|
2635
|
+
break;
|
2636
|
+
}
|
2637
|
+
}
|
2638
|
+
}
|
2639
|
+
if (isOrder) {
|
2640
|
+
preNode = nodes[0].getPreNode();
|
2641
|
+
nextNode = nodes[nodes.length-1].getNextNode();
|
2642
|
+
}
|
2643
|
+
|
2644
|
+
//set node in selected
|
2645
|
+
curNode = $("<ul class='zTreeDragUL'></ul>");
|
2646
|
+
for (i=0, l=nodes.length; i<l; i++) {
|
2647
|
+
tmpNode = nodes[i];
|
2648
|
+
tmpNode.editNameFlag = false;
|
2649
|
+
view.selectNode(setting, tmpNode, i>0);
|
2650
|
+
view.removeTreeDom(setting, tmpNode);
|
2651
|
+
|
2652
|
+
tmpDom = $("<li id='"+ tmpNode.tId +"_tmp'></li>");
|
2653
|
+
tmpDom.append($("#" + tmpNode.tId + consts.id.A).clone());
|
2654
|
+
tmpDom.css("padding", "0");
|
2655
|
+
tmpDom.children("#" + tmpNode.tId + consts.id.A).removeClass(consts.node.CURSELECTED);
|
2656
|
+
curNode.append(tmpDom);
|
2657
|
+
if (i == setting.edit.drag.maxShowNodeNum-1) {
|
2658
|
+
tmpDom = $("<li id='"+ tmpNode.tId +"_moretmp'><a> ... </a></li>");
|
2659
|
+
curNode.append(tmpDom);
|
2660
|
+
break;
|
2661
|
+
}
|
2662
|
+
}
|
2663
|
+
curNode.attr("id", nodes[0].tId + consts.id.UL + "_tmp");
|
2664
|
+
curNode.addClass(setting.treeObj.attr("class"));
|
2665
|
+
curNode.appendTo("body");
|
2666
|
+
|
2667
|
+
tmpArrow = $("<span class='tmpzTreeMove_arrow'></span>");
|
2668
|
+
tmpArrow.attr("id", "zTreeMove_arrow_tmp");
|
2669
|
+
tmpArrow.appendTo("body");
|
2670
|
+
|
2671
|
+
setting.treeObj.trigger(consts.event.DRAG, [event, setting.treeId, nodes]);
|
2672
|
+
}
|
2673
|
+
|
2674
|
+
if (root.dragFlag == 1) {
|
2675
|
+
if (tmpTarget && tmpArrow.attr("id") == event.target.id && tmpTargetNodeId && (event.clientX + doc.scrollLeft()+2) > ($("#" + tmpTargetNodeId + consts.id.A, tmpTarget).offset().left)) {
|
2676
|
+
var xT = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget);
|
2677
|
+
event.target = (xT.length > 0) ? xT.get(0) : event.target;
|
2678
|
+
} else if (tmpTarget) {
|
2679
|
+
tmpTarget.removeClass(consts.node.TMPTARGET_TREE);
|
2680
|
+
if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV)
|
2681
|
+
.removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER);
|
2682
|
+
}
|
2683
|
+
tmpTarget = null;
|
2684
|
+
tmpTargetNodeId = null;
|
2685
|
+
|
2686
|
+
//judge drag & drop in multi ztree
|
2687
|
+
isOtherTree = false;
|
2688
|
+
targetSetting = setting;
|
2689
|
+
var settings = data.getSettings();
|
2690
|
+
for (var s in settings) {
|
2691
|
+
if (settings[s].treeId && settings[s].edit.enable && settings[s].treeId != setting.treeId
|
2692
|
+
&& (event.target.id == settings[s].treeId || $(event.target).parents("#" + settings[s].treeId).length>0)) {
|
2693
|
+
isOtherTree = true;
|
2694
|
+
targetSetting = settings[s];
|
2695
|
+
}
|
2696
|
+
}
|
2697
|
+
|
2698
|
+
var docScrollTop = doc.scrollTop(),
|
2699
|
+
docScrollLeft = doc.scrollLeft(),
|
2700
|
+
treeOffset = targetSetting.treeObj.offset(),
|
2701
|
+
scrollHeight = targetSetting.treeObj.get(0).scrollHeight,
|
2702
|
+
scrollWidth = targetSetting.treeObj.get(0).scrollWidth,
|
2703
|
+
dTop = (event.clientY + docScrollTop - treeOffset.top),
|
2704
|
+
dBottom = (targetSetting.treeObj.height() + treeOffset.top - event.clientY - docScrollTop),
|
2705
|
+
dLeft = (event.clientX + docScrollLeft - treeOffset.left),
|
2706
|
+
dRight = (targetSetting.treeObj.width() + treeOffset.left - event.clientX - docScrollLeft),
|
2707
|
+
isTop = (dTop < setting.edit.drag.borderMax && dTop > setting.edit.drag.borderMin),
|
2708
|
+
isBottom = (dBottom < setting.edit.drag.borderMax && dBottom > setting.edit.drag.borderMin),
|
2709
|
+
isLeft = (dLeft < setting.edit.drag.borderMax && dLeft > setting.edit.drag.borderMin),
|
2710
|
+
isRight = (dRight < setting.edit.drag.borderMax && dRight > setting.edit.drag.borderMin),
|
2711
|
+
isTreeInner = dTop > setting.edit.drag.borderMin && dBottom > setting.edit.drag.borderMin && dLeft > setting.edit.drag.borderMin && dRight > setting.edit.drag.borderMin,
|
2712
|
+
isTreeTop = (isTop && targetSetting.treeObj.scrollTop() <= 0),
|
2713
|
+
isTreeBottom = (isBottom && (targetSetting.treeObj.scrollTop() + targetSetting.treeObj.height()+10) >= scrollHeight),
|
2714
|
+
isTreeLeft = (isLeft && targetSetting.treeObj.scrollLeft() <= 0),
|
2715
|
+
isTreeRight = (isRight && (targetSetting.treeObj.scrollLeft() + targetSetting.treeObj.width()+10) >= scrollWidth);
|
2716
|
+
|
2717
|
+
if (event.target.id && targetSetting.treeObj.find("#" + event.target.id).length > 0) {
|
2718
|
+
//get node <li> dom
|
2719
|
+
var targetObj = event.target;
|
2720
|
+
while (targetObj && targetObj.tagName && !tools.eqs(targetObj.tagName, "li") && targetObj.id != targetSetting.treeId) {
|
2721
|
+
targetObj = targetObj.parentNode;
|
2722
|
+
}
|
2723
|
+
|
2724
|
+
var canMove = true;
|
2725
|
+
//don't move to self or children of self
|
2726
|
+
for (i=0, l=nodes.length; i<l; i++) {
|
2727
|
+
tmpNode = nodes[i];
|
2728
|
+
if (targetObj.id === tmpNode.tId) {
|
2729
|
+
canMove = false;
|
2730
|
+
break;
|
2731
|
+
} else if ($("#" + tmpNode.tId).find("#" + targetObj.id).length > 0) {
|
2732
|
+
canMove = false;
|
2733
|
+
break;
|
2734
|
+
}
|
2735
|
+
}
|
2736
|
+
if (canMove) {
|
2737
|
+
if (event.target.id &&
|
2738
|
+
(event.target.id == (targetObj.id + consts.id.A) || $(event.target).parents("#" + targetObj.id + consts.id.A).length > 0)) {
|
2739
|
+
tmpTarget = $(targetObj);
|
2740
|
+
tmpTargetNodeId = targetObj.id;
|
2741
|
+
}
|
2742
|
+
}
|
2743
|
+
}
|
2744
|
+
|
2745
|
+
//the mouse must be in zTree
|
2746
|
+
tmpNode = nodes[0];
|
2747
|
+
if (isTreeInner && (event.target.id == targetSetting.treeId || $(event.target).parents("#" + targetSetting.treeId).length>0)) {
|
2748
|
+
//judge mouse move in root of ztree
|
2749
|
+
if (!tmpTarget && (event.target.id == targetSetting.treeId || isTreeTop || isTreeBottom || isTreeLeft || isTreeRight) && (isOtherTree || (!isOtherTree && tmpNode.parentTId))) {
|
2750
|
+
tmpTarget = targetSetting.treeObj;
|
2751
|
+
}
|
2752
|
+
//auto scroll top
|
2753
|
+
if (isTop) {
|
2754
|
+
targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()-10);
|
2755
|
+
} else if (isBottom) {
|
2756
|
+
targetSetting.treeObj.scrollTop(targetSetting.treeObj.scrollTop()+10);
|
2757
|
+
}
|
2758
|
+
if (isLeft) {
|
2759
|
+
targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()-10);
|
2760
|
+
} else if (isRight) {
|
2761
|
+
targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+10);
|
2762
|
+
}
|
2763
|
+
//auto scroll left
|
2764
|
+
if (tmpTarget && tmpTarget != targetSetting.treeObj && tmpTarget.offset().left < targetSetting.treeObj.offset().left) {
|
2765
|
+
targetSetting.treeObj.scrollLeft(targetSetting.treeObj.scrollLeft()+ tmpTarget.offset().left - targetSetting.treeObj.offset().left);
|
2766
|
+
}
|
2767
|
+
}
|
2768
|
+
|
2769
|
+
curNode.css({
|
2770
|
+
"top": (event.clientY + docScrollTop + 3) + "px",
|
2771
|
+
"left": (event.clientX + docScrollLeft + 3) + "px"
|
2772
|
+
});
|
2773
|
+
|
2774
|
+
var dX = 0;
|
2775
|
+
var dY = 0;
|
2776
|
+
if (tmpTarget && tmpTarget.attr("id")!=targetSetting.treeId) {
|
2777
|
+
var tmpTargetNode = tmpTargetNodeId == null ? null: data.getNodeCache(targetSetting, tmpTargetNodeId),
|
2778
|
+
isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy),
|
2779
|
+
isPrev = !!(preNode && tmpTargetNodeId === preNode.tId),
|
2780
|
+
isNext = !!(nextNode && tmpTargetNodeId === nextNode.tId),
|
2781
|
+
isInner = (tmpNode.parentTId && tmpNode.parentTId == tmpTargetNodeId),
|
2782
|
+
canPrev = (isCopy || !isNext) && tools.apply(targetSetting.edit.drag.prev, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.prev),
|
2783
|
+
canNext = (isCopy || !isPrev) && tools.apply(targetSetting.edit.drag.next, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.next),
|
2784
|
+
canInner = (isCopy || !isInner) && !(targetSetting.data.keep.leaf && !tmpTargetNode.isParent) && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, tmpTargetNode], !!targetSetting.edit.drag.inner);
|
2785
|
+
if (!canPrev && !canNext && !canInner) {
|
2786
|
+
tmpTarget = null;
|
2787
|
+
tmpTargetNodeId = "";
|
2788
|
+
moveType = consts.move.TYPE_INNER;
|
2789
|
+
tmpArrow.css({
|
2790
|
+
"display":"none"
|
2791
|
+
});
|
2792
|
+
if (window.zTreeMoveTimer) {
|
2793
|
+
clearTimeout(window.zTreeMoveTimer);
|
2794
|
+
window.zTreeMoveTargetNodeTId = null
|
2795
|
+
}
|
2796
|
+
} else {
|
2797
|
+
var tmpTargetA = $("#" + tmpTargetNodeId + consts.id.A, tmpTarget),
|
2798
|
+
tmpNextA = tmpTargetNode.isLastNode ? null : $("#" + tmpTargetNode.getNextNode().tId + consts.id.A, tmpTarget.next()),
|
2799
|
+
tmpTop = tmpTargetA.offset().top,
|
2800
|
+
tmpLeft = tmpTargetA.offset().left,
|
2801
|
+
prevPercent = canPrev ? (canInner ? 0.25 : (canNext ? 0.5 : 1) ) : -1,
|
2802
|
+
nextPercent = canNext ? (canInner ? 0.75 : (canPrev ? 0.5 : 0) ) : -1,
|
2803
|
+
dY_percent = (event.clientY + docScrollTop - tmpTop)/tmpTargetA.height();
|
2804
|
+
if ((prevPercent==1 ||dY_percent<=prevPercent && dY_percent>=-.2) && canPrev) {
|
2805
|
+
dX = 1 - tmpArrow.width();
|
2806
|
+
dY = tmpTop - tmpArrow.height()/2;
|
2807
|
+
moveType = consts.move.TYPE_PREV;
|
2808
|
+
} else if ((nextPercent==0 || dY_percent>=nextPercent && dY_percent<=1.2) && canNext) {
|
2809
|
+
dX = 1 - tmpArrow.width();
|
2810
|
+
dY = (tmpNextA == null || (tmpTargetNode.isParent && tmpTargetNode.open)) ? (tmpTop + tmpTargetA.height() - tmpArrow.height()/2) : (tmpNextA.offset().top - tmpArrow.height()/2);
|
2811
|
+
moveType = consts.move.TYPE_NEXT;
|
2812
|
+
}else {
|
2813
|
+
dX = 5 - tmpArrow.width();
|
2814
|
+
dY = tmpTop;
|
2815
|
+
moveType = consts.move.TYPE_INNER;
|
2816
|
+
}
|
2817
|
+
tmpArrow.css({
|
2818
|
+
"display":"block",
|
2819
|
+
"top": dY + "px",
|
2820
|
+
"left": (tmpLeft + dX) + "px"
|
2821
|
+
});
|
2822
|
+
tmpTargetA.addClass(consts.node.TMPTARGET_NODE + "_" + moveType);
|
2823
|
+
|
2824
|
+
if (preTmpTargetNodeId != tmpTargetNodeId || preTmpMoveType != moveType) {
|
2825
|
+
startTime = (new Date()).getTime();
|
2826
|
+
}
|
2827
|
+
if (tmpTargetNode && tmpTargetNode.isParent && moveType == consts.move.TYPE_INNER) {
|
2828
|
+
var startTimer = true;
|
2829
|
+
if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId !== tmpTargetNode.tId) {
|
2830
|
+
clearTimeout(window.zTreeMoveTimer);
|
2831
|
+
window.zTreeMoveTargetNodeTId = null;
|
2832
|
+
} else if (window.zTreeMoveTimer && window.zTreeMoveTargetNodeTId === tmpTargetNode.tId) {
|
2833
|
+
startTimer = false;
|
2834
|
+
}
|
2835
|
+
if (startTimer) {
|
2836
|
+
window.zTreeMoveTimer = setTimeout(function() {
|
2837
|
+
if (moveType != consts.move.TYPE_INNER) return;
|
2838
|
+
if (tmpTargetNode && tmpTargetNode.isParent && !tmpTargetNode.open && (new Date()).getTime() - startTime > targetSetting.edit.drag.autoOpenTime
|
2839
|
+
&& tools.apply(targetSetting.callback.beforeDragOpen, [targetSetting.treeId, tmpTargetNode], true)) {
|
2840
|
+
view.switchNode(targetSetting, tmpTargetNode);
|
2841
|
+
if (targetSetting.edit.drag.autoExpandTrigger) {
|
2842
|
+
targetSetting.treeObj.trigger(consts.event.EXPAND, [targetSetting.treeId, tmpTargetNode]);
|
2843
|
+
}
|
2844
|
+
}
|
2845
|
+
}, targetSetting.edit.drag.autoOpenTime+50);
|
2846
|
+
window.zTreeMoveTargetNodeTId = tmpTargetNode.tId;
|
2847
|
+
}
|
2848
|
+
}
|
2849
|
+
}
|
2850
|
+
} else {
|
2851
|
+
moveType = consts.move.TYPE_INNER;
|
2852
|
+
if (tmpTarget && tools.apply(targetSetting.edit.drag.inner, [targetSetting.treeId, nodes, null], !!targetSetting.edit.drag.inner)) {
|
2853
|
+
tmpTarget.addClass(consts.node.TMPTARGET_TREE);
|
2854
|
+
} else {
|
2855
|
+
tmpTarget = null;
|
2856
|
+
}
|
2857
|
+
tmpArrow.css({
|
2858
|
+
"display":"none"
|
2859
|
+
});
|
2860
|
+
if (window.zTreeMoveTimer) {
|
2861
|
+
clearTimeout(window.zTreeMoveTimer);
|
2862
|
+
window.zTreeMoveTargetNodeTId = null;
|
2863
|
+
}
|
2864
|
+
}
|
2865
|
+
preTmpTargetNodeId = tmpTargetNodeId;
|
2866
|
+
preTmpMoveType = moveType;
|
2867
|
+
}
|
2868
|
+
return false;
|
2869
|
+
}
|
2870
|
+
|
2871
|
+
doc.bind("mouseup", _docMouseUp);
|
2872
|
+
function _docMouseUp(event) {
|
2873
|
+
if (window.zTreeMoveTimer) {
|
2874
|
+
clearTimeout(window.zTreeMoveTimer);
|
2875
|
+
window.zTreeMoveTargetNodeTId = null;
|
2876
|
+
}
|
2877
|
+
preTmpTargetNodeId = null;
|
2878
|
+
preTmpMoveType = null;
|
2879
|
+
doc.unbind("mousemove", _docMouseMove);
|
2880
|
+
doc.unbind("mouseup", _docMouseUp);
|
2881
|
+
doc.unbind("selectstart", _docSelect);
|
2882
|
+
$("body").css("cursor", "auto");
|
2883
|
+
if (tmpTarget) {
|
2884
|
+
tmpTarget.removeClass(consts.node.TMPTARGET_TREE);
|
2885
|
+
if (tmpTargetNodeId) $("#" + tmpTargetNodeId + consts.id.A, tmpTarget).removeClass(consts.node.TMPTARGET_NODE + "_" + consts.move.TYPE_PREV)
|
2886
|
+
.removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_NEXT).removeClass(consts.node.TMPTARGET_NODE + "_" + _consts.move.TYPE_INNER);
|
2887
|
+
}
|
2888
|
+
tools.showIfameMask(setting, false);
|
2889
|
+
|
2890
|
+
root.showHoverDom = true;
|
2891
|
+
if (root.dragFlag == 0) return;
|
2892
|
+
root.dragFlag = 0;
|
2893
|
+
|
2894
|
+
var i, l, tmpNode;
|
2895
|
+
for (i=0, l=nodes.length; i<l; i++) {
|
2896
|
+
tmpNode = nodes[i];
|
2897
|
+
if (tmpNode.isParent && root.dragNodeShowBefore[tmpNode.tId] && !tmpNode.open) {
|
2898
|
+
view.expandCollapseNode(setting, tmpNode, !tmpNode.open);
|
2899
|
+
delete root.dragNodeShowBefore[tmpNode.tId];
|
2900
|
+
}
|
2901
|
+
}
|
2902
|
+
|
2903
|
+
if (curNode) curNode.remove();
|
2904
|
+
if (tmpArrow) tmpArrow.remove();
|
2905
|
+
|
2906
|
+
var isCopy = (event.ctrlKey && setting.edit.drag.isMove && setting.edit.drag.isCopy) || (!setting.edit.drag.isMove && setting.edit.drag.isCopy);
|
2907
|
+
if (!isCopy && tmpTarget && tmpTargetNodeId && nodes[0].parentTId && tmpTargetNodeId==nodes[0].parentTId && moveType == consts.move.TYPE_INNER) {
|
2908
|
+
tmpTarget = null;
|
2909
|
+
}
|
2910
|
+
if (tmpTarget) {
|
2911
|
+
var dragTargetNode = tmpTargetNodeId == null ? null: data.getNodeCache(targetSetting, tmpTargetNodeId);
|
2912
|
+
if (tools.apply(setting.callback.beforeDrop, [targetSetting.treeId, nodes, dragTargetNode, moveType, isCopy], true) == false) return;
|
2913
|
+
var newNodes = isCopy ? tools.clone(nodes) : nodes;
|
2914
|
+
|
2915
|
+
function dropCallback() {
|
2916
|
+
if (isOtherTree) {
|
2917
|
+
if (!isCopy) {
|
2918
|
+
for(var i=0, l=nodes.length; i<l; i++) {
|
2919
|
+
view.removeNode(setting, nodes[i]);
|
2920
|
+
}
|
2921
|
+
}
|
2922
|
+
if (moveType == consts.move.TYPE_INNER) {
|
2923
|
+
view.addNodes(targetSetting, dragTargetNode, newNodes);
|
2924
|
+
} else {
|
2925
|
+
view.addNodes(targetSetting, dragTargetNode.getParentNode(), newNodes);
|
2926
|
+
if (moveType == consts.move.TYPE_PREV) {
|
2927
|
+
for (i=0, l=newNodes.length; i<l; i++) {
|
2928
|
+
view.moveNode(targetSetting, dragTargetNode, newNodes[i], moveType, false);
|
2929
|
+
}
|
2930
|
+
} else {
|
2931
|
+
for (i=-1, l=newNodes.length-1; i<l; l--) {
|
2932
|
+
view.moveNode(targetSetting, dragTargetNode, newNodes[l], moveType, false);
|
2933
|
+
}
|
2934
|
+
}
|
2935
|
+
}
|
2936
|
+
} else {
|
2937
|
+
if (isCopy && moveType == consts.move.TYPE_INNER) {
|
2938
|
+
view.addNodes(targetSetting, dragTargetNode, newNodes);
|
2939
|
+
} else {
|
2940
|
+
if (isCopy) {
|
2941
|
+
view.addNodes(targetSetting, dragTargetNode.getParentNode(), newNodes);
|
2942
|
+
}
|
2943
|
+
if (moveType != consts.move.TYPE_NEXT) {
|
2944
|
+
for (i=0, l=newNodes.length; i<l; i++) {
|
2945
|
+
view.moveNode(targetSetting, dragTargetNode, newNodes[i], moveType, false);
|
2946
|
+
}
|
2947
|
+
} else {
|
2948
|
+
for (i=-1, l=newNodes.length-1; i<l; l--) {
|
2949
|
+
view.moveNode(targetSetting, dragTargetNode, newNodes[l], moveType, false);
|
2950
|
+
}
|
2951
|
+
}
|
2952
|
+
}
|
2953
|
+
}
|
2954
|
+
for (i=0, l=newNodes.length; i<l; i++) {
|
2955
|
+
view.selectNode(targetSetting, newNodes[i], i>0);
|
2956
|
+
}
|
2957
|
+
$("#" + newNodes[0].tId).focus().blur();
|
2958
|
+
|
2959
|
+
setting.treeObj.trigger(consts.event.DROP, [event, targetSetting.treeId, newNodes, dragTargetNode, moveType, isCopy]);
|
2960
|
+
}
|
2961
|
+
|
2962
|
+
if (moveType == consts.move.TYPE_INNER && tools.canAsync(targetSetting, dragTargetNode)) {
|
2963
|
+
view.asyncNode(targetSetting, dragTargetNode, false, dropCallback);
|
2964
|
+
} else {
|
2965
|
+
dropCallback();
|
2966
|
+
}
|
2967
|
+
|
2968
|
+
} else {
|
2969
|
+
for (i=0, l=nodes.length; i<l; i++) {
|
2970
|
+
view.selectNode(targetSetting, nodes[i], i>0);
|
2971
|
+
}
|
2972
|
+
setting.treeObj.trigger(consts.event.DROP, [event, setting.treeId, nodes, null, null, null]);
|
2973
|
+
}
|
2974
|
+
}
|
2975
|
+
|
2976
|
+
doc.bind("selectstart", _docSelect);
|
2977
|
+
function _docSelect() {
|
2978
|
+
return false;
|
2979
|
+
}
|
2980
|
+
|
2981
|
+
//Avoid FireFox's Bug
|
2982
|
+
//If zTree Div CSS set 'overflow', so drag node outside of zTree, and event.target is error.
|
2983
|
+
if(eventMouseDown.preventDefault) {
|
2984
|
+
eventMouseDown.preventDefault();
|
2985
|
+
}
|
2986
|
+
return true;
|
2987
|
+
}
|
2988
|
+
},
|
2989
|
+
//method of tools for zTree
|
2990
|
+
_tools = {
|
2991
|
+
getAbs: function (obj) {
|
2992
|
+
var oRect = obj.getBoundingClientRect();
|
2993
|
+
return [oRect.left,oRect.top]
|
2994
|
+
},
|
2995
|
+
inputFocus: function(inputObj) {
|
2996
|
+
if (inputObj.get(0)) {
|
2997
|
+
inputObj.focus();
|
2998
|
+
tools.setCursorPosition(inputObj.get(0), inputObj.val().length);
|
2999
|
+
}
|
3000
|
+
},
|
3001
|
+
inputSelect: function(inputObj) {
|
3002
|
+
if (inputObj.get(0)) {
|
3003
|
+
inputObj.focus();
|
3004
|
+
inputObj.select();
|
3005
|
+
}
|
3006
|
+
},
|
3007
|
+
setCursorPosition: function(obj, pos){
|
3008
|
+
if(obj.setSelectionRange) {
|
3009
|
+
obj.focus();
|
3010
|
+
obj.setSelectionRange(pos,pos);
|
3011
|
+
} else if (obj.createTextRange) {
|
3012
|
+
var range = obj.createTextRange();
|
3013
|
+
range.collapse(true);
|
3014
|
+
range.moveEnd('character', pos);
|
3015
|
+
range.moveStart('character', pos);
|
3016
|
+
range.select();
|
3017
|
+
}
|
3018
|
+
},
|
3019
|
+
showIfameMask: function(setting, showSign) {
|
3020
|
+
var root = data.getRoot(setting);
|
3021
|
+
//clear full mask
|
3022
|
+
while (root.dragMaskList.length > 0) {
|
3023
|
+
root.dragMaskList[0].remove();
|
3024
|
+
root.dragMaskList.shift();
|
3025
|
+
}
|
3026
|
+
if (showSign) {
|
3027
|
+
//show mask
|
3028
|
+
var iframeList = $("iframe");
|
3029
|
+
for (var i = 0, l = iframeList.length; i < l; i++) {
|
3030
|
+
var obj = iframeList.get(i),
|
3031
|
+
r = tools.getAbs(obj),
|
3032
|
+
dragMask = $("<div id='zTreeMask_" + i + "' class='zTreeMask' style='top:" + r[1] + "px; left:" + r[0] + "px; width:" + obj.offsetWidth + "px; height:" + obj.offsetHeight + "px;'></div>");
|
3033
|
+
dragMask.appendTo("body");
|
3034
|
+
root.dragMaskList.push(dragMask);
|
3035
|
+
}
|
3036
|
+
}
|
3037
|
+
}
|
3038
|
+
},
|
3039
|
+
//method of operate ztree dom
|
3040
|
+
_view = {
|
3041
|
+
addEditBtn: function(setting, node) {
|
3042
|
+
if (node.editNameFlag || $("#" + node.tId + consts.id.EDIT).length > 0) {
|
3043
|
+
return;
|
3044
|
+
}
|
3045
|
+
if (!tools.apply(setting.edit.showRenameBtn, [setting.treeId, node], setting.edit.showRenameBtn)) {
|
3046
|
+
return;
|
3047
|
+
}
|
3048
|
+
var aObj = $("#" + node.tId + consts.id.A),
|
3049
|
+
editStr = "<span class='button edit' id='" + node.tId + consts.id.EDIT + "' title='"+tools.apply(setting.edit.renameTitle, [setting.treeId, node], setting.edit.renameTitle)+"' treeNode"+consts.id.EDIT+" style='display:none;'></span>";
|
3050
|
+
aObj.append(editStr);
|
3051
|
+
|
3052
|
+
$("#" + node.tId + consts.id.EDIT).bind('click',
|
3053
|
+
function() {
|
3054
|
+
if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeEditName, [setting.treeId, node], true) == false) return false;
|
3055
|
+
view.editNode(setting, node);
|
3056
|
+
return false;
|
3057
|
+
}
|
3058
|
+
).show();
|
3059
|
+
},
|
3060
|
+
addRemoveBtn: function(setting, node) {
|
3061
|
+
if (node.editNameFlag || $("#" + node.tId + consts.id.REMOVE).length > 0) {
|
3062
|
+
return;
|
3063
|
+
}
|
3064
|
+
if (!tools.apply(setting.edit.showRemoveBtn, [setting.treeId, node], setting.edit.showRemoveBtn)) {
|
3065
|
+
return;
|
3066
|
+
}
|
3067
|
+
var aObj = $("#" + node.tId + consts.id.A),
|
3068
|
+
removeStr = "<span class='button remove' id='" + node.tId + consts.id.REMOVE + "' title='"+tools.apply(setting.edit.removeTitle, [setting.treeId, node], setting.edit.removeTitle)+"' treeNode"+consts.id.REMOVE+" style='display:none;'></span>";
|
3069
|
+
aObj.append(removeStr);
|
3070
|
+
|
3071
|
+
$("#" + node.tId + consts.id.REMOVE).bind('click',
|
3072
|
+
function() {
|
3073
|
+
if (!tools.uCanDo(setting) || tools.apply(setting.callback.beforeRemove, [setting.treeId, node], true) == false) return false;
|
3074
|
+
view.removeNode(setting, node);
|
3075
|
+
setting.treeObj.trigger(consts.event.REMOVE, [setting.treeId, node]);
|
3076
|
+
return false;
|
3077
|
+
}
|
3078
|
+
).bind('mousedown',
|
3079
|
+
function(eventMouseDown) {
|
3080
|
+
return true;
|
3081
|
+
}
|
3082
|
+
).show();
|
3083
|
+
},
|
3084
|
+
addHoverDom: function(setting, node) {
|
3085
|
+
if (data.getRoot(setting).showHoverDom) {
|
3086
|
+
node.isHover = true;
|
3087
|
+
if (setting.edit.enable) {
|
3088
|
+
view.addEditBtn(setting, node);
|
3089
|
+
view.addRemoveBtn(setting, node);
|
3090
|
+
}
|
3091
|
+
tools.apply(setting.view.addHoverDom, [setting.treeId, node]);
|
3092
|
+
}
|
3093
|
+
},
|
3094
|
+
cancelCurEditNode: function (setting, forceName) {
|
3095
|
+
var root = data.getRoot(setting),
|
3096
|
+
nameKey = setting.data.key.name,
|
3097
|
+
node = root.curEditNode;
|
3098
|
+
|
3099
|
+
if (node) {
|
3100
|
+
var inputObj = root.curEditInput;
|
3101
|
+
var newName = forceName ? forceName:inputObj.val();
|
3102
|
+
if (!forceName && tools.apply(setting.callback.beforeRename, [setting.treeId, node, newName], true) === false) {
|
3103
|
+
return false;
|
3104
|
+
} else {
|
3105
|
+
node[nameKey] = newName ? newName:inputObj.val();
|
3106
|
+
if (!forceName) {
|
3107
|
+
setting.treeObj.trigger(consts.event.RENAME, [setting.treeId, node]);
|
3108
|
+
}
|
3109
|
+
}
|
3110
|
+
var aObj = $("#" + node.tId + consts.id.A);
|
3111
|
+
aObj.removeClass(consts.node.CURSELECTED_EDIT);
|
3112
|
+
inputObj.unbind();
|
3113
|
+
view.setNodeName(setting, node);
|
3114
|
+
node.editNameFlag = false;
|
3115
|
+
root.curEditNode = null;
|
3116
|
+
root.curEditInput = null;
|
3117
|
+
view.selectNode(setting, node, false);
|
3118
|
+
}
|
3119
|
+
root.noSelection = true;
|
3120
|
+
return true;
|
3121
|
+
},
|
3122
|
+
editNode: function(setting, node) {
|
3123
|
+
var root = data.getRoot(setting);
|
3124
|
+
view.editNodeBlur = false;
|
3125
|
+
if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) {
|
3126
|
+
setTimeout(function() {tools.inputFocus(root.curEditInput);}, 0);
|
3127
|
+
return;
|
3128
|
+
}
|
3129
|
+
var nameKey = setting.data.key.name;
|
3130
|
+
node.editNameFlag = true;
|
3131
|
+
view.removeTreeDom(setting, node);
|
3132
|
+
view.cancelCurEditNode(setting);
|
3133
|
+
view.selectNode(setting, node, false);
|
3134
|
+
$("#" + node.tId + consts.id.SPAN).html("<input type=text class='rename' id='" + node.tId + consts.id.INPUT + "' treeNode" + consts.id.INPUT + " >");
|
3135
|
+
var inputObj = $("#" + node.tId + consts.id.INPUT);
|
3136
|
+
inputObj.attr("value", node[nameKey]);
|
3137
|
+
if (setting.edit.editNameSelectAll) {
|
3138
|
+
tools.inputSelect(inputObj);
|
3139
|
+
} else {
|
3140
|
+
tools.inputFocus(inputObj);
|
3141
|
+
}
|
3142
|
+
|
3143
|
+
inputObj.bind('blur', function(event) {
|
3144
|
+
if (!view.editNodeBlur) {
|
3145
|
+
view.cancelCurEditNode(setting);
|
3146
|
+
}
|
3147
|
+
}).bind('keydown', function(event) {
|
3148
|
+
if (event.keyCode=="13") {
|
3149
|
+
view.editNodeBlur = true;
|
3150
|
+
view.cancelCurEditNode(setting, null, true);
|
3151
|
+
} else if (event.keyCode=="27") {
|
3152
|
+
view.cancelCurEditNode(setting, node[nameKey]);
|
3153
|
+
}
|
3154
|
+
}).bind('click', function(event) {
|
3155
|
+
return false;
|
3156
|
+
}).bind('dblclick', function(event) {
|
3157
|
+
return false;
|
3158
|
+
});
|
3159
|
+
|
3160
|
+
$("#" + node.tId + consts.id.A).addClass(consts.node.CURSELECTED_EDIT);
|
3161
|
+
root.curEditInput = inputObj;
|
3162
|
+
root.noSelection = false;
|
3163
|
+
root.curEditNode = node;
|
3164
|
+
},
|
3165
|
+
moveNode: function(setting, targetNode, node, moveType, animateFlag, isSilent) {
|
3166
|
+
var root = data.getRoot(setting),
|
3167
|
+
childKey = setting.data.key.children;
|
3168
|
+
if (targetNode == node) return;
|
3169
|
+
if (setting.data.keep.leaf && targetNode && !targetNode.isParent && moveType == consts.move.TYPE_INNER) return;
|
3170
|
+
var oldParentNode = (node.parentTId ? node.getParentNode(): root),
|
3171
|
+
targetNodeIsRoot = (targetNode === null || targetNode == root);
|
3172
|
+
if (targetNodeIsRoot && targetNode === null) targetNode = root;
|
3173
|
+
if (targetNodeIsRoot) moveType = consts.move.TYPE_INNER;
|
3174
|
+
var targetParentNode = (targetNode.parentTId ? targetNode.getParentNode() : root);
|
3175
|
+
|
3176
|
+
if (moveType != consts.move.TYPE_PREV && moveType != consts.move.TYPE_NEXT) {
|
3177
|
+
moveType = consts.move.TYPE_INNER;
|
3178
|
+
}
|
3179
|
+
|
3180
|
+
if (moveType == consts.move.TYPE_INNER) {
|
3181
|
+
if (targetNodeIsRoot) {
|
3182
|
+
//parentTId of root node is null
|
3183
|
+
node.parentTId = null;
|
3184
|
+
} else {
|
3185
|
+
if (!targetNode.isParent) {
|
3186
|
+
targetNode.isParent = true;
|
3187
|
+
targetNode.open = !!targetNode.open;
|
3188
|
+
view.setNodeLineIcos(setting, targetNode);
|
3189
|
+
}
|
3190
|
+
node.parentTId = targetNode.tId;
|
3191
|
+
}
|
3192
|
+
}
|
3193
|
+
|
3194
|
+
//move node Dom
|
3195
|
+
var targetObj, target_ulObj;
|
3196
|
+
if (targetNodeIsRoot) {
|
3197
|
+
targetObj = setting.treeObj;
|
3198
|
+
target_ulObj = targetObj;
|
3199
|
+
} else {
|
3200
|
+
if (!isSilent && moveType == consts.move.TYPE_INNER) {
|
3201
|
+
view.expandCollapseNode(setting, targetNode, true, false);
|
3202
|
+
} else if (!isSilent) {
|
3203
|
+
view.expandCollapseNode(setting, targetNode.getParentNode(), true, false);
|
3204
|
+
}
|
3205
|
+
targetObj = $("#" + targetNode.tId);
|
3206
|
+
target_ulObj = $("#" + targetNode.tId + consts.id.UL);
|
3207
|
+
if (!!targetObj.get(0) && !target_ulObj.get(0)) {
|
3208
|
+
var ulstr = [];
|
3209
|
+
view.makeUlHtml(setting, targetNode, ulstr, '');
|
3210
|
+
targetObj.append(ulstr.join(''));
|
3211
|
+
}
|
3212
|
+
target_ulObj = $("#" + targetNode.tId + consts.id.UL);
|
3213
|
+
}
|
3214
|
+
var nodeDom = $("#" + node.tId);
|
3215
|
+
if (!nodeDom.get(0)) {
|
3216
|
+
nodeDom = view.appendNodes(setting, node.level, [node], null, false, true).join('');
|
3217
|
+
} else if (!targetObj.get(0)) {
|
3218
|
+
nodeDom.remove();
|
3219
|
+
}
|
3220
|
+
if (target_ulObj.get(0) && moveType == consts.move.TYPE_INNER) {
|
3221
|
+
target_ulObj.append(nodeDom);
|
3222
|
+
} else if (targetObj.get(0) && moveType == consts.move.TYPE_PREV) {
|
3223
|
+
targetObj.before(nodeDom);
|
3224
|
+
} else if (targetObj.get(0) && moveType == consts.move.TYPE_NEXT) {
|
3225
|
+
targetObj.after(nodeDom);
|
3226
|
+
}
|
3227
|
+
|
3228
|
+
//repair the data after move
|
3229
|
+
var i,l,
|
3230
|
+
tmpSrcIndex = -1,
|
3231
|
+
tmpTargetIndex = 0,
|
3232
|
+
oldNeighbor = null,
|
3233
|
+
newNeighbor = null,
|
3234
|
+
oldLevel = node.level;
|
3235
|
+
if (node.isFirstNode) {
|
3236
|
+
tmpSrcIndex = 0;
|
3237
|
+
if (oldParentNode[childKey].length > 1 ) {
|
3238
|
+
oldNeighbor = oldParentNode[childKey][1];
|
3239
|
+
oldNeighbor.isFirstNode = true;
|
3240
|
+
}
|
3241
|
+
} else if (node.isLastNode) {
|
3242
|
+
tmpSrcIndex = oldParentNode[childKey].length -1;
|
3243
|
+
oldNeighbor = oldParentNode[childKey][tmpSrcIndex - 1];
|
3244
|
+
oldNeighbor.isLastNode = true;
|
3245
|
+
} else {
|
3246
|
+
for (i = 0, l = oldParentNode[childKey].length; i < l; i++) {
|
3247
|
+
if (oldParentNode[childKey][i].tId == node.tId) {
|
3248
|
+
tmpSrcIndex = i;
|
3249
|
+
break;
|
3250
|
+
}
|
3251
|
+
}
|
3252
|
+
}
|
3253
|
+
if (tmpSrcIndex >= 0) {
|
3254
|
+
oldParentNode[childKey].splice(tmpSrcIndex, 1);
|
3255
|
+
}
|
3256
|
+
if (moveType != consts.move.TYPE_INNER) {
|
3257
|
+
for (i = 0, l = targetParentNode[childKey].length; i < l; i++) {
|
3258
|
+
if (targetParentNode[childKey][i].tId == targetNode.tId) tmpTargetIndex = i;
|
3259
|
+
}
|
3260
|
+
}
|
3261
|
+
if (moveType == consts.move.TYPE_INNER) {
|
3262
|
+
if (!targetNode[childKey]) targetNode[childKey] = new Array();
|
3263
|
+
if (targetNode[childKey].length > 0) {
|
3264
|
+
newNeighbor = targetNode[childKey][targetNode[childKey].length - 1];
|
3265
|
+
newNeighbor.isLastNode = false;
|
3266
|
+
}
|
3267
|
+
targetNode[childKey].splice(targetNode[childKey].length, 0, node);
|
3268
|
+
node.isLastNode = true;
|
3269
|
+
node.isFirstNode = (targetNode[childKey].length == 1);
|
3270
|
+
} else if (targetNode.isFirstNode && moveType == consts.move.TYPE_PREV) {
|
3271
|
+
targetParentNode[childKey].splice(tmpTargetIndex, 0, node);
|
3272
|
+
newNeighbor = targetNode;
|
3273
|
+
newNeighbor.isFirstNode = false;
|
3274
|
+
node.parentTId = targetNode.parentTId;
|
3275
|
+
node.isFirstNode = true;
|
3276
|
+
node.isLastNode = false;
|
3277
|
+
|
3278
|
+
} else if (targetNode.isLastNode && moveType == consts.move.TYPE_NEXT) {
|
3279
|
+
targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node);
|
3280
|
+
newNeighbor = targetNode;
|
3281
|
+
newNeighbor.isLastNode = false;
|
3282
|
+
node.parentTId = targetNode.parentTId;
|
3283
|
+
node.isFirstNode = false;
|
3284
|
+
node.isLastNode = true;
|
3285
|
+
|
3286
|
+
} else {
|
3287
|
+
if (moveType == consts.move.TYPE_PREV) {
|
3288
|
+
targetParentNode[childKey].splice(tmpTargetIndex, 0, node);
|
3289
|
+
} else {
|
3290
|
+
targetParentNode[childKey].splice(tmpTargetIndex + 1, 0, node);
|
3291
|
+
}
|
3292
|
+
node.parentTId = targetNode.parentTId;
|
3293
|
+
node.isFirstNode = false;
|
3294
|
+
node.isLastNode = false;
|
3295
|
+
}
|
3296
|
+
data.fixPIdKeyValue(setting, node);
|
3297
|
+
data.setSonNodeLevel(setting, node.getParentNode(), node);
|
3298
|
+
|
3299
|
+
//repair node what been moved
|
3300
|
+
view.setNodeLineIcos(setting, node);
|
3301
|
+
view.repairNodeLevelClass(setting, node, oldLevel)
|
3302
|
+
|
3303
|
+
//repair node's old parentNode dom
|
3304
|
+
if (!setting.data.keep.parent && oldParentNode[childKey].length < 1) {
|
3305
|
+
//old parentNode has no child nodes
|
3306
|
+
oldParentNode.isParent = false;
|
3307
|
+
oldParentNode.open = false;
|
3308
|
+
var tmp_ulObj = $("#" + oldParentNode.tId + consts.id.UL),
|
3309
|
+
tmp_switchObj = $("#" + oldParentNode.tId + consts.id.SWITCH),
|
3310
|
+
tmp_icoObj = $("#" + oldParentNode.tId + consts.id.ICON);
|
3311
|
+
view.replaceSwitchClass(oldParentNode, tmp_switchObj, consts.folder.DOCU);
|
3312
|
+
view.replaceIcoClass(oldParentNode, tmp_icoObj, consts.folder.DOCU);
|
3313
|
+
tmp_ulObj.css("display", "none");
|
3314
|
+
|
3315
|
+
} else if (oldNeighbor) {
|
3316
|
+
//old neigbor node
|
3317
|
+
view.setNodeLineIcos(setting, oldNeighbor);
|
3318
|
+
}
|
3319
|
+
|
3320
|
+
//new neigbor node
|
3321
|
+
if (newNeighbor) {
|
3322
|
+
view.setNodeLineIcos(setting, newNeighbor);
|
3323
|
+
}
|
3324
|
+
|
3325
|
+
//repair checkbox / radio
|
3326
|
+
if (!!setting.check && setting.check.enable && view.repairChkClass) {
|
3327
|
+
view.repairChkClass(setting, oldParentNode);
|
3328
|
+
view.repairParentChkClassWithSelf(setting, oldParentNode);
|
3329
|
+
if (oldParentNode != node.parent)
|
3330
|
+
view.repairParentChkClassWithSelf(setting, node);
|
3331
|
+
}
|
3332
|
+
|
3333
|
+
//expand parents after move
|
3334
|
+
if (!isSilent) {
|
3335
|
+
view.expandCollapseParentNode(setting, node.getParentNode(), true, animateFlag);
|
3336
|
+
}
|
3337
|
+
},
|
3338
|
+
removeEditBtn: function(node) {
|
3339
|
+
$("#" + node.tId + consts.id.EDIT).unbind().remove();
|
3340
|
+
},
|
3341
|
+
removeRemoveBtn: function(node) {
|
3342
|
+
$("#" + node.tId + consts.id.REMOVE).unbind().remove();
|
3343
|
+
},
|
3344
|
+
removeTreeDom: function(setting, node) {
|
3345
|
+
node.isHover = false;
|
3346
|
+
view.removeEditBtn(node);
|
3347
|
+
view.removeRemoveBtn(node);
|
3348
|
+
tools.apply(setting.view.removeHoverDom, [setting.treeId, node]);
|
3349
|
+
},
|
3350
|
+
repairNodeLevelClass: function(setting, node, oldLevel) {
|
3351
|
+
if (oldLevel === node.level) return;
|
3352
|
+
var liObj = $("#" + node.tId),
|
3353
|
+
aObj = $("#" + node.tId + consts.id.A),
|
3354
|
+
ulObj = $("#" + node.tId + consts.id.UL),
|
3355
|
+
oldClass = "level" + oldLevel,
|
3356
|
+
newClass = "level" + node.level;
|
3357
|
+
liObj.removeClass(oldClass);
|
3358
|
+
liObj.addClass(newClass);
|
3359
|
+
aObj.removeClass(oldClass);
|
3360
|
+
aObj.addClass(newClass);
|
3361
|
+
ulObj.removeClass(oldClass);
|
3362
|
+
ulObj.addClass(newClass);
|
3363
|
+
}
|
3364
|
+
},
|
3365
|
+
|
3366
|
+
_z = {
|
3367
|
+
tools: _tools,
|
3368
|
+
view: _view,
|
3369
|
+
event: _event,
|
3370
|
+
data: _data
|
3371
|
+
};
|
3372
|
+
$.extend(true, $.fn.zTree.consts, _consts);
|
3373
|
+
$.extend(true, $.fn.zTree._z, _z);
|
3374
|
+
|
3375
|
+
var zt = $.fn.zTree,
|
3376
|
+
tools = zt._z.tools,
|
3377
|
+
consts = zt.consts,
|
3378
|
+
view = zt._z.view,
|
3379
|
+
data = zt._z.data,
|
3380
|
+
event = zt._z.event;
|
3381
|
+
|
3382
|
+
data.exSetting(_setting);
|
3383
|
+
data.addInitBind(_bindEvent);
|
3384
|
+
data.addInitUnBind(_unbindEvent);
|
3385
|
+
data.addInitCache(_initCache);
|
3386
|
+
data.addInitNode(_initNode);
|
3387
|
+
data.addInitProxy(_eventProxy);
|
3388
|
+
data.addInitRoot(_initRoot);
|
3389
|
+
data.addZTreeTools(_zTreeTools);
|
3390
|
+
|
3391
|
+
var _cancelPreSelectedNode = view.cancelPreSelectedNode;
|
3392
|
+
view.cancelPreSelectedNode = function (setting, node) {
|
3393
|
+
var list = data.getRoot(setting).curSelectedList;
|
3394
|
+
for (var i=0, j=list.length; i<j; i++) {
|
3395
|
+
if (!node || node === list[i]) {
|
3396
|
+
view.removeTreeDom(setting, list[i]);
|
3397
|
+
if (node) break;
|
3398
|
+
}
|
3399
|
+
}
|
3400
|
+
if (_cancelPreSelectedNode) _cancelPreSelectedNode.apply(view, arguments);
|
3401
|
+
}
|
3402
|
+
|
3403
|
+
var _createNodes = view.createNodes;
|
3404
|
+
view.createNodes = function(setting, level, nodes, parentNode) {
|
3405
|
+
if (_createNodes) {
|
3406
|
+
_createNodes.apply(view, arguments);
|
3407
|
+
}
|
3408
|
+
if (!nodes) return;
|
3409
|
+
if (view.repairParentChkClassWithSelf) {
|
3410
|
+
view.repairParentChkClassWithSelf(setting, parentNode);
|
3411
|
+
}
|
3412
|
+
}
|
3413
|
+
|
3414
|
+
var _makeNodeUrl = view.makeNodeUrl;
|
3415
|
+
view.makeNodeUrl = function(setting, node) {
|
3416
|
+
return setting.edit.enable ? null : (_makeNodeUrl.apply(view, arguments));
|
3417
|
+
}
|
3418
|
+
|
3419
|
+
var _removeNode = view.removeNode;
|
3420
|
+
view.removeNode = function(setting, node) {
|
3421
|
+
var root = data.getRoot(setting);
|
3422
|
+
if (root.curEditNode === node) root.curEditNode = null;
|
3423
|
+
if (_removeNode) {
|
3424
|
+
_removeNode.apply(view, arguments);
|
3425
|
+
}
|
3426
|
+
}
|
3427
|
+
|
3428
|
+
var _selectNode = view.selectNode;
|
3429
|
+
view.selectNode = function(setting, node, addFlag) {
|
3430
|
+
var root = data.getRoot(setting);
|
3431
|
+
if (data.isSelectedNode(setting, node) && root.curEditNode == node && node.editNameFlag) {
|
3432
|
+
return false;
|
3433
|
+
}
|
3434
|
+
if (_selectNode) _selectNode.apply(view, arguments);
|
3435
|
+
view.addHoverDom(setting, node);
|
3436
|
+
return true;
|
3437
|
+
}
|
3438
|
+
|
3439
|
+
var _uCanDo = tools.uCanDo;
|
3440
|
+
tools.uCanDo = function(setting, e) {
|
3441
|
+
var root = data.getRoot(setting);
|
3442
|
+
if (e && (tools.eqs(e.type, "mouseover") || tools.eqs(e.type, "mouseout") || tools.eqs(e.type, "mousedown") || tools.eqs(e.type, "mouseup"))) {
|
3443
|
+
return true;
|
3444
|
+
}
|
3445
|
+
return (!root.curEditNode) && (_uCanDo ? _uCanDo.apply(view, arguments) : true);
|
3446
|
+
}
|
3447
|
+
})(jQuery);
|