tocmd 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/bin/tocmd +70 -0
  3. data/lib/mdpreview/markdown_render.rb +45 -0
  4. data/lib/mdpreview/translator.rb +237 -0
  5. data/lib/mdpreview/version.rb +3 -0
  6. data/lib/mdpreview.rb +18 -0
  7. data/test/mdptest.rb +100 -0
  8. data/vendor/cur.file +6 -0
  9. data/vendor/meta.js +1 -0
  10. data/vendor/template.html +0 -0
  11. data/vendor/toc/css/demo.css +33 -0
  12. data/vendor/toc/css/zTreeStyle/img/diy/1_close.png +0 -0
  13. data/vendor/toc/css/zTreeStyle/img/diy/1_open.png +0 -0
  14. data/vendor/toc/css/zTreeStyle/img/diy/2.png +0 -0
  15. data/vendor/toc/css/zTreeStyle/img/diy/3.png +0 -0
  16. data/vendor/toc/css/zTreeStyle/img/diy/4.png +0 -0
  17. data/vendor/toc/css/zTreeStyle/img/diy/5.png +0 -0
  18. data/vendor/toc/css/zTreeStyle/img/diy/6.png +0 -0
  19. data/vendor/toc/css/zTreeStyle/img/diy/7.png +0 -0
  20. data/vendor/toc/css/zTreeStyle/img/diy/8.png +0 -0
  21. data/vendor/toc/css/zTreeStyle/img/diy/9.png +0 -0
  22. data/vendor/toc/css/zTreeStyle/img/line_conn.gif +0 -0
  23. data/vendor/toc/css/zTreeStyle/img/loading.gif +0 -0
  24. data/vendor/toc/css/zTreeStyle/img/zTreeStandard.gif +0 -0
  25. data/vendor/toc/css/zTreeStyle/img/zTreeStandard.png +0 -0
  26. data/vendor/toc/css/zTreeStyle/zTreeStyle.css +97 -0
  27. data/vendor/toc/js/jquery-1.4.4.min.js +167 -0
  28. data/vendor/toc/js/jquery.ztree.all-3.5.js +3447 -0
  29. data/vendor/toc/js/jquery.ztree.all-3.5.min.js +157 -0
  30. data/vendor/toc/js/jquery.ztree.core-3.5.js +1644 -0
  31. data/vendor/toc/js/jquery.ztree.core-3.5.min.js +68 -0
  32. data/vendor/toc/js/jquery.ztree.excheck-3.5.js +624 -0
  33. data/vendor/toc/js/jquery.ztree.excheck-3.5.min.js +33 -0
  34. data/vendor/toc/js/jquery.ztree.exedit-3.5.js +1178 -0
  35. data/vendor/toc/js/jquery.ztree.exedit-3.5.min.js +52 -0
  36. data/vendor/toc/js/jquery.ztree.exhide-3.5.js +362 -0
  37. data/vendor/toc/js/jquery.ztree.exhide-3.5.min.js +22 -0
  38. data/vendor/toc/js/jquery.ztree_toc.js +224 -0
  39. data/vendor/toc/js/jquery.ztree_toc.min.js +4 -0
  40. data/vendor/toc/style/Clearness Dark.css +146 -0
  41. data/vendor/toc/style/Clearness.css +147 -0
  42. data/vendor/toc/style/GitHub.css +90 -0
  43. data/vendor/toc/style/GitHub2.css +297 -0
  44. data/vendor/toc/style/github-bf51422f4bb36427d391e4b75a1daa083c2d840e.css +1 -0
  45. data/vendor/toc/style/github2-d731afd4f624c99a4b19ad69f3083cd6d02b81d5.css +1 -0
  46. data/vendor/toc/style/makedownpad.css +285 -0
  47. metadata +90 -0
@@ -0,0 +1,624 @@
1
+ /*
2
+ * JQuery zTree excheck 3.5.02
3
+ * http://zTree.me/
4
+ *
5
+ * Copyright (c) 2010 Hunter.z
6
+ *
7
+ * Licensed same as jquery - MIT License
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ * email: hunter.z@263.net
11
+ * Date: 2013-01-28
12
+ */
13
+ (function($){
14
+ //default consts of excheck
15
+ var _consts = {
16
+ event: {
17
+ CHECK: "ztree_check"
18
+ },
19
+ id: {
20
+ CHECK: "_check"
21
+ },
22
+ checkbox: {
23
+ STYLE: "checkbox",
24
+ DEFAULT: "chk",
25
+ DISABLED: "disable",
26
+ FALSE: "false",
27
+ TRUE: "true",
28
+ FULL: "full",
29
+ PART: "part",
30
+ FOCUS: "focus"
31
+ },
32
+ radio: {
33
+ STYLE: "radio",
34
+ TYPE_ALL: "all",
35
+ TYPE_LEVEL: "level"
36
+ }
37
+ },
38
+ //default setting of excheck
39
+ _setting = {
40
+ check: {
41
+ enable: false,
42
+ autoCheckTrigger: false,
43
+ chkStyle: _consts.checkbox.STYLE,
44
+ nocheckInherit: false,
45
+ chkDisabledInherit: false,
46
+ radioType: _consts.radio.TYPE_LEVEL,
47
+ chkboxType: {
48
+ "Y": "ps",
49
+ "N": "ps"
50
+ }
51
+ },
52
+ data: {
53
+ key: {
54
+ checked: "checked"
55
+ }
56
+ },
57
+ callback: {
58
+ beforeCheck:null,
59
+ onCheck:null
60
+ }
61
+ },
62
+ //default root of excheck
63
+ _initRoot = function (setting) {
64
+ var r = data.getRoot(setting);
65
+ r.radioCheckedList = [];
66
+ },
67
+ //default cache of excheck
68
+ _initCache = function(treeId) {},
69
+ //default bind event of excheck
70
+ _bindEvent = function(setting) {
71
+ var o = setting.treeObj,
72
+ c = consts.event;
73
+ o.bind(c.CHECK, function (event, srcEvent, treeId, node) {
74
+ tools.apply(setting.callback.onCheck, [!!srcEvent?srcEvent : event, treeId, node]);
75
+ });
76
+ },
77
+ _unbindEvent = function(setting) {
78
+ var o = setting.treeObj,
79
+ c = consts.event;
80
+ o.unbind(c.CHECK);
81
+ },
82
+ //default event proxy of excheck
83
+ _eventProxy = function(e) {
84
+ var target = e.target,
85
+ setting = data.getSetting(e.data.treeId),
86
+ tId = "", node = null,
87
+ nodeEventType = "", treeEventType = "",
88
+ nodeEventCallback = null, treeEventCallback = null;
89
+
90
+ if (tools.eqs(e.type, "mouseover")) {
91
+ if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
92
+ tId = target.parentNode.id;
93
+ nodeEventType = "mouseoverCheck";
94
+ }
95
+ } else if (tools.eqs(e.type, "mouseout")) {
96
+ if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
97
+ tId = target.parentNode.id;
98
+ nodeEventType = "mouseoutCheck";
99
+ }
100
+ } else if (tools.eqs(e.type, "click")) {
101
+ if (setting.check.enable && tools.eqs(target.tagName, "span") && target.getAttribute("treeNode"+ consts.id.CHECK) !== null) {
102
+ tId = target.parentNode.id;
103
+ nodeEventType = "checkNode";
104
+ }
105
+ }
106
+ if (tId.length>0) {
107
+ node = data.getNodeCache(setting, tId);
108
+ switch (nodeEventType) {
109
+ case "checkNode" :
110
+ nodeEventCallback = _handler.onCheckNode;
111
+ break;
112
+ case "mouseoverCheck" :
113
+ nodeEventCallback = _handler.onMouseoverCheck;
114
+ break;
115
+ case "mouseoutCheck" :
116
+ nodeEventCallback = _handler.onMouseoutCheck;
117
+ break;
118
+ }
119
+ }
120
+ var proxyResult = {
121
+ stop: false,
122
+ node: node,
123
+ nodeEventType: nodeEventType,
124
+ nodeEventCallback: nodeEventCallback,
125
+ treeEventType: treeEventType,
126
+ treeEventCallback: treeEventCallback
127
+ };
128
+ return proxyResult
129
+ },
130
+ //default init node of excheck
131
+ _initNode = function(setting, level, n, parentNode, isFirstNode, isLastNode, openFlag) {
132
+ if (!n) return;
133
+ var checkedKey = setting.data.key.checked;
134
+ if (typeof n[checkedKey] == "string") n[checkedKey] = tools.eqs(n[checkedKey], "true");
135
+ n[checkedKey] = !!n[checkedKey];
136
+ n.checkedOld = n[checkedKey];
137
+ if (typeof n.nocheck == "string") n.nocheck = tools.eqs(n.nocheck, "true");
138
+ n.nocheck = !!n.nocheck || (setting.check.nocheckInherit && parentNode && !!parentNode.nocheck);
139
+ if (typeof n.chkDisabled == "string") n.chkDisabled = tools.eqs(n.chkDisabled, "true");
140
+ n.chkDisabled = !!n.chkDisabled || (setting.check.chkDisabledInherit && parentNode && !!parentNode.chkDisabled);
141
+ if (typeof n.halfCheck == "string") n.halfCheck = tools.eqs(n.halfCheck, "true");
142
+ n.halfCheck = !!n.halfCheck;
143
+ n.check_Child_State = -1;
144
+ n.check_Focus = false;
145
+ n.getCheckStatus = function() {return data.getCheckStatus(setting, n);};
146
+ },
147
+ //add dom for check
148
+ _beforeA = function(setting, node, html) {
149
+ var checkedKey = setting.data.key.checked;
150
+ if (setting.check.enable) {
151
+ data.makeChkFlag(setting, node);
152
+ if (setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL && node[checkedKey] ) {
153
+ var r = data.getRoot(setting);
154
+ r.radioCheckedList.push(node);
155
+ }
156
+ 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>");
157
+ }
158
+ },
159
+ //update zTreeObj, add method of check
160
+ _zTreeTools = function(setting, zTreeTools) {
161
+ zTreeTools.checkNode = function(node, checked, checkTypeFlag, callbackFlag) {
162
+ var checkedKey = this.setting.data.key.checked;
163
+ if (node.chkDisabled === true) return;
164
+ if (checked !== true && checked !== false) {
165
+ checked = !node[checkedKey];
166
+ }
167
+ callbackFlag = !!callbackFlag;
168
+
169
+ if (node[checkedKey] === checked && !checkTypeFlag) {
170
+ return;
171
+ } else if (callbackFlag && tools.apply(this.setting.callback.beforeCheck, [this.setting.treeId, node], true) == false) {
172
+ return;
173
+ }
174
+ if (tools.uCanDo(this.setting) && this.setting.check.enable && node.nocheck !== true) {
175
+ node[checkedKey] = checked;
176
+ var checkObj = $("#" + node.tId + consts.id.CHECK);
177
+ if (checkTypeFlag || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
178
+ view.setChkClass(this.setting, checkObj, node);
179
+ view.repairParentChkClassWithSelf(this.setting, node);
180
+ if (callbackFlag) {
181
+ setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
182
+ }
183
+ }
184
+ }
185
+
186
+ zTreeTools.checkAllNodes = function(checked) {
187
+ view.repairAllChk(this.setting, !!checked);
188
+ }
189
+
190
+ zTreeTools.getCheckedNodes = function(checked) {
191
+ var childKey = this.setting.data.key.children;
192
+ checked = (checked !== false);
193
+ return data.getTreeCheckedNodes(this.setting, data.getRoot(setting)[childKey], checked);
194
+ }
195
+
196
+ zTreeTools.getChangeCheckedNodes = function() {
197
+ var childKey = this.setting.data.key.children;
198
+ return data.getTreeChangeCheckedNodes(this.setting, data.getRoot(setting)[childKey]);
199
+ }
200
+
201
+ zTreeTools.setChkDisabled = function(node, disabled, inheritParent, inheritChildren) {
202
+ disabled = !!disabled;
203
+ inheritParent = !!inheritParent;
204
+ inheritChildren = !!inheritChildren;
205
+ view.repairSonChkDisabled(this.setting, node, disabled, inheritChildren);
206
+ view.repairParentChkDisabled(this.setting, node.getParentNode(), disabled, inheritParent);
207
+ }
208
+
209
+ var _updateNode = zTreeTools.updateNode;
210
+ zTreeTools.updateNode = function(node, checkTypeFlag) {
211
+ if (_updateNode) _updateNode.apply(zTreeTools, arguments);
212
+ if (!node || !this.setting.check.enable) return;
213
+ var nObj = $("#" + node.tId);
214
+ if (nObj.get(0) && tools.uCanDo(this.setting)) {
215
+ var checkObj = $("#" + node.tId + consts.id.CHECK);
216
+ if (checkTypeFlag == true || this.setting.check.chkStyle === consts.radio.STYLE) view.checkNodeRelation(this.setting, node);
217
+ view.setChkClass(this.setting, checkObj, node);
218
+ view.repairParentChkClassWithSelf(this.setting, node);
219
+ }
220
+ }
221
+ },
222
+ //method of operate data
223
+ _data = {
224
+ getRadioCheckedList: function(setting) {
225
+ var checkedList = data.getRoot(setting).radioCheckedList;
226
+ for (var i=0, j=checkedList.length; i<j; i++) {
227
+ if(!data.getNodeCache(setting, checkedList[i].tId)) {
228
+ checkedList.splice(i, 1);
229
+ i--; j--;
230
+ }
231
+ }
232
+ return checkedList;
233
+ },
234
+ getCheckStatus: function(setting, node) {
235
+ if (!setting.check.enable || node.nocheck || node.chkDisabled) return null;
236
+ var checkedKey = setting.data.key.checked,
237
+ r = {
238
+ checked: node[checkedKey],
239
+ 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)))
240
+ };
241
+ return r;
242
+ },
243
+ getTreeCheckedNodes: function(setting, nodes, checked, results) {
244
+ if (!nodes) return [];
245
+ var childKey = setting.data.key.children,
246
+ checkedKey = setting.data.key.checked,
247
+ onlyOne = (checked && setting.check.chkStyle == consts.radio.STYLE && setting.check.radioType == consts.radio.TYPE_ALL);
248
+ results = !results ? [] : results;
249
+ for (var i = 0, l = nodes.length; i < l; i++) {
250
+ if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] == checked) {
251
+ results.push(nodes[i]);
252
+ if(onlyOne) {
253
+ break;
254
+ }
255
+ }
256
+ data.getTreeCheckedNodes(setting, nodes[i][childKey], checked, results);
257
+ if(onlyOne && results.length > 0) {
258
+ break;
259
+ }
260
+ }
261
+ return results;
262
+ },
263
+ getTreeChangeCheckedNodes: function(setting, nodes, results) {
264
+ if (!nodes) return [];
265
+ var childKey = setting.data.key.children,
266
+ checkedKey = setting.data.key.checked;
267
+ results = !results ? [] : results;
268
+ for (var i = 0, l = nodes.length; i < l; i++) {
269
+ if (nodes[i].nocheck !== true && nodes[i].chkDisabled !== true && nodes[i][checkedKey] != nodes[i].checkedOld) {
270
+ results.push(nodes[i]);
271
+ }
272
+ data.getTreeChangeCheckedNodes(setting, nodes[i][childKey], results);
273
+ }
274
+ return results;
275
+ },
276
+ makeChkFlag: function(setting, node) {
277
+ if (!node) return;
278
+ var childKey = setting.data.key.children,
279
+ checkedKey = setting.data.key.checked,
280
+ chkFlag = -1;
281
+ if (node[childKey]) {
282
+ for (var i = 0, l = node[childKey].length; i < l; i++) {
283
+ var cNode = node[childKey][i];
284
+ var tmp = -1;
285
+ if (setting.check.chkStyle == consts.radio.STYLE) {
286
+ if (cNode.nocheck === true || cNode.chkDisabled === true) {
287
+ tmp = cNode.check_Child_State;
288
+ } else if (cNode.halfCheck === true) {
289
+ tmp = 2;
290
+ } else if (cNode[checkedKey]) {
291
+ tmp = 2;
292
+ } else {
293
+ tmp = cNode.check_Child_State > 0 ? 2:0;
294
+ }
295
+ if (tmp == 2) {
296
+ chkFlag = 2; break;
297
+ } else if (tmp == 0){
298
+ chkFlag = 0;
299
+ }
300
+ } else if (setting.check.chkStyle == consts.checkbox.STYLE) {
301
+ if (cNode.nocheck === true || cNode.chkDisabled === true) {
302
+ tmp = cNode.check_Child_State;
303
+ } else if (cNode.halfCheck === true) {
304
+ tmp = 1;
305
+ } else if (cNode[checkedKey] ) {
306
+ tmp = (cNode.check_Child_State === -1 || cNode.check_Child_State === 2) ? 2 : 1;
307
+ } else {
308
+ tmp = (cNode.check_Child_State > 0) ? 1 : 0;
309
+ }
310
+ if (tmp === 1) {
311
+ chkFlag = 1; break;
312
+ } else if (tmp === 2 && chkFlag > -1 && i > 0 && tmp !== chkFlag) {
313
+ chkFlag = 1; break;
314
+ } else if (chkFlag === 2 && tmp > -1 && tmp < 2) {
315
+ chkFlag = 1; break;
316
+ } else if (tmp > -1) {
317
+ chkFlag = tmp;
318
+ }
319
+ }
320
+ }
321
+ }
322
+ node.check_Child_State = chkFlag;
323
+ }
324
+ },
325
+ //method of event proxy
326
+ _event = {
327
+
328
+ },
329
+ //method of event handler
330
+ _handler = {
331
+ onCheckNode: function (event, node) {
332
+ if (node.chkDisabled === true) return false;
333
+ var setting = data.getSetting(event.data.treeId),
334
+ checkedKey = setting.data.key.checked;
335
+ if (tools.apply(setting.callback.beforeCheck, [setting.treeId, node], true) == false) return true;
336
+ node[checkedKey] = !node[checkedKey];
337
+ view.checkNodeRelation(setting, node);
338
+ var checkObj = $("#" + node.tId + consts.id.CHECK);
339
+ view.setChkClass(setting, checkObj, node);
340
+ view.repairParentChkClassWithSelf(setting, node);
341
+ setting.treeObj.trigger(consts.event.CHECK, [event, setting.treeId, node]);
342
+ return true;
343
+ },
344
+ onMouseoverCheck: function(event, node) {
345
+ if (node.chkDisabled === true) return false;
346
+ var setting = data.getSetting(event.data.treeId),
347
+ checkObj = $("#" + node.tId + consts.id.CHECK);
348
+ node.check_Focus = true;
349
+ view.setChkClass(setting, checkObj, node);
350
+ return true;
351
+ },
352
+ onMouseoutCheck: function(event, node) {
353
+ if (node.chkDisabled === true) return false;
354
+ var setting = data.getSetting(event.data.treeId),
355
+ checkObj = $("#" + node.tId + consts.id.CHECK);
356
+ node.check_Focus = false;
357
+ view.setChkClass(setting, checkObj, node);
358
+ return true;
359
+ }
360
+ },
361
+ //method of tools for zTree
362
+ _tools = {
363
+
364
+ },
365
+ //method of operate ztree dom
366
+ _view = {
367
+ checkNodeRelation: function(setting, node) {
368
+ var pNode, i, l,
369
+ childKey = setting.data.key.children,
370
+ checkedKey = setting.data.key.checked,
371
+ r = consts.radio;
372
+ if (setting.check.chkStyle == r.STYLE) {
373
+ var checkedList = data.getRadioCheckedList(setting);
374
+ if (node[checkedKey]) {
375
+ if (setting.check.radioType == r.TYPE_ALL) {
376
+ for (i = checkedList.length-1; i >= 0; i--) {
377
+ pNode = checkedList[i];
378
+ pNode[checkedKey] = false;
379
+ checkedList.splice(i, 1);
380
+
381
+ view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode);
382
+ if (pNode.parentTId != node.parentTId) {
383
+ view.repairParentChkClassWithSelf(setting, pNode);
384
+ }
385
+ }
386
+ checkedList.push(node);
387
+ } else {
388
+ var parentNode = (node.parentTId) ? node.getParentNode() : data.getRoot(setting);
389
+ for (i = 0, l = parentNode[childKey].length; i < l; i++) {
390
+ pNode = parentNode[childKey][i];
391
+ if (pNode[checkedKey] && pNode != node) {
392
+ pNode[checkedKey] = false;
393
+ view.setChkClass(setting, $("#" + pNode.tId + consts.id.CHECK), pNode);
394
+ }
395
+ }
396
+ }
397
+ } else if (setting.check.radioType == r.TYPE_ALL) {
398
+ for (i = 0, l = checkedList.length; i < l; i++) {
399
+ if (node == checkedList[i]) {
400
+ checkedList.splice(i, 1);
401
+ break;
402
+ }
403
+ }
404
+ }
405
+
406
+ } else {
407
+ if (node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.Y.indexOf("s") > -1)) {
408
+ view.setSonNodeCheckBox(setting, node, true);
409
+ }
410
+ if (!node[checkedKey] && (!node[childKey] || node[childKey].length==0 || setting.check.chkboxType.N.indexOf("s") > -1)) {
411
+ view.setSonNodeCheckBox(setting, node, false);
412
+ }
413
+ if (node[checkedKey] && setting.check.chkboxType.Y.indexOf("p") > -1) {
414
+ view.setParentNodeCheckBox(setting, node, true);
415
+ }
416
+ if (!node[checkedKey] && setting.check.chkboxType.N.indexOf("p") > -1) {
417
+ view.setParentNodeCheckBox(setting, node, false);
418
+ }
419
+ }
420
+ },
421
+ makeChkClass: function(setting, node) {
422
+ var checkedKey = setting.data.key.checked,
423
+ c = consts.checkbox, r = consts.radio,
424
+ fullStyle = "";
425
+ if (node.chkDisabled === true) {
426
+ fullStyle = c.DISABLED;
427
+ } else if (node.halfCheck) {
428
+ fullStyle = c.PART;
429
+ } else if (setting.check.chkStyle == r.STYLE) {
430
+ fullStyle = (node.check_Child_State < 1)? c.FULL:c.PART;
431
+ } else {
432
+ 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);
433
+ }
434
+ var chkName = setting.check.chkStyle + "_" + (node[checkedKey] ? c.TRUE : c.FALSE) + "_" + fullStyle;
435
+ chkName = (node.check_Focus && node.chkDisabled !== true) ? chkName + "_" + c.FOCUS : chkName;
436
+ return "button " + c.DEFAULT + " " + chkName;
437
+ },
438
+ repairAllChk: function(setting, checked) {
439
+ if (setting.check.enable && setting.check.chkStyle === consts.checkbox.STYLE) {
440
+ var checkedKey = setting.data.key.checked,
441
+ childKey = setting.data.key.children,
442
+ root = data.getRoot(setting);
443
+ for (var i = 0, l = root[childKey].length; i<l ; i++) {
444
+ var node = root[childKey][i];
445
+ if (node.nocheck !== true && node.chkDisabled !== true) {
446
+ node[checkedKey] = checked;
447
+ }
448
+ view.setSonNodeCheckBox(setting, node, checked);
449
+ }
450
+ }
451
+ },
452
+ repairChkClass: function(setting, node) {
453
+ if (!node) return;
454
+ data.makeChkFlag(setting, node);
455
+ if (node.nocheck !== true) {
456
+ var checkObj = $("#" + node.tId + consts.id.CHECK);
457
+ view.setChkClass(setting, checkObj, node);
458
+ }
459
+ },
460
+ repairParentChkClass: function(setting, node) {
461
+ if (!node || !node.parentTId) return;
462
+ var pNode = node.getParentNode();
463
+ view.repairChkClass(setting, pNode);
464
+ view.repairParentChkClass(setting, pNode);
465
+ },
466
+ repairParentChkClassWithSelf: function(setting, node) {
467
+ if (!node) return;
468
+ var childKey = setting.data.key.children;
469
+ if (node[childKey] && node[childKey].length > 0) {
470
+ view.repairParentChkClass(setting, node[childKey][0]);
471
+ } else {
472
+ view.repairParentChkClass(setting, node);
473
+ }
474
+ },
475
+ repairSonChkDisabled: function(setting, node, chkDisabled, inherit) {
476
+ if (!node) return;
477
+ var childKey = setting.data.key.children;
478
+ if (node.chkDisabled != chkDisabled) {
479
+ node.chkDisabled = chkDisabled;
480
+ }
481
+ view.repairChkClass(setting, node);
482
+ if (node[childKey] && inherit) {
483
+ for (var i = 0, l = node[childKey].length; i < l; i++) {
484
+ var sNode = node[childKey][i];
485
+ view.repairSonChkDisabled(setting, sNode, chkDisabled, inherit);
486
+ }
487
+ }
488
+ },
489
+ repairParentChkDisabled: function(setting, node, chkDisabled, inherit) {
490
+ if (!node) return;
491
+ if (node.chkDisabled != chkDisabled && inherit) {
492
+ node.chkDisabled = chkDisabled;
493
+ }
494
+ view.repairChkClass(setting, node);
495
+ view.repairParentChkDisabled(setting, node.getParentNode(), chkDisabled, inherit);
496
+ },
497
+ setChkClass: function(setting, obj, node) {
498
+ if (!obj) return;
499
+ if (node.nocheck === true) {
500
+ obj.hide();
501
+ } else {
502
+ obj.show();
503
+ }
504
+ obj.removeClass();
505
+ obj.addClass(view.makeChkClass(setting, node));
506
+ },
507
+ setParentNodeCheckBox: function(setting, node, value, srcNode) {
508
+ var childKey = setting.data.key.children,
509
+ checkedKey = setting.data.key.checked,
510
+ checkObj = $("#" + node.tId + consts.id.CHECK);
511
+ if (!srcNode) srcNode = node;
512
+ data.makeChkFlag(setting, node);
513
+ if (node.nocheck !== true && node.chkDisabled !== true) {
514
+ node[checkedKey] = value;
515
+ view.setChkClass(setting, checkObj, node);
516
+ if (setting.check.autoCheckTrigger && node != srcNode) {
517
+ setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
518
+ }
519
+ }
520
+ if (node.parentTId) {
521
+ var pSign = true;
522
+ if (!value) {
523
+ var pNodes = node.getParentNode()[childKey];
524
+ for (var i = 0, l = pNodes.length; i < l; i++) {
525
+ if ((pNodes[i].nocheck !== true && pNodes[i].chkDisabled !== true && pNodes[i][checkedKey])
526
+ || ((pNodes[i].nocheck === true || pNodes[i].chkDisabled === true) && pNodes[i].check_Child_State > 0)) {
527
+ pSign = false;
528
+ break;
529
+ }
530
+ }
531
+ }
532
+ if (pSign) {
533
+ view.setParentNodeCheckBox(setting, node.getParentNode(), value, srcNode);
534
+ }
535
+ }
536
+ },
537
+ setSonNodeCheckBox: function(setting, node, value, srcNode) {
538
+ if (!node) return;
539
+ var childKey = setting.data.key.children,
540
+ checkedKey = setting.data.key.checked,
541
+ checkObj = $("#" + node.tId + consts.id.CHECK);
542
+ if (!srcNode) srcNode = node;
543
+
544
+ var hasDisable = false;
545
+ if (node[childKey]) {
546
+ for (var i = 0, l = node[childKey].length; i < l && node.chkDisabled !== true; i++) {
547
+ var sNode = node[childKey][i];
548
+ view.setSonNodeCheckBox(setting, sNode, value, srcNode);
549
+ if (sNode.chkDisabled === true) hasDisable = true;
550
+ }
551
+ }
552
+
553
+ if (node != data.getRoot(setting) && node.chkDisabled !== true) {
554
+ if (hasDisable && node.nocheck !== true) {
555
+ data.makeChkFlag(setting, node);
556
+ }
557
+ if (node.nocheck !== true && node.chkDisabled !== true) {
558
+ node[checkedKey] = value;
559
+ if (!hasDisable) node.check_Child_State = (node[childKey] && node[childKey].length > 0) ? (value ? 2 : 0) : -1;
560
+ } else {
561
+ node.check_Child_State = -1;
562
+ }
563
+ view.setChkClass(setting, checkObj, node);
564
+ if (setting.check.autoCheckTrigger && node != srcNode && node.nocheck !== true && node.chkDisabled !== true) {
565
+ setting.treeObj.trigger(consts.event.CHECK, [null, setting.treeId, node]);
566
+ }
567
+ }
568
+
569
+ }
570
+ },
571
+
572
+ _z = {
573
+ tools: _tools,
574
+ view: _view,
575
+ event: _event,
576
+ data: _data
577
+ };
578
+ $.extend(true, $.fn.zTree.consts, _consts);
579
+ $.extend(true, $.fn.zTree._z, _z);
580
+
581
+ var zt = $.fn.zTree,
582
+ tools = zt._z.tools,
583
+ consts = zt.consts,
584
+ view = zt._z.view,
585
+ data = zt._z.data,
586
+ event = zt._z.event;
587
+
588
+ data.exSetting(_setting);
589
+ data.addInitBind(_bindEvent);
590
+ data.addInitUnBind(_unbindEvent);
591
+ data.addInitCache(_initCache);
592
+ data.addInitNode(_initNode);
593
+ data.addInitProxy(_eventProxy);
594
+ data.addInitRoot(_initRoot);
595
+ data.addBeforeA(_beforeA);
596
+ data.addZTreeTools(_zTreeTools);
597
+
598
+ var _createNodes = view.createNodes;
599
+ view.createNodes = function(setting, level, nodes, parentNode) {
600
+ if (_createNodes) _createNodes.apply(view, arguments);
601
+ if (!nodes) return;
602
+ view.repairParentChkClassWithSelf(setting, parentNode);
603
+ }
604
+ var _removeNode = view.removeNode;
605
+ view.removeNode = function(setting, node) {
606
+ var parentNode = node.getParentNode();
607
+ if (_removeNode) _removeNode.apply(view, arguments);
608
+ if (!node || !parentNode) return;
609
+ view.repairChkClass(setting, parentNode);
610
+ view.repairParentChkClass(setting, parentNode);
611
+ }
612
+
613
+ var _appendNodes = view.appendNodes;
614
+ view.appendNodes = function(setting, level, nodes, parentNode, initFlag, openFlag) {
615
+ var html = "";
616
+ if (_appendNodes) {
617
+ html = _appendNodes.apply(view, arguments);
618
+ }
619
+ if (parentNode) {
620
+ data.makeChkFlag(setting, parentNode);
621
+ }
622
+ return html;
623
+ }
624
+ })(jQuery);
@@ -0,0 +1,33 @@
1
+ /*
2
+ * JQuery zTree excheck 3.5.02
3
+ * http://zTree.me/
4
+ *
5
+ * Copyright (c) 2010 Hunter.z
6
+ *
7
+ * Licensed same as jquery - MIT License
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ * email: hunter.z@263.net
11
+ * Date: 2013-01-28
12
+ */
13
+ (function(m){var p,q,r,n={event:{CHECK:"ztree_check"},id:{CHECK:"_check"},checkbox:{STYLE:"checkbox",DEFAULT:"chk",DISABLED:"disable",FALSE:"false",TRUE:"true",FULL:"full",PART:"part",FOCUS:"focus"},radio:{STYLE:"radio",TYPE_ALL:"all",TYPE_LEVEL:"level"}},v={check:{enable:!1,autoCheckTrigger:!1,chkStyle:n.checkbox.STYLE,nocheckInherit:!1,chkDisabledInherit:!1,radioType:n.radio.TYPE_LEVEL,chkboxType:{Y:"ps",N:"ps"}},data:{key:{checked:"checked"}},callback:{beforeCheck:null,onCheck:null}};p=function(c,
14
+ a){if(a.chkDisabled===!0)return!1;var b=g.getSetting(c.data.treeId),d=b.data.key.checked;if(l.apply(b.callback.beforeCheck,[b.treeId,a],!0)==!1)return!0;a[d]=!a[d];e.checkNodeRelation(b,a);d=m("#"+a.tId+i.id.CHECK);e.setChkClass(b,d,a);e.repairParentChkClassWithSelf(b,a);b.treeObj.trigger(i.event.CHECK,[c,b.treeId,a]);return!0};q=function(c,a){if(a.chkDisabled===!0)return!1;var b=g.getSetting(c.data.treeId),d=m("#"+a.tId+i.id.CHECK);a.check_Focus=!0;e.setChkClass(b,d,a);return!0};r=function(c,a){if(a.chkDisabled===
15
+ !0)return!1;var b=g.getSetting(c.data.treeId),d=m("#"+a.tId+i.id.CHECK);a.check_Focus=!1;e.setChkClass(b,d,a);return!0};m.extend(!0,m.fn.zTree.consts,n);m.extend(!0,m.fn.zTree._z,{tools:{},view:{checkNodeRelation:function(c,a){var b,d,h,k=c.data.key.children,j=c.data.key.checked;b=i.radio;if(c.check.chkStyle==b.STYLE){var f=g.getRadioCheckedList(c);if(a[j])if(c.check.radioType==b.TYPE_ALL){for(d=f.length-1;d>=0;d--)b=f[d],b[j]=!1,f.splice(d,1),e.setChkClass(c,m("#"+b.tId+i.id.CHECK),b),b.parentTId!=
16
+ a.parentTId&&e.repairParentChkClassWithSelf(c,b);f.push(a)}else{f=a.parentTId?a.getParentNode():g.getRoot(c);for(d=0,h=f[k].length;d<h;d++)b=f[k][d],b[j]&&b!=a&&(b[j]=!1,e.setChkClass(c,m("#"+b.tId+i.id.CHECK),b))}else if(c.check.radioType==b.TYPE_ALL)for(d=0,h=f.length;d<h;d++)if(a==f[d]){f.splice(d,1);break}}else a[j]&&(!a[k]||a[k].length==0||c.check.chkboxType.Y.indexOf("s")>-1)&&e.setSonNodeCheckBox(c,a,!0),!a[j]&&(!a[k]||a[k].length==0||c.check.chkboxType.N.indexOf("s")>-1)&&e.setSonNodeCheckBox(c,
17
+ a,!1),a[j]&&c.check.chkboxType.Y.indexOf("p")>-1&&e.setParentNodeCheckBox(c,a,!0),!a[j]&&c.check.chkboxType.N.indexOf("p")>-1&&e.setParentNodeCheckBox(c,a,!1)},makeChkClass:function(c,a){var b=c.data.key.checked,d=i.checkbox,h=i.radio,k="",k=a.chkDisabled===!0?d.DISABLED:a.halfCheck?d.PART:c.check.chkStyle==h.STYLE?a.check_Child_State<1?d.FULL:d.PART:a[b]?a.check_Child_State===2||a.check_Child_State===-1?d.FULL:d.PART:a.check_Child_State<1?d.FULL:d.PART,b=c.check.chkStyle+"_"+(a[b]?d.TRUE:d.FALSE)+
18
+ "_"+k,b=a.check_Focus&&a.chkDisabled!==!0?b+"_"+d.FOCUS:b;return"button "+d.DEFAULT+" "+b},repairAllChk:function(c,a){if(c.check.enable&&c.check.chkStyle===i.checkbox.STYLE)for(var b=c.data.key.checked,d=c.data.key.children,h=g.getRoot(c),k=0,j=h[d].length;k<j;k++){var f=h[d][k];f.nocheck!==!0&&f.chkDisabled!==!0&&(f[b]=a);e.setSonNodeCheckBox(c,f,a)}},repairChkClass:function(c,a){if(a&&(g.makeChkFlag(c,a),a.nocheck!==!0)){var b=m("#"+a.tId+i.id.CHECK);e.setChkClass(c,b,a)}},repairParentChkClass:function(c,
19
+ a){if(a&&a.parentTId){var b=a.getParentNode();e.repairChkClass(c,b);e.repairParentChkClass(c,b)}},repairParentChkClassWithSelf:function(c,a){if(a){var b=c.data.key.children;a[b]&&a[b].length>0?e.repairParentChkClass(c,a[b][0]):e.repairParentChkClass(c,a)}},repairSonChkDisabled:function(c,a,b,d){if(a){var h=c.data.key.children;if(a.chkDisabled!=b)a.chkDisabled=b;e.repairChkClass(c,a);if(a[h]&&d)for(var k=0,j=a[h].length;k<j;k++)e.repairSonChkDisabled(c,a[h][k],b,d)}},repairParentChkDisabled:function(c,
20
+ a,b,d){if(a){if(a.chkDisabled!=b&&d)a.chkDisabled=b;e.repairChkClass(c,a);e.repairParentChkDisabled(c,a.getParentNode(),b,d)}},setChkClass:function(c,a,b){a&&(b.nocheck===!0?a.hide():a.show(),a.removeClass(),a.addClass(e.makeChkClass(c,b)))},setParentNodeCheckBox:function(c,a,b,d){var h=c.data.key.children,k=c.data.key.checked,j=m("#"+a.tId+i.id.CHECK);d||(d=a);g.makeChkFlag(c,a);a.nocheck!==!0&&a.chkDisabled!==!0&&(a[k]=b,e.setChkClass(c,j,a),c.check.autoCheckTrigger&&a!=d&&c.treeObj.trigger(i.event.CHECK,
21
+ [null,c.treeId,a]));if(a.parentTId){j=!0;if(!b)for(var h=a.getParentNode()[h],f=0,o=h.length;f<o;f++)if(h[f].nocheck!==!0&&h[f].chkDisabled!==!0&&h[f][k]||(h[f].nocheck===!0||h[f].chkDisabled===!0)&&h[f].check_Child_State>0){j=!1;break}j&&e.setParentNodeCheckBox(c,a.getParentNode(),b,d)}},setSonNodeCheckBox:function(c,a,b,d){if(a){var h=c.data.key.children,k=c.data.key.checked,j=m("#"+a.tId+i.id.CHECK);d||(d=a);var f=!1;if(a[h])for(var o=0,l=a[h].length;o<l&&a.chkDisabled!==!0;o++){var n=a[h][o];
22
+ e.setSonNodeCheckBox(c,n,b,d);n.chkDisabled===!0&&(f=!0)}if(a!=g.getRoot(c)&&a.chkDisabled!==!0){f&&a.nocheck!==!0&&g.makeChkFlag(c,a);if(a.nocheck!==!0&&a.chkDisabled!==!0){if(a[k]=b,!f)a.check_Child_State=a[h]&&a[h].length>0?b?2:0:-1}else a.check_Child_State=-1;e.setChkClass(c,j,a);c.check.autoCheckTrigger&&a!=d&&a.nocheck!==!0&&a.chkDisabled!==!0&&c.treeObj.trigger(i.event.CHECK,[null,c.treeId,a])}}}},event:{},data:{getRadioCheckedList:function(c){for(var a=g.getRoot(c).radioCheckedList,b=0,d=
23
+ a.length;b<d;b++)g.getNodeCache(c,a[b].tId)||(a.splice(b,1),b--,d--);return a},getCheckStatus:function(c,a){if(!c.check.enable||a.nocheck||a.chkDisabled)return null;var b=c.data.key.checked;return{checked:a[b],half:a.halfCheck?a.halfCheck:c.check.chkStyle==i.radio.STYLE?a.check_Child_State===2:a[b]?a.check_Child_State>-1&&a.check_Child_State<2:a.check_Child_State>0}},getTreeCheckedNodes:function(c,a,b,d){if(!a)return[];for(var h=c.data.key.children,k=c.data.key.checked,e=b&&c.check.chkStyle==i.radio.STYLE&&
24
+ c.check.radioType==i.radio.TYPE_ALL,d=!d?[]:d,f=0,o=a.length;f<o;f++){if(a[f].nocheck!==!0&&a[f].chkDisabled!==!0&&a[f][k]==b&&(d.push(a[f]),e))break;g.getTreeCheckedNodes(c,a[f][h],b,d);if(e&&d.length>0)break}return d},getTreeChangeCheckedNodes:function(c,a,b){if(!a)return[];for(var d=c.data.key.children,h=c.data.key.checked,b=!b?[]:b,k=0,e=a.length;k<e;k++)a[k].nocheck!==!0&&a[k].chkDisabled!==!0&&a[k][h]!=a[k].checkedOld&&b.push(a[k]),g.getTreeChangeCheckedNodes(c,a[k][d],b);return b},makeChkFlag:function(c,
25
+ a){if(a){var b=c.data.key.children,d=c.data.key.checked,h=-1;if(a[b])for(var e=0,j=a[b].length;e<j;e++){var f=a[b][e],g=-1;if(c.check.chkStyle==i.radio.STYLE)if(g=f.nocheck===!0||f.chkDisabled===!0?f.check_Child_State:f.halfCheck===!0?2:f[d]?2:f.check_Child_State>0?2:0,g==2){h=2;break}else g==0&&(h=0);else if(c.check.chkStyle==i.checkbox.STYLE)if(g=f.nocheck===!0||f.chkDisabled===!0?f.check_Child_State:f.halfCheck===!0?1:f[d]?f.check_Child_State===-1||f.check_Child_State===2?2:1:f.check_Child_State>
26
+ 0?1:0,g===1){h=1;break}else if(g===2&&h>-1&&e>0&&g!==h){h=1;break}else if(h===2&&g>-1&&g<2){h=1;break}else g>-1&&(h=g)}a.check_Child_State=h}}}});var n=m.fn.zTree,l=n._z.tools,i=n.consts,e=n._z.view,g=n._z.data;g.exSetting(v);g.addInitBind(function(c){c.treeObj.bind(i.event.CHECK,function(a,b,d,h){l.apply(c.callback.onCheck,[b?b:a,d,h])})});g.addInitUnBind(function(c){c.treeObj.unbind(i.event.CHECK)});g.addInitCache(function(){});g.addInitNode(function(c,a,b,d){if(b){a=c.data.key.checked;typeof b[a]==
27
+ "string"&&(b[a]=l.eqs(b[a],"true"));b[a]=!!b[a];b.checkedOld=b[a];if(typeof b.nocheck=="string")b.nocheck=l.eqs(b.nocheck,"true");b.nocheck=!!b.nocheck||c.check.nocheckInherit&&d&&!!d.nocheck;if(typeof b.chkDisabled=="string")b.chkDisabled=l.eqs(b.chkDisabled,"true");b.chkDisabled=!!b.chkDisabled||c.check.chkDisabledInherit&&d&&!!d.chkDisabled;if(typeof b.halfCheck=="string")b.halfCheck=l.eqs(b.halfCheck,"true");b.halfCheck=!!b.halfCheck;b.check_Child_State=-1;b.check_Focus=!1;b.getCheckStatus=function(){return g.getCheckStatus(c,
28
+ b)}}});g.addInitProxy(function(c){var a=c.target,b=g.getSetting(c.data.treeId),d="",h=null,e="",j=null;if(l.eqs(c.type,"mouseover")){if(b.check.enable&&l.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+i.id.CHECK)!==null)d=a.parentNode.id,e="mouseoverCheck"}else if(l.eqs(c.type,"mouseout")){if(b.check.enable&&l.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+i.id.CHECK)!==null)d=a.parentNode.id,e="mouseoutCheck"}else if(l.eqs(c.type,"click")&&b.check.enable&&l.eqs(a.tagName,"span")&&a.getAttribute("treeNode"+
29
+ i.id.CHECK)!==null)d=a.parentNode.id,e="checkNode";if(d.length>0)switch(h=g.getNodeCache(b,d),e){case "checkNode":j=p;break;case "mouseoverCheck":j=q;break;case "mouseoutCheck":j=r}return{stop:!1,node:h,nodeEventType:e,nodeEventCallback:j,treeEventType:"",treeEventCallback:null}});g.addInitRoot(function(c){g.getRoot(c).radioCheckedList=[]});g.addBeforeA(function(c,a,b){var d=c.data.key.checked;c.check.enable&&(g.makeChkFlag(c,a),c.check.chkStyle==i.radio.STYLE&&c.check.radioType==i.radio.TYPE_ALL&&
30
+ a[d]&&g.getRoot(c).radioCheckedList.push(a),b.push("<span ID='",a.tId,i.id.CHECK,"' class='",e.makeChkClass(c,a),"' treeNode",i.id.CHECK,a.nocheck===!0?" style='display:none;'":"","></span>"))});g.addZTreeTools(function(c,a){a.checkNode=function(a,b,g,j){var f=this.setting.data.key.checked;if(a.chkDisabled!==!0&&(b!==!0&&b!==!1&&(b=!a[f]),j=!!j,(a[f]!==b||g)&&!(j&&l.apply(this.setting.callback.beforeCheck,[this.setting.treeId,a],!0)==!1)&&l.uCanDo(this.setting)&&this.setting.check.enable&&a.nocheck!==
31
+ !0))a[f]=b,b=m("#"+a.tId+i.id.CHECK),(g||this.setting.check.chkStyle===i.radio.STYLE)&&e.checkNodeRelation(this.setting,a),e.setChkClass(this.setting,b,a),e.repairParentChkClassWithSelf(this.setting,a),j&&c.treeObj.trigger(i.event.CHECK,[null,c.treeId,a])};a.checkAllNodes=function(a){e.repairAllChk(this.setting,!!a)};a.getCheckedNodes=function(a){var b=this.setting.data.key.children;return g.getTreeCheckedNodes(this.setting,g.getRoot(c)[b],a!==!1)};a.getChangeCheckedNodes=function(){var a=this.setting.data.key.children;
32
+ return g.getTreeChangeCheckedNodes(this.setting,g.getRoot(c)[a])};a.setChkDisabled=function(a,b,c,g){b=!!b;c=!!c;e.repairSonChkDisabled(this.setting,a,b,!!g);e.repairParentChkDisabled(this.setting,a.getParentNode(),b,c)};var b=a.updateNode;a.updateNode=function(c,h){b&&b.apply(a,arguments);if(c&&this.setting.check.enable&&m("#"+c.tId).get(0)&&l.uCanDo(this.setting)){var g=m("#"+c.tId+i.id.CHECK);(h==!0||this.setting.check.chkStyle===i.radio.STYLE)&&e.checkNodeRelation(this.setting,c);e.setChkClass(this.setting,
33
+ g,c);e.repairParentChkClassWithSelf(this.setting,c)}}});var s=e.createNodes;e.createNodes=function(c,a,b,d){s&&s.apply(e,arguments);b&&e.repairParentChkClassWithSelf(c,d)};var t=e.removeNode;e.removeNode=function(c,a){var b=a.getParentNode();t&&t.apply(e,arguments);a&&b&&(e.repairChkClass(c,b),e.repairParentChkClass(c,b))};var u=e.appendNodes;e.appendNodes=function(c,a,b,d,h,i){var j="";u&&(j=u.apply(e,arguments));d&&g.makeChkFlag(c,d);return j}})(jQuery);