@iqworksai/common-components 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/DbSchemaBrowser/index.d.ts.map +1 -1
- package/dist/components/DbSchemaBrowser/types.d.ts +1 -1
- package/dist/components/DbSchemaBrowser/types.d.ts.map +1 -1
- package/dist/components/FileBrowser/index.d.ts.map +1 -1
- package/dist/index-6n5-C3qh.js +159 -0
- package/dist/index-BT9NbQL6.mjs +5204 -0
- package/dist/index-DP52KpOS.mjs +28446 -0
- package/dist/index-DozkkyY_.js +34 -0
- package/dist/index.cjs +1 -240
- package/dist/index.mjs +93 -41055
- package/dist/jquery-Cg-ZYQCq.js +13 -0
- package/dist/jquery-PS7a9kWs.mjs +3641 -0
- package/dist/jstree-C7qSDVkF.mjs +4249 -0
- package/dist/jstree-KNvGgmMd.js +37 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4249 @@
|
|
|
1
|
+
import { a as te } from "./jquery-PS7a9kWs.mjs";
|
|
2
|
+
var ie = { exports: {} };
|
|
3
|
+
(function(G) {
|
|
4
|
+
(function(l) {
|
|
5
|
+
G.exports ? G.exports = l(te) : l(jQuery);
|
|
6
|
+
})(function(l, y) {
|
|
7
|
+
/*!
|
|
8
|
+
* jsTree 3.3.17
|
|
9
|
+
* http://jstree.com/
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
|
|
12
|
+
*
|
|
13
|
+
* Licensed same as jquery - under the terms of the MIT License
|
|
14
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
15
|
+
*/
|
|
16
|
+
/*!
|
|
17
|
+
* if using jslint please allow for the jQuery global and use following options:
|
|
18
|
+
* jslint: loopfunc: true, browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true
|
|
19
|
+
*/
|
|
20
|
+
if (!l.jstree) {
|
|
21
|
+
var ee = 0, D = !1, q = !1, X = !1, Z = [], R = l("script:last").attr("src"), T = window.document, W = window.setImmediate, b = window.Promise;
|
|
22
|
+
!W && b && (W = function(e, s) {
|
|
23
|
+
b.resolve(s).then(e);
|
|
24
|
+
}), l.jstree = {
|
|
25
|
+
/**
|
|
26
|
+
* specifies the jstree version in use
|
|
27
|
+
* @name $.jstree.version
|
|
28
|
+
*/
|
|
29
|
+
version: "3.3.17",
|
|
30
|
+
/**
|
|
31
|
+
* holds all the default options used when creating new instances
|
|
32
|
+
* @name $.jstree.defaults
|
|
33
|
+
*/
|
|
34
|
+
defaults: {
|
|
35
|
+
/**
|
|
36
|
+
* configure which plugins will be active on an instance. Should be an array of strings, where each element is a plugin name. The default is `[]`
|
|
37
|
+
* @name $.jstree.defaults.plugins
|
|
38
|
+
*/
|
|
39
|
+
plugins: []
|
|
40
|
+
},
|
|
41
|
+
/**
|
|
42
|
+
* stores all loaded jstree plugins (used internally)
|
|
43
|
+
* @name $.jstree.plugins
|
|
44
|
+
*/
|
|
45
|
+
plugins: {},
|
|
46
|
+
path: R && R.indexOf("/") !== -1 ? R.replace(/\/[^\/]+$/, "") : "",
|
|
47
|
+
idregex: /[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g,
|
|
48
|
+
root: "#"
|
|
49
|
+
}, l.jstree.create = function(e, s) {
|
|
50
|
+
var t = new l.jstree.core(++ee), i = s;
|
|
51
|
+
return s = l.extend(!0, {}, l.jstree.defaults, s), i && i.plugins && (s.plugins = i.plugins), l.each(s.plugins, function(r, a) {
|
|
52
|
+
r !== "core" && (t = t.plugin(a, s[a]));
|
|
53
|
+
}), l(e).data("jstree", t), t.init(e, s), t;
|
|
54
|
+
}, l.jstree.destroy = function() {
|
|
55
|
+
l(".jstree:jstree").jstree("destroy"), l(T).off(".jstree");
|
|
56
|
+
}, l.jstree.core = function(e) {
|
|
57
|
+
this._id = e, this._cnt = 0, this._wrk = null, this._data = {
|
|
58
|
+
core: {
|
|
59
|
+
themes: {
|
|
60
|
+
name: !1,
|
|
61
|
+
dots: !1,
|
|
62
|
+
icons: !1,
|
|
63
|
+
ellipsis: !1
|
|
64
|
+
},
|
|
65
|
+
selected: [],
|
|
66
|
+
last_error: {},
|
|
67
|
+
working: !1,
|
|
68
|
+
worker_queue: [],
|
|
69
|
+
focused: null
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}, l.jstree.reference = function(e) {
|
|
73
|
+
var s = null, t = null;
|
|
74
|
+
if (e && e.id && (!e.tagName || !e.nodeType) && (e = e.id), !t || !t.length)
|
|
75
|
+
try {
|
|
76
|
+
t = l(e);
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
if (!t || !t.length)
|
|
80
|
+
try {
|
|
81
|
+
t = l("#" + e.replace(l.jstree.idregex, "\\$&"));
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
return t && t.length && (t = t.closest(".jstree")).length && (t = t.data("jstree")) ? s = t : l(".jstree").each(function() {
|
|
85
|
+
var i = l(this).data("jstree");
|
|
86
|
+
if (i && i._model.data[e])
|
|
87
|
+
return s = i, !1;
|
|
88
|
+
}), s;
|
|
89
|
+
}, l.fn.jstree = function(e) {
|
|
90
|
+
var s = typeof e == "string", t = Array.prototype.slice.call(arguments, 1), i = null;
|
|
91
|
+
return e === !0 && !this.length ? !1 : (this.each(function() {
|
|
92
|
+
var r = l.jstree.reference(this), a = s && r ? r[e] : null;
|
|
93
|
+
if (i = s && a ? a.apply(r, t) : null, !r && !s && (e === y || l.isPlainObject(e)) && l.jstree.create(this, e), (r && !s || e === !0) && (i = r || !1), i !== null && i !== y)
|
|
94
|
+
return !1;
|
|
95
|
+
}), i !== null && i !== y ? i : this);
|
|
96
|
+
}, l.expr.pseudos.jstree = l.expr.createPseudo(function(e) {
|
|
97
|
+
return function(s) {
|
|
98
|
+
return l(s).hasClass("jstree") && l(s).data("jstree") !== y;
|
|
99
|
+
};
|
|
100
|
+
}), l.jstree.defaults.core = {
|
|
101
|
+
/**
|
|
102
|
+
* data configuration
|
|
103
|
+
*
|
|
104
|
+
* If left as `false` the HTML inside the jstree container element is used to populate the tree (that should be an unordered list with list items).
|
|
105
|
+
*
|
|
106
|
+
* You can also pass in a HTML string or a JSON array here.
|
|
107
|
+
*
|
|
108
|
+
* It is possible to pass in a standard jQuery-like AJAX config and jstree will automatically determine if the response is JSON or HTML and use that to populate the tree.
|
|
109
|
+
* In addition to the standard jQuery ajax options here you can supply functions for `data` and `url`, the functions will be run in the current instance's scope and a param will be passed indicating which node is being loaded, the return value of those functions will be used.
|
|
110
|
+
*
|
|
111
|
+
* The last option is to specify a function, that function will receive the node being loaded as argument and a second param which is a function which should be called with the result.
|
|
112
|
+
*
|
|
113
|
+
* __Examples__
|
|
114
|
+
*
|
|
115
|
+
* // AJAX
|
|
116
|
+
* $('#tree').jstree({
|
|
117
|
+
* 'core' : {
|
|
118
|
+
* 'data' : {
|
|
119
|
+
* 'url' : '/get/children/',
|
|
120
|
+
* 'data' : function (node) {
|
|
121
|
+
* return { 'id' : node.id };
|
|
122
|
+
* }
|
|
123
|
+
* }
|
|
124
|
+
* });
|
|
125
|
+
*
|
|
126
|
+
* // direct data
|
|
127
|
+
* $('#tree').jstree({
|
|
128
|
+
* 'core' : {
|
|
129
|
+
* 'data' : [
|
|
130
|
+
* 'Simple root node',
|
|
131
|
+
* {
|
|
132
|
+
* 'id' : 'node_2',
|
|
133
|
+
* 'text' : 'Root node with options',
|
|
134
|
+
* 'state' : { 'opened' : true, 'selected' : true },
|
|
135
|
+
* 'children' : [ { 'text' : 'Child 1' }, 'Child 2']
|
|
136
|
+
* }
|
|
137
|
+
* ]
|
|
138
|
+
* }
|
|
139
|
+
* });
|
|
140
|
+
*
|
|
141
|
+
* // function
|
|
142
|
+
* $('#tree').jstree({
|
|
143
|
+
* 'core' : {
|
|
144
|
+
* 'data' : function (obj, callback) {
|
|
145
|
+
* callback.call(this, ['Root 1', 'Root 2']);
|
|
146
|
+
* }
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* @name $.jstree.defaults.core.data
|
|
150
|
+
*/
|
|
151
|
+
data: !1,
|
|
152
|
+
/**
|
|
153
|
+
* configure the various strings used throughout the tree
|
|
154
|
+
*
|
|
155
|
+
* You can use an object where the key is the string you need to replace and the value is your replacement.
|
|
156
|
+
* Another option is to specify a function which will be called with an argument of the needed string and should return the replacement.
|
|
157
|
+
* If left as `false` no replacement is made.
|
|
158
|
+
*
|
|
159
|
+
* __Examples__
|
|
160
|
+
*
|
|
161
|
+
* $('#tree').jstree({
|
|
162
|
+
* 'core' : {
|
|
163
|
+
* 'strings' : {
|
|
164
|
+
* 'Loading ...' : 'Please wait ...'
|
|
165
|
+
* }
|
|
166
|
+
* }
|
|
167
|
+
* });
|
|
168
|
+
*
|
|
169
|
+
* @name $.jstree.defaults.core.strings
|
|
170
|
+
*/
|
|
171
|
+
strings: !1,
|
|
172
|
+
/**
|
|
173
|
+
* determines what happens when a user tries to modify the structure of the tree
|
|
174
|
+
* If left as `false` all operations like create, rename, delete, move or copy are prevented.
|
|
175
|
+
* You can set this to `true` to allow all interactions or use a function to have better control.
|
|
176
|
+
*
|
|
177
|
+
* __Examples__
|
|
178
|
+
*
|
|
179
|
+
* $('#tree').jstree({
|
|
180
|
+
* 'core' : {
|
|
181
|
+
* 'check_callback' : function (operation, node, node_parent, node_position, more) {
|
|
182
|
+
* // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node', 'copy_node' or 'edit'
|
|
183
|
+
* // in case of 'rename_node' node_position is filled with the new node name
|
|
184
|
+
* return operation === 'rename_node' ? true : false;
|
|
185
|
+
* }
|
|
186
|
+
* }
|
|
187
|
+
* });
|
|
188
|
+
*
|
|
189
|
+
* @name $.jstree.defaults.core.check_callback
|
|
190
|
+
*/
|
|
191
|
+
check_callback: !1,
|
|
192
|
+
/**
|
|
193
|
+
* a callback called with a single object parameter in the instance's scope when something goes wrong (operation prevented, ajax failed, etc)
|
|
194
|
+
* @name $.jstree.defaults.core.error
|
|
195
|
+
*/
|
|
196
|
+
error: l.noop,
|
|
197
|
+
/**
|
|
198
|
+
* the open / close animation duration in milliseconds - set this to `false` to disable the animation (default is `200`)
|
|
199
|
+
* @name $.jstree.defaults.core.animation
|
|
200
|
+
*/
|
|
201
|
+
animation: 200,
|
|
202
|
+
/**
|
|
203
|
+
* a boolean indicating if multiple nodes can be selected
|
|
204
|
+
* @name $.jstree.defaults.core.multiple
|
|
205
|
+
*/
|
|
206
|
+
multiple: !0,
|
|
207
|
+
/**
|
|
208
|
+
* theme configuration object
|
|
209
|
+
* @name $.jstree.defaults.core.themes
|
|
210
|
+
*/
|
|
211
|
+
themes: {
|
|
212
|
+
/**
|
|
213
|
+
* the name of the theme to use (if left as `false` the default theme is used)
|
|
214
|
+
* @name $.jstree.defaults.core.themes.name
|
|
215
|
+
*/
|
|
216
|
+
name: !1,
|
|
217
|
+
/**
|
|
218
|
+
* the URL of the theme's CSS file, leave this as `false` if you have manually included the theme CSS (recommended). You can set this to `true` too which will try to autoload the theme.
|
|
219
|
+
* @name $.jstree.defaults.core.themes.url
|
|
220
|
+
*/
|
|
221
|
+
url: !1,
|
|
222
|
+
/**
|
|
223
|
+
* the location of all jstree themes - only used if `url` is set to `true`
|
|
224
|
+
* @name $.jstree.defaults.core.themes.dir
|
|
225
|
+
*/
|
|
226
|
+
dir: !1,
|
|
227
|
+
/**
|
|
228
|
+
* a boolean indicating if connecting dots are shown
|
|
229
|
+
* @name $.jstree.defaults.core.themes.dots
|
|
230
|
+
*/
|
|
231
|
+
dots: !0,
|
|
232
|
+
/**
|
|
233
|
+
* a boolean indicating if node icons are shown
|
|
234
|
+
* @name $.jstree.defaults.core.themes.icons
|
|
235
|
+
*/
|
|
236
|
+
icons: !0,
|
|
237
|
+
/**
|
|
238
|
+
* a boolean indicating if node ellipsis should be shown - this only works with a fixed with on the container
|
|
239
|
+
* @name $.jstree.defaults.core.themes.ellipsis
|
|
240
|
+
*/
|
|
241
|
+
ellipsis: !1,
|
|
242
|
+
/**
|
|
243
|
+
* a boolean indicating if the tree background is striped
|
|
244
|
+
* @name $.jstree.defaults.core.themes.stripes
|
|
245
|
+
*/
|
|
246
|
+
stripes: !1,
|
|
247
|
+
/**
|
|
248
|
+
* a string (or boolean `false`) specifying the theme variant to use (if the theme supports variants)
|
|
249
|
+
* @name $.jstree.defaults.core.themes.variant
|
|
250
|
+
*/
|
|
251
|
+
variant: !1,
|
|
252
|
+
/**
|
|
253
|
+
* a boolean specifying if a reponsive version of the theme should kick in on smaller screens (if the theme supports it). Defaults to `false`.
|
|
254
|
+
* @name $.jstree.defaults.core.themes.responsive
|
|
255
|
+
*/
|
|
256
|
+
responsive: !1
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* if left as `true` all parents of all selected nodes will be opened once the tree loads (so that all selected nodes are visible to the user)
|
|
260
|
+
* @name $.jstree.defaults.core.expand_selected_onload
|
|
261
|
+
*/
|
|
262
|
+
expand_selected_onload: !0,
|
|
263
|
+
/**
|
|
264
|
+
* if left as `true` web workers will be used to parse incoming JSON data where possible, so that the UI will not be blocked by large requests. Workers are however about 30% slower. Defaults to `true`
|
|
265
|
+
* @name $.jstree.defaults.core.worker
|
|
266
|
+
*/
|
|
267
|
+
worker: !0,
|
|
268
|
+
/**
|
|
269
|
+
* Force node text to plain text (and escape HTML). Defaults to `false`
|
|
270
|
+
* @name $.jstree.defaults.core.force_text
|
|
271
|
+
*/
|
|
272
|
+
force_text: !1,
|
|
273
|
+
/**
|
|
274
|
+
* Should the node be toggled if the text is double clicked. Defaults to `true`
|
|
275
|
+
* @name $.jstree.defaults.core.dblclick_toggle
|
|
276
|
+
*/
|
|
277
|
+
dblclick_toggle: !0,
|
|
278
|
+
/**
|
|
279
|
+
* Should the loaded nodes be part of the state. Defaults to `false`
|
|
280
|
+
* @name $.jstree.defaults.core.loaded_state
|
|
281
|
+
*/
|
|
282
|
+
loaded_state: !1,
|
|
283
|
+
/**
|
|
284
|
+
* Should the last active node be focused when the tree container is blurred and the focused again. This helps working with screen readers. Defaults to `true`
|
|
285
|
+
* @name $.jstree.defaults.core.restore_focus
|
|
286
|
+
*/
|
|
287
|
+
restore_focus: !0,
|
|
288
|
+
/**
|
|
289
|
+
* Force to compute and set "aria-setsize" and "aria-posinset" explicitly for each treeitem.
|
|
290
|
+
* Some browsers may compute incorrect elements position and produce wrong announcements for screen readers. Defaults to `false`
|
|
291
|
+
* @name $.jstree.defaults.core.compute_elements_positions
|
|
292
|
+
*/
|
|
293
|
+
compute_elements_positions: !1,
|
|
294
|
+
/**
|
|
295
|
+
* Default keyboard shortcuts (an object where each key is the button name or combo - like 'enter', 'ctrl-space', 'p', etc and the value is the function to execute in the instance's scope)
|
|
296
|
+
* @name $.jstree.defaults.core.keyboard
|
|
297
|
+
*/
|
|
298
|
+
keyboard: {
|
|
299
|
+
"ctrl-space": function(e) {
|
|
300
|
+
e.type = "click", l(e.currentTarget).trigger(e);
|
|
301
|
+
},
|
|
302
|
+
enter: function(e) {
|
|
303
|
+
e.type = "click", l(e.currentTarget).trigger(e);
|
|
304
|
+
},
|
|
305
|
+
left: function(e) {
|
|
306
|
+
if (e.preventDefault(), this.is_open(e.currentTarget))
|
|
307
|
+
this.close_node(e.currentTarget);
|
|
308
|
+
else {
|
|
309
|
+
var s = this.get_parent(e.currentTarget);
|
|
310
|
+
s && s.id !== l.jstree.root && this.get_node(s, !0).children(".jstree-anchor").trigger("focus");
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
up: function(e) {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
var s = this.get_prev_dom(e.currentTarget);
|
|
316
|
+
s && s.length && s.children(".jstree-anchor").trigger("focus");
|
|
317
|
+
},
|
|
318
|
+
right: function(e) {
|
|
319
|
+
if (e.preventDefault(), this.is_closed(e.currentTarget))
|
|
320
|
+
this.open_node(e.currentTarget, function(t) {
|
|
321
|
+
this.get_node(t, !0).children(".jstree-anchor").trigger("focus");
|
|
322
|
+
});
|
|
323
|
+
else if (this.is_open(e.currentTarget)) {
|
|
324
|
+
var s = this.get_node(e.currentTarget, !0).children(".jstree-children")[0];
|
|
325
|
+
s && l(this._firstChild(s)).children(".jstree-anchor").trigger("focus");
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
down: function(e) {
|
|
329
|
+
e.preventDefault();
|
|
330
|
+
var s = this.get_next_dom(e.currentTarget);
|
|
331
|
+
s && s.length && s.children(".jstree-anchor").trigger("focus");
|
|
332
|
+
},
|
|
333
|
+
"*": function(e) {
|
|
334
|
+
this.open_all();
|
|
335
|
+
},
|
|
336
|
+
home: function(e) {
|
|
337
|
+
e.preventDefault();
|
|
338
|
+
var s = this._firstChild(this.get_container_ul()[0]);
|
|
339
|
+
s && l(s).children(".jstree-anchor").filter(":visible").trigger("focus");
|
|
340
|
+
},
|
|
341
|
+
end: function(e) {
|
|
342
|
+
e.preventDefault(), this.element.find(".jstree-anchor").filter(":visible").last().trigger("focus");
|
|
343
|
+
},
|
|
344
|
+
f2: function(e) {
|
|
345
|
+
e.preventDefault(), this.edit(e.currentTarget);
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
/**
|
|
349
|
+
* Should reselecting an already selected node trigger the select and changed callbacks
|
|
350
|
+
* @name $.jstree.defaults.core.allow_reselect
|
|
351
|
+
*/
|
|
352
|
+
allow_reselect: !1
|
|
353
|
+
}, l.jstree.core.prototype = {
|
|
354
|
+
/**
|
|
355
|
+
* used to decorate an instance with a plugin. Used internally.
|
|
356
|
+
* @private
|
|
357
|
+
* @name plugin(deco [, opts])
|
|
358
|
+
* @param {String} deco the plugin to decorate with
|
|
359
|
+
* @param {Object} opts options for the plugin
|
|
360
|
+
* @return {jsTree}
|
|
361
|
+
*/
|
|
362
|
+
plugin: function(e, s) {
|
|
363
|
+
var t = l.jstree.plugins[e];
|
|
364
|
+
return t ? (this._data[e] = {}, t.prototype = this, new t(s, this)) : this;
|
|
365
|
+
},
|
|
366
|
+
/**
|
|
367
|
+
* initialize the instance. Used internally.
|
|
368
|
+
* @private
|
|
369
|
+
* @name init(el, optons)
|
|
370
|
+
* @param {DOMElement|jQuery|String} el the element we are transforming
|
|
371
|
+
* @param {Object} options options for this instance
|
|
372
|
+
* @trigger init.jstree, loading.jstree, loaded.jstree, ready.jstree, changed.jstree
|
|
373
|
+
*/
|
|
374
|
+
init: function(e, s) {
|
|
375
|
+
this._model = {
|
|
376
|
+
data: {},
|
|
377
|
+
changed: [],
|
|
378
|
+
force_full_redraw: !1,
|
|
379
|
+
redraw_timeout: !1,
|
|
380
|
+
default_state: {
|
|
381
|
+
loaded: !0,
|
|
382
|
+
opened: !1,
|
|
383
|
+
selected: !1,
|
|
384
|
+
disabled: !1
|
|
385
|
+
}
|
|
386
|
+
}, this._model.data[l.jstree.root] = {
|
|
387
|
+
id: l.jstree.root,
|
|
388
|
+
parent: null,
|
|
389
|
+
parents: [],
|
|
390
|
+
children: [],
|
|
391
|
+
children_d: [],
|
|
392
|
+
state: { loaded: !1 }
|
|
393
|
+
}, this.element = l(e).addClass("jstree jstree-" + this._id), this.settings = s, this._data.core.ready = !1, this._data.core.loaded = !1, this._data.core.rtl = this.element.css("direction") === "rtl", this.element[this._data.core.rtl ? "addClass" : "removeClass"]("jstree-rtl"), this.element.attr("role", "tree"), this.settings.core.multiple && this.element.attr("aria-multiselectable", !0), this.element.attr("tabindex") || this.element.attr("tabindex", "0"), this.bind(), this.trigger("init"), this._data.core.original_container_html = this.element.find(" > ul > li").clone(!0), this._data.core.original_container_html.find("li").addBack().contents().filter(function() {
|
|
394
|
+
return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue));
|
|
395
|
+
}).remove(), this.element.html("<ul class='jstree-container-ul jstree-children' role='group'><li id='j" + this._id + "_loading' class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='none'><i class='jstree-icon jstree-ocl'></i><a class='jstree-anchor' role='treeitem' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>" + this.get_string("Loading ...") + "</a></li></ul>"), this.element.attr("aria-activedescendant", "j" + this._id + "_loading"), this._data.core.li_height = this.get_container_ul().children("li").first().outerHeight() || 24, this._data.core.node = this._create_prototype_node(), this.trigger("loading"), this.load_node(l.jstree.root);
|
|
396
|
+
},
|
|
397
|
+
/**
|
|
398
|
+
* destroy an instance
|
|
399
|
+
* @name destroy()
|
|
400
|
+
* @param {Boolean} keep_html if not set to `true` the container will be emptied, otherwise the current DOM elements will be kept intact
|
|
401
|
+
*/
|
|
402
|
+
destroy: function(e) {
|
|
403
|
+
if (this.trigger("destroy"), this._wrk)
|
|
404
|
+
try {
|
|
405
|
+
window.URL.revokeObjectURL(this._wrk), this._wrk = null;
|
|
406
|
+
} catch {
|
|
407
|
+
}
|
|
408
|
+
e || this.element.empty(), this.teardown();
|
|
409
|
+
},
|
|
410
|
+
/**
|
|
411
|
+
* Create a prototype node
|
|
412
|
+
* @name _create_prototype_node()
|
|
413
|
+
* @return {DOMElement}
|
|
414
|
+
*/
|
|
415
|
+
_create_prototype_node: function() {
|
|
416
|
+
var e = T.createElement("LI"), s, t;
|
|
417
|
+
return e.setAttribute("role", "none"), s = T.createElement("I"), s.className = "jstree-icon jstree-ocl", s.setAttribute("role", "presentation"), e.appendChild(s), s = T.createElement("A"), s.className = "jstree-anchor", s.setAttribute("href", "#"), s.setAttribute("tabindex", "-1"), s.setAttribute("role", "treeitem"), t = T.createElement("I"), t.className = "jstree-icon jstree-themeicon", t.setAttribute("role", "presentation"), s.appendChild(t), e.appendChild(s), s = t = null, e;
|
|
418
|
+
},
|
|
419
|
+
_kbevent_to_func: function(e) {
|
|
420
|
+
var s = {
|
|
421
|
+
8: "Backspace",
|
|
422
|
+
9: "Tab",
|
|
423
|
+
13: "Enter",
|
|
424
|
+
19: "Pause",
|
|
425
|
+
27: "Esc",
|
|
426
|
+
32: "Space",
|
|
427
|
+
33: "PageUp",
|
|
428
|
+
34: "PageDown",
|
|
429
|
+
35: "End",
|
|
430
|
+
36: "Home",
|
|
431
|
+
37: "Left",
|
|
432
|
+
38: "Up",
|
|
433
|
+
39: "Right",
|
|
434
|
+
40: "Down",
|
|
435
|
+
44: "Print",
|
|
436
|
+
45: "Insert",
|
|
437
|
+
46: "Delete",
|
|
438
|
+
96: "Numpad0",
|
|
439
|
+
97: "Numpad1",
|
|
440
|
+
98: "Numpad2",
|
|
441
|
+
99: "Numpad3",
|
|
442
|
+
100: "Numpad4",
|
|
443
|
+
101: "Numpad5",
|
|
444
|
+
102: "Numpad6",
|
|
445
|
+
103: "Numpad7",
|
|
446
|
+
104: "Numpad8",
|
|
447
|
+
105: "Numpad9",
|
|
448
|
+
"-13": "NumpadEnter",
|
|
449
|
+
112: "F1",
|
|
450
|
+
113: "F2",
|
|
451
|
+
114: "F3",
|
|
452
|
+
115: "F4",
|
|
453
|
+
116: "F5",
|
|
454
|
+
117: "F6",
|
|
455
|
+
118: "F7",
|
|
456
|
+
119: "F8",
|
|
457
|
+
120: "F9",
|
|
458
|
+
121: "F10",
|
|
459
|
+
122: "F11",
|
|
460
|
+
123: "F12",
|
|
461
|
+
144: "Numlock",
|
|
462
|
+
145: "Scrolllock",
|
|
463
|
+
16: "Shift",
|
|
464
|
+
17: "Ctrl",
|
|
465
|
+
18: "Alt",
|
|
466
|
+
48: "0",
|
|
467
|
+
49: "1",
|
|
468
|
+
50: "2",
|
|
469
|
+
51: "3",
|
|
470
|
+
52: "4",
|
|
471
|
+
53: "5",
|
|
472
|
+
54: "6",
|
|
473
|
+
55: "7",
|
|
474
|
+
56: "8",
|
|
475
|
+
57: "9",
|
|
476
|
+
59: ";",
|
|
477
|
+
61: "=",
|
|
478
|
+
65: "a",
|
|
479
|
+
66: "b",
|
|
480
|
+
67: "c",
|
|
481
|
+
68: "d",
|
|
482
|
+
69: "e",
|
|
483
|
+
70: "f",
|
|
484
|
+
71: "g",
|
|
485
|
+
72: "h",
|
|
486
|
+
73: "i",
|
|
487
|
+
74: "j",
|
|
488
|
+
75: "k",
|
|
489
|
+
76: "l",
|
|
490
|
+
77: "m",
|
|
491
|
+
78: "n",
|
|
492
|
+
79: "o",
|
|
493
|
+
80: "p",
|
|
494
|
+
81: "q",
|
|
495
|
+
82: "r",
|
|
496
|
+
83: "s",
|
|
497
|
+
84: "t",
|
|
498
|
+
85: "u",
|
|
499
|
+
86: "v",
|
|
500
|
+
87: "w",
|
|
501
|
+
88: "x",
|
|
502
|
+
89: "y",
|
|
503
|
+
90: "z",
|
|
504
|
+
107: "+",
|
|
505
|
+
109: "-",
|
|
506
|
+
110: ".",
|
|
507
|
+
186: ";",
|
|
508
|
+
187: "=",
|
|
509
|
+
188: ",",
|
|
510
|
+
189: "-",
|
|
511
|
+
190: ".",
|
|
512
|
+
191: "/",
|
|
513
|
+
192: "`",
|
|
514
|
+
219: "[",
|
|
515
|
+
220: "\\",
|
|
516
|
+
221: "]",
|
|
517
|
+
222: "'",
|
|
518
|
+
111: "/",
|
|
519
|
+
106: "*",
|
|
520
|
+
173: "-"
|
|
521
|
+
}, t = [];
|
|
522
|
+
if (e.ctrlKey && t.push("ctrl"), e.altKey && t.push("alt"), e.shiftKey && t.push("shift"), t.push(s[e.which] ? s[e.which].toLowerCase() : e.which), t = t.sort().join("-").toLowerCase(), t === "shift-shift" || t === "ctrl-ctrl" || t === "alt-alt")
|
|
523
|
+
return null;
|
|
524
|
+
var i = this.settings.core.keyboard, r, a;
|
|
525
|
+
for (r in i)
|
|
526
|
+
if (i.hasOwnProperty(r) && (a = r, a !== "-" && a !== "+" && (a = a.replace("--", "-MINUS").replace("+-", "-MINUS").replace("++", "-PLUS").replace("-+", "-PLUS"), a = a.split(/-|\+/).sort().join("-").replace("MINUS", "-").replace("PLUS", "+").toLowerCase()), a === t))
|
|
527
|
+
return i[r];
|
|
528
|
+
return null;
|
|
529
|
+
},
|
|
530
|
+
/**
|
|
531
|
+
* part of the destroying of an instance. Used internally.
|
|
532
|
+
* @private
|
|
533
|
+
* @name teardown()
|
|
534
|
+
*/
|
|
535
|
+
teardown: function() {
|
|
536
|
+
this.unbind(), this.element.removeClass("jstree").removeData("jstree").find("[class^='jstree']").addBack().attr("class", function() {
|
|
537
|
+
return this.className.replace(/jstree[^ ]*|$/ig, "");
|
|
538
|
+
}), this.element = null;
|
|
539
|
+
},
|
|
540
|
+
/**
|
|
541
|
+
* bind all events. Used internally.
|
|
542
|
+
* @private
|
|
543
|
+
* @name bind()
|
|
544
|
+
*/
|
|
545
|
+
bind: function() {
|
|
546
|
+
var e = "", s = null, t = 0;
|
|
547
|
+
this.element.on("dblclick.jstree", function(i) {
|
|
548
|
+
if (i.target.tagName && i.target.tagName.toLowerCase() === "input")
|
|
549
|
+
return !0;
|
|
550
|
+
if (T.selection && T.selection.empty)
|
|
551
|
+
T.selection.empty();
|
|
552
|
+
else if (window.getSelection) {
|
|
553
|
+
var r = window.getSelection();
|
|
554
|
+
try {
|
|
555
|
+
r.removeAllRanges(), r.collapse();
|
|
556
|
+
} catch {
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}).on("mousedown.jstree", (function(i) {
|
|
560
|
+
i.target === this.element[0] && (i.preventDefault(), t = +/* @__PURE__ */ new Date());
|
|
561
|
+
}).bind(this)).on("mousedown.jstree", ".jstree-ocl", function(i) {
|
|
562
|
+
i.preventDefault();
|
|
563
|
+
}).on("click.jstree", ".jstree-ocl", (function(i) {
|
|
564
|
+
this.toggle_node(i.target);
|
|
565
|
+
}).bind(this)).on("dblclick.jstree", ".jstree-anchor", (function(i) {
|
|
566
|
+
if (i.target.tagName && i.target.tagName.toLowerCase() === "input")
|
|
567
|
+
return !0;
|
|
568
|
+
this.settings.core.dblclick_toggle && this.toggle_node(i.target);
|
|
569
|
+
}).bind(this)).on("click.jstree", ".jstree-anchor", (function(i) {
|
|
570
|
+
i.preventDefault(), i.currentTarget !== T.activeElement && l(i.currentTarget).trigger("focus"), this.activate_node(i.currentTarget, i);
|
|
571
|
+
}).bind(this)).on("keydown.jstree", ".jstree-anchor", (function(i) {
|
|
572
|
+
if (i.target.tagName && i.target.tagName.toLowerCase() === "input")
|
|
573
|
+
return !0;
|
|
574
|
+
this._data.core.rtl && (i.which === 37 ? i.which = 39 : i.which === 39 && (i.which = 37));
|
|
575
|
+
var r = this._kbevent_to_func(i);
|
|
576
|
+
if (r) {
|
|
577
|
+
var a = r.call(this, i);
|
|
578
|
+
if (a === !1 || a === !0)
|
|
579
|
+
return a;
|
|
580
|
+
}
|
|
581
|
+
}).bind(this)).on("load_node.jstree", (function(i, r) {
|
|
582
|
+
r.status && (r.node.id === l.jstree.root && !this._data.core.loaded && (this._data.core.loaded = !0, this._firstChild(this.get_container_ul()[0]) && this.element.attr("aria-activedescendant", this._firstChild(this.get_container_ul()[0]).id), this.trigger("loaded")), this._data.core.ready || setTimeout((function() {
|
|
583
|
+
if (this.element && !this.get_container_ul().find(".jstree-loading").length) {
|
|
584
|
+
if (this._data.core.ready = !0, this._data.core.selected.length) {
|
|
585
|
+
if (this.settings.core.expand_selected_onload) {
|
|
586
|
+
var a = [], n, c;
|
|
587
|
+
for (n = 0, c = this._data.core.selected.length; n < c; n++)
|
|
588
|
+
a = a.concat(this._model.data[this._data.core.selected[n]].parents);
|
|
589
|
+
for (a = l.vakata.array_unique(a), n = 0, c = a.length; n < c; n++)
|
|
590
|
+
this.open_node(a[n], !1, 0);
|
|
591
|
+
}
|
|
592
|
+
this.trigger("changed", { action: "ready", selected: this._data.core.selected });
|
|
593
|
+
}
|
|
594
|
+
this.trigger("ready");
|
|
595
|
+
}
|
|
596
|
+
}).bind(this), 0));
|
|
597
|
+
}).bind(this)).on("keypress.jstree", (function(i) {
|
|
598
|
+
if (i.target.tagName && i.target.tagName.toLowerCase() === "input")
|
|
599
|
+
return !0;
|
|
600
|
+
s && clearTimeout(s), s = setTimeout(function() {
|
|
601
|
+
e = "";
|
|
602
|
+
}, 500);
|
|
603
|
+
var r = String.fromCharCode(i.which).toLowerCase(), a = this.element.find(".jstree-anchor").filter(":visible"), n = a.index(T.activeElement) || 0, c = !1;
|
|
604
|
+
e += r, !(e.length > 1 && (a.slice(n).each((function(d, h) {
|
|
605
|
+
if (l(h).text().toLowerCase().indexOf(e) === 0)
|
|
606
|
+
return l(h).trigger("focus"), c = !0, !1;
|
|
607
|
+
}).bind(this)), c || (a.slice(0, n).each((function(d, h) {
|
|
608
|
+
if (l(h).text().toLowerCase().indexOf(e) === 0)
|
|
609
|
+
return l(h).trigger("focus"), c = !0, !1;
|
|
610
|
+
}).bind(this)), c))) && new RegExp("^" + r.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&") + "+$").test(e) && (a.slice(n + 1).each((function(d, h) {
|
|
611
|
+
if (l(h).text().toLowerCase().charAt(0) === r)
|
|
612
|
+
return l(h).trigger("focus"), c = !0, !1;
|
|
613
|
+
}).bind(this)), c || a.slice(0, n + 1).each((function(d, h) {
|
|
614
|
+
if (l(h).text().toLowerCase().charAt(0) === r)
|
|
615
|
+
return l(h).trigger("focus"), c = !0, !1;
|
|
616
|
+
}).bind(this)));
|
|
617
|
+
}).bind(this)).on("init.jstree", (function() {
|
|
618
|
+
var i = this.settings.core.themes;
|
|
619
|
+
this._data.core.themes.dots = i.dots, this._data.core.themes.stripes = i.stripes, this._data.core.themes.icons = i.icons, this._data.core.themes.ellipsis = i.ellipsis, this.set_theme(i.name || "default", i.url), this.set_theme_variant(i.variant);
|
|
620
|
+
}).bind(this)).on("loading.jstree", (function() {
|
|
621
|
+
this[this._data.core.themes.dots ? "show_dots" : "hide_dots"](), this[this._data.core.themes.icons ? "show_icons" : "hide_icons"](), this[this._data.core.themes.stripes ? "show_stripes" : "hide_stripes"](), this[this._data.core.themes.ellipsis ? "show_ellipsis" : "hide_ellipsis"]();
|
|
622
|
+
}).bind(this)).on("blur.jstree", ".jstree-anchor", (function(i) {
|
|
623
|
+
this._data.core.focused = null, l(i.currentTarget).filter(".jstree-hovered").trigger("mouseleave"), this.element.attr("tabindex", "0"), l(i.currentTarget).attr("tabindex", "-1");
|
|
624
|
+
}).bind(this)).on("focus.jstree", ".jstree-anchor", (function(i) {
|
|
625
|
+
var r = this.get_node(i.currentTarget);
|
|
626
|
+
r && (r.id || r.id === 0) && (this._data.core.focused = r.id), this.element.find(".jstree-hovered").not(i.currentTarget).trigger("mouseleave"), l(i.currentTarget).trigger("mouseenter"), this.element.attr("tabindex", "-1"), l(i.currentTarget).attr("tabindex", "0");
|
|
627
|
+
}).bind(this)).on("focus.jstree", (function() {
|
|
628
|
+
if (+/* @__PURE__ */ new Date() - t > 500 && !this._data.core.focused && this.settings.core.restore_focus) {
|
|
629
|
+
t = 0;
|
|
630
|
+
var i = this.get_node(this.element.attr("aria-activedescendant"), !0);
|
|
631
|
+
i && i.find("> .jstree-anchor").trigger("focus");
|
|
632
|
+
}
|
|
633
|
+
}).bind(this)).on("mouseenter.jstree", ".jstree-anchor", (function(i) {
|
|
634
|
+
this.hover_node(i.currentTarget);
|
|
635
|
+
}).bind(this)).on("mouseleave.jstree", ".jstree-anchor", (function(i) {
|
|
636
|
+
this.dehover_node(i.currentTarget);
|
|
637
|
+
}).bind(this));
|
|
638
|
+
},
|
|
639
|
+
/**
|
|
640
|
+
* part of the destroying of an instance. Used internally.
|
|
641
|
+
* @private
|
|
642
|
+
* @name unbind()
|
|
643
|
+
*/
|
|
644
|
+
unbind: function() {
|
|
645
|
+
this.element.off(".jstree"), l(T).off(".jstree-" + this._id);
|
|
646
|
+
},
|
|
647
|
+
/**
|
|
648
|
+
* trigger an event. Used internally.
|
|
649
|
+
* @private
|
|
650
|
+
* @name trigger(ev [, data])
|
|
651
|
+
* @param {String} ev the name of the event to trigger
|
|
652
|
+
* @param {Object} data additional data to pass with the event
|
|
653
|
+
*/
|
|
654
|
+
trigger: function(e, s) {
|
|
655
|
+
s || (s = {}), s.instance = this, this.element.triggerHandler(e.replace(".jstree", "") + ".jstree", s);
|
|
656
|
+
},
|
|
657
|
+
/**
|
|
658
|
+
* returns the jQuery extended instance container
|
|
659
|
+
* @name get_container()
|
|
660
|
+
* @return {jQuery}
|
|
661
|
+
*/
|
|
662
|
+
get_container: function() {
|
|
663
|
+
return this.element;
|
|
664
|
+
},
|
|
665
|
+
/**
|
|
666
|
+
* returns the jQuery extended main UL node inside the instance container. Used internally.
|
|
667
|
+
* @private
|
|
668
|
+
* @name get_container_ul()
|
|
669
|
+
* @return {jQuery}
|
|
670
|
+
*/
|
|
671
|
+
get_container_ul: function() {
|
|
672
|
+
return this.element.children(".jstree-children").first();
|
|
673
|
+
},
|
|
674
|
+
/**
|
|
675
|
+
* gets string replacements (localization). Used internally.
|
|
676
|
+
* @private
|
|
677
|
+
* @name get_string(key)
|
|
678
|
+
* @param {String} key
|
|
679
|
+
* @return {String}
|
|
680
|
+
*/
|
|
681
|
+
get_string: function(e) {
|
|
682
|
+
var s = this.settings.core.strings;
|
|
683
|
+
return l.vakata.is_function(s) ? s.call(this, e) : s && s[e] ? s[e] : e;
|
|
684
|
+
},
|
|
685
|
+
/**
|
|
686
|
+
* gets the first child of a DOM node. Used internally.
|
|
687
|
+
* @private
|
|
688
|
+
* @name _firstChild(dom)
|
|
689
|
+
* @param {DOMElement} dom
|
|
690
|
+
* @return {DOMElement}
|
|
691
|
+
*/
|
|
692
|
+
_firstChild: function(e) {
|
|
693
|
+
for (e = e ? e.firstChild : null; e !== null && e.nodeType !== 1; )
|
|
694
|
+
e = e.nextSibling;
|
|
695
|
+
return e;
|
|
696
|
+
},
|
|
697
|
+
/**
|
|
698
|
+
* gets the next sibling of a DOM node. Used internally.
|
|
699
|
+
* @private
|
|
700
|
+
* @name _nextSibling(dom)
|
|
701
|
+
* @param {DOMElement} dom
|
|
702
|
+
* @return {DOMElement}
|
|
703
|
+
*/
|
|
704
|
+
_nextSibling: function(e) {
|
|
705
|
+
for (e = e ? e.nextSibling : null; e !== null && e.nodeType !== 1; )
|
|
706
|
+
e = e.nextSibling;
|
|
707
|
+
return e;
|
|
708
|
+
},
|
|
709
|
+
/**
|
|
710
|
+
* gets the previous sibling of a DOM node. Used internally.
|
|
711
|
+
* @private
|
|
712
|
+
* @name _previousSibling(dom)
|
|
713
|
+
* @param {DOMElement} dom
|
|
714
|
+
* @return {DOMElement}
|
|
715
|
+
*/
|
|
716
|
+
_previousSibling: function(e) {
|
|
717
|
+
for (e = e ? e.previousSibling : null; e !== null && e.nodeType !== 1; )
|
|
718
|
+
e = e.previousSibling;
|
|
719
|
+
return e;
|
|
720
|
+
},
|
|
721
|
+
/**
|
|
722
|
+
* get the JSON representation of a node (or the actual jQuery extended DOM node) by using any input (child DOM element, ID string, selector, etc)
|
|
723
|
+
* @name get_node(obj [, as_dom])
|
|
724
|
+
* @param {mixed} obj
|
|
725
|
+
* @param {Boolean} as_dom
|
|
726
|
+
* @return {Object|jQuery}
|
|
727
|
+
*/
|
|
728
|
+
get_node: function(e, s) {
|
|
729
|
+
e && (e.id || e.id === 0) && (e = e.id), e instanceof l && e.length && e[0].id && (e = e[0].id);
|
|
730
|
+
var t;
|
|
731
|
+
try {
|
|
732
|
+
if (this._model.data[e])
|
|
733
|
+
e = this._model.data[e];
|
|
734
|
+
else if (typeof e == "string" && this._model.data[e.replace(/^#/, "")])
|
|
735
|
+
e = this._model.data[e.replace(/^#/, "")];
|
|
736
|
+
else if (typeof e == "string" && (t = l("#" + e.replace(l.jstree.idregex, "\\$&"), this.element)).length && this._model.data[t.closest(".jstree-node").attr("id")])
|
|
737
|
+
e = this._model.data[t.closest(".jstree-node").attr("id")];
|
|
738
|
+
else if ((t = this.element.find(e)).length && this._model.data[t.closest(".jstree-node").attr("id")])
|
|
739
|
+
e = this._model.data[t.closest(".jstree-node").attr("id")];
|
|
740
|
+
else if ((t = this.element.find(e)).length && t.hasClass("jstree"))
|
|
741
|
+
e = this._model.data[l.jstree.root];
|
|
742
|
+
else
|
|
743
|
+
return !1;
|
|
744
|
+
return s && (e = e.id === l.jstree.root ? this.element : l("#" + e.id.replace(l.jstree.idregex, "\\$&"), this.element)), e;
|
|
745
|
+
} catch {
|
|
746
|
+
return !1;
|
|
747
|
+
}
|
|
748
|
+
},
|
|
749
|
+
/**
|
|
750
|
+
* get the path to a node, either consisting of node texts, or of node IDs, optionally glued together (otherwise an array)
|
|
751
|
+
* @name get_path(obj [, glue, ids])
|
|
752
|
+
* @param {mixed} obj the node
|
|
753
|
+
* @param {String} glue if you want the path as a string - pass the glue here (for example '/'), if a falsy value is supplied here, an array is returned
|
|
754
|
+
* @param {Boolean} ids if set to true build the path using ID, otherwise node text is used
|
|
755
|
+
* @return {mixed}
|
|
756
|
+
*/
|
|
757
|
+
get_path: function(e, s, t) {
|
|
758
|
+
if (e = e.parents ? e : this.get_node(e), !e || e.id === l.jstree.root || !e.parents)
|
|
759
|
+
return !1;
|
|
760
|
+
var i, r, a = [];
|
|
761
|
+
for (a.push(t ? e.id : e.text), i = 0, r = e.parents.length; i < r; i++)
|
|
762
|
+
a.push(t ? e.parents[i] : this.get_text(e.parents[i]));
|
|
763
|
+
return a = a.reverse().slice(1), s ? a.join(s) : a;
|
|
764
|
+
},
|
|
765
|
+
/**
|
|
766
|
+
* get the next visible node that is below the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
|
|
767
|
+
* @name get_next_dom(obj [, strict])
|
|
768
|
+
* @param {mixed} obj
|
|
769
|
+
* @param {Boolean} strict
|
|
770
|
+
* @return {jQuery}
|
|
771
|
+
*/
|
|
772
|
+
get_next_dom: function(e, s) {
|
|
773
|
+
var t;
|
|
774
|
+
if (e = this.get_node(e, !0), e[0] === this.element[0]) {
|
|
775
|
+
for (t = this._firstChild(this.get_container_ul()[0]); t && t.offsetHeight === 0; )
|
|
776
|
+
t = this._nextSibling(t);
|
|
777
|
+
return t ? l(t) : !1;
|
|
778
|
+
}
|
|
779
|
+
if (!e || !e.length)
|
|
780
|
+
return !1;
|
|
781
|
+
if (s) {
|
|
782
|
+
t = e[0];
|
|
783
|
+
do
|
|
784
|
+
t = this._nextSibling(t);
|
|
785
|
+
while (t && t.offsetHeight === 0);
|
|
786
|
+
return t ? l(t) : !1;
|
|
787
|
+
}
|
|
788
|
+
if (e.hasClass("jstree-open")) {
|
|
789
|
+
for (t = this._firstChild(e.children(".jstree-children")[0]); t && t.offsetHeight === 0; )
|
|
790
|
+
t = this._nextSibling(t);
|
|
791
|
+
if (t !== null)
|
|
792
|
+
return l(t);
|
|
793
|
+
}
|
|
794
|
+
t = e[0];
|
|
795
|
+
do
|
|
796
|
+
t = this._nextSibling(t);
|
|
797
|
+
while (t && t.offsetHeight === 0);
|
|
798
|
+
return t !== null ? l(t) : e.parentsUntil(".jstree", ".jstree-node").nextAll(".jstree-node:visible").first();
|
|
799
|
+
},
|
|
800
|
+
/**
|
|
801
|
+
* get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
|
|
802
|
+
* @name get_prev_dom(obj [, strict])
|
|
803
|
+
* @param {mixed} obj
|
|
804
|
+
* @param {Boolean} strict
|
|
805
|
+
* @return {jQuery}
|
|
806
|
+
*/
|
|
807
|
+
get_prev_dom: function(e, s) {
|
|
808
|
+
var t;
|
|
809
|
+
if (e = this.get_node(e, !0), e[0] === this.element[0]) {
|
|
810
|
+
for (t = this.get_container_ul()[0].lastChild; t && t.offsetHeight === 0; )
|
|
811
|
+
t = this._previousSibling(t);
|
|
812
|
+
return t ? l(t) : !1;
|
|
813
|
+
}
|
|
814
|
+
if (!e || !e.length)
|
|
815
|
+
return !1;
|
|
816
|
+
if (s) {
|
|
817
|
+
t = e[0];
|
|
818
|
+
do
|
|
819
|
+
t = this._previousSibling(t);
|
|
820
|
+
while (t && t.offsetHeight === 0);
|
|
821
|
+
return t ? l(t) : !1;
|
|
822
|
+
}
|
|
823
|
+
t = e[0];
|
|
824
|
+
do
|
|
825
|
+
t = this._previousSibling(t);
|
|
826
|
+
while (t && t.offsetHeight === 0);
|
|
827
|
+
if (t !== null) {
|
|
828
|
+
for (e = l(t); e.hasClass("jstree-open"); )
|
|
829
|
+
e = e.children(".jstree-children").first().children(".jstree-node:visible:last");
|
|
830
|
+
return e;
|
|
831
|
+
}
|
|
832
|
+
return t = e[0].parentNode.parentNode, t && t.className && t.className.indexOf("jstree-node") !== -1 ? l(t) : !1;
|
|
833
|
+
},
|
|
834
|
+
/**
|
|
835
|
+
* get the parent ID of a node
|
|
836
|
+
* @name get_parent(obj)
|
|
837
|
+
* @param {mixed} obj
|
|
838
|
+
* @return {String}
|
|
839
|
+
*/
|
|
840
|
+
get_parent: function(e) {
|
|
841
|
+
return e = this.get_node(e), !e || e.id === l.jstree.root ? !1 : e.parent;
|
|
842
|
+
},
|
|
843
|
+
/**
|
|
844
|
+
* get a jQuery collection of all the children of a node (node must be rendered), returns false on error
|
|
845
|
+
* @name get_children_dom(obj)
|
|
846
|
+
* @param {mixed} obj
|
|
847
|
+
* @return {jQuery}
|
|
848
|
+
*/
|
|
849
|
+
get_children_dom: function(e) {
|
|
850
|
+
return e = this.get_node(e, !0), e[0] === this.element[0] ? this.get_container_ul().children(".jstree-node") : !e || !e.length ? !1 : e.children(".jstree-children").children(".jstree-node");
|
|
851
|
+
},
|
|
852
|
+
/**
|
|
853
|
+
* checks if a node has children
|
|
854
|
+
* @name is_parent(obj)
|
|
855
|
+
* @param {mixed} obj
|
|
856
|
+
* @return {Boolean}
|
|
857
|
+
*/
|
|
858
|
+
is_parent: function(e) {
|
|
859
|
+
return e = this.get_node(e), e && (e.state.loaded === !1 || e.children.length > 0);
|
|
860
|
+
},
|
|
861
|
+
/**
|
|
862
|
+
* checks if a node is loaded (its children are available)
|
|
863
|
+
* @name is_loaded(obj)
|
|
864
|
+
* @param {mixed} obj
|
|
865
|
+
* @return {Boolean}
|
|
866
|
+
*/
|
|
867
|
+
is_loaded: function(e) {
|
|
868
|
+
return e = this.get_node(e), e && e.state.loaded;
|
|
869
|
+
},
|
|
870
|
+
/**
|
|
871
|
+
* check if a node is currently loading (fetching children)
|
|
872
|
+
* @name is_loading(obj)
|
|
873
|
+
* @param {mixed} obj
|
|
874
|
+
* @return {Boolean}
|
|
875
|
+
*/
|
|
876
|
+
is_loading: function(e) {
|
|
877
|
+
return e = this.get_node(e), e && e.state && e.state.loading;
|
|
878
|
+
},
|
|
879
|
+
/**
|
|
880
|
+
* check if a node is opened
|
|
881
|
+
* @name is_open(obj)
|
|
882
|
+
* @param {mixed} obj
|
|
883
|
+
* @return {Boolean}
|
|
884
|
+
*/
|
|
885
|
+
is_open: function(e) {
|
|
886
|
+
return e = this.get_node(e), e && e.state.opened;
|
|
887
|
+
},
|
|
888
|
+
/**
|
|
889
|
+
* check if a node is in a closed state
|
|
890
|
+
* @name is_closed(obj)
|
|
891
|
+
* @param {mixed} obj
|
|
892
|
+
* @return {Boolean}
|
|
893
|
+
*/
|
|
894
|
+
is_closed: function(e) {
|
|
895
|
+
return e = this.get_node(e), e && this.is_parent(e) && !e.state.opened;
|
|
896
|
+
},
|
|
897
|
+
/**
|
|
898
|
+
* check if a node has no children
|
|
899
|
+
* @name is_leaf(obj)
|
|
900
|
+
* @param {mixed} obj
|
|
901
|
+
* @return {Boolean}
|
|
902
|
+
*/
|
|
903
|
+
is_leaf: function(e) {
|
|
904
|
+
return !this.is_parent(e);
|
|
905
|
+
},
|
|
906
|
+
/**
|
|
907
|
+
* loads a node (fetches its children using the `core.data` setting). Multiple nodes can be passed to by using an array.
|
|
908
|
+
* @name load_node(obj [, callback])
|
|
909
|
+
* @param {mixed} obj
|
|
910
|
+
* @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives two arguments - the node and a boolean status
|
|
911
|
+
* @return {Boolean}
|
|
912
|
+
* @trigger load_node.jstree
|
|
913
|
+
*/
|
|
914
|
+
load_node: function(e, s) {
|
|
915
|
+
var t = this.get_node(e, !0), i, r, a, n, c;
|
|
916
|
+
if (l.vakata.is_array(e))
|
|
917
|
+
return this._load_nodes(e.slice(), s), !0;
|
|
918
|
+
if (e = this.get_node(e), !e)
|
|
919
|
+
return s && s.call(this, e, !1), !1;
|
|
920
|
+
if (e.state.loaded) {
|
|
921
|
+
for (e.state.loaded = !1, a = 0, n = e.parents.length; a < n; a++)
|
|
922
|
+
this._model.data[e.parents[a]].children_d = l.vakata.array_filter(this._model.data[e.parents[a]].children_d, function(d) {
|
|
923
|
+
return l.inArray(d, e.children_d) === -1;
|
|
924
|
+
});
|
|
925
|
+
for (i = 0, r = e.children_d.length; i < r; i++)
|
|
926
|
+
this._model.data[e.children_d[i]].state.selected && (c = !0), delete this._model.data[e.children_d[i]];
|
|
927
|
+
c && (this._data.core.selected = l.vakata.array_filter(this._data.core.selected, function(d) {
|
|
928
|
+
return l.inArray(d, e.children_d) === -1;
|
|
929
|
+
})), e.children = [], e.children_d = [], c && this.trigger("changed", { action: "load_node", node: e, selected: this._data.core.selected });
|
|
930
|
+
}
|
|
931
|
+
return e.state.failed = !1, e.state.loading = !0, e.id !== l.jstree.root ? t.children(".jstree-anchor").attr("aria-busy", !0) : t.attr("aria-busy", !0), t.addClass("jstree-loading"), this._load_node(e, (function(d) {
|
|
932
|
+
e = this._model.data[e.id], e.state.loading = !1, e.state.loaded = d, e.state.failed = !e.state.loaded;
|
|
933
|
+
var h = this.get_node(e, !0), o = 0, f = 0, _ = this._model.data, u = !1;
|
|
934
|
+
for (o = 0, f = e.children.length; o < f; o++)
|
|
935
|
+
if (_[e.children[o]] && !_[e.children[o]].state.hidden) {
|
|
936
|
+
u = !0;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
e.state.loaded && h && h.length && (h.removeClass("jstree-closed jstree-open jstree-leaf"), u ? e.id !== "#" && h.addClass(e.state.opened ? "jstree-open" : "jstree-closed") : h.addClass("jstree-leaf")), e.id !== l.jstree.root ? h.children(".jstree-anchor").attr("aria-busy", !1) : h.attr("aria-busy", !1), h.removeClass("jstree-loading"), this.trigger("load_node", { node: e, status: d }), s && s.call(this, e, d);
|
|
940
|
+
}).bind(this)), !0;
|
|
941
|
+
},
|
|
942
|
+
/**
|
|
943
|
+
* load an array of nodes (will also load unavailable nodes as soon as they appear in the structure). Used internally.
|
|
944
|
+
* @private
|
|
945
|
+
* @name _load_nodes(nodes [, callback])
|
|
946
|
+
* @param {array} nodes
|
|
947
|
+
* @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - the array passed to _load_nodes
|
|
948
|
+
*/
|
|
949
|
+
_load_nodes: function(e, s, t, i) {
|
|
950
|
+
var r = !0, a = function() {
|
|
951
|
+
this._load_nodes(e, s, !0);
|
|
952
|
+
}, n = this._model.data, c, d, h = [];
|
|
953
|
+
for (c = 0, d = e.length; c < d; c++)
|
|
954
|
+
n[e[c]] && (!n[e[c]].state.loaded && !n[e[c]].state.failed || !t && i) && (this.is_loading(e[c]) || this.load_node(e[c], a), r = !1);
|
|
955
|
+
if (r) {
|
|
956
|
+
for (c = 0, d = e.length; c < d; c++)
|
|
957
|
+
n[e[c]] && n[e[c]].state.loaded && h.push(e[c]);
|
|
958
|
+
s && !s.done && (s.call(this, h), s.done = !0);
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
/**
|
|
962
|
+
* loads all unloaded nodes
|
|
963
|
+
* @name load_all([obj, callback])
|
|
964
|
+
* @param {mixed} obj the node to load recursively, omit to load all nodes in the tree
|
|
965
|
+
* @param {function} callback a function to be executed once loading all the nodes is complete,
|
|
966
|
+
* @trigger load_all.jstree
|
|
967
|
+
*/
|
|
968
|
+
load_all: function(e, s) {
|
|
969
|
+
if (e || (e = l.jstree.root), e = this.get_node(e), !e)
|
|
970
|
+
return !1;
|
|
971
|
+
var t = [], i = this._model.data, r = i[e.id].children_d, a, n;
|
|
972
|
+
for (e.state && !e.state.loaded && t.push(e.id), a = 0, n = r.length; a < n; a++)
|
|
973
|
+
i[r[a]] && i[r[a]].state && !i[r[a]].state.loaded && t.push(r[a]);
|
|
974
|
+
t.length ? this._load_nodes(t, function() {
|
|
975
|
+
this.load_all(e, s);
|
|
976
|
+
}) : (s && s.call(this, e), this.trigger("load_all", { node: e }));
|
|
977
|
+
},
|
|
978
|
+
/**
|
|
979
|
+
* handles the actual loading of a node. Used only internally.
|
|
980
|
+
* @private
|
|
981
|
+
* @name _load_node(obj [, callback])
|
|
982
|
+
* @param {mixed} obj
|
|
983
|
+
* @param {function} callback a function to be executed once loading is complete, the function is executed in the instance's scope and receives one argument - a boolean status
|
|
984
|
+
* @return {Boolean}
|
|
985
|
+
*/
|
|
986
|
+
_load_node: function(e, s) {
|
|
987
|
+
var t = this.settings.core.data, i, r = function() {
|
|
988
|
+
return this.nodeType !== 3 && this.nodeType !== 8;
|
|
989
|
+
};
|
|
990
|
+
return t ? l.vakata.is_function(t) ? t.call(this, e, (function(a) {
|
|
991
|
+
a === !1 ? s.call(this, !1) : this[typeof a == "string" ? "_append_html_data" : "_append_json_data"](e, typeof a == "string" ? l(l.parseHTML(a)).filter(r) : a, function(n) {
|
|
992
|
+
s.call(this, n);
|
|
993
|
+
});
|
|
994
|
+
}).bind(this)) : typeof t == "object" ? t.url ? (t = l.extend(!0, {}, t), l.vakata.is_function(t.url) && (t.url = t.url.call(this, e)), l.vakata.is_function(t.data) && (t.data = t.data.call(this, e)), l.ajax(t).done((function(a, n, c) {
|
|
995
|
+
var d = c.getResponseHeader("Content-Type");
|
|
996
|
+
return d && d.indexOf("json") !== -1 || typeof a == "object" ? this._append_json_data(e, a, function(h) {
|
|
997
|
+
s.call(this, h);
|
|
998
|
+
}) : d && d.indexOf("html") !== -1 || typeof a == "string" ? this._append_html_data(e, l(l.parseHTML(a)).filter(r), function(h) {
|
|
999
|
+
s.call(this, h);
|
|
1000
|
+
}) : (this._data.core.last_error = { error: "ajax", plugin: "core", id: "core_04", reason: "Could not load node", data: JSON.stringify({ id: e.id, xhr: c }) }, this.settings.core.error.call(this, this._data.core.last_error), s.call(this, !1));
|
|
1001
|
+
}).bind(this)).fail((function(a) {
|
|
1002
|
+
this._data.core.last_error = { error: "ajax", plugin: "core", id: "core_04", reason: "Could not load node", data: JSON.stringify({ id: e.id, xhr: a }) }, s.call(this, !1), this.settings.core.error.call(this, this._data.core.last_error);
|
|
1003
|
+
}).bind(this))) : (l.vakata.is_array(t) ? i = l.extend(!0, [], t) : l.isPlainObject(t) ? i = l.extend(!0, {}, t) : i = t, e.id === l.jstree.root ? this._append_json_data(e, i, function(a) {
|
|
1004
|
+
s.call(this, a);
|
|
1005
|
+
}) : (this._data.core.last_error = { error: "nodata", plugin: "core", id: "core_05", reason: "Could not load node", data: JSON.stringify({ id: e.id }) }, this.settings.core.error.call(this, this._data.core.last_error), s.call(this, !1))) : typeof t == "string" ? e.id === l.jstree.root ? this._append_html_data(e, l(l.parseHTML(t)).filter(r), function(a) {
|
|
1006
|
+
s.call(this, a);
|
|
1007
|
+
}) : (this._data.core.last_error = { error: "nodata", plugin: "core", id: "core_06", reason: "Could not load node", data: JSON.stringify({ id: e.id }) }, this.settings.core.error.call(this, this._data.core.last_error), s.call(this, !1)) : s.call(this, !1) : e.id === l.jstree.root ? this._append_html_data(e, this._data.core.original_container_html.clone(!0), function(a) {
|
|
1008
|
+
s.call(this, a);
|
|
1009
|
+
}) : s.call(this, !1);
|
|
1010
|
+
},
|
|
1011
|
+
/**
|
|
1012
|
+
* adds a node to the list of nodes to redraw. Used only internally.
|
|
1013
|
+
* @private
|
|
1014
|
+
* @name _node_changed(obj [, callback])
|
|
1015
|
+
* @param {mixed} obj
|
|
1016
|
+
*/
|
|
1017
|
+
_node_changed: function(e) {
|
|
1018
|
+
e = this.get_node(e), e && l.inArray(e.id, this._model.changed) === -1 && this._model.changed.push(e.id);
|
|
1019
|
+
},
|
|
1020
|
+
/**
|
|
1021
|
+
* appends HTML content to the tree. Used internally.
|
|
1022
|
+
* @private
|
|
1023
|
+
* @name _append_html_data(obj, data)
|
|
1024
|
+
* @param {mixed} obj the node to append to
|
|
1025
|
+
* @param {String} data the HTML string to parse and append
|
|
1026
|
+
* @trigger model.jstree, changed.jstree
|
|
1027
|
+
*/
|
|
1028
|
+
_append_html_data: function(e, s, t) {
|
|
1029
|
+
e = this.get_node(e), e.children = [], e.children_d = [];
|
|
1030
|
+
var i = s.is("ul") ? s.children() : s, r = e.id, a = [], n = [], c = this._model.data, d = c[r], h = this._data.core.selected.length, o, f, _;
|
|
1031
|
+
for (i.each((function(u, g) {
|
|
1032
|
+
o = this._parse_model_from_html(l(g), r, d.parents.concat()), o && (a.push(o), n.push(o), c[o].children_d.length && (n = n.concat(c[o].children_d)));
|
|
1033
|
+
}).bind(this)), d.children = a, d.children_d = n, f = 0, _ = d.parents.length; f < _; f++)
|
|
1034
|
+
c[d.parents[f]].children_d = c[d.parents[f]].children_d.concat(n);
|
|
1035
|
+
this.trigger("model", { nodes: n, parent: r }), r !== l.jstree.root ? (this._node_changed(r), this.redraw()) : (this.get_container_ul().children(".jstree-initial-node").remove(), this.redraw(!0)), this._data.core.selected.length !== h && this.trigger("changed", { action: "model", selected: this._data.core.selected }), t.call(this, !0);
|
|
1036
|
+
},
|
|
1037
|
+
/**
|
|
1038
|
+
* appends JSON content to the tree. Used internally.
|
|
1039
|
+
* @private
|
|
1040
|
+
* @name _append_json_data(obj, data)
|
|
1041
|
+
* @param {mixed} obj the node to append to
|
|
1042
|
+
* @param {String} data the JSON object to parse and append
|
|
1043
|
+
* @param {Boolean} force_processing internal param - do not set
|
|
1044
|
+
* @trigger model.jstree, changed.jstree
|
|
1045
|
+
*/
|
|
1046
|
+
_append_json_data: function(e, s, t, i) {
|
|
1047
|
+
if (this.element !== null) {
|
|
1048
|
+
e = this.get_node(e), e.children = [], e.children_d = [], s.d && (s = s.d, typeof s == "string" && (s = JSON.parse(s))), l.vakata.is_array(s) || (s = [s]);
|
|
1049
|
+
var r = null, a = {
|
|
1050
|
+
df: this._model.default_state,
|
|
1051
|
+
dat: s,
|
|
1052
|
+
par: e.id,
|
|
1053
|
+
m: this._model.data,
|
|
1054
|
+
t_id: this._id,
|
|
1055
|
+
t_cnt: this._cnt,
|
|
1056
|
+
sel: this._data.core.selected
|
|
1057
|
+
}, n = this, c = function(h, o) {
|
|
1058
|
+
h.data && (h = h.data);
|
|
1059
|
+
var f = h.dat, _ = h.par, u = [], g = [], p = [], m = h.df, N = h.t_id, O = h.t_cnt, x = h.m, A = x[_], K = h.sel, P, C, S, L, F = function(v, j, E) {
|
|
1060
|
+
E ? E = E.concat() : E = [], j && E.unshift(j);
|
|
1061
|
+
var H = v.id.toString(), w, B, z, Y, k = {
|
|
1062
|
+
id: H,
|
|
1063
|
+
text: v.text || "",
|
|
1064
|
+
icon: v.icon !== o ? v.icon : !0,
|
|
1065
|
+
parent: j,
|
|
1066
|
+
parents: E,
|
|
1067
|
+
children: v.children || [],
|
|
1068
|
+
children_d: v.children_d || [],
|
|
1069
|
+
data: v.data,
|
|
1070
|
+
state: {},
|
|
1071
|
+
li_attr: { id: !1 },
|
|
1072
|
+
a_attr: { href: "#" },
|
|
1073
|
+
original: !1
|
|
1074
|
+
};
|
|
1075
|
+
for (w in m)
|
|
1076
|
+
m.hasOwnProperty(w) && (k.state[w] = m[w]);
|
|
1077
|
+
if (v && v.data && v.data.jstree && v.data.jstree.icon && (k.icon = v.data.jstree.icon), (k.icon === o || k.icon === null || k.icon === "") && (k.icon = !0), v && v.data && (k.data = v.data, v.data.jstree))
|
|
1078
|
+
for (w in v.data.jstree)
|
|
1079
|
+
v.data.jstree.hasOwnProperty(w) && (k.state[w] = v.data.jstree[w]);
|
|
1080
|
+
if (v && typeof v.state == "object")
|
|
1081
|
+
for (w in v.state)
|
|
1082
|
+
v.state.hasOwnProperty(w) && (k.state[w] = v.state[w]);
|
|
1083
|
+
if (v && typeof v.li_attr == "object")
|
|
1084
|
+
for (w in v.li_attr)
|
|
1085
|
+
v.li_attr.hasOwnProperty(w) && (k.li_attr[w] = v.li_attr[w]);
|
|
1086
|
+
if (k.li_attr.id || (k.li_attr.id = H), v && typeof v.a_attr == "object")
|
|
1087
|
+
for (w in v.a_attr)
|
|
1088
|
+
v.a_attr.hasOwnProperty(w) && (k.a_attr[w] = v.a_attr[w]);
|
|
1089
|
+
for (v && v.children && v.children === !0 && (k.state.loaded = !1, k.children = [], k.children_d = []), x[k.id] = k, w = 0, B = k.children.length; w < B; w++)
|
|
1090
|
+
z = F(x[k.children[w]], k.id, E), Y = x[z], k.children_d.push(z), Y.children_d.length && (k.children_d = k.children_d.concat(Y.children_d));
|
|
1091
|
+
return delete v.data, delete v.children, x[k.id].original = v, k.state.selected && p.push(k.id), k.id;
|
|
1092
|
+
}, J = function(v, j, E) {
|
|
1093
|
+
E ? E = E.concat() : E = [], j && E.unshift(j);
|
|
1094
|
+
var H = !1, w, B, z, Y, k;
|
|
1095
|
+
do
|
|
1096
|
+
H = "j" + N + "_" + ++O;
|
|
1097
|
+
while (x[H]);
|
|
1098
|
+
k = {
|
|
1099
|
+
id: !1,
|
|
1100
|
+
text: typeof v == "string" ? v : "",
|
|
1101
|
+
icon: typeof v == "object" && v.icon !== o ? v.icon : !0,
|
|
1102
|
+
parent: j,
|
|
1103
|
+
parents: E,
|
|
1104
|
+
children: [],
|
|
1105
|
+
children_d: [],
|
|
1106
|
+
data: null,
|
|
1107
|
+
state: {},
|
|
1108
|
+
li_attr: { id: !1 },
|
|
1109
|
+
a_attr: { href: "#" },
|
|
1110
|
+
original: !1
|
|
1111
|
+
};
|
|
1112
|
+
for (w in m)
|
|
1113
|
+
m.hasOwnProperty(w) && (k.state[w] = m[w]);
|
|
1114
|
+
if (v && (v.id || v.id === 0) && (k.id = v.id.toString()), v && v.text && (k.text = v.text), v && v.data && v.data.jstree && v.data.jstree.icon && (k.icon = v.data.jstree.icon), (k.icon === o || k.icon === null || k.icon === "") && (k.icon = !0), v && v.data && (k.data = v.data, v.data.jstree))
|
|
1115
|
+
for (w in v.data.jstree)
|
|
1116
|
+
v.data.jstree.hasOwnProperty(w) && (k.state[w] = v.data.jstree[w]);
|
|
1117
|
+
if (v && typeof v.state == "object")
|
|
1118
|
+
for (w in v.state)
|
|
1119
|
+
v.state.hasOwnProperty(w) && (k.state[w] = v.state[w]);
|
|
1120
|
+
if (v && typeof v.li_attr == "object")
|
|
1121
|
+
for (w in v.li_attr)
|
|
1122
|
+
v.li_attr.hasOwnProperty(w) && (k.li_attr[w] = v.li_attr[w]);
|
|
1123
|
+
if (k.li_attr.id && !(k.id || k.id === 0) && (k.id = k.li_attr.id.toString()), k.id || k.id === 0 || (k.id = H), k.li_attr.id || (k.li_attr.id = k.id), v && typeof v.a_attr == "object")
|
|
1124
|
+
for (w in v.a_attr)
|
|
1125
|
+
v.a_attr.hasOwnProperty(w) && (k.a_attr[w] = v.a_attr[w]);
|
|
1126
|
+
if (v && v.children && v.children.length) {
|
|
1127
|
+
for (w = 0, B = v.children.length; w < B; w++)
|
|
1128
|
+
z = J(v.children[w], k.id, E), Y = x[z], k.children.push(z), Y.children_d.length && (k.children_d = k.children_d.concat(Y.children_d));
|
|
1129
|
+
k.children_d = k.children_d.concat(k.children);
|
|
1130
|
+
}
|
|
1131
|
+
return v && v.children && v.children === !0 && (k.state.loaded = !1, k.children = [], k.children_d = []), delete v.data, delete v.children, k.original = v, x[k.id] = k, k.state.selected && p.push(k.id), k.id;
|
|
1132
|
+
};
|
|
1133
|
+
if (f.length && f[0].id !== o && f[0].parent !== o) {
|
|
1134
|
+
for (C = 0, S = f.length; C < S; C++)
|
|
1135
|
+
f[C].children || (f[C].children = []), f[C].state || (f[C].state = {}), x[f[C].id.toString()] = f[C];
|
|
1136
|
+
for (C = 0, S = f.length; C < S; C++) {
|
|
1137
|
+
if (!x[f[C].parent.toString()]) {
|
|
1138
|
+
typeof n < "u" && (n._data.core.last_error = { error: "parse", plugin: "core", id: "core_07", reason: "Node with invalid parent", data: JSON.stringify({ id: f[C].id.toString(), parent: f[C].parent.toString() }) }, n.settings.core.error.call(n, n._data.core.last_error));
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
x[f[C].parent.toString()].children.push(f[C].id.toString()), A.children_d.push(f[C].id.toString());
|
|
1142
|
+
}
|
|
1143
|
+
for (C = 0, S = A.children.length; C < S; C++)
|
|
1144
|
+
P = F(x[A.children[C]], _, A.parents.concat()), g.push(P), x[P].children_d.length && (g = g.concat(x[P].children_d));
|
|
1145
|
+
for (C = 0, S = A.parents.length; C < S; C++)
|
|
1146
|
+
x[A.parents[C]].children_d = x[A.parents[C]].children_d.concat(g);
|
|
1147
|
+
L = {
|
|
1148
|
+
cnt: O,
|
|
1149
|
+
mod: x,
|
|
1150
|
+
sel: K,
|
|
1151
|
+
par: _,
|
|
1152
|
+
dpc: g,
|
|
1153
|
+
add: p
|
|
1154
|
+
};
|
|
1155
|
+
} else {
|
|
1156
|
+
for (C = 0, S = f.length; C < S; C++)
|
|
1157
|
+
P = J(f[C], _, A.parents.concat()), P && (u.push(P), g.push(P), x[P].children_d.length && (g = g.concat(x[P].children_d)));
|
|
1158
|
+
for (A.children = u, A.children_d = g, C = 0, S = A.parents.length; C < S; C++)
|
|
1159
|
+
x[A.parents[C]].children_d = x[A.parents[C]].children_d.concat(g);
|
|
1160
|
+
L = {
|
|
1161
|
+
cnt: O,
|
|
1162
|
+
mod: x,
|
|
1163
|
+
sel: K,
|
|
1164
|
+
par: _,
|
|
1165
|
+
dpc: g,
|
|
1166
|
+
add: p
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
if (typeof window > "u" || typeof window.document > "u")
|
|
1170
|
+
postMessage(L);
|
|
1171
|
+
else
|
|
1172
|
+
return L;
|
|
1173
|
+
}, d = function(h, o) {
|
|
1174
|
+
if (this.element !== null) {
|
|
1175
|
+
this._cnt = h.cnt;
|
|
1176
|
+
var f, _ = this._model.data;
|
|
1177
|
+
for (f in _)
|
|
1178
|
+
_.hasOwnProperty(f) && _[f].state && _[f].state.loading && h.mod[f] && (h.mod[f].state.loading = !0);
|
|
1179
|
+
if (this._model.data = h.mod, o) {
|
|
1180
|
+
var u, g = h.add, p = h.sel, m = this._data.core.selected.slice();
|
|
1181
|
+
if (_ = this._model.data, p.length !== m.length || l.vakata.array_unique(p.concat(m)).length !== p.length) {
|
|
1182
|
+
for (f = 0, u = p.length; f < u; f++)
|
|
1183
|
+
l.inArray(p[f], g) === -1 && l.inArray(p[f], m) === -1 && (_[p[f]].state.selected = !1);
|
|
1184
|
+
for (f = 0, u = m.length; f < u; f++)
|
|
1185
|
+
l.inArray(m[f], p) === -1 && (_[m[f]].state.selected = !0);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
h.add.length && (this._data.core.selected = this._data.core.selected.concat(h.add)), this.trigger("model", { nodes: h.dpc, parent: h.par }), h.par !== l.jstree.root ? (this._node_changed(h.par), this.redraw()) : this.redraw(!0), h.add.length && this.trigger("changed", { action: "model", selected: this._data.core.selected }), !o && W ? W(function() {
|
|
1189
|
+
t.call(n, !0);
|
|
1190
|
+
}) : t.call(n, !0);
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
if (this.settings.core.worker && window.Blob && window.URL && window.Worker)
|
|
1194
|
+
try {
|
|
1195
|
+
this._wrk === null && (this._wrk = window.URL.createObjectURL(
|
|
1196
|
+
new window.Blob(
|
|
1197
|
+
["self.onmessage = " + c.toString()],
|
|
1198
|
+
{ type: "text/javascript" }
|
|
1199
|
+
)
|
|
1200
|
+
)), !this._data.core.working || i ? (this._data.core.working = !0, r = new window.Worker(this._wrk), r.onmessage = (function(h) {
|
|
1201
|
+
d.call(this, h.data, !0);
|
|
1202
|
+
try {
|
|
1203
|
+
r.terminate(), r = null;
|
|
1204
|
+
} catch {
|
|
1205
|
+
}
|
|
1206
|
+
this._data.core.worker_queue.length ? this._append_json_data.apply(this, this._data.core.worker_queue.shift()) : this._data.core.working = !1;
|
|
1207
|
+
}).bind(this), r.onerror = (function(h) {
|
|
1208
|
+
d.call(this, c(a), !1), this._data.core.worker_queue.length ? this._append_json_data.apply(this, this._data.core.worker_queue.shift()) : this._data.core.working = !1;
|
|
1209
|
+
}).bind(this), a.par ? r.postMessage(a) : this._data.core.worker_queue.length ? this._append_json_data.apply(this, this._data.core.worker_queue.shift()) : this._data.core.working = !1) : this._data.core.worker_queue.push([e, s, t, !0]);
|
|
1210
|
+
} catch {
|
|
1211
|
+
d.call(this, c(a), !1), this._data.core.worker_queue.length ? this._append_json_data.apply(this, this._data.core.worker_queue.shift()) : this._data.core.working = !1;
|
|
1212
|
+
}
|
|
1213
|
+
else
|
|
1214
|
+
d.call(this, c(a), !1);
|
|
1215
|
+
}
|
|
1216
|
+
},
|
|
1217
|
+
/**
|
|
1218
|
+
* parses a node from a jQuery object and appends them to the in memory tree model. Used internally.
|
|
1219
|
+
* @private
|
|
1220
|
+
* @name _parse_model_from_html(d [, p, ps])
|
|
1221
|
+
* @param {jQuery} d the jQuery object to parse
|
|
1222
|
+
* @param {String} p the parent ID
|
|
1223
|
+
* @param {Array} ps list of all parents
|
|
1224
|
+
* @return {String} the ID of the object added to the model
|
|
1225
|
+
*/
|
|
1226
|
+
_parse_model_from_html: function(e, s, t) {
|
|
1227
|
+
t ? t = [].concat(t) : t = [], s && t.unshift(s);
|
|
1228
|
+
var i, r, a = this._model.data, n = {
|
|
1229
|
+
id: !1,
|
|
1230
|
+
text: !1,
|
|
1231
|
+
icon: !0,
|
|
1232
|
+
parent: s,
|
|
1233
|
+
parents: t,
|
|
1234
|
+
children: [],
|
|
1235
|
+
children_d: [],
|
|
1236
|
+
data: null,
|
|
1237
|
+
state: {},
|
|
1238
|
+
li_attr: { id: !1 },
|
|
1239
|
+
a_attr: { href: "#" },
|
|
1240
|
+
original: !1
|
|
1241
|
+
}, c, d, h;
|
|
1242
|
+
for (c in this._model.default_state)
|
|
1243
|
+
this._model.default_state.hasOwnProperty(c) && (n.state[c] = this._model.default_state[c]);
|
|
1244
|
+
if (d = l.vakata.attributes(e, !0), l.each(d, function(o, f) {
|
|
1245
|
+
if (f = l.vakata.trim(f), !f.length)
|
|
1246
|
+
return !0;
|
|
1247
|
+
n.li_attr[o] = f, o === "id" && (n.id = f.toString());
|
|
1248
|
+
}), d = e.children("a").first(), d.length && (d = l.vakata.attributes(d, !0), l.each(d, function(o, f) {
|
|
1249
|
+
f = l.vakata.trim(f), f.length && (n.a_attr[o] = f);
|
|
1250
|
+
})), d = e.children("a").first().length ? e.children("a").first().clone() : e.clone(), d.children("ins, i, ul").remove(), d = d.html(), d = l("<div></div>").html(d), n.text = this.settings.core.force_text ? d.text() : d.html(), d = e.data(), n.data = d ? l.extend(!0, {}, d) : null, n.state.opened = e.hasClass("jstree-open"), n.state.selected = e.children("a").hasClass("jstree-clicked"), n.state.disabled = e.children("a").hasClass("jstree-disabled"), n.data && n.data.jstree)
|
|
1251
|
+
for (c in n.data.jstree)
|
|
1252
|
+
n.data.jstree.hasOwnProperty(c) && (n.state[c] = n.data.jstree[c]);
|
|
1253
|
+
d = e.children("a").children(".jstree-themeicon"), d.length && (n.icon = d.hasClass("jstree-themeicon-hidden") ? !1 : d.attr("rel")), n.state.icon !== y && (n.icon = n.state.icon), (n.icon === y || n.icon === null || n.icon === "") && (n.icon = !0), d = e.children("ul").children("li");
|
|
1254
|
+
do
|
|
1255
|
+
h = "j" + this._id + "_" + ++this._cnt;
|
|
1256
|
+
while (a[h]);
|
|
1257
|
+
return n.id = n.li_attr.id ? n.li_attr.id.toString() : h, d.length ? (d.each((function(o, f) {
|
|
1258
|
+
i = this._parse_model_from_html(l(f), n.id, t), r = this._model.data[i], n.children.push(i), r.children_d.length && (n.children_d = n.children_d.concat(r.children_d));
|
|
1259
|
+
}).bind(this)), n.children_d = n.children_d.concat(n.children)) : e.hasClass("jstree-closed") && (n.state.loaded = !1), n.li_attr.class && (n.li_attr.class = n.li_attr.class.replace("jstree-closed", "").replace("jstree-open", "")), n.a_attr.class && (n.a_attr.class = n.a_attr.class.replace("jstree-clicked", "").replace("jstree-disabled", "")), a[n.id] = n, n.state.selected && this._data.core.selected.push(n.id), n.id;
|
|
1260
|
+
},
|
|
1261
|
+
/**
|
|
1262
|
+
* parses a node from a JSON object (used when dealing with flat data, which has no nesting of children, but has id and parent properties) and appends it to the in memory tree model. Used internally.
|
|
1263
|
+
* @private
|
|
1264
|
+
* @name _parse_model_from_flat_json(d [, p, ps])
|
|
1265
|
+
* @param {Object} d the JSON object to parse
|
|
1266
|
+
* @param {String} p the parent ID
|
|
1267
|
+
* @param {Array} ps list of all parents
|
|
1268
|
+
* @return {String} the ID of the object added to the model
|
|
1269
|
+
*/
|
|
1270
|
+
_parse_model_from_flat_json: function(e, s, t) {
|
|
1271
|
+
t ? t = t.concat() : t = [], s && t.unshift(s);
|
|
1272
|
+
var i = e.id.toString(), r = this._model.data, a = this._model.default_state, n, c, d, h, o = {
|
|
1273
|
+
id: i,
|
|
1274
|
+
text: e.text || "",
|
|
1275
|
+
icon: e.icon !== y ? e.icon : !0,
|
|
1276
|
+
parent: s,
|
|
1277
|
+
parents: t,
|
|
1278
|
+
children: e.children || [],
|
|
1279
|
+
children_d: e.children_d || [],
|
|
1280
|
+
data: e.data,
|
|
1281
|
+
state: {},
|
|
1282
|
+
li_attr: { id: !1 },
|
|
1283
|
+
a_attr: { href: "#" },
|
|
1284
|
+
original: !1
|
|
1285
|
+
};
|
|
1286
|
+
for (n in a)
|
|
1287
|
+
a.hasOwnProperty(n) && (o.state[n] = a[n]);
|
|
1288
|
+
if (e && e.data && e.data.jstree && e.data.jstree.icon && (o.icon = e.data.jstree.icon), (o.icon === y || o.icon === null || o.icon === "") && (o.icon = !0), e && e.data && (o.data = e.data, e.data.jstree))
|
|
1289
|
+
for (n in e.data.jstree)
|
|
1290
|
+
e.data.jstree.hasOwnProperty(n) && (o.state[n] = e.data.jstree[n]);
|
|
1291
|
+
if (e && typeof e.state == "object")
|
|
1292
|
+
for (n in e.state)
|
|
1293
|
+
e.state.hasOwnProperty(n) && (o.state[n] = e.state[n]);
|
|
1294
|
+
if (e && typeof e.li_attr == "object")
|
|
1295
|
+
for (n in e.li_attr)
|
|
1296
|
+
e.li_attr.hasOwnProperty(n) && (o.li_attr[n] = e.li_attr[n]);
|
|
1297
|
+
if (o.li_attr.id || (o.li_attr.id = i), e && typeof e.a_attr == "object")
|
|
1298
|
+
for (n in e.a_attr)
|
|
1299
|
+
e.a_attr.hasOwnProperty(n) && (o.a_attr[n] = e.a_attr[n]);
|
|
1300
|
+
for (e && e.children && e.children === !0 && (o.state.loaded = !1, o.children = [], o.children_d = []), r[o.id] = o, n = 0, c = o.children.length; n < c; n++)
|
|
1301
|
+
d = this._parse_model_from_flat_json(r[o.children[n]], o.id, t), h = r[d], o.children_d.push(d), h.children_d.length && (o.children_d = o.children_d.concat(h.children_d));
|
|
1302
|
+
return delete e.data, delete e.children, r[o.id].original = e, o.state.selected && this._data.core.selected.push(o.id), o.id;
|
|
1303
|
+
},
|
|
1304
|
+
/**
|
|
1305
|
+
* parses a node from a JSON object and appends it to the in memory tree model. Used internally.
|
|
1306
|
+
* @private
|
|
1307
|
+
* @name _parse_model_from_json(d [, p, ps])
|
|
1308
|
+
* @param {Object} d the JSON object to parse
|
|
1309
|
+
* @param {String} p the parent ID
|
|
1310
|
+
* @param {Array} ps list of all parents
|
|
1311
|
+
* @return {String} the ID of the object added to the model
|
|
1312
|
+
*/
|
|
1313
|
+
_parse_model_from_json: function(e, s, t) {
|
|
1314
|
+
t ? t = t.concat() : t = [], s && t.unshift(s);
|
|
1315
|
+
var i = !1, r, a, n, c, d = this._model.data, h = this._model.default_state, o;
|
|
1316
|
+
do
|
|
1317
|
+
i = "j" + this._id + "_" + ++this._cnt;
|
|
1318
|
+
while (d[i]);
|
|
1319
|
+
o = {
|
|
1320
|
+
id: !1,
|
|
1321
|
+
text: typeof e == "string" ? e : "",
|
|
1322
|
+
icon: typeof e == "object" && e.icon !== y ? e.icon : !0,
|
|
1323
|
+
parent: s,
|
|
1324
|
+
parents: t,
|
|
1325
|
+
children: [],
|
|
1326
|
+
children_d: [],
|
|
1327
|
+
data: null,
|
|
1328
|
+
state: {},
|
|
1329
|
+
li_attr: { id: !1 },
|
|
1330
|
+
a_attr: { href: "#" },
|
|
1331
|
+
original: !1
|
|
1332
|
+
};
|
|
1333
|
+
for (r in h)
|
|
1334
|
+
h.hasOwnProperty(r) && (o.state[r] = h[r]);
|
|
1335
|
+
if (e && (e.id || e.id === 0) && (o.id = e.id.toString()), e && e.text && (o.text = e.text), e && e.data && e.data.jstree && e.data.jstree.icon && (o.icon = e.data.jstree.icon), (o.icon === y || o.icon === null || o.icon === "") && (o.icon = !0), e && e.data && (o.data = e.data, e.data.jstree))
|
|
1336
|
+
for (r in e.data.jstree)
|
|
1337
|
+
e.data.jstree.hasOwnProperty(r) && (o.state[r] = e.data.jstree[r]);
|
|
1338
|
+
if (e && typeof e.state == "object")
|
|
1339
|
+
for (r in e.state)
|
|
1340
|
+
e.state.hasOwnProperty(r) && (o.state[r] = e.state[r]);
|
|
1341
|
+
if (e && typeof e.li_attr == "object")
|
|
1342
|
+
for (r in e.li_attr)
|
|
1343
|
+
e.li_attr.hasOwnProperty(r) && (o.li_attr[r] = e.li_attr[r]);
|
|
1344
|
+
if (o.li_attr.id && !(o.id || o.id === 0) && (o.id = o.li_attr.id.toString()), o.id || o.id === 0 || (o.id = i), o.li_attr.id || (o.li_attr.id = o.id), e && typeof e.a_attr == "object")
|
|
1345
|
+
for (r in e.a_attr)
|
|
1346
|
+
e.a_attr.hasOwnProperty(r) && (o.a_attr[r] = e.a_attr[r]);
|
|
1347
|
+
if (e && e.children && e.children.length) {
|
|
1348
|
+
for (r = 0, a = e.children.length; r < a; r++)
|
|
1349
|
+
n = this._parse_model_from_json(e.children[r], o.id, t), c = d[n], o.children.push(n), c.children_d.length && (o.children_d = o.children_d.concat(c.children_d));
|
|
1350
|
+
o.children_d = o.children.concat(o.children_d);
|
|
1351
|
+
}
|
|
1352
|
+
return e && e.children && e.children === !0 && (o.state.loaded = !1, o.children = [], o.children_d = []), delete e.data, delete e.children, o.original = e, d[o.id] = o, o.state.selected && this._data.core.selected.push(o.id), o.id;
|
|
1353
|
+
},
|
|
1354
|
+
/**
|
|
1355
|
+
* redraws all nodes that need to be redrawn. Used internally.
|
|
1356
|
+
* @private
|
|
1357
|
+
* @name _redraw()
|
|
1358
|
+
* @trigger redraw.jstree
|
|
1359
|
+
*/
|
|
1360
|
+
_redraw: function() {
|
|
1361
|
+
var e = this._model.force_full_redraw ? this._model.data[l.jstree.root].children.concat([]) : this._model.changed.concat([]), s = T.createElement("UL"), t, i, r, a = this._data.core.focused;
|
|
1362
|
+
for (i = 0, r = e.length; i < r; i++)
|
|
1363
|
+
t = this.redraw_node(e[i], !0, this._model.force_full_redraw), t && this._model.force_full_redraw && s.appendChild(t);
|
|
1364
|
+
this._model.force_full_redraw && (s.className = this.get_container_ul()[0].className, s.setAttribute("role", "presentation"), this.element.empty().append(s)), a !== null && this.settings.core.restore_focus && (t = this.get_node(a, !0), t && t.length && t.children(".jstree-anchor")[0] !== T.activeElement ? t.children(".jstree-anchor").trigger("focus") : this._data.core.focused = null), this._model.force_full_redraw = !1, this._model.changed = [], this.trigger("redraw", { nodes: e });
|
|
1365
|
+
},
|
|
1366
|
+
/**
|
|
1367
|
+
* redraws all nodes that need to be redrawn or optionally - the whole tree
|
|
1368
|
+
* @name redraw([full])
|
|
1369
|
+
* @param {Boolean} full if set to `true` all nodes are redrawn.
|
|
1370
|
+
*/
|
|
1371
|
+
redraw: function(e) {
|
|
1372
|
+
e && (this._model.force_full_redraw = !0), this._redraw();
|
|
1373
|
+
},
|
|
1374
|
+
/**
|
|
1375
|
+
* redraws a single node's children. Used internally.
|
|
1376
|
+
* @private
|
|
1377
|
+
* @name draw_children(node)
|
|
1378
|
+
* @param {mixed} node the node whose children will be redrawn
|
|
1379
|
+
*/
|
|
1380
|
+
draw_children: function(e) {
|
|
1381
|
+
var s = this.get_node(e), t = !1, i = !1, r = !1, a = T;
|
|
1382
|
+
if (!s)
|
|
1383
|
+
return !1;
|
|
1384
|
+
if (s.id === l.jstree.root)
|
|
1385
|
+
return this.redraw(!0);
|
|
1386
|
+
if (e = this.get_node(e, !0), !e || !e.length)
|
|
1387
|
+
return !1;
|
|
1388
|
+
if (e.children(".jstree-children").remove(), e = e[0], s.children.length && s.state.loaded) {
|
|
1389
|
+
for (r = a.createElement("UL"), r.setAttribute("role", "group"), r.className = "jstree-children", t = 0, i = s.children.length; t < i; t++)
|
|
1390
|
+
r.appendChild(this.redraw_node(s.children[t], !0, !0));
|
|
1391
|
+
e.appendChild(r);
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
/**
|
|
1395
|
+
* redraws a single node. Used internally.
|
|
1396
|
+
* @private
|
|
1397
|
+
* @name redraw_node(node, deep, is_callback, force_render)
|
|
1398
|
+
* @param {mixed} node the node to redraw
|
|
1399
|
+
* @param {Boolean} deep should child nodes be redrawn too
|
|
1400
|
+
* @param {Boolean} is_callback is this a recursion call
|
|
1401
|
+
* @param {Boolean} force_render should children of closed parents be drawn anyway
|
|
1402
|
+
*/
|
|
1403
|
+
redraw_node: function(e, s, t, i) {
|
|
1404
|
+
var r = this.get_node(e), a = !1, n = !1, c = !1, d = !1, h = !1, o = !1, f = "", _ = T, u = this._model.data, g = !1, p = null, m = 0, N = 0, O = !1, x = !1;
|
|
1405
|
+
if (!r)
|
|
1406
|
+
return !1;
|
|
1407
|
+
if (r.id === l.jstree.root)
|
|
1408
|
+
return this.redraw(!0);
|
|
1409
|
+
if (s = s || r.children.length === 0, e = T.querySelector ? this.element[0].querySelector("#" + ("0123456789".indexOf(r.id[0]) !== -1 ? "\\3" + r.id[0] + " " + r.id.substr(1).replace(l.jstree.idregex, "\\$&") : r.id.replace(l.jstree.idregex, "\\$&"))) : T.getElementById(r.id), e)
|
|
1410
|
+
e = l(e), t || (a = e.parent().parent()[0], a === this.element[0] && (a = null), n = e.index()), !s && r.children.length && !e.children(".jstree-children").length && (s = !0), s || (c = e.children(".jstree-children")[0]), g = e.children(".jstree-anchor")[0] === T.activeElement, e.remove();
|
|
1411
|
+
else if (s = !0, !t) {
|
|
1412
|
+
if (a = r.parent !== l.jstree.root ? l("#" + r.parent.replace(l.jstree.idregex, "\\$&"), this.element)[0] : null, a !== null && (!a || !u[r.parent].state.opened))
|
|
1413
|
+
return !1;
|
|
1414
|
+
n = l.inArray(r.id, a === null ? u[l.jstree.root].children : u[r.parent].children);
|
|
1415
|
+
}
|
|
1416
|
+
e = this._data.core.node.cloneNode(!0), f = "jstree-node ";
|
|
1417
|
+
for (d in r.li_attr)
|
|
1418
|
+
if (r.li_attr.hasOwnProperty(d)) {
|
|
1419
|
+
if (d === "id")
|
|
1420
|
+
continue;
|
|
1421
|
+
d !== "class" ? e.setAttribute(d, r.li_attr[d]) : f += r.li_attr[d];
|
|
1422
|
+
}
|
|
1423
|
+
for (r.a_attr.id || (r.a_attr.id = r.id + "_anchor"), e.childNodes[1].setAttribute("aria-selected", !!r.state.selected), e.childNodes[1].setAttribute("aria-level", r.parents.length), this.settings.core.compute_elements_positions && (e.childNodes[1].setAttribute("aria-setsize", u[r.parent].children.length), e.childNodes[1].setAttribute("aria-posinset", u[r.parent].children.indexOf(r.id) + 1)), r.state.disabled && e.childNodes[1].setAttribute("aria-disabled", !0), d = 0, h = r.children.length; d < h; d++)
|
|
1424
|
+
if (!u[r.children[d]].state.hidden) {
|
|
1425
|
+
O = !0;
|
|
1426
|
+
break;
|
|
1427
|
+
}
|
|
1428
|
+
if (r.parent !== null && u[r.parent] && !r.state.hidden && (d = l.inArray(r.id, u[r.parent].children), x = r.id, d !== -1))
|
|
1429
|
+
for (d++, h = u[r.parent].children.length; d < h && (u[u[r.parent].children[d]].state.hidden || (x = u[r.parent].children[d]), x === r.id); d++)
|
|
1430
|
+
;
|
|
1431
|
+
r.state.hidden && (f += " jstree-hidden"), r.state.loading && (f += " jstree-loading"), r.state.loaded && !O ? f += " jstree-leaf" : (f += r.state.opened && r.state.loaded ? " jstree-open" : " jstree-closed", e.childNodes[1].setAttribute("aria-expanded", r.state.opened && r.state.loaded)), x === r.id && (f += " jstree-last"), e.id = r.id, e.className = f, f = (r.state.selected ? " jstree-clicked" : "") + (r.state.disabled ? " jstree-disabled" : "");
|
|
1432
|
+
for (h in r.a_attr)
|
|
1433
|
+
if (r.a_attr.hasOwnProperty(h)) {
|
|
1434
|
+
if (h === "href" && r.a_attr[h] === "#")
|
|
1435
|
+
continue;
|
|
1436
|
+
h !== "class" ? e.childNodes[1].setAttribute(h, r.a_attr[h]) : f += " " + r.a_attr[h];
|
|
1437
|
+
}
|
|
1438
|
+
if (f.length && (e.childNodes[1].className = "jstree-anchor " + f), (r.icon && r.icon !== !0 || r.icon === !1) && (r.icon === !1 ? e.childNodes[1].childNodes[0].className += " jstree-themeicon-hidden" : r.icon.indexOf("/") === -1 && r.icon.indexOf(".") === -1 ? e.childNodes[1].childNodes[0].className += " " + r.icon + " jstree-themeicon-custom" : (e.childNodes[1].childNodes[0].style.backgroundImage = 'url("' + r.icon + '")', e.childNodes[1].childNodes[0].style.backgroundPosition = "center center", e.childNodes[1].childNodes[0].style.backgroundSize = "auto", e.childNodes[1].childNodes[0].className += " jstree-themeicon-custom")), this.settings.core.force_text ? e.childNodes[1].appendChild(_.createTextNode(r.text)) : e.childNodes[1].innerHTML += r.text, s && r.children.length && (r.state.opened || i) && r.state.loaded) {
|
|
1439
|
+
for (o = _.createElement("UL"), o.setAttribute("role", "group"), o.className = "jstree-children", d = 0, h = r.children.length; d < h; d++)
|
|
1440
|
+
o.appendChild(this.redraw_node(r.children[d], s, !0));
|
|
1441
|
+
e.appendChild(o);
|
|
1442
|
+
}
|
|
1443
|
+
if (c && e.appendChild(c), !t) {
|
|
1444
|
+
for (a || (a = this.element[0]), d = 0, h = a.childNodes.length; d < h; d++)
|
|
1445
|
+
if (a.childNodes[d] && a.childNodes[d].className && a.childNodes[d].className.indexOf("jstree-children") !== -1) {
|
|
1446
|
+
p = a.childNodes[d];
|
|
1447
|
+
break;
|
|
1448
|
+
}
|
|
1449
|
+
p || (p = _.createElement("UL"), p.setAttribute("role", "group"), p.className = "jstree-children", a.appendChild(p)), a = p, n < a.childNodes.length ? a.insertBefore(e, a.childNodes[n]) : a.appendChild(e), g && (m = this.element[0].scrollTop, N = this.element[0].scrollLeft, e.childNodes[1].focus(), this.element[0].scrollTop = m, this.element[0].scrollLeft = N);
|
|
1450
|
+
}
|
|
1451
|
+
return r.state.opened && !r.state.loaded && (r.state.opened = !1, setTimeout((function() {
|
|
1452
|
+
this.open_node(r.id, !1, 0);
|
|
1453
|
+
}).bind(this), 0)), e;
|
|
1454
|
+
},
|
|
1455
|
+
/**
|
|
1456
|
+
* opens a node, revealing its children. If the node is not loaded it will be loaded and opened once ready.
|
|
1457
|
+
* @name open_node(obj [, callback, animation])
|
|
1458
|
+
* @param {mixed} obj the node to open
|
|
1459
|
+
* @param {Function} callback a function to execute once the node is opened
|
|
1460
|
+
* @param {Number} animation the animation duration in milliseconds when opening the node (overrides the `core.animation` setting). Use `false` for no animation.
|
|
1461
|
+
* @trigger open_node.jstree, after_open.jstree, before_open.jstree
|
|
1462
|
+
*/
|
|
1463
|
+
open_node: function(e, s, t) {
|
|
1464
|
+
var i, r, a, n;
|
|
1465
|
+
if (l.vakata.is_array(e)) {
|
|
1466
|
+
for (e = e.slice(), i = 0, r = e.length; i < r; i++)
|
|
1467
|
+
this.open_node(e[i], s, t);
|
|
1468
|
+
return !0;
|
|
1469
|
+
}
|
|
1470
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1471
|
+
return !1;
|
|
1472
|
+
if (t = t === y ? this.settings.core.animation : t, !this.is_closed(e))
|
|
1473
|
+
return s && s.call(this, e, !1), !1;
|
|
1474
|
+
if (this.is_loaded(e))
|
|
1475
|
+
return a = this.get_node(e, !0), n = this, a.length && (t && a.children(".jstree-children").length && a.children(".jstree-children").stop(!0, !0), e.children.length && !this._firstChild(a.children(".jstree-children")[0]) && this.draw_children(e), t ? (this.trigger("before_open", { node: e }), a.children(".jstree-children").css("display", "none").end().removeClass("jstree-closed").addClass("jstree-open").children(".jstree-anchor").attr("aria-expanded", !0).end().children(".jstree-children").stop(!0, !0).slideDown(t, function() {
|
|
1476
|
+
this.style.display = "", n.element && n.trigger("after_open", { node: e });
|
|
1477
|
+
})) : (this.trigger("before_open", { node: e }), a[0].className = a[0].className.replace("jstree-closed", "jstree-open"), a[0].childNodes[1].setAttribute("aria-expanded", !0))), e.state.opened = !0, s && s.call(this, e, !0), a.length || this.trigger("before_open", { node: e }), this.trigger("open_node", { node: e }), (!t || !a.length) && this.trigger("after_open", { node: e }), !0;
|
|
1478
|
+
if (this.is_loading(e))
|
|
1479
|
+
return setTimeout((function() {
|
|
1480
|
+
this.open_node(e, s, t);
|
|
1481
|
+
}).bind(this), 500);
|
|
1482
|
+
this.load_node(e, function(c, d) {
|
|
1483
|
+
return d ? this.open_node(c, s, t) : s ? s.call(this, c, !1) : !1;
|
|
1484
|
+
});
|
|
1485
|
+
},
|
|
1486
|
+
/**
|
|
1487
|
+
* opens every parent of a node (node should be loaded)
|
|
1488
|
+
* @name _open_to(obj)
|
|
1489
|
+
* @param {mixed} obj the node to reveal
|
|
1490
|
+
* @private
|
|
1491
|
+
*/
|
|
1492
|
+
_open_to: function(e) {
|
|
1493
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1494
|
+
return !1;
|
|
1495
|
+
var s, t, i = e.parents;
|
|
1496
|
+
for (s = 0, t = i.length; s < t; s += 1)
|
|
1497
|
+
s !== l.jstree.root && this.open_node(i[s], !1, 0);
|
|
1498
|
+
return l("#" + e.id.replace(l.jstree.idregex, "\\$&"), this.element);
|
|
1499
|
+
},
|
|
1500
|
+
/**
|
|
1501
|
+
* closes a node, hiding its children
|
|
1502
|
+
* @name close_node(obj [, animation])
|
|
1503
|
+
* @param {mixed} obj the node to close
|
|
1504
|
+
* @param {Number} animation the animation duration in milliseconds when closing the node (overrides the `core.animation` setting). Use `false` for no animation.
|
|
1505
|
+
* @trigger close_node.jstree, after_close.jstree
|
|
1506
|
+
*/
|
|
1507
|
+
close_node: function(e, s) {
|
|
1508
|
+
var t, i, r, a;
|
|
1509
|
+
if (l.vakata.is_array(e)) {
|
|
1510
|
+
for (e = e.slice(), t = 0, i = e.length; t < i; t++)
|
|
1511
|
+
this.close_node(e[t], s);
|
|
1512
|
+
return !0;
|
|
1513
|
+
}
|
|
1514
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root || this.is_closed(e))
|
|
1515
|
+
return !1;
|
|
1516
|
+
s = s === y ? this.settings.core.animation : s, r = this, a = this.get_node(e, !0), e.state.opened = !1, this.trigger("close_node", { node: e }), a.length ? s ? a.children(".jstree-children").attr("style", "display:block !important").end().removeClass("jstree-open").addClass("jstree-closed").children(".jstree-anchor").attr("aria-expanded", !1).end().children(".jstree-children").stop(!0, !0).slideUp(s, function() {
|
|
1517
|
+
this.style.display = "", a.children(".jstree-children").remove(), r.element && r.trigger("after_close", { node: e });
|
|
1518
|
+
}) : (a[0].className = a[0].className.replace("jstree-open", "jstree-closed"), a.children(".jstree-anchor").attr("aria-expanded", !1), a.children(".jstree-children").remove(), this.trigger("after_close", { node: e })) : this.trigger("after_close", { node: e });
|
|
1519
|
+
},
|
|
1520
|
+
/**
|
|
1521
|
+
* toggles a node - closing it if it is open, opening it if it is closed
|
|
1522
|
+
* @name toggle_node(obj)
|
|
1523
|
+
* @param {mixed} obj the node to toggle
|
|
1524
|
+
*/
|
|
1525
|
+
toggle_node: function(e) {
|
|
1526
|
+
var s, t;
|
|
1527
|
+
if (l.vakata.is_array(e)) {
|
|
1528
|
+
for (e = e.slice(), s = 0, t = e.length; s < t; s++)
|
|
1529
|
+
this.toggle_node(e[s]);
|
|
1530
|
+
return !0;
|
|
1531
|
+
}
|
|
1532
|
+
if (this.is_closed(e))
|
|
1533
|
+
return this.open_node(e);
|
|
1534
|
+
if (this.is_open(e))
|
|
1535
|
+
return this.close_node(e);
|
|
1536
|
+
},
|
|
1537
|
+
/**
|
|
1538
|
+
* opens all nodes within a node (or the tree), revealing their children. If the node is not loaded it will be loaded and opened once ready.
|
|
1539
|
+
* @name open_all([obj, animation, original_obj])
|
|
1540
|
+
* @param {mixed} obj the node to open recursively, omit to open all nodes in the tree
|
|
1541
|
+
* @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation
|
|
1542
|
+
* @param {jQuery} reference to the node that started the process (internal use)
|
|
1543
|
+
* @trigger open_all.jstree
|
|
1544
|
+
*/
|
|
1545
|
+
open_all: function(e, s, t) {
|
|
1546
|
+
if (e || (e = l.jstree.root), e = this.get_node(e), !e)
|
|
1547
|
+
return !1;
|
|
1548
|
+
var i = e.id === l.jstree.root ? this.get_container_ul() : this.get_node(e, !0), r, a, n;
|
|
1549
|
+
if (!i.length) {
|
|
1550
|
+
for (r = 0, a = e.children_d.length; r < a; r++)
|
|
1551
|
+
this.is_closed(this._model.data[e.children_d[r]]) && (this._model.data[e.children_d[r]].state.opened = !0);
|
|
1552
|
+
return this.trigger("open_all", { node: e });
|
|
1553
|
+
}
|
|
1554
|
+
t = t || i, n = this, i = this.is_closed(e) ? i.find(".jstree-closed").addBack() : i.find(".jstree-closed"), i.each(function() {
|
|
1555
|
+
n.open_node(
|
|
1556
|
+
this,
|
|
1557
|
+
function(c, d) {
|
|
1558
|
+
d && this.is_parent(c) && this.open_all(c, s, t);
|
|
1559
|
+
},
|
|
1560
|
+
s || 0
|
|
1561
|
+
);
|
|
1562
|
+
}), t.find(".jstree-closed").length === 0 && this.trigger("open_all", { node: this.get_node(t) });
|
|
1563
|
+
},
|
|
1564
|
+
/**
|
|
1565
|
+
* closes all nodes within a node (or the tree), revealing their children
|
|
1566
|
+
* @name close_all([obj, animation])
|
|
1567
|
+
* @param {mixed} obj the node to close recursively, omit to close all nodes in the tree
|
|
1568
|
+
* @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation
|
|
1569
|
+
* @trigger close_all.jstree
|
|
1570
|
+
*/
|
|
1571
|
+
close_all: function(e, s) {
|
|
1572
|
+
if (e || (e = l.jstree.root), e = this.get_node(e), !e)
|
|
1573
|
+
return !1;
|
|
1574
|
+
var t = e.id === l.jstree.root ? this.get_container_ul() : this.get_node(e, !0), i = this, r, a;
|
|
1575
|
+
for (t.length && (t = this.is_open(e) ? t.find(".jstree-open").addBack() : t.find(".jstree-open"), l(t.get().reverse()).each(function() {
|
|
1576
|
+
i.close_node(this, s || 0);
|
|
1577
|
+
})), r = 0, a = e.children_d.length; r < a; r++)
|
|
1578
|
+
this._model.data[e.children_d[r]].state.opened = !1;
|
|
1579
|
+
this.trigger("close_all", { node: e });
|
|
1580
|
+
},
|
|
1581
|
+
/**
|
|
1582
|
+
* checks if a node is disabled (not selectable)
|
|
1583
|
+
* @name is_disabled(obj)
|
|
1584
|
+
* @param {mixed} obj
|
|
1585
|
+
* @return {Boolean}
|
|
1586
|
+
*/
|
|
1587
|
+
is_disabled: function(e) {
|
|
1588
|
+
return e = this.get_node(e), e && e.state && e.state.disabled;
|
|
1589
|
+
},
|
|
1590
|
+
/**
|
|
1591
|
+
* enables a node - so that it can be selected
|
|
1592
|
+
* @name enable_node(obj)
|
|
1593
|
+
* @param {mixed} obj the node to enable
|
|
1594
|
+
* @trigger enable_node.jstree
|
|
1595
|
+
*/
|
|
1596
|
+
enable_node: function(e) {
|
|
1597
|
+
var s, t;
|
|
1598
|
+
if (l.vakata.is_array(e)) {
|
|
1599
|
+
for (e = e.slice(), s = 0, t = e.length; s < t; s++)
|
|
1600
|
+
this.enable_node(e[s]);
|
|
1601
|
+
return !0;
|
|
1602
|
+
}
|
|
1603
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1604
|
+
return !1;
|
|
1605
|
+
e.state.disabled = !1, this.get_node(e, !0).children(".jstree-anchor").removeClass("jstree-disabled").attr("aria-disabled", !1), this.trigger("enable_node", { node: e });
|
|
1606
|
+
},
|
|
1607
|
+
/**
|
|
1608
|
+
* disables a node - so that it can not be selected
|
|
1609
|
+
* @name disable_node(obj)
|
|
1610
|
+
* @param {mixed} obj the node to disable
|
|
1611
|
+
* @trigger disable_node.jstree
|
|
1612
|
+
*/
|
|
1613
|
+
disable_node: function(e) {
|
|
1614
|
+
var s, t;
|
|
1615
|
+
if (l.vakata.is_array(e)) {
|
|
1616
|
+
for (e = e.slice(), s = 0, t = e.length; s < t; s++)
|
|
1617
|
+
this.disable_node(e[s]);
|
|
1618
|
+
return !0;
|
|
1619
|
+
}
|
|
1620
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1621
|
+
return !1;
|
|
1622
|
+
e.state.disabled = !0, this.get_node(e, !0).children(".jstree-anchor").addClass("jstree-disabled").attr("aria-disabled", !0), this.trigger("disable_node", { node: e });
|
|
1623
|
+
},
|
|
1624
|
+
/**
|
|
1625
|
+
* determines if a node is hidden
|
|
1626
|
+
* @name is_hidden(obj)
|
|
1627
|
+
* @param {mixed} obj the node
|
|
1628
|
+
*/
|
|
1629
|
+
is_hidden: function(e) {
|
|
1630
|
+
return e = this.get_node(e), e.state.hidden === !0;
|
|
1631
|
+
},
|
|
1632
|
+
/**
|
|
1633
|
+
* hides a node - it is still in the structure but will not be visible
|
|
1634
|
+
* @name hide_node(obj)
|
|
1635
|
+
* @param {mixed} obj the node to hide
|
|
1636
|
+
* @param {Boolean} skip_redraw internal parameter controlling if redraw is called
|
|
1637
|
+
* @trigger hide_node.jstree
|
|
1638
|
+
*/
|
|
1639
|
+
hide_node: function(e, s) {
|
|
1640
|
+
var t, i;
|
|
1641
|
+
if (l.vakata.is_array(e)) {
|
|
1642
|
+
for (e = e.slice(), t = 0, i = e.length; t < i; t++)
|
|
1643
|
+
this.hide_node(e[t], !0);
|
|
1644
|
+
return s || this.redraw(), !0;
|
|
1645
|
+
}
|
|
1646
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1647
|
+
return !1;
|
|
1648
|
+
e.state.hidden || (e.state.hidden = !0, this._node_changed(e.parent), s || this.redraw(), this.trigger("hide_node", { node: e }));
|
|
1649
|
+
},
|
|
1650
|
+
/**
|
|
1651
|
+
* shows a node
|
|
1652
|
+
* @name show_node(obj)
|
|
1653
|
+
* @param {mixed} obj the node to show
|
|
1654
|
+
* @param {Boolean} skip_redraw internal parameter controlling if redraw is called
|
|
1655
|
+
* @trigger show_node.jstree
|
|
1656
|
+
*/
|
|
1657
|
+
show_node: function(e, s) {
|
|
1658
|
+
var t, i;
|
|
1659
|
+
if (l.vakata.is_array(e)) {
|
|
1660
|
+
for (e = e.slice(), t = 0, i = e.length; t < i; t++)
|
|
1661
|
+
this.show_node(e[t], !0);
|
|
1662
|
+
return s || this.redraw(), !0;
|
|
1663
|
+
}
|
|
1664
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1665
|
+
return !1;
|
|
1666
|
+
e.state.hidden && (e.state.hidden = !1, this._node_changed(e.parent), s || this.redraw(), this.trigger("show_node", { node: e }));
|
|
1667
|
+
},
|
|
1668
|
+
/**
|
|
1669
|
+
* hides all nodes
|
|
1670
|
+
* @name hide_all()
|
|
1671
|
+
* @trigger hide_all.jstree
|
|
1672
|
+
*/
|
|
1673
|
+
hide_all: function(e) {
|
|
1674
|
+
var s, t = this._model.data, i = [];
|
|
1675
|
+
for (s in t)
|
|
1676
|
+
t.hasOwnProperty(s) && s !== l.jstree.root && !t[s].state.hidden && (t[s].state.hidden = !0, i.push(s));
|
|
1677
|
+
return this._model.force_full_redraw = !0, e || this.redraw(), this.trigger("hide_all", { nodes: i }), i;
|
|
1678
|
+
},
|
|
1679
|
+
/**
|
|
1680
|
+
* shows all nodes
|
|
1681
|
+
* @name show_all()
|
|
1682
|
+
* @trigger show_all.jstree
|
|
1683
|
+
*/
|
|
1684
|
+
show_all: function(e) {
|
|
1685
|
+
var s, t = this._model.data, i = [];
|
|
1686
|
+
for (s in t)
|
|
1687
|
+
t.hasOwnProperty(s) && s !== l.jstree.root && t[s].state.hidden && (t[s].state.hidden = !1, i.push(s));
|
|
1688
|
+
return this._model.force_full_redraw = !0, e || this.redraw(), this.trigger("show_all", { nodes: i }), i;
|
|
1689
|
+
},
|
|
1690
|
+
/**
|
|
1691
|
+
* called when a node is selected by the user. Used internally.
|
|
1692
|
+
* @private
|
|
1693
|
+
* @name activate_node(obj, e)
|
|
1694
|
+
* @param {mixed} obj the node
|
|
1695
|
+
* @param {Object} e the related event
|
|
1696
|
+
* @trigger activate_node.jstree, changed.jstree
|
|
1697
|
+
*/
|
|
1698
|
+
activate_node: function(e, s) {
|
|
1699
|
+
if (this.is_disabled(e))
|
|
1700
|
+
return !1;
|
|
1701
|
+
if ((!s || typeof s != "object") && (s = {}), this._data.core.last_clicked = this._data.core.last_clicked && this._data.core.last_clicked.id !== y ? this.get_node(this._data.core.last_clicked.id) : null, this._data.core.last_clicked && !this._data.core.last_clicked.state.selected && (this._data.core.last_clicked = null), !this._data.core.last_clicked && this._data.core.selected.length && (this._data.core.last_clicked = this.get_node(this._data.core.selected[this._data.core.selected.length - 1])), !this.settings.core.multiple || !s.metaKey && !s.ctrlKey && !s.shiftKey || s.shiftKey && (!this._data.core.last_clicked || !this.get_parent(e) || this.get_parent(e) !== this._data.core.last_clicked.parent))
|
|
1702
|
+
!this.settings.core.multiple && (s.metaKey || s.ctrlKey || s.shiftKey) && this.is_selected(e) ? this.deselect_node(e, !1, s) : ((this.settings.core.allow_reselect || !this.is_selected(e) || this._data.core.selected.length !== 1) && (this.deselect_all(!0), this.select_node(e, !1, !1, s)), this._data.core.last_clicked = this.get_node(e));
|
|
1703
|
+
else if (s.shiftKey) {
|
|
1704
|
+
var t = this.get_node(e).id, i = this._data.core.last_clicked.id, r = this.get_node(this._data.core.last_clicked.parent).children, a = !1, n, c;
|
|
1705
|
+
for (n = 0, c = r.length; n < c; n += 1)
|
|
1706
|
+
r[n] === t && (a = !a), r[n] === i && (a = !a), !this.is_disabled(r[n]) && (a || r[n] === t || r[n] === i) ? this.is_hidden(r[n]) || this.select_node(r[n], !0, !1, s) : s.ctrlKey || this.deselect_node(r[n], !0, s);
|
|
1707
|
+
this.trigger("changed", { action: "select_node", node: this.get_node(e), selected: this._data.core.selected, event: s });
|
|
1708
|
+
} else
|
|
1709
|
+
this.is_selected(e) ? this.deselect_node(e, !1, s) : (s.ctrlKey && (this._data.core.last_clicked = this.get_node(e)), this.select_node(e, !1, !1, s));
|
|
1710
|
+
this.trigger("activate_node", { node: this.get_node(e), event: s });
|
|
1711
|
+
},
|
|
1712
|
+
/**
|
|
1713
|
+
* applies the hover state on a node, called when a node is hovered by the user. Used internally.
|
|
1714
|
+
* @private
|
|
1715
|
+
* @name hover_node(obj)
|
|
1716
|
+
* @param {mixed} obj
|
|
1717
|
+
* @trigger hover_node.jstree
|
|
1718
|
+
*/
|
|
1719
|
+
hover_node: function(e) {
|
|
1720
|
+
if (e = this.get_node(e, !0), !e || !e.length || e.children(".jstree-hovered").length)
|
|
1721
|
+
return !1;
|
|
1722
|
+
var s = this.element.find(".jstree-hovered"), t = this.element;
|
|
1723
|
+
s && s.length && this.dehover_node(s), e.children(".jstree-anchor").addClass("jstree-hovered"), this.trigger("hover_node", { node: this.get_node(e) }), setTimeout(function() {
|
|
1724
|
+
t.attr("aria-activedescendant", e[0].id);
|
|
1725
|
+
}, 0);
|
|
1726
|
+
},
|
|
1727
|
+
/**
|
|
1728
|
+
* removes the hover state from a nodecalled when a node is no longer hovered by the user. Used internally.
|
|
1729
|
+
* @private
|
|
1730
|
+
* @name dehover_node(obj)
|
|
1731
|
+
* @param {mixed} obj
|
|
1732
|
+
* @trigger dehover_node.jstree
|
|
1733
|
+
*/
|
|
1734
|
+
dehover_node: function(e) {
|
|
1735
|
+
if (e = this.get_node(e, !0), !e || !e.length || !e.children(".jstree-hovered").length)
|
|
1736
|
+
return !1;
|
|
1737
|
+
e.children(".jstree-anchor").removeClass("jstree-hovered"), this.trigger("dehover_node", { node: this.get_node(e) });
|
|
1738
|
+
},
|
|
1739
|
+
/**
|
|
1740
|
+
* select a node
|
|
1741
|
+
* @name select_node(obj [, supress_event, prevent_open])
|
|
1742
|
+
* @param {mixed} obj an array can be used to select multiple nodes
|
|
1743
|
+
* @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
|
|
1744
|
+
* @param {Boolean} prevent_open if set to `true` parents of the selected node won't be opened
|
|
1745
|
+
* @trigger select_node.jstree, changed.jstree
|
|
1746
|
+
*/
|
|
1747
|
+
select_node: function(e, s, t, i) {
|
|
1748
|
+
var r, a, n;
|
|
1749
|
+
if (l.vakata.is_array(e)) {
|
|
1750
|
+
for (e = e.slice(), a = 0, n = e.length; a < n; a++)
|
|
1751
|
+
this.select_node(e[a], s, t, i);
|
|
1752
|
+
return !0;
|
|
1753
|
+
}
|
|
1754
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1755
|
+
return !1;
|
|
1756
|
+
r = this.get_node(e, !0), e.state.selected || (e.state.selected = !0, this._data.core.selected.push(e.id), t || (r = this._open_to(e)), r && r.length && r.children(".jstree-anchor").addClass("jstree-clicked").attr("aria-selected", !0), this.trigger("select_node", { node: e, selected: this._data.core.selected, event: i }), s || this.trigger("changed", { action: "select_node", node: e, selected: this._data.core.selected, event: i }));
|
|
1757
|
+
},
|
|
1758
|
+
/**
|
|
1759
|
+
* deselect a node
|
|
1760
|
+
* @name deselect_node(obj [, supress_event])
|
|
1761
|
+
* @param {mixed} obj an array can be used to deselect multiple nodes
|
|
1762
|
+
* @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
|
|
1763
|
+
* @trigger deselect_node.jstree, changed.jstree
|
|
1764
|
+
*/
|
|
1765
|
+
deselect_node: function(e, s, t) {
|
|
1766
|
+
var i, r, a;
|
|
1767
|
+
if (l.vakata.is_array(e)) {
|
|
1768
|
+
for (e = e.slice(), i = 0, r = e.length; i < r; i++)
|
|
1769
|
+
this.deselect_node(e[i], s, t);
|
|
1770
|
+
return !0;
|
|
1771
|
+
}
|
|
1772
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1773
|
+
return !1;
|
|
1774
|
+
a = this.get_node(e, !0), e.state.selected && (e.state.selected = !1, this._data.core.selected = l.vakata.array_remove_item(this._data.core.selected, e.id), a.length && a.children(".jstree-anchor").removeClass("jstree-clicked").attr("aria-selected", !1), this.trigger("deselect_node", { node: e, selected: this._data.core.selected, event: t }), s || this.trigger("changed", { action: "deselect_node", node: e, selected: this._data.core.selected, event: t }));
|
|
1775
|
+
},
|
|
1776
|
+
/**
|
|
1777
|
+
* select all nodes in the tree
|
|
1778
|
+
* @name select_all([supress_event])
|
|
1779
|
+
* @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
|
|
1780
|
+
* @trigger select_all.jstree, changed.jstree
|
|
1781
|
+
*/
|
|
1782
|
+
select_all: function(e) {
|
|
1783
|
+
var s = this._data.core.selected.concat([]), t, i;
|
|
1784
|
+
for (this._data.core.selected = this._model.data[l.jstree.root].children_d.concat(), t = 0, i = this._data.core.selected.length; t < i; t++)
|
|
1785
|
+
this._model.data[this._data.core.selected[t]] && (this._model.data[this._data.core.selected[t]].state.selected = !0);
|
|
1786
|
+
this.redraw(!0), this.trigger("select_all", { selected: this._data.core.selected }), e || this.trigger("changed", { action: "select_all", selected: this._data.core.selected, old_selection: s });
|
|
1787
|
+
},
|
|
1788
|
+
/**
|
|
1789
|
+
* deselect all selected nodes
|
|
1790
|
+
* @name deselect_all([supress_event])
|
|
1791
|
+
* @param {Boolean} supress_event if set to `true` the `changed.jstree` event won't be triggered
|
|
1792
|
+
* @trigger deselect_all.jstree, changed.jstree
|
|
1793
|
+
*/
|
|
1794
|
+
deselect_all: function(e) {
|
|
1795
|
+
var s = this._data.core.selected.concat([]), t, i;
|
|
1796
|
+
for (t = 0, i = this._data.core.selected.length; t < i; t++)
|
|
1797
|
+
this._model.data[this._data.core.selected[t]] && (this._model.data[this._data.core.selected[t]].state.selected = !1);
|
|
1798
|
+
this._data.core.selected = [], this.element.find(".jstree-clicked").removeClass("jstree-clicked").attr("aria-selected", !1), this.trigger("deselect_all", { selected: this._data.core.selected, node: s }), e || this.trigger("changed", { action: "deselect_all", selected: this._data.core.selected, old_selection: s });
|
|
1799
|
+
},
|
|
1800
|
+
/**
|
|
1801
|
+
* checks if a node is selected
|
|
1802
|
+
* @name is_selected(obj)
|
|
1803
|
+
* @param {mixed} obj
|
|
1804
|
+
* @return {Boolean}
|
|
1805
|
+
*/
|
|
1806
|
+
is_selected: function(e) {
|
|
1807
|
+
return e = this.get_node(e), !e || e.id === l.jstree.root ? !1 : e.state.selected;
|
|
1808
|
+
},
|
|
1809
|
+
/**
|
|
1810
|
+
* get an array of all selected nodes
|
|
1811
|
+
* @name get_selected([full])
|
|
1812
|
+
* @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
|
|
1813
|
+
* @return {Array}
|
|
1814
|
+
*/
|
|
1815
|
+
get_selected: function(e) {
|
|
1816
|
+
return e ? l.map(this._data.core.selected, (function(s) {
|
|
1817
|
+
return this.get_node(s);
|
|
1818
|
+
}).bind(this)) : this._data.core.selected.slice();
|
|
1819
|
+
},
|
|
1820
|
+
/**
|
|
1821
|
+
* get an array of all top level selected nodes (ignoring children of selected nodes)
|
|
1822
|
+
* @name get_top_selected([full])
|
|
1823
|
+
* @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
|
|
1824
|
+
* @return {Array}
|
|
1825
|
+
*/
|
|
1826
|
+
get_top_selected: function(e) {
|
|
1827
|
+
var s = this.get_selected(!0), t = {}, i, r, a, n;
|
|
1828
|
+
for (i = 0, r = s.length; i < r; i++)
|
|
1829
|
+
t[s[i].id] = s[i];
|
|
1830
|
+
for (i = 0, r = s.length; i < r; i++)
|
|
1831
|
+
for (a = 0, n = s[i].children_d.length; a < n; a++)
|
|
1832
|
+
t[s[i].children_d[a]] && delete t[s[i].children_d[a]];
|
|
1833
|
+
s = [];
|
|
1834
|
+
for (i in t)
|
|
1835
|
+
t.hasOwnProperty(i) && s.push(i);
|
|
1836
|
+
return e ? l.map(s, (function(c) {
|
|
1837
|
+
return this.get_node(c);
|
|
1838
|
+
}).bind(this)) : s;
|
|
1839
|
+
},
|
|
1840
|
+
/**
|
|
1841
|
+
* get an array of all bottom level selected nodes (ignoring selected parents)
|
|
1842
|
+
* @name get_bottom_selected([full])
|
|
1843
|
+
* @param {mixed} full if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
|
|
1844
|
+
* @return {Array}
|
|
1845
|
+
*/
|
|
1846
|
+
get_bottom_selected: function(e) {
|
|
1847
|
+
var s = this.get_selected(!0), t = [], i, r;
|
|
1848
|
+
for (i = 0, r = s.length; i < r; i++)
|
|
1849
|
+
s[i].children.length || t.push(s[i].id);
|
|
1850
|
+
return e ? l.map(t, (function(a) {
|
|
1851
|
+
return this.get_node(a);
|
|
1852
|
+
}).bind(this)) : t;
|
|
1853
|
+
},
|
|
1854
|
+
/**
|
|
1855
|
+
* gets the current state of the tree so that it can be restored later with `set_state(state)`. Used internally.
|
|
1856
|
+
* @name get_state()
|
|
1857
|
+
* @private
|
|
1858
|
+
* @return {Object}
|
|
1859
|
+
*/
|
|
1860
|
+
get_state: function() {
|
|
1861
|
+
var e = {
|
|
1862
|
+
core: {
|
|
1863
|
+
open: [],
|
|
1864
|
+
loaded: [],
|
|
1865
|
+
scroll: {
|
|
1866
|
+
left: this.element.scrollLeft(),
|
|
1867
|
+
top: this.element.scrollTop()
|
|
1868
|
+
},
|
|
1869
|
+
/*!
|
|
1870
|
+
'themes' : {
|
|
1871
|
+
'name' : this.get_theme(),
|
|
1872
|
+
'icons' : this._data.core.themes.icons,
|
|
1873
|
+
'dots' : this._data.core.themes.dots
|
|
1874
|
+
},
|
|
1875
|
+
*/
|
|
1876
|
+
selected: []
|
|
1877
|
+
}
|
|
1878
|
+
}, s;
|
|
1879
|
+
for (s in this._model.data)
|
|
1880
|
+
this._model.data.hasOwnProperty(s) && s !== l.jstree.root && (this._model.data[s].state.loaded && this.settings.core.loaded_state && e.core.loaded.push(s), this._model.data[s].state.opened && e.core.open.push(s), this._model.data[s].state.selected && e.core.selected.push(s));
|
|
1881
|
+
return e;
|
|
1882
|
+
},
|
|
1883
|
+
/**
|
|
1884
|
+
* sets the state of the tree. Used internally.
|
|
1885
|
+
* @name set_state(state [, callback])
|
|
1886
|
+
* @private
|
|
1887
|
+
* @param {Object} state the state to restore. Keep in mind this object is passed by reference and jstree will modify it.
|
|
1888
|
+
* @param {Function} callback an optional function to execute once the state is restored.
|
|
1889
|
+
* @trigger set_state.jstree
|
|
1890
|
+
*/
|
|
1891
|
+
set_state: function(e, s) {
|
|
1892
|
+
if (e) {
|
|
1893
|
+
if (e.core && e.core.selected && e.core.initial_selection === y && (e.core.initial_selection = this._data.core.selected.concat([]).sort().join(",")), e.core) {
|
|
1894
|
+
var t, i;
|
|
1895
|
+
if (e.core.loaded)
|
|
1896
|
+
return !this.settings.core.loaded_state || !l.vakata.is_array(e.core.loaded) || !e.core.loaded.length ? (delete e.core.loaded, this.set_state(e, s)) : this._load_nodes(e.core.loaded, function(r) {
|
|
1897
|
+
delete e.core.loaded, this.set_state(e, s);
|
|
1898
|
+
}), !1;
|
|
1899
|
+
if (e.core.open)
|
|
1900
|
+
return !l.vakata.is_array(e.core.open) || !e.core.open.length ? (delete e.core.open, this.set_state(e, s)) : this._load_nodes(e.core.open, function(r) {
|
|
1901
|
+
this.open_node(r, !1, 0), delete e.core.open, this.set_state(e, s);
|
|
1902
|
+
}), !1;
|
|
1903
|
+
if (e.core.scroll)
|
|
1904
|
+
return e.core.scroll && e.core.scroll.left !== y && this.element.scrollLeft(e.core.scroll.left), e.core.scroll && e.core.scroll.top !== y && this.element.scrollTop(e.core.scroll.top), delete e.core.scroll, this.set_state(e, s), !1;
|
|
1905
|
+
if (e.core.selected)
|
|
1906
|
+
return t = this, (e.core.initial_selection === y || e.core.initial_selection === this._data.core.selected.concat([]).sort().join(",")) && (this.deselect_all(), l.each(e.core.selected, function(r, a) {
|
|
1907
|
+
t.select_node(a, !1, !0);
|
|
1908
|
+
})), delete e.core.initial_selection, delete e.core.selected, this.set_state(e, s), !1;
|
|
1909
|
+
for (i in e)
|
|
1910
|
+
e.hasOwnProperty(i) && i !== "core" && l.inArray(i, this.settings.plugins) === -1 && delete e[i];
|
|
1911
|
+
if (l.isEmptyObject(e.core))
|
|
1912
|
+
return delete e.core, this.set_state(e, s), !1;
|
|
1913
|
+
}
|
|
1914
|
+
return l.isEmptyObject(e) ? (e = null, s && s.call(this), this.trigger("set_state"), !1) : !0;
|
|
1915
|
+
}
|
|
1916
|
+
return !1;
|
|
1917
|
+
},
|
|
1918
|
+
/**
|
|
1919
|
+
* refreshes the tree - all nodes are reloaded with calls to `load_node`.
|
|
1920
|
+
* @name refresh()
|
|
1921
|
+
* @param {Boolean} skip_loading an option to skip showing the loading indicator
|
|
1922
|
+
* @param {Mixed} forget_state if set to `true` state will not be reapplied, if set to a function (receiving the current state as argument) the result of that function will be used as state
|
|
1923
|
+
* @trigger refresh.jstree
|
|
1924
|
+
*/
|
|
1925
|
+
refresh: function(e, s) {
|
|
1926
|
+
this._data.core.state = s === !0 ? {} : this.get_state(), s && l.vakata.is_function(s) && (this._data.core.state = s.call(this, this._data.core.state)), this._cnt = 0, this._model.data = {}, this._model.data[l.jstree.root] = {
|
|
1927
|
+
id: l.jstree.root,
|
|
1928
|
+
parent: null,
|
|
1929
|
+
parents: [],
|
|
1930
|
+
children: [],
|
|
1931
|
+
children_d: [],
|
|
1932
|
+
state: { loaded: !1 }
|
|
1933
|
+
}, this._data.core.selected = [], this._data.core.last_clicked = null, this._data.core.focused = null;
|
|
1934
|
+
var t = this.get_container_ul()[0].className;
|
|
1935
|
+
e || (this.element.html("<ul class='" + t + "' role='group'><li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='none' id='j" + this._id + "_loading'><i class='jstree-icon jstree-ocl'></i><a class='jstree-anchor' role='treeitem' href='#'><i class='jstree-icon jstree-themeicon-hidden'></i>" + this.get_string("Loading ...") + "</a></li></ul>"), this.element.attr("aria-activedescendant", "j" + this._id + "_loading")), this.load_node(l.jstree.root, function(i, r) {
|
|
1936
|
+
r && (this.get_container_ul()[0].className = t, this._firstChild(this.get_container_ul()[0]) && this.element.attr("aria-activedescendant", this._firstChild(this.get_container_ul()[0]).id), this.set_state(l.extend(!0, {}, this._data.core.state), function() {
|
|
1937
|
+
this.trigger("refresh");
|
|
1938
|
+
})), this._data.core.state = null;
|
|
1939
|
+
});
|
|
1940
|
+
},
|
|
1941
|
+
/**
|
|
1942
|
+
* refreshes a node in the tree (reload its children) all opened nodes inside that node are reloaded with calls to `load_node`.
|
|
1943
|
+
* @name refresh_node(obj)
|
|
1944
|
+
* @param {mixed} obj the node
|
|
1945
|
+
* @trigger refresh_node.jstree
|
|
1946
|
+
*/
|
|
1947
|
+
refresh_node: function(e) {
|
|
1948
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1949
|
+
return !1;
|
|
1950
|
+
var s = [], t = [], i = this._data.core.selected.concat([]);
|
|
1951
|
+
t.push(e.id), e.state.opened === !0 && s.push(e.id), this.get_node(e, !0).find(".jstree-open").each(function() {
|
|
1952
|
+
t.push(this.id), s.push(this.id);
|
|
1953
|
+
}), this._load_nodes(t, (function(r) {
|
|
1954
|
+
this.open_node(s, !1, 0), this.select_node(i), this.trigger("refresh_node", { node: e, nodes: r });
|
|
1955
|
+
}).bind(this), !1, !0);
|
|
1956
|
+
},
|
|
1957
|
+
/**
|
|
1958
|
+
* set (change) the ID of a node
|
|
1959
|
+
* @name set_id(obj, id)
|
|
1960
|
+
* @param {mixed} obj the node
|
|
1961
|
+
* @param {String} id the new ID
|
|
1962
|
+
* @return {Boolean}
|
|
1963
|
+
* @trigger set_id.jstree
|
|
1964
|
+
*/
|
|
1965
|
+
set_id: function(e, s) {
|
|
1966
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
1967
|
+
return !1;
|
|
1968
|
+
var t, i, r = this._model.data, a = e.id;
|
|
1969
|
+
for (s = s.toString(), r[e.parent].children[l.inArray(e.id, r[e.parent].children)] = s, t = 0, i = e.parents.length; t < i; t++)
|
|
1970
|
+
r[e.parents[t]].children_d[l.inArray(e.id, r[e.parents[t]].children_d)] = s;
|
|
1971
|
+
for (t = 0, i = e.children.length; t < i; t++)
|
|
1972
|
+
r[e.children[t]].parent = s;
|
|
1973
|
+
for (t = 0, i = e.children_d.length; t < i; t++)
|
|
1974
|
+
r[e.children_d[t]].parents[l.inArray(e.id, r[e.children_d[t]].parents)] = s;
|
|
1975
|
+
return t = l.inArray(e.id, this._data.core.selected), t !== -1 && (this._data.core.selected[t] = s), t = this.get_node(e.id, !0), t && (t.attr("id", s), this.element.attr("aria-activedescendant") === e.id && this.element.attr("aria-activedescendant", s)), delete r[e.id], e.id = s, e.li_attr.id = s, r[s] = e, this.trigger("set_id", { node: e, new: e.id, old: a }), !0;
|
|
1976
|
+
},
|
|
1977
|
+
/**
|
|
1978
|
+
* get the text value of a node
|
|
1979
|
+
* @name get_text(obj)
|
|
1980
|
+
* @param {mixed} obj the node
|
|
1981
|
+
* @return {String}
|
|
1982
|
+
*/
|
|
1983
|
+
get_text: function(e) {
|
|
1984
|
+
return e = this.get_node(e), !e || e.id === l.jstree.root ? !1 : e.text;
|
|
1985
|
+
},
|
|
1986
|
+
/**
|
|
1987
|
+
* set the text value of a node. Used internally, please use `rename_node(obj, val)`.
|
|
1988
|
+
* @private
|
|
1989
|
+
* @name set_text(obj, val)
|
|
1990
|
+
* @param {mixed} obj the node, you can pass an array to set the text on multiple nodes
|
|
1991
|
+
* @param {String} val the new text value
|
|
1992
|
+
* @return {Boolean}
|
|
1993
|
+
* @trigger set_text.jstree
|
|
1994
|
+
*/
|
|
1995
|
+
set_text: function(e, s) {
|
|
1996
|
+
var t, i;
|
|
1997
|
+
if (l.vakata.is_array(e)) {
|
|
1998
|
+
for (e = e.slice(), t = 0, i = e.length; t < i; t++)
|
|
1999
|
+
this.set_text(e[t], s);
|
|
2000
|
+
return !0;
|
|
2001
|
+
}
|
|
2002
|
+
return e = this.get_node(e), !e || e.id === l.jstree.root ? !1 : (e.text = s, this.get_node(e, !0).length && this.redraw_node(e.id), this.trigger("set_text", { obj: e, text: s }), !0);
|
|
2003
|
+
},
|
|
2004
|
+
/**
|
|
2005
|
+
* gets a JSON representation of a node (or the whole tree)
|
|
2006
|
+
* @name get_json([obj, options])
|
|
2007
|
+
* @param {mixed} obj
|
|
2008
|
+
* @param {Object} options
|
|
2009
|
+
* @param {Boolean} options.no_state do not return state information
|
|
2010
|
+
* @param {Boolean} options.no_id do not return ID
|
|
2011
|
+
* @param {Boolean} options.no_children do not include children
|
|
2012
|
+
* @param {Boolean} options.no_data do not include node data
|
|
2013
|
+
* @param {Boolean} options.no_li_attr do not include LI attributes
|
|
2014
|
+
* @param {Boolean} options.no_a_attr do not include A attributes
|
|
2015
|
+
* @param {Boolean} options.flat return flat JSON instead of nested
|
|
2016
|
+
* @return {Object}
|
|
2017
|
+
*/
|
|
2018
|
+
get_json: function(e, s, t) {
|
|
2019
|
+
if (e = this.get_node(e || l.jstree.root), !e)
|
|
2020
|
+
return !1;
|
|
2021
|
+
s && s.flat && !t && (t = []);
|
|
2022
|
+
var i = {
|
|
2023
|
+
id: e.id,
|
|
2024
|
+
text: e.text,
|
|
2025
|
+
icon: this.get_icon(e),
|
|
2026
|
+
li_attr: l.extend(!0, {}, e.li_attr),
|
|
2027
|
+
a_attr: l.extend(!0, {}, e.a_attr),
|
|
2028
|
+
state: {},
|
|
2029
|
+
data: s && s.no_data ? !1 : l.extend(!0, l.vakata.is_array(e.data) ? [] : {}, e.data)
|
|
2030
|
+
//( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ),
|
|
2031
|
+
}, r, a;
|
|
2032
|
+
if (s && s.flat ? i.parent = e.parent : i.children = [], !s || !s.no_state)
|
|
2033
|
+
for (r in e.state)
|
|
2034
|
+
e.state.hasOwnProperty(r) && (i.state[r] = e.state[r]);
|
|
2035
|
+
else
|
|
2036
|
+
delete i.state;
|
|
2037
|
+
if (s && s.no_li_attr && delete i.li_attr, s && s.no_a_attr && delete i.a_attr, s && s.no_id && (delete i.id, i.li_attr && i.li_attr.id && delete i.li_attr.id, i.a_attr && i.a_attr.id && delete i.a_attr.id), s && s.flat && e.id !== l.jstree.root && t.push(i), !s || !s.no_children)
|
|
2038
|
+
for (r = 0, a = e.children.length; r < a; r++)
|
|
2039
|
+
s && s.flat ? this.get_json(e.children[r], s, t) : i.children.push(this.get_json(e.children[r], s));
|
|
2040
|
+
return s && s.flat ? t : e.id === l.jstree.root ? i.children : i;
|
|
2041
|
+
},
|
|
2042
|
+
/**
|
|
2043
|
+
* create a new node (do not confuse with load_node)
|
|
2044
|
+
* @name create_node([par, node, pos, callback, is_loaded])
|
|
2045
|
+
* @param {mixed} par the parent node (to create a root node use either "#" (string) or `null`)
|
|
2046
|
+
* @param {mixed} node the data for the new node (a valid JSON object, or a simple string with the name)
|
|
2047
|
+
* @param {mixed} pos the index at which to insert the node, "first" and "last" are also supported, default is "last"
|
|
2048
|
+
* @param {Function} callback a function to be called once the node is created
|
|
2049
|
+
* @param {Boolean} is_loaded internal argument indicating if the parent node was succesfully loaded
|
|
2050
|
+
* @return {String} the ID of the newly create node
|
|
2051
|
+
* @trigger model.jstree, create_node.jstree
|
|
2052
|
+
*/
|
|
2053
|
+
create_node: function(e, s, t, i, r) {
|
|
2054
|
+
if (e === null && (e = l.jstree.root), e = this.get_node(e), !e)
|
|
2055
|
+
return !1;
|
|
2056
|
+
if (t = t === y ? "last" : t, !t.toString().match(/^(before|after)$/) && !r && !this.is_loaded(e))
|
|
2057
|
+
return this.load_node(e, function() {
|
|
2058
|
+
this.create_node(e, s, t, i, !0);
|
|
2059
|
+
});
|
|
2060
|
+
s || (s = { text: this.get_string("New node") }), typeof s == "string" ? s = { text: s } : s = l.extend(!0, {}, s), s.text === y && (s.text = this.get_string("New node"));
|
|
2061
|
+
var a, n, c, d;
|
|
2062
|
+
switch (e.id === l.jstree.root && (t === "before" && (t = "first"), t === "after" && (t = "last")), t) {
|
|
2063
|
+
case "before":
|
|
2064
|
+
a = this.get_node(e.parent), t = l.inArray(e.id, a.children), e = a;
|
|
2065
|
+
break;
|
|
2066
|
+
case "after":
|
|
2067
|
+
a = this.get_node(e.parent), t = l.inArray(e.id, a.children) + 1, e = a;
|
|
2068
|
+
break;
|
|
2069
|
+
case "inside":
|
|
2070
|
+
case "first":
|
|
2071
|
+
t = 0;
|
|
2072
|
+
break;
|
|
2073
|
+
case "last":
|
|
2074
|
+
t = e.children.length;
|
|
2075
|
+
break;
|
|
2076
|
+
default:
|
|
2077
|
+
t || (t = 0);
|
|
2078
|
+
break;
|
|
2079
|
+
}
|
|
2080
|
+
if (t > e.children.length && (t = e.children.length), s.id === y && (s.id = !0), !this.check("create_node", s, e, t))
|
|
2081
|
+
return this.settings.core.error.call(this, this._data.core.last_error), !1;
|
|
2082
|
+
if (s.id === !0 && delete s.id, s = this._parse_model_from_json(s, e.id, e.parents.concat()), !s)
|
|
2083
|
+
return !1;
|
|
2084
|
+
for (a = this.get_node(s), n = [], n.push(s), n = n.concat(a.children_d), this.trigger("model", { nodes: n, parent: e.id }), e.children_d = e.children_d.concat(n), c = 0, d = e.parents.length; c < d; c++)
|
|
2085
|
+
this._model.data[e.parents[c]].children_d = this._model.data[e.parents[c]].children_d.concat(n);
|
|
2086
|
+
for (s = a, a = [], c = 0, d = e.children.length; c < d; c++)
|
|
2087
|
+
a[c >= t ? c + 1 : c] = e.children[c];
|
|
2088
|
+
return a[t] = s.id, e.children = a, this.redraw_node(e, !0), this.trigger("create_node", { node: this.get_node(s), parent: e.id, position: t }), i && i.call(this, this.get_node(s)), s.id;
|
|
2089
|
+
},
|
|
2090
|
+
/**
|
|
2091
|
+
* set the text value of a node
|
|
2092
|
+
* @name rename_node(obj, val)
|
|
2093
|
+
* @param {mixed} obj the node, you can pass an array to rename multiple nodes to the same name
|
|
2094
|
+
* @param {String} val the new text value
|
|
2095
|
+
* @return {Boolean}
|
|
2096
|
+
* @trigger rename_node.jstree
|
|
2097
|
+
*/
|
|
2098
|
+
rename_node: function(e, s) {
|
|
2099
|
+
var t, i, r;
|
|
2100
|
+
if (l.vakata.is_array(e)) {
|
|
2101
|
+
for (e = e.slice(), t = 0, i = e.length; t < i; t++)
|
|
2102
|
+
this.rename_node(e[t], s);
|
|
2103
|
+
return !0;
|
|
2104
|
+
}
|
|
2105
|
+
return e = this.get_node(e), !e || e.id === l.jstree.root ? !1 : (r = e.text, this.check("rename_node", e, this.get_parent(e), s) ? (this.set_text(e, s), this.trigger("rename_node", { node: e, text: s, old: r }), !0) : (this.settings.core.error.call(this, this._data.core.last_error), !1));
|
|
2106
|
+
},
|
|
2107
|
+
/**
|
|
2108
|
+
* remove a node
|
|
2109
|
+
* @name delete_node(obj)
|
|
2110
|
+
* @param {mixed} obj the node, you can pass an array to delete multiple nodes
|
|
2111
|
+
* @return {Boolean}
|
|
2112
|
+
* @trigger delete_node.jstree, changed.jstree
|
|
2113
|
+
*/
|
|
2114
|
+
delete_node: function(e) {
|
|
2115
|
+
var s, t, i, r, a, n, c, d, h, o, f, _;
|
|
2116
|
+
if (l.vakata.is_array(e)) {
|
|
2117
|
+
for (e = e.slice(), s = 0, t = e.length; s < t; s++)
|
|
2118
|
+
this.delete_node(e[s]);
|
|
2119
|
+
return !0;
|
|
2120
|
+
}
|
|
2121
|
+
if (e = this.get_node(e), !e || e.id === l.jstree.root)
|
|
2122
|
+
return !1;
|
|
2123
|
+
if (i = this.get_node(e.parent), r = l.inArray(e.id, i.children), o = !1, !this.check("delete_node", e, i, r))
|
|
2124
|
+
return this.settings.core.error.call(this, this._data.core.last_error), !1;
|
|
2125
|
+
for (r !== -1 && (i.children = l.vakata.array_remove(i.children, r)), a = e.children_d.concat([]), a.push(e.id), n = 0, c = e.parents.length; n < c; n++)
|
|
2126
|
+
this._model.data[e.parents[n]].children_d = l.vakata.array_filter(this._model.data[e.parents[n]].children_d, function(u) {
|
|
2127
|
+
return l.inArray(u, a) === -1;
|
|
2128
|
+
});
|
|
2129
|
+
for (d = 0, h = a.length; d < h; d++)
|
|
2130
|
+
if (this._model.data[a[d]].state.selected) {
|
|
2131
|
+
o = !0;
|
|
2132
|
+
break;
|
|
2133
|
+
}
|
|
2134
|
+
for (o && (this._data.core.selected = l.vakata.array_filter(this._data.core.selected, function(u) {
|
|
2135
|
+
return l.inArray(u, a) === -1;
|
|
2136
|
+
})), this.trigger("delete_node", { node: e, parent: i.id }), o && this.trigger("changed", { action: "delete_node", node: e, selected: this._data.core.selected, parent: i.id }), d = 0, h = a.length; d < h; d++)
|
|
2137
|
+
delete this._model.data[a[d]];
|
|
2138
|
+
return l.inArray(this._data.core.focused, a) !== -1 && (this._data.core.focused = null, f = this.element[0].scrollTop, _ = this.element[0].scrollLeft, i.id === l.jstree.root ? this._model.data[l.jstree.root].children[0] && this.get_node(this._model.data[l.jstree.root].children[0], !0).children(".jstree-anchor").trigger("focus") : this.get_node(i, !0).children(".jstree-anchor").trigger("focus"), this.element[0].scrollTop = f, this.element[0].scrollLeft = _), this.redraw_node(i, !0), !0;
|
|
2139
|
+
},
|
|
2140
|
+
/**
|
|
2141
|
+
* check if an operation is premitted on the tree. Used internally.
|
|
2142
|
+
* @private
|
|
2143
|
+
* @name check(chk, obj, par, pos)
|
|
2144
|
+
* @param {String} chk the operation to check, can be "create_node", "rename_node", "delete_node", "copy_node" or "move_node"
|
|
2145
|
+
* @param {mixed} obj the node
|
|
2146
|
+
* @param {mixed} par the parent
|
|
2147
|
+
* @param {mixed} pos the position to insert at, or if "rename_node" - the new name
|
|
2148
|
+
* @param {mixed} more some various additional information, for example if a "move_node" operations is triggered by DND this will be the hovered node
|
|
2149
|
+
* @return {Boolean}
|
|
2150
|
+
*/
|
|
2151
|
+
check: function(e, s, t, i, r) {
|
|
2152
|
+
s = s && s.id ? s : this.get_node(s), t = t && t.id ? t : this.get_node(t);
|
|
2153
|
+
var a = e.match(/^(move_node|copy_node|create_node)$/i) ? t : s, n = this.settings.core.check_callback;
|
|
2154
|
+
if (e === "move_node" || e === "copy_node") {
|
|
2155
|
+
if ((!r || !r.is_multi) && e === "move_node" && l.inArray(s.id, t.children) === i)
|
|
2156
|
+
return this._data.core.last_error = { error: "check", plugin: "core", id: "core_08", reason: "Moving node to its current position", data: JSON.stringify({ chk: e, pos: i, obj: s && s.id ? s.id : !1, par: t && t.id ? t.id : !1 }) }, !1;
|
|
2157
|
+
if ((!r || !r.is_multi) && (s.id === t.id || e === "move_node" && l.inArray(s.id, t.children) === i || l.inArray(t.id, s.children_d) !== -1))
|
|
2158
|
+
return this._data.core.last_error = { error: "check", plugin: "core", id: "core_01", reason: "Moving parent inside child", data: JSON.stringify({ chk: e, pos: i, obj: s && s.id ? s.id : !1, par: t && t.id ? t.id : !1 }) }, !1;
|
|
2159
|
+
}
|
|
2160
|
+
return a && a.data && (a = a.data), a && a.functions && (a.functions[e] === !1 || a.functions[e] === !0) ? (a.functions[e] === !1 && (this._data.core.last_error = { error: "check", plugin: "core", id: "core_02", reason: "Node data prevents function: " + e, data: JSON.stringify({ chk: e, pos: i, obj: s && s.id ? s.id : !1, par: t && t.id ? t.id : !1 }) }), a.functions[e]) : n === !1 || l.vakata.is_function(n) && n.call(this, e, s, t, i, r) === !1 || n && n[e] === !1 ? (this._data.core.last_error = { error: "check", plugin: "core", id: "core_03", reason: "User config for core.check_callback prevents function: " + e, data: JSON.stringify({ chk: e, pos: i, obj: s && s.id ? s.id : !1, par: t && t.id ? t.id : !1 }) }, !1) : !0;
|
|
2161
|
+
},
|
|
2162
|
+
/**
|
|
2163
|
+
* get the last error
|
|
2164
|
+
* @name last_error()
|
|
2165
|
+
* @return {Object}
|
|
2166
|
+
*/
|
|
2167
|
+
last_error: function() {
|
|
2168
|
+
return this._data.core.last_error;
|
|
2169
|
+
},
|
|
2170
|
+
/**
|
|
2171
|
+
* move a node to a new parent
|
|
2172
|
+
* @name move_node(obj, par [, pos, callback, is_loaded])
|
|
2173
|
+
* @param {mixed} obj the node to move, pass an array to move multiple nodes
|
|
2174
|
+
* @param {mixed} par the new parent
|
|
2175
|
+
* @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
|
|
2176
|
+
* @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
|
|
2177
|
+
* @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
|
|
2178
|
+
* @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
|
|
2179
|
+
* @param {Boolean} instance internal parameter indicating if the node comes from another instance
|
|
2180
|
+
* @trigger move_node.jstree
|
|
2181
|
+
*/
|
|
2182
|
+
move_node: function(e, s, t, i, r, a, n) {
|
|
2183
|
+
var c, d, h, o, f, _, u, g, p, m, N, O, x, A;
|
|
2184
|
+
if (s = this.get_node(s), t = t === y ? 0 : t, !s)
|
|
2185
|
+
return !1;
|
|
2186
|
+
if (!t.toString().match(/^(before|after)$/) && !r && !this.is_loaded(s))
|
|
2187
|
+
return this.load_node(s, function() {
|
|
2188
|
+
this.move_node(e, s, t, i, !0, !1, n);
|
|
2189
|
+
});
|
|
2190
|
+
if (l.vakata.is_array(e))
|
|
2191
|
+
if (e.length === 1)
|
|
2192
|
+
e = e[0];
|
|
2193
|
+
else {
|
|
2194
|
+
for (c = 0, d = e.length; c < d; c++)
|
|
2195
|
+
(p = this.move_node(e[c], s, t, i, r, !1, n)) && (s = p, t = "after");
|
|
2196
|
+
return this.redraw(), !0;
|
|
2197
|
+
}
|
|
2198
|
+
if (e = e && e.id !== y ? e : this.get_node(e), !e || e.id === l.jstree.root)
|
|
2199
|
+
return !1;
|
|
2200
|
+
if (h = (e.parent || l.jstree.root).toString(), f = !t.toString().match(/^(before|after)$/) || s.id === l.jstree.root ? s : this.get_node(s.parent), _ = n || (this._model.data[e.id] ? this : l.jstree.reference(e.id)), u = !_ || !_._id || this._id !== _._id, o = _ && _._id && h && _._model.data[h] && _._model.data[h].children ? l.inArray(e.id, _._model.data[h].children) : -1, _ && _._id && (e = _._model.data[e.id]), u)
|
|
2201
|
+
return (p = this.copy_node(e, s, t, i, r, !1, n)) ? (_ && _.delete_node(e), p) : !1;
|
|
2202
|
+
switch (s.id === l.jstree.root && (t === "before" && (t = "first"), t === "after" && (t = "last")), t) {
|
|
2203
|
+
case "before":
|
|
2204
|
+
t = l.inArray(s.id, f.children);
|
|
2205
|
+
break;
|
|
2206
|
+
case "after":
|
|
2207
|
+
t = l.inArray(s.id, f.children) + 1;
|
|
2208
|
+
break;
|
|
2209
|
+
case "inside":
|
|
2210
|
+
case "first":
|
|
2211
|
+
t = 0;
|
|
2212
|
+
break;
|
|
2213
|
+
case "last":
|
|
2214
|
+
t = f.children.length;
|
|
2215
|
+
break;
|
|
2216
|
+
default:
|
|
2217
|
+
t || (t = 0);
|
|
2218
|
+
break;
|
|
2219
|
+
}
|
|
2220
|
+
if (t > f.children.length && (t = f.children.length), !this.check("move_node", e, f, t, { core: !0, origin: n, is_multi: _ && _._id && _._id !== this._id, is_foreign: !_ || !_._id }))
|
|
2221
|
+
return this.settings.core.error.call(this, this._data.core.last_error), !1;
|
|
2222
|
+
if (e.parent === f.id) {
|
|
2223
|
+
for (g = f.children.concat(), p = l.inArray(e.id, g), p !== -1 && (g = l.vakata.array_remove(g, p), t > p && t--), p = [], m = 0, N = g.length; m < N; m++)
|
|
2224
|
+
p[m >= t ? m + 1 : m] = g[m];
|
|
2225
|
+
p[t] = e.id, f.children = p, this._node_changed(f.id), this.redraw(f.id === l.jstree.root);
|
|
2226
|
+
} else {
|
|
2227
|
+
for (p = e.children_d.concat(), p.push(e.id), m = 0, N = e.parents.length; m < N; m++) {
|
|
2228
|
+
for (g = [], A = _._model.data[e.parents[m]].children_d, O = 0, x = A.length; O < x; O++)
|
|
2229
|
+
l.inArray(A[O], p) === -1 && g.push(A[O]);
|
|
2230
|
+
_._model.data[e.parents[m]].children_d = g;
|
|
2231
|
+
}
|
|
2232
|
+
for (_._model.data[h].children = l.vakata.array_remove_item(_._model.data[h].children, e.id), m = 0, N = f.parents.length; m < N; m++)
|
|
2233
|
+
this._model.data[f.parents[m]].children_d = this._model.data[f.parents[m]].children_d.concat(p);
|
|
2234
|
+
for (g = [], m = 0, N = f.children.length; m < N; m++)
|
|
2235
|
+
g[m >= t ? m + 1 : m] = f.children[m];
|
|
2236
|
+
for (g[t] = e.id, f.children = g, f.children_d.push(e.id), f.children_d = f.children_d.concat(e.children_d), e.parent = f.id, p = f.parents.concat(), p.unshift(f.id), A = e.parents.length, e.parents = p, p = p.concat(), m = 0, N = e.children_d.length; m < N; m++)
|
|
2237
|
+
this._model.data[e.children_d[m]].parents = this._model.data[e.children_d[m]].parents.slice(0, A * -1), Array.prototype.push.apply(this._model.data[e.children_d[m]].parents, p);
|
|
2238
|
+
(h === l.jstree.root || f.id === l.jstree.root) && (this._model.force_full_redraw = !0), this._model.force_full_redraw || (this._node_changed(h), this._node_changed(f.id)), a || this.redraw();
|
|
2239
|
+
}
|
|
2240
|
+
return i && i.call(this, e, f, t), this.trigger("move_node", { node: e, parent: f.id, position: t, old_parent: h, old_position: o, is_multi: _ && _._id && _._id !== this._id, is_foreign: !_ || !_._id, old_instance: _, new_instance: this }), e.id;
|
|
2241
|
+
},
|
|
2242
|
+
/**
|
|
2243
|
+
* copy a node to a new parent
|
|
2244
|
+
* @name copy_node(obj, par [, pos, callback, is_loaded])
|
|
2245
|
+
* @param {mixed} obj the node to copy, pass an array to copy multiple nodes
|
|
2246
|
+
* @param {mixed} par the new parent
|
|
2247
|
+
* @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
|
|
2248
|
+
* @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
|
|
2249
|
+
* @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
|
|
2250
|
+
* @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
|
|
2251
|
+
* @param {Boolean} instance internal parameter indicating if the node comes from another instance
|
|
2252
|
+
* @trigger model.jstree copy_node.jstree
|
|
2253
|
+
*/
|
|
2254
|
+
copy_node: function(e, s, t, i, r, a, n) {
|
|
2255
|
+
var c, d, h, o, f, _, u, g, p, m;
|
|
2256
|
+
if (s = this.get_node(s), t = t === y ? 0 : t, !s)
|
|
2257
|
+
return !1;
|
|
2258
|
+
if (!t.toString().match(/^(before|after)$/) && !r && !this.is_loaded(s))
|
|
2259
|
+
return this.load_node(s, function() {
|
|
2260
|
+
this.copy_node(e, s, t, i, !0, !1, n);
|
|
2261
|
+
});
|
|
2262
|
+
if (l.vakata.is_array(e))
|
|
2263
|
+
if (e.length === 1)
|
|
2264
|
+
e = e[0];
|
|
2265
|
+
else {
|
|
2266
|
+
for (c = 0, d = e.length; c < d; c++)
|
|
2267
|
+
(o = this.copy_node(e[c], s, t, i, r, !0, n)) && (s = o, t = "after");
|
|
2268
|
+
return this.redraw(), !0;
|
|
2269
|
+
}
|
|
2270
|
+
if (e = e && e.id !== y ? e : this.get_node(e), !e || e.id === l.jstree.root)
|
|
2271
|
+
return !1;
|
|
2272
|
+
switch (g = (e.parent || l.jstree.root).toString(), p = !t.toString().match(/^(before|after)$/) || s.id === l.jstree.root ? s : this.get_node(s.parent), m = n || (this._model.data[e.id] ? this : l.jstree.reference(e.id)), !m || !m._id || (this._id, m._id), m && m._id && (e = m._model.data[e.id]), s.id === l.jstree.root && (t === "before" && (t = "first"), t === "after" && (t = "last")), t) {
|
|
2273
|
+
case "before":
|
|
2274
|
+
t = l.inArray(s.id, p.children);
|
|
2275
|
+
break;
|
|
2276
|
+
case "after":
|
|
2277
|
+
t = l.inArray(s.id, p.children) + 1;
|
|
2278
|
+
break;
|
|
2279
|
+
case "inside":
|
|
2280
|
+
case "first":
|
|
2281
|
+
t = 0;
|
|
2282
|
+
break;
|
|
2283
|
+
case "last":
|
|
2284
|
+
t = p.children.length;
|
|
2285
|
+
break;
|
|
2286
|
+
default:
|
|
2287
|
+
t || (t = 0);
|
|
2288
|
+
break;
|
|
2289
|
+
}
|
|
2290
|
+
if (t > p.children.length && (t = p.children.length), !this.check("copy_node", e, p, t, { core: !0, origin: n, is_multi: m && m._id && m._id !== this._id, is_foreign: !m || !m._id }))
|
|
2291
|
+
return this.settings.core.error.call(this, this._data.core.last_error), !1;
|
|
2292
|
+
if (u = m ? m.get_json(e, { no_id: !0, no_data: !0, no_state: !0 }) : e, !u || (u.id === !0 && delete u.id, u = this._parse_model_from_json(u, p.id, p.parents.concat()), !u))
|
|
2293
|
+
return !1;
|
|
2294
|
+
for (o = this.get_node(u), e && e.state && e.state.loaded === !1 && (o.state.loaded = !1), h = [], h.push(u), h = h.concat(o.children_d), this.trigger("model", { nodes: h, parent: p.id }), f = 0, _ = p.parents.length; f < _; f++)
|
|
2295
|
+
this._model.data[p.parents[f]].children_d = this._model.data[p.parents[f]].children_d.concat(h);
|
|
2296
|
+
for (h = [], f = 0, _ = p.children.length; f < _; f++)
|
|
2297
|
+
h[f >= t ? f + 1 : f] = p.children[f];
|
|
2298
|
+
return h[t] = o.id, p.children = h, p.children_d.push(o.id), p.children_d = p.children_d.concat(o.children_d), p.id === l.jstree.root && (this._model.force_full_redraw = !0), this._model.force_full_redraw || this._node_changed(p.id), a || this.redraw(p.id === l.jstree.root), i && i.call(this, o, p, t), this.trigger("copy_node", { node: o, original: e, parent: p.id, position: t, old_parent: g, old_position: m && m._id && g && m._model.data[g] && m._model.data[g].children ? l.inArray(e.id, m._model.data[g].children) : -1, is_multi: m && m._id && m._id !== this._id, is_foreign: !m || !m._id, old_instance: m, new_instance: this }), o.id;
|
|
2299
|
+
},
|
|
2300
|
+
/**
|
|
2301
|
+
* cut a node (a later call to `paste(obj)` would move the node)
|
|
2302
|
+
* @name cut(obj)
|
|
2303
|
+
* @param {mixed} obj multiple objects can be passed using an array
|
|
2304
|
+
* @trigger cut.jstree
|
|
2305
|
+
*/
|
|
2306
|
+
cut: function(e) {
|
|
2307
|
+
if (e || (e = this._data.core.selected.concat()), l.vakata.is_array(e) || (e = [e]), !e.length)
|
|
2308
|
+
return !1;
|
|
2309
|
+
var s = [], t, i, r;
|
|
2310
|
+
for (i = 0, r = e.length; i < r; i++)
|
|
2311
|
+
t = this.get_node(e[i]), t && (t.id || t.id === 0) && t.id !== l.jstree.root && s.push(t);
|
|
2312
|
+
if (!s.length)
|
|
2313
|
+
return !1;
|
|
2314
|
+
D = s, X = this, q = "move_node", this.trigger("cut", { node: e });
|
|
2315
|
+
},
|
|
2316
|
+
/**
|
|
2317
|
+
* copy a node (a later call to `paste(obj)` would copy the node)
|
|
2318
|
+
* @name copy(obj)
|
|
2319
|
+
* @param {mixed} obj multiple objects can be passed using an array
|
|
2320
|
+
* @trigger copy.jstree
|
|
2321
|
+
*/
|
|
2322
|
+
copy: function(e) {
|
|
2323
|
+
if (e || (e = this._data.core.selected.concat()), l.vakata.is_array(e) || (e = [e]), !e.length)
|
|
2324
|
+
return !1;
|
|
2325
|
+
var s = [], t, i, r;
|
|
2326
|
+
for (i = 0, r = e.length; i < r; i++)
|
|
2327
|
+
t = this.get_node(e[i]), t && t.id !== y && t.id !== l.jstree.root && s.push(t);
|
|
2328
|
+
if (!s.length)
|
|
2329
|
+
return !1;
|
|
2330
|
+
D = s, X = this, q = "copy_node", this.trigger("copy", { node: e });
|
|
2331
|
+
},
|
|
2332
|
+
/**
|
|
2333
|
+
* get the current buffer (any nodes that are waiting for a paste operation)
|
|
2334
|
+
* @name get_buffer()
|
|
2335
|
+
* @return {Object} an object consisting of `mode` ("copy_node" or "move_node"), `node` (an array of objects) and `inst` (the instance)
|
|
2336
|
+
*/
|
|
2337
|
+
get_buffer: function() {
|
|
2338
|
+
return { mode: q, node: D, inst: X };
|
|
2339
|
+
},
|
|
2340
|
+
/**
|
|
2341
|
+
* check if there is something in the buffer to paste
|
|
2342
|
+
* @name can_paste()
|
|
2343
|
+
* @return {Boolean}
|
|
2344
|
+
*/
|
|
2345
|
+
can_paste: function() {
|
|
2346
|
+
return q !== !1 && D !== !1;
|
|
2347
|
+
},
|
|
2348
|
+
/**
|
|
2349
|
+
* copy or move the previously cut or copied nodes to a new parent
|
|
2350
|
+
* @name paste(obj [, pos])
|
|
2351
|
+
* @param {mixed} obj the new parent
|
|
2352
|
+
* @param {mixed} pos the position to insert at (besides integer, "first" and "last" are supported), defaults to integer `0`
|
|
2353
|
+
* @trigger paste.jstree
|
|
2354
|
+
*/
|
|
2355
|
+
paste: function(e, s) {
|
|
2356
|
+
if (e = this.get_node(e), !e || !q || !q.match(/^(copy_node|move_node)$/) || !D)
|
|
2357
|
+
return !1;
|
|
2358
|
+
this[q](D, e, s, !1, !1, !1, X) && this.trigger("paste", { parent: e.id, node: D, mode: q }), D = !1, q = !1, X = !1;
|
|
2359
|
+
},
|
|
2360
|
+
/**
|
|
2361
|
+
* clear the buffer of previously copied or cut nodes
|
|
2362
|
+
* @name clear_buffer()
|
|
2363
|
+
* @trigger clear_buffer.jstree
|
|
2364
|
+
*/
|
|
2365
|
+
clear_buffer: function() {
|
|
2366
|
+
D = !1, q = !1, X = !1, this.trigger("clear_buffer");
|
|
2367
|
+
},
|
|
2368
|
+
/**
|
|
2369
|
+
* put a node in edit mode (input field to rename the node)
|
|
2370
|
+
* @name edit(obj [, default_text, callback])
|
|
2371
|
+
* @param {mixed} obj
|
|
2372
|
+
* @param {String} default_text the text to populate the input with (if omitted or set to a non-string value the node's text value is used)
|
|
2373
|
+
* @param {Function} callback a function to be called once the text box is blurred, it is called in the instance's scope and receives the node, a status parameter (true if the rename is successful, false otherwise), a boolean indicating if the user cancelled the edit and the original unescaped value provided by the user. You can also access the node's title using .text
|
|
2374
|
+
*/
|
|
2375
|
+
edit: function(e, s, t) {
|
|
2376
|
+
var i, r, a, n, c, d, h, o, f, _ = !1;
|
|
2377
|
+
if (e = this.get_node(e), !e)
|
|
2378
|
+
return !1;
|
|
2379
|
+
if (!this.check("edit", e, this.get_parent(e)))
|
|
2380
|
+
return this.settings.core.error.call(this, this._data.core.last_error), !1;
|
|
2381
|
+
f = e, s = typeof s == "string" ? s : e.text, this.set_text(e, ""), e = this._open_to(e), f.text = s, i = this._data.core.rtl, r = this.element.width(), this._data.core.focused = f.id, a = e.children(".jstree-anchor").trigger("focus"), n = l("<span></span>");
|
|
2382
|
+
/*!
|
|
2383
|
+
oi = obj.children("i:visible"),
|
|
2384
|
+
ai = a.children("i:visible"),
|
|
2385
|
+
w1 = oi.width() * oi.length,
|
|
2386
|
+
w2 = ai.width() * ai.length,
|
|
2387
|
+
*/
|
|
2388
|
+
c = s, d = l("<div></div>", { css: { position: "absolute", top: "-200px", left: i ? "0px" : "-1000px", visibility: "hidden" } }).appendTo(T.body), h = l("<input />", {
|
|
2389
|
+
value: c,
|
|
2390
|
+
class: "jstree-rename-input",
|
|
2391
|
+
// "size" : t.length,
|
|
2392
|
+
css: {
|
|
2393
|
+
padding: "0",
|
|
2394
|
+
border: "1px solid silver",
|
|
2395
|
+
"box-sizing": "border-box",
|
|
2396
|
+
display: "inline-block",
|
|
2397
|
+
height: this._data.core.li_height + "px",
|
|
2398
|
+
lineHeight: this._data.core.li_height + "px",
|
|
2399
|
+
width: "150px"
|
|
2400
|
+
// will be set a bit further down
|
|
2401
|
+
},
|
|
2402
|
+
on: {
|
|
2403
|
+
blur: (function(u) {
|
|
2404
|
+
u.stopImmediatePropagation(), u.preventDefault();
|
|
2405
|
+
var g = n.children(".jstree-rename-input"), p = g.val(), m = this.settings.core.force_text, N;
|
|
2406
|
+
p === "" && (p = c), d.remove(), n.replaceWith(a), n.remove(), c = m ? c : l("<div></div>").append(l.parseHTML(c)).html(), e = this.get_node(e), this.set_text(e, c), N = !!this.rename_node(e, m ? l("<div></div>").text(p).text() : l("<div></div>").append(l.parseHTML(p)).html()), N || this.set_text(e, c), this._data.core.focused = f.id, setTimeout((function() {
|
|
2407
|
+
var O = this.get_node(f.id, !0);
|
|
2408
|
+
O.length && (this._data.core.focused = f.id, O.children(".jstree-anchor").trigger("focus"));
|
|
2409
|
+
}).bind(this), 0), t && t.call(this, f, N, _, p), h = null;
|
|
2410
|
+
}).bind(this),
|
|
2411
|
+
keydown: function(u) {
|
|
2412
|
+
var g = u.which;
|
|
2413
|
+
g === 27 && (_ = !0, this.value = c), (g === 27 || g === 13 || g === 37 || g === 38 || g === 39 || g === 40 || g === 32) && u.stopImmediatePropagation(), (g === 27 || g === 13) && (u.preventDefault(), this.blur());
|
|
2414
|
+
},
|
|
2415
|
+
click: function(u) {
|
|
2416
|
+
u.stopImmediatePropagation();
|
|
2417
|
+
},
|
|
2418
|
+
mousedown: function(u) {
|
|
2419
|
+
u.stopImmediatePropagation();
|
|
2420
|
+
},
|
|
2421
|
+
keyup: function(u) {
|
|
2422
|
+
h.width(Math.min(d.text("pW" + this.value).width(), r));
|
|
2423
|
+
},
|
|
2424
|
+
keypress: function(u) {
|
|
2425
|
+
if (u.which === 13)
|
|
2426
|
+
return !1;
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
}), o = {
|
|
2430
|
+
fontFamily: a.css("fontFamily") || "",
|
|
2431
|
+
fontSize: a.css("fontSize") || "",
|
|
2432
|
+
fontWeight: a.css("fontWeight") || "",
|
|
2433
|
+
fontStyle: a.css("fontStyle") || "",
|
|
2434
|
+
fontStretch: a.css("fontStretch") || "",
|
|
2435
|
+
fontVariant: a.css("fontVariant") || "",
|
|
2436
|
+
letterSpacing: a.css("letterSpacing") || "",
|
|
2437
|
+
wordSpacing: a.css("wordSpacing") || ""
|
|
2438
|
+
}, n.attr("class", a.attr("class")).append(a.contents().clone()).append(h), a.replaceWith(n), d.css(o), h.css(o).width(Math.min(d.text("pW" + h[0].value).width(), r))[0].select(), l(T).one("mousedown.jstree touchstart.jstree dnd_start.vakata", function(u) {
|
|
2439
|
+
h && u.target !== h && l(h).trigger("blur");
|
|
2440
|
+
});
|
|
2441
|
+
},
|
|
2442
|
+
/**
|
|
2443
|
+
* changes the theme
|
|
2444
|
+
* @name set_theme(theme_name [, theme_url])
|
|
2445
|
+
* @param {String} theme_name the name of the new theme to apply
|
|
2446
|
+
* @param {mixed} theme_url the location of the CSS file for this theme. Omit or set to `false` if you manually included the file. Set to `true` to autoload from the `core.themes.dir` directory.
|
|
2447
|
+
* @trigger set_theme.jstree
|
|
2448
|
+
*/
|
|
2449
|
+
set_theme: function(e, s) {
|
|
2450
|
+
if (!e)
|
|
2451
|
+
return !1;
|
|
2452
|
+
if (s === !0) {
|
|
2453
|
+
var t = this.settings.core.themes.dir;
|
|
2454
|
+
t || (t = l.jstree.path + "/themes"), s = t + "/" + e + "/style.css";
|
|
2455
|
+
}
|
|
2456
|
+
s && l.inArray(s, Z) === -1 && (l("head").append('<link rel="stylesheet" href="' + s + '" type="text/css" />'), Z.push(s)), this._data.core.themes.name && this.element.removeClass("jstree-" + this._data.core.themes.name), this._data.core.themes.name = e, this.element.addClass("jstree-" + e), this.element[this.settings.core.themes.responsive ? "addClass" : "removeClass"]("jstree-" + e + "-responsive"), this.trigger("set_theme", { theme: e });
|
|
2457
|
+
},
|
|
2458
|
+
/**
|
|
2459
|
+
* gets the name of the currently applied theme name
|
|
2460
|
+
* @name get_theme()
|
|
2461
|
+
* @return {String}
|
|
2462
|
+
*/
|
|
2463
|
+
get_theme: function() {
|
|
2464
|
+
return this._data.core.themes.name;
|
|
2465
|
+
},
|
|
2466
|
+
/**
|
|
2467
|
+
* changes the theme variant (if the theme has variants)
|
|
2468
|
+
* @name set_theme_variant(variant_name)
|
|
2469
|
+
* @param {String|Boolean} variant_name the variant to apply (if `false` is used the current variant is removed)
|
|
2470
|
+
*/
|
|
2471
|
+
set_theme_variant: function(e) {
|
|
2472
|
+
this._data.core.themes.variant && this.element.removeClass("jstree-" + this._data.core.themes.name + "-" + this._data.core.themes.variant), this._data.core.themes.variant = e, e && this.element.addClass("jstree-" + this._data.core.themes.name + "-" + this._data.core.themes.variant);
|
|
2473
|
+
},
|
|
2474
|
+
/**
|
|
2475
|
+
* gets the name of the currently applied theme variant
|
|
2476
|
+
* @name get_theme()
|
|
2477
|
+
* @return {String}
|
|
2478
|
+
*/
|
|
2479
|
+
get_theme_variant: function() {
|
|
2480
|
+
return this._data.core.themes.variant;
|
|
2481
|
+
},
|
|
2482
|
+
/**
|
|
2483
|
+
* shows a striped background on the container (if the theme supports it)
|
|
2484
|
+
* @name show_stripes()
|
|
2485
|
+
*/
|
|
2486
|
+
show_stripes: function() {
|
|
2487
|
+
this._data.core.themes.stripes = !0, this.get_container_ul().addClass("jstree-striped"), this.trigger("show_stripes");
|
|
2488
|
+
},
|
|
2489
|
+
/**
|
|
2490
|
+
* hides the striped background on the container
|
|
2491
|
+
* @name hide_stripes()
|
|
2492
|
+
*/
|
|
2493
|
+
hide_stripes: function() {
|
|
2494
|
+
this._data.core.themes.stripes = !1, this.get_container_ul().removeClass("jstree-striped"), this.trigger("hide_stripes");
|
|
2495
|
+
},
|
|
2496
|
+
/**
|
|
2497
|
+
* toggles the striped background on the container
|
|
2498
|
+
* @name toggle_stripes()
|
|
2499
|
+
*/
|
|
2500
|
+
toggle_stripes: function() {
|
|
2501
|
+
this._data.core.themes.stripes ? this.hide_stripes() : this.show_stripes();
|
|
2502
|
+
},
|
|
2503
|
+
/**
|
|
2504
|
+
* shows the connecting dots (if the theme supports it)
|
|
2505
|
+
* @name show_dots()
|
|
2506
|
+
*/
|
|
2507
|
+
show_dots: function() {
|
|
2508
|
+
this._data.core.themes.dots = !0, this.get_container_ul().removeClass("jstree-no-dots"), this.trigger("show_dots");
|
|
2509
|
+
},
|
|
2510
|
+
/**
|
|
2511
|
+
* hides the connecting dots
|
|
2512
|
+
* @name hide_dots()
|
|
2513
|
+
*/
|
|
2514
|
+
hide_dots: function() {
|
|
2515
|
+
this._data.core.themes.dots = !1, this.get_container_ul().addClass("jstree-no-dots"), this.trigger("hide_dots");
|
|
2516
|
+
},
|
|
2517
|
+
/**
|
|
2518
|
+
* toggles the connecting dots
|
|
2519
|
+
* @name toggle_dots()
|
|
2520
|
+
*/
|
|
2521
|
+
toggle_dots: function() {
|
|
2522
|
+
this._data.core.themes.dots ? this.hide_dots() : this.show_dots();
|
|
2523
|
+
},
|
|
2524
|
+
/**
|
|
2525
|
+
* show the node icons
|
|
2526
|
+
* @name show_icons()
|
|
2527
|
+
*/
|
|
2528
|
+
show_icons: function() {
|
|
2529
|
+
this._data.core.themes.icons = !0, this.get_container_ul().removeClass("jstree-no-icons"), this.trigger("show_icons");
|
|
2530
|
+
},
|
|
2531
|
+
/**
|
|
2532
|
+
* hide the node icons
|
|
2533
|
+
* @name hide_icons()
|
|
2534
|
+
*/
|
|
2535
|
+
hide_icons: function() {
|
|
2536
|
+
this._data.core.themes.icons = !1, this.get_container_ul().addClass("jstree-no-icons"), this.trigger("hide_icons");
|
|
2537
|
+
},
|
|
2538
|
+
/**
|
|
2539
|
+
* toggle the node icons
|
|
2540
|
+
* @name toggle_icons()
|
|
2541
|
+
*/
|
|
2542
|
+
toggle_icons: function() {
|
|
2543
|
+
this._data.core.themes.icons ? this.hide_icons() : this.show_icons();
|
|
2544
|
+
},
|
|
2545
|
+
/**
|
|
2546
|
+
* show the node ellipsis
|
|
2547
|
+
* @name show_icons()
|
|
2548
|
+
*/
|
|
2549
|
+
show_ellipsis: function() {
|
|
2550
|
+
this._data.core.themes.ellipsis = !0, this.get_container_ul().addClass("jstree-ellipsis"), this.trigger("show_ellipsis");
|
|
2551
|
+
},
|
|
2552
|
+
/**
|
|
2553
|
+
* hide the node ellipsis
|
|
2554
|
+
* @name hide_ellipsis()
|
|
2555
|
+
*/
|
|
2556
|
+
hide_ellipsis: function() {
|
|
2557
|
+
this._data.core.themes.ellipsis = !1, this.get_container_ul().removeClass("jstree-ellipsis"), this.trigger("hide_ellipsis");
|
|
2558
|
+
},
|
|
2559
|
+
/**
|
|
2560
|
+
* toggle the node ellipsis
|
|
2561
|
+
* @name toggle_icons()
|
|
2562
|
+
*/
|
|
2563
|
+
toggle_ellipsis: function() {
|
|
2564
|
+
this._data.core.themes.ellipsis ? this.hide_ellipsis() : this.show_ellipsis();
|
|
2565
|
+
},
|
|
2566
|
+
/**
|
|
2567
|
+
* set the node icon for a node
|
|
2568
|
+
* @name set_icon(obj, icon)
|
|
2569
|
+
* @param {mixed} obj
|
|
2570
|
+
* @param {String} icon the new icon - can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class
|
|
2571
|
+
*/
|
|
2572
|
+
set_icon: function(e, s) {
|
|
2573
|
+
var t, i, r, a;
|
|
2574
|
+
if (l.vakata.is_array(e)) {
|
|
2575
|
+
for (e = e.slice(), t = 0, i = e.length; t < i; t++)
|
|
2576
|
+
this.set_icon(e[t], s);
|
|
2577
|
+
return !0;
|
|
2578
|
+
}
|
|
2579
|
+
return e = this.get_node(e), !e || e.id === l.jstree.root ? !1 : (a = e.icon, e.icon = s === !0 || s === null || s === y || s === "" ? !0 : s, r = this.get_node(e, !0).children(".jstree-anchor").children(".jstree-themeicon"), s === !1 ? (r.removeClass("jstree-themeicon-custom " + a).css("background", "").removeAttr("rel"), this.hide_icon(e)) : s === !0 || s === null || s === y || s === "" ? (r.removeClass("jstree-themeicon-custom " + a).css("background", "").removeAttr("rel"), a === !1 && this.show_icon(e)) : s.indexOf("/") === -1 && s.indexOf(".") === -1 ? (r.removeClass(a).css("background", ""), r.addClass(s + " jstree-themeicon-custom").attr("rel", s), a === !1 && this.show_icon(e)) : (r.removeClass(a).css("background", ""), r.addClass("jstree-themeicon-custom").css("background", "url('" + s + "') center center no-repeat").attr("rel", s), a === !1 && this.show_icon(e)), !0);
|
|
2580
|
+
},
|
|
2581
|
+
/**
|
|
2582
|
+
* get the node icon for a node
|
|
2583
|
+
* @name get_icon(obj)
|
|
2584
|
+
* @param {mixed} obj
|
|
2585
|
+
* @return {String}
|
|
2586
|
+
*/
|
|
2587
|
+
get_icon: function(e) {
|
|
2588
|
+
return e = this.get_node(e), !e || e.id === l.jstree.root ? !1 : e.icon;
|
|
2589
|
+
},
|
|
2590
|
+
/**
|
|
2591
|
+
* hide the icon on an individual node
|
|
2592
|
+
* @name hide_icon(obj)
|
|
2593
|
+
* @param {mixed} obj
|
|
2594
|
+
*/
|
|
2595
|
+
hide_icon: function(e) {
|
|
2596
|
+
var s, t;
|
|
2597
|
+
if (l.vakata.is_array(e)) {
|
|
2598
|
+
for (e = e.slice(), s = 0, t = e.length; s < t; s++)
|
|
2599
|
+
this.hide_icon(e[s]);
|
|
2600
|
+
return !0;
|
|
2601
|
+
}
|
|
2602
|
+
return e = this.get_node(e), !e || e === l.jstree.root ? !1 : (e.icon = !1, this.get_node(e, !0).children(".jstree-anchor").children(".jstree-themeicon").addClass("jstree-themeicon-hidden"), !0);
|
|
2603
|
+
},
|
|
2604
|
+
/**
|
|
2605
|
+
* show the icon on an individual node
|
|
2606
|
+
* @name show_icon(obj)
|
|
2607
|
+
* @param {mixed} obj
|
|
2608
|
+
*/
|
|
2609
|
+
show_icon: function(e) {
|
|
2610
|
+
var s, t, i;
|
|
2611
|
+
if (l.vakata.is_array(e)) {
|
|
2612
|
+
for (e = e.slice(), s = 0, t = e.length; s < t; s++)
|
|
2613
|
+
this.show_icon(e[s]);
|
|
2614
|
+
return !0;
|
|
2615
|
+
}
|
|
2616
|
+
return e = this.get_node(e), !e || e === l.jstree.root ? !1 : (i = this.get_node(e, !0), e.icon = i.length ? i.children(".jstree-anchor").children(".jstree-themeicon").attr("rel") : !0, e.icon || (e.icon = !0), i.children(".jstree-anchor").children(".jstree-themeicon").removeClass("jstree-themeicon-hidden"), !0);
|
|
2617
|
+
}
|
|
2618
|
+
}, l.vakata = {}, l.vakata.attributes = function(e, s) {
|
|
2619
|
+
e = l(e)[0];
|
|
2620
|
+
var t = s ? {} : [];
|
|
2621
|
+
return e && e.attributes && l.each(e.attributes, function(i, r) {
|
|
2622
|
+
l.inArray(r.name.toLowerCase(), ["style", "contenteditable", "hasfocus", "tabindex"]) === -1 && r.value !== null && l.vakata.trim(r.value) !== "" && (s ? t[r.name] = r.value : t.push(r.name));
|
|
2623
|
+
}), t;
|
|
2624
|
+
}, l.vakata.array_unique = function(e) {
|
|
2625
|
+
var s = [], t, i, r = {};
|
|
2626
|
+
for (t = 0, i = e.length; t < i; t++)
|
|
2627
|
+
r[e[t]] === y && (s.push(e[t]), r[e[t]] = !0);
|
|
2628
|
+
return s;
|
|
2629
|
+
}, l.vakata.array_remove = function(e, s) {
|
|
2630
|
+
return e.splice(s, 1), e;
|
|
2631
|
+
}, l.vakata.array_remove_item = function(e, s) {
|
|
2632
|
+
var t = l.inArray(s, e);
|
|
2633
|
+
return t !== -1 ? l.vakata.array_remove(e, t) : e;
|
|
2634
|
+
}, l.vakata.array_filter = function(e, s, t, i, r) {
|
|
2635
|
+
if (e.filter)
|
|
2636
|
+
return e.filter(s, t);
|
|
2637
|
+
i = [];
|
|
2638
|
+
for (r in e)
|
|
2639
|
+
~~r + "" == r + "" && r >= 0 && s.call(t, e[r], +r, e) && i.push(e[r]);
|
|
2640
|
+
return i;
|
|
2641
|
+
}, l.vakata.trim = function(e) {
|
|
2642
|
+
return String.prototype.trim ? String.prototype.trim.call(e.toString()) : e.toString().replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
2643
|
+
}, l.vakata.is_function = function(e) {
|
|
2644
|
+
return typeof e == "function" && typeof e.nodeType != "number";
|
|
2645
|
+
}, l.vakata.is_array = Array.isArray || function(e) {
|
|
2646
|
+
return Object.prototype.toString.call(e) === "[object Array]";
|
|
2647
|
+
}, Function.prototype.bind || (Function.prototype.bind = function() {
|
|
2648
|
+
var e = this, s = arguments[0], t = Array.prototype.slice.call(arguments, 1);
|
|
2649
|
+
if (typeof e != "function")
|
|
2650
|
+
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
|
2651
|
+
return function() {
|
|
2652
|
+
var i = t.concat(Array.prototype.slice.call(arguments));
|
|
2653
|
+
return e.apply(s, i);
|
|
2654
|
+
};
|
|
2655
|
+
}), l.jstree.plugins.changed = function(e, s) {
|
|
2656
|
+
var t = [];
|
|
2657
|
+
this.trigger = function(i, r) {
|
|
2658
|
+
var a, n;
|
|
2659
|
+
if (r || (r = {}), i.replace(".jstree", "") === "changed") {
|
|
2660
|
+
r.changed = { selected: [], deselected: [] };
|
|
2661
|
+
var c = {};
|
|
2662
|
+
for (a = 0, n = t.length; a < n; a++)
|
|
2663
|
+
c[t[a]] = 1;
|
|
2664
|
+
for (a = 0, n = r.selected.length; a < n; a++)
|
|
2665
|
+
c[r.selected[a]] ? c[r.selected[a]] = 2 : r.changed.selected.push(r.selected[a]);
|
|
2666
|
+
for (a = 0, n = t.length; a < n; a++)
|
|
2667
|
+
c[t[a]] === 1 && r.changed.deselected.push(t[a]);
|
|
2668
|
+
t = r.selected.slice();
|
|
2669
|
+
}
|
|
2670
|
+
s.trigger.call(this, i, r);
|
|
2671
|
+
}, this.refresh = function(i, r) {
|
|
2672
|
+
return t = [], s.refresh.apply(this, arguments);
|
|
2673
|
+
};
|
|
2674
|
+
};
|
|
2675
|
+
var V = T.createElement("I");
|
|
2676
|
+
V.className = "jstree-icon jstree-checkbox", V.setAttribute("role", "presentation"), l.jstree.defaults.checkbox = {
|
|
2677
|
+
/**
|
|
2678
|
+
* a boolean indicating if checkboxes should be visible (can be changed at a later time using `show_checkboxes()` and `hide_checkboxes`). Defaults to `true`.
|
|
2679
|
+
* @name $.jstree.defaults.checkbox.visible
|
|
2680
|
+
* @plugin checkbox
|
|
2681
|
+
*/
|
|
2682
|
+
visible: !0,
|
|
2683
|
+
/**
|
|
2684
|
+
* a boolean indicating if checkboxes should cascade down and have an undetermined state. Defaults to `true`.
|
|
2685
|
+
* @name $.jstree.defaults.checkbox.three_state
|
|
2686
|
+
* @plugin checkbox
|
|
2687
|
+
*/
|
|
2688
|
+
three_state: !0,
|
|
2689
|
+
/**
|
|
2690
|
+
* a boolean indicating if clicking anywhere on the node should act as clicking on the checkbox. Defaults to `true`.
|
|
2691
|
+
* @name $.jstree.defaults.checkbox.whole_node
|
|
2692
|
+
* @plugin checkbox
|
|
2693
|
+
*/
|
|
2694
|
+
whole_node: !0,
|
|
2695
|
+
/**
|
|
2696
|
+
* a boolean indicating if the selected style of a node should be kept, or removed. Defaults to `true`.
|
|
2697
|
+
* @name $.jstree.defaults.checkbox.keep_selected_style
|
|
2698
|
+
* @plugin checkbox
|
|
2699
|
+
*/
|
|
2700
|
+
keep_selected_style: !0,
|
|
2701
|
+
/**
|
|
2702
|
+
* This setting controls how cascading and undetermined nodes are applied.
|
|
2703
|
+
* If 'up' is in the string - cascading up is enabled, if 'down' is in the string - cascading down is enabled, if 'undetermined' is in the string - undetermined nodes will be used.
|
|
2704
|
+
* If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''.
|
|
2705
|
+
* @name $.jstree.defaults.checkbox.cascade
|
|
2706
|
+
* @plugin checkbox
|
|
2707
|
+
*/
|
|
2708
|
+
cascade: "",
|
|
2709
|
+
/**
|
|
2710
|
+
* This setting controls if checkbox are bound to the general tree selection or to an internal array maintained by the checkbox plugin. Defaults to `true`, only set to `false` if you know exactly what you are doing.
|
|
2711
|
+
* @name $.jstree.defaults.checkbox.tie_selection
|
|
2712
|
+
* @plugin checkbox
|
|
2713
|
+
*/
|
|
2714
|
+
tie_selection: !0,
|
|
2715
|
+
/**
|
|
2716
|
+
* This setting controls if cascading down affects disabled checkboxes
|
|
2717
|
+
* @name $.jstree.defaults.checkbox.cascade_to_disabled
|
|
2718
|
+
* @plugin checkbox
|
|
2719
|
+
*/
|
|
2720
|
+
cascade_to_disabled: !0,
|
|
2721
|
+
/**
|
|
2722
|
+
* This setting controls if cascading down affects hidden checkboxes
|
|
2723
|
+
* @name $.jstree.defaults.checkbox.cascade_to_hidden
|
|
2724
|
+
* @plugin checkbox
|
|
2725
|
+
*/
|
|
2726
|
+
cascade_to_hidden: !0
|
|
2727
|
+
}, l.jstree.plugins.checkbox = function(e, s) {
|
|
2728
|
+
this.bind = function() {
|
|
2729
|
+
s.bind.call(this), this._data.checkbox.uto = !1, this._data.checkbox.selected = [], this.settings.checkbox.three_state && (this.settings.checkbox.cascade = "up+down+undetermined"), this.element.on("init.jstree", (function() {
|
|
2730
|
+
this._data.checkbox.visible = this.settings.checkbox.visible, this.settings.checkbox.keep_selected_style || this.element.addClass("jstree-checkbox-no-clicked"), this.settings.checkbox.tie_selection && this.element.addClass("jstree-checkbox-selection");
|
|
2731
|
+
}).bind(this)).on("loading.jstree", (function() {
|
|
2732
|
+
this[this._data.checkbox.visible ? "show_checkboxes" : "hide_checkboxes"]();
|
|
2733
|
+
}).bind(this)), this.settings.checkbox.cascade.indexOf("undetermined") !== -1 && this.element.on("changed.jstree uncheck_node.jstree check_node.jstree uncheck_all.jstree check_all.jstree move_node.jstree copy_node.jstree redraw.jstree open_node.jstree", (function() {
|
|
2734
|
+
this._data.checkbox.uto && clearTimeout(this._data.checkbox.uto), this._data.checkbox.uto = setTimeout(this._undetermined.bind(this), 50);
|
|
2735
|
+
}).bind(this)), this.settings.checkbox.tie_selection || this.element.on("model.jstree", (function(t, i) {
|
|
2736
|
+
var r = this._model.data;
|
|
2737
|
+
r[i.parent];
|
|
2738
|
+
var a = i.nodes, n, c;
|
|
2739
|
+
for (n = 0, c = a.length; n < c; n++)
|
|
2740
|
+
r[a[n]].state.checked = r[a[n]].state.checked || r[a[n]].original && r[a[n]].original.state && r[a[n]].original.state.checked, r[a[n]].state.checked && this._data.checkbox.selected.push(a[n]);
|
|
2741
|
+
}).bind(this)), (this.settings.checkbox.cascade.indexOf("up") !== -1 || this.settings.checkbox.cascade.indexOf("down") !== -1) && this.element.on("model.jstree", (function(t, i) {
|
|
2742
|
+
var r = this._model.data, a = r[i.parent], n = i.nodes, c = [], d, h, o, f, _, u, g = this.settings.checkbox.cascade, p = this.settings.checkbox.tie_selection;
|
|
2743
|
+
if (g.indexOf("down") !== -1) {
|
|
2744
|
+
if (a.state[p ? "selected" : "checked"]) {
|
|
2745
|
+
for (h = 0, o = n.length; h < o; h++)
|
|
2746
|
+
r[n[h]].state[p ? "selected" : "checked"] = !0;
|
|
2747
|
+
this._data[p ? "core" : "checkbox"].selected = this._data[p ? "core" : "checkbox"].selected.concat(n);
|
|
2748
|
+
} else
|
|
2749
|
+
for (h = 0, o = n.length; h < o; h++)
|
|
2750
|
+
if (r[n[h]].state[p ? "selected" : "checked"]) {
|
|
2751
|
+
for (f = 0, _ = r[n[h]].children_d.length; f < _; f++)
|
|
2752
|
+
r[r[n[h]].children_d[f]].state[p ? "selected" : "checked"] = !0;
|
|
2753
|
+
this._data[p ? "core" : "checkbox"].selected = this._data[p ? "core" : "checkbox"].selected.concat(r[n[h]].children_d);
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
if (g.indexOf("up") !== -1) {
|
|
2757
|
+
for (h = 0, o = a.children_d.length; h < o; h++)
|
|
2758
|
+
r[a.children_d[h]].children.length || c.push(r[a.children_d[h]].parent);
|
|
2759
|
+
for (c = l.vakata.array_unique(c), f = 0, _ = c.length; f < _; f++)
|
|
2760
|
+
for (a = r[c[f]]; a && a.id !== l.jstree.root; ) {
|
|
2761
|
+
for (d = 0, h = 0, o = a.children.length; h < o; h++)
|
|
2762
|
+
d += r[a.children[h]].state[p ? "selected" : "checked"];
|
|
2763
|
+
if (d === o)
|
|
2764
|
+
a.state[p ? "selected" : "checked"] = !0, this._data[p ? "core" : "checkbox"].selected.push(a.id), u = this.get_node(a, !0), u && u.length && u.children(".jstree-anchor").attr("aria-selected", !0).addClass(p ? "jstree-clicked" : "jstree-checked");
|
|
2765
|
+
else
|
|
2766
|
+
break;
|
|
2767
|
+
a = this.get_node(a.parent);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
this._data[p ? "core" : "checkbox"].selected = l.vakata.array_unique(this._data[p ? "core" : "checkbox"].selected);
|
|
2771
|
+
}).bind(this)).on(this.settings.checkbox.tie_selection ? "select_node.jstree" : "check_node.jstree", (function(t, i) {
|
|
2772
|
+
var r = i.node, a = this._model.data, n = this.get_node(r.parent), c, d, h, o, f = this.settings.checkbox.cascade, _ = this.settings.checkbox.tie_selection, u = {}, g = this._data[_ ? "core" : "checkbox"].selected;
|
|
2773
|
+
for (c = 0, d = g.length; c < d; c++)
|
|
2774
|
+
u[g[c]] = !0;
|
|
2775
|
+
if (f.indexOf("down") !== -1) {
|
|
2776
|
+
var p = this._cascade_new_checked_state(r.id, !0), m = r.children_d.concat(r.id);
|
|
2777
|
+
for (c = 0, d = m.length; c < d; c++)
|
|
2778
|
+
p.indexOf(m[c]) > -1 ? u[m[c]] = !0 : delete u[m[c]];
|
|
2779
|
+
}
|
|
2780
|
+
if (f.indexOf("up") !== -1)
|
|
2781
|
+
for (; n && n.id !== l.jstree.root; ) {
|
|
2782
|
+
for (h = 0, c = 0, d = n.children.length; c < d; c++)
|
|
2783
|
+
h += a[n.children[c]].state[_ ? "selected" : "checked"];
|
|
2784
|
+
if (h === d)
|
|
2785
|
+
n.state[_ ? "selected" : "checked"] = !0, u[n.id] = !0, o = this.get_node(n, !0), o && o.length && o.children(".jstree-anchor").attr("aria-selected", !0).addClass(_ ? "jstree-clicked" : "jstree-checked");
|
|
2786
|
+
else
|
|
2787
|
+
break;
|
|
2788
|
+
n = this.get_node(n.parent);
|
|
2789
|
+
}
|
|
2790
|
+
g = [];
|
|
2791
|
+
for (c in u)
|
|
2792
|
+
u.hasOwnProperty(c) && g.push(c);
|
|
2793
|
+
this._data[_ ? "core" : "checkbox"].selected = g;
|
|
2794
|
+
}).bind(this)).on(this.settings.checkbox.tie_selection ? "deselect_all.jstree" : "uncheck_all.jstree", (function(t, i) {
|
|
2795
|
+
var r = this.get_node(l.jstree.root), a = this._model.data, n, c, d;
|
|
2796
|
+
for (n = 0, c = r.children_d.length; n < c; n++)
|
|
2797
|
+
d = a[r.children_d[n]], d && d.original && d.original.state && d.original.state.undetermined && (d.original.state.undetermined = !1);
|
|
2798
|
+
}).bind(this)).on(this.settings.checkbox.tie_selection ? "deselect_node.jstree" : "uncheck_node.jstree", (function(t, i) {
|
|
2799
|
+
var r = i.node;
|
|
2800
|
+
this.get_node(r, !0);
|
|
2801
|
+
var a, n, c, d = this.settings.checkbox.cascade, h = this.settings.checkbox.tie_selection, o = this._data[h ? "core" : "checkbox"].selected, f = r.children_d.concat(r.id);
|
|
2802
|
+
if (d.indexOf("down") !== -1) {
|
|
2803
|
+
var _ = this._cascade_new_checked_state(r.id, !1);
|
|
2804
|
+
o = l.vakata.array_filter(o, function(u) {
|
|
2805
|
+
return f.indexOf(u) === -1 || _.indexOf(u) > -1;
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
if (d.indexOf("up") !== -1 && o.indexOf(r.id) === -1) {
|
|
2809
|
+
for (a = 0, n = r.parents.length; a < n; a++)
|
|
2810
|
+
c = this._model.data[r.parents[a]], c.state[h ? "selected" : "checked"] = !1, c && c.original && c.original.state && c.original.state.undetermined && (c.original.state.undetermined = !1), c = this.get_node(r.parents[a], !0), c && c.length && c.children(".jstree-anchor").attr("aria-selected", !1).removeClass(h ? "jstree-clicked" : "jstree-checked");
|
|
2811
|
+
o = l.vakata.array_filter(o, function(u) {
|
|
2812
|
+
return r.parents.indexOf(u) === -1;
|
|
2813
|
+
});
|
|
2814
|
+
}
|
|
2815
|
+
this._data[h ? "core" : "checkbox"].selected = o;
|
|
2816
|
+
}).bind(this)), this.settings.checkbox.cascade.indexOf("up") !== -1 && this.element.on("delete_node.jstree", (function(t, i) {
|
|
2817
|
+
for (var r = this.get_node(i.parent), a = this._model.data, n, c, d, h, o = this.settings.checkbox.tie_selection; r && r.id !== l.jstree.root && !r.state[o ? "selected" : "checked"]; ) {
|
|
2818
|
+
for (d = 0, n = 0, c = r.children.length; n < c; n++)
|
|
2819
|
+
d += a[r.children[n]].state[o ? "selected" : "checked"];
|
|
2820
|
+
if (c > 0 && d === c)
|
|
2821
|
+
r.state[o ? "selected" : "checked"] = !0, this._data[o ? "core" : "checkbox"].selected.push(r.id), h = this.get_node(r, !0), h && h.length && h.children(".jstree-anchor").attr("aria-selected", !0).addClass(o ? "jstree-clicked" : "jstree-checked");
|
|
2822
|
+
else
|
|
2823
|
+
break;
|
|
2824
|
+
r = this.get_node(r.parent);
|
|
2825
|
+
}
|
|
2826
|
+
}).bind(this)).on("move_node.jstree", (function(t, i) {
|
|
2827
|
+
var r = i.is_multi, a = i.old_parent, n = this.get_node(i.parent), c = this._model.data, d, h, o, f, _, u = this.settings.checkbox.tie_selection;
|
|
2828
|
+
if (!r)
|
|
2829
|
+
for (d = this.get_node(a); d && d.id !== l.jstree.root && !d.state[u ? "selected" : "checked"]; ) {
|
|
2830
|
+
for (h = 0, o = 0, f = d.children.length; o < f; o++)
|
|
2831
|
+
h += c[d.children[o]].state[u ? "selected" : "checked"];
|
|
2832
|
+
if (f > 0 && h === f)
|
|
2833
|
+
d.state[u ? "selected" : "checked"] = !0, this._data[u ? "core" : "checkbox"].selected.push(d.id), _ = this.get_node(d, !0), _ && _.length && _.children(".jstree-anchor").attr("aria-selected", !0).addClass(u ? "jstree-clicked" : "jstree-checked");
|
|
2834
|
+
else
|
|
2835
|
+
break;
|
|
2836
|
+
d = this.get_node(d.parent);
|
|
2837
|
+
}
|
|
2838
|
+
for (d = n; d && d.id !== l.jstree.root; ) {
|
|
2839
|
+
for (h = 0, o = 0, f = d.children.length; o < f; o++)
|
|
2840
|
+
h += c[d.children[o]].state[u ? "selected" : "checked"];
|
|
2841
|
+
if (h === f)
|
|
2842
|
+
d.state[u ? "selected" : "checked"] || (d.state[u ? "selected" : "checked"] = !0, this._data[u ? "core" : "checkbox"].selected.push(d.id), _ = this.get_node(d, !0), _ && _.length && _.children(".jstree-anchor").attr("aria-selected", !0).addClass(u ? "jstree-clicked" : "jstree-checked"));
|
|
2843
|
+
else if (d.state[u ? "selected" : "checked"])
|
|
2844
|
+
d.state[u ? "selected" : "checked"] = !1, this._data[u ? "core" : "checkbox"].selected = l.vakata.array_remove_item(this._data[u ? "core" : "checkbox"].selected, d.id), _ = this.get_node(d, !0), _ && _.length && _.children(".jstree-anchor").attr("aria-selected", !1).removeClass(u ? "jstree-clicked" : "jstree-checked");
|
|
2845
|
+
else
|
|
2846
|
+
break;
|
|
2847
|
+
d = this.get_node(d.parent);
|
|
2848
|
+
}
|
|
2849
|
+
}).bind(this));
|
|
2850
|
+
}, this.get_undetermined = function(t) {
|
|
2851
|
+
if (this.settings.checkbox.cascade.indexOf("undetermined") === -1)
|
|
2852
|
+
return [];
|
|
2853
|
+
var i, r, a, n, c = {}, d = this._model.data, h = this.settings.checkbox.tie_selection, o = this._data[h ? "core" : "checkbox"].selected, f = [], _ = this, u = [];
|
|
2854
|
+
for (i = 0, r = o.length; i < r; i++)
|
|
2855
|
+
if (d[o[i]] && d[o[i]].parents)
|
|
2856
|
+
for (a = 0, n = d[o[i]].parents.length; a < n && c[d[o[i]].parents[a]] === y; a++)
|
|
2857
|
+
d[o[i]].parents[a] !== l.jstree.root && (c[d[o[i]].parents[a]] = !0, f.push(d[o[i]].parents[a]));
|
|
2858
|
+
for (this.element.find(".jstree-closed").not(":has(.jstree-children)").each(function() {
|
|
2859
|
+
var g = _.get_node(this), p;
|
|
2860
|
+
if (g) {
|
|
2861
|
+
if (g.state.loaded) {
|
|
2862
|
+
for (i = 0, r = g.children_d.length; i < r; i++)
|
|
2863
|
+
if (p = d[g.children_d[i]], !p.state.loaded && p.original && p.original.state && p.original.state.undetermined && p.original.state.undetermined === !0)
|
|
2864
|
+
for (c[p.id] === y && p.id !== l.jstree.root && (c[p.id] = !0, f.push(p.id)), a = 0, n = p.parents.length; a < n; a++)
|
|
2865
|
+
c[p.parents[a]] === y && p.parents[a] !== l.jstree.root && (c[p.parents[a]] = !0, f.push(p.parents[a]));
|
|
2866
|
+
} else if (g.original && g.original.state && g.original.state.undetermined && g.original.state.undetermined === !0)
|
|
2867
|
+
for (c[g.id] === y && g.id !== l.jstree.root && (c[g.id] = !0, f.push(g.id)), a = 0, n = g.parents.length; a < n; a++)
|
|
2868
|
+
c[g.parents[a]] === y && g.parents[a] !== l.jstree.root && (c[g.parents[a]] = !0, f.push(g.parents[a]));
|
|
2869
|
+
}
|
|
2870
|
+
}), i = 0, r = f.length; i < r; i++)
|
|
2871
|
+
d[f[i]].state[h ? "selected" : "checked"] || u.push(t ? d[f[i]] : f[i]);
|
|
2872
|
+
return u;
|
|
2873
|
+
}, this._undetermined = function() {
|
|
2874
|
+
if (this.element !== null) {
|
|
2875
|
+
var t = this.get_undetermined(!1), i, r, a;
|
|
2876
|
+
for (this.element.find(".jstree-undetermined").removeClass("jstree-undetermined"), i = 0, r = t.length; i < r; i++)
|
|
2877
|
+
a = this.get_node(t[i], !0), a && a.length && a.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-undetermined");
|
|
2878
|
+
}
|
|
2879
|
+
}, this.redraw_node = function(t, i, r, a) {
|
|
2880
|
+
if (t = s.redraw_node.apply(this, arguments), t) {
|
|
2881
|
+
var n, c, d = null, h = null;
|
|
2882
|
+
for (n = 0, c = t.childNodes.length; n < c; n++)
|
|
2883
|
+
if (t.childNodes[n] && t.childNodes[n].className && t.childNodes[n].className.indexOf("jstree-anchor") !== -1) {
|
|
2884
|
+
d = t.childNodes[n];
|
|
2885
|
+
break;
|
|
2886
|
+
}
|
|
2887
|
+
d && (!this.settings.checkbox.tie_selection && this._model.data[t.id].state.checked && (d.className += " jstree-checked"), h = V.cloneNode(!1), this._model.data[t.id].state.checkbox_disabled && (h.className += " jstree-checkbox-disabled"), d.insertBefore(h, d.childNodes[0]));
|
|
2888
|
+
}
|
|
2889
|
+
return !r && this.settings.checkbox.cascade.indexOf("undetermined") !== -1 && (this._data.checkbox.uto && clearTimeout(this._data.checkbox.uto), this._data.checkbox.uto = setTimeout(this._undetermined.bind(this), 50)), t;
|
|
2890
|
+
}, this.show_checkboxes = function() {
|
|
2891
|
+
this._data.core.themes.checkboxes = !0, this.get_container_ul().removeClass("jstree-no-checkboxes");
|
|
2892
|
+
}, this.hide_checkboxes = function() {
|
|
2893
|
+
this._data.core.themes.checkboxes = !1, this.get_container_ul().addClass("jstree-no-checkboxes");
|
|
2894
|
+
}, this.toggle_checkboxes = function() {
|
|
2895
|
+
this._data.core.themes.checkboxes ? this.hide_checkboxes() : this.show_checkboxes();
|
|
2896
|
+
}, this.is_undetermined = function(t) {
|
|
2897
|
+
t = this.get_node(t);
|
|
2898
|
+
var i = this.settings.checkbox.cascade, r, a, n = this.settings.checkbox.tie_selection, c = this._data[n ? "core" : "checkbox"].selected, d = this._model.data;
|
|
2899
|
+
if (!t || t.state[n ? "selected" : "checked"] === !0 || i.indexOf("undetermined") === -1 || i.indexOf("down") === -1 && i.indexOf("up") === -1)
|
|
2900
|
+
return !1;
|
|
2901
|
+
if (!t.state.loaded && t.original.state.undetermined === !0)
|
|
2902
|
+
return !0;
|
|
2903
|
+
for (r = 0, a = t.children_d.length; r < a; r++)
|
|
2904
|
+
if (l.inArray(t.children_d[r], c) !== -1 || !d[t.children_d[r]].state.loaded && d[t.children_d[r]].original.state.undetermined)
|
|
2905
|
+
return !0;
|
|
2906
|
+
return !1;
|
|
2907
|
+
}, this.disable_checkbox = function(t) {
|
|
2908
|
+
var i, r, a;
|
|
2909
|
+
if (l.vakata.is_array(t)) {
|
|
2910
|
+
for (t = t.slice(), i = 0, r = t.length; i < r; i++)
|
|
2911
|
+
this.disable_checkbox(t[i]);
|
|
2912
|
+
return !0;
|
|
2913
|
+
}
|
|
2914
|
+
if (t = this.get_node(t), !t || t.id === l.jstree.root)
|
|
2915
|
+
return !1;
|
|
2916
|
+
a = this.get_node(t, !0), t.state.checkbox_disabled || (t.state.checkbox_disabled = !0, a && a.length && a.children(".jstree-anchor").children(".jstree-checkbox").addClass("jstree-checkbox-disabled"), this.trigger("disable_checkbox", { node: t }));
|
|
2917
|
+
}, this.enable_checkbox = function(t) {
|
|
2918
|
+
var i, r, a;
|
|
2919
|
+
if (l.vakata.is_array(t)) {
|
|
2920
|
+
for (t = t.slice(), i = 0, r = t.length; i < r; i++)
|
|
2921
|
+
this.enable_checkbox(t[i]);
|
|
2922
|
+
return !0;
|
|
2923
|
+
}
|
|
2924
|
+
if (t = this.get_node(t), !t || t.id === l.jstree.root)
|
|
2925
|
+
return !1;
|
|
2926
|
+
a = this.get_node(t, !0), t.state.checkbox_disabled && (t.state.checkbox_disabled = !1, a && a.length && a.children(".jstree-anchor").children(".jstree-checkbox").removeClass("jstree-checkbox-disabled"), this.trigger("enable_checkbox", { node: t }));
|
|
2927
|
+
}, this.activate_node = function(t, i) {
|
|
2928
|
+
if (l(i.target).hasClass("jstree-checkbox-disabled"))
|
|
2929
|
+
return !1;
|
|
2930
|
+
if (this.settings.checkbox.tie_selection && (this.settings.checkbox.whole_node || l(i.target).hasClass("jstree-checkbox")) && (i.ctrlKey = !0), this.settings.checkbox.tie_selection || !this.settings.checkbox.whole_node && !l(i.target).hasClass("jstree-checkbox"))
|
|
2931
|
+
return s.activate_node.call(this, t, i);
|
|
2932
|
+
if (this.is_disabled(t))
|
|
2933
|
+
return !1;
|
|
2934
|
+
this.is_checked(t) ? this.uncheck_node(t, i) : this.check_node(t, i), this.trigger("activate_node", { node: this.get_node(t) });
|
|
2935
|
+
}, this.delete_node = function(t) {
|
|
2936
|
+
if (this.settings.checkbox.tie_selection || l.vakata.is_array(t))
|
|
2937
|
+
return s.delete_node.call(this, t);
|
|
2938
|
+
var i, r, a, n = !1;
|
|
2939
|
+
if (t = this.get_node(t), !t || t.id === l.jstree.root)
|
|
2940
|
+
return !1;
|
|
2941
|
+
for (i = t.children_d.concat([]), i.push(t.id), r = 0, a = i.length; r < a; r++)
|
|
2942
|
+
if (this._model.data[i[r]].state.checked) {
|
|
2943
|
+
n = !0;
|
|
2944
|
+
break;
|
|
2945
|
+
}
|
|
2946
|
+
return n && (this._data.checkbox.selected = l.vakata.array_filter(this._data.checkbox.selected, function(c) {
|
|
2947
|
+
return l.inArray(c, i) === -1;
|
|
2948
|
+
})), s.delete_node.call(this, t);
|
|
2949
|
+
}, this._cascade_new_checked_state = function(t, i) {
|
|
2950
|
+
var r = this, a = this.settings.checkbox.tie_selection, n = this._model.data[t], c = [], d = [], h, o, f;
|
|
2951
|
+
if ((this.settings.checkbox.cascade_to_disabled || !n.state.disabled) && (this.settings.checkbox.cascade_to_hidden || !n.state.hidden)) {
|
|
2952
|
+
if (n.children)
|
|
2953
|
+
for (h = 0, o = n.children.length; h < o; h++) {
|
|
2954
|
+
var _ = n.children[h];
|
|
2955
|
+
f = r._cascade_new_checked_state(_, i), c = c.concat(f), f.indexOf(_) > -1 && d.push(_);
|
|
2956
|
+
}
|
|
2957
|
+
var u = r.get_node(n, !0), g = d.length > 0 && d.length < n.children.length;
|
|
2958
|
+
n.original && n.original.state && n.original.state.undetermined && (n.original.state.undetermined = g), g ? (n.state[a ? "selected" : "checked"] = !1, u.children(".jstree-anchor").attr("aria-selected", !1).removeClass(a ? "jstree-clicked" : "jstree-checked")) : i && d.length === n.children.length ? (n.state[a ? "selected" : "checked"] = i, c.push(n.id), u.children(".jstree-anchor").attr("aria-selected", !0).addClass(a ? "jstree-clicked" : "jstree-checked")) : (n.state[a ? "selected" : "checked"] = !1, u.children(".jstree-anchor").attr("aria-selected", !1).removeClass(a ? "jstree-clicked" : "jstree-checked"));
|
|
2959
|
+
} else
|
|
2960
|
+
f = this.get_checked_descendants(t), n.state[a ? "selected" : "checked"] && f.push(n.id), c = c.concat(f);
|
|
2961
|
+
return c;
|
|
2962
|
+
}, this.get_checked_descendants = function(t) {
|
|
2963
|
+
var i = this, r = i.settings.checkbox.tie_selection, a = i._model.data[t];
|
|
2964
|
+
return l.vakata.array_filter(a.children_d, function(n) {
|
|
2965
|
+
return i._model.data[n].state[r ? "selected" : "checked"];
|
|
2966
|
+
});
|
|
2967
|
+
}, this.check_node = function(t, i) {
|
|
2968
|
+
if (this.settings.checkbox.tie_selection)
|
|
2969
|
+
return this.select_node(t, !1, !0, i);
|
|
2970
|
+
var r, a, n;
|
|
2971
|
+
if (l.vakata.is_array(t)) {
|
|
2972
|
+
for (t = t.slice(), a = 0, n = t.length; a < n; a++)
|
|
2973
|
+
this.check_node(t[a], i);
|
|
2974
|
+
return !0;
|
|
2975
|
+
}
|
|
2976
|
+
if (t = this.get_node(t), !t || t.id === l.jstree.root)
|
|
2977
|
+
return !1;
|
|
2978
|
+
r = this.get_node(t, !0), t.state.checked || (t.state.checked = !0, this._data.checkbox.selected.push(t.id), r && r.length && r.children(".jstree-anchor").addClass("jstree-checked"), this.trigger("check_node", { node: t, selected: this._data.checkbox.selected, event: i }));
|
|
2979
|
+
}, this.uncheck_node = function(t, i) {
|
|
2980
|
+
if (this.settings.checkbox.tie_selection)
|
|
2981
|
+
return this.deselect_node(t, !1, i);
|
|
2982
|
+
var r, a, n;
|
|
2983
|
+
if (l.vakata.is_array(t)) {
|
|
2984
|
+
for (t = t.slice(), r = 0, a = t.length; r < a; r++)
|
|
2985
|
+
this.uncheck_node(t[r], i);
|
|
2986
|
+
return !0;
|
|
2987
|
+
}
|
|
2988
|
+
if (t = this.get_node(t), !t || t.id === l.jstree.root)
|
|
2989
|
+
return !1;
|
|
2990
|
+
n = this.get_node(t, !0), t.state.checked && (t.state.checked = !1, this._data.checkbox.selected = l.vakata.array_remove_item(this._data.checkbox.selected, t.id), n.length && n.children(".jstree-anchor").removeClass("jstree-checked"), this.trigger("uncheck_node", { node: t, selected: this._data.checkbox.selected, event: i }));
|
|
2991
|
+
}, this.check_all = function() {
|
|
2992
|
+
if (this.settings.checkbox.tie_selection)
|
|
2993
|
+
return this.select_all();
|
|
2994
|
+
this._data.checkbox.selected.concat([]);
|
|
2995
|
+
var t, i;
|
|
2996
|
+
for (this._data.checkbox.selected = this._model.data[l.jstree.root].children_d.concat(), t = 0, i = this._data.checkbox.selected.length; t < i; t++)
|
|
2997
|
+
this._model.data[this._data.checkbox.selected[t]] && (this._model.data[this._data.checkbox.selected[t]].state.checked = !0);
|
|
2998
|
+
this.redraw(!0), this.trigger("check_all", { selected: this._data.checkbox.selected });
|
|
2999
|
+
}, this.uncheck_all = function() {
|
|
3000
|
+
if (this.settings.checkbox.tie_selection)
|
|
3001
|
+
return this.deselect_all();
|
|
3002
|
+
var t = this._data.checkbox.selected.concat([]), i, r;
|
|
3003
|
+
for (i = 0, r = this._data.checkbox.selected.length; i < r; i++)
|
|
3004
|
+
this._model.data[this._data.checkbox.selected[i]] && (this._model.data[this._data.checkbox.selected[i]].state.checked = !1);
|
|
3005
|
+
this._data.checkbox.selected = [], this.element.find(".jstree-checked").removeClass("jstree-checked"), this.trigger("uncheck_all", { selected: this._data.checkbox.selected, node: t });
|
|
3006
|
+
}, this.is_checked = function(t) {
|
|
3007
|
+
return this.settings.checkbox.tie_selection ? this.is_selected(t) : (t = this.get_node(t), !t || t.id === l.jstree.root ? !1 : t.state.checked);
|
|
3008
|
+
}, this.get_checked = function(t) {
|
|
3009
|
+
return this.settings.checkbox.tie_selection ? this.get_selected(t) : t ? l.map(this._data.checkbox.selected, (function(i) {
|
|
3010
|
+
return this.get_node(i);
|
|
3011
|
+
}).bind(this)) : this._data.checkbox.selected.slice();
|
|
3012
|
+
}, this.get_top_checked = function(t) {
|
|
3013
|
+
if (this.settings.checkbox.tie_selection)
|
|
3014
|
+
return this.get_top_selected(t);
|
|
3015
|
+
var i = this.get_checked(!0), r = {}, a, n, c, d;
|
|
3016
|
+
for (a = 0, n = i.length; a < n; a++)
|
|
3017
|
+
r[i[a].id] = i[a];
|
|
3018
|
+
for (a = 0, n = i.length; a < n; a++)
|
|
3019
|
+
for (c = 0, d = i[a].children_d.length; c < d; c++)
|
|
3020
|
+
r[i[a].children_d[c]] && delete r[i[a].children_d[c]];
|
|
3021
|
+
i = [];
|
|
3022
|
+
for (a in r)
|
|
3023
|
+
r.hasOwnProperty(a) && i.push(a);
|
|
3024
|
+
return t ? l.map(i, (function(h) {
|
|
3025
|
+
return this.get_node(h);
|
|
3026
|
+
}).bind(this)) : i;
|
|
3027
|
+
}, this.get_bottom_checked = function(t) {
|
|
3028
|
+
if (this.settings.checkbox.tie_selection)
|
|
3029
|
+
return this.get_bottom_selected(t);
|
|
3030
|
+
var i = this.get_checked(!0), r = [], a, n;
|
|
3031
|
+
for (a = 0, n = i.length; a < n; a++)
|
|
3032
|
+
i[a].children.length || r.push(i[a].id);
|
|
3033
|
+
return t ? l.map(r, (function(c) {
|
|
3034
|
+
return this.get_node(c);
|
|
3035
|
+
}).bind(this)) : r;
|
|
3036
|
+
}, this.load_node = function(t, i) {
|
|
3037
|
+
var r, a, n;
|
|
3038
|
+
if (!l.vakata.is_array(t) && !this.settings.checkbox.tie_selection && (n = this.get_node(t), n && n.state.loaded))
|
|
3039
|
+
for (r = 0, a = n.children_d.length; r < a; r++)
|
|
3040
|
+
this._model.data[n.children_d[r]].state.checked && (this._data.checkbox.selected = l.vakata.array_remove_item(this._data.checkbox.selected, n.children_d[r]));
|
|
3041
|
+
return s.load_node.apply(this, arguments);
|
|
3042
|
+
}, this.get_state = function() {
|
|
3043
|
+
var t = s.get_state.apply(this, arguments);
|
|
3044
|
+
return this.settings.checkbox.tie_selection || (t.checkbox = this._data.checkbox.selected.slice()), t;
|
|
3045
|
+
}, this.set_state = function(t, i) {
|
|
3046
|
+
var r = s.set_state.apply(this, arguments);
|
|
3047
|
+
if (r && t.checkbox) {
|
|
3048
|
+
if (!this.settings.checkbox.tie_selection) {
|
|
3049
|
+
this.uncheck_all();
|
|
3050
|
+
var a = this;
|
|
3051
|
+
l.each(t.checkbox, function(n, c) {
|
|
3052
|
+
a.check_node(c);
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
return delete t.checkbox, this.set_state(t, i), !1;
|
|
3056
|
+
}
|
|
3057
|
+
return r;
|
|
3058
|
+
}, this.refresh = function(t, i) {
|
|
3059
|
+
return this.settings.checkbox.tie_selection && (this._data.checkbox.selected = []), s.refresh.apply(this, arguments);
|
|
3060
|
+
};
|
|
3061
|
+
}, l.jstree.defaults.conditionalselect = function() {
|
|
3062
|
+
return !0;
|
|
3063
|
+
}, l.jstree.plugins.conditionalselect = function(e, s) {
|
|
3064
|
+
this.activate_node = function(t, i) {
|
|
3065
|
+
if (this.settings.conditionalselect.call(this, this.get_node(t), i))
|
|
3066
|
+
return s.activate_node.call(this, t, i);
|
|
3067
|
+
};
|
|
3068
|
+
}, l.jstree.defaults.contextmenu = {
|
|
3069
|
+
/**
|
|
3070
|
+
* a boolean indicating if the node should be selected when the context menu is invoked on it. Defaults to `true`.
|
|
3071
|
+
* @name $.jstree.defaults.contextmenu.select_node
|
|
3072
|
+
* @plugin contextmenu
|
|
3073
|
+
*/
|
|
3074
|
+
select_node: !0,
|
|
3075
|
+
/**
|
|
3076
|
+
* a boolean indicating if the menu should be shown aligned with the node. Defaults to `true`, otherwise the mouse coordinates are used.
|
|
3077
|
+
* @name $.jstree.defaults.contextmenu.show_at_node
|
|
3078
|
+
* @plugin contextmenu
|
|
3079
|
+
*/
|
|
3080
|
+
show_at_node: !0,
|
|
3081
|
+
/**
|
|
3082
|
+
* an object of actions, or a function that accepts a node and a callback function and calls the callback function with an object of actions available for that node (you can also return the items too).
|
|
3083
|
+
*
|
|
3084
|
+
* Each action consists of a key (a unique name) and a value which is an object with the following properties (only label and action are required). Once a menu item is activated the `action` function will be invoked with an object containing the following keys: item - the contextmenu item definition as seen below, reference - the DOM node that was used (the tree node), element - the contextmenu DOM element, position - an object with x/y properties indicating the position of the menu.
|
|
3085
|
+
*
|
|
3086
|
+
* * `separator_before` - a boolean indicating if there should be a separator before this item
|
|
3087
|
+
* * `separator_after` - a boolean indicating if there should be a separator after this item
|
|
3088
|
+
* * `_disabled` - a boolean indicating if this action should be disabled
|
|
3089
|
+
* * `label` - a string - the name of the action (could be a function returning a string)
|
|
3090
|
+
* * `title` - a string - an optional tooltip for the item
|
|
3091
|
+
* * `action` - a function to be executed if this item is chosen, the function will receive
|
|
3092
|
+
* * `icon` - a string, can be a path to an icon or a className, if using an image that is in the current directory use a `./` prefix, otherwise it will be detected as a class
|
|
3093
|
+
* * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2)
|
|
3094
|
+
* * `shortcut_label` - shortcut label (like for example `F2` for rename)
|
|
3095
|
+
* * `submenu` - an object with the same structure as $.jstree.defaults.contextmenu.items which can be used to create a submenu - each key will be rendered as a separate option in a submenu that will appear once the current item is hovered
|
|
3096
|
+
*
|
|
3097
|
+
* @name $.jstree.defaults.contextmenu.items
|
|
3098
|
+
* @plugin contextmenu
|
|
3099
|
+
*/
|
|
3100
|
+
items: function(e, s) {
|
|
3101
|
+
return {
|
|
3102
|
+
create: {
|
|
3103
|
+
separator_before: !1,
|
|
3104
|
+
separator_after: !0,
|
|
3105
|
+
_disabled: !1,
|
|
3106
|
+
//(this.check("create_node", data.reference, {}, "last")),
|
|
3107
|
+
label: "Create",
|
|
3108
|
+
action: function(t) {
|
|
3109
|
+
var i = l.jstree.reference(t.reference), r = i.get_node(t.reference);
|
|
3110
|
+
i.create_node(r, {}, "last", function(a) {
|
|
3111
|
+
try {
|
|
3112
|
+
i.edit(a);
|
|
3113
|
+
} catch {
|
|
3114
|
+
setTimeout(function() {
|
|
3115
|
+
i.edit(a);
|
|
3116
|
+
}, 0);
|
|
3117
|
+
}
|
|
3118
|
+
});
|
|
3119
|
+
}
|
|
3120
|
+
},
|
|
3121
|
+
rename: {
|
|
3122
|
+
separator_before: !1,
|
|
3123
|
+
separator_after: !1,
|
|
3124
|
+
_disabled: !1,
|
|
3125
|
+
//(this.check("rename_node", data.reference, this.get_parent(data.reference), "")),
|
|
3126
|
+
label: "Rename",
|
|
3127
|
+
/*!
|
|
3128
|
+
"shortcut" : 113,
|
|
3129
|
+
"shortcut_label" : 'F2',
|
|
3130
|
+
"icon" : "glyphicon glyphicon-leaf",
|
|
3131
|
+
*/
|
|
3132
|
+
action: function(t) {
|
|
3133
|
+
var i = l.jstree.reference(t.reference), r = i.get_node(t.reference);
|
|
3134
|
+
i.edit(r);
|
|
3135
|
+
}
|
|
3136
|
+
},
|
|
3137
|
+
remove: {
|
|
3138
|
+
separator_before: !1,
|
|
3139
|
+
icon: !1,
|
|
3140
|
+
separator_after: !1,
|
|
3141
|
+
_disabled: !1,
|
|
3142
|
+
//(this.check("delete_node", data.reference, this.get_parent(data.reference), "")),
|
|
3143
|
+
label: "Delete",
|
|
3144
|
+
action: function(t) {
|
|
3145
|
+
var i = l.jstree.reference(t.reference), r = i.get_node(t.reference);
|
|
3146
|
+
i.is_selected(r) ? i.delete_node(i.get_selected()) : i.delete_node(r);
|
|
3147
|
+
}
|
|
3148
|
+
},
|
|
3149
|
+
ccp: {
|
|
3150
|
+
separator_before: !0,
|
|
3151
|
+
icon: !1,
|
|
3152
|
+
separator_after: !1,
|
|
3153
|
+
label: "Edit",
|
|
3154
|
+
action: !1,
|
|
3155
|
+
submenu: {
|
|
3156
|
+
cut: {
|
|
3157
|
+
separator_before: !1,
|
|
3158
|
+
separator_after: !1,
|
|
3159
|
+
label: "Cut",
|
|
3160
|
+
action: function(t) {
|
|
3161
|
+
var i = l.jstree.reference(t.reference), r = i.get_node(t.reference);
|
|
3162
|
+
i.is_selected(r) ? i.cut(i.get_top_selected()) : i.cut(r);
|
|
3163
|
+
}
|
|
3164
|
+
},
|
|
3165
|
+
copy: {
|
|
3166
|
+
separator_before: !1,
|
|
3167
|
+
icon: !1,
|
|
3168
|
+
separator_after: !1,
|
|
3169
|
+
label: "Copy",
|
|
3170
|
+
action: function(t) {
|
|
3171
|
+
var i = l.jstree.reference(t.reference), r = i.get_node(t.reference);
|
|
3172
|
+
i.is_selected(r) ? i.copy(i.get_top_selected()) : i.copy(r);
|
|
3173
|
+
}
|
|
3174
|
+
},
|
|
3175
|
+
paste: {
|
|
3176
|
+
separator_before: !1,
|
|
3177
|
+
icon: !1,
|
|
3178
|
+
_disabled: function(t) {
|
|
3179
|
+
return !l.jstree.reference(t.reference).can_paste();
|
|
3180
|
+
},
|
|
3181
|
+
separator_after: !1,
|
|
3182
|
+
label: "Paste",
|
|
3183
|
+
action: function(t) {
|
|
3184
|
+
var i = l.jstree.reference(t.reference), r = i.get_node(t.reference);
|
|
3185
|
+
i.paste(r);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
}, l.jstree.plugins.contextmenu = function(e, s) {
|
|
3193
|
+
this.bind = function() {
|
|
3194
|
+
s.bind.call(this);
|
|
3195
|
+
var t = 0, i = null, r, a;
|
|
3196
|
+
this.element.on("init.jstree loading.jstree ready.jstree", (function() {
|
|
3197
|
+
this.get_container_ul().addClass("jstree-contextmenu");
|
|
3198
|
+
}).bind(this)).on("contextmenu.jstree", ".jstree-anchor", (function(n, c) {
|
|
3199
|
+
n.target.tagName.toLowerCase() !== "input" && (n.preventDefault(), t = n.ctrlKey ? +/* @__PURE__ */ new Date() : 0, (c || i) && (t = +/* @__PURE__ */ new Date() + 1e4), i && clearTimeout(i), this.is_loading(n.currentTarget) || this.show_contextmenu(n.currentTarget, n.pageX, n.pageY, n));
|
|
3200
|
+
}).bind(this)).on("click.jstree", ".jstree-anchor", (function(n) {
|
|
3201
|
+
this._data.contextmenu.visible && (!t || +/* @__PURE__ */ new Date() - t > 250) && l.vakata.context.hide(), t = 0;
|
|
3202
|
+
}).bind(this)).on("touchstart.jstree", ".jstree-anchor", function(n) {
|
|
3203
|
+
!n.originalEvent || !n.originalEvent.changedTouches || !n.originalEvent.changedTouches[0] || (r = n.originalEvent.changedTouches[0].clientX, a = n.originalEvent.changedTouches[0].clientY, i = setTimeout(function() {
|
|
3204
|
+
l(n.currentTarget).trigger("contextmenu", !0);
|
|
3205
|
+
}, 750));
|
|
3206
|
+
}).on("touchmove.vakata.jstree", function(n) {
|
|
3207
|
+
i && n.originalEvent && n.originalEvent.changedTouches && n.originalEvent.changedTouches[0] && (Math.abs(r - n.originalEvent.changedTouches[0].clientX) > 10 || Math.abs(a - n.originalEvent.changedTouches[0].clientY) > 10) && (clearTimeout(i), l.vakata.context.hide());
|
|
3208
|
+
}).on("touchend.vakata.jstree", function(n) {
|
|
3209
|
+
i && clearTimeout(i);
|
|
3210
|
+
});
|
|
3211
|
+
/*!
|
|
3212
|
+
if(!('oncontextmenu' in document.body) && ('ontouchstart' in document.body)) {
|
|
3213
|
+
var el = null, tm = null;
|
|
3214
|
+
this.element
|
|
3215
|
+
.on("touchstart", ".jstree-anchor", function (e) {
|
|
3216
|
+
el = e.currentTarget;
|
|
3217
|
+
tm = +new Date();
|
|
3218
|
+
$(document).one("touchend", function (e) {
|
|
3219
|
+
e.target = document.elementFromPoint(e.originalEvent.targetTouches[0].pageX - window.pageXOffset, e.originalEvent.targetTouches[0].pageY - window.pageYOffset);
|
|
3220
|
+
e.currentTarget = e.target;
|
|
3221
|
+
tm = ((+(new Date())) - tm);
|
|
3222
|
+
if(e.target === el && tm > 600 && tm < 1000) {
|
|
3223
|
+
e.preventDefault();
|
|
3224
|
+
$(el).trigger('contextmenu', e);
|
|
3225
|
+
}
|
|
3226
|
+
el = null;
|
|
3227
|
+
tm = null;
|
|
3228
|
+
});
|
|
3229
|
+
});
|
|
3230
|
+
}
|
|
3231
|
+
*/
|
|
3232
|
+
l(T).on("context_hide.vakata.jstree", (function(n, c) {
|
|
3233
|
+
this._data.contextmenu.visible = !1, l(c.reference).removeClass("jstree-context");
|
|
3234
|
+
}).bind(this));
|
|
3235
|
+
}, this.teardown = function() {
|
|
3236
|
+
this._data.contextmenu.visible && l.vakata.context.hide(), l(T).off("context_hide.vakata.jstree"), s.teardown.call(this);
|
|
3237
|
+
}, this.show_contextmenu = function(t, i, r, a) {
|
|
3238
|
+
if (t = this.get_node(t), !t || t.id === l.jstree.root)
|
|
3239
|
+
return !1;
|
|
3240
|
+
var n = this.settings.contextmenu, c = this.get_node(t, !0), d = c.children(".jstree-anchor"), h = !1, o = !1;
|
|
3241
|
+
(n.show_at_node || i === y || r === y) && (h = d.offset(), i = h.left, r = h.top + this._data.core.li_height), this.settings.contextmenu.select_node && !this.is_selected(t) && this.activate_node(t, a), o = n.items, l.vakata.is_function(o) && (o = o.call(this, t, (function(f) {
|
|
3242
|
+
this._show_contextmenu(t, i, r, f);
|
|
3243
|
+
}).bind(this))), l.isPlainObject(o) && this._show_contextmenu(t, i, r, o);
|
|
3244
|
+
}, this._show_contextmenu = function(t, i, r, a) {
|
|
3245
|
+
var n = this.get_node(t, !0), c = n.children(".jstree-anchor");
|
|
3246
|
+
l(T).one("context_show.vakata.jstree", (function(d, h) {
|
|
3247
|
+
var o = "jstree-contextmenu jstree-" + this.get_theme() + "-contextmenu";
|
|
3248
|
+
l(h.element).addClass(o), c.addClass("jstree-context");
|
|
3249
|
+
}).bind(this)), this._data.contextmenu.visible = !0, l.vakata.context.show(c, { x: i, y: r }, a), this.trigger("show_contextmenu", { node: t, x: i, y: r });
|
|
3250
|
+
};
|
|
3251
|
+
}, function(e) {
|
|
3252
|
+
var s = !1, t = {
|
|
3253
|
+
element: !1,
|
|
3254
|
+
reference: !1,
|
|
3255
|
+
position_x: 0,
|
|
3256
|
+
position_y: 0,
|
|
3257
|
+
items: [],
|
|
3258
|
+
html: "",
|
|
3259
|
+
is_visible: !1
|
|
3260
|
+
};
|
|
3261
|
+
e.vakata.context = {
|
|
3262
|
+
settings: {
|
|
3263
|
+
hide_onmouseleave: 0,
|
|
3264
|
+
icons: !0
|
|
3265
|
+
},
|
|
3266
|
+
_trigger: function(i) {
|
|
3267
|
+
e(T).triggerHandler("context_" + i + ".vakata", {
|
|
3268
|
+
reference: t.reference,
|
|
3269
|
+
element: t.element,
|
|
3270
|
+
position: {
|
|
3271
|
+
x: t.position_x,
|
|
3272
|
+
y: t.position_y
|
|
3273
|
+
}
|
|
3274
|
+
});
|
|
3275
|
+
},
|
|
3276
|
+
_execute: function(i) {
|
|
3277
|
+
return i = t.items[i], i && (!i._disabled || e.vakata.is_function(i._disabled) && !i._disabled({ item: i, reference: t.reference, element: t.element })) && i.action ? i.action.call(null, {
|
|
3278
|
+
item: i,
|
|
3279
|
+
reference: t.reference,
|
|
3280
|
+
element: t.element,
|
|
3281
|
+
position: {
|
|
3282
|
+
x: t.position_x,
|
|
3283
|
+
y: t.position_y
|
|
3284
|
+
}
|
|
3285
|
+
}) : !1;
|
|
3286
|
+
},
|
|
3287
|
+
_parse: function(i, r) {
|
|
3288
|
+
if (!i)
|
|
3289
|
+
return !1;
|
|
3290
|
+
r || (t.html = "", t.items = []);
|
|
3291
|
+
var a = "", n = !1, c;
|
|
3292
|
+
return r && (a += "<ul>"), e.each(i, function(d, h) {
|
|
3293
|
+
if (!h)
|
|
3294
|
+
return !0;
|
|
3295
|
+
t.items.push(h), !n && h.separator_before && (a += "<li class='vakata-context-separator'><a href='#' " + (e.vakata.context.settings.icons ? "" : 'class="vakata-context-no-icons"') + "> </a></li>"), n = !1, a += "<li class='" + (h._class || "") + (h._disabled === !0 || e.vakata.is_function(h._disabled) && h._disabled({ item: h, reference: t.reference, element: t.element }) ? " vakata-contextmenu-disabled " : "") + "' " + (h.shortcut ? " data-shortcut='" + h.shortcut + "' " : "") + ">", a += "<a href='#' rel='" + (t.items.length - 1) + "' " + (h.title ? "title='" + h.title + "'" : "") + ">", e.vakata.context.settings.icons && (a += "<i ", h.icon && (h.icon.indexOf("/") !== -1 || h.icon.indexOf(".") !== -1 ? a += ` style='background:url("` + h.icon + `") center center no-repeat' ` : a += " class='" + h.icon + "' "), a += "></i><span class='vakata-contextmenu-sep'> </span>"), a += (e.vakata.is_function(h.label) ? h.label({ item: d, reference: t.reference, element: t.element }) : h.label) + (h.shortcut ? ' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-' + h.shortcut + '">' + (h.shortcut_label || "") + "</span>" : "") + "</a>", h.submenu && (c = e.vakata.context._parse(h.submenu, !0), c && (a += c)), a += "</li>", h.separator_after && (a += "<li class='vakata-context-separator'><a href='#' " + (e.vakata.context.settings.icons ? "" : 'class="vakata-context-no-icons"') + "> </a></li>", n = !0);
|
|
3296
|
+
}), a = a.replace(/<li class\='vakata-context-separator'\><\/li\>$/, ""), r && (a += "</ul>"), r || (t.html = a, e.vakata.context._trigger("parse")), a.length > 10 ? a : !1;
|
|
3297
|
+
},
|
|
3298
|
+
_show_submenu: function(i) {
|
|
3299
|
+
if (i = e(i), !(!i.length || !i.children("ul").length)) {
|
|
3300
|
+
var r = i.children("ul"), a = i.offset().left, n = a + i.outerWidth(), c = i.offset().top, d = r.width(), h = r.height(), o = e(window).width() + e(window).scrollLeft(), f = e(window).height() + e(window).scrollTop();
|
|
3301
|
+
s ? i[n - (d + 10 + i.outerWidth()) < 0 ? "addClass" : "removeClass"]("vakata-context-left") : i[n + d > o && a > o - n ? "addClass" : "removeClass"]("vakata-context-right"), c + h + 10 > f && r.css("bottom", "-1px"), i.hasClass("vakata-context-right") ? a < d && r.css("margin-right", a - d) : o - n < d && r.css("margin-left", o - n - d), r.show();
|
|
3302
|
+
}
|
|
3303
|
+
},
|
|
3304
|
+
show: function(i, r, a) {
|
|
3305
|
+
var n, c, d, h, o, f, _, u, g = !0;
|
|
3306
|
+
switch (t.element && t.element.length && t.element.width(""), g) {
|
|
3307
|
+
case (!r && !i):
|
|
3308
|
+
return !1;
|
|
3309
|
+
case (!!r && !!i):
|
|
3310
|
+
t.reference = i, t.position_x = r.x, t.position_y = r.y;
|
|
3311
|
+
break;
|
|
3312
|
+
case (!r && !!i):
|
|
3313
|
+
t.reference = i, n = i.offset(), t.position_x = n.left + i.outerHeight(), t.position_y = n.top;
|
|
3314
|
+
break;
|
|
3315
|
+
case (!!r && !i):
|
|
3316
|
+
t.position_x = r.x, t.position_y = r.y;
|
|
3317
|
+
break;
|
|
3318
|
+
}
|
|
3319
|
+
i && !a && e(i).data("vakata_contextmenu") && (a = e(i).data("vakata_contextmenu")), e.vakata.context._parse(a) && t.element.html(t.html), t.items.length && (t.element.appendTo(T.body), c = t.element, d = t.position_x, h = t.position_y, o = c.width(), f = c.height(), _ = e(window).width() + e(window).scrollLeft(), u = e(window).height() + e(window).scrollTop(), s && (d -= c.outerWidth() - e(i).outerWidth(), d < e(window).scrollLeft() + 20 && (d = e(window).scrollLeft() + 20)), d + o + 20 > _ && (d = _ - (o + 20)), h + f + 20 > u && (h = u - (f + 20)), t.element.css({ left: d, top: h }).show().find("a").first().trigger("focus").parent().addClass("vakata-context-hover"), t.is_visible = !0, e.vakata.context._trigger("show"));
|
|
3320
|
+
},
|
|
3321
|
+
hide: function() {
|
|
3322
|
+
t.is_visible && (t.element.hide().find("ul").hide().end().find(":focus").trigger("blur").end().detach(), t.is_visible = !1, e.vakata.context._trigger("hide"));
|
|
3323
|
+
}
|
|
3324
|
+
}, e(function() {
|
|
3325
|
+
s = e(T.body).css("direction") === "rtl";
|
|
3326
|
+
var i = !1;
|
|
3327
|
+
t.element = e("<ul class='vakata-context'></ul>"), t.element.on("mouseenter", "li", function(r) {
|
|
3328
|
+
r.stopImmediatePropagation(), !e.contains(this, r.relatedTarget) && (i && clearTimeout(i), t.element.find(".vakata-context-hover").removeClass("vakata-context-hover").end(), e(this).siblings().find("ul").hide().end().end().parentsUntil(".vakata-context", "li").addBack().addClass("vakata-context-hover"), e.vakata.context._show_submenu(this));
|
|
3329
|
+
}).on("mouseleave", "li", function(r) {
|
|
3330
|
+
e.contains(this, r.relatedTarget) || e(this).find(".vakata-context-hover").addBack().removeClass("vakata-context-hover");
|
|
3331
|
+
}).on("mouseleave", function(r) {
|
|
3332
|
+
e(this).find(".vakata-context-hover").removeClass("vakata-context-hover"), e.vakata.context.settings.hide_onmouseleave && (i = setTimeout(
|
|
3333
|
+
/* @__PURE__ */ function(a) {
|
|
3334
|
+
return function() {
|
|
3335
|
+
e.vakata.context.hide();
|
|
3336
|
+
};
|
|
3337
|
+
}(),
|
|
3338
|
+
e.vakata.context.settings.hide_onmouseleave
|
|
3339
|
+
));
|
|
3340
|
+
}).on("click", "a", function(r) {
|
|
3341
|
+
r.preventDefault(), !e(this).trigger("blur").parent().hasClass("vakata-context-disabled") && e.vakata.context._execute(e(this).attr("rel")) !== !1 && e.vakata.context.hide();
|
|
3342
|
+
}).on("keydown", "a", function(r) {
|
|
3343
|
+
var a = null;
|
|
3344
|
+
switch (r.which) {
|
|
3345
|
+
case 13:
|
|
3346
|
+
case 32:
|
|
3347
|
+
r.type = "click", r.preventDefault(), e(r.currentTarget).trigger(r);
|
|
3348
|
+
break;
|
|
3349
|
+
case 37:
|
|
3350
|
+
t.is_visible && (t.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children("a").trigger("focus"), r.stopImmediatePropagation(), r.preventDefault());
|
|
3351
|
+
break;
|
|
3352
|
+
case 38:
|
|
3353
|
+
t.is_visible && (a = t.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first(), a.length || (a = t.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last()), a.addClass("vakata-context-hover").children("a").trigger("focus"), r.stopImmediatePropagation(), r.preventDefault());
|
|
3354
|
+
break;
|
|
3355
|
+
case 39:
|
|
3356
|
+
t.is_visible && (t.element.find(".vakata-context-hover").last().children("ul").show().children("li:not(.vakata-context-separator)").removeClass("vakata-context-hover").first().addClass("vakata-context-hover").children("a").trigger("focus"), r.stopImmediatePropagation(), r.preventDefault());
|
|
3357
|
+
break;
|
|
3358
|
+
case 40:
|
|
3359
|
+
t.is_visible && (a = t.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first(), a.length || (a = t.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first()), a.addClass("vakata-context-hover").children("a").trigger("focus"), r.stopImmediatePropagation(), r.preventDefault());
|
|
3360
|
+
break;
|
|
3361
|
+
case 27:
|
|
3362
|
+
e.vakata.context.hide(), r.preventDefault();
|
|
3363
|
+
break;
|
|
3364
|
+
}
|
|
3365
|
+
}).on("keydown", function(r) {
|
|
3366
|
+
r.preventDefault();
|
|
3367
|
+
var a = t.element.find(".vakata-contextmenu-shortcut-" + r.which).parent();
|
|
3368
|
+
a.parent().not(".vakata-context-disabled") && a.trigger("click");
|
|
3369
|
+
}), e(T).on("mousedown.vakata.jstree", function(r) {
|
|
3370
|
+
t.is_visible && t.element[0] !== r.target && !e.contains(t.element[0], r.target) && e.vakata.context.hide();
|
|
3371
|
+
}).on("context_show.vakata.jstree", function(r, a) {
|
|
3372
|
+
t.element.find("li:has(ul)").children("a").addClass("vakata-context-parent"), s && t.element.addClass("vakata-context-rtl").css("direction", "rtl"), t.element.find("ul").hide().end();
|
|
3373
|
+
});
|
|
3374
|
+
});
|
|
3375
|
+
}(l), l.jstree.defaults.dnd = {
|
|
3376
|
+
/**
|
|
3377
|
+
* a boolean indicating if a copy should be possible while dragging (by pressint the meta key or Ctrl). Defaults to `true`.
|
|
3378
|
+
* @name $.jstree.defaults.dnd.copy
|
|
3379
|
+
* @plugin dnd
|
|
3380
|
+
*/
|
|
3381
|
+
copy: !0,
|
|
3382
|
+
/**
|
|
3383
|
+
* a number indicating how long a node should remain hovered while dragging to be opened. Defaults to `500`.
|
|
3384
|
+
* @name $.jstree.defaults.dnd.open_timeout
|
|
3385
|
+
* @plugin dnd
|
|
3386
|
+
*/
|
|
3387
|
+
open_timeout: 500,
|
|
3388
|
+
/**
|
|
3389
|
+
* a function invoked each time a node is about to be dragged, invoked in the tree's scope and receives the nodes about to be dragged as an argument (array) and the event that started the drag - return `false` to prevent dragging
|
|
3390
|
+
* @name $.jstree.defaults.dnd.is_draggable
|
|
3391
|
+
* @plugin dnd
|
|
3392
|
+
*/
|
|
3393
|
+
is_draggable: !0,
|
|
3394
|
+
/**
|
|
3395
|
+
* a boolean indicating if checks should constantly be made while the user is dragging the node (as opposed to checking only on drop), default is `true`
|
|
3396
|
+
* @name $.jstree.defaults.dnd.check_while_dragging
|
|
3397
|
+
* @plugin dnd
|
|
3398
|
+
*/
|
|
3399
|
+
check_while_dragging: !0,
|
|
3400
|
+
/**
|
|
3401
|
+
* a boolean indicating if nodes from this tree should only be copied with dnd (as opposed to moved), default is `false`
|
|
3402
|
+
* @name $.jstree.defaults.dnd.always_copy
|
|
3403
|
+
* @plugin dnd
|
|
3404
|
+
*/
|
|
3405
|
+
always_copy: !1,
|
|
3406
|
+
/**
|
|
3407
|
+
* when dropping a node "inside", this setting indicates the position the node should go to - it can be an integer or a string: "first" (same as 0) or "last", default is `0`
|
|
3408
|
+
* @name $.jstree.defaults.dnd.inside_pos
|
|
3409
|
+
* @plugin dnd
|
|
3410
|
+
*/
|
|
3411
|
+
inside_pos: 0,
|
|
3412
|
+
/**
|
|
3413
|
+
* when starting the drag on a node that is selected this setting controls if all selected nodes are dragged or only the single node, default is `true`, which means all selected nodes are dragged when the drag is started on a selected node
|
|
3414
|
+
* @name $.jstree.defaults.dnd.drag_selection
|
|
3415
|
+
* @plugin dnd
|
|
3416
|
+
*/
|
|
3417
|
+
drag_selection: !0,
|
|
3418
|
+
/**
|
|
3419
|
+
* controls whether dnd works on touch devices. If left as boolean true dnd will work the same as in desktop browsers, which in some cases may impair scrolling. If set to boolean false dnd will not work on touch devices. There is a special third option - string "selected" which means only selected nodes can be dragged on touch devices.
|
|
3420
|
+
* @name $.jstree.defaults.dnd.touch
|
|
3421
|
+
* @plugin dnd
|
|
3422
|
+
*/
|
|
3423
|
+
touch: !0,
|
|
3424
|
+
/**
|
|
3425
|
+
* controls whether items can be dropped anywhere on the node, not just on the anchor, by default only the node anchor is a valid drop target. Works best with the wholerow plugin. If enabled on mobile depending on the interface it might be hard for the user to cancel the drop, since the whole tree container will be a valid drop target.
|
|
3426
|
+
* @name $.jstree.defaults.dnd.large_drop_target
|
|
3427
|
+
* @plugin dnd
|
|
3428
|
+
*/
|
|
3429
|
+
large_drop_target: !1,
|
|
3430
|
+
/**
|
|
3431
|
+
* controls whether a drag can be initiated from any part of the node and not just the text/icon part, works best with the wholerow plugin. Keep in mind it can cause problems with tree scrolling on mobile depending on the interface - in that case set the touch option to "selected".
|
|
3432
|
+
* @name $.jstree.defaults.dnd.large_drag_target
|
|
3433
|
+
* @plugin dnd
|
|
3434
|
+
*/
|
|
3435
|
+
large_drag_target: !1,
|
|
3436
|
+
/**
|
|
3437
|
+
* controls whether use HTML5 dnd api instead of classical. That will allow better integration of dnd events with other HTML5 controls.
|
|
3438
|
+
* @reference http://caniuse.com/#feat=dragndrop
|
|
3439
|
+
* @name $.jstree.defaults.dnd.use_html5
|
|
3440
|
+
* @plugin dnd
|
|
3441
|
+
*/
|
|
3442
|
+
use_html5: !1,
|
|
3443
|
+
/**
|
|
3444
|
+
* controls whether items can be dropped anywhere on the tree.
|
|
3445
|
+
* @name $.jstree.defaults.dnd.blank_space_drop
|
|
3446
|
+
* @plugin dnd
|
|
3447
|
+
*/
|
|
3448
|
+
blank_space_drop: !1
|
|
3449
|
+
};
|
|
3450
|
+
var I, M;
|
|
3451
|
+
l.jstree.plugins.dnd = function(e, s) {
|
|
3452
|
+
this.init = function(t, i) {
|
|
3453
|
+
s.init.call(this, t, i), this.settings.dnd.use_html5 = this.settings.dnd.use_html5 && "draggable" in T.createElement("span");
|
|
3454
|
+
}, this.bind = function() {
|
|
3455
|
+
s.bind.call(this), this.element.on(this.settings.dnd.use_html5 ? "dragstart.jstree" : "mousedown.jstree touchstart.jstree", this.settings.dnd.large_drag_target ? ".jstree-node" : ".jstree-anchor", (function(t) {
|
|
3456
|
+
if (this.settings.dnd.large_drag_target && l(t.target).closest(".jstree-node")[0] !== t.currentTarget || t.type === "touchstart" && (!this.settings.dnd.touch || this.settings.dnd.touch === "selected" && !l(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").hasClass("jstree-clicked")))
|
|
3457
|
+
return !0;
|
|
3458
|
+
var i = this.get_node(t.target), r = this.is_selected(i) && this.settings.dnd.drag_selection ? this.get_top_selected().length : 1, a = r > 1 ? r + " " + this.get_string("nodes") : this.get_text(t.currentTarget);
|
|
3459
|
+
if (this.settings.core.force_text && (a = l.vakata.html.escape(a)), i && (i.id || i.id === 0) && i.id !== l.jstree.root && (t.which === 1 || t.type === "touchstart" || t.type === "dragstart") && (this.settings.dnd.is_draggable === !0 || l.vakata.is_function(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, r > 1 ? this.get_top_selected(!0) : [i], t)))
|
|
3460
|
+
if (I = { jstree: !0, origin: this, obj: this.get_node(i, !0), nodes: r > 1 ? this.get_top_selected() : [i.id] }, M = t.currentTarget, this.settings.dnd.use_html5)
|
|
3461
|
+
l.vakata.dnd._trigger("start", t, { helper: l(), element: M, data: I });
|
|
3462
|
+
else
|
|
3463
|
+
return this.element.trigger("mousedown.jstree"), l.vakata.dnd.start(t, I, '<div id="jstree-dnd" class="jstree-' + this.get_theme() + " jstree-" + this.get_theme() + "-" + this.get_theme_variant() + " " + (this.settings.core.themes.responsive ? " jstree-dnd-responsive" : "") + '"><i class="jstree-icon jstree-er"></i>' + a + '<ins class="jstree-copy">+</ins></div>');
|
|
3464
|
+
}).bind(this)), this.settings.dnd.use_html5 && this.element.on("dragover.jstree", function(t) {
|
|
3465
|
+
return t.preventDefault(), l.vakata.dnd._trigger("move", t, { helper: l(), element: M, data: I }), !1;
|
|
3466
|
+
}).on("drop.jstree", (function(t) {
|
|
3467
|
+
return t.preventDefault(), l.vakata.dnd._trigger("stop", t, { helper: l(), element: M, data: I }), !1;
|
|
3468
|
+
}).bind(this));
|
|
3469
|
+
}, this.redraw_node = function(t, i, r, a) {
|
|
3470
|
+
if (t = s.redraw_node.apply(this, arguments), t && this.settings.dnd.use_html5)
|
|
3471
|
+
if (this.settings.dnd.large_drag_target)
|
|
3472
|
+
t.setAttribute("draggable", !0);
|
|
3473
|
+
else {
|
|
3474
|
+
var n, c, d = null;
|
|
3475
|
+
for (n = 0, c = t.childNodes.length; n < c; n++)
|
|
3476
|
+
if (t.childNodes[n] && t.childNodes[n].className && t.childNodes[n].className.indexOf("jstree-anchor") !== -1) {
|
|
3477
|
+
d = t.childNodes[n];
|
|
3478
|
+
break;
|
|
3479
|
+
}
|
|
3480
|
+
d && d.setAttribute("draggable", !0);
|
|
3481
|
+
}
|
|
3482
|
+
return t;
|
|
3483
|
+
};
|
|
3484
|
+
}, l(function() {
|
|
3485
|
+
var e = !1, s = !1, t = !1, i = !1, r = l('<div id="jstree-marker"> </div>').hide();
|
|
3486
|
+
l(T).on("dragover.vakata.jstree", function(a) {
|
|
3487
|
+
M && l.vakata.dnd._trigger("move", a, { helper: l(), element: M, data: I });
|
|
3488
|
+
}).on("drop.vakata.jstree", function(a) {
|
|
3489
|
+
M && (l.vakata.dnd._trigger("stop", a, { helper: l(), element: M, data: I }), M = null, I = null);
|
|
3490
|
+
}).on("dnd_start.vakata.jstree", function(a, n) {
|
|
3491
|
+
e = !1, t = !1, !(!n || !n.data || !n.data.jstree) && r.appendTo(T.body);
|
|
3492
|
+
}).on("dnd_move.vakata.jstree", function(a, n) {
|
|
3493
|
+
var c = n.event.target !== t.target;
|
|
3494
|
+
if (i && (!n.event || n.event.type !== "dragover" || c) && clearTimeout(i), !(!n || !n.data || !n.data.jstree) && !(n.event.target.id && n.event.target.id === "jstree-marker")) {
|
|
3495
|
+
t = n.event;
|
|
3496
|
+
var d = l.jstree.reference(n.event.target), h = !1, o = !1, f = !1, _, u, g, p, m, N, O, x, A, K, P, C, S, L, F, J, v;
|
|
3497
|
+
if (d && d._data && d._data.dnd) {
|
|
3498
|
+
if (r.attr("class", "jstree-" + d.get_theme() + (d.settings.core.themes.responsive ? " jstree-dnd-responsive" : "")), F = n.data.origin && (n.data.origin.settings.dnd.always_copy || n.data.origin.settings.dnd.copy && (n.event.metaKey || n.event.ctrlKey)), n.helper.children().attr("class", "jstree-" + d.get_theme() + " jstree-" + d.get_theme() + "-" + d.get_theme_variant() + " " + (d.settings.core.themes.responsive ? " jstree-dnd-responsive" : "")).find(".jstree-copy").first()[F ? "show" : "hide"](), (n.event.target === d.element[0] || n.event.target === d.get_container_ul()[0]) && (d.get_container_ul().children().length === 0 || d.settings.dnd.blank_space_drop)) {
|
|
3499
|
+
for (O = !0, x = 0, A = n.data.nodes.length; x < A && (O = O && d.check(n.data.origin && (n.data.origin.settings.dnd.always_copy || n.data.origin.settings.dnd.copy && (n.event.metaKey || n.event.ctrlKey)) ? "copy_node" : "move_node", n.data.origin && n.data.origin !== d ? n.data.origin.get_node(n.data.nodes[x]) : n.data.nodes[x], l.jstree.root, "last", { dnd: !0, ref: d.get_node(l.jstree.root), pos: "i", origin: n.data.origin, is_multi: n.data.origin && n.data.origin !== d, is_foreign: !n.data.origin }), !!O); x++)
|
|
3500
|
+
;
|
|
3501
|
+
if (O) {
|
|
3502
|
+
e = { ins: d, par: l.jstree.root, pos: "last" }, r.hide(), n.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok"), n.event.originalEvent && n.event.originalEvent.dataTransfer && (n.event.originalEvent.dataTransfer.dropEffect = F ? "copy" : "move");
|
|
3503
|
+
return;
|
|
3504
|
+
}
|
|
3505
|
+
} else if (h = d.settings.dnd.large_drop_target ? l(n.event.target).closest(".jstree-node").children(".jstree-anchor") : l(n.event.target).closest(".jstree-anchor"), h && h.length && h.parent().is(".jstree-closed, .jstree-open, .jstree-leaf") && (o = h.offset(), f = (n.event.pageY !== y ? n.event.pageY : n.event.originalEvent.pageY) - o.top, g = h.outerHeight(), f < g / 3 ? N = ["b", "i", "a"] : f > g - g / 3 ? N = ["a", "i", "b"] : N = f > g / 2 ? ["i", "a", "b"] : ["i", "b", "a"], l.each(N, function(j, E) {
|
|
3506
|
+
switch (E) {
|
|
3507
|
+
case "b":
|
|
3508
|
+
_ = o.left - 6, u = o.top, p = d.get_parent(h), m = h.parent().index(), v = "jstree-below";
|
|
3509
|
+
break;
|
|
3510
|
+
case "i":
|
|
3511
|
+
S = d.settings.dnd.inside_pos, L = d.get_node(h.parent()), _ = o.left - 2, u = o.top + g / 2 + 1, p = L.id, m = S === "first" ? 0 : S === "last" ? L.children.length : Math.min(S, L.children.length), v = "jstree-inside";
|
|
3512
|
+
break;
|
|
3513
|
+
case "a":
|
|
3514
|
+
_ = o.left - 6, u = o.top + g, p = d.get_parent(h), m = h.parent().index() + 1, v = "jstree-above";
|
|
3515
|
+
break;
|
|
3516
|
+
}
|
|
3517
|
+
for (O = !0, x = 0, A = n.data.nodes.length; x < A; x++)
|
|
3518
|
+
if (K = n.data.origin && (n.data.origin.settings.dnd.always_copy || n.data.origin.settings.dnd.copy && (n.event.metaKey || n.event.ctrlKey)) ? "copy_node" : "move_node", P = m, K === "move_node" && E === "a" && n.data.origin && n.data.origin === d && p === d.get_parent(n.data.nodes[x]) && (C = d.get_node(p), P > l.inArray(n.data.nodes[x], C.children) && (P -= 1)), O = O && (d && d.settings && d.settings.dnd && d.settings.dnd.check_while_dragging === !1 || d.check(K, n.data.origin && n.data.origin !== d ? n.data.origin.get_node(n.data.nodes[x]) : n.data.nodes[x], p, P, { dnd: !0, ref: d.get_node(h.parent()), pos: E, origin: n.data.origin, is_multi: n.data.origin && n.data.origin !== d, is_foreign: !n.data.origin })), !O) {
|
|
3519
|
+
d && d.last_error && (s = d.last_error());
|
|
3520
|
+
break;
|
|
3521
|
+
}
|
|
3522
|
+
if (E === "i" && h.parent().is(".jstree-closed") && d.settings.dnd.open_timeout && (!n.event || n.event.type !== "dragover" || c) && (i && clearTimeout(i), i = setTimeout(/* @__PURE__ */ function(H, w) {
|
|
3523
|
+
return function() {
|
|
3524
|
+
H.open_node(w);
|
|
3525
|
+
};
|
|
3526
|
+
}(d, h), d.settings.dnd.open_timeout)), O)
|
|
3527
|
+
return J = d.get_node(p, !0), J.hasClass(".jstree-dnd-parent") || (l(".jstree-dnd-parent").removeClass("jstree-dnd-parent"), J.addClass("jstree-dnd-parent")), e = { ins: d, par: p, pos: E === "i" && S === "last" && m === 0 && !d.is_loaded(L) ? "last" : m }, r.css({ left: _ + "px", top: u + "px" }).show(), r.removeClass("jstree-above jstree-inside jstree-below").addClass(v), n.helper.find(".jstree-icon").first().removeClass("jstree-er").addClass("jstree-ok"), n.event.originalEvent && n.event.originalEvent.dataTransfer && (n.event.originalEvent.dataTransfer.dropEffect = F ? "copy" : "move"), s = {}, N = !0, !1;
|
|
3528
|
+
}), N === !0))
|
|
3529
|
+
return;
|
|
3530
|
+
}
|
|
3531
|
+
l(".jstree-dnd-parent").removeClass("jstree-dnd-parent"), e = !1, n.helper.find(".jstree-icon").removeClass("jstree-ok").addClass("jstree-er"), n.event.originalEvent && n.event.originalEvent.dataTransfer, r.hide();
|
|
3532
|
+
}
|
|
3533
|
+
}).on("dnd_scroll.vakata.jstree", function(a, n) {
|
|
3534
|
+
!n || !n.data || !n.data.jstree || (r.hide(), e = !1, t = !1, n.helper.find(".jstree-icon").first().removeClass("jstree-ok").addClass("jstree-er"));
|
|
3535
|
+
}).on("dnd_stop.vakata.jstree", function(a, n) {
|
|
3536
|
+
if (l(".jstree-dnd-parent").removeClass("jstree-dnd-parent"), i && clearTimeout(i), !(!n || !n.data || !n.data.jstree)) {
|
|
3537
|
+
r.hide().detach();
|
|
3538
|
+
var c, d, h = [];
|
|
3539
|
+
if (e) {
|
|
3540
|
+
for (c = 0, d = n.data.nodes.length; c < d; c++)
|
|
3541
|
+
h[c] = n.data.origin ? n.data.origin.get_node(n.data.nodes[c]) : n.data.nodes[c];
|
|
3542
|
+
e.ins[n.data.origin && (n.data.origin.settings.dnd.always_copy || n.data.origin.settings.dnd.copy && (n.event.metaKey || n.event.ctrlKey)) ? "copy_node" : "move_node"](h, e.par, e.pos, !1, !1, !1, n.data.origin);
|
|
3543
|
+
} else
|
|
3544
|
+
c = l(n.event.target).closest(".jstree"), c.length && s && s.error && s.error === "check" && (c = c.jstree(!0), c && c.settings.core.error.call(this, s));
|
|
3545
|
+
t = !1, e = !1;
|
|
3546
|
+
}
|
|
3547
|
+
}).on("keyup.jstree keydown.jstree", function(a, n) {
|
|
3548
|
+
n = l.vakata.dnd._get(), n && n.data && n.data.jstree && (a.type === "keyup" && a.which === 27 ? (i && clearTimeout(i), e = !1, s = !1, t = !1, i = !1, r.hide().detach(), l.vakata.dnd._clean()) : (n.helper.find(".jstree-copy").first()[n.data.origin && (n.data.origin.settings.dnd.always_copy || n.data.origin.settings.dnd.copy && (a.metaKey || a.ctrlKey)) ? "show" : "hide"](), t && (t.metaKey = a.metaKey, t.ctrlKey = a.ctrlKey, l.vakata.dnd._trigger("move", t))));
|
|
3549
|
+
});
|
|
3550
|
+
}), function(e) {
|
|
3551
|
+
e.vakata.html = {
|
|
3552
|
+
div: e("<div></div>"),
|
|
3553
|
+
escape: function(t) {
|
|
3554
|
+
return e.vakata.html.div.text(t).html();
|
|
3555
|
+
},
|
|
3556
|
+
strip: function(t) {
|
|
3557
|
+
return e.vakata.html.div.empty().append(e.parseHTML(t)).text();
|
|
3558
|
+
}
|
|
3559
|
+
};
|
|
3560
|
+
var s = {
|
|
3561
|
+
element: !1,
|
|
3562
|
+
target: !1,
|
|
3563
|
+
is_down: !1,
|
|
3564
|
+
is_drag: !1,
|
|
3565
|
+
helper: !1,
|
|
3566
|
+
helper_w: 0,
|
|
3567
|
+
data: !1,
|
|
3568
|
+
init_x: 0,
|
|
3569
|
+
init_y: 0,
|
|
3570
|
+
scroll_l: 0,
|
|
3571
|
+
scroll_t: 0,
|
|
3572
|
+
scroll_e: !1,
|
|
3573
|
+
scroll_i: !1,
|
|
3574
|
+
is_touch: !1
|
|
3575
|
+
};
|
|
3576
|
+
e.vakata.dnd = {
|
|
3577
|
+
settings: {
|
|
3578
|
+
scroll_speed: 10,
|
|
3579
|
+
scroll_proximity: 20,
|
|
3580
|
+
helper_left: 5,
|
|
3581
|
+
helper_top: 10,
|
|
3582
|
+
threshold: 5,
|
|
3583
|
+
threshold_touch: 10
|
|
3584
|
+
},
|
|
3585
|
+
_trigger: function(t, i, r) {
|
|
3586
|
+
r === y && (r = e.vakata.dnd._get()), r.event = i, e(T).triggerHandler("dnd_" + t + ".vakata", r);
|
|
3587
|
+
},
|
|
3588
|
+
_get: function() {
|
|
3589
|
+
return {
|
|
3590
|
+
data: s.data,
|
|
3591
|
+
element: s.element,
|
|
3592
|
+
helper: s.helper
|
|
3593
|
+
};
|
|
3594
|
+
},
|
|
3595
|
+
_clean: function() {
|
|
3596
|
+
s.helper && s.helper.remove(), s.scroll_i && (clearInterval(s.scroll_i), s.scroll_i = !1), s = {
|
|
3597
|
+
element: !1,
|
|
3598
|
+
target: !1,
|
|
3599
|
+
is_down: !1,
|
|
3600
|
+
is_drag: !1,
|
|
3601
|
+
helper: !1,
|
|
3602
|
+
helper_w: 0,
|
|
3603
|
+
data: !1,
|
|
3604
|
+
init_x: 0,
|
|
3605
|
+
init_y: 0,
|
|
3606
|
+
scroll_l: 0,
|
|
3607
|
+
scroll_t: 0,
|
|
3608
|
+
scroll_e: !1,
|
|
3609
|
+
scroll_i: !1,
|
|
3610
|
+
is_touch: !1
|
|
3611
|
+
}, M = null, e(T).off("mousemove.vakata.jstree touchmove.vakata.jstree", e.vakata.dnd.drag), e(T).off("mouseup.vakata.jstree touchend.vakata.jstree", e.vakata.dnd.stop);
|
|
3612
|
+
},
|
|
3613
|
+
_scroll: function(t) {
|
|
3614
|
+
if (!s.scroll_e || !s.scroll_l && !s.scroll_t)
|
|
3615
|
+
return s.scroll_i && (clearInterval(s.scroll_i), s.scroll_i = !1), !1;
|
|
3616
|
+
if (!s.scroll_i)
|
|
3617
|
+
return s.scroll_i = setInterval(e.vakata.dnd._scroll, 100), !1;
|
|
3618
|
+
if (t === !0)
|
|
3619
|
+
return !1;
|
|
3620
|
+
var i = s.scroll_e.scrollTop(), r = s.scroll_e.scrollLeft();
|
|
3621
|
+
s.scroll_e.scrollTop(i + s.scroll_t * e.vakata.dnd.settings.scroll_speed), s.scroll_e.scrollLeft(r + s.scroll_l * e.vakata.dnd.settings.scroll_speed), (i !== s.scroll_e.scrollTop() || r !== s.scroll_e.scrollLeft()) && e.vakata.dnd._trigger("scroll", s.scroll_e);
|
|
3622
|
+
},
|
|
3623
|
+
start: function(t, i, r) {
|
|
3624
|
+
t.type === "touchstart" && t.originalEvent && t.originalEvent.changedTouches && t.originalEvent.changedTouches[0] && (t.pageX = t.originalEvent.changedTouches[0].pageX, t.pageY = t.originalEvent.changedTouches[0].pageY, t.target = T.elementFromPoint(t.originalEvent.changedTouches[0].pageX - window.pageXOffset, t.originalEvent.changedTouches[0].pageY - window.pageYOffset)), s.is_drag && e.vakata.dnd.stop({});
|
|
3625
|
+
try {
|
|
3626
|
+
t.currentTarget.unselectable = "on", t.currentTarget.onselectstart = function() {
|
|
3627
|
+
return !1;
|
|
3628
|
+
}, t.currentTarget.style && (t.currentTarget.style.touchAction = "none", t.currentTarget.style.msTouchAction = "none", t.currentTarget.style.MozUserSelect = "none");
|
|
3629
|
+
} catch {
|
|
3630
|
+
}
|
|
3631
|
+
return s.init_x = t.pageX, s.init_y = t.pageY, s.data = i, s.is_down = !0, s.element = t.currentTarget, s.target = t.target, s.is_touch = t.type === "touchstart", r !== !1 && (s.helper = e("<div id='vakata-dnd'></div>").html(r).css({
|
|
3632
|
+
display: "block",
|
|
3633
|
+
margin: "0",
|
|
3634
|
+
padding: "0",
|
|
3635
|
+
position: "absolute",
|
|
3636
|
+
top: "-2000px",
|
|
3637
|
+
lineHeight: "16px",
|
|
3638
|
+
zIndex: "10000"
|
|
3639
|
+
})), e(T).on("mousemove.vakata.jstree touchmove.vakata.jstree", e.vakata.dnd.drag), e(T).on("mouseup.vakata.jstree touchend.vakata.jstree", e.vakata.dnd.stop), !1;
|
|
3640
|
+
},
|
|
3641
|
+
drag: function(t) {
|
|
3642
|
+
if (t.type === "touchmove" && t.originalEvent && t.originalEvent.changedTouches && t.originalEvent.changedTouches[0] && (t.pageX = t.originalEvent.changedTouches[0].pageX, t.pageY = t.originalEvent.changedTouches[0].pageY, t.target = T.elementFromPoint(t.originalEvent.changedTouches[0].pageX - window.pageXOffset, t.originalEvent.changedTouches[0].pageY - window.pageYOffset)), !!s.is_down) {
|
|
3643
|
+
if (!s.is_drag)
|
|
3644
|
+
if (Math.abs(t.pageX - s.init_x) > (s.is_touch ? e.vakata.dnd.settings.threshold_touch : e.vakata.dnd.settings.threshold) || Math.abs(t.pageY - s.init_y) > (s.is_touch ? e.vakata.dnd.settings.threshold_touch : e.vakata.dnd.settings.threshold))
|
|
3645
|
+
s.helper && (s.helper.appendTo(T.body), s.helper_w = s.helper.outerWidth()), s.is_drag = !0, e(s.target).one("click.vakata", !1), e.vakata.dnd._trigger("start", t);
|
|
3646
|
+
else
|
|
3647
|
+
return;
|
|
3648
|
+
var i = !1, r = !1, a = !1, n = !1, c = !1, d = !1, h = !1, o = !1, f = !1, _ = !1;
|
|
3649
|
+
return s.scroll_t = 0, s.scroll_l = 0, s.scroll_e = !1, e(e(t.target).parentsUntil("body").addBack().get().reverse()).filter(function() {
|
|
3650
|
+
return this.ownerDocument && /^auto|scroll$/.test(e(this).css("overflow")) && (this.scrollHeight > this.offsetHeight || this.scrollWidth > this.offsetWidth);
|
|
3651
|
+
}).each(function() {
|
|
3652
|
+
var u = e(this), g = u.offset();
|
|
3653
|
+
if (this.scrollHeight > this.offsetHeight && (g.top + u.height() - t.pageY < e.vakata.dnd.settings.scroll_proximity && (s.scroll_t = 1), t.pageY - g.top < e.vakata.dnd.settings.scroll_proximity && (s.scroll_t = -1)), this.scrollWidth > this.offsetWidth && (g.left + u.width() - t.pageX < e.vakata.dnd.settings.scroll_proximity && (s.scroll_l = 1), t.pageX - g.left < e.vakata.dnd.settings.scroll_proximity && (s.scroll_l = -1)), s.scroll_t || s.scroll_l)
|
|
3654
|
+
return s.scroll_e = e(this), !1;
|
|
3655
|
+
}), s.scroll_e || (i = e(T), r = e(window), a = i.height(), n = r.height(), c = i.width(), d = r.width(), h = i.scrollTop(), o = i.scrollLeft(), a > n && t.pageY - h < e.vakata.dnd.settings.scroll_proximity && (s.scroll_t = -1), a > n && n - (t.pageY - h) < e.vakata.dnd.settings.scroll_proximity && (s.scroll_t = 1), c > d && t.pageX - o < e.vakata.dnd.settings.scroll_proximity && (s.scroll_l = -1), c > d && d - (t.pageX - o) < e.vakata.dnd.settings.scroll_proximity && (s.scroll_l = 1), (s.scroll_t || s.scroll_l) && (s.scroll_e = i)), s.scroll_e && e.vakata.dnd._scroll(!0), s.helper && (f = parseInt(t.pageY + e.vakata.dnd.settings.helper_top, 10), _ = parseInt(t.pageX + e.vakata.dnd.settings.helper_left, 10), a && f + 25 > a && (f = a - 50), c && _ + s.helper_w > c && (_ = c - (s.helper_w + 2)), s.helper.css({
|
|
3656
|
+
left: _ + "px",
|
|
3657
|
+
top: f + "px"
|
|
3658
|
+
})), e.vakata.dnd._trigger("move", t), !1;
|
|
3659
|
+
}
|
|
3660
|
+
},
|
|
3661
|
+
stop: function(t) {
|
|
3662
|
+
if (t.type === "touchend" && t.originalEvent && t.originalEvent.changedTouches && t.originalEvent.changedTouches[0] && (t.pageX = t.originalEvent.changedTouches[0].pageX, t.pageY = t.originalEvent.changedTouches[0].pageY, t.target = T.elementFromPoint(t.originalEvent.changedTouches[0].pageX - window.pageXOffset, t.originalEvent.changedTouches[0].pageY - window.pageYOffset)), s.is_drag)
|
|
3663
|
+
t.target !== s.target && e(s.target).off("click.vakata"), e.vakata.dnd._trigger("stop", t);
|
|
3664
|
+
else if (t.type === "touchend" && t.target === s.target) {
|
|
3665
|
+
var i = setTimeout(function() {
|
|
3666
|
+
e(t.target).trigger("click");
|
|
3667
|
+
}, 100);
|
|
3668
|
+
e(t.target).one("click", function() {
|
|
3669
|
+
i && clearTimeout(i);
|
|
3670
|
+
});
|
|
3671
|
+
}
|
|
3672
|
+
return e.vakata.dnd._clean(), !1;
|
|
3673
|
+
}
|
|
3674
|
+
};
|
|
3675
|
+
}(l), l.jstree.defaults.massload = null, l.jstree.plugins.massload = function(e, s) {
|
|
3676
|
+
this.init = function(t, i) {
|
|
3677
|
+
this._data.massload = {}, s.init.call(this, t, i);
|
|
3678
|
+
}, this._load_nodes = function(t, i, r, a) {
|
|
3679
|
+
var n = this.settings.massload, c = [], d = this._model.data, h, o, f;
|
|
3680
|
+
if (!r) {
|
|
3681
|
+
for (h = 0, o = t.length; h < o; h++)
|
|
3682
|
+
(!d[t[h]] || !d[t[h]].state.loaded && !d[t[h]].state.failed || a) && (c.push(t[h]), f = this.get_node(t[h], !0), f && f.length && f.addClass("jstree-loading").attr("aria-busy", !0));
|
|
3683
|
+
if (this._data.massload = {}, c.length) {
|
|
3684
|
+
if (l.vakata.is_function(n))
|
|
3685
|
+
return n.call(this, c, (function(_) {
|
|
3686
|
+
var u, g;
|
|
3687
|
+
if (_)
|
|
3688
|
+
for (u in _)
|
|
3689
|
+
_.hasOwnProperty(u) && (this._data.massload[u] = _[u]);
|
|
3690
|
+
for (u = 0, g = t.length; u < g; u++)
|
|
3691
|
+
f = this.get_node(t[u], !0), f && f.length && f.removeClass("jstree-loading").attr("aria-busy", !1);
|
|
3692
|
+
s._load_nodes.call(this, t, i, r, a);
|
|
3693
|
+
}).bind(this));
|
|
3694
|
+
if (typeof n == "object" && n && n.url)
|
|
3695
|
+
return n = l.extend(!0, {}, n), l.vakata.is_function(n.url) && (n.url = n.url.call(this, c)), l.vakata.is_function(n.data) && (n.data = n.data.call(this, c)), l.ajax(n).done((function(_, u, g) {
|
|
3696
|
+
var p, m;
|
|
3697
|
+
if (_)
|
|
3698
|
+
for (p in _)
|
|
3699
|
+
_.hasOwnProperty(p) && (this._data.massload[p] = _[p]);
|
|
3700
|
+
for (p = 0, m = t.length; p < m; p++)
|
|
3701
|
+
f = this.get_node(t[p], !0), f && f.length && f.removeClass("jstree-loading").attr("aria-busy", !1);
|
|
3702
|
+
s._load_nodes.call(this, t, i, r, a);
|
|
3703
|
+
}).bind(this)).fail((function(_) {
|
|
3704
|
+
s._load_nodes.call(this, t, i, r, a);
|
|
3705
|
+
}).bind(this));
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
return s._load_nodes.call(this, t, i, r, a);
|
|
3709
|
+
}, this._load_node = function(t, i) {
|
|
3710
|
+
var r = this._data.massload[t.id], a = null, n;
|
|
3711
|
+
return r ? (a = this[typeof r == "string" ? "_append_html_data" : "_append_json_data"](
|
|
3712
|
+
t,
|
|
3713
|
+
typeof r == "string" ? l(l.parseHTML(r)).filter(function() {
|
|
3714
|
+
return this.nodeType !== 3;
|
|
3715
|
+
}) : r,
|
|
3716
|
+
function(c) {
|
|
3717
|
+
i.call(this, c);
|
|
3718
|
+
}
|
|
3719
|
+
), n = this.get_node(t.id, !0), n && n.length && n.removeClass("jstree-loading").attr("aria-busy", !1), delete this._data.massload[t.id], a) : s._load_node.call(this, t, i);
|
|
3720
|
+
};
|
|
3721
|
+
}, l.jstree.defaults.search = {
|
|
3722
|
+
/**
|
|
3723
|
+
* a jQuery-like AJAX config, which jstree uses if a server should be queried for results.
|
|
3724
|
+
*
|
|
3725
|
+
* A `str` (which is the search string) parameter will be added with the request, an optional `inside` parameter will be added if the search is limited to a node id. The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed.
|
|
3726
|
+
* Leave this setting as `false` to not query the server. You can also set this to a function, which will be invoked in the instance's scope and receive 3 parameters - the search string, the callback to call with the array of nodes to load, and the optional node ID to limit the search to
|
|
3727
|
+
* @name $.jstree.defaults.search.ajax
|
|
3728
|
+
* @plugin search
|
|
3729
|
+
*/
|
|
3730
|
+
ajax: !1,
|
|
3731
|
+
/**
|
|
3732
|
+
* Indicates if the search should be fuzzy or not (should `chnd3` match `child node 3`). Default is `false`.
|
|
3733
|
+
* @name $.jstree.defaults.search.fuzzy
|
|
3734
|
+
* @plugin search
|
|
3735
|
+
*/
|
|
3736
|
+
fuzzy: !1,
|
|
3737
|
+
/**
|
|
3738
|
+
* Indicates if the search should be case sensitive. Default is `false`.
|
|
3739
|
+
* @name $.jstree.defaults.search.case_sensitive
|
|
3740
|
+
* @plugin search
|
|
3741
|
+
*/
|
|
3742
|
+
case_sensitive: !1,
|
|
3743
|
+
/**
|
|
3744
|
+
* Indicates if the tree should be filtered (by default) to show only matching nodes (keep in mind this can be a heavy on large trees in old browsers).
|
|
3745
|
+
* This setting can be changed at runtime when calling the search method. Default is `false`.
|
|
3746
|
+
* @name $.jstree.defaults.search.show_only_matches
|
|
3747
|
+
* @plugin search
|
|
3748
|
+
*/
|
|
3749
|
+
show_only_matches: !1,
|
|
3750
|
+
/**
|
|
3751
|
+
* Indicates if the children of matched element are shown (when show_only_matches is true)
|
|
3752
|
+
* This setting can be changed at runtime when calling the search method. Default is `false`.
|
|
3753
|
+
* @name $.jstree.defaults.search.show_only_matches_children
|
|
3754
|
+
* @plugin search
|
|
3755
|
+
*/
|
|
3756
|
+
show_only_matches_children: !1,
|
|
3757
|
+
/**
|
|
3758
|
+
* Indicates if all nodes opened to reveal the search result, should be closed when the search is cleared or a new search is performed. Default is `true`.
|
|
3759
|
+
* @name $.jstree.defaults.search.close_opened_onclear
|
|
3760
|
+
* @plugin search
|
|
3761
|
+
*/
|
|
3762
|
+
close_opened_onclear: !0,
|
|
3763
|
+
/**
|
|
3764
|
+
* Indicates if only leaf nodes should be included in search results. Default is `false`.
|
|
3765
|
+
* @name $.jstree.defaults.search.search_leaves_only
|
|
3766
|
+
* @plugin search
|
|
3767
|
+
*/
|
|
3768
|
+
search_leaves_only: !1,
|
|
3769
|
+
/**
|
|
3770
|
+
* If set to a function it wil be called in the instance's scope with two arguments - search string and node (where node will be every node in the structure, so use with caution).
|
|
3771
|
+
* If the function returns a truthy value the node will be considered a match (it might not be displayed if search_only_leaves is set to true and the node is not a leaf). Default is `false`.
|
|
3772
|
+
* @name $.jstree.defaults.search.search_callback
|
|
3773
|
+
* @plugin search
|
|
3774
|
+
*/
|
|
3775
|
+
search_callback: !1
|
|
3776
|
+
}, l.jstree.plugins.search = function(e, s) {
|
|
3777
|
+
this.bind = function() {
|
|
3778
|
+
s.bind.call(this), this._data.search.str = "", this._data.search.dom = l(), this._data.search.res = [], this._data.search.opn = [], this._data.search.som = !1, this._data.search.smc = !1, this._data.search.hdn = [], this.element.on("search.jstree", (function(t, i) {
|
|
3779
|
+
if (this._data.search.som && i.res.length) {
|
|
3780
|
+
var r = this._model.data, a, n, c = [], d, h;
|
|
3781
|
+
for (a = 0, n = i.res.length; a < n; a++)
|
|
3782
|
+
if (r[i.res[a]] && !r[i.res[a]].state.hidden && (c.push(i.res[a]), c = c.concat(r[i.res[a]].parents), this._data.search.smc))
|
|
3783
|
+
for (d = 0, h = r[i.res[a]].children_d.length; d < h; d++)
|
|
3784
|
+
r[r[i.res[a]].children_d[d]] && !r[r[i.res[a]].children_d[d]].state.hidden && c.push(r[i.res[a]].children_d[d]);
|
|
3785
|
+
c = l.vakata.array_remove_item(l.vakata.array_unique(c), l.jstree.root), this._data.search.hdn = this.hide_all(!0), this.show_node(c, !0), this.redraw(!0);
|
|
3786
|
+
}
|
|
3787
|
+
}).bind(this)).on("clear_search.jstree", (function(t, i) {
|
|
3788
|
+
this._data.search.som && i.res.length && (this.show_node(this._data.search.hdn, !0), this.redraw(!0));
|
|
3789
|
+
}).bind(this));
|
|
3790
|
+
}, this.search = function(t, i, r, a, n, c) {
|
|
3791
|
+
if (t === !1 || l.vakata.trim(t.toString()) === "")
|
|
3792
|
+
return this.clear_search();
|
|
3793
|
+
a = this.get_node(a), a = a && (a.id || a.id === 0) ? a.id : null, t = t.toString();
|
|
3794
|
+
var d = this.settings.search, h = d.ajax ? d.ajax : !1, o = this._model.data, f = null, _ = [], u = [], g, p;
|
|
3795
|
+
if (this._data.search.res.length && !n && this.clear_search(), r === y && (r = d.show_only_matches), c === y && (c = d.show_only_matches_children), !i && h !== !1)
|
|
3796
|
+
return l.vakata.is_function(h) ? h.call(this, t, (function(m) {
|
|
3797
|
+
m && m.d && (m = m.d), this._load_nodes(l.vakata.is_array(m) ? l.vakata.array_unique(m) : [], function() {
|
|
3798
|
+
this.search(t, !0, r, a, n, c);
|
|
3799
|
+
});
|
|
3800
|
+
}).bind(this), a) : (h = l.extend({}, h), h.data || (h.data = {}), h.data.str = t, a && (h.data.inside = a), this._data.search.lastRequest && this._data.search.lastRequest.abort(), this._data.search.lastRequest = l.ajax(h).fail((function() {
|
|
3801
|
+
this._data.core.last_error = { error: "ajax", plugin: "search", id: "search_01", reason: "Could not load search parents", data: JSON.stringify(h) }, this.settings.core.error.call(this, this._data.core.last_error);
|
|
3802
|
+
}).bind(this)).done((function(m) {
|
|
3803
|
+
m && m.d && (m = m.d), this._load_nodes(l.vakata.is_array(m) ? l.vakata.array_unique(m) : [], function() {
|
|
3804
|
+
this.search(t, !0, r, a, n, c);
|
|
3805
|
+
});
|
|
3806
|
+
}).bind(this)), this._data.search.lastRequest);
|
|
3807
|
+
if (n || (this._data.search.str = t, this._data.search.dom = l(), this._data.search.res = [], this._data.search.opn = [], this._data.search.som = r, this._data.search.smc = c), f = new l.vakata.search(t, !0, { caseSensitive: d.case_sensitive, fuzzy: d.fuzzy }), l.each(o[a || l.jstree.root].children_d, function(m, N) {
|
|
3808
|
+
var O = o[N];
|
|
3809
|
+
O.text && !O.state.hidden && (!d.search_leaves_only || O.state.loaded && O.children.length === 0) && (d.search_callback && d.search_callback.call(this, t, O) || !d.search_callback && f.search(O.text).isMatch) && (_.push(N), u = u.concat(O.parents));
|
|
3810
|
+
}), _.length) {
|
|
3811
|
+
for (u = l.vakata.array_unique(u), g = 0, p = u.length; g < p; g++)
|
|
3812
|
+
u[g] !== l.jstree.root && o[u[g]] && this.open_node(u[g], null, 0) === !0 && this._data.search.opn.push(u[g]);
|
|
3813
|
+
n ? (this._data.search.dom = this._data.search.dom.add(l(this.element[0].querySelectorAll("#" + l.map(_, function(m) {
|
|
3814
|
+
return "0123456789".indexOf(m[0]) !== -1 ? "\\3" + m[0] + " " + m.substr(1).replace(l.jstree.idregex, "\\$&") : m.replace(l.jstree.idregex, "\\$&");
|
|
3815
|
+
}).join(", #")))), this._data.search.res = l.vakata.array_unique(this._data.search.res.concat(_))) : (this._data.search.dom = l(this.element[0].querySelectorAll("#" + l.map(_, function(m) {
|
|
3816
|
+
return "0123456789".indexOf(m[0]) !== -1 ? "\\3" + m[0] + " " + m.substr(1).replace(l.jstree.idregex, "\\$&") : m.replace(l.jstree.idregex, "\\$&");
|
|
3817
|
+
}).join(", #"))), this._data.search.res = _), this._data.search.dom.children(".jstree-anchor").addClass("jstree-search");
|
|
3818
|
+
}
|
|
3819
|
+
this.trigger("search", { nodes: this._data.search.dom, str: t, res: this._data.search.res, show_only_matches: r });
|
|
3820
|
+
}, this.clear_search = function() {
|
|
3821
|
+
this.settings.search.close_opened_onclear && this.close_node(this._data.search.opn, 0), this.trigger("clear_search", { nodes: this._data.search.dom, str: this._data.search.str, res: this._data.search.res }), this._data.search.res.length && (this._data.search.dom = l(this.element[0].querySelectorAll("#" + l.map(this._data.search.res, function(t) {
|
|
3822
|
+
return "0123456789".indexOf(t[0]) !== -1 ? "\\3" + t[0] + " " + t.substr(1).replace(l.jstree.idregex, "\\$&") : t.replace(l.jstree.idregex, "\\$&");
|
|
3823
|
+
}).join(", #"))), this._data.search.dom.children(".jstree-anchor").removeClass("jstree-search")), this._data.search.str = "", this._data.search.res = [], this._data.search.opn = [], this._data.search.dom = l();
|
|
3824
|
+
}, this.redraw_node = function(t, i, r, a) {
|
|
3825
|
+
if (t = s.redraw_node.apply(this, arguments), t && l.inArray(t.id, this._data.search.res) !== -1) {
|
|
3826
|
+
var n, c, d = null;
|
|
3827
|
+
for (n = 0, c = t.childNodes.length; n < c; n++)
|
|
3828
|
+
if (t.childNodes[n] && t.childNodes[n].className && t.childNodes[n].className.indexOf("jstree-anchor") !== -1) {
|
|
3829
|
+
d = t.childNodes[n];
|
|
3830
|
+
break;
|
|
3831
|
+
}
|
|
3832
|
+
d && (d.className += " jstree-search");
|
|
3833
|
+
}
|
|
3834
|
+
return t;
|
|
3835
|
+
};
|
|
3836
|
+
}, function(e) {
|
|
3837
|
+
e.vakata.search = function(s, t, i) {
|
|
3838
|
+
i = i || {}, i = e.extend({}, e.vakata.search.defaults, i), i.fuzzy !== !1 && (i.fuzzy = !0), s = i.caseSensitive ? s : s.toLowerCase();
|
|
3839
|
+
var r = i.location, a = i.distance, n = i.threshold, c = s.length, d, h, o, f;
|
|
3840
|
+
return c > 32 && (i.fuzzy = !1), i.fuzzy && (d = 1 << c - 1, h = function() {
|
|
3841
|
+
var _ = {}, u = 0;
|
|
3842
|
+
for (u = 0; u < c; u++)
|
|
3843
|
+
_[s.charAt(u)] = 0;
|
|
3844
|
+
for (u = 0; u < c; u++)
|
|
3845
|
+
_[s.charAt(u)] |= 1 << c - u - 1;
|
|
3846
|
+
return _;
|
|
3847
|
+
}(), o = function(_, u) {
|
|
3848
|
+
var g = _ / c, p = Math.abs(r - u);
|
|
3849
|
+
return a ? g + p / a : p ? 1 : g;
|
|
3850
|
+
}), f = function(_) {
|
|
3851
|
+
if (_ = i.caseSensitive ? _.toString() : _.toString().toLowerCase(), s === _ || _.indexOf(s) !== -1)
|
|
3852
|
+
return {
|
|
3853
|
+
isMatch: !0,
|
|
3854
|
+
score: 0
|
|
3855
|
+
};
|
|
3856
|
+
if (!i.fuzzy)
|
|
3857
|
+
return {
|
|
3858
|
+
isMatch: !1,
|
|
3859
|
+
score: 1
|
|
3860
|
+
};
|
|
3861
|
+
var u, g, p = _.length, m = n, N = _.indexOf(s, r), O, x, A = c + p, K, P, C, S, L, F = 1;
|
|
3862
|
+
for (N !== -1 && (m = Math.min(o(0, N), m), N = _.lastIndexOf(s, r + c), N !== -1 && (m = Math.min(o(0, N), m))), N = -1, u = 0; u < c; u++) {
|
|
3863
|
+
for (O = 0, x = A; O < x; )
|
|
3864
|
+
o(u, r + x) <= m ? O = x : A = x, x = Math.floor((A - O) / 2 + O);
|
|
3865
|
+
for (A = x, P = Math.max(1, r - x + 1), C = Math.min(r + x, p) + c, S = new Array(C + 2), S[C + 1] = (1 << u) - 1, g = C; g >= P; g--)
|
|
3866
|
+
if (L = h[_.charAt(g - 1)], u === 0 ? S[g] = (S[g + 1] << 1 | 1) & L : S[g] = (S[g + 1] << 1 | 1) & L | ((K[g + 1] | K[g]) << 1 | 1) | K[g + 1], S[g] & d && (F = o(u, g - 1), F <= m))
|
|
3867
|
+
if (m = F, N = g - 1, N > r)
|
|
3868
|
+
P = Math.max(1, 2 * r - N);
|
|
3869
|
+
else
|
|
3870
|
+
break;
|
|
3871
|
+
if (o(u + 1, r) > m)
|
|
3872
|
+
break;
|
|
3873
|
+
K = S;
|
|
3874
|
+
}
|
|
3875
|
+
return {
|
|
3876
|
+
isMatch: N >= 0,
|
|
3877
|
+
score: F
|
|
3878
|
+
};
|
|
3879
|
+
}, t === !0 ? { search: f } : f(t);
|
|
3880
|
+
}, e.vakata.search.defaults = {
|
|
3881
|
+
location: 0,
|
|
3882
|
+
distance: 100,
|
|
3883
|
+
threshold: 0.6,
|
|
3884
|
+
fuzzy: !1,
|
|
3885
|
+
caseSensitive: !1
|
|
3886
|
+
};
|
|
3887
|
+
}(l), l.jstree.defaults.sort = function(e, s) {
|
|
3888
|
+
return this.get_text(e) > this.get_text(s) ? 1 : -1;
|
|
3889
|
+
}, l.jstree.plugins.sort = function(e, s) {
|
|
3890
|
+
this.bind = function() {
|
|
3891
|
+
s.bind.call(this), this.element.on("model.jstree", (function(t, i) {
|
|
3892
|
+
this.sort(i.parent, !0);
|
|
3893
|
+
}).bind(this)).on("rename_node.jstree create_node.jstree", (function(t, i) {
|
|
3894
|
+
this.sort(i.parent || i.node.parent, !1), this.redraw_node(i.parent || i.node.parent, !0);
|
|
3895
|
+
}).bind(this)).on("move_node.jstree copy_node.jstree", (function(t, i) {
|
|
3896
|
+
this.sort(i.parent, !1), this.redraw_node(i.parent, !0);
|
|
3897
|
+
}).bind(this));
|
|
3898
|
+
}, this.sort = function(t, i) {
|
|
3899
|
+
var r, a;
|
|
3900
|
+
if (t = this.get_node(t), t && t.children && t.children.length && (t.children.sort(this.settings.sort.bind(this)), i))
|
|
3901
|
+
for (r = 0, a = t.children_d.length; r < a; r++)
|
|
3902
|
+
this.sort(t.children_d[r], !1);
|
|
3903
|
+
};
|
|
3904
|
+
};
|
|
3905
|
+
var Q = !1;
|
|
3906
|
+
l.jstree.defaults.state = {
|
|
3907
|
+
/**
|
|
3908
|
+
* A string for the key to use when saving the current tree (change if using multiple trees in your project). Defaults to `jstree`.
|
|
3909
|
+
* @name $.jstree.defaults.state.key
|
|
3910
|
+
* @plugin state
|
|
3911
|
+
*/
|
|
3912
|
+
key: "jstree",
|
|
3913
|
+
/**
|
|
3914
|
+
* A space separated list of events that trigger a state save. Defaults to `changed.jstree open_node.jstree close_node.jstree`.
|
|
3915
|
+
* @name $.jstree.defaults.state.events
|
|
3916
|
+
* @plugin state
|
|
3917
|
+
*/
|
|
3918
|
+
events: "changed.jstree open_node.jstree close_node.jstree check_node.jstree uncheck_node.jstree",
|
|
3919
|
+
/**
|
|
3920
|
+
* Time in milliseconds after which the state will expire. Defaults to 'false' meaning - no expire.
|
|
3921
|
+
* @name $.jstree.defaults.state.ttl
|
|
3922
|
+
* @plugin state
|
|
3923
|
+
*/
|
|
3924
|
+
ttl: !1,
|
|
3925
|
+
/**
|
|
3926
|
+
* A function that will be executed prior to restoring state with one argument - the state object. Can be used to clear unwanted parts of the state.
|
|
3927
|
+
* @name $.jstree.defaults.state.filter
|
|
3928
|
+
* @plugin state
|
|
3929
|
+
*/
|
|
3930
|
+
filter: !1,
|
|
3931
|
+
/**
|
|
3932
|
+
* Should loaded nodes be restored (setting this to true means that it is possible that the whole tree will be loaded for some users - use with caution). Defaults to `false`
|
|
3933
|
+
* @name $.jstree.defaults.state.preserve_loaded
|
|
3934
|
+
* @plugin state
|
|
3935
|
+
*/
|
|
3936
|
+
preserve_loaded: !1
|
|
3937
|
+
}, l.jstree.plugins.state = function(e, s) {
|
|
3938
|
+
this.bind = function() {
|
|
3939
|
+
s.bind.call(this);
|
|
3940
|
+
var t = (function() {
|
|
3941
|
+
this.element.on(this.settings.state.events, (function() {
|
|
3942
|
+
Q && clearTimeout(Q), Q = setTimeout((function() {
|
|
3943
|
+
this.save_state();
|
|
3944
|
+
}).bind(this), 100);
|
|
3945
|
+
}).bind(this)), this.trigger("state_ready");
|
|
3946
|
+
}).bind(this);
|
|
3947
|
+
this.element.on("ready.jstree", (function(i, r) {
|
|
3948
|
+
this.element.one("restore_state.jstree", t), this.restore_state() || t();
|
|
3949
|
+
}).bind(this));
|
|
3950
|
+
}, this.save_state = function() {
|
|
3951
|
+
var t = this.get_state();
|
|
3952
|
+
this.settings.state.preserve_loaded || delete t.core.loaded;
|
|
3953
|
+
var i = { state: t, ttl: this.settings.state.ttl, sec: +/* @__PURE__ */ new Date() };
|
|
3954
|
+
l.vakata.storage.set(this.settings.state.key, JSON.stringify(i));
|
|
3955
|
+
}, this.restore_state = function() {
|
|
3956
|
+
var t = l.vakata.storage.get(this.settings.state.key);
|
|
3957
|
+
if (t)
|
|
3958
|
+
try {
|
|
3959
|
+
t = JSON.parse(t);
|
|
3960
|
+
} catch {
|
|
3961
|
+
return !1;
|
|
3962
|
+
}
|
|
3963
|
+
return t && t.ttl && t.sec && +/* @__PURE__ */ new Date() - t.sec > t.ttl ? !1 : (t && t.state && (t = t.state), t && l.vakata.is_function(this.settings.state.filter) && (t = this.settings.state.filter.call(this, t)), t ? (this.settings.state.preserve_loaded || delete t.core.loaded, this.element.one("set_state.jstree", function(i, r) {
|
|
3964
|
+
r.instance.trigger("restore_state", { state: l.extend(!0, {}, t) });
|
|
3965
|
+
}), this.set_state(t), !0) : !1);
|
|
3966
|
+
}, this.clear_state = function() {
|
|
3967
|
+
return l.vakata.storage.del(this.settings.state.key);
|
|
3968
|
+
};
|
|
3969
|
+
}, function(e, s) {
|
|
3970
|
+
e.vakata.storage = {
|
|
3971
|
+
// simply specifying the functions in FF throws an error
|
|
3972
|
+
set: function(t, i) {
|
|
3973
|
+
return window.localStorage.setItem(t, i);
|
|
3974
|
+
},
|
|
3975
|
+
get: function(t) {
|
|
3976
|
+
return window.localStorage.getItem(t);
|
|
3977
|
+
},
|
|
3978
|
+
del: function(t) {
|
|
3979
|
+
return window.localStorage.removeItem(t);
|
|
3980
|
+
}
|
|
3981
|
+
};
|
|
3982
|
+
}(l), l.jstree.defaults.types = {
|
|
3983
|
+
default: {}
|
|
3984
|
+
}, l.jstree.defaults.types[l.jstree.root] = {}, l.jstree.plugins.types = function(e, s) {
|
|
3985
|
+
this.init = function(t, i) {
|
|
3986
|
+
var r, a;
|
|
3987
|
+
if (i && i.types && i.types.default) {
|
|
3988
|
+
for (r in i.types)
|
|
3989
|
+
if (r !== "default" && r !== l.jstree.root && i.types.hasOwnProperty(r))
|
|
3990
|
+
for (a in i.types.default)
|
|
3991
|
+
i.types.default.hasOwnProperty(a) && i.types[r][a] === y && (i.types[r][a] = i.types.default[a]);
|
|
3992
|
+
}
|
|
3993
|
+
s.init.call(this, t, i), this._model.data[l.jstree.root].type = l.jstree.root;
|
|
3994
|
+
}, this.refresh = function(t, i) {
|
|
3995
|
+
s.refresh.call(this, t, i), this._model.data[l.jstree.root].type = l.jstree.root;
|
|
3996
|
+
}, this.bind = function() {
|
|
3997
|
+
this.element.on("model.jstree", (function(t, i) {
|
|
3998
|
+
var r = this._model.data, a = i.nodes, n = this.settings.types, c, d, h = "default", o;
|
|
3999
|
+
for (c = 0, d = a.length; c < d; c++) {
|
|
4000
|
+
if (h = "default", r[a[c]].original && r[a[c]].original.type && n[r[a[c]].original.type] && (h = r[a[c]].original.type), r[a[c]].data && r[a[c]].data.jstree && r[a[c]].data.jstree.type && n[r[a[c]].data.jstree.type] && (h = r[a[c]].data.jstree.type), r[a[c]].type = h, r[a[c]].icon === !0 && n[h].icon !== y && (r[a[c]].icon = n[h].icon), n[h].li_attr !== y && typeof n[h].li_attr == "object") {
|
|
4001
|
+
for (o in n[h].li_attr)
|
|
4002
|
+
if (n[h].li_attr.hasOwnProperty(o)) {
|
|
4003
|
+
if (o === "id")
|
|
4004
|
+
continue;
|
|
4005
|
+
r[a[c]].li_attr[o] === y ? r[a[c]].li_attr[o] = n[h].li_attr[o] : o === "class" && (r[a[c]].li_attr.class = n[h].li_attr.class + " " + r[a[c]].li_attr.class);
|
|
4006
|
+
}
|
|
4007
|
+
}
|
|
4008
|
+
if (n[h].a_attr !== y && typeof n[h].a_attr == "object") {
|
|
4009
|
+
for (o in n[h].a_attr)
|
|
4010
|
+
if (n[h].a_attr.hasOwnProperty(o)) {
|
|
4011
|
+
if (o === "id")
|
|
4012
|
+
continue;
|
|
4013
|
+
r[a[c]].a_attr[o] === y ? r[a[c]].a_attr[o] = n[h].a_attr[o] : o === "href" && r[a[c]].a_attr[o] === "#" ? r[a[c]].a_attr.href = n[h].a_attr.href : o === "class" && (r[a[c]].a_attr.class = n[h].a_attr.class + " " + r[a[c]].a_attr.class);
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
r[l.jstree.root].type = l.jstree.root;
|
|
4018
|
+
}).bind(this)), s.bind.call(this);
|
|
4019
|
+
}, this.get_json = function(t, i, r) {
|
|
4020
|
+
var a, n, c = this._model.data, d = i ? l.extend(!0, {}, i, { no_id: !1 }) : {}, h = s.get_json.call(this, t, d, r);
|
|
4021
|
+
if (h === !1)
|
|
4022
|
+
return !1;
|
|
4023
|
+
if (l.vakata.is_array(h))
|
|
4024
|
+
for (a = 0, n = h.length; a < n; a++)
|
|
4025
|
+
h[a].type = (h[a].id || h[a].id === 0) && c[h[a].id] && c[h[a].id].type ? c[h[a].id].type : "default", i && i.no_id && (delete h[a].id, h[a].li_attr && h[a].li_attr.id && delete h[a].li_attr.id, h[a].a_attr && h[a].a_attr.id && delete h[a].a_attr.id);
|
|
4026
|
+
else
|
|
4027
|
+
h.type = (h.id || h.id === 0) && c[h.id] && c[h.id].type ? c[h.id].type : "default", i && i.no_id && (h = this._delete_ids(h));
|
|
4028
|
+
return h;
|
|
4029
|
+
}, this._delete_ids = function(t) {
|
|
4030
|
+
if (l.vakata.is_array(t)) {
|
|
4031
|
+
for (var i = 0, r = t.length; i < r; i++)
|
|
4032
|
+
t[i] = this._delete_ids(t[i]);
|
|
4033
|
+
return t;
|
|
4034
|
+
}
|
|
4035
|
+
return delete t.id, t.li_attr && t.li_attr.id && delete t.li_attr.id, t.a_attr && t.a_attr.id && delete t.a_attr.id, t.children && l.vakata.is_array(t.children) && (t.children = this._delete_ids(t.children)), t;
|
|
4036
|
+
}, this.check = function(t, i, r, a, n) {
|
|
4037
|
+
if (s.check.call(this, t, i, r, a, n) === !1)
|
|
4038
|
+
return !1;
|
|
4039
|
+
i = i && (i.id || i.id === 0) ? i : this.get_node(i), r = r && (r.id || r.id === 0) ? r : this.get_node(r);
|
|
4040
|
+
var c = i && (i.id || i.id === 0) ? n && n.origin ? n.origin : l.jstree.reference(i.id) : null, d, h, o, f;
|
|
4041
|
+
switch (c = c && c._model && c._model.data ? c._model.data : null, t) {
|
|
4042
|
+
case "create_node":
|
|
4043
|
+
case "move_node":
|
|
4044
|
+
case "copy_node":
|
|
4045
|
+
if (t !== "move_node" || l.inArray(i.id, r.children) === -1) {
|
|
4046
|
+
if (d = this.get_rules(r), d.max_children !== y && d.max_children !== -1 && d.max_children === r.children.length)
|
|
4047
|
+
return this._data.core.last_error = { error: "check", plugin: "types", id: "types_01", reason: "max_children prevents function: " + t, data: JSON.stringify({ chk: t, pos: a, obj: i && (i.id || i.id === 0) ? i.id : !1, par: r && (r.id || r.id === 0) ? r.id : !1 }) }, !1;
|
|
4048
|
+
if (d.valid_children !== y && d.valid_children !== -1 && l.inArray(i.type || "default", d.valid_children) === -1)
|
|
4049
|
+
return this._data.core.last_error = { error: "check", plugin: "types", id: "types_02", reason: "valid_children prevents function: " + t, data: JSON.stringify({ chk: t, pos: a, obj: i && (i.id || i.id === 0) ? i.id : !1, par: r && (r.id || r.id === 0) ? r.id : !1 }) }, !1;
|
|
4050
|
+
if (c && i.children_d && i.parents) {
|
|
4051
|
+
for (h = 0, o = 0, f = i.children_d.length; o < f; o++)
|
|
4052
|
+
h = Math.max(h, c[i.children_d[o]].parents.length);
|
|
4053
|
+
h = h - i.parents.length + 1;
|
|
4054
|
+
}
|
|
4055
|
+
(h <= 0 || h === y) && (h = 1);
|
|
4056
|
+
do {
|
|
4057
|
+
if (d.max_depth !== y && d.max_depth !== -1 && d.max_depth < h)
|
|
4058
|
+
return this._data.core.last_error = { error: "check", plugin: "types", id: "types_03", reason: "max_depth prevents function: " + t, data: JSON.stringify({ chk: t, pos: a, obj: i && (i.id || i.id === 0) ? i.id : !1, par: r && (r.id || r.id === 0) ? r.id : !1 }) }, !1;
|
|
4059
|
+
r = this.get_node(r.parent), d = this.get_rules(r), h++;
|
|
4060
|
+
} while (r);
|
|
4061
|
+
}
|
|
4062
|
+
break;
|
|
4063
|
+
}
|
|
4064
|
+
return !0;
|
|
4065
|
+
}, this.get_rules = function(t) {
|
|
4066
|
+
if (t = this.get_node(t), !t)
|
|
4067
|
+
return !1;
|
|
4068
|
+
var i = this.get_type(t, !0);
|
|
4069
|
+
return i.max_depth === y && (i.max_depth = -1), i.max_children === y && (i.max_children = -1), i.valid_children === y && (i.valid_children = -1), i;
|
|
4070
|
+
}, this.get_type = function(t, i) {
|
|
4071
|
+
return t = this.get_node(t), t ? i ? l.extend({ type: t.type }, this.settings.types[t.type]) : t.type : !1;
|
|
4072
|
+
}, this.set_type = function(t, i) {
|
|
4073
|
+
var r = this._model.data, a, n, c, d, h, o, f, _;
|
|
4074
|
+
if (l.vakata.is_array(t)) {
|
|
4075
|
+
for (t = t.slice(), n = 0, c = t.length; n < c; n++)
|
|
4076
|
+
this.set_type(t[n], i);
|
|
4077
|
+
return !0;
|
|
4078
|
+
}
|
|
4079
|
+
if (a = this.settings.types, t = this.get_node(t), !a[i] || !t)
|
|
4080
|
+
return !1;
|
|
4081
|
+
if (f = this.get_node(t, !0), f && f.length && (_ = f.children(".jstree-anchor")), d = t.type, h = this.get_icon(t), t.type = i, (h === !0 || !a[d] || a[d].icon !== y && h === a[d].icon) && this.set_icon(t, a[i].icon !== y ? a[i].icon : !0), a[d] && a[d].li_attr !== y && typeof a[d].li_attr == "object") {
|
|
4082
|
+
for (o in a[d].li_attr)
|
|
4083
|
+
if (a[d].li_attr.hasOwnProperty(o)) {
|
|
4084
|
+
if (o === "id")
|
|
4085
|
+
continue;
|
|
4086
|
+
o === "class" ? (r[t.id].li_attr.class = (r[t.id].li_attr.class || "").replace(a[d].li_attr[o], ""), f && f.removeClass(a[d].li_attr[o])) : r[t.id].li_attr[o] === a[d].li_attr[o] && (r[t.id].li_attr[o] = null, f && f.removeAttr(o));
|
|
4087
|
+
}
|
|
4088
|
+
}
|
|
4089
|
+
if (a[d] && a[d].a_attr !== y && typeof a[d].a_attr == "object") {
|
|
4090
|
+
for (o in a[d].a_attr)
|
|
4091
|
+
if (a[d].a_attr.hasOwnProperty(o)) {
|
|
4092
|
+
if (o === "id")
|
|
4093
|
+
continue;
|
|
4094
|
+
o === "class" ? (r[t.id].a_attr.class = (r[t.id].a_attr.class || "").replace(a[d].a_attr[o], ""), _ && _.removeClass(a[d].a_attr[o])) : r[t.id].a_attr[o] === a[d].a_attr[o] && (o === "href" ? (r[t.id].a_attr[o] = "#", _ && _.attr("href", "#")) : (delete r[t.id].a_attr[o], _ && _.removeAttr(o)));
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
if (a[i].li_attr !== y && typeof a[i].li_attr == "object") {
|
|
4098
|
+
for (o in a[i].li_attr)
|
|
4099
|
+
if (a[i].li_attr.hasOwnProperty(o)) {
|
|
4100
|
+
if (o === "id")
|
|
4101
|
+
continue;
|
|
4102
|
+
r[t.id].li_attr[o] === y ? (r[t.id].li_attr[o] = a[i].li_attr[o], f && (o === "class" ? f.addClass(a[i].li_attr[o]) : f.attr(o, a[i].li_attr[o]))) : o === "class" && (r[t.id].li_attr.class = a[i].li_attr[o] + " " + r[t.id].li_attr.class, f && f.addClass(a[i].li_attr[o]));
|
|
4103
|
+
}
|
|
4104
|
+
}
|
|
4105
|
+
if (a[i].a_attr !== y && typeof a[i].a_attr == "object") {
|
|
4106
|
+
for (o in a[i].a_attr)
|
|
4107
|
+
if (a[i].a_attr.hasOwnProperty(o)) {
|
|
4108
|
+
if (o === "id")
|
|
4109
|
+
continue;
|
|
4110
|
+
r[t.id].a_attr[o] === y ? (r[t.id].a_attr[o] = a[i].a_attr[o], _ && (o === "class" ? _.addClass(a[i].a_attr[o]) : _.attr(o, a[i].a_attr[o]))) : o === "href" && r[t.id].a_attr[o] === "#" ? (r[t.id].a_attr.href = a[i].a_attr.href, _ && _.attr("href", a[i].a_attr.href)) : o === "class" && (r[t.id].a_attr.class = a[i].a_attr.class + " " + r[t.id].a_attr.class, _ && _.addClass(a[i].a_attr[o]));
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
return !0;
|
|
4114
|
+
};
|
|
4115
|
+
}, l.jstree.defaults.unique = {
|
|
4116
|
+
/**
|
|
4117
|
+
* Indicates if the comparison should be case sensitive. Default is `false`.
|
|
4118
|
+
* @name $.jstree.defaults.unique.case_sensitive
|
|
4119
|
+
* @plugin unique
|
|
4120
|
+
*/
|
|
4121
|
+
case_sensitive: !1,
|
|
4122
|
+
/**
|
|
4123
|
+
* Indicates if white space should be trimmed before the comparison. Default is `false`.
|
|
4124
|
+
* @name $.jstree.defaults.unique.trim_whitespace
|
|
4125
|
+
* @plugin unique
|
|
4126
|
+
*/
|
|
4127
|
+
trim_whitespace: !1,
|
|
4128
|
+
/**
|
|
4129
|
+
* A callback executed in the instance's scope when a new node is created with no name and a node with the default name already exists, the two arguments are the conflicting name and the counter. The default will produce results like `New node (2)`.
|
|
4130
|
+
* @name $.jstree.defaults.unique.duplicate
|
|
4131
|
+
* @plugin unique
|
|
4132
|
+
*/
|
|
4133
|
+
duplicate: function(e, s) {
|
|
4134
|
+
return e + " (" + s + ")";
|
|
4135
|
+
}
|
|
4136
|
+
}, l.jstree.plugins.unique = function(e, s) {
|
|
4137
|
+
this.check = function(t, i, r, a, n) {
|
|
4138
|
+
if (s.check.call(this, t, i, r, a, n) === !1)
|
|
4139
|
+
return !1;
|
|
4140
|
+
if (i = i && (i.id || i.id === 0) ? i : this.get_node(i), r = r && (r.id || r.id === 0) ? r : this.get_node(r), !r || !r.children)
|
|
4141
|
+
return !0;
|
|
4142
|
+
var c = t === "rename_node" ? a : i.text, d = [], h = this.settings.unique.case_sensitive, o = this.settings.unique.trim_whitespace, f = this._model.data, _, u, g;
|
|
4143
|
+
for (_ = 0, u = r.children.length; _ < u; _++)
|
|
4144
|
+
g = f[r.children[_]].text, h || (g = g.toLowerCase()), o && (g = g.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "")), d.push(g);
|
|
4145
|
+
switch (h || (c = c.toLowerCase()), o && (c = c.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "")), t) {
|
|
4146
|
+
case "delete_node":
|
|
4147
|
+
return !0;
|
|
4148
|
+
case "rename_node":
|
|
4149
|
+
return g = i.text || "", h || (g = g.toLowerCase()), o && (g = g.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "")), _ = l.inArray(c, d) === -1 || i.text && g === c, _ || (this._data.core.last_error = { error: "check", plugin: "unique", id: "unique_01", reason: "Child with name " + c + " already exists. Preventing: " + t, data: JSON.stringify({ chk: t, pos: a, obj: i && (i.id || i.id === 0) ? i.id : !1, par: r && (r.id || r.id === 0) ? r.id : !1 }) }), _;
|
|
4150
|
+
case "create_node":
|
|
4151
|
+
return _ = l.inArray(c, d) === -1, _ || (this._data.core.last_error = { error: "check", plugin: "unique", id: "unique_04", reason: "Child with name " + c + " already exists. Preventing: " + t, data: JSON.stringify({ chk: t, pos: a, obj: i && (i.id || i.id === 0) ? i.id : !1, par: r && (r.id || r.id === 0) ? r.id : !1 }) }), _;
|
|
4152
|
+
case "copy_node":
|
|
4153
|
+
return _ = l.inArray(c, d) === -1, _ || (this._data.core.last_error = { error: "check", plugin: "unique", id: "unique_02", reason: "Child with name " + c + " already exists. Preventing: " + t, data: JSON.stringify({ chk: t, pos: a, obj: i && (i.id || i.id === 0) ? i.id : !1, par: r && (r.id || r.id === 0) ? r.id : !1 }) }), _;
|
|
4154
|
+
case "move_node":
|
|
4155
|
+
return _ = i.parent === r.id && (!n || !n.is_multi) || l.inArray(c, d) === -1, _ || (this._data.core.last_error = { error: "check", plugin: "unique", id: "unique_03", reason: "Child with name " + c + " already exists. Preventing: " + t, data: JSON.stringify({ chk: t, pos: a, obj: i && (i.id || i.id === 0) ? i.id : !1, par: r && (r.id || r.id === 0) ? r.id : !1 }) }), _;
|
|
4156
|
+
}
|
|
4157
|
+
return !0;
|
|
4158
|
+
}, this.create_node = function(t, i, r, a, n) {
|
|
4159
|
+
if (!i || typeof i == "object" && i.text === y) {
|
|
4160
|
+
if (t === null && (t = l.jstree.root), t = this.get_node(t), !t)
|
|
4161
|
+
return s.create_node.call(this, t, i, r, a, n);
|
|
4162
|
+
if (r = r === y ? "last" : r, !r.toString().match(/^(before|after)$/) && !n && !this.is_loaded(t))
|
|
4163
|
+
return s.create_node.call(this, t, i, r, a, n);
|
|
4164
|
+
i || (i = {});
|
|
4165
|
+
var c, d, h, o, f, _ = this._model.data, u = this.settings.unique.case_sensitive, g = this.settings.unique.trim_whitespace, p = this.settings.unique.duplicate, m;
|
|
4166
|
+
for (d = c = this.get_string("New node"), h = [], o = 0, f = t.children.length; o < f; o++)
|
|
4167
|
+
m = _[t.children[o]].text, u || (m = m.toLowerCase()), g && (m = m.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "")), h.push(m);
|
|
4168
|
+
for (o = 1, m = d, u || (m = m.toLowerCase()), g && (m = m.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "")); l.inArray(m, h) !== -1; )
|
|
4169
|
+
d = p.call(this, c, ++o).toString(), m = d, u || (m = m.toLowerCase()), g && (m = m.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""));
|
|
4170
|
+
i.text = d;
|
|
4171
|
+
}
|
|
4172
|
+
return s.create_node.call(this, t, i, r, a, n);
|
|
4173
|
+
};
|
|
4174
|
+
};
|
|
4175
|
+
var U = T.createElement("DIV");
|
|
4176
|
+
if (U.setAttribute("unselectable", "on"), U.setAttribute("role", "presentation"), U.className = "jstree-wholerow", U.innerHTML = " ", l.jstree.plugins.wholerow = function(e, s) {
|
|
4177
|
+
this.bind = function() {
|
|
4178
|
+
s.bind.call(this), this.element.on("ready.jstree set_state.jstree", (function() {
|
|
4179
|
+
this.hide_dots();
|
|
4180
|
+
}).bind(this)).on("init.jstree loading.jstree ready.jstree", (function() {
|
|
4181
|
+
this.get_container_ul().addClass("jstree-wholerow-ul");
|
|
4182
|
+
}).bind(this)).on("deselect_all.jstree", (function(t, i) {
|
|
4183
|
+
this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");
|
|
4184
|
+
}).bind(this)).on("changed.jstree", (function(t, i) {
|
|
4185
|
+
this.element.find(".jstree-wholerow-clicked").removeClass("jstree-wholerow-clicked");
|
|
4186
|
+
var r = !1, a, n;
|
|
4187
|
+
for (a = 0, n = i.selected.length; a < n; a++)
|
|
4188
|
+
r = this.get_node(i.selected[a], !0), r && r.length && r.children(".jstree-wholerow").addClass("jstree-wholerow-clicked");
|
|
4189
|
+
}).bind(this)).on("open_node.jstree", (function(t, i) {
|
|
4190
|
+
this.get_node(i.node, !0).find(".jstree-clicked").parent().children(".jstree-wholerow").addClass("jstree-wholerow-clicked");
|
|
4191
|
+
}).bind(this)).on("hover_node.jstree dehover_node.jstree", (function(t, i) {
|
|
4192
|
+
t.type === "hover_node" && this.is_disabled(i.node) || this.get_node(i.node, !0).children(".jstree-wholerow")[t.type === "hover_node" ? "addClass" : "removeClass"]("jstree-wholerow-hovered");
|
|
4193
|
+
}).bind(this)).on("contextmenu.jstree", ".jstree-wholerow", (function(t) {
|
|
4194
|
+
if (this._data.contextmenu) {
|
|
4195
|
+
t.preventDefault();
|
|
4196
|
+
var i = l.Event("contextmenu", { metaKey: t.metaKey, ctrlKey: t.ctrlKey, altKey: t.altKey, shiftKey: t.shiftKey, pageX: t.pageX, pageY: t.pageY });
|
|
4197
|
+
l(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(i);
|
|
4198
|
+
}
|
|
4199
|
+
}).bind(this)).on("click.jstree", ".jstree-wholerow", function(t) {
|
|
4200
|
+
t.stopImmediatePropagation();
|
|
4201
|
+
var i = l.Event("click", { metaKey: t.metaKey, ctrlKey: t.ctrlKey, altKey: t.altKey, shiftKey: t.shiftKey });
|
|
4202
|
+
l(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(i).trigger("focus");
|
|
4203
|
+
}).on("dblclick.jstree", ".jstree-wholerow", function(t) {
|
|
4204
|
+
t.stopImmediatePropagation();
|
|
4205
|
+
var i = l.Event("dblclick", { metaKey: t.metaKey, ctrlKey: t.ctrlKey, altKey: t.altKey, shiftKey: t.shiftKey });
|
|
4206
|
+
l(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(i).trigger("focus");
|
|
4207
|
+
}).on("click.jstree", ".jstree-leaf > .jstree-ocl", (function(t) {
|
|
4208
|
+
t.stopImmediatePropagation();
|
|
4209
|
+
var i = l.Event("click", { metaKey: t.metaKey, ctrlKey: t.ctrlKey, altKey: t.altKey, shiftKey: t.shiftKey });
|
|
4210
|
+
l(t.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(i).trigger("focus");
|
|
4211
|
+
}).bind(this)).on("mouseover.jstree", ".jstree-wholerow, .jstree-icon", (function(t) {
|
|
4212
|
+
return t.stopImmediatePropagation(), this.is_disabled(t.currentTarget) || this.hover_node(t.currentTarget), !1;
|
|
4213
|
+
}).bind(this)).on("mouseleave.jstree", ".jstree-node", (function(t) {
|
|
4214
|
+
this.dehover_node(t.currentTarget);
|
|
4215
|
+
}).bind(this));
|
|
4216
|
+
}, this.teardown = function() {
|
|
4217
|
+
this.settings.wholerow && this.element.find(".jstree-wholerow").remove(), s.teardown.call(this);
|
|
4218
|
+
}, this.redraw_node = function(t, i, r, a) {
|
|
4219
|
+
if (t = s.redraw_node.apply(this, arguments), t) {
|
|
4220
|
+
var n = U.cloneNode(!0);
|
|
4221
|
+
l.inArray(t.id, this._data.core.selected) !== -1 && (n.className += " jstree-wholerow-clicked"), this._data.core.focused && this._data.core.focused === t.id && (n.className += " jstree-wholerow-hovered"), t.insertBefore(n, t.childNodes[0]);
|
|
4222
|
+
}
|
|
4223
|
+
return t;
|
|
4224
|
+
};
|
|
4225
|
+
}, window.customElements && Object && Object.create) {
|
|
4226
|
+
var $ = Object.create(HTMLElement.prototype);
|
|
4227
|
+
$.createdCallback = function() {
|
|
4228
|
+
var e = { core: {}, plugins: [] }, s;
|
|
4229
|
+
for (s in l.jstree.plugins)
|
|
4230
|
+
l.jstree.plugins.hasOwnProperty(s) && this.attributes[s] && (e.plugins.push(s), this.getAttribute(s) && JSON.parse(this.getAttribute(s)) && (e[s] = JSON.parse(this.getAttribute(s))));
|
|
4231
|
+
for (s in l.jstree.defaults.core)
|
|
4232
|
+
l.jstree.defaults.core.hasOwnProperty(s) && this.attributes[s] && (e.core[s] = JSON.parse(this.getAttribute(s)) || this.getAttribute(s));
|
|
4233
|
+
l(this).jstree(e);
|
|
4234
|
+
};
|
|
4235
|
+
try {
|
|
4236
|
+
window.customElements.define("vakata-jstree", function() {
|
|
4237
|
+
}, { prototype: $ });
|
|
4238
|
+
} catch {
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
});
|
|
4243
|
+
})(ie);
|
|
4244
|
+
const se = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4245
|
+
__proto__: null
|
|
4246
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
4247
|
+
export {
|
|
4248
|
+
se as j
|
|
4249
|
+
};
|