jstree-rails-4 3.3.4 → 3.3.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fc466fd09787baf263981593e1e218175853cc0e
4
- data.tar.gz: 339f485ad09c8bc3f9df4c381ad8766625263d52
2
+ SHA256:
3
+ metadata.gz: 15fd7da27ef66707c91e83381c14cd7bb7f964d506c420bfe0873ee9350a8a5c
4
+ data.tar.gz: e217421d7b25adfd3c930820a8e873a1dd7ba2bd202360270327cd865498041d
5
5
  SHA512:
6
- metadata.gz: 49bacacf259e1a723d3d773af2f66116c768bec96d09a737a04ba2599be14dee7c81ca6d33e5d875c1144fa6e11e0aafa50adad0efcac8ebb014bf055bf2d343
7
- data.tar.gz: c2bb926645064947f28980b8eb9d6a5feff6d18f4b8ff701d61f1b978c9ad8c0ad0ce832001f70d2a78134162f7b167e7ba88455d91e0e574518065d5a108639
6
+ metadata.gz: c174ed620d5e08ed67f3bdb457b145ccb3c5bc345a45b792caa7d1c8a2ef71511eacdd43a7c7e6bb1970c5bb6338629aa0966aa97583e0dcf8ac4aed0dd7364a
7
+ data.tar.gz: e80d5a236ea2130e4b552efded92ec280b410675a8507d8f5e8e2b30f93ef015c44579e13e9126bd42281f487d99c620f761255089cb1c2fbe74849351f89459
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jstree-rails-4 (3.3.4)
4
+ jstree-rails-4 (3.3.8)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -21,4 +21,4 @@ DEPENDENCIES
21
21
  thor (~> 0.19)
22
22
 
23
23
  BUNDLED WITH
24
- 1.14.6
24
+ 1.16.3
data/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  The `jstree-rails-4` gem integrates the `jsTree` jQuery plugin with the Rails asset pipeline.
6
6
 
7
- GemVersion: 3.3.4
7
+ GemVersion: 3.3.8
8
8
 
9
- jsTree Version: 3.3.4
9
+ jsTree Version: 3.3.8
10
10
 
11
11
  ## Usage
12
12
 
@@ -1,5 +1,5 @@
1
1
  module JSTree
2
2
  module Rails
3
- VERSION = '3.3.4'
3
+ VERSION = '3.3.8'
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@
13
13
  }(function ($, undefined) {
14
14
  "use strict";
15
15
  /*!
16
- * jsTree 3.3.4
16
+ * jsTree 3.3.8
17
17
  * http://jstree.com/
18
18
  *
19
19
  * Copyright (c) 2014 Ivan Bozhanov (http://vakata.com)
@@ -54,7 +54,7 @@
54
54
  * specifies the jstree version in use
55
55
  * @name $.jstree.version
56
56
  */
57
- version : '3.3.4',
57
+ version : '3.3.8',
58
58
  /**
59
59
  * holds all the default options used when creating new instances
60
60
  * @name $.jstree.defaults
@@ -430,10 +430,90 @@
430
430
  */
431
431
  force_text : false,
432
432
  /**
433
- * Should the node should be toggled if the text is double clicked . Defaults to `true`
433
+ * Should the node be toggled if the text is double clicked. Defaults to `true`
434
434
  * @name $.jstree.defaults.core.dblclick_toggle
435
435
  */
436
- dblclick_toggle : true
436
+ dblclick_toggle : true,
437
+ /**
438
+ * Should the loaded nodes be part of the state. Defaults to `false`
439
+ * @name $.jstree.defaults.core.loaded_state
440
+ */
441
+ loaded_state : false,
442
+ /**
443
+ * 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`
444
+ * @name $.jstree.defaults.core.restore_focus
445
+ */
446
+ restore_focus : true,
447
+ /**
448
+ * 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)
449
+ * @name $.jstree.defaults.core.keyboard
450
+ */
451
+ keyboard : {
452
+ 'ctrl-space': function (e) {
453
+ // aria defines space only with Ctrl
454
+ e.type = "click";
455
+ $(e.currentTarget).trigger(e);
456
+ },
457
+ 'enter': function (e) {
458
+ // enter
459
+ e.type = "click";
460
+ $(e.currentTarget).trigger(e);
461
+ },
462
+ 'left': function (e) {
463
+ // left
464
+ e.preventDefault();
465
+ if(this.is_open(e.currentTarget)) {
466
+ this.close_node(e.currentTarget);
467
+ }
468
+ else {
469
+ var o = this.get_parent(e.currentTarget);
470
+ if(o && o.id !== $.jstree.root) { this.get_node(o, true).children('.jstree-anchor').focus(); }
471
+ }
472
+ },
473
+ 'up': function (e) {
474
+ // up
475
+ e.preventDefault();
476
+ var o = this.get_prev_dom(e.currentTarget);
477
+ if(o && o.length) { o.children('.jstree-anchor').focus(); }
478
+ },
479
+ 'right': function (e) {
480
+ // right
481
+ e.preventDefault();
482
+ if(this.is_closed(e.currentTarget)) {
483
+ this.open_node(e.currentTarget, function (o) { this.get_node(o, true).children('.jstree-anchor').focus(); });
484
+ }
485
+ else if (this.is_open(e.currentTarget)) {
486
+ var o = this.get_node(e.currentTarget, true).children('.jstree-children')[0];
487
+ if(o) { $(this._firstChild(o)).children('.jstree-anchor').focus(); }
488
+ }
489
+ },
490
+ 'down': function (e) {
491
+ // down
492
+ e.preventDefault();
493
+ var o = this.get_next_dom(e.currentTarget);
494
+ if(o && o.length) { o.children('.jstree-anchor').focus(); }
495
+ },
496
+ '*': function (e) {
497
+ // aria defines * on numpad as open_all - not very common
498
+ this.open_all();
499
+ },
500
+ 'home': function (e) {
501
+ // home
502
+ e.preventDefault();
503
+ var o = this._firstChild(this.get_container_ul()[0]);
504
+ if(o) { $(o).children('.jstree-anchor').filter(':visible').focus(); }
505
+ },
506
+ 'end': function (e) {
507
+ // end
508
+ e.preventDefault();
509
+ this.element.find('.jstree-anchor').filter(':visible').last().focus();
510
+ },
511
+ 'f2': function (e) {
512
+ // f2 - safe to include - if check_callback is false it will fail
513
+ e.preventDefault();
514
+ this.edit(e.currentTarget);
515
+ }
516
+ }
437
517
  };
438
518
  $.jstree.core.prototype = {
439
519
  /**
@@ -548,7 +628,9 @@
548
628
  this.teardown();
549
629
  },
550
630
  /**
551
- * Create prototype node
631
+ * Create a prototype node
632
+ * @name _create_prototype_node()
633
+ * @return {DOMElement}
552
634
  */
553
635
  _create_prototype_node : function () {
554
636
  var _node = document.createElement('LI'), _temp1, _temp2;
@@ -570,6 +652,48 @@
570
652
 
571
653
  return _node;
572
654
  },
655
+ _kbevent_to_func : function (e) {
656
+ var keys = {
657
+ 8: "Backspace", 9: "Tab", 13: "Enter", 19: "Pause", 27: "Esc",
658
+ 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home",
659
+ 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "Print", 45: "Insert",
660
+ 46: "Delete", 96: "Numpad0", 97: "Numpad1", 98: "Numpad2", 99 : "Numpad3",
661
+ 100: "Numpad4", 101: "Numpad5", 102: "Numpad6", 103: "Numpad7",
662
+ 104: "Numpad8", 105: "Numpad9", '-13': "NumpadEnter", 112: "F1",
663
+ 113: "F2", 114: "F3", 115: "F4", 116: "F5", 117: "F6", 118: "F7",
664
+ 119: "F8", 120: "F9", 121: "F10", 122: "F11", 123: "F12", 144: "Numlock",
665
+ 145: "Scrolllock", 16: 'Shift', 17: 'Ctrl', 18: 'Alt',
666
+ 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
667
+ 54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
668
+ 66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
669
+ 73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
670
+ 80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
671
+ 87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
672
+ 186: ';', 187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`',
673
+ 219: '[', 220: '\\',221: ']', 222: "'", 111: '/', 106: '*', 173: '-'
674
+ };
675
+ var parts = [];
676
+ if (e.ctrlKey) { parts.push('ctrl'); }
677
+ if (e.altKey) { parts.push('alt'); }
678
+ if (e.shiftKey) { parts.push('shift'); }
679
+ parts.push(keys[e.which] || e.which);
680
+ parts = parts.sort().join('-').toLowerCase();
681
+
682
+ var kb = this.settings.core.keyboard, i, tmp;
683
+ for (i in kb) {
684
+ if (kb.hasOwnProperty(i)) {
685
+ tmp = i;
686
+ if (tmp !== '-' && tmp !== '+') {
687
+ tmp = tmp.replace('--', '-MINUS').replace('+-', '-MINUS').replace('++', '-PLUS').replace('-+', '-PLUS');
688
+ tmp = tmp.split(/-|\+/).sort().join('-').replace('MINUS', '-').replace('PLUS', '+').toLowerCase();
689
+ }
690
+ if (tmp === parts) {
691
+ return kb[i];
692
+ }
693
+ }
694
+ }
695
+ return null;
696
+ },
573
697
  /**
574
698
  * part of the destroying of an instance. Used internally.
575
699
  * @private
@@ -635,83 +759,16 @@
635
759
  }, this))
636
760
  .on('keydown.jstree', '.jstree-anchor', $.proxy(function (e) {
637
761
  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
762
  if(this._data.core.rtl) {
641
763
  if(e.which === 37) { e.which = 39; }
642
764
  else if(e.which === 39) { e.which = 37; }
643
765
  }
644
- switch(e.which) {
645
- case 32: // aria defines space only with Ctrl
646
- if(e.ctrlKey) {
647
- e.type = "click";
648
- $(e.currentTarget).trigger(e);
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
- */
766
+ var f = this._kbevent_to_func(e);
767
+ if (f) {
768
+ var r = f.call(this, e);
769
+ if (r === false || r === true) {
770
+ return r;
771
+ }
715
772
  }
716
773
  }, this))
717
774
  .on("load_node.jstree", $.proxy(function (e, data) {
@@ -832,7 +889,7 @@
832
889
  }, this))
833
890
  .on('blur.jstree', '.jstree-anchor', $.proxy(function (e) {
834
891
  this._data.core.focused = null;
835
- $(e.currentTarget).filter('.jstree-hovered').mouseleave();
892
+ $(e.currentTarget).filter('.jstree-hovered').trigger('mouseleave');
836
893
  this.element.attr('tabindex', '0');
837
894
  }, this))
838
895
  .on('focus.jstree', '.jstree-anchor', $.proxy(function (e) {
@@ -840,12 +897,12 @@
840
897
  if(tmp && tmp.id) {
841
898
  this._data.core.focused = tmp.id;
842
899
  }
843
- this.element.find('.jstree-hovered').not(e.currentTarget).mouseleave();
844
- $(e.currentTarget).mouseenter();
900
+ this.element.find('.jstree-hovered').not(e.currentTarget).trigger('mouseleave');
901
+ $(e.currentTarget).trigger('mouseenter');
845
902
  this.element.attr('tabindex', '-1');
846
903
  }, this))
847
904
  .on('focus.jstree', $.proxy(function () {
848
- if(+(new Date()) - was_click > 500 && !this._data.core.focused) {
905
+ if(+(new Date()) - was_click > 500 && !this._data.core.focused && this.settings.core.restore_focus) {
849
906
  was_click = 0;
850
907
  var act = this.get_node(this.element.attr('aria-activedescendant'), true);
851
908
  if(act) {
@@ -966,6 +1023,9 @@
966
1023
  if(obj && obj.id) {
967
1024
  obj = obj.id;
968
1025
  }
1026
+ if (obj instanceof $ && obj.length && obj[0].id) {
1027
+ obj = obj[0].id;
1028
+ }
969
1029
  var dom;
970
1030
  try {
971
1031
  if(this._model.data[obj]) {
@@ -977,10 +1037,10 @@
977
1037
  else if(typeof obj === "string" && (dom = $('#' + obj.replace($.jstree.idregex,'\\$&'), this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
978
1038
  obj = this._model.data[dom.closest('.jstree-node').attr('id')];
979
1039
  }
980
- else if((dom = $(obj, this.element)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
1040
+ else if((dom = this.element.find(obj)).length && this._model.data[dom.closest('.jstree-node').attr('id')]) {
981
1041
  obj = this._model.data[dom.closest('.jstree-node').attr('id')];
982
1042
  }
983
- else if((dom = $(obj, this.element)).length && dom.hasClass('jstree')) {
1043
+ else if((dom = this.element.find(obj)).length && dom.hasClass('jstree')) {
984
1044
  obj = this._model.data[$.jstree.root];
985
1045
  }
986
1046
  else {
@@ -1114,7 +1174,7 @@
1114
1174
  return obj.parent;
1115
1175
  },
1116
1176
  /**
1117
- * get a jQuery collection of all the children of a node (node must be rendered)
1177
+ * get a jQuery collection of all the children of a node (node must be rendered), returns false on error
1118
1178
  * @name get_children_dom(obj)
1119
1179
  * @param {mixed} obj
1120
1180
  * @return {jQuery}
@@ -1274,7 +1334,7 @@
1274
1334
  return true;
1275
1335
  },
1276
1336
  /**
1277
- * load an array of nodes (will also load unavailable nodes as soon as the appear in the structure). Used internally.
1337
+ * load an array of nodes (will also load unavailable nodes as soon as they appear in the structure). Used internally.
1278
1338
  * @private
1279
1339
  * @name _load_nodes(nodes [, callback])
1280
1340
  * @param {array} nodes
@@ -1453,7 +1513,7 @@
1453
1513
  */
1454
1514
  _node_changed : function (obj) {
1455
1515
  obj = this.get_node(obj);
1456
- if(obj) {
1516
+ if (obj && $.inArray(obj.id, this._model.changed) === -1) {
1457
1517
  this._model.changed.push(obj.id);
1458
1518
  }
1459
1519
  },
@@ -1545,6 +1605,7 @@
1545
1605
  't_cnt' : this._cnt,
1546
1606
  'sel' : this._data.core.selected
1547
1607
  },
1608
+ inst = this,
1548
1609
  func = function (data, undefined) {
1549
1610
  if(data.data) { data = data.data; }
1550
1611
  var dat = data.dat,
@@ -1755,10 +1816,21 @@
1755
1816
  if(!dat[i].children) {
1756
1817
  dat[i].children = [];
1757
1818
  }
1819
+ if(!dat[i].state) {
1820
+ dat[i].state = {};
1821
+ }
1758
1822
  m[dat[i].id.toString()] = dat[i];
1759
1823
  }
1760
1824
  // 2) populate children (foreach)
1761
1825
  for(i = 0, j = dat.length; i < j; i++) {
1826
+ if (!m[dat[i].parent.toString()]) {
1827
+ if (typeof inst !== "undefined") {
1828
+ 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() }) };
1829
+ inst.settings.core.error.call(inst, inst._data.core.last_error);
1830
+ }
1831
+ continue;
1832
+ }
1833
+
1762
1834
  m[dat[i].parent.toString()].children.push(dat[i].id.toString());
1763
1835
  // populate parent.children_d
1764
1836
  p.children_d.push(dat[i].id.toString());
@@ -2222,7 +2294,7 @@
2222
2294
  tmp.children_d = tmp.children_d.concat(e.children_d);
2223
2295
  }
2224
2296
  }
2225
- tmp.children_d = tmp.children_d.concat(tmp.children);
2297
+ tmp.children_d = tmp.children.concat(tmp.children_d);
2226
2298
  }
2227
2299
  if(d && d.children && d.children === true) {
2228
2300
  tmp.state.loaded = false;
@@ -2259,7 +2331,7 @@
2259
2331
  this.element.empty().append(f);
2260
2332
  //this.get_container_ul()[0].appendChild(f);
2261
2333
  }
2262
- if(fe !== null) {
2334
+ if(fe !== null && this.settings.core.restore_focus) {
2263
2335
  tmp = this.get_node(fe, true);
2264
2336
  if(tmp && tmp.length && tmp.children('.jstree-anchor')[0] !== document.activeElement) {
2265
2337
  tmp.children('.jstree-anchor').focus();
@@ -2435,6 +2507,9 @@
2435
2507
  if(obj.state.hidden) {
2436
2508
  c += ' jstree-hidden';
2437
2509
  }
2510
+ if (obj.state.loading) {
2511
+ c += ' jstree-loading';
2512
+ }
2438
2513
  if(obj.state.loaded && !has_children) {
2439
2514
  c += ' jstree-leaf';
2440
2515
  }
@@ -2539,7 +2614,7 @@
2539
2614
  return node;
2540
2615
  },
2541
2616
  /**
2542
- * opens a node, revaling its children. If the node is not loaded it will be loaded and opened once ready.
2617
+ * opens a node, revealing its children. If the node is not loaded it will be loaded and opened once ready.
2543
2618
  * @name open_node(obj [, callback, animation])
2544
2619
  * @param {mixed} obj the node to open
2545
2620
  * @param {Function} callback a function to execute once the node is opened
@@ -2743,7 +2818,7 @@
2743
2818
  }
2744
2819
  },
2745
2820
  /**
2746
- * opens all nodes within a node (or the tree), revaling their children. If the node is not loaded it will be loaded and opened once ready.
2821
+ * 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
2822
  * @name open_all([obj, animation, original_obj])
2748
2823
  * @param {mixed} obj the node to open recursively, omit to open all nodes in the tree
2749
2824
  * @param {Number} animation the animation duration in milliseconds when opening the nodes, the default is no animation
@@ -2784,7 +2859,7 @@
2784
2859
  }
2785
2860
  },
2786
2861
  /**
2787
- * closes all nodes within a node (or the tree), revaling their children
2862
+ * closes all nodes within a node (or the tree), revealing their children
2788
2863
  * @name close_all([obj, animation])
2789
2864
  * @param {mixed} obj the node to close recursively, omit to close all nodes in the tree
2790
2865
  * @param {Number} animation the animation duration in milliseconds when closing the nodes, the default is no animation
@@ -3360,6 +3435,7 @@
3360
3435
  var state = {
3361
3436
  'core' : {
3362
3437
  'open' : [],
3438
+ 'loaded' : [],
3363
3439
  'scroll' : {
3364
3440
  'left' : this.element.scrollLeft(),
3365
3441
  'top' : this.element.scrollTop()
@@ -3377,6 +3453,9 @@
3377
3453
  for(i in this._model.data) {
3378
3454
  if(this._model.data.hasOwnProperty(i)) {
3379
3455
  if(i !== $.jstree.root) {
3456
+ if(this._model.data[i].state.loaded && this.settings.core.loaded_state) {
3457
+ state.core.loaded.push(i);
3458
+ }
3380
3459
  if(this._model.data[i].state.opened) {
3381
3460
  state.core.open.push(i);
3382
3461
  }
@@ -3403,6 +3482,19 @@
3403
3482
  }
3404
3483
  if(state.core) {
3405
3484
  var res, n, t, _this, i;
3485
+ if(state.core.loaded) {
3486
+ if(!this.settings.core.loaded_state || !$.isArray(state.core.loaded) || !state.core.loaded.length) {
3487
+ delete state.core.loaded;
3488
+ this.set_state(state, callback);
3489
+ }
3490
+ else {
3491
+ this._load_nodes(state.core.loaded, function (nodes) {
3492
+ delete state.core.loaded;
3493
+ this.set_state(state, callback);
3494
+ });
3495
+ }
3496
+ return false;
3497
+ }
3406
3498
  if(state.core.open) {
3407
3499
  if(!$.isArray(state.core.open) || !state.core.open.length) {
3408
3500
  delete state.core.open;
@@ -3933,6 +4025,10 @@
3933
4025
  var tmp = chk.match(/^move_node|copy_node|create_node$/i) ? par : obj,
3934
4026
  chc = this.settings.core.check_callback;
3935
4027
  if(chk === "move_node" || chk === "copy_node") {
4028
+ if((!more || !more.is_multi) && (chk === "move_node" && $.inArray(obj.id, par.children) === pos)) {
4029
+ 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 }) };
4030
+ return false;
4031
+ }
3936
4032
  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
4033
  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
4034
  return false;
@@ -4405,7 +4501,7 @@
4405
4501
  w2 = ai.width() * ai.length,
4406
4502
  */
4407
4503
  t = default_text;
4408
- h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body");
4504
+ h1 = $("<"+"div />", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo(document.body);
4409
4505
  h2 = $("<"+"input />", {
4410
4506
  "value" : t,
4411
4507
  "class" : "jstree-rename-input",
@@ -4431,6 +4527,7 @@
4431
4527
  s.replaceWith(a);
4432
4528
  s.remove();
4433
4529
  t = f ? t : $('<div></div>').append($.parseHTML(t)).html();
4530
+ obj = this.get_node(obj);
4434
4531
  this.set_text(obj, t);
4435
4532
  nv = !!this.rename_node(obj, f ? $('<div></div>').text(v).text() : $('<div></div>').append($.parseHTML(v)).html());
4436
4533
  if(!nv) {
@@ -4705,6 +4802,7 @@
4705
4802
  obj.icon = icon === true || icon === null || icon === undefined || icon === '' ? true : icon;
4706
4803
  dom = this.get_node(obj, true).children(".jstree-anchor").children(".jstree-themeicon");
4707
4804
  if(icon === false) {
4805
+ dom.removeClass('jstree-themeicon-custom ' + old).css("background","").removeAttr("rel");
4708
4806
  this.hide_icon(obj);
4709
4807
  }
4710
4808
  else if(icon === true || icon === null || icon === undefined || icon === '') {
@@ -5077,14 +5175,15 @@
5077
5175
  if(s.indexOf('down') !== -1) {
5078
5176
  //this._data[ t ? 'core' : 'checkbox' ].selected = $.vakata.array_unique(this._data[ t ? 'core' : 'checkbox' ].selected.concat(obj.children_d));
5079
5177
  var selectedIds = this._cascade_new_checked_state(obj.id, true);
5080
- obj.children_d.concat(obj.id).forEach(function(id) {
5081
- if (selectedIds.indexOf(id) > -1) {
5082
- sel[id] = true;
5083
- }
5084
- else {
5085
- delete sel[id];
5086
- }
5087
- });
5178
+ var temp = obj.children_d.concat(obj.id);
5179
+ for (i = 0, j = temp.length; i < j; i++) {
5180
+ if (selectedIds.indexOf(temp[i]) > -1) {
5181
+ sel[temp[i]] = true;
5182
+ }
5183
+ else {
5184
+ delete sel[temp[i]];
5185
+ }
5186
+ }
5088
5187
  }
5089
5188
 
5090
5189
  // apply up
@@ -5142,7 +5241,7 @@
5142
5241
  if(s.indexOf('down') !== -1) {
5143
5242
  var selectedIds = this._cascade_new_checked_state(obj.id, false);
5144
5243
 
5145
- cur = cur.filter(function(id) {
5244
+ cur = $.vakata.array_filter(cur, function(id) {
5146
5245
  return allIds.indexOf(id) === -1 || selectedIds.indexOf(id) > -1;
5147
5246
  });
5148
5247
  }
@@ -5162,7 +5261,7 @@
5162
5261
  }
5163
5262
  }
5164
5263
 
5165
- cur = cur.filter(function(id) {
5264
+ cur = $.vakata.array_filter(cur, function(id) {
5166
5265
  return obj.parents.indexOf(id) === -1;
5167
5266
  });
5168
5267
  }
@@ -5258,16 +5357,18 @@
5258
5357
  }, this));
5259
5358
  }
5260
5359
  };
5261
-
5262
5360
  /**
5263
- * set the undetermined state where and if necessary. Used internally.
5264
- * @private
5265
- * @name _undetermined()
5361
+ * get an array of all nodes whose state is "undetermined"
5362
+ * @name get_undetermined([full])
5363
+ * @param {boolean} full: if set to `true` the returned array will consist of the full node objects, otherwise - only IDs will be returned
5364
+ * @return {Array}
5266
5365
  * @plugin checkbox
5267
5366
  */
5268
- this._undetermined = function () {
5269
- if(this.element === null) { return; }
5270
- 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;
5367
+ this.get_undetermined = function (full) {
5368
+ if (this.settings.checkbox.cascade.indexOf('undetermined') === -1) {
5369
+ return [];
5370
+ }
5371
+ 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
5372
  for(i = 0, j = s.length; i < j; i++) {
5272
5373
  if(m[s[i]] && m[s[i]].parents) {
5273
5374
  for(k = 0, l = m[s[i]].parents.length; k < l; k++) {
@@ -5320,14 +5421,28 @@
5320
5421
  }
5321
5422
  }
5322
5423
  });
5424
+ for (i = 0, j = p.length; i < j; i++) {
5425
+ if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) {
5426
+ r.push(full ? m[p[i]] : p[i]);
5427
+ }
5428
+ }
5429
+ return r;
5430
+ };
5431
+ /**
5432
+ * set the undetermined state where and if necessary. Used internally.
5433
+ * @private
5434
+ * @name _undetermined()
5435
+ * @plugin checkbox
5436
+ */
5437
+ this._undetermined = function () {
5438
+ if(this.element === null) { return; }
5439
+ var p = this.get_undetermined(false), i, j, s;
5323
5440
 
5324
5441
  this.element.find('.jstree-undetermined').removeClass('jstree-undetermined');
5325
- for(i = 0, j = p.length; i < j; i++) {
5326
- if(!m[p[i]].state[ t ? 'selected' : 'checked' ]) {
5327
- s = this.get_node(p[i], true);
5328
- if(s && s.length) {
5329
- s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
5330
- }
5442
+ for (i = 0, j = p.length; i < j; i++) {
5443
+ s = this.get_node(p[i], true);
5444
+ if(s && s.length) {
5445
+ s.children('.jstree-anchor').children('.jstree-checkbox').addClass('jstree-undetermined');
5331
5446
  }
5332
5447
  }
5333
5448
  };
@@ -5432,7 +5547,7 @@
5432
5547
  };
5433
5548
  /**
5434
5549
  * enable a node's checkbox
5435
- * @name disable_checkbox(obj)
5550
+ * @name enable_checkbox(obj)
5436
5551
  * @param {mixed} obj an array can be used too
5437
5552
  * @trigger enable_checkbox.jstree
5438
5553
  * @plugin checkbox
@@ -5490,63 +5605,65 @@
5490
5605
  };
5491
5606
 
5492
5607
  /**
5493
- * Unchecks a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
5608
+ * Cascades checked state to a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants).
5494
5609
  * However if these unaffected nodes are already selected their ids will be included in the returned array.
5495
- * @param id
5496
- * @param checkedState
5610
+ * @private
5611
+ * @param {string} id the node ID
5612
+ * @param {bool} checkedState should the nodes be checked or not
5497
5613
  * @returns {Array} Array of all node id's (in this tree branch) that are checked.
5498
5614
  */
5499
- this._cascade_new_checked_state = function(id, checkedState) {
5615
+ this._cascade_new_checked_state = function (id, checkedState) {
5500
5616
  var self = this;
5501
5617
  var t = this.settings.checkbox.tie_selection;
5502
5618
  var node = this._model.data[id];
5503
5619
  var selectedNodeIds = [];
5504
- var selectedChildrenIds = [];
5620
+ var selectedChildrenIds = [], i, j, selectedChildIds;
5505
5621
 
5506
5622
  if (
5507
5623
  (this.settings.checkbox.cascade_to_disabled || !node.state.disabled) &&
5508
5624
  (this.settings.checkbox.cascade_to_hidden || !node.state.hidden)
5509
5625
  ) {
5510
- //First try and check/uncheck the children
5511
- if (node.children) {
5512
- node.children.forEach(function(childId) {
5513
- var selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
5626
+ //First try and check/uncheck the children
5627
+ if (node.children) {
5628
+ for (i = 0, j = node.children.length; i < j; i++) {
5629
+ var childId = node.children[i];
5630
+ selectedChildIds = self._cascade_new_checked_state(childId, checkedState);
5514
5631
  selectedNodeIds = selectedNodeIds.concat(selectedChildIds);
5515
5632
  if (selectedChildIds.indexOf(childId) > -1) {
5516
5633
  selectedChildrenIds.push(childId);
5517
5634
  }
5518
- });
5635
+ }
5519
5636
  }
5520
5637
 
5521
5638
  var dom = self.get_node(node, true);
5522
5639
 
5523
- //A node's state is undetermined if some but not all of it's children are checked/selected .
5640
+ //A node's state is undetermined if some but not all of it's children are checked/selected .
5524
5641
  var undetermined = selectedChildrenIds.length > 0 && selectedChildrenIds.length < node.children.length;
5525
5642
 
5526
5643
  if(node.original && node.original.state && node.original.state.undetermined) {
5527
5644
  node.original.state.undetermined = undetermined;
5528
5645
  }
5529
5646
 
5530
- //If a node is undetermined then remove selected class
5647
+ //If a node is undetermined then remove selected class
5531
5648
  if (undetermined) {
5532
- node.state[ t ? 'selected' : 'checked' ] = false;
5533
- dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5649
+ node.state[ t ? 'selected' : 'checked' ] = false;
5650
+ dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5534
5651
  }
5535
- //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),
5536
- //check the node and style it correctly.
5652
+ //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),
5653
+ //check the node and style it correctly.
5537
5654
  else if (checkedState && selectedChildrenIds.length === node.children.length) {
5538
- node.state[ t ? 'selected' : 'checked' ] = checkedState;
5655
+ node.state[ t ? 'selected' : 'checked' ] = checkedState;
5539
5656
  selectedNodeIds.push(node.id);
5540
5657
 
5541
5658
  dom.attr('aria-selected', true).children('.jstree-anchor').addClass(t ? 'jstree-clicked' : 'jstree-checked');
5542
5659
  }
5543
5660
  else {
5544
- node.state[ t ? 'selected' : 'checked' ] = false;
5661
+ node.state[ t ? 'selected' : 'checked' ] = false;
5545
5662
  dom.attr('aria-selected', false).children('.jstree-anchor').removeClass(t ? 'jstree-clicked' : 'jstree-checked');
5546
5663
  }
5547
5664
  }
5548
5665
  else {
5549
- var selectedChildIds = this.get_checked_descendants(id);
5666
+ selectedChildIds = this.get_checked_descendants(id);
5550
5667
 
5551
5668
  if (node.state[ t ? 'selected' : 'checked' ]) {
5552
5669
  selectedChildIds.push(node.id);
@@ -5560,14 +5677,17 @@
5560
5677
 
5561
5678
  /**
5562
5679
  * Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id)
5563
- * @param id
5680
+ * @name get_checked_descendants(obj)
5681
+ * @param {string} id the node ID
5682
+ * @return {Array} array of IDs
5683
+ * @plugin checkbox
5564
5684
  */
5565
- this.get_checked_descendants = function(id) {
5685
+ this.get_checked_descendants = function (id) {
5566
5686
  var self = this;
5567
5687
  var t = self.settings.checkbox.tie_selection;
5568
5688
  var node = self._model.data[id];
5569
5689
 
5570
- return node.children_d.filter(function(_id) {
5690
+ return $.vakata.array_filter(node.children_d, function(_id) {
5571
5691
  return self._model.data[_id].state[ t ? 'selected' : 'checked' ];
5572
5692
  });
5573
5693
  };
@@ -5726,7 +5846,7 @@
5726
5846
  */
5727
5847
  this.get_checked = function (full) {
5728
5848
  if(this.settings.checkbox.tie_selection) { return this.get_selected(full); }
5729
- return full ? $.map(this._data.checkbox.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.checkbox.selected;
5849
+ return full ? $.map(this._data.checkbox.selected, $.proxy(function (i) { return this.get_node(i); }, this)) : this._data.checkbox.selected.slice();
5730
5850
  };
5731
5851
  /**
5732
5852
  * 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)
@@ -5813,7 +5933,7 @@
5813
5933
  return res;
5814
5934
  };
5815
5935
  this.refresh = function (skip_loading, forget_state) {
5816
- if(!this.settings.checkbox.tie_selection) {
5936
+ if(this.settings.checkbox.tie_selection) {
5817
5937
  this._data.checkbox.selected = [];
5818
5938
  }
5819
5939
  return parent.refresh.apply(this, arguments);
@@ -5840,7 +5960,7 @@
5840
5960
  // own function
5841
5961
  this.activate_node = function (obj, e) {
5842
5962
  if(this.settings.conditionalselect.call(this, this.get_node(obj), e)) {
5843
- parent.activate_node.call(this, obj, e);
5963
+ return parent.activate_node.call(this, obj, e);
5844
5964
  }
5845
5965
  };
5846
5966
  };
@@ -6041,8 +6161,9 @@
6041
6161
  }, 750);
6042
6162
  })
6043
6163
  .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) > 50 || Math.abs(ey - e.originalEvent.changedTouches[0].clientY) > 50)) {
6164
+ 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
6165
  clearTimeout(cto);
6166
+ $.vakata.context.hide();
6046
6167
  }
6047
6168
  })
6048
6169
  .on('touchend.vakata.jstree', function (e) {
@@ -6314,7 +6435,7 @@
6314
6435
  vakata_context.element.html(vakata_context.html);
6315
6436
  }
6316
6437
  if(vakata_context.items.length) {
6317
- vakata_context.element.appendTo("body");
6438
+ vakata_context.element.appendTo(document.body);
6318
6439
  e = vakata_context.element;
6319
6440
  x = vakata_context.position_x;
6320
6441
  y = vakata_context.position_y;
@@ -6370,7 +6491,7 @@
6370
6491
  }
6371
6492
  };
6372
6493
  $(function () {
6373
- right_to_left = $("body").css("direction") === "rtl";
6494
+ right_to_left = $(document.body).css("direction") === "rtl";
6374
6495
  var to = false;
6375
6496
 
6376
6497
  vakata_context.element = $("<ul class='vakata-context'></ul>");
@@ -6658,11 +6779,23 @@
6658
6779
  marker = $('<div id="jstree-marker">&#160;</div>').hide(); //.appendTo('body');
6659
6780
 
6660
6781
  $(document)
6782
+ .on('dragover.vakata.jstree', function (e) {
6783
+ if (elm) {
6784
+ $.vakata.dnd._trigger('move', e, { 'helper': $(), 'element': elm, 'data': drg });
6785
+ }
6786
+ })
6787
+ .on('drop.vakata.jstree', function (e) {
6788
+ if (elm) {
6789
+ $.vakata.dnd._trigger('stop', e, { 'helper': $(), 'element': elm, 'data': drg });
6790
+ elm = null;
6791
+ drg = null;
6792
+ }
6793
+ })
6661
6794
  .on('dnd_start.vakata.jstree', function (e, data) {
6662
6795
  lastmv = false;
6663
6796
  lastev = false;
6664
6797
  if(!data || !data.data || !data.data.jstree) { return; }
6665
- marker.appendTo('body'); //.show();
6798
+ marker.appendTo(document.body); //.show();
6666
6799
  })
6667
6800
  .on('dnd_move.vakata.jstree', function (e, data) {
6668
6801
  var isDifferentNode = data.event.target !== lastev.target;
@@ -6796,7 +6929,7 @@
6796
6929
  lastmv = false;
6797
6930
  data.helper.find('.jstree-icon').removeClass('jstree-ok').addClass('jstree-er');
6798
6931
  if (data.event.originalEvent && data.event.originalEvent.dataTransfer) {
6799
- data.event.originalEvent.dataTransfer.dropEffect = 'none';
6932
+ //data.event.originalEvent.dataTransfer.dropEffect = 'none';
6800
6933
  }
6801
6934
  marker.hide();
6802
6935
  })
@@ -6889,7 +7022,7 @@
6889
7022
  helper_left : 5,
6890
7023
  helper_top : 10,
6891
7024
  threshold : 5,
6892
- threshold_touch : 50
7025
+ threshold_touch : 10
6893
7026
  },
6894
7027
  _trigger : function (event_name, e, data) {
6895
7028
  if (data === undefined) {
@@ -7007,7 +7140,7 @@
7007
7140
  Math.abs(e.pageY - vakata_dnd.init_y) > (vakata_dnd.is_touch ? $.vakata.dnd.settings.threshold_touch : $.vakata.dnd.settings.threshold)
7008
7141
  ) {
7009
7142
  if(vakata_dnd.helper) {
7010
- vakata_dnd.helper.appendTo("body");
7143
+ vakata_dnd.helper.appendTo(document.body);
7011
7144
  vakata_dnd.helper_w = vakata_dnd.helper.outerWidth();
7012
7145
  }
7013
7146
  vakata_dnd.is_drag = true;
@@ -7754,7 +7887,13 @@
7754
7887
  * @name $.jstree.defaults.state.filter
7755
7888
  * @plugin state
7756
7889
  */
7757
- filter : false
7890
+ filter : false,
7891
+ /**
7892
+ * 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`
7893
+ * @name $.jstree.defaults.state.preserve_loaded
7894
+ * @plugin state
7895
+ */
7896
+ preserve_loaded : false
7758
7897
  };
7759
7898
  $.jstree.plugins.state = function (options, parent) {
7760
7899
  this.bind = function () {
@@ -7784,7 +7923,11 @@
7784
7923
  * @plugin state
7785
7924
  */
7786
7925
  this.save_state = function () {
7787
- var st = { 'state' : this.get_state(), 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) };
7926
+ var tm = this.get_state();
7927
+ if (!this.settings.state.preserve_loaded) {
7928
+ delete tm.core.loaded;
7929
+ }
7930
+ var st = { 'state' : tm, 'ttl' : this.settings.state.ttl, 'sec' : +(new Date()) };
7788
7931
  $.vakata.storage.set(this.settings.state.key, JSON.stringify(st));
7789
7932
  };
7790
7933
  /**
@@ -7799,6 +7942,9 @@
7799
7942
  if(!!k && k.state) { k = k.state; }
7800
7943
  if(!!k && $.isFunction(this.settings.state.filter)) { k = this.settings.state.filter.call(this, k); }
7801
7944
  if(!!k) {
7945
+ if (!this.settings.state.preserve_loaded) {
7946
+ delete k.core.loaded;
7947
+ }
7802
7948
  this.element.one("set_state.jstree", function (e, data) { data.instance.trigger('restore_state', { 'state' : $.extend(true, {}, k) }); });
7803
7949
  this.set_state(k);
7804
7950
  return true;
@@ -8202,6 +8348,12 @@
8202
8348
  * @plugin unique
8203
8349
  */
8204
8350
  case_sensitive : false,
8351
+ /**
8352
+ * Indicates if white space should be trimmed before the comparison. Default is `false`.
8353
+ * @name $.jstree.defaults.unique.trim_whitespace
8354
+ * @plugin unique
8355
+ */
8356
+ trim_whitespace : false,
8205
8357
  /**
8206
8358
  * A callback executed in the instance's scope when a new node is created and the name is already taken, the two arguments are the conflicting name and the counter. The default will produce results like `New node (2)`.
8207
8359
  * @name $.jstree.defaults.unique.duplicate
@@ -8221,16 +8373,32 @@
8221
8373
  var n = chk === "rename_node" ? pos : obj.text,
8222
8374
  c = [],
8223
8375
  s = this.settings.unique.case_sensitive,
8224
- m = this._model.data, i, j;
8376
+ w = this.settings.unique.trim_whitespace,
8377
+ m = this._model.data, i, j, t;
8225
8378
  for(i = 0, j = par.children.length; i < j; i++) {
8226
- c.push(s ? m[par.children[i]].text : m[par.children[i]].text.toLowerCase());
8379
+ t = m[par.children[i]].text;
8380
+ if (!s) {
8381
+ t = t.toLowerCase();
8382
+ }
8383
+ if (w) {
8384
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8385
+ }
8386
+ c.push(t);
8227
8387
  }
8228
8388
  if(!s) { n = n.toLowerCase(); }
8389
+ if (w) { n = n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); }
8229
8390
  switch(chk) {
8230
8391
  case "delete_node":
8231
8392
  return true;
8232
8393
  case "rename_node":
8233
- i = ($.inArray(n, c) === -1 || (obj.text && obj.text[ s ? 'toString' : 'toLowerCase']() === n));
8394
+ t = obj.text || '';
8395
+ if (!s) {
8396
+ t = t.toLowerCase();
8397
+ }
8398
+ if (w) {
8399
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8400
+ }
8401
+ i = ($.inArray(n, c) === -1 || (obj.text && t === n));
8234
8402
  if(!i) {
8235
8403
  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 }) };
8236
8404
  }
@@ -8270,15 +8438,36 @@
8270
8438
  return parent.create_node.call(this, par, node, pos, callback, is_loaded);
8271
8439
  }
8272
8440
  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;
8441
+ 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
8442
  n = tmp = this.get_string('New node');
8275
8443
  dpc = [];
8276
8444
  for(i = 0, j = par.children.length; i < j; i++) {
8277
- dpc.push(s ? m[par.children[i]].text : m[par.children[i]].text.toLowerCase());
8445
+ t = m[par.children[i]].text;
8446
+ if (!s) {
8447
+ t = t.toLowerCase();
8448
+ }
8449
+ if (w) {
8450
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8451
+ }
8452
+ dpc.push(t);
8278
8453
  }
8279
8454
  i = 1;
8280
- while($.inArray(s ? n : n.toLowerCase(), dpc) !== -1) {
8455
+ t = n;
8456
+ if (!s) {
8457
+ t = t.toLowerCase();
8458
+ }
8459
+ if (w) {
8460
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8461
+ }
8462
+ while($.inArray(t, dpc) !== -1) {
8281
8463
  n = cb.call(this, tmp, (++i)).toString();
8464
+ t = n;
8465
+ if (!s) {
8466
+ t = t.toLowerCase();
8467
+ }
8468
+ if (w) {
8469
+ t = t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
8470
+ }
8282
8471
  }
8283
8472
  node.text = n;
8284
8473
  }
@@ -8395,7 +8584,7 @@
8395
8584
  };
8396
8585
  // include the wholerow plugin by default
8397
8586
  // $.jstree.defaults.plugins.push("wholerow");
8398
- if(document.registerElement && Object && Object.create) {
8587
+ if(window.customElements && Object && Object.create) {
8399
8588
  var proto = Object.create(HTMLElement.prototype);
8400
8589
  proto.createdCallback = function () {
8401
8590
  var c = { core : {}, plugins : [] }, i;
@@ -8416,8 +8605,8 @@
8416
8605
  };
8417
8606
  // proto.attributeChangedCallback = function (name, previous, value) { };
8418
8607
  try {
8419
- document.registerElement("vakata-jstree", { prototype: proto });
8420
- } catch(ignore) { }
8608
+ window.customElements.define("vakata-jstree", function() {}, { prototype: proto });
8609
+ } catch (ignore) { }
8421
8610
  }
8422
8611
 
8423
8612
  }));