jstree-rails-4 3.3.4 → 3.3.17
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.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/Gemfile.lock +12 -9
- data/README.md +2 -2
- data/jstree-rails-4.gemspec +4 -4
- data/lib/jstree-rails-4/version.rb +1 -1
- data/vendor/assets/images/default/32px.png +0 -0
- data/vendor/assets/images/default/40px.png +0 -0
- data/vendor/assets/images/default/throbber.gif +0 -0
- data/vendor/assets/images/default-dark/32px.png +0 -0
- data/vendor/assets/images/default-dark/40px.png +0 -0
- data/vendor/assets/images/default-dark/throbber.gif +0 -0
- data/vendor/assets/javascripts/jstree.js +840 -518
- data/vendor/assets/stylesheets/jstree-default-dark.scss +35 -37
- data/vendor/assets/stylesheets/jstree-default.scss +22 -24
- metadata +12 -15
@@ -13,7 +13,7 @@
|
|
13
13
|
}(function ($, undefined) {
|
14
14
|
"use strict";
|
15
15
|
/*!
|
16
|
-
* jsTree 3.3.
|
16
|
+
* jsTree 3.3.17
|
17
17
|
* http://jstree.com/
|
18
18
|
*
|
19
19
|
* Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
|
@@ -45,6 +45,15 @@
|
|
45
45
|
src = $('script:last').attr('src'),
|
46
46
|
document = window.document; // local variable is always faster to access then a global
|
47
47
|
|
48
|
+
var setImmediate = window.setImmediate;
|
49
|
+
var Promise = window.Promise;
|
50
|
+
if (!setImmediate && Promise) {
|
51
|
+
// Good enough approximation of setImmediate
|
52
|
+
setImmediate = function (cb, arg) {
|
53
|
+
Promise.resolve(arg).then(cb);
|
54
|
+
};
|
55
|
+
}
|
56
|
+
|
48
57
|
/**
|
49
58
|
* holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances.
|
50
59
|
* @name $.jstree
|
@@ -54,7 +63,7 @@
|
|
54
63
|
* specifies the jstree version in use
|
55
64
|
* @name $.jstree.version
|
56
65
|
*/
|
57
|
-
version : '3.3.
|
66
|
+
version : '3.3.17',
|
58
67
|
/**
|
59
68
|
* holds all the default options used when creating new instances
|
60
69
|
* @name $.jstree.defaults
|
@@ -265,7 +274,7 @@
|
|
265
274
|
* You can also pass in a HTML string or a JSON array here.
|
266
275
|
*
|
267
276
|
* 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.
|
268
|
-
* In addition to the standard jQuery ajax options here you can
|
277
|
+
* 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.
|
269
278
|
*
|
270
279
|
* 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.
|
271
280
|
*
|
@@ -430,10 +439,101 @@
|
|
430
439
|
*/
|
431
440
|
force_text : false,
|
432
441
|
/**
|
433
|
-
* Should the node
|
442
|
+
* Should the node be toggled if the text is double clicked. Defaults to `true`
|
434
443
|
* @name $.jstree.defaults.core.dblclick_toggle
|
435
444
|
*/
|
436
|
-
dblclick_toggle : true
|
445
|
+
dblclick_toggle : true,
|
446
|
+
/**
|
447
|
+
* Should the loaded nodes be part of the state. Defaults to `false`
|
448
|
+
* @name $.jstree.defaults.core.loaded_state
|
449
|
+
*/
|
450
|
+
loaded_state : false,
|
451
|
+
/**
|
452
|
+
* 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`
|
453
|
+
* @name $.jstree.defaults.core.restore_focus
|
454
|
+
*/
|
455
|
+
restore_focus : true,
|
456
|
+
/**
|
457
|
+
* Force to compute and set "aria-setsize" and "aria-posinset" explicitly for each treeitem.
|
458
|
+
* Some browsers may compute incorrect elements position and produce wrong announcements for screen readers. Defaults to `false`
|
459
|
+
* @name $.jstree.defaults.core.compute_elements_positions
|
460
|
+
*/
|
461
|
+
compute_elements_positions : false,
|
462
|
+
/**
|
463
|
+
* 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)
|
464
|
+
* @name $.jstree.defaults.core.keyboard
|
465
|
+
*/
|
466
|
+
keyboard : {
|
467
|
+
'ctrl-space': function (e) {
|
468
|
+
// aria defines space only with Ctrl
|
469
|
+
e.type = "click";
|
470
|
+
$(e.currentTarget).trigger(e);
|
471
|
+
},
|
472
|
+
'enter': function (e) {
|
473
|
+
// enter
|
474
|
+
e.type = "click";
|
475
|
+
$(e.currentTarget).trigger(e);
|
476
|
+
},
|
477
|
+
'left': function (e) {
|
478
|
+
// left
|
479
|
+
e.preventDefault();
|
480
|
+
if(this.is_open(e.currentTarget)) {
|
481
|
+
this.close_node(e.currentTarget);
|
482
|
+
}
|
483
|
+
else {
|
484
|
+
var o = this.get_parent(e.currentTarget);
|
485
|
+
if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').trigger('focus'); }
|
486
|
+
}
|
487
|
+
},
|
488
|
+
'up': function (e) {
|
489
|
+
// up
|
490
|
+
e.preventDefault();
|
491
|
+
var o = this.get_prev_dom(e.currentTarget);
|
492
|
+
if(o && o.length) { o.children('.jstree-anchor').trigger('focus'); }
|
493
|
+
},
|
494
|
+
'right': function (e) {
|
495
|
+
// right
|
496
|
+
e.preventDefault();
|
497
|
+
if(this.is_closed(e.currentTarget)) {
|
498
|
+
this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').trigger('focus'); });
|
499
|
+
}
|
500
|
+
else if (this.is_open(e.currentTarget)) {
|
501
|
+
var o = this.get_node(e.currentTarget, true).children('.jstree-children')[0];
|
502
|
+
if(o) { $(this._firstChild(o)).children('.jstree-anchor').trigger('focus'); }
|
503
|
+
}
|
504
|
+
},
|
505
|
+
'down': function (e) {
|
506
|
+
// down
|
507
|
+
e.preventDefault();
|
508
|
+
var o = this.get_next_dom(e.currentTarget);
|
509
|
+
if(o && o.length) { o.children('.jstree-anchor').trigger('focus'); }
|
510
|
+
},
|
511
|
+
'*': function (e) {
|
512
|
+
// aria defines * on numpad as open_all - not very common
|
513
|
+
this.open_all();
|
514
|
+
},
|
515
|
+
'home': function (e) {
|
516
|
+
// home
|
517
|
+
e.preventDefault();
|
518
|
+
var o = this._firstChild(this.get_container_ul()[0]);
|
519
|
+
if(o) { $(o).children('.jstree-anchor').filter(':visible').trigger('focus'); }
|
520
|
+
},
|
521
|
+
'end': function (e) {
|
522
|
+
// end
|
523
|
+
e.preventDefault();
|
524
|
+
this.element.find('.jstree-anchor').filter(':visible').last().trigger('focus');
|
525
|
+
},
|
526
|
+
'f2': function (e) {
|
527
|
+
// f2 - safe to include - if check_callback is false it will fail
|
528
|
+
e.preventDefault();
|
529
|
+
this.edit(e.currentTarget);
|
530
|
+
}
|
531
|
+
},
|
532
|
+
/**
|
533
|
+
* Should reselecting an already selected node trigger the select and changed callbacks
|
534
|
+
* @name $.jstree.defaults.core.allow_reselect
|
535
|
+
*/
|
536
|
+
allow_reselect : false
|
437
537
|
};
|
438
538
|
$.jstree.core.prototype = {
|
439
539
|
/**
|
@@ -513,7 +613,7 @@
|
|
513
613
|
return this.nodeType === 3 && (!this.nodeValue || /^\s+$/.test(this.nodeValue));
|
514
614
|
})
|
515
615
|
.remove();
|
516
|
-
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='
|
616
|
+
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>");
|
517
617
|
this.element.attr('aria-activedescendant','j' + this._id + '_loading');
|
518
618
|
this._data.core.li_height = this.get_container_ul().children("li").first().outerHeight() || 24;
|
519
619
|
this._data.core.node = this._create_prototype_node();
|
@@ -548,11 +648,13 @@
|
|
548
648
|
this.teardown();
|
549
649
|
},
|
550
650
|
/**
|
551
|
-
* Create prototype node
|
651
|
+
* Create a prototype node
|
652
|
+
* @name _create_prototype_node()
|
653
|
+
* @return {DOMElement}
|
552
654
|
*/
|
553
655
|
_create_prototype_node : function () {
|
554
656
|
var _node = document.createElement('LI'), _temp1, _temp2;
|
555
|
-
_node.setAttribute('role', '
|
657
|
+
_node.setAttribute('role', 'none');
|
556
658
|
_temp1 = document.createElement('I');
|
557
659
|
_temp1.className = 'jstree-icon jstree-ocl';
|
558
660
|
_temp1.setAttribute('role', 'presentation');
|
@@ -561,6 +663,7 @@
|
|
561
663
|
_temp1.className = 'jstree-anchor';
|
562
664
|
_temp1.setAttribute('href','#');
|
563
665
|
_temp1.setAttribute('tabindex','-1');
|
666
|
+
_temp1.setAttribute('role', 'treeitem');
|
564
667
|
_temp2 = document.createElement('I');
|
565
668
|
_temp2.className = 'jstree-icon jstree-themeicon';
|
566
669
|
_temp2.setAttribute('role', 'presentation');
|
@@ -570,6 +673,51 @@
|
|
570
673
|
|
571
674
|
return _node;
|
572
675
|
},
|
676
|
+
_kbevent_to_func : function (e) {
|
677
|
+
var keys = {
|
678
|
+
8: "Backspace", 9: "Tab", 13: "Enter", 19: "Pause", 27: "Esc",
|
679
|
+
32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home",
|
680
|
+
37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "Print", 45: "Insert",
|
681
|
+
46: "Delete", 96: "Numpad0", 97: "Numpad1", 98: "Numpad2", 99 : "Numpad3",
|
682
|
+
100: "Numpad4", 101: "Numpad5", 102: "Numpad6", 103: "Numpad7",
|
683
|
+
104: "Numpad8", 105: "Numpad9", '-13': "NumpadEnter", 112: "F1",
|
684
|
+
113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7",
|
685
|
+
119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "Numlock",
|
686
|
+
145: "Scrolllock", 16: 'Shift', 17: 'Ctrl', 18: 'Alt',
|
687
|
+
48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
|
688
|
+
54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
|
689
|
+
66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
|
690
|
+
73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
|
691
|
+
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
|
692
|
+
87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
|
693
|
+
186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
|
694
|
+
219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*', 173: '-'
|
695
|
+
};
|
696
|
+
var parts = [];
|
697
|
+
if (e.ctrlKey) { parts.push('ctrl'); }
|
698
|
+
if (e.altKey) { parts.push('alt'); }
|
699
|
+
if (e.shiftKey) { parts.push('shift'); }
|
700
|
+
parts.push(keys[e.which] ? keys[e.which].toLowerCase() : e.which);
|
701
|
+
parts = parts.sort().join('-').toLowerCase();
|
702
|
+
if (parts === 'shift-shift' || parts === 'ctrl-ctrl' || parts === 'alt-alt') {
|
703
|
+
return null;
|
704
|
+
}
|
705
|
+
|
706
|
+
var kb = this.settings.core.keyboard, i, tmp;
|
707
|
+
for (i in kb) {
|
708
|
+
if (kb.hasOwnProperty(i)) {
|
709
|
+
tmp = i;
|
710
|
+
if (tmp !== '-' && tmp !== '+') {
|
711
|
+
tmp = tmp.replace('--', '-MINUS').replace('+-', '-MINUS').replace('++', '-PLUS').replace('-+', '-PLUS');
|
712
|
+
tmp = tmp.split(/-|\+/).sort().join('-').replace('MINUS', '-').replace('PLUS', '+').toLowerCase();
|
713
|
+
}
|
714
|
+
if (tmp === parts) {
|
715
|
+
return kb[i];
|
716
|
+
}
|
717
|
+
}
|
718
|
+
}
|
719
|
+
return null;
|
720
|
+
},
|
573
721
|
/**
|
574
722
|
* part of the destroying of an instance. Used internally.
|
575
723
|
* @private
|
@@ -610,111 +758,44 @@
|
|
610
758
|
}
|
611
759
|
}
|
612
760
|
})
|
613
|
-
.on("mousedown.jstree",
|
761
|
+
.on("mousedown.jstree", function (e) {
|
614
762
|
if(e.target === this.element[0]) {
|
615
763
|
e.preventDefault(); // prevent losing focus when clicking scroll arrows (FF, Chrome)
|
616
764
|
was_click = +(new Date()); // ie does not allow to prevent losing focus
|
617
765
|
}
|
618
|
-
}
|
766
|
+
}.bind(this))
|
619
767
|
.on("mousedown.jstree", ".jstree-ocl", function (e) {
|
620
768
|
e.preventDefault(); // prevent any node inside from losing focus when clicking the open/close icon
|
621
769
|
})
|
622
|
-
.on("click.jstree", ".jstree-ocl",
|
770
|
+
.on("click.jstree", ".jstree-ocl", function (e) {
|
623
771
|
this.toggle_node(e.target);
|
624
|
-
}
|
625
|
-
.on("dblclick.jstree", ".jstree-anchor",
|
772
|
+
}.bind(this))
|
773
|
+
.on("dblclick.jstree", ".jstree-anchor", function (e) {
|
626
774
|
if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
|
627
775
|
if(this.settings.core.dblclick_toggle) {
|
628
776
|
this.toggle_node(e.target);
|
629
777
|
}
|
630
|
-
}
|
631
|
-
.on("click.jstree", ".jstree-anchor",
|
778
|
+
}.bind(this))
|
779
|
+
.on("click.jstree", ".jstree-anchor", function (e) {
|
632
780
|
e.preventDefault();
|
633
|
-
if(e.currentTarget !== document.activeElement) { $(e.currentTarget).focus
|
781
|
+
if(e.currentTarget !== document.activeElement) { $(e.currentTarget).trigger('focus'); }
|
634
782
|
this.activate_node(e.currentTarget, e);
|
635
|
-
}
|
636
|
-
.on('keydown.jstree', '.jstree-anchor',
|
783
|
+
}.bind(this))
|
784
|
+
.on('keydown.jstree', '.jstree-anchor', function (e) {
|
637
785
|
if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
|
638
|
-
if(e.which !== 32 && e.which !== 13 && (e.shiftKey || e.ctrlKey || e.altKey || e.metaKey)) { return true; }
|
639
|
-
var o = null;
|
640
786
|
if(this._data.core.rtl) {
|
641
787
|
if(e.which === 37) { e.which = 39; }
|
642
788
|
else if(e.which === 39) { e.which = 37; }
|
643
789
|
}
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
break;
|
651
|
-
case 13: // enter
|
652
|
-
e.type = "click";
|
653
|
-
$(e.currentTarget).trigger(e);
|
654
|
-
break;
|
655
|
-
case 37: // left
|
656
|
-
e.preventDefault();
|
657
|
-
if(this.is_open(e.currentTarget)) {
|
658
|
-
this.close_node(e.currentTarget);
|
659
|
-
}
|
660
|
-
else {
|
661
|
-
o = this.get_parent(e.currentTarget);
|
662
|
-
if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').focus(); }
|
663
|
-
}
|
664
|
-
break;
|
665
|
-
case 38: // up
|
666
|
-
e.preventDefault();
|
667
|
-
o = this.get_prev_dom(e.currentTarget);
|
668
|
-
if(o && o.length) { o.children('.jstree-anchor').focus(); }
|
669
|
-
break;
|
670
|
-
case 39: // right
|
671
|
-
e.preventDefault();
|
672
|
-
if(this.is_closed(e.currentTarget)) {
|
673
|
-
this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); });
|
674
|
-
}
|
675
|
-
else if (this.is_open(e.currentTarget)) {
|
676
|
-
o = this.get_node(e.currentTarget, true).children('.jstree-children')[0];
|
677
|
-
if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); }
|
678
|
-
}
|
679
|
-
break;
|
680
|
-
case 40: // down
|
681
|
-
e.preventDefault();
|
682
|
-
o = this.get_next_dom(e.currentTarget);
|
683
|
-
if(o && o.length) { o.children('.jstree-anchor').focus(); }
|
684
|
-
break;
|
685
|
-
case 106: // aria defines * on numpad as open_all - not very common
|
686
|
-
this.open_all();
|
687
|
-
break;
|
688
|
-
case 36: // home
|
689
|
-
e.preventDefault();
|
690
|
-
o = this._firstChild(this.get_container_ul()[0]);
|
691
|
-
if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); }
|
692
|
-
break;
|
693
|
-
case 35: // end
|
694
|
-
e.preventDefault();
|
695
|
-
this.element.find('.jstree-anchor').filter(':visible').last().focus();
|
696
|
-
break;
|
697
|
-
case 113: // f2 - safe to include - if check_callback is false it will fail
|
698
|
-
e.preventDefault();
|
699
|
-
this.edit(e.currentTarget);
|
700
|
-
break;
|
701
|
-
default:
|
702
|
-
break;
|
703
|
-
/*!
|
704
|
-
// delete
|
705
|
-
case 46:
|
706
|
-
e.preventDefault();
|
707
|
-
o = this.get_node(e.currentTarget);
|
708
|
-
if(o && o.id && o.id !== $.jstree.root) {
|
709
|
-
o = this.is_selected(o) ? this.get_selected() : o;
|
710
|
-
this.delete_node(o);
|
711
|
-
}
|
712
|
-
break;
|
713
|
-
|
714
|
-
*/
|
790
|
+
var f = this._kbevent_to_func(e);
|
791
|
+
if (f) {
|
792
|
+
var r = f.call(this, e);
|
793
|
+
if (r === false || r === true) {
|
794
|
+
return r;
|
795
|
+
}
|
715
796
|
}
|
716
|
-
}
|
717
|
-
.on("load_node.jstree",
|
797
|
+
}.bind(this))
|
798
|
+
.on("load_node.jstree", function (e, data) {
|
718
799
|
if(data.status) {
|
719
800
|
if(data.node.id === $.jstree.root && !this._data.core.loaded) {
|
720
801
|
this._data.core.loaded = true;
|
@@ -729,7 +810,7 @@
|
|
729
810
|
this.trigger("loaded");
|
730
811
|
}
|
731
812
|
if(!this._data.core.ready) {
|
732
|
-
setTimeout(
|
813
|
+
setTimeout(function() {
|
733
814
|
if(this.element && !this.get_container_ul().find('.jstree-loading').length) {
|
734
815
|
this._data.core.ready = true;
|
735
816
|
if(this._data.core.selected.length) {
|
@@ -752,12 +833,12 @@
|
|
752
833
|
*/
|
753
834
|
this.trigger("ready");
|
754
835
|
}
|
755
|
-
}
|
836
|
+
}.bind(this), 0);
|
756
837
|
}
|
757
838
|
}
|
758
|
-
}
|
839
|
+
}.bind(this))
|
759
840
|
// quick searching when the tree is focused
|
760
|
-
.on('keypress.jstree',
|
841
|
+
.on('keypress.jstree', function (e) {
|
761
842
|
if(e.target.tagName && e.target.tagName.toLowerCase() === "input") { return true; }
|
762
843
|
if(tout) { clearTimeout(tout); }
|
763
844
|
tout = setTimeout(function () {
|
@@ -772,50 +853,50 @@
|
|
772
853
|
|
773
854
|
// match for whole word from current node down (including the current node)
|
774
855
|
if(word.length > 1) {
|
775
|
-
col.slice(ind).each(
|
856
|
+
col.slice(ind).each(function (i, v) {
|
776
857
|
if($(v).text().toLowerCase().indexOf(word) === 0) {
|
777
|
-
$(v).focus
|
858
|
+
$(v).trigger('focus');
|
778
859
|
end = true;
|
779
860
|
return false;
|
780
861
|
}
|
781
|
-
}
|
862
|
+
}.bind(this));
|
782
863
|
if(end) { return; }
|
783
864
|
|
784
865
|
// match for whole word from the beginning of the tree
|
785
|
-
col.slice(0, ind).each(
|
866
|
+
col.slice(0, ind).each(function (i, v) {
|
786
867
|
if($(v).text().toLowerCase().indexOf(word) === 0) {
|
787
|
-
$(v).focus
|
868
|
+
$(v).trigger('focus');
|
788
869
|
end = true;
|
789
870
|
return false;
|
790
871
|
}
|
791
|
-
}
|
872
|
+
}.bind(this));
|
792
873
|
if(end) { return; }
|
793
874
|
}
|
794
875
|
// list nodes that start with that letter (only if word consists of a single char)
|
795
876
|
if(new RegExp('^' + chr.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') + '+$').test(word)) {
|
796
877
|
// search for the next node starting with that letter
|
797
|
-
col.slice(ind + 1).each(
|
878
|
+
col.slice(ind + 1).each(function (i, v) {
|
798
879
|
if($(v).text().toLowerCase().charAt(0) === chr) {
|
799
|
-
$(v).focus
|
880
|
+
$(v).trigger('focus');
|
800
881
|
end = true;
|
801
882
|
return false;
|
802
883
|
}
|
803
|
-
}
|
884
|
+
}.bind(this));
|
804
885
|
if(end) { return; }
|
805
886
|
|
806
887
|
// search from the beginning
|
807
|
-
col.slice(0, ind + 1).each(
|
888
|
+
col.slice(0, ind + 1).each(function (i, v) {
|
808
889
|
if($(v).text().toLowerCase().charAt(0) === chr) {
|
809
|
-
$(v).focus
|
890
|
+
$(v).trigger('focus');
|
810
891
|
end = true;
|
811
892
|
return false;
|
812
893
|
}
|
813
|
-
}
|
894
|
+
}.bind(this));
|
814
895
|
if(end) { return; }
|
815
896
|
}
|
816
|
-
}
|
897
|
+
}.bind(this))
|
817
898
|
// THEME RELATED
|
818
|
-
.on("init.jstree",
|
899
|
+
.on("init.jstree", function () {
|
819
900
|
var s = this.settings.core.themes;
|
820
901
|
this._data.core.themes.dots = s.dots;
|
821
902
|
this._data.core.themes.stripes = s.stripes;
|
@@ -823,42 +904,44 @@
|
|
823
904
|
this._data.core.themes.ellipsis = s.ellipsis;
|
824
905
|
this.set_theme(s.name || "default", s.url);
|
825
906
|
this.set_theme_variant(s.variant);
|
826
|
-
}
|
827
|
-
.on("loading.jstree",
|
907
|
+
}.bind(this))
|
908
|
+
.on("loading.jstree", function () {
|
828
909
|
this[ this._data.core.themes.dots ? "show_dots" : "hide_dots" ]();
|
829
910
|
this[ this._data.core.themes.icons ? "show_icons" : "hide_icons" ]();
|
830
911
|
this[ this._data.core.themes.stripes ? "show_stripes" : "hide_stripes" ]();
|
831
912
|
this[ this._data.core.themes.ellipsis ? "show_ellipsis" : "hide_ellipsis" ]();
|
832
|
-
}
|
833
|
-
.on('blur.jstree', '.jstree-anchor',
|
913
|
+
}.bind(this))
|
914
|
+
.on('blur.jstree', '.jstree-anchor', function (e) {
|
834
915
|
this._data.core.focused = null;
|
835
|
-
$(e.currentTarget).filter('.jstree-hovered').mouseleave
|
916
|
+
$(e.currentTarget).filter('.jstree-hovered').trigger('mouseleave');
|
836
917
|
this.element.attr('tabindex', '0');
|
837
|
-
|
838
|
-
|
918
|
+
$(e.currentTarget).attr('tabindex', '-1');
|
919
|
+
}.bind(this))
|
920
|
+
.on('focus.jstree', '.jstree-anchor', function (e) {
|
839
921
|
var tmp = this.get_node(e.currentTarget);
|
840
|
-
if(tmp && tmp.id) {
|
922
|
+
if(tmp && (tmp.id || tmp.id === 0)) {
|
841
923
|
this._data.core.focused = tmp.id;
|
842
924
|
}
|
843
|
-
this.element.find('.jstree-hovered').not(e.currentTarget).mouseleave
|
844
|
-
$(e.currentTarget).mouseenter
|
925
|
+
this.element.find('.jstree-hovered').not(e.currentTarget).trigger('mouseleave');
|
926
|
+
$(e.currentTarget).trigger('mouseenter');
|
845
927
|
this.element.attr('tabindex', '-1');
|
846
|
-
|
847
|
-
|
848
|
-
|
928
|
+
$(e.currentTarget).attr('tabindex', '0');
|
929
|
+
}.bind(this))
|
930
|
+
.on('focus.jstree', function () {
|
931
|
+
if(+(new Date()) - was_click > 500 && !this._data.core.focused && this.settings.core.restore_focus) {
|
849
932
|
was_click = 0;
|
850
933
|
var act = this.get_node(this.element.attr('aria-activedescendant'), true);
|
851
934
|
if(act) {
|
852
|
-
act.find('> .jstree-anchor').focus
|
935
|
+
act.find('> .jstree-anchor').trigger('focus');
|
853
936
|
}
|
854
937
|
}
|
855
|
-
}
|
856
|
-
.on('mouseenter.jstree', '.jstree-anchor',
|
938
|
+
}.bind(this))
|
939
|
+
.on('mouseenter.jstree', '.jstree-anchor', function (e) {
|
857
940
|
this.hover_node(e.currentTarget);
|
858
|
-
}
|
859
|
-
.on('mouseleave.jstree', '.jstree-anchor',
|
941
|
+
}.bind(this))
|
942
|
+
.on('mouseleave.jstree', '.jstree-anchor', function (e) {
|
860
943
|
this.dehover_node(e.currentTarget);
|
861
|
-
}
|
944
|
+
}.bind(this));
|
862
945
|
},
|
863
946
|
/**
|
864
947
|
* part of the destroying of an instance. Used internally.
|
@@ -909,7 +992,7 @@
|
|
909
992
|
*/
|
910
993
|
get_string : function (key) {
|
911
994
|
var a = this.settings.core.strings;
|
912
|
-
if($.
|
995
|
+
if($.vakata.is_function(a)) { return a.call(this, key); }
|
913
996
|
if(a && a[key]) { return a[key]; }
|
914
997
|
return key;
|
915
998
|
},
|
@@ -963,9 +1046,12 @@
|
|
963
1046
|
* @return {Object|jQuery}
|
964
1047
|
*/
|
965
1048
|
get_node : function (obj, as_dom) {
|
966
|
-
if(obj && obj.id) {
|
1049
|
+
if(obj && (obj.id || obj.id === 0)) {
|
967
1050
|
obj = obj.id;
|
968
1051
|
}
|
1052
|
+
if (obj instanceof $ && obj.length && obj[0].id) {
|
1053
|
+
obj = obj[0].id;
|
1054
|
+
}
|
969
1055
|
var dom;
|
970
1056
|
try {
|
971
1057
|
if(this._model.data[obj]) {
|
@@ -977,10 +1063,10 @@
|
|
977
1063
|
else if(typeof obj === "string" && (dom = $('#' + obj.replace($.jstree.idregex,'\\$&'), this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
|
978
1064
|
obj = this._model.data[dom.closest('.jstree-node').attr('id')];
|
979
1065
|
}
|
980
|
-
else if((dom =
|
1066
|
+
else if((dom = this.element.find(obj)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
|
981
1067
|
obj = this._model.data[dom.closest('.jstree-node').attr('id')];
|
982
1068
|
}
|
983
|
-
else if((dom =
|
1069
|
+
else if((dom = this.element.find(obj)).length && dom.hasClass('jstree')) {
|
984
1070
|
obj = this._model.data[$.jstree.root];
|
985
1071
|
}
|
986
1072
|
else {
|
@@ -1114,7 +1200,7 @@
|
|
1114
1200
|
return obj.parent;
|
1115
1201
|
},
|
1116
1202
|
/**
|
1117
|
-
* get a jQuery collection of all the children of a node (node must be rendered)
|
1203
|
+
* get a jQuery collection of all the children of a node (node must be rendered), returns false on error
|
1118
1204
|
* @name get_children_dom(obj)
|
1119
1205
|
* @param {mixed} obj
|
1120
1206
|
* @return {jQuery}
|
@@ -1197,8 +1283,8 @@
|
|
1197
1283
|
* @trigger load_node.jstree
|
1198
1284
|
*/
|
1199
1285
|
load_node : function (obj, callback) {
|
1200
|
-
var k, l, i, j, c;
|
1201
|
-
if($.
|
1286
|
+
var dom = this.get_node(obj, true), k, l, i, j, c;
|
1287
|
+
if($.vakata.is_array(obj)) {
|
1202
1288
|
this._load_nodes(obj.slice(), callback);
|
1203
1289
|
return true;
|
1204
1290
|
}
|
@@ -1234,8 +1320,13 @@
|
|
1234
1320
|
}
|
1235
1321
|
obj.state.failed = false;
|
1236
1322
|
obj.state.loading = true;
|
1237
|
-
|
1238
|
-
|
1323
|
+
if (obj.id !== $.jstree.root) {
|
1324
|
+
dom.children(".jstree-anchor").attr('aria-busy', true);
|
1325
|
+
} else {
|
1326
|
+
dom.attr('aria-busy', true);
|
1327
|
+
}
|
1328
|
+
dom.addClass("jstree-loading");
|
1329
|
+
this._load_node(obj, function (status) {
|
1239
1330
|
obj = this._model.data[obj.id];
|
1240
1331
|
obj.state.loading = false;
|
1241
1332
|
obj.state.loaded = status;
|
@@ -1258,7 +1349,12 @@
|
|
1258
1349
|
}
|
1259
1350
|
}
|
1260
1351
|
}
|
1261
|
-
|
1352
|
+
if (obj.id !== $.jstree.root) {
|
1353
|
+
dom.children(".jstree-anchor").attr('aria-busy', false);
|
1354
|
+
} else {
|
1355
|
+
dom.attr('aria-busy', false);
|
1356
|
+
}
|
1357
|
+
dom.removeClass("jstree-loading");
|
1262
1358
|
/**
|
1263
1359
|
* triggered after a node is loaded
|
1264
1360
|
* @event
|
@@ -1270,11 +1366,11 @@
|
|
1270
1366
|
if(callback) {
|
1271
1367
|
callback.call(this, obj, status);
|
1272
1368
|
}
|
1273
|
-
}
|
1369
|
+
}.bind(this));
|
1274
1370
|
return true;
|
1275
1371
|
},
|
1276
1372
|
/**
|
1277
|
-
* load an array of nodes (will also load unavailable nodes as soon as
|
1373
|
+
* load an array of nodes (will also load unavailable nodes as soon as they appear in the structure). Used internally.
|
1278
1374
|
* @private
|
1279
1375
|
* @name _load_nodes(nodes [, callback])
|
1280
1376
|
* @param {array} nodes
|
@@ -1368,8 +1464,8 @@
|
|
1368
1464
|
}
|
1369
1465
|
// return callback.call(this, obj.id === $.jstree.root ? this._append_html_data(obj, this._data.core.original_container_html.clone(true)) : false);
|
1370
1466
|
}
|
1371
|
-
if($.
|
1372
|
-
return s.call(this, obj,
|
1467
|
+
if($.vakata.is_function(s)) {
|
1468
|
+
return s.call(this, obj, function (d) {
|
1373
1469
|
if(d === false) {
|
1374
1470
|
callback.call(this, false);
|
1375
1471
|
}
|
@@ -1379,19 +1475,19 @@
|
|
1379
1475
|
});
|
1380
1476
|
}
|
1381
1477
|
// 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));
|
1382
|
-
}
|
1478
|
+
}.bind(this));
|
1383
1479
|
}
|
1384
1480
|
if(typeof s === 'object') {
|
1385
1481
|
if(s.url) {
|
1386
1482
|
s = $.extend(true, {}, s);
|
1387
|
-
if($.
|
1483
|
+
if($.vakata.is_function(s.url)) {
|
1388
1484
|
s.url = s.url.call(this, obj);
|
1389
1485
|
}
|
1390
|
-
if($.
|
1486
|
+
if($.vakata.is_function(s.data)) {
|
1391
1487
|
s.data = s.data.call(this, obj);
|
1392
1488
|
}
|
1393
1489
|
return $.ajax(s)
|
1394
|
-
.done(
|
1490
|
+
.done(function (d,t,x) {
|
1395
1491
|
var type = x.getResponseHeader('Content-Type');
|
1396
1492
|
if((type && type.indexOf('json') !== -1) || typeof d === "object") {
|
1397
1493
|
return this._append_json_data(obj, d, function (status) { callback.call(this, status); });
|
@@ -1404,14 +1500,14 @@
|
|
1404
1500
|
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 }) };
|
1405
1501
|
this.settings.core.error.call(this, this._data.core.last_error);
|
1406
1502
|
return callback.call(this, false);
|
1407
|
-
}
|
1408
|
-
.fail(
|
1503
|
+
}.bind(this))
|
1504
|
+
.fail(function (f) {
|
1409
1505
|
this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'core', 'id' : 'core_04', 'reason' : 'Could not load node', 'data' : JSON.stringify({ 'id' : obj.id, 'xhr' : f }) };
|
1410
1506
|
callback.call(this, false);
|
1411
1507
|
this.settings.core.error.call(this, this._data.core.last_error);
|
1412
|
-
}
|
1508
|
+
}.bind(this));
|
1413
1509
|
}
|
1414
|
-
if ($.
|
1510
|
+
if ($.vakata.is_array(s)) {
|
1415
1511
|
t = $.extend(true, [], s);
|
1416
1512
|
} else if ($.isPlainObject(s)) {
|
1417
1513
|
t = $.extend(true, {}, s);
|
@@ -1453,7 +1549,7 @@
|
|
1453
1549
|
*/
|
1454
1550
|
_node_changed : function (obj) {
|
1455
1551
|
obj = this.get_node(obj);
|
1456
|
-
|
1552
|
+
if (obj && $.inArray(obj.id, this._model.changed) === -1) {
|
1457
1553
|
this._model.changed.push(obj.id);
|
1458
1554
|
}
|
1459
1555
|
},
|
@@ -1477,7 +1573,7 @@
|
|
1477
1573
|
p = m[par],
|
1478
1574
|
s = this._data.core.selected.length,
|
1479
1575
|
tmp, i, j;
|
1480
|
-
dat.each(
|
1576
|
+
dat.each(function (i, v) {
|
1481
1577
|
tmp = this._parse_model_from_html($(v), par, p.parents.concat());
|
1482
1578
|
if(tmp) {
|
1483
1579
|
chd.push(tmp);
|
@@ -1486,7 +1582,7 @@
|
|
1486
1582
|
dpc = dpc.concat(m[tmp].children_d);
|
1487
1583
|
}
|
1488
1584
|
}
|
1489
|
-
}
|
1585
|
+
}.bind(this));
|
1490
1586
|
p.children = chd;
|
1491
1587
|
p.children_d = dpc;
|
1492
1588
|
for(i = 0, j = p.parents.length; i < j; i++) {
|
@@ -1534,7 +1630,7 @@
|
|
1534
1630
|
data = JSON.parse(data);
|
1535
1631
|
}
|
1536
1632
|
}
|
1537
|
-
if(!$.
|
1633
|
+
if(!$.vakata.is_array(data)) { data = [data]; }
|
1538
1634
|
var w = null,
|
1539
1635
|
args = {
|
1540
1636
|
'df' : this._model.default_state,
|
@@ -1545,6 +1641,7 @@
|
|
1545
1641
|
't_cnt' : this._cnt,
|
1546
1642
|
'sel' : this._data.core.selected
|
1547
1643
|
},
|
1644
|
+
inst = this,
|
1548
1645
|
func = function (data, undefined) {
|
1549
1646
|
if(data.data) { data = data.data; }
|
1550
1647
|
var dat = data.dat,
|
@@ -1674,7 +1771,7 @@
|
|
1674
1771
|
tmp.state[i] = df[i];
|
1675
1772
|
}
|
1676
1773
|
}
|
1677
|
-
if(d && d.id) { tmp.id = d.id.toString(); }
|
1774
|
+
if(d && (d.id || d.id === 0)) { tmp.id = d.id.toString(); }
|
1678
1775
|
if(d && d.text) { tmp.text = d.text; }
|
1679
1776
|
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
|
1680
1777
|
tmp.icon = d.data.jstree.icon;
|
@@ -1706,10 +1803,10 @@
|
|
1706
1803
|
}
|
1707
1804
|
}
|
1708
1805
|
}
|
1709
|
-
if(tmp.li_attr.id && !tmp.id) {
|
1806
|
+
if(tmp.li_attr.id && !(tmp.id || tmp.id === 0)) {
|
1710
1807
|
tmp.id = tmp.li_attr.id.toString();
|
1711
1808
|
}
|
1712
|
-
if(!tmp.id) {
|
1809
|
+
if(!(tmp.id || tmp.id === 0)) {
|
1713
1810
|
tmp.id = tid;
|
1714
1811
|
}
|
1715
1812
|
if(!tmp.li_attr.id) {
|
@@ -1755,10 +1852,21 @@
|
|
1755
1852
|
if(!dat[i].children) {
|
1756
1853
|
dat[i].children = [];
|
1757
1854
|
}
|
1855
|
+
if(!dat[i].state) {
|
1856
|
+
dat[i].state = {};
|
1857
|
+
}
|
1758
1858
|
m[dat[i].id.toString()] = dat[i];
|
1759
1859
|
}
|
1760
1860
|
// 2) populate children (foreach)
|
1761
1861
|
for(i = 0, j = dat.length; i < j; i++) {
|
1862
|
+
if (!m[dat[i].parent.toString()]) {
|
1863
|
+
if (typeof inst !== "undefined") {
|
1864
|
+
inst._data.core.last_error = { 'error' : 'parse', 'plugin' : 'core', 'id' : 'core_07', 'reason' : 'Node with invalid parent', 'data' : JSON.stringify({ 'id' : dat[i].id.toString(), 'parent' : dat[i].parent.toString() }) };
|
1865
|
+
inst.settings.core.error.call(inst, inst._data.core.last_error);
|
1866
|
+
}
|
1867
|
+
continue;
|
1868
|
+
}
|
1869
|
+
|
1762
1870
|
m[dat[i].parent.toString()].children.push(dat[i].id.toString());
|
1763
1871
|
// populate parent.children_d
|
1764
1872
|
p.children_d.push(dat[i].id.toString());
|
@@ -1863,7 +1971,16 @@
|
|
1863
1971
|
if(rslt.add.length) {
|
1864
1972
|
this.trigger('changed', { 'action' : 'model', 'selected' : this._data.core.selected });
|
1865
1973
|
}
|
1866
|
-
|
1974
|
+
|
1975
|
+
// If no worker, try to mimic worker behavioour, by invoking cb asynchronously
|
1976
|
+
if (!worker && setImmediate) {
|
1977
|
+
setImmediate(function(){
|
1978
|
+
cb.call(inst, true);
|
1979
|
+
});
|
1980
|
+
}
|
1981
|
+
else {
|
1982
|
+
cb.call(inst, true);
|
1983
|
+
}
|
1867
1984
|
};
|
1868
1985
|
if(this.settings.core.worker && window.Blob && window.URL && window.Worker) {
|
1869
1986
|
try {
|
@@ -1878,7 +1995,7 @@
|
|
1878
1995
|
if(!this._data.core.working || force_processing) {
|
1879
1996
|
this._data.core.working = true;
|
1880
1997
|
w = new window.Worker(this._wrk);
|
1881
|
-
w.onmessage =
|
1998
|
+
w.onmessage = function (e) {
|
1882
1999
|
rslt.call(this, e.data, true);
|
1883
2000
|
try { w.terminate(); w = null; } catch(ignore) { }
|
1884
2001
|
if(this._data.core.worker_queue.length) {
|
@@ -1887,7 +2004,16 @@
|
|
1887
2004
|
else {
|
1888
2005
|
this._data.core.working = false;
|
1889
2006
|
}
|
1890
|
-
}
|
2007
|
+
}.bind(this);
|
2008
|
+
w.onerror = function (e) {
|
2009
|
+
rslt.call(this, func(args), false);
|
2010
|
+
if(this._data.core.worker_queue.length) {
|
2011
|
+
this._append_json_data.apply(this, this._data.core.worker_queue.shift());
|
2012
|
+
}
|
2013
|
+
else {
|
2014
|
+
this._data.core.working = false;
|
2015
|
+
}
|
2016
|
+
}.bind(this);
|
1891
2017
|
if(!args.par) {
|
1892
2018
|
if(this._data.core.worker_queue.length) {
|
1893
2019
|
this._append_json_data.apply(this, this._data.core.worker_queue.shift());
|
@@ -1953,7 +2079,7 @@
|
|
1953
2079
|
}
|
1954
2080
|
tmp = $.vakata.attributes(d, true);
|
1955
2081
|
$.each(tmp, function (i, v) {
|
1956
|
-
v = $.trim(v);
|
2082
|
+
v = $.vakata.trim(v);
|
1957
2083
|
if(!v.length) { return true; }
|
1958
2084
|
data.li_attr[i] = v;
|
1959
2085
|
if(i === 'id') {
|
@@ -1964,7 +2090,7 @@
|
|
1964
2090
|
if(tmp.length) {
|
1965
2091
|
tmp = $.vakata.attributes(tmp, true);
|
1966
2092
|
$.each(tmp, function (i, v) {
|
1967
|
-
v = $.trim(v);
|
2093
|
+
v = $.vakata.trim(v);
|
1968
2094
|
if(v.length) {
|
1969
2095
|
data.a_attr[i] = v;
|
1970
2096
|
}
|
@@ -1973,7 +2099,7 @@
|
|
1973
2099
|
tmp = d.children("a").first().length ? d.children("a").first().clone() : d.clone();
|
1974
2100
|
tmp.children("ins, i, ul").remove();
|
1975
2101
|
tmp = tmp.html();
|
1976
|
-
tmp = $('<div
|
2102
|
+
tmp = $('<div></div>').html(tmp);
|
1977
2103
|
data.text = this.settings.core.force_text ? tmp.text() : tmp.html();
|
1978
2104
|
tmp = d.data();
|
1979
2105
|
data.data = tmp ? $.extend(true, {}, tmp) : null;
|
@@ -2003,14 +2129,14 @@
|
|
2003
2129
|
} while(m[tid]);
|
2004
2130
|
data.id = data.li_attr.id ? data.li_attr.id.toString() : tid;
|
2005
2131
|
if(tmp.length) {
|
2006
|
-
tmp.each(
|
2132
|
+
tmp.each(function (i, v) {
|
2007
2133
|
c = this._parse_model_from_html($(v), data.id, ps);
|
2008
2134
|
e = this._model.data[c];
|
2009
2135
|
data.children.push(c);
|
2010
2136
|
if(e.children_d.length) {
|
2011
2137
|
data.children_d = data.children_d.concat(e.children_d);
|
2012
2138
|
}
|
2013
|
-
}
|
2139
|
+
}.bind(this));
|
2014
2140
|
data.children_d = data.children_d.concat(data.children);
|
2015
2141
|
}
|
2016
2142
|
else {
|
@@ -2165,7 +2291,7 @@
|
|
2165
2291
|
tmp.state[i] = df[i];
|
2166
2292
|
}
|
2167
2293
|
}
|
2168
|
-
if(d && d.id) { tmp.id = d.id.toString(); }
|
2294
|
+
if(d && (d.id || d.id === 0)) { tmp.id = d.id.toString(); }
|
2169
2295
|
if(d && d.text) { tmp.text = d.text; }
|
2170
2296
|
if(d && d.data && d.data.jstree && d.data.jstree.icon) {
|
2171
2297
|
tmp.icon = d.data.jstree.icon;
|
@@ -2197,10 +2323,10 @@
|
|
2197
2323
|
}
|
2198
2324
|
}
|
2199
2325
|
}
|
2200
|
-
if(tmp.li_attr.id && !tmp.id) {
|
2326
|
+
if(tmp.li_attr.id && !(tmp.id || tmp.id === 0)) {
|
2201
2327
|
tmp.id = tmp.li_attr.id.toString();
|
2202
2328
|
}
|
2203
|
-
if(!tmp.id) {
|
2329
|
+
if(!(tmp.id || tmp.id === 0)) {
|
2204
2330
|
tmp.id = tid;
|
2205
2331
|
}
|
2206
2332
|
if(!tmp.li_attr.id) {
|
@@ -2222,7 +2348,7 @@
|
|
2222
2348
|
tmp.children_d = tmp.children_d.concat(e.children_d);
|
2223
2349
|
}
|
2224
2350
|
}
|
2225
|
-
tmp.children_d = tmp.
|
2351
|
+
tmp.children_d = tmp.children.concat(tmp.children_d);
|
2226
2352
|
}
|
2227
2353
|
if(d && d.children && d.children === true) {
|
2228
2354
|
tmp.state.loaded = false;
|
@@ -2255,14 +2381,14 @@
|
|
2255
2381
|
}
|
2256
2382
|
if(this._model.force_full_redraw) {
|
2257
2383
|
f.className = this.get_container_ul()[0].className;
|
2258
|
-
f.setAttribute('role','
|
2384
|
+
f.setAttribute('role','presentation');
|
2259
2385
|
this.element.empty().append(f);
|
2260
2386
|
//this.get_container_ul()[0].appendChild(f);
|
2261
2387
|
}
|
2262
|
-
if(fe !== null) {
|
2388
|
+
if(fe !== null && this.settings.core.restore_focus) {
|
2263
2389
|
tmp = this.get_node(fe, true);
|
2264
2390
|
if(tmp && tmp.length && tmp.children('.jstree-anchor')[0] !== document.activeElement) {
|
2265
|
-
tmp.children('.jstree-anchor').focus
|
2391
|
+
tmp.children('.jstree-anchor').trigger('focus');
|
2266
2392
|
}
|
2267
2393
|
else {
|
2268
2394
|
this._data.core.focused = null;
|
@@ -2403,11 +2529,14 @@
|
|
2403
2529
|
if(!obj.a_attr.id) {
|
2404
2530
|
obj.a_attr.id = obj.id + '_anchor';
|
2405
2531
|
}
|
2406
|
-
node.setAttribute('aria-selected', !!obj.state.selected);
|
2407
|
-
node.setAttribute('aria-level', obj.parents.length);
|
2408
|
-
|
2532
|
+
node.childNodes[1].setAttribute('aria-selected', !!obj.state.selected);
|
2533
|
+
node.childNodes[1].setAttribute('aria-level', obj.parents.length);
|
2534
|
+
if(this.settings.core.compute_elements_positions) {
|
2535
|
+
node.childNodes[1].setAttribute('aria-setsize', m[obj.parent].children.length);
|
2536
|
+
node.childNodes[1].setAttribute('aria-posinset', m[obj.parent].children.indexOf(obj.id) + 1);
|
2537
|
+
}
|
2409
2538
|
if(obj.state.disabled) {
|
2410
|
-
node.setAttribute('aria-disabled', true);
|
2539
|
+
node.childNodes[1].setAttribute('aria-disabled', true);
|
2411
2540
|
}
|
2412
2541
|
|
2413
2542
|
for(i = 0, j = obj.children.length; i < j; i++) {
|
@@ -2435,12 +2564,15 @@
|
|
2435
2564
|
if(obj.state.hidden) {
|
2436
2565
|
c += ' jstree-hidden';
|
2437
2566
|
}
|
2567
|
+
if (obj.state.loading) {
|
2568
|
+
c += ' jstree-loading';
|
2569
|
+
}
|
2438
2570
|
if(obj.state.loaded && !has_children) {
|
2439
2571
|
c += ' jstree-leaf';
|
2440
2572
|
}
|
2441
2573
|
else {
|
2442
2574
|
c += obj.state.opened && obj.state.loaded ? ' jstree-open' : ' jstree-closed';
|
2443
|
-
node.setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) );
|
2575
|
+
node.childNodes[1].setAttribute('aria-expanded', (obj.state.opened && obj.state.loaded) );
|
2444
2576
|
}
|
2445
2577
|
if(last_sibling === obj.id) {
|
2446
2578
|
c += ' jstree-last';
|
@@ -2532,14 +2664,14 @@
|
|
2532
2664
|
}
|
2533
2665
|
if(obj.state.opened && !obj.state.loaded) {
|
2534
2666
|
obj.state.opened = false;
|
2535
|
-
setTimeout(
|
2667
|
+
setTimeout(function () {
|
2536
2668
|
this.open_node(obj.id, false, 0);
|
2537
|
-
}
|
2669
|
+
}.bind(this), 0);
|
2538
2670
|
}
|
2539
2671
|
return node;
|
2540
2672
|
},
|
2541
2673
|
/**
|
2542
|
-
* opens a node,
|
2674
|
+
* opens a node, revealing its children. If the node is not loaded it will be loaded and opened once ready.
|
2543
2675
|
* @name open_node(obj [, callback, animation])
|
2544
2676
|
* @param {mixed} obj the node to open
|
2545
2677
|
* @param {Function} callback a function to execute once the node is opened
|
@@ -2548,7 +2680,7 @@
|
|
2548
2680
|
*/
|
2549
2681
|
open_node : function (obj, callback, animation) {
|
2550
2682
|
var t1, t2, d, t;
|
2551
|
-
if($.
|
2683
|
+
if($.vakata.is_array(obj)) {
|
2552
2684
|
obj = obj.slice();
|
2553
2685
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
2554
2686
|
this.open_node(obj[t1], callback, animation);
|
@@ -2568,9 +2700,9 @@
|
|
2568
2700
|
}
|
2569
2701
|
if(!this.is_loaded(obj)) {
|
2570
2702
|
if(this.is_loading(obj)) {
|
2571
|
-
return setTimeout(
|
2703
|
+
return setTimeout(function () {
|
2572
2704
|
this.open_node(obj, callback, animation);
|
2573
|
-
}
|
2705
|
+
}.bind(this), 500);
|
2574
2706
|
}
|
2575
2707
|
this.load_node(obj, function (o, ok) {
|
2576
2708
|
return ok ? this.open_node(o, callback, animation) : (callback ? callback.call(this, o, false) : false);
|
@@ -2590,13 +2722,14 @@
|
|
2590
2722
|
if(!animation) {
|
2591
2723
|
this.trigger('before_open', { "node" : obj });
|
2592
2724
|
d[0].className = d[0].className.replace('jstree-closed', 'jstree-open');
|
2593
|
-
d[0].setAttribute("aria-expanded", true);
|
2725
|
+
d[0].childNodes[1].setAttribute("aria-expanded", true);
|
2594
2726
|
}
|
2595
2727
|
else {
|
2596
2728
|
this.trigger('before_open', { "node" : obj });
|
2597
2729
|
d
|
2598
2730
|
.children(".jstree-children").css("display","none").end()
|
2599
|
-
.removeClass("jstree-closed").addClass("jstree-open")
|
2731
|
+
.removeClass("jstree-closed").addClass("jstree-open")
|
2732
|
+
.children('.jstree-anchor').attr("aria-expanded", true).end()
|
2600
2733
|
.children(".jstree-children").stop(true, true)
|
2601
2734
|
.slideDown(animation, function () {
|
2602
2735
|
this.style.display = "";
|
@@ -2666,7 +2799,7 @@
|
|
2666
2799
|
*/
|
2667
2800
|
close_node : function (obj, animation) {
|
2668
2801
|
var t1, t2, t, d;
|
2669
|
-
if($.
|
2802
|
+
if($.vakata.is_array(obj)) {
|
2670
2803
|
obj = obj.slice();
|
2671
2804
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
2672
2805
|
this.close_node(obj[t1], animation);
|
@@ -2704,13 +2837,15 @@
|
|
2704
2837
|
else {
|
2705
2838
|
if(!animation) {
|
2706
2839
|
d[0].className = d[0].className.replace('jstree-open', 'jstree-closed');
|
2707
|
-
d.attr("aria-expanded", false)
|
2840
|
+
d.children('.jstree-anchor').attr("aria-expanded", false);
|
2841
|
+
d.children('.jstree-children').remove();
|
2708
2842
|
this.trigger("after_close", { "node" : obj });
|
2709
2843
|
}
|
2710
2844
|
else {
|
2711
2845
|
d
|
2712
2846
|
.children(".jstree-children").attr("style","display:block !important").end()
|
2713
|
-
.removeClass("jstree-open").addClass("jstree-closed")
|
2847
|
+
.removeClass("jstree-open").addClass("jstree-closed")
|
2848
|
+
.children('.jstree-anchor').attr("aria-expanded", false).end()
|
2714
2849
|
.children(".jstree-children").stop(true, true).slideUp(animation, function () {
|
2715
2850
|
this.style.display = "";
|
2716
2851
|
d.children('.jstree-children').remove();
|
@@ -2728,7 +2863,7 @@
|
|
2728
2863
|
*/
|
2729
2864
|
toggle_node : function (obj) {
|
2730
2865
|
var t1, t2;
|
2731
|
-
if($.
|
2866
|
+
if($.vakata.is_array(obj)) {
|
2732
2867
|
obj = obj.slice();
|
2733
2868
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
2734
2869
|
this.toggle_node(obj[t1]);
|
@@ -2743,7 +2878,7 @@
|
|
2743
2878
|
}
|
2744
2879
|
},
|
2745
2880
|
/**
|
2746
|
-
* opens all nodes within a node (or the tree),
|
2881
|
+
* 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.
|
2747
2882
|
* @name open_all([obj, animation, original_obj])
|
2748
2883
|
* @param {mixed} obj the node to open recursively, omit to open all nodes in the tree
|
2749
2884
|
* @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation
|
@@ -2784,7 +2919,7 @@
|
|
2784
2919
|
}
|
2785
2920
|
},
|
2786
2921
|
/**
|
2787
|
-
* closes all nodes within a node (or the tree),
|
2922
|
+
* closes all nodes within a node (or the tree), revealing their children
|
2788
2923
|
* @name close_all([obj, animation])
|
2789
2924
|
* @param {mixed} obj the node to close recursively, omit to close all nodes in the tree
|
2790
2925
|
* @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation
|
@@ -2829,7 +2964,7 @@
|
|
2829
2964
|
*/
|
2830
2965
|
enable_node : function (obj) {
|
2831
2966
|
var t1, t2;
|
2832
|
-
if($.
|
2967
|
+
if($.vakata.is_array(obj)) {
|
2833
2968
|
obj = obj.slice();
|
2834
2969
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
2835
2970
|
this.enable_node(obj[t1]);
|
@@ -2858,7 +2993,7 @@
|
|
2858
2993
|
*/
|
2859
2994
|
disable_node : function (obj) {
|
2860
2995
|
var t1, t2;
|
2861
|
-
if($.
|
2996
|
+
if($.vakata.is_array(obj)) {
|
2862
2997
|
obj = obj.slice();
|
2863
2998
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
2864
2999
|
this.disable_node(obj[t1]);
|
@@ -2897,7 +3032,7 @@
|
|
2897
3032
|
*/
|
2898
3033
|
hide_node : function (obj, skip_redraw) {
|
2899
3034
|
var t1, t2;
|
2900
|
-
if($.
|
3035
|
+
if($.vakata.is_array(obj)) {
|
2901
3036
|
obj = obj.slice();
|
2902
3037
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
2903
3038
|
this.hide_node(obj[t1], true);
|
@@ -2935,7 +3070,7 @@
|
|
2935
3070
|
*/
|
2936
3071
|
show_node : function (obj, skip_redraw) {
|
2937
3072
|
var t1, t2;
|
2938
|
-
if($.
|
3073
|
+
if($.vakata.is_array(obj)) {
|
2939
3074
|
obj = obj.slice();
|
2940
3075
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
2941
3076
|
this.show_node(obj[t1], true);
|
@@ -3042,8 +3177,10 @@
|
|
3042
3177
|
this.deselect_node(obj, false, e);
|
3043
3178
|
}
|
3044
3179
|
else {
|
3045
|
-
this.
|
3046
|
-
|
3180
|
+
if (this.settings.core.allow_reselect || !this.is_selected(obj) || this._data.core.selected.length !== 1) {
|
3181
|
+
this.deselect_all(true);
|
3182
|
+
this.select_node(obj, false, false, e);
|
3183
|
+
}
|
3047
3184
|
this._data.core.last_clicked = this.get_node(obj);
|
3048
3185
|
}
|
3049
3186
|
}
|
@@ -3068,13 +3205,18 @@
|
|
3068
3205
|
}
|
3069
3206
|
}
|
3070
3207
|
else {
|
3071
|
-
|
3208
|
+
if (!e.ctrlKey) {
|
3209
|
+
this.deselect_node(p[i], true, e);
|
3210
|
+
}
|
3072
3211
|
}
|
3073
3212
|
}
|
3074
3213
|
this.trigger('changed', { 'action' : 'select_node', 'node' : this.get_node(obj), 'selected' : this._data.core.selected, 'event' : e });
|
3075
3214
|
}
|
3076
3215
|
else {
|
3077
3216
|
if(!this.is_selected(obj)) {
|
3217
|
+
if (e.ctrlKey) {
|
3218
|
+
this._data.core.last_clicked = this.get_node(obj);
|
3219
|
+
}
|
3078
3220
|
this.select_node(obj, false, false, e);
|
3079
3221
|
}
|
3080
3222
|
else {
|
@@ -3147,7 +3289,7 @@
|
|
3147
3289
|
*/
|
3148
3290
|
select_node : function (obj, supress_event, prevent_open, e) {
|
3149
3291
|
var dom, t1, t2, th;
|
3150
|
-
if($.
|
3292
|
+
if($.vakata.is_array(obj)) {
|
3151
3293
|
obj = obj.slice();
|
3152
3294
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
3153
3295
|
this.select_node(obj[t1], supress_event, prevent_open, e);
|
@@ -3166,7 +3308,7 @@
|
|
3166
3308
|
dom = this._open_to(obj);
|
3167
3309
|
}
|
3168
3310
|
if(dom && dom.length) {
|
3169
|
-
dom.
|
3311
|
+
dom.children('.jstree-anchor').addClass('jstree-clicked').attr('aria-selected', true);
|
3170
3312
|
}
|
3171
3313
|
/**
|
3172
3314
|
* triggered when an node is selected
|
@@ -3200,7 +3342,7 @@
|
|
3200
3342
|
*/
|
3201
3343
|
deselect_node : function (obj, supress_event, e) {
|
3202
3344
|
var t1, t2, dom;
|
3203
|
-
if($.
|
3345
|
+
if($.vakata.is_array(obj)) {
|
3204
3346
|
obj = obj.slice();
|
3205
3347
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
3206
3348
|
this.deselect_node(obj[t1], supress_event, e);
|
@@ -3216,7 +3358,7 @@
|
|
3216
3358
|
obj.state.selected = false;
|
3217
3359
|
this._data.core.selected = $.vakata.array_remove_item(this._data.core.selected, obj.id);
|
3218
3360
|
if(dom.length) {
|
3219
|
-
dom.
|
3361
|
+
dom.children('.jstree-anchor').removeClass('jstree-clicked').attr('aria-selected', false);
|
3220
3362
|
}
|
3221
3363
|
/**
|
3222
3364
|
* triggered when an node is deselected
|
@@ -3272,7 +3414,7 @@
|
|
3272
3414
|
}
|
3273
3415
|
}
|
3274
3416
|
this._data.core.selected = [];
|
3275
|
-
this.element.find('.jstree-clicked').removeClass('jstree-clicked').
|
3417
|
+
this.element.find('.jstree-clicked').removeClass('jstree-clicked').attr('aria-selected', false);
|
3276
3418
|
/**
|
3277
3419
|
* triggered when all nodes are deselected
|
3278
3420
|
* @event
|
@@ -3305,7 +3447,7 @@
|
|
3305
3447
|
* @return {Array}
|
3306
3448
|
*/
|
3307
3449
|
get_selected : function (full) {
|
3308
|
-
return full ? $.map(this._data.core.selected,
|
3450
|
+
return full ? $.map(this._data.core.selected, function (i) { return this.get_node(i); }.bind(this)) : this._data.core.selected.slice();
|
3309
3451
|
},
|
3310
3452
|
/**
|
3311
3453
|
* get an array of all top level selected nodes (ignoring children of selected nodes)
|
@@ -3332,7 +3474,7 @@
|
|
3332
3474
|
tmp.push(i);
|
3333
3475
|
}
|
3334
3476
|
}
|
3335
|
-
return full ? $.map(tmp,
|
3477
|
+
return full ? $.map(tmp, function (i) { return this.get_node(i); }.bind(this)) : tmp;
|
3336
3478
|
},
|
3337
3479
|
/**
|
3338
3480
|
* get an array of all bottom level selected nodes (ignoring selected parents)
|
@@ -3348,7 +3490,7 @@
|
|
3348
3490
|
obj.push(tmp[i].id);
|
3349
3491
|
}
|
3350
3492
|
}
|
3351
|
-
return full ? $.map(obj,
|
3493
|
+
return full ? $.map(obj, function (i) { return this.get_node(i); }.bind(this)) : obj;
|
3352
3494
|
},
|
3353
3495
|
/**
|
3354
3496
|
* gets the current state of the tree so that it can be restored later with `set_state(state)`. Used internally.
|
@@ -3360,6 +3502,7 @@
|
|
3360
3502
|
var state = {
|
3361
3503
|
'core' : {
|
3362
3504
|
'open' : [],
|
3505
|
+
'loaded' : [],
|
3363
3506
|
'scroll' : {
|
3364
3507
|
'left' : this.element.scrollLeft(),
|
3365
3508
|
'top' : this.element.scrollTop()
|
@@ -3377,6 +3520,9 @@
|
|
3377
3520
|
for(i in this._model.data) {
|
3378
3521
|
if(this._model.data.hasOwnProperty(i)) {
|
3379
3522
|
if(i !== $.jstree.root) {
|
3523
|
+
if(this._model.data[i].state.loaded && this.settings.core.loaded_state) {
|
3524
|
+
state.core.loaded.push(i);
|
3525
|
+
}
|
3380
3526
|
if(this._model.data[i].state.opened) {
|
3381
3527
|
state.core.open.push(i);
|
3382
3528
|
}
|
@@ -3403,8 +3549,21 @@
|
|
3403
3549
|
}
|
3404
3550
|
if(state.core) {
|
3405
3551
|
var res, n, t, _this, i;
|
3552
|
+
if(state.core.loaded) {
|
3553
|
+
if(!this.settings.core.loaded_state || !$.vakata.is_array(state.core.loaded) || !state.core.loaded.length) {
|
3554
|
+
delete state.core.loaded;
|
3555
|
+
this.set_state(state, callback);
|
3556
|
+
}
|
3557
|
+
else {
|
3558
|
+
this._load_nodes(state.core.loaded, function (nodes) {
|
3559
|
+
delete state.core.loaded;
|
3560
|
+
this.set_state(state, callback);
|
3561
|
+
});
|
3562
|
+
}
|
3563
|
+
return false;
|
3564
|
+
}
|
3406
3565
|
if(state.core.open) {
|
3407
|
-
if(!$.
|
3566
|
+
if(!$.vakata.is_array(state.core.open) || !state.core.open.length) {
|
3408
3567
|
delete state.core.open;
|
3409
3568
|
this.set_state(state, callback);
|
3410
3569
|
}
|
@@ -3478,7 +3637,7 @@
|
|
3478
3637
|
*/
|
3479
3638
|
refresh : function (skip_loading, forget_state) {
|
3480
3639
|
this._data.core.state = forget_state === true ? {} : this.get_state();
|
3481
|
-
if(forget_state && $.
|
3640
|
+
if(forget_state && $.vakata.is_function(forget_state)) { this._data.core.state = forget_state.call(this, this._data.core.state); }
|
3482
3641
|
this._cnt = 0;
|
3483
3642
|
this._model.data = {};
|
3484
3643
|
this._model.data[$.jstree.root] = {
|
@@ -3495,7 +3654,7 @@
|
|
3495
3654
|
|
3496
3655
|
var c = this.get_container_ul()[0].className;
|
3497
3656
|
if(!skip_loading) {
|
3498
|
-
this.element.html("<"+"ul class='"+c+"' role='group'><"+"li class='jstree-initial-node jstree-loading jstree-leaf jstree-last' role='
|
3657
|
+
this.element.html("<"+"ul class='"+c+"' 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>");
|
3499
3658
|
this.element.attr('aria-activedescendant','j'+this._id+'_loading');
|
3500
3659
|
}
|
3501
3660
|
this.load_node($.jstree.root, function (o, s) {
|
@@ -3529,7 +3688,7 @@
|
|
3529
3688
|
to_load.push(obj.id);
|
3530
3689
|
if(obj.state.opened === true) { opened.push(obj.id); }
|
3531
3690
|
this.get_node(obj, true).find('.jstree-open').each(function() { to_load.push(this.id); opened.push(this.id); });
|
3532
|
-
this._load_nodes(to_load,
|
3691
|
+
this._load_nodes(to_load, function (nodes) {
|
3533
3692
|
this.open_node(opened, false, 0);
|
3534
3693
|
this.select_node(s);
|
3535
3694
|
/**
|
@@ -3540,7 +3699,7 @@
|
|
3540
3699
|
* @param {Array} nodes - an array of the IDs of the nodes that were reloaded
|
3541
3700
|
*/
|
3542
3701
|
this.trigger('refresh_node', { 'node' : obj, 'nodes' : nodes });
|
3543
|
-
}
|
3702
|
+
}.bind(this), false, true);
|
3544
3703
|
},
|
3545
3704
|
/**
|
3546
3705
|
* set (change) the ID of a node
|
@@ -3612,7 +3771,7 @@
|
|
3612
3771
|
*/
|
3613
3772
|
set_text : function (obj, val) {
|
3614
3773
|
var t1, t2;
|
3615
|
-
if($.
|
3774
|
+
if($.vakata.is_array(obj)) {
|
3616
3775
|
obj = obj.slice();
|
3617
3776
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
3618
3777
|
this.set_text(obj[t1], val);
|
@@ -3660,7 +3819,7 @@
|
|
3660
3819
|
'li_attr' : $.extend(true, {}, obj.li_attr),
|
3661
3820
|
'a_attr' : $.extend(true, {}, obj.a_attr),
|
3662
3821
|
'state' : {},
|
3663
|
-
'data' : options && options.no_data ? false : $.extend(true, $.
|
3822
|
+
'data' : options && options.no_data ? false : $.extend(true, $.vakata.is_array(obj.data)?[]:{}, obj.data)
|
3664
3823
|
//( this.get_node(obj, true).length ? this.get_node(obj, true).data() : obj.data ),
|
3665
3824
|
}, i, j;
|
3666
3825
|
if(options && options.flat) {
|
@@ -3763,7 +3922,7 @@
|
|
3763
3922
|
break;
|
3764
3923
|
}
|
3765
3924
|
if(pos > par.children.length) { pos = par.children.length; }
|
3766
|
-
if(
|
3925
|
+
if(node.id === undefined) { node.id = true; }
|
3767
3926
|
if(!this.check("create_node", node, par, pos)) {
|
3768
3927
|
this.settings.core.error.call(this, this._data.core.last_error);
|
3769
3928
|
return false;
|
@@ -3812,7 +3971,7 @@
|
|
3812
3971
|
*/
|
3813
3972
|
rename_node : function (obj, val) {
|
3814
3973
|
var t1, t2, old;
|
3815
|
-
if($.
|
3974
|
+
if($.vakata.is_array(obj)) {
|
3816
3975
|
obj = obj.slice();
|
3817
3976
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
3818
3977
|
this.rename_node(obj[t1], val);
|
@@ -3847,7 +4006,7 @@
|
|
3847
4006
|
*/
|
3848
4007
|
delete_node : function (obj) {
|
3849
4008
|
var t1, t2, par, pos, tmp, i, j, k, l, c, top, lft;
|
3850
|
-
if($.
|
4009
|
+
if($.vakata.is_array(obj)) {
|
3851
4010
|
obj = obj.slice();
|
3852
4011
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
3853
4012
|
this.delete_node(obj[t1]);
|
@@ -3904,11 +4063,11 @@
|
|
3904
4063
|
lft = this.element[0].scrollLeft;
|
3905
4064
|
if(par.id === $.jstree.root) {
|
3906
4065
|
if (this._model.data[$.jstree.root].children[0]) {
|
3907
|
-
this.get_node(this._model.data[$.jstree.root].children[0], true).children('.jstree-anchor').focus
|
4066
|
+
this.get_node(this._model.data[$.jstree.root].children[0], true).children('.jstree-anchor').trigger('focus');
|
3908
4067
|
}
|
3909
4068
|
}
|
3910
4069
|
else {
|
3911
|
-
this.get_node(par, true).children('.jstree-anchor').focus
|
4070
|
+
this.get_node(par, true).children('.jstree-anchor').trigger('focus');
|
3912
4071
|
}
|
3913
4072
|
this.element[0].scrollTop = top;
|
3914
4073
|
this.element[0].scrollLeft = lft;
|
@@ -3930,9 +4089,13 @@
|
|
3930
4089
|
check : function (chk, obj, par, pos, more) {
|
3931
4090
|
obj = obj && obj.id ? obj : this.get_node(obj);
|
3932
4091
|
par = par && par.id ? par : this.get_node(par);
|
3933
|
-
var tmp = chk.match(/^move_node|copy_node|create_node$/i) ? par : obj,
|
4092
|
+
var tmp = chk.match(/^(move_node|copy_node|create_node)$/i) ? par : obj,
|
3934
4093
|
chc = this.settings.core.check_callback;
|
3935
4094
|
if(chk === "move_node" || chk === "copy_node") {
|
4095
|
+
if((!more || !more.is_multi) && (chk === "move_node" && $.inArray(obj.id, par.children) === pos)) {
|
4096
|
+
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_08', 'reason' : 'Moving node to its current position', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
|
4097
|
+
return false;
|
4098
|
+
}
|
3936
4099
|
if((!more || !more.is_multi) && (obj.id === par.id || (chk === "move_node" && $.inArray(obj.id, par.children) === pos) || $.inArray(par.id, obj.children_d) !== -1)) {
|
3937
4100
|
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_01', 'reason' : 'Moving parent inside child', 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
|
3938
4101
|
return false;
|
@@ -3945,7 +4108,7 @@
|
|
3945
4108
|
}
|
3946
4109
|
return tmp.functions[chk];
|
3947
4110
|
}
|
3948
|
-
if(chc === false || ($.
|
4111
|
+
if(chc === false || ($.vakata.is_function(chc) && chc.call(this, chk, obj, par, pos, more) === false) || (chc && chc[chk] === false)) {
|
3949
4112
|
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'core', 'id' : 'core_03', 'reason' : 'User config for core.check_callback prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
|
3950
4113
|
return false;
|
3951
4114
|
}
|
@@ -3981,7 +4144,7 @@
|
|
3981
4144
|
return this.load_node(par, function () { this.move_node(obj, par, pos, callback, true, false, origin); });
|
3982
4145
|
}
|
3983
4146
|
|
3984
|
-
if($.
|
4147
|
+
if($.vakata.is_array(obj)) {
|
3985
4148
|
if(obj.length === 1) {
|
3986
4149
|
obj = obj[0];
|
3987
4150
|
}
|
@@ -3997,7 +4160,7 @@
|
|
3997
4160
|
return true;
|
3998
4161
|
}
|
3999
4162
|
}
|
4000
|
-
obj = obj && obj.id ? obj : this.get_node(obj);
|
4163
|
+
obj = obj && (obj.id !== undefined) ? obj : this.get_node(obj);
|
4001
4164
|
|
4002
4165
|
if(!obj || obj.id === $.jstree.root) { return false; }
|
4003
4166
|
|
@@ -4154,7 +4317,7 @@
|
|
4154
4317
|
return this.load_node(par, function () { this.copy_node(obj, par, pos, callback, true, false, origin); });
|
4155
4318
|
}
|
4156
4319
|
|
4157
|
-
if($.
|
4320
|
+
if($.vakata.is_array(obj)) {
|
4158
4321
|
if(obj.length === 1) {
|
4159
4322
|
obj = obj[0];
|
4160
4323
|
}
|
@@ -4170,7 +4333,7 @@
|
|
4170
4333
|
return true;
|
4171
4334
|
}
|
4172
4335
|
}
|
4173
|
-
obj = obj && obj.id ? obj : this.get_node(obj);
|
4336
|
+
obj = obj && (obj.id !== undefined) ? obj : this.get_node(obj);
|
4174
4337
|
if(!obj || obj.id === $.jstree.root) { return false; }
|
4175
4338
|
|
4176
4339
|
old_par = (obj.parent || $.jstree.root).toString();
|
@@ -4269,12 +4432,12 @@
|
|
4269
4432
|
*/
|
4270
4433
|
cut : function (obj) {
|
4271
4434
|
if(!obj) { obj = this._data.core.selected.concat(); }
|
4272
|
-
if(!$.
|
4435
|
+
if(!$.vakata.is_array(obj)) { obj = [obj]; }
|
4273
4436
|
if(!obj.length) { return false; }
|
4274
4437
|
var tmp = [], o, t1, t2;
|
4275
4438
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
4276
4439
|
o = this.get_node(obj[t1]);
|
4277
|
-
if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); }
|
4440
|
+
if(o && (o.id || o.id === 0) && o.id !== $.jstree.root) { tmp.push(o); }
|
4278
4441
|
}
|
4279
4442
|
if(!tmp.length) { return false; }
|
4280
4443
|
ccp_node = tmp;
|
@@ -4296,12 +4459,12 @@
|
|
4296
4459
|
*/
|
4297
4460
|
copy : function (obj) {
|
4298
4461
|
if(!obj) { obj = this._data.core.selected.concat(); }
|
4299
|
-
if(!$.
|
4462
|
+
if(!$.vakata.is_array(obj)) { obj = [obj]; }
|
4300
4463
|
if(!obj.length) { return false; }
|
4301
4464
|
var tmp = [], o, t1, t2;
|
4302
4465
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
4303
4466
|
o = this.get_node(obj[t1]);
|
4304
|
-
if(o && o.id && o.id !== $.jstree.root) { tmp.push(o); }
|
4467
|
+
if(o && (o.id !== undefined) && o.id !== $.jstree.root) { tmp.push(o); }
|
4305
4468
|
}
|
4306
4469
|
if(!tmp.length) { return false; }
|
4307
4470
|
ccp_node = tmp;
|
@@ -4377,7 +4540,7 @@
|
|
4377
4540
|
* @name edit(obj [, default_text, callback])
|
4378
4541
|
* @param {mixed} obj
|
4379
4542
|
* @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)
|
4380
|
-
* @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)
|
4543
|
+
* @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
|
4381
4544
|
*/
|
4382
4545
|
edit : function (obj, default_text, callback) {
|
4383
4546
|
var rtl, w, a, s, t, h1, h2, fn, tmp, cancel = false;
|
@@ -4396,8 +4559,8 @@
|
|
4396
4559
|
rtl = this._data.core.rtl;
|
4397
4560
|
w = this.element.width();
|
4398
4561
|
this._data.core.focused = tmp.id;
|
4399
|
-
a = obj.children('.jstree-anchor').focus
|
4400
|
-
s = $('<span>');
|
4562
|
+
a = obj.children('.jstree-anchor').trigger('focus');
|
4563
|
+
s = $('<span></span>');
|
4401
4564
|
/*!
|
4402
4565
|
oi = obj.children("i:visible"),
|
4403
4566
|
ai = a.children("i:visible"),
|
@@ -4405,7 +4568,7 @@
|
|
4405
4568
|
w2 = ai.width() * ai.length,
|
4406
4569
|
*/
|
4407
4570
|
t = default_text;
|
4408
|
-
h1 = $("<"+"div
|
4571
|
+
h1 = $("<"+"div></div>", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo(document.body);
|
4409
4572
|
h2 = $("<"+"input />", {
|
4410
4573
|
"value" : t,
|
4411
4574
|
"class" : "jstree-rename-input",
|
@@ -4419,57 +4582,60 @@
|
|
4419
4582
|
"lineHeight" : (this._data.core.li_height) + "px",
|
4420
4583
|
"width" : "150px" // will be set a bit further down
|
4421
4584
|
},
|
4422
|
-
"
|
4423
|
-
e
|
4424
|
-
e.preventDefault();
|
4425
|
-
var i = s.children(".jstree-rename-input"),
|
4426
|
-
v = i.val(),
|
4427
|
-
f = this.settings.core.force_text,
|
4428
|
-
nv;
|
4429
|
-
if(v === "") { v = t; }
|
4430
|
-
h1.remove();
|
4431
|
-
s.replaceWith(a);
|
4432
|
-
s.remove();
|
4433
|
-
t = f ? t : $('<div></div>').append($.parseHTML(t)).html();
|
4434
|
-
this.set_text(obj, t);
|
4435
|
-
nv = !!this.rename_node(obj, f ? $('<div></div>').text(v).text() : $('<div></div>').append($.parseHTML(v)).html());
|
4436
|
-
if(!nv) {
|
4437
|
-
this.set_text(obj, t); // move this up? and fix #483
|
4438
|
-
}
|
4439
|
-
this._data.core.focused = tmp.id;
|
4440
|
-
setTimeout($.proxy(function () {
|
4441
|
-
var node = this.get_node(tmp.id, true);
|
4442
|
-
if(node.length) {
|
4443
|
-
this._data.core.focused = tmp.id;
|
4444
|
-
node.children('.jstree-anchor').focus();
|
4445
|
-
}
|
4446
|
-
}, this), 0);
|
4447
|
-
if(callback) {
|
4448
|
-
callback.call(this, tmp, nv, cancel);
|
4449
|
-
}
|
4450
|
-
h2 = null;
|
4451
|
-
}, this),
|
4452
|
-
"keydown" : function (e) {
|
4453
|
-
var key = e.which;
|
4454
|
-
if(key === 27) {
|
4455
|
-
cancel = true;
|
4456
|
-
this.value = t;
|
4457
|
-
}
|
4458
|
-
if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) {
|
4585
|
+
"on" : {
|
4586
|
+
"blur" : function (e) {
|
4459
4587
|
e.stopImmediatePropagation();
|
4460
|
-
}
|
4461
|
-
if(key === 27 || key === 13) {
|
4462
4588
|
e.preventDefault();
|
4463
|
-
|
4589
|
+
var i = s.children(".jstree-rename-input"),
|
4590
|
+
v = i.val(),
|
4591
|
+
f = this.settings.core.force_text,
|
4592
|
+
nv;
|
4593
|
+
if(v === "") { v = t; }
|
4594
|
+
h1.remove();
|
4595
|
+
s.replaceWith(a);
|
4596
|
+
s.remove();
|
4597
|
+
t = f ? t : $('<div></div>').append($.parseHTML(t)).html();
|
4598
|
+
obj = this.get_node(obj);
|
4599
|
+
this.set_text(obj, t);
|
4600
|
+
nv = !!this.rename_node(obj, f ? $('<div></div>').text(v).text() : $('<div></div>').append($.parseHTML(v)).html());
|
4601
|
+
if(!nv) {
|
4602
|
+
this.set_text(obj, t); // move this up? and fix #483
|
4603
|
+
}
|
4604
|
+
this._data.core.focused = tmp.id;
|
4605
|
+
setTimeout(function () {
|
4606
|
+
var node = this.get_node(tmp.id, true);
|
4607
|
+
if(node.length) {
|
4608
|
+
this._data.core.focused = tmp.id;
|
4609
|
+
node.children('.jstree-anchor').trigger('focus');
|
4610
|
+
}
|
4611
|
+
}.bind(this), 0);
|
4612
|
+
if(callback) {
|
4613
|
+
callback.call(this, tmp, nv, cancel, v);
|
4614
|
+
}
|
4615
|
+
h2 = null;
|
4616
|
+
}.bind(this),
|
4617
|
+
"keydown" : function (e) {
|
4618
|
+
var key = e.which;
|
4619
|
+
if(key === 27) {
|
4620
|
+
cancel = true;
|
4621
|
+
this.value = t;
|
4622
|
+
}
|
4623
|
+
if(key === 27 || key === 13 || key === 37 || key === 38 || key === 39 || key === 40 || key === 32) {
|
4624
|
+
e.stopImmediatePropagation();
|
4625
|
+
}
|
4626
|
+
if(key === 27 || key === 13) {
|
4627
|
+
e.preventDefault();
|
4628
|
+
this.blur();
|
4629
|
+
}
|
4630
|
+
},
|
4631
|
+
"click" : function (e) { e.stopImmediatePropagation(); },
|
4632
|
+
"mousedown" : function (e) { e.stopImmediatePropagation(); },
|
4633
|
+
"keyup" : function (e) {
|
4634
|
+
h2.width(Math.min(h1.text("pW" + this.value).width(),w));
|
4635
|
+
},
|
4636
|
+
"keypress" : function(e) {
|
4637
|
+
if(e.which === 13) { return false; }
|
4464
4638
|
}
|
4465
|
-
},
|
4466
|
-
"click" : function (e) { e.stopImmediatePropagation(); },
|
4467
|
-
"mousedown" : function (e) { e.stopImmediatePropagation(); },
|
4468
|
-
"keyup" : function (e) {
|
4469
|
-
h2.width(Math.min(h1.text("pW" + this.value).width(),w));
|
4470
|
-
},
|
4471
|
-
"keypress" : function(e) {
|
4472
|
-
if(e.which === 13) { return false; }
|
4473
4639
|
}
|
4474
4640
|
});
|
4475
4641
|
fn = {
|
@@ -4488,7 +4654,7 @@
|
|
4488
4654
|
h2.css(fn).width(Math.min(h1.text("pW" + h2[0].value).width(),w))[0].select();
|
4489
4655
|
$(document).one('mousedown.jstree touchstart.jstree dnd_start.vakata', function (e) {
|
4490
4656
|
if (h2 && e.target !== h2) {
|
4491
|
-
$(h2).blur
|
4657
|
+
$(h2).trigger('blur');
|
4492
4658
|
}
|
4493
4659
|
});
|
4494
4660
|
},
|
@@ -4692,7 +4858,7 @@
|
|
4692
4858
|
*/
|
4693
4859
|
set_icon : function (obj, icon) {
|
4694
4860
|
var t1, t2, dom, old;
|
4695
|
-
if($.
|
4861
|
+
if($.vakata.is_array(obj)) {
|
4696
4862
|
obj = obj.slice();
|
4697
4863
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
4698
4864
|
this.set_icon(obj[t1], icon);
|
@@ -4705,6 +4871,7 @@
|
|
4705
4871
|
obj.icon = icon === true || icon === null || icon === undefined || icon === '' ? true : icon;
|
4706
4872
|
dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon");
|
4707
4873
|
if(icon === false) {
|
4874
|
+
dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
|
4708
4875
|
this.hide_icon(obj);
|
4709
4876
|
}
|
4710
4877
|
else if(icon === true || icon === null || icon === undefined || icon === '') {
|
@@ -4740,7 +4907,7 @@
|
|
4740
4907
|
*/
|
4741
4908
|
hide_icon : function (obj) {
|
4742
4909
|
var t1, t2;
|
4743
|
-
if($.
|
4910
|
+
if($.vakata.is_array(obj)) {
|
4744
4911
|
obj = obj.slice();
|
4745
4912
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
4746
4913
|
this.hide_icon(obj[t1]);
|
@@ -4760,7 +4927,7 @@
|
|
4760
4927
|
*/
|
4761
4928
|
show_icon : function (obj) {
|
4762
4929
|
var t1, t2, dom;
|
4763
|
-
if($.
|
4930
|
+
if($.vakata.is_array(obj)) {
|
4764
4931
|
obj = obj.slice();
|
4765
4932
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
4766
4933
|
this.show_icon(obj[t1]);
|
@@ -4786,7 +4953,7 @@
|
|
4786
4953
|
if(node && node.attributes) {
|
4787
4954
|
$.each(node.attributes, function (i, v) {
|
4788
4955
|
if($.inArray(v.name.toLowerCase(),['style','contenteditable','hasfocus','tabindex']) !== -1) { return; }
|
4789
|
-
if(v.value !== null && $.trim(v.value) !== '') {
|
4956
|
+
if(v.value !== null && $.vakata.trim(v.value) !== '') {
|
4790
4957
|
if(with_values) { attr[v.name] = v.value; }
|
4791
4958
|
else { attr.push(v.name); }
|
4792
4959
|
}
|
@@ -4830,6 +4997,34 @@
|
|
4830
4997
|
}
|
4831
4998
|
return d;
|
4832
4999
|
};
|
5000
|
+
$.vakata.trim = function (text) {
|
5001
|
+
return String.prototype.trim ?
|
5002
|
+
String.prototype.trim.call(text.toString()) :
|
5003
|
+
text.toString().replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
5004
|
+
};
|
5005
|
+
$.vakata.is_function = function(obj) {
|
5006
|
+
return typeof obj === "function" && typeof obj.nodeType !== "number";
|
5007
|
+
};
|
5008
|
+
$.vakata.is_array = Array.isArray || function (obj) {
|
5009
|
+
return Object.prototype.toString.call(obj) === "[object Array]";
|
5010
|
+
};
|
5011
|
+
|
5012
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind#polyfill
|
5013
|
+
if (!Function.prototype.bind) {
|
5014
|
+
Function.prototype.bind = function () {
|
5015
|
+
var thatFunc = this, thatArg = arguments[0];
|
5016
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
5017
|
+
if (typeof thatFunc !== 'function') {
|
5018
|
+
// closest thing possible to the ECMAScript 5
|
5019
|
+
// internal IsCallable function
|
5020
|
+
throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
|
5021
|
+
}
|
5022
|
+
return function(){
|
5023
|
+
var funcArgs = args.concat(Array.prototype.slice.call(arguments));
|
5024
|
+
return thatFunc.apply(thatArg, funcArgs);
|
5025
|
+
};
|
5026
|
+
};
|
5027
|
+
}
|
4833
5028
|
|
4834
5029
|
|
4835
5030
|
/**
|
@@ -4963,7 +5158,7 @@
|
|
4963
5158
|
this.settings.checkbox.cascade = 'up+down+undetermined';
|
4964
5159
|
}
|
4965
5160
|
this.element
|
4966
|
-
.on("init.jstree",
|
5161
|
+
.on("init.jstree", function () {
|
4967
5162
|
this._data.checkbox.visible = this.settings.checkbox.visible;
|
4968
5163
|
if(!this.settings.checkbox.keep_selected_style) {
|
4969
5164
|
this.element.addClass('jstree-checkbox-no-clicked');
|
@@ -4971,21 +5166,21 @@
|
|
4971
5166
|
if(this.settings.checkbox.tie_selection) {
|
4972
5167
|
this.element.addClass('jstree-checkbox-selection');
|
4973
5168
|
}
|
4974
|
-
}
|
4975
|
-
.on("loading.jstree",
|
5169
|
+
}.bind(this))
|
5170
|
+
.on("loading.jstree", function () {
|
4976
5171
|
this[ this._data.checkbox.visible ? 'show_checkboxes' : 'hide_checkboxes' ]();
|
4977
|
-
}
|
5172
|
+
}.bind(this));
|
4978
5173
|
if(this.settings.checkbox.cascade.indexOf('undetermined') !== -1) {
|
4979
5174
|
this.element
|
4980
|
-
.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',
|
5175
|
+
.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 () {
|
4981
5176
|
// only if undetermined is in setting
|
4982
5177
|
if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); }
|
4983
|
-
this._data.checkbox.uto = setTimeout(
|
4984
|
-
}
|
5178
|
+
this._data.checkbox.uto = setTimeout(this._undetermined.bind(this), 50);
|
5179
|
+
}.bind(this));
|
4985
5180
|
}
|
4986
5181
|
if(!this.settings.checkbox.tie_selection) {
|
4987
5182
|
this.element
|
4988
|
-
.on('model.jstree',
|
5183
|
+
.on('model.jstree', function (e, data) {
|
4989
5184
|
var m = this._model.data,
|
4990
5185
|
p = m[data.parent],
|
4991
5186
|
dpc = data.nodes,
|
@@ -4996,11 +5191,11 @@
|
|
4996
5191
|
this._data.checkbox.selected.push(dpc[i]);
|
4997
5192
|
}
|
4998
5193
|
}
|
4999
|
-
}
|
5194
|
+
}.bind(this));
|
5000
5195
|
}
|
5001
5196
|
if(this.settings.checkbox.cascade.indexOf('up') !== -1 || this.settings.checkbox.cascade.indexOf('down') !== -1) {
|
5002
5197
|
this.element
|
5003
|
-
.on('model.jstree',
|
5198
|
+
.on('model.jstree', function (e, data) {
|
5004
5199
|
var m = this._model.data,
|
5005
5200
|
p = m[data.parent],
|
5006
5201
|
dpc = data.nodes,
|
@@ -5048,7 +5243,7 @@
|
|
5048
5243
|
this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
|
5049
5244
|
tmp = this.get_node(p, true);
|
5050
5245
|
if(tmp && tmp.length) {
|
5051
|
-
tmp.attr('aria-selected', true).
|
5246
|
+
tmp.children('.jstree-anchor').attr('aria-selected', true).addClass( t ? 'jstree-clicked' : 'jstree-checked');
|
5052
5247
|
}
|
5053
5248
|
}
|
5054
5249
|
else {
|
@@ -5060,8 +5255,8 @@
|
|
5060
5255
|
}
|
5061
5256
|
|
5062
5257
|
this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected);
|
5063
|
-
}
|
5064
|
-
.on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree',
|
5258
|
+
}.bind(this))
|
5259
|
+
.on(this.settings.checkbox.tie_selection ? 'select_node.jstree' : 'check_node.jstree', function (e, data) {
|
5065
5260
|
var self = this,
|
5066
5261
|
obj = data.node,
|
5067
5262
|
m = this._model.data,
|
@@ -5077,14 +5272,15 @@
|
|
5077
5272
|
if(s.indexOf('down') !== -1) {
|
5078
5273
|
//this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d));
|
5079
5274
|
var selectedIds = this._cascade_new_checked_state(obj.id, true);
|
5080
|
-
|
5081
|
-
|
5082
|
-
|
5083
|
-
|
5084
|
-
|
5085
|
-
|
5086
|
-
|
5087
|
-
|
5275
|
+
var temp = obj.children_d.concat(obj.id);
|
5276
|
+
for (i = 0, j = temp.length; i < j; i++) {
|
5277
|
+
if (selectedIds.indexOf(temp[i]) > -1) {
|
5278
|
+
sel[temp[i]] = true;
|
5279
|
+
}
|
5280
|
+
else {
|
5281
|
+
delete sel[temp[i]];
|
5282
|
+
}
|
5283
|
+
}
|
5088
5284
|
}
|
5089
5285
|
|
5090
5286
|
// apply up
|
@@ -5100,7 +5296,7 @@
|
|
5100
5296
|
//this._data[ t ? 'core' : 'checkbox' ].selected.push(par.id);
|
5101
5297
|
tmp = this.get_node(par, true);
|
5102
5298
|
if(tmp && tmp.length) {
|
5103
|
-
tmp.attr('aria-selected', true).
|
5299
|
+
tmp.children('.jstree-anchor').attr('aria-selected', true).addClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5104
5300
|
}
|
5105
5301
|
}
|
5106
5302
|
else {
|
@@ -5117,8 +5313,8 @@
|
|
5117
5313
|
}
|
5118
5314
|
}
|
5119
5315
|
this._data[ t ? 'core' : 'checkbox' ].selected = cur;
|
5120
|
-
}
|
5121
|
-
.on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree',
|
5316
|
+
}.bind(this))
|
5317
|
+
.on(this.settings.checkbox.tie_selection ? 'deselect_all.jstree' : 'uncheck_all.jstree', function (e, data) {
|
5122
5318
|
var obj = this.get_node($.jstree.root),
|
5123
5319
|
m = this._model.data,
|
5124
5320
|
i, j, tmp;
|
@@ -5128,8 +5324,8 @@
|
|
5128
5324
|
tmp.original.state.undetermined = false;
|
5129
5325
|
}
|
5130
5326
|
}
|
5131
|
-
}
|
5132
|
-
.on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree',
|
5327
|
+
}.bind(this))
|
5328
|
+
.on(this.settings.checkbox.tie_selection ? 'deselect_node.jstree' : 'uncheck_node.jstree', function (e, data) {
|
5133
5329
|
var self = this,
|
5134
5330
|
obj = data.node,
|
5135
5331
|
dom = this.get_node(obj, true),
|
@@ -5142,7 +5338,7 @@
|
|
5142
5338
|
if(s.indexOf('down') !== -1) {
|
5143
5339
|
var selectedIds = this._cascade_new_checked_state(obj.id, false);
|
5144
5340
|
|
5145
|
-
cur =
|
5341
|
+
cur = $.vakata.array_filter(cur, function(id) {
|
5146
5342
|
return allIds.indexOf(id) === -1 || selectedIds.indexOf(id) > -1;
|
5147
5343
|
});
|
5148
5344
|
}
|
@@ -5158,21 +5354,21 @@
|
|
5158
5354
|
}
|
5159
5355
|
tmp = this.get_node(obj.parents[i], true);
|
5160
5356
|
if(tmp && tmp.length) {
|
5161
|
-
tmp.attr('aria-selected', false).
|
5357
|
+
tmp.children('.jstree-anchor').attr('aria-selected', false).removeClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5162
5358
|
}
|
5163
5359
|
}
|
5164
5360
|
|
5165
|
-
cur =
|
5361
|
+
cur = $.vakata.array_filter(cur, function(id) {
|
5166
5362
|
return obj.parents.indexOf(id) === -1;
|
5167
5363
|
});
|
5168
5364
|
}
|
5169
5365
|
|
5170
5366
|
this._data[ t ? 'core' : 'checkbox' ].selected = cur;
|
5171
|
-
}
|
5367
|
+
}.bind(this));
|
5172
5368
|
}
|
5173
5369
|
if(this.settings.checkbox.cascade.indexOf('up') !== -1) {
|
5174
5370
|
this.element
|
5175
|
-
.on('delete_node.jstree',
|
5371
|
+
.on('delete_node.jstree', function (e, data) {
|
5176
5372
|
// apply up (whole handler)
|
5177
5373
|
var p = this.get_node(data.parent),
|
5178
5374
|
m = this._model.data,
|
@@ -5187,7 +5383,7 @@
|
|
5187
5383
|
this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
|
5188
5384
|
tmp = this.get_node(p, true);
|
5189
5385
|
if(tmp && tmp.length) {
|
5190
|
-
tmp.attr('aria-selected', true).
|
5386
|
+
tmp.children('.jstree-anchor').attr('aria-selected', true).addClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5191
5387
|
}
|
5192
5388
|
}
|
5193
5389
|
else {
|
@@ -5195,8 +5391,8 @@
|
|
5195
5391
|
}
|
5196
5392
|
p = this.get_node(p.parent);
|
5197
5393
|
}
|
5198
|
-
}
|
5199
|
-
.on('move_node.jstree',
|
5394
|
+
}.bind(this))
|
5395
|
+
.on('move_node.jstree', function (e, data) {
|
5200
5396
|
// apply up (whole handler)
|
5201
5397
|
var is_multi = data.is_multi,
|
5202
5398
|
old_par = data.old_parent,
|
@@ -5215,7 +5411,7 @@
|
|
5215
5411
|
this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
|
5216
5412
|
tmp = this.get_node(p, true);
|
5217
5413
|
if(tmp && tmp.length) {
|
5218
|
-
tmp.attr('aria-selected', true).
|
5414
|
+
tmp.children('.jstree-anchor').attr('aria-selected', true).addClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5219
5415
|
}
|
5220
5416
|
}
|
5221
5417
|
else {
|
@@ -5236,7 +5432,7 @@
|
|
5236
5432
|
this._data[ t ? 'core' : 'checkbox' ].selected.push(p.id);
|
5237
5433
|
tmp = this.get_node(p, true);
|
5238
5434
|
if(tmp && tmp.length) {
|
5239
|
-
tmp.attr('aria-selected', true).
|
5435
|
+
tmp.children('.jstree-anchor').attr('aria-selected', true).addClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5240
5436
|
}
|
5241
5437
|
}
|
5242
5438
|
}
|
@@ -5246,7 +5442,7 @@
|
|
5246
5442
|
this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_remove_item(this._data[ t ? 'core' : 'checkbox' ].selected, p.id);
|
5247
5443
|
tmp = this.get_node(p, true);
|
5248
5444
|
if(tmp && tmp.length) {
|
5249
|
-
tmp.attr('aria-selected', false).
|
5445
|
+
tmp.children('.jstree-anchor').attr('aria-selected', false).removeClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5250
5446
|
}
|
5251
5447
|
}
|
5252
5448
|
else {
|
@@ -5255,19 +5451,21 @@
|
|
5255
5451
|
}
|
5256
5452
|
p = this.get_node(p.parent);
|
5257
5453
|
}
|
5258
|
-
}
|
5454
|
+
}.bind(this));
|
5259
5455
|
}
|
5260
5456
|
};
|
5261
|
-
|
5262
5457
|
/**
|
5263
|
-
*
|
5264
|
-
* @
|
5265
|
-
* @
|
5458
|
+
* get an array of all nodes whose state is "undetermined"
|
5459
|
+
* @name get_undetermined([full])
|
5460
|
+
* @param {boolean} full: if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
|
5461
|
+
* @return {Array}
|
5266
5462
|
* @plugin checkbox
|
5267
5463
|
*/
|
5268
|
-
this.
|
5269
|
-
if(this.
|
5270
|
-
|
5464
|
+
this.get_undetermined = function (full) {
|
5465
|
+
if (this.settings.checkbox.cascade.indexOf('undetermined') === -1) {
|
5466
|
+
return [];
|
5467
|
+
}
|
5468
|
+
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, r = [];
|
5271
5469
|
for(i = 0, j = s.length; i < j; i++) {
|
5272
5470
|
if(m[s[i]] && m[s[i]].parents) {
|
5273
5471
|
for(k = 0, l = m[s[i]].parents.length; k < l; k++) {
|
@@ -5320,14 +5518,28 @@
|
|
5320
5518
|
}
|
5321
5519
|
}
|
5322
5520
|
});
|
5521
|
+
for (i = 0, j = p.length; i < j; i++) {
|
5522
|
+
if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) {
|
5523
|
+
r.push(full ? m[p[i]] : p[i]);
|
5524
|
+
}
|
5525
|
+
}
|
5526
|
+
return r;
|
5527
|
+
};
|
5528
|
+
/**
|
5529
|
+
* set the undetermined state where and if necessary. Used internally.
|
5530
|
+
* @private
|
5531
|
+
* @name _undetermined()
|
5532
|
+
* @plugin checkbox
|
5533
|
+
*/
|
5534
|
+
this._undetermined = function () {
|
5535
|
+
if(this.element === null) { return; }
|
5536
|
+
var p = this.get_undetermined(false), i, j, s;
|
5323
5537
|
|
5324
5538
|
this.element.find('.jstree-undetermined').removeClass('jstree-undetermined');
|
5325
|
-
for(i = 0, j = p.length; i < j; i++) {
|
5326
|
-
|
5327
|
-
|
5328
|
-
|
5329
|
-
s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
|
5330
|
-
}
|
5539
|
+
for (i = 0, j = p.length; i < j; i++) {
|
5540
|
+
s = this.get_node(p[i], true);
|
5541
|
+
if(s && s.length) {
|
5542
|
+
s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
|
5331
5543
|
}
|
5332
5544
|
}
|
5333
5545
|
};
|
@@ -5350,7 +5562,7 @@
|
|
5350
5562
|
}
|
5351
5563
|
if(!is_callback && this.settings.checkbox.cascade.indexOf('undetermined') !== -1) {
|
5352
5564
|
if(this._data.checkbox.uto) { clearTimeout(this._data.checkbox.uto); }
|
5353
|
-
this._data.checkbox.uto = setTimeout(
|
5565
|
+
this._data.checkbox.uto = setTimeout(this._undetermined.bind(this), 50);
|
5354
5566
|
}
|
5355
5567
|
return obj;
|
5356
5568
|
};
|
@@ -5403,7 +5615,7 @@
|
|
5403
5615
|
*/
|
5404
5616
|
this.disable_checkbox = function (obj) {
|
5405
5617
|
var t1, t2, dom;
|
5406
|
-
if($.
|
5618
|
+
if($.vakata.is_array(obj)) {
|
5407
5619
|
obj = obj.slice();
|
5408
5620
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
5409
5621
|
this.disable_checkbox(obj[t1]);
|
@@ -5432,14 +5644,14 @@
|
|
5432
5644
|
};
|
5433
5645
|
/**
|
5434
5646
|
* enable a node's checkbox
|
5435
|
-
* @name
|
5647
|
+
* @name enable_checkbox(obj)
|
5436
5648
|
* @param {mixed} obj an array can be used too
|
5437
5649
|
* @trigger enable_checkbox.jstree
|
5438
5650
|
* @plugin checkbox
|
5439
5651
|
*/
|
5440
5652
|
this.enable_checkbox = function (obj) {
|
5441
5653
|
var t1, t2, dom;
|
5442
|
-
if($.
|
5654
|
+
if($.vakata.is_array(obj)) {
|
5443
5655
|
obj = obj.slice();
|
5444
5656
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
5445
5657
|
this.enable_checkbox(obj[t1]);
|
@@ -5488,65 +5700,90 @@
|
|
5488
5700
|
}
|
5489
5701
|
this.trigger('activate_node', { 'node' : this.get_node(obj) });
|
5490
5702
|
};
|
5703
|
+
this.delete_node = function (obj) {
|
5704
|
+
if(this.settings.checkbox.tie_selection || $.vakata.is_array(obj)) {
|
5705
|
+
return parent.delete_node.call(this, obj);
|
5706
|
+
}
|
5707
|
+
var tmp, k, l, c = false;
|
5708
|
+
obj = this.get_node(obj);
|
5709
|
+
if(!obj || obj.id === $.jstree.root) { return false; }
|
5710
|
+
tmp = obj.children_d.concat([]);
|
5711
|
+
tmp.push(obj.id);
|
5712
|
+
for(k = 0, l = tmp.length; k < l; k++) {
|
5713
|
+
if(this._model.data[tmp[k]].state.checked) {
|
5714
|
+
c = true;
|
5715
|
+
break;
|
5716
|
+
}
|
5717
|
+
}
|
5718
|
+
if (c) {
|
5719
|
+
this._data.checkbox.selected = $.vakata.array_filter(this._data.checkbox.selected, function (v) {
|
5720
|
+
return $.inArray(v, tmp) === -1;
|
5721
|
+
});
|
5722
|
+
}
|
5723
|
+
return parent.delete_node.call(this, obj);
|
5724
|
+
};
|
5491
5725
|
|
5492
5726
|
/**
|
5493
|
-
*
|
5727
|
+
* Cascades checked state to a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
|
5494
5728
|
* However if these unaffected nodes are already selected their ids will be included in the returned array.
|
5495
|
-
* @
|
5496
|
-
* @
|
5729
|
+
* @private
|
5730
|
+
* @name _cascade_new_checked_state(id, checkedState)
|
5731
|
+
* @param {string} id the node ID
|
5732
|
+
* @param {bool} checkedState should the nodes be checked or not
|
5497
5733
|
* @returns {Array} Array of all node id's (in this tree branch) that are checked.
|
5498
5734
|
*/
|
5499
|
-
this._cascade_new_checked_state = function(id, checkedState) {
|
5735
|
+
this._cascade_new_checked_state = function (id, checkedState) {
|
5500
5736
|
var self = this;
|
5501
5737
|
var t = this.settings.checkbox.tie_selection;
|
5502
5738
|
var node = this._model.data[id];
|
5503
5739
|
var selectedNodeIds = [];
|
5504
|
-
var selectedChildrenIds = [];
|
5740
|
+
var selectedChildrenIds = [], i, j, selectedChildIds;
|
5505
5741
|
|
5506
5742
|
if (
|
5507
5743
|
(this.settings.checkbox.cascade_to_disabled || !node.state.disabled) &&
|
5508
5744
|
(this.settings.checkbox.cascade_to_hidden || !node.state.hidden)
|
5509
5745
|
) {
|
5510
|
-
|
5511
|
-
|
5512
|
-
node.children.
|
5513
|
-
var
|
5746
|
+
//First try and check/uncheck the children
|
5747
|
+
if (node.children) {
|
5748
|
+
for (i = 0, j = node.children.length; i < j; i++) {
|
5749
|
+
var childId = node.children[i];
|
5750
|
+
selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
|
5514
5751
|
selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
|
5515
5752
|
if (selectedChildIds.indexOf(childId) > -1) {
|
5516
5753
|
selectedChildrenIds.push(childId);
|
5517
5754
|
}
|
5518
|
-
}
|
5755
|
+
}
|
5519
5756
|
}
|
5520
5757
|
|
5521
5758
|
var dom = self.get_node(node, true);
|
5522
5759
|
|
5523
|
-
|
5760
|
+
//A node's state is undetermined if some but not all of it's children are checked/selected .
|
5524
5761
|
var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length;
|
5525
5762
|
|
5526
5763
|
if(node.original && node.original.state && node.original.state.undetermined) {
|
5527
5764
|
node.original.state.undetermined = undetermined;
|
5528
5765
|
}
|
5529
5766
|
|
5530
|
-
|
5767
|
+
//If a node is undetermined then remove selected class
|
5531
5768
|
if (undetermined) {
|
5532
|
-
|
5533
|
-
|
5769
|
+
node.state[ t ? 'selected' : 'checked' ] = false;
|
5770
|
+
dom.children('.jstree-anchor').attr('aria-selected', false).removeClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5534
5771
|
}
|
5535
|
-
|
5536
|
-
|
5772
|
+
//Otherwise, if the checkedState === true (i.e. the node is being checked now) and all of the node's children are checked (if it has any children),
|
5773
|
+
//check the node and style it correctly.
|
5537
5774
|
else if (checkedState && selectedChildrenIds.length === node.children.length) {
|
5538
|
-
|
5775
|
+
node.state[ t ? 'selected' : 'checked' ] = checkedState;
|
5539
5776
|
selectedNodeIds.push(node.id);
|
5540
5777
|
|
5541
|
-
dom.attr('aria-selected', true).
|
5778
|
+
dom.children('.jstree-anchor').attr('aria-selected', true).addClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5542
5779
|
}
|
5543
5780
|
else {
|
5544
|
-
|
5545
|
-
dom.attr('aria-selected', false).
|
5781
|
+
node.state[ t ? 'selected' : 'checked' ] = false;
|
5782
|
+
dom.children('.jstree-anchor').attr('aria-selected', false).removeClass(t ? 'jstree-clicked' : 'jstree-checked');
|
5546
5783
|
}
|
5547
5784
|
}
|
5548
5785
|
else {
|
5549
|
-
|
5786
|
+
selectedChildIds = this.get_checked_descendants(id);
|
5550
5787
|
|
5551
5788
|
if (node.state[ t ? 'selected' : 'checked' ]) {
|
5552
5789
|
selectedChildIds.push(node.id);
|
@@ -5560,14 +5797,17 @@
|
|
5560
5797
|
|
5561
5798
|
/**
|
5562
5799
|
* Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id)
|
5563
|
-
* @
|
5800
|
+
* @name get_checked_descendants(obj)
|
5801
|
+
* @param {string} id the node ID
|
5802
|
+
* @return {Array} array of IDs
|
5803
|
+
* @plugin checkbox
|
5564
5804
|
*/
|
5565
|
-
this.get_checked_descendants = function(id) {
|
5805
|
+
this.get_checked_descendants = function (id) {
|
5566
5806
|
var self = this;
|
5567
5807
|
var t = self.settings.checkbox.tie_selection;
|
5568
5808
|
var node = self._model.data[id];
|
5569
5809
|
|
5570
|
-
return node.children_d
|
5810
|
+
return $.vakata.array_filter(node.children_d, function(_id) {
|
5571
5811
|
return self._model.data[_id].state[ t ? 'selected' : 'checked' ];
|
5572
5812
|
});
|
5573
5813
|
};
|
@@ -5582,7 +5822,7 @@
|
|
5582
5822
|
this.check_node = function (obj, e) {
|
5583
5823
|
if(this.settings.checkbox.tie_selection) { return this.select_node(obj, false, true, e); }
|
5584
5824
|
var dom, t1, t2, th;
|
5585
|
-
if($.
|
5825
|
+
if($.vakata.is_array(obj)) {
|
5586
5826
|
obj = obj.slice();
|
5587
5827
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
5588
5828
|
this.check_node(obj[t1], e);
|
@@ -5622,7 +5862,7 @@
|
|
5622
5862
|
this.uncheck_node = function (obj, e) {
|
5623
5863
|
if(this.settings.checkbox.tie_selection) { return this.deselect_node(obj, false, e); }
|
5624
5864
|
var t1, t2, dom;
|
5625
|
-
if($.
|
5865
|
+
if($.vakata.is_array(obj)) {
|
5626
5866
|
obj = obj.slice();
|
5627
5867
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
5628
5868
|
this.uncheck_node(obj[t1], e);
|
@@ -5726,7 +5966,7 @@
|
|
5726
5966
|
*/
|
5727
5967
|
this.get_checked = function (full) {
|
5728
5968
|
if(this.settings.checkbox.tie_selection) { return this.get_selected(full); }
|
5729
|
-
return full ? $.map(this._data.checkbox.selected,
|
5969
|
+
return full ? $.map(this._data.checkbox.selected, function (i) { return this.get_node(i); }.bind(this)) : this._data.checkbox.selected.slice();
|
5730
5970
|
};
|
5731
5971
|
/**
|
5732
5972
|
* get an array of all top level checked nodes (ignoring children of checked nodes) (if tie_selection is on in the settings this function will return the same as get_top_selected)
|
@@ -5755,7 +5995,7 @@
|
|
5755
5995
|
tmp.push(i);
|
5756
5996
|
}
|
5757
5997
|
}
|
5758
|
-
return full ? $.map(tmp,
|
5998
|
+
return full ? $.map(tmp, function (i) { return this.get_node(i); }.bind(this)) : tmp;
|
5759
5999
|
};
|
5760
6000
|
/**
|
5761
6001
|
* get an array of all bottom level checked nodes (ignoring selected parents) (if tie_selection is on in the settings this function will return the same as get_bottom_selected)
|
@@ -5773,11 +6013,11 @@
|
|
5773
6013
|
obj.push(tmp[i].id);
|
5774
6014
|
}
|
5775
6015
|
}
|
5776
|
-
return full ? $.map(obj,
|
6016
|
+
return full ? $.map(obj, function (i) { return this.get_node(i); }.bind(this)) : obj;
|
5777
6017
|
};
|
5778
6018
|
this.load_node = function (obj, callback) {
|
5779
6019
|
var k, l, i, j, c, tmp;
|
5780
|
-
if(!$.
|
6020
|
+
if(!$.vakata.is_array(obj) && !this.settings.checkbox.tie_selection) {
|
5781
6021
|
tmp = this.get_node(obj);
|
5782
6022
|
if(tmp && tmp.state.loaded) {
|
5783
6023
|
for(k = 0, l = tmp.children_d.length; k < l; k++) {
|
@@ -5813,7 +6053,7 @@
|
|
5813
6053
|
return res;
|
5814
6054
|
};
|
5815
6055
|
this.refresh = function (skip_loading, forget_state) {
|
5816
|
-
if(
|
6056
|
+
if(this.settings.checkbox.tie_selection) {
|
5817
6057
|
this._data.checkbox.selected = [];
|
5818
6058
|
}
|
5819
6059
|
return parent.refresh.apply(this, arguments);
|
@@ -5840,7 +6080,7 @@
|
|
5840
6080
|
// own function
|
5841
6081
|
this.activate_node = function (obj, e) {
|
5842
6082
|
if(this.settings.conditionalselect.call(this, this.get_node(obj), e)) {
|
5843
|
-
parent.activate_node.call(this, obj, e);
|
6083
|
+
return parent.activate_node.call(this, obj, e);
|
5844
6084
|
}
|
5845
6085
|
};
|
5846
6086
|
};
|
@@ -6005,10 +6245,10 @@
|
|
6005
6245
|
|
6006
6246
|
var last_ts = 0, cto = null, ex, ey;
|
6007
6247
|
this.element
|
6008
|
-
.on("init.jstree loading.jstree ready.jstree",
|
6248
|
+
.on("init.jstree loading.jstree ready.jstree", function () {
|
6009
6249
|
this.get_container_ul().addClass('jstree-contextmenu');
|
6010
|
-
}
|
6011
|
-
.on("contextmenu.jstree", ".jstree-anchor",
|
6250
|
+
}.bind(this))
|
6251
|
+
.on("contextmenu.jstree", ".jstree-anchor", function (e, data) {
|
6012
6252
|
if (e.target.tagName.toLowerCase() === 'input') {
|
6013
6253
|
return;
|
6014
6254
|
}
|
@@ -6023,13 +6263,13 @@
|
|
6023
6263
|
if(!this.is_loading(e.currentTarget)) {
|
6024
6264
|
this.show_contextmenu(e.currentTarget, e.pageX, e.pageY, e);
|
6025
6265
|
}
|
6026
|
-
}
|
6027
|
-
.on("click.jstree", ".jstree-anchor",
|
6266
|
+
}.bind(this))
|
6267
|
+
.on("click.jstree", ".jstree-anchor", function (e) {
|
6028
6268
|
if(this._data.contextmenu.visible && (!last_ts || (+new Date()) - last_ts > 250)) { // work around safari & macOS ctrl+click
|
6029
6269
|
$.vakata.context.hide();
|
6030
6270
|
}
|
6031
6271
|
last_ts = 0;
|
6032
|
-
}
|
6272
|
+
}.bind(this))
|
6033
6273
|
.on("touchstart.jstree", ".jstree-anchor", function (e) {
|
6034
6274
|
if(!e.originalEvent || !e.originalEvent.changedTouches || !e.originalEvent.changedTouches[0]) {
|
6035
6275
|
return;
|
@@ -6041,8 +6281,9 @@
|
|
6041
6281
|
}, 750);
|
6042
6282
|
})
|
6043
6283
|
.on('touchmove.vakata.jstree', function (e) {
|
6044
|
-
if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.originalEvent.changedTouches[0].clientX) >
|
6284
|
+
if(cto && e.originalEvent && e.originalEvent.changedTouches && e.originalEvent.changedTouches[0] && (Math.abs(ex - e.originalEvent.changedTouches[0].clientX) > 10 || Math.abs(ey - e.originalEvent.changedTouches[0].clientY) > 10)) {
|
6045
6285
|
clearTimeout(cto);
|
6286
|
+
$.vakata.context.hide();
|
6046
6287
|
}
|
6047
6288
|
})
|
6048
6289
|
.on('touchend.vakata.jstree', function (e) {
|
@@ -6072,15 +6313,16 @@
|
|
6072
6313
|
});
|
6073
6314
|
}
|
6074
6315
|
*/
|
6075
|
-
$(document).on("context_hide.vakata.jstree",
|
6316
|
+
$(document).on("context_hide.vakata.jstree", function (e, data) {
|
6076
6317
|
this._data.contextmenu.visible = false;
|
6077
6318
|
$(data.reference).removeClass('jstree-context');
|
6078
|
-
}
|
6319
|
+
}.bind(this));
|
6079
6320
|
};
|
6080
6321
|
this.teardown = function () {
|
6081
6322
|
if(this._data.contextmenu.visible) {
|
6082
6323
|
$.vakata.context.hide();
|
6083
6324
|
}
|
6325
|
+
$(document).off("context_hide.vakata.jstree");
|
6084
6326
|
parent.teardown.call(this);
|
6085
6327
|
};
|
6086
6328
|
|
@@ -6112,10 +6354,10 @@
|
|
6112
6354
|
}
|
6113
6355
|
|
6114
6356
|
i = s.items;
|
6115
|
-
if($.
|
6116
|
-
i = i.call(this, obj,
|
6357
|
+
if($.vakata.is_function(i)) {
|
6358
|
+
i = i.call(this, obj, function (i) {
|
6117
6359
|
this._show_contextmenu(obj, x, y, i);
|
6118
|
-
}
|
6360
|
+
}.bind(this));
|
6119
6361
|
}
|
6120
6362
|
if($.isPlainObject(i)) {
|
6121
6363
|
this._show_contextmenu(obj, x, y, i);
|
@@ -6135,11 +6377,11 @@
|
|
6135
6377
|
this._show_contextmenu = function (obj, x, y, i) {
|
6136
6378
|
var d = this.get_node(obj, true),
|
6137
6379
|
a = d.children(".jstree-anchor");
|
6138
|
-
$(document).one("context_show.vakata.jstree",
|
6380
|
+
$(document).one("context_show.vakata.jstree", function (e, data) {
|
6139
6381
|
var cls = 'jstree-contextmenu jstree-' + this.get_theme() + '-contextmenu';
|
6140
6382
|
$(data.element).addClass(cls);
|
6141
6383
|
a.addClass('jstree-context');
|
6142
|
-
}
|
6384
|
+
}.bind(this));
|
6143
6385
|
this._data.contextmenu.visible = true;
|
6144
6386
|
$.vakata.context.show(a, { 'x' : x, 'y' : y }, i);
|
6145
6387
|
/**
|
@@ -6185,7 +6427,7 @@
|
|
6185
6427
|
},
|
6186
6428
|
_execute : function (i) {
|
6187
6429
|
i = vakata_context.items[i];
|
6188
|
-
return i && (!i._disabled || ($.
|
6430
|
+
return i && (!i._disabled || ($.vakata.is_function(i._disabled) && !i._disabled({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }))) && i.action ? i.action.call(null, {
|
6189
6431
|
"item" : i,
|
6190
6432
|
"reference" : vakata_context.reference,
|
6191
6433
|
"element" : vakata_context.element,
|
@@ -6210,10 +6452,10 @@
|
|
6210
6452
|
if(!val) { return true; }
|
6211
6453
|
vakata_context.items.push(val);
|
6212
6454
|
if(!sep && val.separator_before) {
|
6213
|
-
str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : '
|
6455
|
+
str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'class="vakata-context-no-icons"') + "> <"+"/a><"+"/li>";
|
6214
6456
|
}
|
6215
6457
|
sep = false;
|
6216
|
-
str += "<"+"li class='" + (val._class || "") + (val._disabled === true || ($.
|
6458
|
+
str += "<"+"li class='" + (val._class || "") + (val._disabled === true || ($.vakata.is_function(val._disabled) && val._disabled({ "item" : val, "reference" : vakata_context.reference, "element" : vakata_context.element })) ? " vakata-contextmenu-disabled " : "") + "' "+(val.shortcut?" data-shortcut='"+val.shortcut+"' ":'')+">";
|
6217
6459
|
str += "<"+"a href='#' rel='" + (vakata_context.items.length - 1) + "' " + (val.title ? "title='" + val.title + "'" : "") + ">";
|
6218
6460
|
if($.vakata.context.settings.icons) {
|
6219
6461
|
str += "<"+"i ";
|
@@ -6223,14 +6465,14 @@
|
|
6223
6465
|
}
|
6224
6466
|
str += "><"+"/i><"+"span class='vakata-contextmenu-sep'> <"+"/span>";
|
6225
6467
|
}
|
6226
|
-
str += ($.
|
6468
|
+
str += ($.vakata.is_function(val.label) ? val.label({ "item" : i, "reference" : vakata_context.reference, "element" : vakata_context.element }) : val.label) + (val.shortcut?' <span class="vakata-contextmenu-shortcut vakata-contextmenu-shortcut-'+val.shortcut+'">'+ (val.shortcut_label || '') +'</span>':'') + "<"+"/a>";
|
6227
6469
|
if(val.submenu) {
|
6228
6470
|
tmp = $.vakata.context._parse(val.submenu, true);
|
6229
6471
|
if(tmp) { str += tmp; }
|
6230
6472
|
}
|
6231
6473
|
str += "<"+"/li>";
|
6232
6474
|
if(val.separator_after) {
|
6233
|
-
str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : '
|
6475
|
+
str += "<"+"li class='vakata-context-separator'><"+"a href='#' " + ($.vakata.context.settings.icons ? '' : 'class="vakata-context-no-icons"') + "> <"+"/a><"+"/li>";
|
6234
6476
|
sep = true;
|
6235
6477
|
}
|
6236
6478
|
});
|
@@ -6314,7 +6556,7 @@
|
|
6314
6556
|
vakata_context.element.html(vakata_context.html);
|
6315
6557
|
}
|
6316
6558
|
if(vakata_context.items.length) {
|
6317
|
-
vakata_context.element.appendTo(
|
6559
|
+
vakata_context.element.appendTo(document.body);
|
6318
6560
|
e = vakata_context.element;
|
6319
6561
|
x = vakata_context.position_x;
|
6320
6562
|
y = vakata_context.position_y;
|
@@ -6338,7 +6580,7 @@
|
|
6338
6580
|
vakata_context.element
|
6339
6581
|
.css({ "left" : x, "top" : y })
|
6340
6582
|
.show()
|
6341
|
-
.find('a').first().focus
|
6583
|
+
.find('a').first().trigger('focus').parent().addClass("vakata-context-hover");
|
6342
6584
|
vakata_context.is_visible = true;
|
6343
6585
|
/**
|
6344
6586
|
* triggered on the document when the contextmenu is shown
|
@@ -6354,7 +6596,7 @@
|
|
6354
6596
|
},
|
6355
6597
|
hide : function () {
|
6356
6598
|
if(vakata_context.is_visible) {
|
6357
|
-
vakata_context.element.hide().find("ul").hide().end().find(':focus').blur
|
6599
|
+
vakata_context.element.hide().find("ul").hide().end().find(':focus').trigger('blur').end().detach();
|
6358
6600
|
vakata_context.is_visible = false;
|
6359
6601
|
/**
|
6360
6602
|
* triggered on the document when the contextmenu is hidden
|
@@ -6370,7 +6612,7 @@
|
|
6370
6612
|
}
|
6371
6613
|
};
|
6372
6614
|
$(function () {
|
6373
|
-
right_to_left = $(
|
6615
|
+
right_to_left = $(document.body).css("direction") === "rtl";
|
6374
6616
|
var to = false;
|
6375
6617
|
|
6376
6618
|
vakata_context.element = $("<ul class='vakata-context'></ul>");
|
@@ -6410,7 +6652,7 @@
|
|
6410
6652
|
e.preventDefault();
|
6411
6653
|
//})
|
6412
6654
|
//.on("mouseup", "a", function (e) {
|
6413
|
-
if(!$(this).blur
|
6655
|
+
if(!$(this).trigger('blur').parent().hasClass("vakata-context-disabled") && $.vakata.context._execute($(this).attr("rel")) !== false) {
|
6414
6656
|
$.vakata.context.hide();
|
6415
6657
|
}
|
6416
6658
|
})
|
@@ -6425,7 +6667,7 @@
|
|
6425
6667
|
break;
|
6426
6668
|
case 37:
|
6427
6669
|
if(vakata_context.is_visible) {
|
6428
|
-
vakata_context.element.find(".vakata-context-hover").last().closest("li").first().find("ul").hide().find(".vakata-context-hover").removeClass("vakata-context-hover").end().end().children('a').focus
|
6670
|
+
vakata_context.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');
|
6429
6671
|
e.stopImmediatePropagation();
|
6430
6672
|
e.preventDefault();
|
6431
6673
|
}
|
@@ -6434,14 +6676,14 @@
|
|
6434
6676
|
if(vakata_context.is_visible) {
|
6435
6677
|
o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").prevAll("li:not(.vakata-context-separator)").first();
|
6436
6678
|
if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").last(); }
|
6437
|
-
o.addClass("vakata-context-hover").children('a').focus
|
6679
|
+
o.addClass("vakata-context-hover").children('a').trigger('focus');
|
6438
6680
|
e.stopImmediatePropagation();
|
6439
6681
|
e.preventDefault();
|
6440
6682
|
}
|
6441
6683
|
break;
|
6442
6684
|
case 39:
|
6443
6685
|
if(vakata_context.is_visible) {
|
6444
|
-
vakata_context.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').focus
|
6686
|
+
vakata_context.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');
|
6445
6687
|
e.stopImmediatePropagation();
|
6446
6688
|
e.preventDefault();
|
6447
6689
|
}
|
@@ -6450,7 +6692,7 @@
|
|
6450
6692
|
if(vakata_context.is_visible) {
|
6451
6693
|
o = vakata_context.element.find("ul:visible").addBack().last().children(".vakata-context-hover").removeClass("vakata-context-hover").nextAll("li:not(.vakata-context-separator)").first();
|
6452
6694
|
if(!o.length) { o = vakata_context.element.find("ul:visible").addBack().last().children("li:not(.vakata-context-separator)").first(); }
|
6453
|
-
o.addClass("vakata-context-hover").children('a').focus
|
6695
|
+
o.addClass("vakata-context-hover").children('a').trigger('focus');
|
6454
6696
|
e.stopImmediatePropagation();
|
6455
6697
|
e.preventDefault();
|
6456
6698
|
}
|
@@ -6468,7 +6710,7 @@
|
|
6468
6710
|
e.preventDefault();
|
6469
6711
|
var a = vakata_context.element.find('.vakata-contextmenu-shortcut-' + e.which).parent();
|
6470
6712
|
if(a.parent().not('.vakata-context-disabled')) {
|
6471
|
-
a.click
|
6713
|
+
a.trigger('click');
|
6472
6714
|
}
|
6473
6715
|
});
|
6474
6716
|
|
@@ -6569,7 +6811,13 @@
|
|
6569
6811
|
* @name $.jstree.defaults.dnd.use_html5
|
6570
6812
|
* @plugin dnd
|
6571
6813
|
*/
|
6572
|
-
use_html5: false
|
6814
|
+
use_html5: false,
|
6815
|
+
/**
|
6816
|
+
* controls whether items can be dropped anywhere on the tree.
|
6817
|
+
* @name $.jstree.defaults.dnd.blank_space_drop
|
6818
|
+
* @plugin dnd
|
6819
|
+
*/
|
6820
|
+
blank_space_drop: false
|
6573
6821
|
};
|
6574
6822
|
var drg, elm;
|
6575
6823
|
// TODO: now check works by checking for each node individually, how about max_children, unique, etc?
|
@@ -6582,7 +6830,7 @@
|
|
6582
6830
|
parent.bind.call(this);
|
6583
6831
|
|
6584
6832
|
this.element
|
6585
|
-
.on(this.settings.dnd.use_html5 ? 'dragstart.jstree' : 'mousedown.jstree touchstart.jstree', this.settings.dnd.large_drag_target ? '.jstree-node' : '.jstree-anchor',
|
6833
|
+
.on(this.settings.dnd.use_html5 ? 'dragstart.jstree' : 'mousedown.jstree touchstart.jstree', this.settings.dnd.large_drag_target ? '.jstree-node' : '.jstree-anchor', function (e) {
|
6586
6834
|
if(this.settings.dnd.large_drag_target && $(e.target).closest('.jstree-node')[0] !== e.currentTarget) {
|
6587
6835
|
return true;
|
6588
6836
|
}
|
@@ -6595,8 +6843,8 @@
|
|
6595
6843
|
if(this.settings.core.force_text) {
|
6596
6844
|
txt = $.vakata.html.escape(txt);
|
6597
6845
|
}
|
6598
|
-
if(obj && obj.id && obj.id !== $.jstree.root && (e.which === 1 || e.type === "touchstart" || e.type === "dragstart") &&
|
6599
|
-
(this.settings.dnd.is_draggable === true || ($.
|
6846
|
+
if(obj && (obj.id || obj.id === 0) && obj.id !== $.jstree.root && (e.which === 1 || e.type === "touchstart" || e.type === "dragstart") &&
|
6847
|
+
(this.settings.dnd.is_draggable === true || ($.vakata.is_function(this.settings.dnd.is_draggable) && this.settings.dnd.is_draggable.call(this, (mlt > 1 ? this.get_top_selected(true) : [obj]), e)))
|
6600
6848
|
) {
|
6601
6849
|
drg = { 'jstree' : true, 'origin' : this, 'obj' : this.get_node(obj,true), 'nodes' : mlt > 1 ? this.get_top_selected() : [obj.id] };
|
6602
6850
|
elm = e.currentTarget;
|
@@ -6604,10 +6852,10 @@
|
|
6604
6852
|
$.vakata.dnd._trigger('start', e, { 'helper': $(), 'element': elm, 'data': drg });
|
6605
6853
|
} else {
|
6606
6854
|
this.element.trigger('mousedown.jstree');
|
6607
|
-
return $.vakata.dnd.start(e, drg, '<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"
|
6855
|
+
return $.vakata.dnd.start(e, drg, '<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">+</ins></div>');
|
6608
6856
|
}
|
6609
6857
|
}
|
6610
|
-
}
|
6858
|
+
}.bind(this));
|
6611
6859
|
if (this.settings.dnd.use_html5) {
|
6612
6860
|
this.element
|
6613
6861
|
.on('dragover.jstree', function (e) {
|
@@ -6620,11 +6868,11 @@
|
|
6620
6868
|
// $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
|
6621
6869
|
// return false;
|
6622
6870
|
// }, this))
|
6623
|
-
.on('drop.jstree',
|
6871
|
+
.on('drop.jstree', function (e) {
|
6624
6872
|
e.preventDefault();
|
6625
6873
|
$.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
|
6626
6874
|
return false;
|
6627
|
-
}
|
6875
|
+
}.bind(this));
|
6628
6876
|
}
|
6629
6877
|
};
|
6630
6878
|
this.redraw_node = function(obj, deep, callback, force_render) {
|
@@ -6658,11 +6906,23 @@
|
|
6658
6906
|
marker = $('<div id="jstree-marker"> </div>').hide(); //.appendTo('body');
|
6659
6907
|
|
6660
6908
|
$(document)
|
6909
|
+
.on('dragover.vakata.jstree', function (e) {
|
6910
|
+
if (elm) {
|
6911
|
+
$.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
|
6912
|
+
}
|
6913
|
+
})
|
6914
|
+
.on('drop.vakata.jstree', function (e) {
|
6915
|
+
if (elm) {
|
6916
|
+
$.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
|
6917
|
+
elm = null;
|
6918
|
+
drg = null;
|
6919
|
+
}
|
6920
|
+
})
|
6661
6921
|
.on('dnd_start.vakata.jstree', function (e, data) {
|
6662
6922
|
lastmv = false;
|
6663
6923
|
lastev = false;
|
6664
6924
|
if(!data || !data.data || !data.data.jstree) { return; }
|
6665
|
-
marker.appendTo(
|
6925
|
+
marker.appendTo(document.body); //.show();
|
6666
6926
|
})
|
6667
6927
|
.on('dnd_move.vakata.jstree', function (e, data) {
|
6668
6928
|
var isDifferentNode = data.event.target !== lastev.target;
|
@@ -6683,7 +6943,7 @@
|
|
6683
6943
|
ref = false,
|
6684
6944
|
off = false,
|
6685
6945
|
rel = false,
|
6686
|
-
tmp, l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm, is_copy, pn;
|
6946
|
+
tmp, l, t, h, p, i, o, ok, t1, t2, op, ps, pr, ip, tm, is_copy, pn, c;
|
6687
6947
|
// if we are over an instance
|
6688
6948
|
if(ins && ins._data && ins._data.dnd) {
|
6689
6949
|
marker.attr('class', 'jstree-' + ins.get_theme() + ( ins.settings.core.themes.responsive ? ' jstree-dnd-responsive' : '' ));
|
@@ -6694,7 +6954,7 @@
|
|
6694
6954
|
|
6695
6955
|
// if are hovering the container itself add a new root node
|
6696
6956
|
//console.log(data.event);
|
6697
|
-
if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && ins.get_container_ul().children().length === 0) {
|
6957
|
+
if( (data.event.target === ins.element[0] || data.event.target === ins.get_container_ul()[0]) && (ins.get_container_ul().children().length === 0 || ins.settings.dnd.blank_space_drop)) {
|
6698
6958
|
ok = true;
|
6699
6959
|
for(t1 = 0, t2 = data.data.nodes.length; t1 < t2; t1++) {
|
6700
6960
|
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]), $.jstree.root, 'last', { 'dnd' : true, 'ref' : ins.get_node($.jstree.root), 'pos' : 'i', 'origin' : data.data.origin, 'is_multi' : (data.data.origin && data.data.origin !== ins), 'is_foreign' : (!data.data.origin) });
|
@@ -6713,6 +6973,7 @@
|
|
6713
6973
|
else {
|
6714
6974
|
// if we are hovering a tree node
|
6715
6975
|
ref = ins.settings.dnd.large_drop_target ? $(data.event.target).closest('.jstree-node').children('.jstree-anchor') : $(data.event.target).closest('.jstree-anchor');
|
6976
|
+
|
6716
6977
|
if(ref && ref.length && ref.parent().is('.jstree-closed, .jstree-open, .jstree-leaf')) {
|
6717
6978
|
off = ref.offset();
|
6718
6979
|
rel = (data.event.pageY !== undefined ? data.event.pageY : data.event.originalEvent.pageY) - off.top;
|
@@ -6733,6 +6994,7 @@
|
|
6733
6994
|
t = off.top;
|
6734
6995
|
p = ins.get_parent(ref);
|
6735
6996
|
i = ref.parent().index();
|
6997
|
+
c = 'jstree-below';
|
6736
6998
|
break;
|
6737
6999
|
case 'i':
|
6738
7000
|
ip = ins.settings.dnd.inside_pos;
|
@@ -6741,12 +7003,14 @@
|
|
6741
7003
|
t = off.top + h / 2 + 1;
|
6742
7004
|
p = tm.id;
|
6743
7005
|
i = ip === 'first' ? 0 : (ip === 'last' ? tm.children.length : Math.min(ip, tm.children.length));
|
7006
|
+
c = 'jstree-inside';
|
6744
7007
|
break;
|
6745
7008
|
case 'a':
|
6746
7009
|
l = off.left - 6;
|
6747
7010
|
t = off.top + h;
|
6748
7011
|
p = ins.get_parent(ref);
|
6749
7012
|
i = ref.parent().index() + 1;
|
7013
|
+
c = 'jstree-above';
|
6750
7014
|
break;
|
6751
7015
|
}
|
6752
7016
|
ok = true;
|
@@ -6779,6 +7043,7 @@
|
|
6779
7043
|
}
|
6780
7044
|
lastmv = { 'ins' : ins, 'par' : p, 'pos' : v === 'i' && ip === 'last' && i === 0 && !ins.is_loaded(tm) ? 'last' : i };
|
6781
7045
|
marker.css({ 'left' : l + 'px', 'top' : t + 'px' }).show();
|
7046
|
+
marker.removeClass('jstree-above jstree-inside jstree-below').addClass(c);
|
6782
7047
|
data.helper.find('.jstree-icon').first().removeClass('jstree-er').addClass('jstree-ok');
|
6783
7048
|
if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
|
6784
7049
|
data.event.originalEvent.dataTransfer.dropEffect = is_copy ? 'copy' : 'move';
|
@@ -6796,7 +7061,7 @@
|
|
6796
7061
|
lastmv = false;
|
6797
7062
|
data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er');
|
6798
7063
|
if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
|
6799
|
-
data.event.originalEvent.dataTransfer.dropEffect = 'none';
|
7064
|
+
//data.event.originalEvent.dataTransfer.dropEffect = 'none';
|
6800
7065
|
}
|
6801
7066
|
marker.hide();
|
6802
7067
|
})
|
@@ -6857,7 +7122,7 @@
|
|
6857
7122
|
// helpers
|
6858
7123
|
(function ($) {
|
6859
7124
|
$.vakata.html = {
|
6860
|
-
div : $('<div
|
7125
|
+
div : $('<div></div>'),
|
6861
7126
|
escape : function (str) {
|
6862
7127
|
return $.vakata.html.div.text(str).html();
|
6863
7128
|
},
|
@@ -6889,7 +7154,7 @@
|
|
6889
7154
|
helper_left : 5,
|
6890
7155
|
helper_top : 10,
|
6891
7156
|
threshold : 5,
|
6892
|
-
threshold_touch :
|
7157
|
+
threshold_touch : 10
|
6893
7158
|
},
|
6894
7159
|
_trigger : function (event_name, e, data) {
|
6895
7160
|
if (data === undefined) {
|
@@ -6924,6 +7189,7 @@
|
|
6924
7189
|
scroll_i: false,
|
6925
7190
|
is_touch: false
|
6926
7191
|
};
|
7192
|
+
elm = null;
|
6927
7193
|
$(document).off("mousemove.vakata.jstree touchmove.vakata.jstree", $.vakata.dnd.drag);
|
6928
7194
|
$(document).off("mouseup.vakata.jstree touchend.vakata.jstree", $.vakata.dnd.stop);
|
6929
7195
|
},
|
@@ -7007,7 +7273,7 @@
|
|
7007
7273
|
Math.abs(e.pageY - vakata_dnd.init_y) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold)
|
7008
7274
|
) {
|
7009
7275
|
if(vakata_dnd.helper) {
|
7010
|
-
vakata_dnd.helper.appendTo(
|
7276
|
+
vakata_dnd.helper.appendTo(document.body);
|
7011
7277
|
vakata_dnd.helper_w = vakata_dnd.helper.outerWidth();
|
7012
7278
|
}
|
7013
7279
|
vakata_dnd.is_drag = true;
|
@@ -7038,7 +7304,7 @@
|
|
7038
7304
|
vakata_dnd.scroll_e = false;
|
7039
7305
|
$($(e.target).parentsUntil("body").addBack().get().reverse())
|
7040
7306
|
.filter(function () {
|
7041
|
-
return (/^auto|scroll$/).test($(this).css("overflow")) &&
|
7307
|
+
return this.ownerDocument && (/^auto|scroll$/).test($(this).css("overflow")) &&
|
7042
7308
|
(this.scrollHeight > this.offsetHeight || this.scrollWidth > this.offsetWidth);
|
7043
7309
|
})
|
7044
7310
|
.each(function () {
|
@@ -7119,7 +7385,7 @@
|
|
7119
7385
|
}
|
7120
7386
|
else {
|
7121
7387
|
if(e.type === "touchend" && e.target === vakata_dnd.target) {
|
7122
|
-
var to = setTimeout(function () { $(e.target).click
|
7388
|
+
var to = setTimeout(function () { $(e.target).trigger('click'); }, 100);
|
7123
7389
|
$(e.target).one('click', function() { if(to) { clearTimeout(to); } });
|
7124
7390
|
}
|
7125
7391
|
}
|
@@ -7164,8 +7430,7 @@
|
|
7164
7430
|
parent.init.call(this, el, options);
|
7165
7431
|
};
|
7166
7432
|
this._load_nodes = function (nodes, callback, is_callback, force_reload) {
|
7167
|
-
var s = this.settings.massload,
|
7168
|
-
nodesString = JSON.stringify(nodes),
|
7433
|
+
var s = this.settings.massload,
|
7169
7434
|
toLoad = [],
|
7170
7435
|
m = this._model.data,
|
7171
7436
|
i, j, dom;
|
@@ -7181,8 +7446,8 @@
|
|
7181
7446
|
}
|
7182
7447
|
this._data.massload = {};
|
7183
7448
|
if (toLoad.length) {
|
7184
|
-
if($.
|
7185
|
-
return s.call(this, toLoad,
|
7449
|
+
if($.vakata.is_function(s)) {
|
7450
|
+
return s.call(this, toLoad, function (data) {
|
7186
7451
|
var i, j;
|
7187
7452
|
if(data) {
|
7188
7453
|
for(i in data) {
|
@@ -7198,18 +7463,18 @@
|
|
7198
7463
|
}
|
7199
7464
|
}
|
7200
7465
|
parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
|
7201
|
-
}
|
7466
|
+
}.bind(this));
|
7202
7467
|
}
|
7203
7468
|
if(typeof s === 'object' && s && s.url) {
|
7204
7469
|
s = $.extend(true, {}, s);
|
7205
|
-
if($.
|
7470
|
+
if($.vakata.is_function(s.url)) {
|
7206
7471
|
s.url = s.url.call(this, toLoad);
|
7207
7472
|
}
|
7208
|
-
if($.
|
7473
|
+
if($.vakata.is_function(s.data)) {
|
7209
7474
|
s.data = s.data.call(this, toLoad);
|
7210
7475
|
}
|
7211
7476
|
return $.ajax(s)
|
7212
|
-
.done(
|
7477
|
+
.done(function (data,t,x) {
|
7213
7478
|
var i, j;
|
7214
7479
|
if(data) {
|
7215
7480
|
for(i in data) {
|
@@ -7225,10 +7490,10 @@
|
|
7225
7490
|
}
|
7226
7491
|
}
|
7227
7492
|
parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
|
7228
|
-
}
|
7229
|
-
.fail(
|
7493
|
+
}.bind(this))
|
7494
|
+
.fail(function (f) {
|
7230
7495
|
parent._load_nodes.call(this, nodes, callback, is_callback, force_reload);
|
7231
|
-
}
|
7496
|
+
}.bind(this));
|
7232
7497
|
}
|
7233
7498
|
}
|
7234
7499
|
}
|
@@ -7254,6 +7519,7 @@
|
|
7254
7519
|
};
|
7255
7520
|
};
|
7256
7521
|
|
7522
|
+
|
7257
7523
|
/**
|
7258
7524
|
* ### Search plugin
|
7259
7525
|
*
|
@@ -7335,7 +7601,7 @@
|
|
7335
7601
|
this._data.search.hdn = [];
|
7336
7602
|
|
7337
7603
|
this.element
|
7338
|
-
.on("search.jstree",
|
7604
|
+
.on("search.jstree", function (e, data) {
|
7339
7605
|
if(this._data.search.som && data.res.length) {
|
7340
7606
|
var m = this._model.data, i, j, p = [], k, l;
|
7341
7607
|
for(i = 0, j = data.res.length; i < j; i++) {
|
@@ -7356,13 +7622,13 @@
|
|
7356
7622
|
this.show_node(p, true);
|
7357
7623
|
this.redraw(true);
|
7358
7624
|
}
|
7359
|
-
}
|
7360
|
-
.on("clear_search.jstree",
|
7625
|
+
}.bind(this))
|
7626
|
+
.on("clear_search.jstree", function (e, data) {
|
7361
7627
|
if(this._data.search.som && data.res.length) {
|
7362
7628
|
this.show_node(this._data.search.hdn, true);
|
7363
7629
|
this.redraw(true);
|
7364
7630
|
}
|
7365
|
-
}
|
7631
|
+
}.bind(this));
|
7366
7632
|
};
|
7367
7633
|
/**
|
7368
7634
|
* used to search the tree nodes for a given string
|
@@ -7376,11 +7642,11 @@
|
|
7376
7642
|
* @trigger search.jstree
|
7377
7643
|
*/
|
7378
7644
|
this.search = function (str, skip_async, show_only_matches, inside, append, show_only_matches_children) {
|
7379
|
-
if(str === false || $.trim(str.toString()) === "") {
|
7645
|
+
if(str === false || $.vakata.trim(str.toString()) === "") {
|
7380
7646
|
return this.clear_search();
|
7381
7647
|
}
|
7382
7648
|
inside = this.get_node(inside);
|
7383
|
-
inside = inside && inside.id ? inside.id : null;
|
7649
|
+
inside = inside && (inside.id || inside.id === 0) ? inside.id : null;
|
7384
7650
|
str = str.toString();
|
7385
7651
|
var s = this.settings.search,
|
7386
7652
|
a = s.ajax ? s.ajax : false,
|
@@ -7398,13 +7664,13 @@
|
|
7398
7664
|
show_only_matches_children = s.show_only_matches_children;
|
7399
7665
|
}
|
7400
7666
|
if(!skip_async && a !== false) {
|
7401
|
-
if($.
|
7402
|
-
return a.call(this, str,
|
7667
|
+
if($.vakata.is_function(a)) {
|
7668
|
+
return a.call(this, str, function (d) {
|
7403
7669
|
if(d && d.d) { d = d.d; }
|
7404
|
-
this._load_nodes(!$.
|
7670
|
+
this._load_nodes(!$.vakata.is_array(d) ? [] : $.vakata.array_unique(d), function () {
|
7405
7671
|
this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
|
7406
7672
|
});
|
7407
|
-
}
|
7673
|
+
}.bind(this), inside);
|
7408
7674
|
}
|
7409
7675
|
else {
|
7410
7676
|
a = $.extend({}, a);
|
@@ -7417,16 +7683,16 @@
|
|
7417
7683
|
this._data.search.lastRequest.abort();
|
7418
7684
|
}
|
7419
7685
|
this._data.search.lastRequest = $.ajax(a)
|
7420
|
-
.fail(
|
7686
|
+
.fail(function () {
|
7421
7687
|
this._data.core.last_error = { 'error' : 'ajax', 'plugin' : 'search', 'id' : 'search_01', 'reason' : 'Could not load search parents', 'data' : JSON.stringify(a) };
|
7422
7688
|
this.settings.core.error.call(this, this._data.core.last_error);
|
7423
|
-
}
|
7424
|
-
.done(
|
7689
|
+
}.bind(this))
|
7690
|
+
.done(function (d) {
|
7425
7691
|
if(d && d.d) { d = d.d; }
|
7426
|
-
this._load_nodes(!$.
|
7692
|
+
this._load_nodes(!$.vakata.is_array(d) ? [] : $.vakata.array_unique(d), function () {
|
7427
7693
|
this.search(str, true, show_only_matches, inside, append, show_only_matches_children);
|
7428
7694
|
});
|
7429
|
-
}
|
7695
|
+
}.bind(this));
|
7430
7696
|
return this._data.search.lastRequest;
|
7431
7697
|
}
|
7432
7698
|
}
|
@@ -7568,7 +7834,7 @@
|
|
7568
7834
|
};
|
7569
7835
|
}
|
7570
7836
|
search = function (text) {
|
7571
|
-
text = options.caseSensitive ? text : text.toLowerCase();
|
7837
|
+
text = options.caseSensitive ? text.toString() : text.toString().toLowerCase();
|
7572
7838
|
if(pattern === text || text.indexOf(pattern) !== -1) {
|
7573
7839
|
return {
|
7574
7840
|
isMatch: true,
|
@@ -7680,17 +7946,17 @@
|
|
7680
7946
|
this.bind = function () {
|
7681
7947
|
parent.bind.call(this);
|
7682
7948
|
this.element
|
7683
|
-
.on("model.jstree",
|
7949
|
+
.on("model.jstree", function (e, data) {
|
7684
7950
|
this.sort(data.parent, true);
|
7685
|
-
}
|
7686
|
-
.on("rename_node.jstree create_node.jstree",
|
7951
|
+
}.bind(this))
|
7952
|
+
.on("rename_node.jstree create_node.jstree", function (e, data) {
|
7687
7953
|
this.sort(data.parent || data.node.parent, false);
|
7688
7954
|
this.redraw_node(data.parent || data.node.parent, true);
|
7689
|
-
}
|
7690
|
-
.on("move_node.jstree copy_node.jstree",
|
7955
|
+
}.bind(this))
|
7956
|
+
.on("move_node.jstree copy_node.jstree", function (e, data) {
|
7691
7957
|
this.sort(data.parent, false);
|
7692
7958
|
this.redraw_node(data.parent, true);
|
7693
|
-
}
|
7959
|
+
}.bind(this));
|
7694
7960
|
};
|
7695
7961
|
/**
|
7696
7962
|
* used to sort a node's children
|
@@ -7705,7 +7971,7 @@
|
|
7705
7971
|
var i, j;
|
7706
7972
|
obj = this.get_node(obj);
|
7707
7973
|
if(obj && obj.children && obj.children.length) {
|
7708
|
-
obj.children.sort(
|
7974
|
+
obj.children.sort(this.settings.sort.bind(this));
|
7709
7975
|
if(deep) {
|
7710
7976
|
for(i = 0, j = obj.children_d.length; i < j; i++) {
|
7711
7977
|
this.sort(obj.children_d[i], false);
|
@@ -7754,16 +8020,22 @@
|
|
7754
8020
|
* @name $.jstree.defaults.state.filter
|
7755
8021
|
* @plugin state
|
7756
8022
|
*/
|
7757
|
-
filter : false
|
8023
|
+
filter : false,
|
8024
|
+
/**
|
8025
|
+
* 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`
|
8026
|
+
* @name $.jstree.defaults.state.preserve_loaded
|
8027
|
+
* @plugin state
|
8028
|
+
*/
|
8029
|
+
preserve_loaded : false
|
7758
8030
|
};
|
7759
8031
|
$.jstree.plugins.state = function (options, parent) {
|
7760
8032
|
this.bind = function () {
|
7761
8033
|
parent.bind.call(this);
|
7762
|
-
var bind =
|
7763
|
-
this.element.on(this.settings.state.events,
|
8034
|
+
var bind = function () {
|
8035
|
+
this.element.on(this.settings.state.events, function () {
|
7764
8036
|
if(to) { clearTimeout(to); }
|
7765
|
-
to = setTimeout(
|
7766
|
-
}
|
8037
|
+
to = setTimeout(function () { this.save_state(); }.bind(this), 100);
|
8038
|
+
}.bind(this));
|
7767
8039
|
/**
|
7768
8040
|
* triggered when the state plugin is finished restoring the state (and immediately after ready if there is no state to restore).
|
7769
8041
|
* @event
|
@@ -7771,12 +8043,12 @@
|
|
7771
8043
|
* @plugin state
|
7772
8044
|
*/
|
7773
8045
|
this.trigger('state_ready');
|
7774
|
-
}
|
8046
|
+
}.bind(this);
|
7775
8047
|
this.element
|
7776
|
-
.on("ready.jstree",
|
8048
|
+
.on("ready.jstree", function (e, data) {
|
7777
8049
|
this.element.one("restore_state.jstree", bind);
|
7778
8050
|
if(!this.restore_state()) { bind(); }
|
7779
|
-
}
|
8051
|
+
}.bind(this));
|
7780
8052
|
};
|
7781
8053
|
/**
|
7782
8054
|
* save the state
|
@@ -7784,7 +8056,11 @@
|
|
7784
8056
|
* @plugin state
|
7785
8057
|
*/
|
7786
8058
|
this.save_state = function () {
|
7787
|
-
var
|
8059
|
+
var tm = this.get_state();
|
8060
|
+
if (!this.settings.state.preserve_loaded) {
|
8061
|
+
delete tm.core.loaded;
|
8062
|
+
}
|
8063
|
+
var st = { 'state' : tm, 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) };
|
7788
8064
|
$.vakata.storage.set(this.settings.state.key, JSON.stringify(st));
|
7789
8065
|
};
|
7790
8066
|
/**
|
@@ -7797,8 +8073,11 @@
|
|
7797
8073
|
if(!!k) { try { k = JSON.parse(k); } catch(ex) { return false; } }
|
7798
8074
|
if(!!k && k.ttl && k.sec && +(new Date()) - k.sec > k.ttl) { return false; }
|
7799
8075
|
if(!!k && k.state) { k = k.state; }
|
7800
|
-
if(!!k && $.
|
8076
|
+
if(!!k && $.vakata.is_function(this.settings.state.filter)) { k = this.settings.state.filter.call(this, k); }
|
7801
8077
|
if(!!k) {
|
8078
|
+
if (!this.settings.state.preserve_loaded) {
|
8079
|
+
delete k.core.loaded;
|
8080
|
+
}
|
7802
8081
|
this.element.one("set_state.jstree", function (e, data) { data.instance.trigger('restore_state', { 'state' : $.extend(true, {}, k) }); });
|
7803
8082
|
this.set_state(k);
|
7804
8083
|
return true;
|
@@ -7879,7 +8158,7 @@
|
|
7879
8158
|
};
|
7880
8159
|
this.bind = function () {
|
7881
8160
|
this.element
|
7882
|
-
.on('model.jstree',
|
8161
|
+
.on('model.jstree', function (e, data) {
|
7883
8162
|
var m = this._model.data,
|
7884
8163
|
dpc = data.nodes,
|
7885
8164
|
t = this.settings.types,
|
@@ -7931,7 +8210,7 @@
|
|
7931
8210
|
}
|
7932
8211
|
}
|
7933
8212
|
m[$.jstree.root].type = $.jstree.root;
|
7934
|
-
}
|
8213
|
+
}.bind(this));
|
7935
8214
|
parent.bind.call(this);
|
7936
8215
|
};
|
7937
8216
|
this.get_json = function (obj, options, flat) {
|
@@ -7940,9 +8219,9 @@
|
|
7940
8219
|
opt = options ? $.extend(true, {}, options, {no_id:false}) : {},
|
7941
8220
|
tmp = parent.get_json.call(this, obj, opt, flat);
|
7942
8221
|
if(tmp === false) { return false; }
|
7943
|
-
if($.
|
8222
|
+
if($.vakata.is_array(tmp)) {
|
7944
8223
|
for(i = 0, j = tmp.length; i < j; i++) {
|
7945
|
-
tmp[i].type = tmp[i].id && m[tmp[i].id] && m[tmp[i].id].type ? m[tmp[i].id].type : "default";
|
8224
|
+
tmp[i].type = (tmp[i].id || tmp[i].id === 0) && m[tmp[i].id] && m[tmp[i].id].type ? m[tmp[i].id].type : "default";
|
7946
8225
|
if(options && options.no_id) {
|
7947
8226
|
delete tmp[i].id;
|
7948
8227
|
if(tmp[i].li_attr && tmp[i].li_attr.id) {
|
@@ -7955,7 +8234,7 @@
|
|
7955
8234
|
}
|
7956
8235
|
}
|
7957
8236
|
else {
|
7958
|
-
tmp.type = tmp.id && m[tmp.id] && m[tmp.id].type ? m[tmp.id].type : "default";
|
8237
|
+
tmp.type = (tmp.id || tmp.id === 0) && m[tmp.id] && m[tmp.id].type ? m[tmp.id].type : "default";
|
7959
8238
|
if(options && options.no_id) {
|
7960
8239
|
tmp = this._delete_ids(tmp);
|
7961
8240
|
}
|
@@ -7963,7 +8242,7 @@
|
|
7963
8242
|
return tmp;
|
7964
8243
|
};
|
7965
8244
|
this._delete_ids = function (tmp) {
|
7966
|
-
if($.
|
8245
|
+
if($.vakata.is_array(tmp)) {
|
7967
8246
|
for(var i = 0, j = tmp.length; i < j; i++) {
|
7968
8247
|
tmp[i] = this._delete_ids(tmp[i]);
|
7969
8248
|
}
|
@@ -7976,16 +8255,16 @@
|
|
7976
8255
|
if(tmp.a_attr && tmp.a_attr.id) {
|
7977
8256
|
delete tmp.a_attr.id;
|
7978
8257
|
}
|
7979
|
-
if(tmp.children && $.
|
8258
|
+
if(tmp.children && $.vakata.is_array(tmp.children)) {
|
7980
8259
|
tmp.children = this._delete_ids(tmp.children);
|
7981
8260
|
}
|
7982
8261
|
return tmp;
|
7983
8262
|
};
|
7984
8263
|
this.check = function (chk, obj, par, pos, more) {
|
7985
8264
|
if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
|
7986
|
-
obj = obj && obj.id ? obj : this.get_node(obj);
|
7987
|
-
par = par && par.id ? par : this.get_node(par);
|
7988
|
-
var m = obj && obj.id ? (more && more.origin ? more.origin : $.jstree.reference(obj.id)) : null, tmp, d, i, j;
|
8265
|
+
obj = obj && (obj.id || obj.id === 0) ? obj : this.get_node(obj);
|
8266
|
+
par = par && (par.id || par.id === 0) ? par : this.get_node(par);
|
8267
|
+
var m = obj && (obj.id || obj.id === 0) ? (more && more.origin ? more.origin : $.jstree.reference(obj.id)) : null, tmp, d, i, j;
|
7989
8268
|
m = m && m._model && m._model.data ? m._model.data : null;
|
7990
8269
|
switch(chk) {
|
7991
8270
|
case "create_node":
|
@@ -7994,11 +8273,11 @@
|
|
7994
8273
|
if(chk !== 'move_node' || $.inArray(obj.id, par.children) === -1) {
|
7995
8274
|
tmp = this.get_rules(par);
|
7996
8275
|
if(tmp.max_children !== undefined && tmp.max_children !== -1 && tmp.max_children === par.children.length) {
|
7997
|
-
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_01', 'reason' : 'max_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
|
8276
|
+
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_01', 'reason' : 'max_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && (obj.id || obj.id === 0) ? obj.id : false, 'par' : par && (par.id || par.id === 0) ? par.id : false }) };
|
7998
8277
|
return false;
|
7999
8278
|
}
|
8000
8279
|
if(tmp.valid_children !== undefined && tmp.valid_children !== -1 && $.inArray((obj.type || 'default'), tmp.valid_children) === -1) {
|
8001
|
-
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_02', 'reason' : 'valid_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
|
8280
|
+
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_02', 'reason' : 'valid_children prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && (obj.id || obj.id === 0) ? obj.id : false, 'par' : par && (par.id || par.id === 0) ? par.id : false }) };
|
8002
8281
|
return false;
|
8003
8282
|
}
|
8004
8283
|
if(m && obj.children_d && obj.parents) {
|
@@ -8011,7 +8290,7 @@
|
|
8011
8290
|
if(d <= 0 || d === undefined) { d = 1; }
|
8012
8291
|
do {
|
8013
8292
|
if(tmp.max_depth !== undefined && tmp.max_depth !== -1 && tmp.max_depth < d) {
|
8014
|
-
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_03', 'reason' : 'max_depth prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && obj.id ? obj.id : false, 'par' : par && par.id ? par.id : false }) };
|
8293
|
+
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'types', 'id' : 'types_03', 'reason' : 'max_depth prevents function: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && (obj.id || obj.id === 0) ? obj.id : false, 'par' : par && (par.id || par.id === 0) ? par.id : false }) };
|
8015
8294
|
return false;
|
8016
8295
|
}
|
8017
8296
|
par = this.get_node(par.parent);
|
@@ -8060,7 +8339,7 @@
|
|
8060
8339
|
*/
|
8061
8340
|
this.set_type = function (obj, type) {
|
8062
8341
|
var m = this._model.data, t, t1, t2, old_type, old_icon, k, d, a;
|
8063
|
-
if($.
|
8342
|
+
if($.vakata.is_array(obj)) {
|
8064
8343
|
obj = obj.slice();
|
8065
8344
|
for(t1 = 0, t2 = obj.length; t1 < t2; t1++) {
|
8066
8345
|
this.set_type(obj[t1], type);
|
@@ -8203,7 +8482,13 @@
|
|
8203
8482
|
*/
|
8204
8483
|
case_sensitive : false,
|
8205
8484
|
/**
|
8206
|
-
*
|
8485
|
+
* Indicates if white space should be trimmed before the comparison. Default is `false`.
|
8486
|
+
* @name $.jstree.defaults.unique.trim_whitespace
|
8487
|
+
* @plugin unique
|
8488
|
+
*/
|
8489
|
+
trim_whitespace : false,
|
8490
|
+
/**
|
8491
|
+
* 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)`.
|
8207
8492
|
* @name $.jstree.defaults.unique.duplicate
|
8208
8493
|
* @plugin unique
|
8209
8494
|
*/
|
@@ -8215,49 +8500,65 @@
|
|
8215
8500
|
$.jstree.plugins.unique = function (options, parent) {
|
8216
8501
|
this.check = function (chk, obj, par, pos, more) {
|
8217
8502
|
if(parent.check.call(this, chk, obj, par, pos, more) === false) { return false; }
|
8218
|
-
obj = obj && obj.id ? obj : this.get_node(obj);
|
8219
|
-
par = par && par.id ? par : this.get_node(par);
|
8503
|
+
obj = obj && (obj.id || obj.id === 0) ? obj : this.get_node(obj);
|
8504
|
+
par = par && (par.id || par.id === 0) ? par : this.get_node(par);
|
8220
8505
|
if(!par || !par.children) { return true; }
|
8221
8506
|
var n = chk === "rename_node" ? pos : obj.text,
|
8222
8507
|
c = [],
|
8223
8508
|
s = this.settings.unique.case_sensitive,
|
8224
|
-
|
8509
|
+
w = this.settings.unique.trim_whitespace,
|
8510
|
+
m = this._model.data, i, j, t;
|
8225
8511
|
for(i = 0, j = par.children.length; i < j; i++) {
|
8226
|
-
|
8512
|
+
t = m[par.children[i]].text;
|
8513
|
+
if (!s) {
|
8514
|
+
t = t.toLowerCase();
|
8515
|
+
}
|
8516
|
+
if (w) {
|
8517
|
+
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
8518
|
+
}
|
8519
|
+
c.push(t);
|
8227
8520
|
}
|
8228
8521
|
if(!s) { n = n.toLowerCase(); }
|
8522
|
+
if (w) { n = n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }
|
8229
8523
|
switch(chk) {
|
8230
8524
|
case "delete_node":
|
8231
8525
|
return true;
|
8232
8526
|
case "rename_node":
|
8233
|
-
|
8527
|
+
t = obj.text || '';
|
8528
|
+
if (!s) {
|
8529
|
+
t = t.toLowerCase();
|
8530
|
+
}
|
8531
|
+
if (w) {
|
8532
|
+
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
8533
|
+
}
|
8534
|
+
i = ($.inArray(n, c) === -1 || (obj.text && t === n));
|
8234
8535
|
if(!i) {
|
8235
|
-
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_01', '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 }) };
|
8536
|
+
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_01', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && (obj.id || obj.id === 0) ? obj.id : false, 'par' : par && (par.id || par.id === 0) ? par.id : false }) };
|
8236
8537
|
}
|
8237
8538
|
return i;
|
8238
8539
|
case "create_node":
|
8239
8540
|
i = ($.inArray(n, c) === -1);
|
8240
8541
|
if(!i) {
|
8241
|
-
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_04', '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 }) };
|
8542
|
+
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_04', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && (obj.id || obj.id === 0) ? obj.id : false, 'par' : par && (par.id || par.id === 0) ? par.id : false }) };
|
8242
8543
|
}
|
8243
8544
|
return i;
|
8244
8545
|
case "copy_node":
|
8245
8546
|
i = ($.inArray(n, c) === -1);
|
8246
8547
|
if(!i) {
|
8247
|
-
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_02', '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 }) };
|
8548
|
+
this._data.core.last_error = { 'error' : 'check', 'plugin' : 'unique', 'id' : 'unique_02', 'reason' : 'Child with name ' + n + ' already exists. Preventing: ' + chk, 'data' : JSON.stringify({ 'chk' : chk, 'pos' : pos, 'obj' : obj && (obj.id || obj.id === 0) ? obj.id : false, 'par' : par && (par.id || par.id === 0) ? par.id : false }) };
|
8248
8549
|
}
|
8249
8550
|
return i;
|
8250
8551
|
case "move_node":
|
8251
8552
|
i = ( (obj.parent === par.id && (!more || !more.is_multi)) || $.inArray(n, c) === -1);
|
8252
8553
|
if(!i) {
|
8253
|
-
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 }) };
|
8554
|
+
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 === 0) ? obj.id : false, 'par' : par && (par.id || par.id === 0) ? par.id : false }) };
|
8254
8555
|
}
|
8255
8556
|
return i;
|
8256
8557
|
}
|
8257
8558
|
return true;
|
8258
8559
|
};
|
8259
8560
|
this.create_node = function (par, node, pos, callback, is_loaded) {
|
8260
|
-
if(!node || node.text === undefined) {
|
8561
|
+
if(!node || (typeof node === 'object' && node.text === undefined)) {
|
8261
8562
|
if(par === null) {
|
8262
8563
|
par = $.jstree.root;
|
8263
8564
|
}
|
@@ -8270,15 +8571,36 @@
|
|
8270
8571
|
return parent.create_node.call(this, par, node, pos, callback, is_loaded);
|
8271
8572
|
}
|
8272
8573
|
if(!node) { node = {}; }
|
8273
|
-
var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, cb = this.settings.unique.duplicate;
|
8574
|
+
var tmp, n, dpc, i, j, m = this._model.data, s = this.settings.unique.case_sensitive, w = this.settings.unique.trim_whitespace, cb = this.settings.unique.duplicate, t;
|
8274
8575
|
n = tmp = this.get_string('New node');
|
8275
8576
|
dpc = [];
|
8276
8577
|
for(i = 0, j = par.children.length; i < j; i++) {
|
8277
|
-
|
8578
|
+
t = m[par.children[i]].text;
|
8579
|
+
if (!s) {
|
8580
|
+
t = t.toLowerCase();
|
8581
|
+
}
|
8582
|
+
if (w) {
|
8583
|
+
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
8584
|
+
}
|
8585
|
+
dpc.push(t);
|
8278
8586
|
}
|
8279
8587
|
i = 1;
|
8280
|
-
|
8588
|
+
t = n;
|
8589
|
+
if (!s) {
|
8590
|
+
t = t.toLowerCase();
|
8591
|
+
}
|
8592
|
+
if (w) {
|
8593
|
+
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
8594
|
+
}
|
8595
|
+
while($.inArray(t, dpc) !== -1) {
|
8281
8596
|
n = cb.call(this, tmp, (++i)).toString();
|
8597
|
+
t = n;
|
8598
|
+
if (!s) {
|
8599
|
+
t = t.toLowerCase();
|
8600
|
+
}
|
8601
|
+
if (w) {
|
8602
|
+
t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
8603
|
+
}
|
8282
8604
|
}
|
8283
8605
|
node.text = n;
|
8284
8606
|
}
|
@@ -8306,17 +8628,17 @@
|
|
8306
8628
|
parent.bind.call(this);
|
8307
8629
|
|
8308
8630
|
this.element
|
8309
|
-
.on('ready.jstree set_state.jstree',
|
8631
|
+
.on('ready.jstree set_state.jstree', function () {
|
8310
8632
|
this.hide_dots();
|
8311
|
-
}
|
8312
|
-
.on("init.jstree loading.jstree ready.jstree",
|
8633
|
+
}.bind(this))
|
8634
|
+
.on("init.jstree loading.jstree ready.jstree", function () {
|
8313
8635
|
//div.style.height = this._data.core.li_height + 'px';
|
8314
8636
|
this.get_container_ul().addClass('jstree-wholerow-ul');
|
8315
|
-
}
|
8316
|
-
.on("deselect_all.jstree",
|
8637
|
+
}.bind(this))
|
8638
|
+
.on("deselect_all.jstree", function (e, data) {
|
8317
8639
|
this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked');
|
8318
|
-
}
|
8319
|
-
.on("changed.jstree",
|
8640
|
+
}.bind(this))
|
8641
|
+
.on("changed.jstree", function (e, data) {
|
8320
8642
|
this.element.find('.jstree-wholerow-clicked').removeClass('jstree-wholerow-clicked');
|
8321
8643
|
var tmp = false, i, j;
|
8322
8644
|
for(i = 0, j = data.selected.length; i < j; i++) {
|
@@ -8325,21 +8647,21 @@
|
|
8325
8647
|
tmp.children('.jstree-wholerow').addClass('jstree-wholerow-clicked');
|
8326
8648
|
}
|
8327
8649
|
}
|
8328
|
-
}
|
8329
|
-
.on("open_node.jstree",
|
8650
|
+
}.bind(this))
|
8651
|
+
.on("open_node.jstree", function (e, data) {
|
8330
8652
|
this.get_node(data.node, true).find('.jstree-clicked').parent().children('.jstree-wholerow').addClass('jstree-wholerow-clicked');
|
8331
|
-
}
|
8332
|
-
.on("hover_node.jstree dehover_node.jstree",
|
8653
|
+
}.bind(this))
|
8654
|
+
.on("hover_node.jstree dehover_node.jstree", function (e, data) {
|
8333
8655
|
if(e.type === "hover_node" && this.is_disabled(data.node)) { return; }
|
8334
8656
|
this.get_node(data.node, true).children('.jstree-wholerow')[e.type === "hover_node"?"addClass":"removeClass"]('jstree-wholerow-hovered');
|
8335
|
-
}
|
8336
|
-
.on("contextmenu.jstree", ".jstree-wholerow",
|
8657
|
+
}.bind(this))
|
8658
|
+
.on("contextmenu.jstree", ".jstree-wholerow", function (e) {
|
8337
8659
|
if (this._data.contextmenu) {
|
8338
8660
|
e.preventDefault();
|
8339
8661
|
var tmp = $.Event('contextmenu', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey, pageX : e.pageX, pageY : e.pageY });
|
8340
8662
|
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp);
|
8341
8663
|
}
|
8342
|
-
}
|
8664
|
+
}.bind(this))
|
8343
8665
|
/*!
|
8344
8666
|
.on("mousedown.jstree touchstart.jstree", ".jstree-wholerow", function (e) {
|
8345
8667
|
if(e.target === e.currentTarget) {
|
@@ -8352,28 +8674,28 @@
|
|
8352
8674
|
.on("click.jstree", ".jstree-wholerow", function (e) {
|
8353
8675
|
e.stopImmediatePropagation();
|
8354
8676
|
var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
|
8355
|
-
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus
|
8677
|
+
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).trigger('focus');
|
8356
8678
|
})
|
8357
8679
|
.on("dblclick.jstree", ".jstree-wholerow", function (e) {
|
8358
8680
|
e.stopImmediatePropagation();
|
8359
8681
|
var tmp = $.Event('dblclick', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
|
8360
|
-
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus
|
8682
|
+
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).trigger('focus');
|
8361
8683
|
})
|
8362
|
-
.on("click.jstree", ".jstree-leaf > .jstree-ocl",
|
8684
|
+
.on("click.jstree", ".jstree-leaf > .jstree-ocl", function (e) {
|
8363
8685
|
e.stopImmediatePropagation();
|
8364
8686
|
var tmp = $.Event('click', { metaKey : e.metaKey, ctrlKey : e.ctrlKey, altKey : e.altKey, shiftKey : e.shiftKey });
|
8365
|
-
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).focus
|
8366
|
-
}
|
8367
|
-
.on("mouseover.jstree", ".jstree-wholerow, .jstree-icon",
|
8687
|
+
$(e.currentTarget).closest(".jstree-node").children(".jstree-anchor").first().trigger(tmp).trigger('focus');
|
8688
|
+
}.bind(this))
|
8689
|
+
.on("mouseover.jstree", ".jstree-wholerow, .jstree-icon", function (e) {
|
8368
8690
|
e.stopImmediatePropagation();
|
8369
8691
|
if(!this.is_disabled(e.currentTarget)) {
|
8370
8692
|
this.hover_node(e.currentTarget);
|
8371
8693
|
}
|
8372
8694
|
return false;
|
8373
|
-
}
|
8374
|
-
.on("mouseleave.jstree", ".jstree-node",
|
8695
|
+
}.bind(this))
|
8696
|
+
.on("mouseleave.jstree", ".jstree-node", function (e) {
|
8375
8697
|
this.dehover_node(e.currentTarget);
|
8376
|
-
}
|
8698
|
+
}.bind(this));
|
8377
8699
|
};
|
8378
8700
|
this.teardown = function () {
|
8379
8701
|
if(this.settings.wholerow) {
|
@@ -8395,7 +8717,7 @@
|
|
8395
8717
|
};
|
8396
8718
|
// include the wholerow plugin by default
|
8397
8719
|
// $.jstree.defaults.plugins.push("wholerow");
|
8398
|
-
if(
|
8720
|
+
if(window.customElements && Object && Object.create) {
|
8399
8721
|
var proto = Object.create(HTMLElement.prototype);
|
8400
8722
|
proto.createdCallback = function () {
|
8401
8723
|
var c = { core : {}, plugins : [] }, i;
|
@@ -8416,8 +8738,8 @@
|
|
8416
8738
|
};
|
8417
8739
|
// proto.attributeChangedCallback = function (name, previous, value) { };
|
8418
8740
|
try {
|
8419
|
-
|
8420
|
-
} catch(ignore) { }
|
8741
|
+
window.customElements.define("vakata-jstree", function() {}, { prototype: proto });
|
8742
|
+
} catch (ignore) { }
|
8421
8743
|
}
|
8422
8744
|
|
8423
8745
|
}));
|