jstree-rails-4 1.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39662753ed3b5136fbe9e4a21c239eaeee0b3929
|
4
|
+
data.tar.gz: 2f44137ee87f3162ff615b515b577120a7974d3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffc5309ad0fe5e7b4b49086683fbba0ca40944a0754e3161b40c017bc6b68bf373589690d39a0c19da42ce0d44307b08a0bf2fbf242af8c3afcbd0f9fda07795
|
7
|
+
data.tar.gz: 21e4df01dfced0d9b5abd7a5b670407af0d0d53bac802722cf9cad975aae16a134299cf15fcb818755de7d1acdaf8f6c6ed94e81d1d84134867c7d2d9e931224
|
@@ -13,7 +13,7 @@
|
|
13
13
|
}(function ($, undefined) {
|
14
14
|
"use strict";
|
15
15
|
/*!
|
16
|
-
* jsTree 3.0
|
16
|
+
* jsTree 3.1.0
|
17
17
|
* http://jstree.com/
|
18
18
|
*
|
19
19
|
* Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
|
@@ -22,7 +22,7 @@
|
|
22
22
|
* http://www.opensource.org/licenses/mit-license.php
|
23
23
|
*/
|
24
24
|
/*!
|
25
|
-
* if using jslint please allow for the jQuery global and use following options:
|
25
|
+
* if using jslint please allow for the jQuery global and use following options:
|
26
26
|
* jslint: browser: true, ass: true, bitwise: true, continue: true, nomen: true, plusplus: true, regexp: true, unparam: true, todo: true, white: true
|
27
27
|
*/
|
28
28
|
|
@@ -42,18 +42,19 @@
|
|
42
42
|
ccp_inst = false,
|
43
43
|
themes_loaded = [],
|
44
44
|
src = $('script:last').attr('src'),
|
45
|
-
|
45
|
+
document = window.document, // local variable is always faster to access then a global
|
46
|
+
_node = document.createElement('LI'), _temp1, _temp2;
|
46
47
|
|
47
48
|
_node.setAttribute('role', 'treeitem');
|
48
|
-
_temp1 =
|
49
|
+
_temp1 = document.createElement('I');
|
49
50
|
_temp1.className = 'jstree-icon jstree-ocl';
|
50
51
|
_temp1.setAttribute('role', 'presentation');
|
51
52
|
_node.appendChild(_temp1);
|
52
|
-
_temp1 =
|
53
|
+
_temp1 = document.createElement('A');
|
53
54
|
_temp1.className = 'jstree-anchor';
|
54
55
|
_temp1.setAttribute('href','#');
|
55
56
|
_temp1.setAttribute('tabindex','-1');
|
56
|
-
_temp2 =
|
57
|
+
_temp2 = document.createElement('I');
|
57
58
|
_temp2.className = 'jstree-icon jstree-themeicon';
|
58
59
|
_temp2.setAttribute('role', 'presentation');
|
59
60
|
_temp1.appendChild(_temp2);
|
@@ -66,11 +67,11 @@
|
|
66
67
|
* @name $.jstree
|
67
68
|
*/
|
68
69
|
$.jstree = {
|
69
|
-
/**
|
70
|
+
/**
|
70
71
|
* specifies the jstree version in use
|
71
72
|
* @name $.jstree.version
|
72
73
|
*/
|
73
|
-
version : '3.0
|
74
|
+
version : '3.1.0',
|
74
75
|
/**
|
75
76
|
* holds all the default options used when creating new instances
|
76
77
|
* @name $.jstree.defaults
|
@@ -109,6 +110,7 @@
|
|
109
110
|
tmp = tmp.plugin(k, options[k]);
|
110
111
|
}
|
111
112
|
});
|
113
|
+
$(el).data('jstree', tmp);
|
112
114
|
tmp.init(el, options);
|
113
115
|
return tmp;
|
114
116
|
};
|
@@ -168,7 +170,7 @@
|
|
168
170
|
$.jstree.reference = function (needle) {
|
169
171
|
var tmp = null,
|
170
172
|
obj = null;
|
171
|
-
if(needle && needle.id) { needle = needle.id; }
|
173
|
+
if(needle && needle.id && (!needle.tagName || !needle.nodeType)) { needle = needle.id; }
|
172
174
|
|
173
175
|
if(!obj || !obj.length) {
|
174
176
|
try { obj = $(needle); } catch (ignore) { }
|
@@ -191,14 +193,14 @@
|
|
191
193
|
return tmp;
|
192
194
|
};
|
193
195
|
/**
|
194
|
-
* Create an instance, get an instance or invoke a command on a instance.
|
195
|
-
*
|
196
|
+
* Create an instance, get an instance or invoke a command on a instance.
|
197
|
+
*
|
196
198
|
* If there is no instance associated with the current node a new one is created and `arg` is used to extend `$.jstree.defaults` for this new instance. There would be no return value (chaining is not broken).
|
197
|
-
*
|
199
|
+
*
|
198
200
|
* If there is an existing instance and `arg` is a string the command specified by `arg` is executed on the instance, with any additional arguments passed to the function. If the function returns a value it will be returned (chaining could break depending on function).
|
199
|
-
*
|
201
|
+
*
|
200
202
|
* If there is an existing instance and `arg` is not a string the instance itself is returned (similar to `$.jstree.reference`).
|
201
|
-
*
|
203
|
+
*
|
202
204
|
* In any other case - nothing is returned and chaining is not broken.
|
203
205
|
*
|
204
206
|
* __Examples__
|
@@ -230,7 +232,7 @@
|
|
230
232
|
null;
|
231
233
|
// if there is no instance and no method is being called - create one
|
232
234
|
if(!instance && !is_method && (arg === undefined || $.isPlainObject(arg))) {
|
233
|
-
|
235
|
+
$.jstree.create(this, arg);
|
234
236
|
}
|
235
237
|
// if there is an instance and no method is called - return the instance
|
236
238
|
if( (instance && !is_method) || arg === true ) {
|
@@ -271,14 +273,14 @@
|
|
271
273
|
$.jstree.defaults.core = {
|
272
274
|
/**
|
273
275
|
* data configuration
|
274
|
-
*
|
276
|
+
*
|
275
277
|
* 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).
|
276
278
|
*
|
277
279
|
* You can also pass in a HTML string or a JSON array here.
|
278
|
-
*
|
279
|
-
* 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.
|
280
|
+
*
|
281
|
+
* 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.
|
280
282
|
* In addition to the standard jQuery ajax options here you can suppy 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.
|
281
|
-
*
|
283
|
+
*
|
282
284
|
* 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.
|
283
285
|
*
|
284
286
|
* __Examples__
|
@@ -307,7 +309,7 @@
|
|
307
309
|
* }
|
308
310
|
* ]
|
309
311
|
* });
|
310
|
-
*
|
312
|
+
*
|
311
313
|
* // function
|
312
314
|
* $('#tree').jstree({
|
313
315
|
* 'core' : {
|
@@ -315,7 +317,7 @@
|
|
315
317
|
* callback.call(this, ['Root 1', 'Root 2']);
|
316
318
|
* }
|
317
319
|
* });
|
318
|
-
*
|
320
|
+
*
|
319
321
|
* @name $.jstree.defaults.core.data
|
320
322
|
*/
|
321
323
|
data : false,
|
@@ -355,7 +357,7 @@
|
|
355
357
|
* }
|
356
358
|
* }
|
357
359
|
* });
|
358
|
-
*
|
360
|
+
*
|
359
361
|
* @name $.jstree.defaults.core.check_callback
|
360
362
|
*/
|
361
363
|
check_callback : false,
|
@@ -460,7 +462,7 @@
|
|
460
462
|
return this;
|
461
463
|
},
|
462
464
|
/**
|
463
|
-
*
|
465
|
+
* initialize the instance. Used internally.
|
464
466
|
* @private
|
465
467
|
* @name init(el, optons)
|
466
468
|
* @param {DOMElement|jQuery|String} el the element we are transforming
|
@@ -610,6 +612,7 @@
|
|
610
612
|
}, this))
|
611
613
|
.on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) {
|
612
614
|
if(e.target.tagName === "INPUT") { return true; }
|
615
|
+
if(e.which !== 32 && e.which !== 13 && (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey)) { return true; }
|
613
616
|
var o = null;
|
614
617
|
if(this._data.core.rtl) {
|
615
618
|
if(e.which === 37) { e.which = 39; }
|
@@ -1030,7 +1033,7 @@
|
|
1030
1033
|
if(tmp !== null) {
|
1031
1034
|
return $(tmp);
|
1032
1035
|
}
|
1033
|
-
return obj.parentsUntil(".jstree",".jstree-node").
|
1036
|
+
return obj.parentsUntil(".jstree",".jstree-node").nextAll(".jstree-node:visible").first();
|
1034
1037
|
},
|
1035
1038
|
/**
|
1036
1039
|
* get the previous visible node that is above the `obj` node. If `strict` is set to `true` only sibling nodes are returned.
|
@@ -1199,12 +1202,14 @@
|
|
1199
1202
|
this.trigger('changed', { 'action' : 'load_node', 'node' : obj, 'selected' : this._data.core.selected });
|
1200
1203
|
}
|
1201
1204
|
}
|
1205
|
+
obj.state.failed = false;
|
1202
1206
|
obj.state.loading = true;
|
1203
1207
|
this.get_node(obj, true).addClass("jstree-loading").attr('aria-busy',true);
|
1204
1208
|
this._load_node(obj, $.proxy(function (status) {
|
1205
1209
|
obj = this._model.data[obj.id];
|
1206
1210
|
obj.state.loading = false;
|
1207
1211
|
obj.state.loaded = status;
|
1212
|
+
obj.state.failed = !obj.state.loaded;
|
1208
1213
|
var dom = this.get_node(obj, true);
|
1209
1214
|
if(obj.state.loaded && !obj.children.length && dom && dom.length && !dom.hasClass('jstree-leaf')) {
|
1210
1215
|
dom.removeClass('jstree-closed jstree-open').addClass('jstree-leaf');
|
@@ -1234,9 +1239,9 @@
|
|
1234
1239
|
_load_nodes : function (nodes, callback, is_callback) {
|
1235
1240
|
var r = true,
|
1236
1241
|
c = function () { this._load_nodes(nodes, callback, true); },
|
1237
|
-
m = this._model.data, i, j;
|
1242
|
+
m = this._model.data, i, j, tmp = [];
|
1238
1243
|
for(i = 0, j = nodes.length; i < j; i++) {
|
1239
|
-
if(m[nodes[i]] && (!m[nodes[i]].state.loaded || !is_callback)) {
|
1244
|
+
if(m[nodes[i]] && ( (!m[nodes[i]].state.loaded && !m[nodes[i]].state.failed) || !is_callback)) {
|
1240
1245
|
if(!this.is_loading(nodes[i])) {
|
1241
1246
|
this.load_node(nodes[i], c);
|
1242
1247
|
}
|
@@ -1244,8 +1249,13 @@
|
|
1244
1249
|
}
|
1245
1250
|
}
|
1246
1251
|
if(r) {
|
1252
|
+
for(i = 0, j = nodes.length; i < j; i++) {
|
1253
|
+
if(m[nodes[i]] && m[nodes[i]].state.loaded) {
|
1254
|
+
tmp.push(nodes[i]);
|
1255
|
+
}
|
1256
|
+
}
|
1247
1257
|
if(callback && !callback.done) {
|
1248
|
-
callback.call(this,
|
1258
|
+
callback.call(this, tmp);
|
1249
1259
|
callback.done = true;
|
1250
1260
|
}
|
1251
1261
|
}
|
@@ -1316,7 +1326,7 @@
|
|
1316
1326
|
if(d === false) {
|
1317
1327
|
callback.call(this, false);
|
1318
1328
|
}
|
1319
|
-
this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d, function (status) {
|
1329
|
+
this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $($.parseHTML(d)).filter(function () { return this.nodeType !== 3; }) : d, function (status) {
|
1320
1330
|
callback.call(this, status);
|
1321
1331
|
});
|
1322
1332
|
// return d === false ? callback.call(this, false) : callback.call(this, this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $(d) : d));
|
@@ -1334,12 +1344,12 @@
|
|
1334
1344
|
return $.ajax(s)
|
1335
1345
|
.done($.proxy(function (d,t,x) {
|
1336
1346
|
var type = x.getResponseHeader('Content-Type');
|
1337
|
-
if(type.indexOf('json') !== -1 || typeof d === "object") {
|
1347
|
+
if((type && type.indexOf('json') !== -1) || typeof d === "object") {
|
1338
1348
|
return this._append_json_data(obj, d, function (status) { callback.call(this, status); });
|
1339
1349
|
//return callback.call(this, this._append_json_data(obj, d));
|
1340
1350
|
}
|
1341
|
-
if(type.indexOf('html') !== -1 || typeof d === "string") {
|
1342
|
-
return this._append_html_data(obj, $(d), function (status) { callback.call(this, status); });
|
1351
|
+
if((type && type.indexOf('html') !== -1) || typeof d === "string") {
|
1352
|
+
return this._append_html_data(obj, $($.parseHTML(d)).filter(function () { return this.nodeType !== 3; }), function (status) { callback.call(this, status); });
|
1343
1353
|
// return callback.call(this, this._append_html_data(obj, $(d)));
|
1344
1354
|
}
|
1345
1355
|
this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : x }) };
|
@@ -1367,7 +1377,7 @@
|
|
1367
1377
|
}
|
1368
1378
|
if(typeof s === 'string') {
|
1369
1379
|
if(obj.id === '#') {
|
1370
|
-
return this._append_html_data(obj, $(s), function (status) {
|
1380
|
+
return this._append_html_data(obj, $($.parseHTML(s)).filter(function () { return this.nodeType !== 3; }), function (status) {
|
1371
1381
|
callback.call(this, status);
|
1372
1382
|
});
|
1373
1383
|
}
|
@@ -1521,6 +1531,9 @@
|
|
1521
1531
|
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
|
1522
1532
|
tmp.icon = d.data.jstree.icon;
|
1523
1533
|
}
|
1534
|
+
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
|
1535
|
+
tmp.icon = true;
|
1536
|
+
}
|
1524
1537
|
if(d && d.data) {
|
1525
1538
|
tmp.data = d.data;
|
1526
1539
|
if(d.data.jstree) {
|
@@ -1610,6 +1623,9 @@
|
|
1610
1623
|
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
|
1611
1624
|
tmp.icon = d.data.jstree.icon;
|
1612
1625
|
}
|
1626
|
+
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
|
1627
|
+
tmp.icon = true;
|
1628
|
+
}
|
1613
1629
|
if(d && d.data) {
|
1614
1630
|
tmp.data = d.data;
|
1615
1631
|
if(d.data.jstree) {
|
@@ -1914,6 +1930,9 @@
|
|
1914
1930
|
if(data.state.icon) {
|
1915
1931
|
data.icon = data.state.icon;
|
1916
1932
|
}
|
1933
|
+
if(data.icon === undefined || data.icon === null || data.icon === "") {
|
1934
|
+
data.icon = true;
|
1935
|
+
}
|
1917
1936
|
tmp = d.children("ul").children("li");
|
1918
1937
|
do {
|
1919
1938
|
tid = 'j' + this._id + '_' + (++this._cnt);
|
@@ -1986,6 +2005,9 @@
|
|
1986
2005
|
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
|
1987
2006
|
tmp.icon = d.data.jstree.icon;
|
1988
2007
|
}
|
2008
|
+
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
|
2009
|
+
tmp.icon = true;
|
2010
|
+
}
|
1989
2011
|
if(d && d.data) {
|
1990
2012
|
tmp.data = d.data;
|
1991
2013
|
if(d.data.jstree) {
|
@@ -2084,6 +2106,9 @@
|
|
2084
2106
|
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
|
2085
2107
|
tmp.icon = d.data.jstree.icon;
|
2086
2108
|
}
|
2109
|
+
if(tmp.icon === undefined || tmp.icon === null || tmp.icon === "") {
|
2110
|
+
tmp.icon = true;
|
2111
|
+
}
|
2087
2112
|
if(d && d.data) {
|
2088
2113
|
tmp.data = d.data;
|
2089
2114
|
if(d.data.jstree) {
|
@@ -3134,44 +3159,18 @@
|
|
3134
3159
|
set_state : function (state, callback) {
|
3135
3160
|
if(state) {
|
3136
3161
|
if(state.core) {
|
3137
|
-
var res, n, t, _this;
|
3162
|
+
var res, n, t, _this, i;
|
3138
3163
|
if(state.core.open) {
|
3139
|
-
if(!$.isArray(state.core.open)) {
|
3164
|
+
if(!$.isArray(state.core.open) || !state.core.open.length) {
|
3140
3165
|
delete state.core.open;
|
3141
3166
|
this.set_state(state, callback);
|
3142
|
-
return false;
|
3143
3167
|
}
|
3144
|
-
|
3145
|
-
|
3146
|
-
|
3147
|
-
|
3148
|
-
|
3149
|
-
|
3150
|
-
if(t.is_loaded(v)) {
|
3151
|
-
if(t.is_closed(v)) {
|
3152
|
-
t.open_node(v, false, 0);
|
3153
|
-
}
|
3154
|
-
if(state && state.core && state.core.open) {
|
3155
|
-
$.vakata.array_remove_item(state.core.open, v);
|
3156
|
-
}
|
3157
|
-
}
|
3158
|
-
else {
|
3159
|
-
if(!t.is_loading(v)) {
|
3160
|
-
t.open_node(v, $.proxy(function (o, s) {
|
3161
|
-
if(!s && state && state.core && state.core.open) {
|
3162
|
-
$.vakata.array_remove_item(state.core.open, o.id);
|
3163
|
-
}
|
3164
|
-
this.set_state(state, callback);
|
3165
|
-
}, t), 0);
|
3166
|
-
}
|
3167
|
-
// there will be some async activity - so wait for it
|
3168
|
-
res = false;
|
3169
|
-
}
|
3170
|
-
}
|
3171
|
-
});
|
3172
|
-
if(res) {
|
3173
|
-
delete state.core.open;
|
3174
|
-
this.set_state(state, callback);
|
3168
|
+
else {
|
3169
|
+
this._load_nodes(state.core.open, function (nodes) {
|
3170
|
+
this.open_node(nodes, false, 0);
|
3171
|
+
delete state.core.open;
|
3172
|
+
this.set_state(state, callback);
|
3173
|
+
}, true);
|
3175
3174
|
}
|
3176
3175
|
return false;
|
3177
3176
|
}
|
@@ -3186,33 +3185,21 @@
|
|
3186
3185
|
this.set_state(state, callback);
|
3187
3186
|
return false;
|
3188
3187
|
}
|
3189
|
-
/*!
|
3190
|
-
if(state.core.themes) {
|
3191
|
-
if(state.core.themes.name) {
|
3192
|
-
this.set_theme(state.core.themes.name);
|
3193
|
-
}
|
3194
|
-
if(typeof state.core.themes.dots !== 'undefined') {
|
3195
|
-
this[ state.core.themes.dots ? "show_dots" : "hide_dots" ]();
|
3196
|
-
}
|
3197
|
-
if(typeof state.core.themes.icons !== 'undefined') {
|
3198
|
-
this[ state.core.themes.icons ? "show_icons" : "hide_icons" ]();
|
3199
|
-
}
|
3200
|
-
delete state.core.themes;
|
3201
|
-
delete state.core.open;
|
3202
|
-
this.set_state(state, callback);
|
3203
|
-
return false;
|
3204
|
-
}
|
3205
|
-
*/
|
3206
3188
|
if(state.core.selected) {
|
3207
3189
|
_this = this;
|
3208
3190
|
this.deselect_all();
|
3209
3191
|
$.each(state.core.selected, function (i, v) {
|
3210
|
-
_this.select_node(v);
|
3192
|
+
_this.select_node(v, false, true);
|
3211
3193
|
});
|
3212
3194
|
delete state.core.selected;
|
3213
3195
|
this.set_state(state, callback);
|
3214
3196
|
return false;
|
3215
3197
|
}
|
3198
|
+
for(i in state) {
|
3199
|
+
if(state.hasOwnProperty(i) && i !== "core" && $.inArray(i, this.settings.plugins) === -1) {
|
3200
|
+
delete state[i];
|
3201
|
+
}
|
3202
|
+
}
|
3216
3203
|
if($.isEmptyObject(state.core)) {
|
3217
3204
|
delete state.core;
|
3218
3205
|
this.set_state(state, callback);
|
@@ -3333,10 +3320,14 @@
|
|
3333
3320
|
// update model and obj itself (obj.id, this._model.data[KEY])
|
3334
3321
|
i = this.get_node(obj.id, true);
|
3335
3322
|
if(i) {
|
3336
|
-
i.attr('id', id);
|
3323
|
+
i.attr('id', id).children('.jstree-anchor').attr('id', id + '_anchor').end().attr('aria-labelledby', id + '_anchor');
|
3324
|
+
if(this.element.attr('aria-activedescendant') === obj.id) {
|
3325
|
+
this.element.attr('aria-activedescendant', id);
|
3326
|
+
}
|
3337
3327
|
}
|
3338
3328
|
delete m[obj.id];
|
3339
3329
|
obj.id = id;
|
3330
|
+
obj.li_attr.id = id;
|
3340
3331
|
m[id] = obj;
|
3341
3332
|
return true;
|
3342
3333
|
},
|
@@ -3685,30 +3676,36 @@
|
|
3685
3676
|
* @param {mixed} par the new parent
|
3686
3677
|
* @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`
|
3687
3678
|
* @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
|
3688
|
-
* @param {Boolean} internal parameter indicating if the parent node has been loaded
|
3689
|
-
* @param {Boolean} internal parameter indicating if the tree should be redrawn
|
3679
|
+
* @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
|
3680
|
+
* @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
|
3681
|
+
* @param {Boolean} instance internal parameter indicating if the node comes from another instance
|
3690
3682
|
* @trigger move_node.jstree
|
3691
3683
|
*/
|
3692
|
-
move_node : function (obj, par, pos, callback, is_loaded, skip_redraw) {
|
3684
|
+
move_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) {
|
3693
3685
|
var t1, t2, old_par, old_pos, new_par, old_ins, is_multi, dpc, tmp, i, j, k, l, p;
|
3694
3686
|
|
3695
3687
|
par = this.get_node(par);
|
3696
3688
|
pos = pos === undefined ? 0 : pos;
|
3697
3689
|
if(!par) { return false; }
|
3698
3690
|
if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
|
3699
|
-
return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true); });
|
3691
|
+
return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true, false, origin); });
|
3700
3692
|
}
|
3701
3693
|
|
3702
3694
|
if($.isArray(obj)) {
|
3703
|
-
obj
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3695
|
+
if(obj.length === 1) {
|
3696
|
+
obj = obj[0];
|
3697
|
+
}
|
3698
|
+
else {
|
3699
|
+
//obj = obj.slice();
|
3700
|
+
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
3701
|
+
if((tmp = this.move_node(obj[t1], par, pos, callback, is_loaded, false, origin))) {
|
3702
|
+
par = tmp;
|
3703
|
+
pos = "after";
|
3704
|
+
}
|
3708
3705
|
}
|
3706
|
+
this.redraw();
|
3707
|
+
return true;
|
3709
3708
|
}
|
3710
|
-
this.redraw();
|
3711
|
-
return true;
|
3712
3709
|
}
|
3713
3710
|
obj = obj && obj.id ? obj : this.get_node(obj);
|
3714
3711
|
|
@@ -3716,13 +3713,17 @@
|
|
3716
3713
|
|
3717
3714
|
old_par = (obj.parent || '#').toString();
|
3718
3715
|
new_par = (!pos.toString().match(/^(before|after)$/) || par.id === '#') ? par : this.get_node(par.parent);
|
3719
|
-
old_ins =
|
3716
|
+
old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id));
|
3720
3717
|
is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id);
|
3721
3718
|
old_pos = old_ins && old_ins._id && old_par && old_ins._model.data[old_par] && old_ins._model.data[old_par].children ? $.inArray(obj.id, old_ins._model.data[old_par].children) : -1;
|
3719
|
+
if(old_ins || old_ins._id) {
|
3720
|
+
obj = old_ins._model.data[obj.id];
|
3721
|
+
}
|
3722
|
+
|
3722
3723
|
if(is_multi) {
|
3723
|
-
if(this.copy_node(obj, par, pos, callback, is_loaded)) {
|
3724
|
+
if((tmp = this.copy_node(obj, par, pos, callback, is_loaded, false, origin))) {
|
3724
3725
|
if(old_ins) { old_ins.delete_node(obj); }
|
3725
|
-
return
|
3726
|
+
return tmp;
|
3726
3727
|
}
|
3727
3728
|
return false;
|
3728
3729
|
}
|
@@ -3750,7 +3751,7 @@
|
|
3750
3751
|
break;
|
3751
3752
|
}
|
3752
3753
|
if(pos > new_par.children.length) { pos = new_par.children.length; }
|
3753
|
-
if(!this.check("move_node", obj, new_par, pos, { 'core' : true, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
|
3754
|
+
if(!this.check("move_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
|
3754
3755
|
this.settings.core.error.call(this, this._data.core.last_error);
|
3755
3756
|
return false;
|
3756
3757
|
}
|
@@ -3839,7 +3840,7 @@
|
|
3839
3840
|
* @param {jsTree} new_instance the instance of the new parent
|
3840
3841
|
*/
|
3841
3842
|
this.trigger('move_node', { "node" : obj, "parent" : new_par.id, "position" : pos, "old_parent" : old_par, "old_position" : old_pos, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id), 'old_instance' : old_ins, 'new_instance' : this });
|
3842
|
-
return
|
3843
|
+
return obj.id;
|
3843
3844
|
},
|
3844
3845
|
/**
|
3845
3846
|
* copy a node to a new parent
|
@@ -3848,39 +3849,49 @@
|
|
3848
3849
|
* @param {mixed} par the new parent
|
3849
3850
|
* @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`
|
3850
3851
|
* @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
|
3851
|
-
* @param {Boolean} internal parameter indicating if the parent node has been loaded
|
3852
|
-
* @param {Boolean} internal parameter indicating if the tree should be redrawn
|
3852
|
+
* @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
|
3853
|
+
* @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
|
3854
|
+
* @param {Boolean} instance internal parameter indicating if the node comes from another instance
|
3853
3855
|
* @trigger model.jstree copy_node.jstree
|
3854
3856
|
*/
|
3855
|
-
copy_node : function (obj, par, pos, callback, is_loaded, skip_redraw) {
|
3857
|
+
copy_node : function (obj, par, pos, callback, is_loaded, skip_redraw, origin) {
|
3856
3858
|
var t1, t2, dpc, tmp, i, j, node, old_par, new_par, old_ins, is_multi;
|
3857
3859
|
|
3858
3860
|
par = this.get_node(par);
|
3859
3861
|
pos = pos === undefined ? 0 : pos;
|
3860
3862
|
if(!par) { return false; }
|
3861
3863
|
if(!pos.toString().match(/^(before|after)$/) && !is_loaded && !this.is_loaded(par)) {
|
3862
|
-
return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true); });
|
3864
|
+
return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true, false, origin); });
|
3863
3865
|
}
|
3864
3866
|
|
3865
3867
|
if($.isArray(obj)) {
|
3866
|
-
obj
|
3867
|
-
|
3868
|
-
|
3869
|
-
|
3870
|
-
|
3871
|
-
|
3868
|
+
if(obj.length === 1) {
|
3869
|
+
obj = obj[0];
|
3870
|
+
}
|
3871
|
+
else {
|
3872
|
+
//obj = obj.slice();
|
3873
|
+
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
3874
|
+
if((tmp = this.copy_node(obj[t1], par, pos, callback, is_loaded, true, origin))) {
|
3875
|
+
par = tmp;
|
3876
|
+
pos = "after";
|
3877
|
+
}
|
3872
3878
|
}
|
3879
|
+
this.redraw();
|
3880
|
+
return true;
|
3873
3881
|
}
|
3874
|
-
this.redraw();
|
3875
|
-
return true;
|
3876
3882
|
}
|
3877
3883
|
obj = obj && obj.id ? obj : this.get_node(obj);
|
3878
3884
|
if(!obj || obj.id === '#') { return false; }
|
3879
3885
|
|
3880
3886
|
old_par = (obj.parent || '#').toString();
|
3881
3887
|
new_par = (!pos.toString().match(/^(before|after)$/) || par.id === '#') ? par : this.get_node(par.parent);
|
3882
|
-
old_ins =
|
3888
|
+
old_ins = origin ? origin : (this._model.data[obj.id] ? this : $.jstree.reference(obj.id));
|
3883
3889
|
is_multi = !old_ins || !old_ins._id || (this._id !== old_ins._id);
|
3890
|
+
|
3891
|
+
if(old_ins || old_ins._id) {
|
3892
|
+
obj = old_ins._model.data[obj.id];
|
3893
|
+
}
|
3894
|
+
|
3884
3895
|
if(par.id === '#') {
|
3885
3896
|
if(pos === "before") { pos = "first"; }
|
3886
3897
|
if(pos === "after") { pos = "last"; }
|
@@ -3904,7 +3915,7 @@
|
|
3904
3915
|
break;
|
3905
3916
|
}
|
3906
3917
|
if(pos > new_par.children.length) { pos = new_par.children.length; }
|
3907
|
-
if(!this.check("copy_node", obj, new_par, pos, { 'core' : true, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
|
3918
|
+
if(!this.check("copy_node", obj, new_par, pos, { 'core' : true, 'origin' : origin, 'is_multi' : (old_ins && old_ins._id && old_ins._id !== this._id), 'is_foreign' : (!old_ins || !old_ins._id) })) {
|
3908
3919
|
this.settings.core.error.call(this, this._data.core.last_error);
|
3909
3920
|
return false;
|
3910
3921
|
}
|
@@ -3991,7 +4002,7 @@
|
|
3991
4002
|
* copy a node (a later call to `paste(obj)` would copy the node)
|
3992
4003
|
* @name copy(obj)
|
3993
4004
|
* @param {mixed} obj multiple objects can be passed using an array
|
3994
|
-
* @trigger copy.
|
4005
|
+
* @trigger copy.jstree
|
3995
4006
|
*/
|
3996
4007
|
copy : function (obj) {
|
3997
4008
|
if(!obj) { obj = this._data.core.selected.concat(); }
|
@@ -4040,7 +4051,7 @@
|
|
4040
4051
|
paste : function (obj, pos) {
|
4041
4052
|
obj = this.get_node(obj);
|
4042
4053
|
if(!obj || !ccp_mode || !ccp_mode.match(/^(copy_node|move_node)$/) || !ccp_node) { return false; }
|
4043
|
-
if(this[ccp_mode](ccp_node, obj, pos)) {
|
4054
|
+
if(this[ccp_mode](ccp_node, obj, pos, false, false, false, ccp_inst)) {
|
4044
4055
|
/**
|
4045
4056
|
* triggered when paste is invoked
|
4046
4057
|
* @event
|
@@ -4078,6 +4089,7 @@
|
|
4078
4089
|
* @param {String} default_text the text to populate the input with (if omitted the node text value is used)
|
4079
4090
|
*/
|
4080
4091
|
edit : function (obj, default_text) {
|
4092
|
+
var rtl, w, a, s, t, h1, h2, fn, tmp;
|
4081
4093
|
obj = this.get_node(obj);
|
4082
4094
|
if(!obj) { return false; }
|
4083
4095
|
if(this.settings.core.check_callback === false) {
|
@@ -4085,23 +4097,25 @@
|
|
4085
4097
|
this.settings.core.error.call(this, this._data.core.last_error);
|
4086
4098
|
return false;
|
4087
4099
|
}
|
4100
|
+
tmp = obj;
|
4088
4101
|
default_text = typeof default_text === 'string' ? default_text : obj.text;
|
4089
4102
|
this.set_text(obj, "");
|
4090
4103
|
obj = this._open_to(obj);
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4103
|
-
|
4104
|
-
|
4104
|
+
tmp.text = default_text;
|
4105
|
+
|
4106
|
+
rtl = this._data.core.rtl;
|
4107
|
+
w = this.element.width();
|
4108
|
+
a = obj.children('.jstree-anchor');
|
4109
|
+
s = $('<span>');
|
4110
|
+
/*!
|
4111
|
+
oi = obj.children("i:visible"),
|
4112
|
+
ai = a.children("i:visible"),
|
4113
|
+
w1 = oi.width() * oi.length,
|
4114
|
+
w2 = ai.width() * ai.length,
|
4115
|
+
*/
|
4116
|
+
t = default_text;
|
4117
|
+
h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body");
|
4118
|
+
h2 = $("<"+"input />", {
|
4105
4119
|
"value" : t,
|
4106
4120
|
"class" : "jstree-rename-input",
|
4107
4121
|
// "size" : t.length,
|
@@ -4147,7 +4161,7 @@
|
|
4147
4161
|
"keypress" : function(event) {
|
4148
4162
|
if(event.which === 13) { return false; }
|
4149
4163
|
}
|
4150
|
-
})
|
4164
|
+
});
|
4151
4165
|
fn = {
|
4152
4166
|
fontFamily : a.css('fontFamily') || '',
|
4153
4167
|
fontSize : a.css('fontSize') || '',
|
@@ -4286,12 +4300,12 @@
|
|
4286
4300
|
obj = this.get_node(obj);
|
4287
4301
|
if(!obj || obj.id === '#') { return false; }
|
4288
4302
|
old = obj.icon;
|
4289
|
-
obj.icon = icon;
|
4303
|
+
obj.icon = icon === true || icon === null || icon === undefined || icon === '' ? true : icon;
|
4290
4304
|
dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon");
|
4291
4305
|
if(icon === false) {
|
4292
4306
|
this.hide_icon(obj);
|
4293
4307
|
}
|
4294
|
-
else if(icon === true) {
|
4308
|
+
else if(icon === true || icon === null || icon === undefined || icon === '') {
|
4295
4309
|
dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
|
4296
4310
|
if(old === false) { this.show_icon(obj); }
|
4297
4311
|
}
|
@@ -4379,14 +4393,12 @@
|
|
4379
4393
|
return attr;
|
4380
4394
|
};
|
4381
4395
|
$.vakata.array_unique = function(array) {
|
4382
|
-
var a = [], i, j, l;
|
4396
|
+
var a = [], i, j, l, o = {};
|
4383
4397
|
for(i = 0, l = array.length; i < l; i++) {
|
4384
|
-
|
4385
|
-
|
4386
|
-
|
4387
|
-
}
|
4398
|
+
if(o[array[i]] === undefined) {
|
4399
|
+
a.push(array[i]);
|
4400
|
+
o[array[i]] = true;
|
4388
4401
|
}
|
4389
|
-
if(j === i) { a.push(array[i]); }
|
4390
4402
|
}
|
4391
4403
|
return a;
|
4392
4404
|
};
|
@@ -4407,7 +4419,7 @@
|
|
4407
4419
|
/**
|
4408
4420
|
* ### Checkbox plugin
|
4409
4421
|
*
|
4410
|
-
* This plugin renders checkbox icons in front of each node, making multiple selection much easier.
|
4422
|
+
* This plugin renders checkbox icons in front of each node, making multiple selection much easier.
|
4411
4423
|
* It also supports tri-state behavior, meaning that if a node has a few of its children checked it will be rendered as undetermined, and state will be propagated up.
|
4412
4424
|
*/
|
4413
4425
|
|
@@ -4445,15 +4457,15 @@
|
|
4445
4457
|
*/
|
4446
4458
|
keep_selected_style : true,
|
4447
4459
|
/**
|
4448
|
-
* This setting controls how cascading and undetermined nodes are applied.
|
4449
|
-
* 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.
|
4460
|
+
* This setting controls how cascading and undetermined nodes are applied.
|
4461
|
+
* 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.
|
4450
4462
|
* If `three_state` is set to `true` this setting is automatically set to 'up+down+undetermined'. Defaults to ''.
|
4451
4463
|
* @name $.jstree.defaults.checkbox.cascade
|
4452
4464
|
* @plugin checkbox
|
4453
4465
|
*/
|
4454
4466
|
cascade : '',
|
4455
4467
|
/**
|
4456
|
-
* 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.
|
4468
|
+
* 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.
|
4457
4469
|
* @name $.jstree.defaults.checkbox.tie_selection
|
4458
4470
|
* @plugin checkbox
|
4459
4471
|
*/
|
@@ -4768,10 +4780,15 @@
|
|
4768
4780
|
* @plugin checkbox
|
4769
4781
|
*/
|
4770
4782
|
this._undetermined = function () {
|
4771
|
-
var i, j, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this;
|
4783
|
+
var i, j, k, l, o = {}, m = this._model.data, t = this.settings.checkbox.tie_selection, s = this._data[ t ? 'core' : 'checkbox' ].selected, p = [], tt = this;
|
4772
4784
|
for(i = 0, j = s.length; i < j; i++) {
|
4773
4785
|
if(m[s[i]] && m[s[i]].parents) {
|
4774
|
-
|
4786
|
+
for(k = 0, l = m[s[i]].parents.length; k < l; k++) {
|
4787
|
+
if(o[m[s[i]].parents[k]] === undefined && m[s[i]].parents[k] !== '#') {
|
4788
|
+
o[m[s[i]].parents[k]] = true;
|
4789
|
+
p.push(m[s[i]].parents[k]);
|
4790
|
+
}
|
4791
|
+
}
|
4775
4792
|
}
|
4776
4793
|
}
|
4777
4794
|
// attempt for server side undetermined state
|
@@ -4780,22 +4797,36 @@
|
|
4780
4797
|
var tmp = tt.get_node(this), tmp2;
|
4781
4798
|
if(!tmp.state.loaded) {
|
4782
4799
|
if(tmp.original && tmp.original.state && tmp.original.state.undetermined && tmp.original.state.undetermined === true) {
|
4783
|
-
|
4784
|
-
|
4800
|
+
if(o[tmp.id] === undefined && tmp.id !== '#') {
|
4801
|
+
o[tmp.id] = true;
|
4802
|
+
p.push(tmp.id);
|
4803
|
+
}
|
4804
|
+
for(k = 0, l = tmp.parents.length; k < l; k++) {
|
4805
|
+
if(o[tmp.parents[k]] === undefined && tmp.parents[k] !== '#') {
|
4806
|
+
o[tmp.parents[k]] = true;
|
4807
|
+
p.push(tmp.parents[k]);
|
4808
|
+
}
|
4809
|
+
}
|
4785
4810
|
}
|
4786
4811
|
}
|
4787
4812
|
else {
|
4788
4813
|
for(i = 0, j = tmp.children_d.length; i < j; i++) {
|
4789
4814
|
tmp2 = m[tmp.children_d[i]];
|
4790
4815
|
if(!tmp2.state.loaded && tmp2.original && tmp2.original.state && tmp2.original.state.undetermined && tmp2.original.state.undetermined === true) {
|
4791
|
-
|
4792
|
-
|
4816
|
+
if(o[tmp2.id] === undefined && tmp2.id !== '#') {
|
4817
|
+
o[tmp2.id] = true;
|
4818
|
+
p.push(tmp2.id);
|
4819
|
+
}
|
4820
|
+
for(k = 0, l = tmp2.parents.length; k < l; k++) {
|
4821
|
+
if(o[tmp2.parents[k]] === undefined && tmp2.parents[k] !== '#') {
|
4822
|
+
o[tmp2.parents[k]] = true;
|
4823
|
+
p.push(tmp2.parents[k]);
|
4824
|
+
}
|
4825
|
+
}
|
4793
4826
|
}
|
4794
4827
|
}
|
4795
4828
|
}
|
4796
4829
|
});
|
4797
|
-
p = $.vakata.array_unique(p);
|
4798
|
-
p = $.vakata.array_remove_item(p,'#');
|
4799
4830
|
|
4800
4831
|
this.element.find('.jstree-undetermined').removeClass('jstree-undetermined');
|
4801
4832
|
for(i = 0, j = p.length; i < j; i++) {
|
@@ -4930,8 +4961,8 @@
|
|
4930
4961
|
};
|
4931
4962
|
/**
|
4932
4963
|
* uncheck a node (only if tie_selection in checkbox settings is false, otherwise deselect_node will be called internally)
|
4933
|
-
* @name
|
4934
|
-
* @param {mixed} obj an array can be used to
|
4964
|
+
* @name uncheck_node(obj)
|
4965
|
+
* @param {mixed} obj an array can be used to uncheck multiple nodes
|
4935
4966
|
* @trigger uncheck_node.jstree
|
4936
4967
|
* @plugin checkbox
|
4937
4968
|
*/
|
@@ -5122,6 +5153,7 @@
|
|
5122
5153
|
});
|
5123
5154
|
}
|
5124
5155
|
delete state.checkbox;
|
5156
|
+
this.set_state(state, callback);
|
5125
5157
|
return false;
|
5126
5158
|
}
|
5127
5159
|
return res;
|
@@ -5137,8 +5169,6 @@
|
|
5137
5169
|
* Shows a context menu when a node is right-clicked.
|
5138
5170
|
*/
|
5139
5171
|
|
5140
|
-
var cto = null, ex, ey;
|
5141
|
-
|
5142
5172
|
/**
|
5143
5173
|
* stores all defaults for the contextmenu plugin
|
5144
5174
|
* @name $.jstree.defaults.contextmenu
|
@@ -5159,9 +5189,9 @@
|
|
5159
5189
|
show_at_node : true,
|
5160
5190
|
/**
|
5161
5191
|
* 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).
|
5162
|
-
*
|
5192
|
+
*
|
5163
5193
|
* 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):
|
5164
|
-
*
|
5194
|
+
*
|
5165
5195
|
* * `separator_before` - a boolean indicating if there should be a separator before this item
|
5166
5196
|
* * `separator_after` - a boolean indicating if there should be a separator after this item
|
5167
5197
|
* * `_disabled` - a boolean indicating if this action should be disabled
|
@@ -5170,7 +5200,7 @@
|
|
5170
5200
|
* * `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
|
5171
5201
|
* * `shortcut` - keyCode which will trigger the action if the menu is open (for example `113` for rename, which equals F2)
|
5172
5202
|
* * `shortcut_label` - shortcut label (like for example `F2` for rename)
|
5173
|
-
*
|
5203
|
+
*
|
5174
5204
|
* @name $.jstree.defaults.contextmenu.items
|
5175
5205
|
* @plugin contextmenu
|
5176
5206
|
*/
|
@@ -5237,7 +5267,7 @@
|
|
5237
5267
|
var inst = $.jstree.reference(data.reference),
|
5238
5268
|
obj = inst.get_node(data.reference);
|
5239
5269
|
if(inst.is_selected(obj)) {
|
5240
|
-
inst.cut(inst.
|
5270
|
+
inst.cut(inst.get_top_selected());
|
5241
5271
|
}
|
5242
5272
|
else {
|
5243
5273
|
inst.cut(obj);
|
@@ -5253,7 +5283,7 @@
|
|
5253
5283
|
var inst = $.jstree.reference(data.reference),
|
5254
5284
|
obj = inst.get_node(data.reference);
|
5255
5285
|
if(inst.is_selected(obj)) {
|
5256
|
-
inst.copy(inst.
|
5286
|
+
inst.copy(inst.get_top_selected());
|
5257
5287
|
}
|
5258
5288
|
else {
|
5259
5289
|
inst.copy(obj);
|
@@ -5284,7 +5314,7 @@
|
|
5284
5314
|
this.bind = function () {
|
5285
5315
|
parent.bind.call(this);
|
5286
5316
|
|
5287
|
-
var last_ts = 0;
|
5317
|
+
var last_ts = 0, cto = null, ex, ey;
|
5288
5318
|
this.element
|
5289
5319
|
.on("contextmenu.jstree", ".jstree-anchor", $.proxy(function (e, data) {
|
5290
5320
|
e.preventDefault();
|
@@ -5314,7 +5344,18 @@
|
|
5314
5344
|
cto = setTimeout(function () {
|
5315
5345
|
$(e.currentTarget).trigger('contextmenu', true);
|
5316
5346
|
}, 750);
|
5347
|
+
})
|
5348
|
+
.on('touchmove.vakata.jstree', function (e) {
|
5349
|
+
if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.pageX) > 50 || Math.abs(ey - e.pageY) > 50)) {
|
5350
|
+
clearTimeout(cto);
|
5351
|
+
}
|
5352
|
+
})
|
5353
|
+
.on('touchend.vakata.jstree', function (e) {
|
5354
|
+
if(cto) {
|
5355
|
+
clearTimeout(cto);
|
5356
|
+
}
|
5317
5357
|
});
|
5358
|
+
|
5318
5359
|
/*
|
5319
5360
|
if(!('oncontextmenu' in document.body) && ('ontouchstart' in document.body)) {
|
5320
5361
|
var el = null, tm = null;
|
@@ -5415,20 +5456,6 @@
|
|
5415
5456
|
};
|
5416
5457
|
};
|
5417
5458
|
|
5418
|
-
$(function () {
|
5419
|
-
$(document)
|
5420
|
-
.on('touchmove.vakata.jstree', function (e) {
|
5421
|
-
if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.pageX) > 50 || Math.abs(ey - e.pageY) > 50)) {
|
5422
|
-
clearTimeout(cto);
|
5423
|
-
}
|
5424
|
-
})
|
5425
|
-
.on('touchend.vakata.jstree', function (e) {
|
5426
|
-
if(cto) {
|
5427
|
-
clearTimeout(cto);
|
5428
|
-
}
|
5429
|
-
});
|
5430
|
-
});
|
5431
|
-
|
5432
5459
|
// contextmenu helper
|
5433
5460
|
(function ($) {
|
5434
5461
|
var right_to_left = false,
|
@@ -5810,7 +5837,19 @@
|
|
5810
5837
|
* @name $.jstree.defaults.dnd.touch
|
5811
5838
|
* @plugin dnd
|
5812
5839
|
*/
|
5813
|
-
touch : true
|
5840
|
+
touch : true,
|
5841
|
+
/**
|
5842
|
+
* 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.
|
5843
|
+
* @name $.jstree.defaults.dnd.large_drop_target
|
5844
|
+
* @plugin dnd
|
5845
|
+
*/
|
5846
|
+
large_drop_target : false,
|
5847
|
+
/**
|
5848
|
+
* 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".
|
5849
|
+
* @name $.jstree.defaults.dnd.large_drag_target
|
5850
|
+
* @plugin dnd
|
5851
|
+
*/
|
5852
|
+
large_drag_target : false
|
5814
5853
|
};
|
5815
5854
|
// TODO: now check works by checking for each node individually, how about max_children, unique, etc?
|
5816
5855
|
$.jstree.plugins.dnd = function (options, parent) {
|
@@ -5818,21 +5857,24 @@
|
|
5818
5857
|
parent.bind.call(this);
|
5819
5858
|
|
5820
5859
|
this.element
|
5821
|
-
.on('mousedown.jstree touchstart.jstree', '.jstree-anchor', $.proxy(function (e) {
|
5822
|
-
if(
|
5860
|
+
.on('mousedown.jstree touchstart.jstree', this.settings.dnd.large_drag_target ? '.jstree-node' : '.jstree-anchor', $.proxy(function (e) {
|
5861
|
+
if(this.settings.dnd.large_drag_target && $(e.target).closest('.jstree-node')[0] !== e.currentTarget) {
|
5862
|
+
return true;
|
5863
|
+
}
|
5864
|
+
if(e.type === "touchstart" && (!this.settings.dnd.touch || (this.settings.dnd.touch === 'selected' && !$(e.currentTarget).closest('.jstree-node').children('.jstree-anchor').hasClass('jstree-clicked')))) {
|
5823
5865
|
return true;
|
5824
5866
|
}
|
5825
5867
|
var obj = this.get_node(e.target),
|
5826
|
-
mlt = this.is_selected(obj) && this.settings.drag_selection ? this.
|
5868
|
+
mlt = this.is_selected(obj) && this.settings.dnd.drag_selection ? this.get_top_selected().length : 1,
|
5827
5869
|
txt = (mlt > 1 ? mlt + ' ' + this.get_string('nodes') : this.get_text(e.currentTarget));
|
5828
5870
|
if(this.settings.core.force_text) {
|
5829
|
-
txt =
|
5871
|
+
txt = $.vakata.html.escape(txt);
|
5830
5872
|
}
|
5831
5873
|
if(obj && obj.id && obj.id !== "#" && (e.which === 1 || e.type === "touchstart") &&
|
5832
|
-
(this.settings.dnd.is_draggable === true || ($.isFunction(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, (mlt > 1 ? this.
|
5874
|
+
(this.settings.dnd.is_draggable === true || ($.isFunction(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, (mlt > 1 ? this.get_top_selected(true) : [obj]))))
|
5833
5875
|
) {
|
5834
5876
|
this.element.trigger('mousedown.jstree');
|
5835
|
-
return $.vakata.dnd.start(e, { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.
|
5877
|
+
return $.vakata.dnd.start(e, { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.get_top_selected() : [obj.id] }, '<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>' + txt + '<ins class="jstree-copy" style="display:none;">+</ins></div>');
|
5836
5878
|
}
|
5837
5879
|
}, this));
|
5838
5880
|
};
|
@@ -5864,7 +5906,7 @@
|
|
5864
5906
|
ref = false,
|
5865
5907
|
off = false,
|
5866
5908
|
rel = false,
|
5867
|
-
l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm;
|
5909
|
+
tmp, l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm;
|
5868
5910
|
// if we are over an instance
|
5869
5911
|
if(ins && ins._data && ins._data.dnd) {
|
5870
5912
|
marker.attr('class', 'jstree-' + ins.get_theme() + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ));
|
@@ -5877,7 +5919,7 @@
|
|
5877
5919
|
if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && ins.get_container_ul().children().length === 0) {
|
5878
5920
|
ok = true;
|
5879
5921
|
for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) {
|
5880
|
-
ok = ok && ins.check( (data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)) ) ? "copy_node" : "move_node"), (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), '#', 'last', { 'dnd' : true, 'ref' : ins.get_node('#'), 'pos' : 'i', 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) });
|
5922
|
+
ok = ok && ins.check( (data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey)) ) ? "copy_node" : "move_node"), (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), '#', 'last', { 'dnd' : true, 'ref' : ins.get_node('#'), 'pos' : 'i', 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) });
|
5881
5923
|
if(!ok) { break; }
|
5882
5924
|
}
|
5883
5925
|
if(ok) {
|
@@ -5889,11 +5931,11 @@
|
|
5889
5931
|
}
|
5890
5932
|
else {
|
5891
5933
|
// if we are hovering a tree node
|
5892
|
-
ref = $(data.event.target).closest('.jstree-anchor');
|
5934
|
+
ref = ins.settings.dnd.large_drop_target ? $(data.event.target).closest('.jstree-node').children('.jstree-anchor') : $(data.event.target).closest('.jstree-anchor');
|
5893
5935
|
if(ref && ref.length && ref.parent().is('.jstree-closed, .jstree-open, .jstree-leaf')) {
|
5894
5936
|
off = ref.offset();
|
5895
5937
|
rel = data.event.pageY - off.top;
|
5896
|
-
h = ref.
|
5938
|
+
h = ref.outerHeight();
|
5897
5939
|
if(rel < h / 3) {
|
5898
5940
|
o = ['b', 'i', 'a'];
|
5899
5941
|
}
|
@@ -5936,7 +5978,7 @@
|
|
5936
5978
|
ps -= 1;
|
5937
5979
|
}
|
5938
5980
|
}
|
5939
|
-
ok = ok && ( (ins && ins.settings && ins.settings.dnd && ins.settings.dnd.check_while_dragging === false) || ins.check(op, (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), p, ps, { 'dnd' : true, 'ref' : ins.get_node(ref.parent()), 'pos' : v, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }) );
|
5981
|
+
ok = ok && ( (ins && ins.settings && ins.settings.dnd && ins.settings.dnd.check_while_dragging === false) || ins.check(op, (data.data.origin && data.data.origin !== ins ? data.data.origin.get_node(data.data.nodes[t1]) : data.data.nodes[t1]), p, ps, { 'dnd' : true, 'ref' : ins.get_node(ref.parent()), 'pos' : v, 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) }) );
|
5940
5982
|
if(!ok) {
|
5941
5983
|
if(ins && ins.last_error) { laster = ins.last_error(); }
|
5942
5984
|
break;
|
@@ -5976,16 +6018,8 @@
|
|
5976
6018
|
if(lastmv) {
|
5977
6019
|
for(i = 0, j = data.data.nodes.length; i < j; i++) {
|
5978
6020
|
nodes[i] = data.data.origin ? data.data.origin.get_node(data.data.nodes[i]) : data.data.nodes[i];
|
5979
|
-
if(data.data.origin) {
|
5980
|
-
nodes[i].instance = data.data.origin;
|
5981
|
-
}
|
5982
|
-
}
|
5983
|
-
lastmv.ins[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? 'copy_node' : 'move_node' ](nodes, lastmv.par, lastmv.pos);
|
5984
|
-
for(i = 0, j = nodes.length; i < j; i++) {
|
5985
|
-
if(nodes[i].instance) {
|
5986
|
-
nodes[i].instance = null;
|
5987
|
-
}
|
5988
6021
|
}
|
6022
|
+
lastmv.ins[ data.data.origin && (data.data.origin.settings.dnd.always_copy || (data.data.origin.settings.dnd.copy && (data.event.metaKey || data.event.ctrlKey))) ? 'copy_node' : 'move_node' ](nodes, lastmv.par, lastmv.pos, false, false, false, data.data.origin);
|
5989
6023
|
}
|
5990
6024
|
else {
|
5991
6025
|
i = $(data.event.target).closest('.jstree');
|
@@ -6007,6 +6041,15 @@
|
|
6007
6041
|
|
6008
6042
|
// helpers
|
6009
6043
|
(function ($) {
|
6044
|
+
$.vakata.html = {
|
6045
|
+
div : $('<div />'),
|
6046
|
+
escape : function (str) {
|
6047
|
+
return $.vakata.html.div.text(str).html();
|
6048
|
+
},
|
6049
|
+
strip : function (str) {
|
6050
|
+
return $.vakata.html.div.empty().append($.parseHTML(str)).text();
|
6051
|
+
}
|
6052
|
+
};
|
6010
6053
|
// private variable
|
6011
6054
|
var vakata_dnd = {
|
6012
6055
|
element : false,
|
@@ -6265,6 +6308,90 @@
|
|
6265
6308
|
// $.jstree.defaults.plugins.push("dnd");
|
6266
6309
|
|
6267
6310
|
|
6311
|
+
/**
|
6312
|
+
* ### Massload plugin
|
6313
|
+
*
|
6314
|
+
* Adds massload functionality to jsTree, so that multiple nodes can be loaded in a single request (only useful with lazy loading).
|
6315
|
+
*/
|
6316
|
+
|
6317
|
+
/**
|
6318
|
+
* massload configuration
|
6319
|
+
*
|
6320
|
+
* It is possible to set this to a standard jQuery-like AJAX config.
|
6321
|
+
* 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 IDs need to be loaded, the return value of those functions will be used.
|
6322
|
+
*
|
6323
|
+
* You can also set this to a function, that function will receive the node IDs being loaded as argument and a second param which is a function (callback) which should be called with the result.
|
6324
|
+
*
|
6325
|
+
* Both the AJAX and the function approach rely on the same return value - an object where the keys are the node IDs, and the value is the children of that node as an array.
|
6326
|
+
*
|
6327
|
+
* {
|
6328
|
+
* "id1" : [{ "text" : "Child of ID1", "id" : "c1" }, { "text" : "Another child of ID1", "id" : "c2" }],
|
6329
|
+
* "id2" : [{ "text" : "Child of ID2", "id" : "c3" }]
|
6330
|
+
* }
|
6331
|
+
*
|
6332
|
+
* @name $.jstree.defaults.massload
|
6333
|
+
* @plugin massload
|
6334
|
+
*/
|
6335
|
+
$.jstree.defaults.massload = null;
|
6336
|
+
$.jstree.plugins.massload = function (options, parent) {
|
6337
|
+
this.init = function (el, options) {
|
6338
|
+
parent.init.call(this, el, options);
|
6339
|
+
this._data.massload = {};
|
6340
|
+
};
|
6341
|
+
this._load_nodes = function (nodes, callback, is_callback) {
|
6342
|
+
var s = this.settings.massload;
|
6343
|
+
if(is_callback && !$.isEmptyObject(this._data.massload)) {
|
6344
|
+
return parent._load_nodes.call(this, nodes, callback, is_callback);
|
6345
|
+
}
|
6346
|
+
if($.isFunction(s)) {
|
6347
|
+
return s.call(this, nodes, $.proxy(function (data) {
|
6348
|
+
if(data) {
|
6349
|
+
for(var i in data) {
|
6350
|
+
if(data.hasOwnProperty(i)) {
|
6351
|
+
this._data.massload[i] = data[i];
|
6352
|
+
}
|
6353
|
+
}
|
6354
|
+
}
|
6355
|
+
parent._load_nodes.call(this, nodes, callback, is_callback);
|
6356
|
+
}, this));
|
6357
|
+
}
|
6358
|
+
if(typeof s === 'object' && s && s.url) {
|
6359
|
+
s = $.extend(true, {}, s);
|
6360
|
+
if($.isFunction(s.url)) {
|
6361
|
+
s.url = s.url.call(this, nodes);
|
6362
|
+
}
|
6363
|
+
if($.isFunction(s.data)) {
|
6364
|
+
s.data = s.data.call(this, nodes);
|
6365
|
+
}
|
6366
|
+
return $.ajax(s)
|
6367
|
+
.done($.proxy(function (data,t,x) {
|
6368
|
+
if(data) {
|
6369
|
+
for(var i in data) {
|
6370
|
+
if(data.hasOwnProperty(i)) {
|
6371
|
+
this._data.massload[i] = data[i];
|
6372
|
+
}
|
6373
|
+
}
|
6374
|
+
}
|
6375
|
+
parent._load_nodes.call(this, nodes, callback, is_callback);
|
6376
|
+
}, this))
|
6377
|
+
.fail($.proxy(function (f) {
|
6378
|
+
parent._load_nodes.call(this, nodes, callback, is_callback);
|
6379
|
+
}, this));
|
6380
|
+
}
|
6381
|
+
return parent._load_nodes.call(this, nodes, callback, is_callback);
|
6382
|
+
};
|
6383
|
+
this._load_node = function (obj, callback) {
|
6384
|
+
var d = this._data.massload[obj.id];
|
6385
|
+
if(d) {
|
6386
|
+
return this[typeof d === 'string' ? '_append_html_data' : '_append_json_data'](obj, typeof d === 'string' ? $($.parseHTML(d)).filter(function () { return this.nodeType !== 3; }) : d, function (status) {
|
6387
|
+
callback.call(this, status);
|
6388
|
+
delete this._data.massload[obj.id];
|
6389
|
+
});
|
6390
|
+
}
|
6391
|
+
return parent._load_node.call(this, obj, callback);
|
6392
|
+
};
|
6393
|
+
};
|
6394
|
+
|
6268
6395
|
/**
|
6269
6396
|
* ### Search plugin
|
6270
6397
|
*
|
@@ -6280,8 +6407,8 @@
|
|
6280
6407
|
/**
|
6281
6408
|
* a jQuery-like AJAX config, which jstree uses if a server should be queried for results.
|
6282
6409
|
*
|
6283
|
-
* A `str` (which is the search string) parameter will be added with the request. The expected result is a JSON array with nodes that need to be opened so that matching nodes will be revealed.
|
6284
|
-
* 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
|
6410
|
+
* 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.
|
6411
|
+
* 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
|
6285
6412
|
* @name $.jstree.defaults.search.ajax
|
6286
6413
|
* @plugin search
|
6287
6414
|
*/
|
@@ -6377,20 +6504,25 @@
|
|
6377
6504
|
* @param {String} str the search string
|
6378
6505
|
* @param {Boolean} skip_async if set to true server will not be queried even if configured
|
6379
6506
|
* @param {Boolean} show_only_matches if set to true only matching nodes will be shown (keep in mind this can be very slow on large trees or old browsers)
|
6507
|
+
* @param {mixed} inside an optional node to whose children to limit the search
|
6508
|
+
* @param {Boolean} append if set to true the results of this search are appended to the previous search
|
6380
6509
|
* @plugin search
|
6381
6510
|
* @trigger search.jstree
|
6382
6511
|
*/
|
6383
|
-
this.search = function (str, skip_async, show_only_matches) {
|
6512
|
+
this.search = function (str, skip_async, show_only_matches, inside, append) {
|
6384
6513
|
if(str === false || $.trim(str.toString()) === "") {
|
6385
6514
|
return this.clear_search();
|
6386
6515
|
}
|
6516
|
+
inside = this.get_node(inside);
|
6517
|
+
inside = inside && inside.id ? inside.id : null;
|
6387
6518
|
str = str.toString();
|
6388
6519
|
var s = this.settings.search,
|
6389
6520
|
a = s.ajax ? s.ajax : false,
|
6521
|
+
m = this._model.data,
|
6390
6522
|
f = null,
|
6391
6523
|
r = [],
|
6392
6524
|
p = [], i, j;
|
6393
|
-
if(this._data.search.res.length) {
|
6525
|
+
if(this._data.search.res.length && !append) {
|
6394
6526
|
this.clear_search();
|
6395
6527
|
}
|
6396
6528
|
if(show_only_matches === undefined) {
|
@@ -6401,14 +6533,17 @@
|
|
6401
6533
|
return a.call(this, str, $.proxy(function (d) {
|
6402
6534
|
if(d && d.d) { d = d.d; }
|
6403
6535
|
this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
|
6404
|
-
this.search(str, true, show_only_matches);
|
6536
|
+
this.search(str, true, show_only_matches, inside, append);
|
6405
6537
|
}, true);
|
6406
|
-
}, this));
|
6538
|
+
}, this), inside);
|
6407
6539
|
}
|
6408
6540
|
else {
|
6409
6541
|
a = $.extend({}, a);
|
6410
6542
|
if(!a.data) { a.data = {}; }
|
6411
6543
|
a.data.str = str;
|
6544
|
+
if(inside) {
|
6545
|
+
a.data.inside = inside;
|
6546
|
+
}
|
6412
6547
|
return $.ajax(a)
|
6413
6548
|
.fail($.proxy(function () {
|
6414
6549
|
this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'search', 'id' : 'search_01', 'reason' : 'Could not load search parents', 'data' : JSON.stringify(a) };
|
@@ -6417,20 +6552,22 @@
|
|
6417
6552
|
.done($.proxy(function (d) {
|
6418
6553
|
if(d && d.d) { d = d.d; }
|
6419
6554
|
this._load_nodes(!$.isArray(d) ? [] : $.vakata.array_unique(d), function () {
|
6420
|
-
this.search(str, true, show_only_matches);
|
6555
|
+
this.search(str, true, show_only_matches, inside, append);
|
6421
6556
|
}, true);
|
6422
6557
|
}, this));
|
6423
6558
|
}
|
6424
6559
|
}
|
6425
|
-
|
6426
|
-
|
6427
|
-
|
6428
|
-
|
6429
|
-
|
6560
|
+
if(!append) {
|
6561
|
+
this._data.search.str = str;
|
6562
|
+
this._data.search.dom = $();
|
6563
|
+
this._data.search.res = [];
|
6564
|
+
this._data.search.opn = [];
|
6565
|
+
this._data.search.som = show_only_matches;
|
6566
|
+
}
|
6430
6567
|
|
6431
6568
|
f = new $.vakata.search(str, true, { caseSensitive : s.case_sensitive, fuzzy : s.fuzzy });
|
6432
|
-
|
6433
|
-
|
6569
|
+
$.each(m[inside ? inside : '#'].children_d, function (ii, i) {
|
6570
|
+
var v = m[i];
|
6434
6571
|
if(v.text && ( (s.search_callback && s.search_callback.call(this, str, v)) || (!s.search_callback && f.search(v.text).isMatch) ) && (!s.search_leaves_only || (v.state.loaded && v.children.length === 0)) ) {
|
6435
6572
|
r.push(i);
|
6436
6573
|
p = p.concat(v.parents);
|
@@ -6439,8 +6576,14 @@
|
|
6439
6576
|
if(r.length) {
|
6440
6577
|
p = $.vakata.array_unique(p);
|
6441
6578
|
this._search_open(p);
|
6442
|
-
|
6443
|
-
|
6579
|
+
if(!append) {
|
6580
|
+
this._data.search.dom = $(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #')));
|
6581
|
+
this._data.search.res = r;
|
6582
|
+
}
|
6583
|
+
else {
|
6584
|
+
this._data.search.dom = this._data.search.dom.add($(this.element[0].querySelectorAll('#' + $.map(r, function (v) { return "0123456789".indexOf(v[0]) !== -1 ? '\\3' + v[0] + ' ' + v.substr(1).replace($.jstree.idregex,'\\$&') : v.replace($.jstree.idregex,'\\$&'); }).join(', #'))));
|
6585
|
+
this._data.search.res = $.vakata.array_unique(this._data.search.res.concat(r));
|
6586
|
+
}
|
6444
6587
|
this._data.search.dom.children(".jstree-anchor").addClass('jstree-search');
|
6445
6588
|
}
|
6446
6589
|
/**
|
@@ -6507,13 +6650,14 @@
|
|
6507
6650
|
// from http://kiro.me/projects/fuse.html
|
6508
6651
|
$.vakata.search = function(pattern, txt, options) {
|
6509
6652
|
options = options || {};
|
6653
|
+
options = $.extend({}, $.vakata.search.defaults, options);
|
6510
6654
|
if(options.fuzzy !== false) {
|
6511
6655
|
options.fuzzy = true;
|
6512
6656
|
}
|
6513
6657
|
pattern = options.caseSensitive ? pattern : pattern.toLowerCase();
|
6514
|
-
var MATCH_LOCATION = options.location
|
6515
|
-
MATCH_DISTANCE = options.distance
|
6516
|
-
MATCH_THRESHOLD = options.threshold
|
6658
|
+
var MATCH_LOCATION = options.location,
|
6659
|
+
MATCH_DISTANCE = options.distance,
|
6660
|
+
MATCH_THRESHOLD = options.threshold,
|
6517
6661
|
patternLen = pattern.length,
|
6518
6662
|
matchmask, pattern_alphabet, match_bitapScore, search;
|
6519
6663
|
if(patternLen > 32) {
|
@@ -6621,6 +6765,13 @@
|
|
6621
6765
|
};
|
6622
6766
|
return txt === true ? { 'search' : search } : search(txt);
|
6623
6767
|
};
|
6768
|
+
$.vakata.search.defaults = {
|
6769
|
+
location : 0,
|
6770
|
+
distance : 100,
|
6771
|
+
threshold : 0.6,
|
6772
|
+
fuzzy : false,
|
6773
|
+
caseSensitive : false
|
6774
|
+
};
|
6624
6775
|
}($));
|
6625
6776
|
|
6626
6777
|
// include the search plugin by default
|
@@ -6801,17 +6952,17 @@
|
|
6801
6952
|
|
6802
6953
|
/**
|
6803
6954
|
* An object storing all types as key value pairs, where the key is the type name and the value is an object that could contain following keys (all optional).
|
6804
|
-
*
|
6955
|
+
*
|
6805
6956
|
* * `max_children` the maximum number of immediate children this node type can have. Do not specify or set to `-1` for unlimited.
|
6806
6957
|
* * `max_depth` the maximum number of nesting this node type can have. A value of `1` would mean that the node can have children, but no grandchildren. Do not specify or set to `-1` for unlimited.
|
6807
6958
|
* * `valid_children` an array of node type strings, that nodes of this type can have as children. Do not specify or set to `-1` for no limits.
|
6808
6959
|
* * `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. Omit to use the default icon from your theme.
|
6809
6960
|
*
|
6810
6961
|
* There are two predefined types:
|
6811
|
-
*
|
6962
|
+
*
|
6812
6963
|
* * `#` represents the root of the tree, for example `max_children` would control the maximum number of root nodes.
|
6813
6964
|
* * `default` represents the default node - any settings here will be applied to all nodes that do not have a type specified.
|
6814
|
-
*
|
6965
|
+
*
|
6815
6966
|
* @name $.jstree.defaults.types
|
6816
6967
|
* @plugin types
|
6817
6968
|
*/
|
@@ -6916,7 +7067,7 @@
|
|
6916
7067
|
if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
|
6917
7068
|
obj = obj && obj.id ? obj : this.get_node(obj);
|
6918
7069
|
par = par && par.id ? par : this.get_node(par);
|
6919
|
-
var m = obj && obj.id ? $.jstree.reference(obj.id) : null, tmp, d, i, j;
|
7070
|
+
var m = obj && obj.id ? (more && more.origin ? more.origin : $.jstree.reference(obj.id)) : null, tmp, d, i, j;
|
6920
7071
|
m = m && m._model && m._model.data ? m._model.data : null;
|
6921
7072
|
switch(chk) {
|
6922
7073
|
case "create_node":
|
@@ -7077,7 +7228,7 @@
|
|
7077
7228
|
}
|
7078
7229
|
return i;
|
7079
7230
|
case "move_node":
|
7080
|
-
i = (obj.parent === par.id || $.inArray(n, c) === -1);
|
7231
|
+
i = ( (obj.parent === par.id && (!more || !more.is_multi)) || $.inArray(n, c) === -1);
|
7081
7232
|
if(!i) {
|
7082
7233
|
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_03', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
|
7083
7234
|
}
|
@@ -7167,6 +7318,15 @@
|
|
7167
7318
|
var tmp = $.Event('contextmenu', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey, pageX : e.pageX, pageY : e.pageY });
|
7168
7319
|
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp);
|
7169
7320
|
}, this))
|
7321
|
+
/*!
|
7322
|
+
.on("mousedown.jstree touchstart.jstree", ".jstree-wholerow", function (e) {
|
7323
|
+
if(e.target === e.currentTarget) {
|
7324
|
+
var a = $(e.currentTarget).closest(".jstree-node").children(".jstree-anchor");
|
7325
|
+
e.target = a[0];
|
7326
|
+
a.trigger(e);
|
7327
|
+
}
|
7328
|
+
})
|
7329
|
+
*/
|
7170
7330
|
.on("click.jstree", ".jstree-wholerow", function (e) {
|
7171
7331
|
e.stopImmediatePropagation();
|
7172
7332
|
var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
|
@@ -7208,9 +7368,6 @@
|
|
7208
7368
|
};
|
7209
7369
|
// include the wholerow plugin by default
|
7210
7370
|
// $.jstree.defaults.plugins.push("wholerow");
|
7211
|
-
|
7212
|
-
|
7213
|
-
(function ($) {
|
7214
7371
|
if(document.registerElement && Object && Object.create) {
|
7215
7372
|
var proto = Object.create(HTMLElement.prototype);
|
7216
7373
|
proto.createdCallback = function () {
|
@@ -7228,12 +7385,12 @@
|
|
7228
7385
|
c.core[i] = JSON.parse(this.getAttribute(i)) || this.getAttribute(i);
|
7229
7386
|
}
|
7230
7387
|
}
|
7231
|
-
|
7388
|
+
$(this).jstree(c);
|
7232
7389
|
};
|
7233
7390
|
// proto.attributeChangedCallback = function (name, previous, value) { };
|
7234
7391
|
try {
|
7235
7392
|
document.registerElement("vakata-jstree", { prototype: proto });
|
7236
7393
|
} catch(ignore) { }
|
7237
7394
|
}
|
7238
|
-
|
7395
|
+
|
7239
7396
|
}));
|