jqtree 1.6.2 → 1.7.0

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.
Files changed (276) hide show
  1. package/.eslintrc +3 -12
  2. package/.github/workflows/ci.yml +57 -30
  3. package/.github/workflows/codeql-analysis.yml +9 -5
  4. package/.prettier +3 -0
  5. package/.tool-versions +1 -0
  6. package/README.md +12 -9
  7. package/bower.json +10 -3
  8. package/{.postcssrc → config/.postcssrc} +0 -0
  9. package/{babel.config.json → config/babel.config.json} +0 -0
  10. package/{babel.coverage.config.json → config/babel.coverage.config.json} +0 -0
  11. package/{jest-jsdom.config.js → config/jest.config.js} +8 -3
  12. package/config/playwright.config.js +18 -0
  13. package/config/production +4 -0
  14. package/{rollup.config.js → config/rollup.config.mjs} +3 -8
  15. package/{jqtree.postcss → css/jqtree.postcss} +0 -0
  16. package/devserver/index.html +1 -9
  17. package/docs/Gemfile +2 -0
  18. package/docs/Gemfile.lock +263 -0
  19. package/{_config.yml → docs/_config.yml} +8 -1
  20. package/{_entries → docs/_entries}/01_general.md +0 -0
  21. package/{_entries → docs/_entries}/02_introduction.md +0 -0
  22. package/{_entries → docs/_entries}/03_features.md +1 -1
  23. package/{_entries → docs/_entries}/04_demo.html +1 -7
  24. package/{_entries → docs/_entries}/05_requirements.md +0 -0
  25. package/{_entries → docs/_entries}/06_downloads.md +0 -0
  26. package/{_entries → docs/_entries}/07_tutorial.md +0 -0
  27. package/{_entries → docs/_entries}/08_examples.md +0 -0
  28. package/{_entries → docs/_entries}/09_usecases.md +0 -0
  29. package/{_entries → docs/_entries}/10_changelog.md +13 -0
  30. package/{_entries → docs/_entries}/11_options.md +0 -0
  31. package/{_entries → docs/_entries}/12_animationspeed.md +0 -0
  32. package/{_entries → docs/_entries}/13_autoescape.md +0 -0
  33. package/{_entries → docs/_entries}/14_autoopen.md +0 -0
  34. package/{_entries → docs/_entries}/15_buttonleft.md +0 -0
  35. package/{_entries → docs/_entries}/16_closedicon.md +0 -0
  36. package/{_entries → docs/_entries}/17_data.md +0 -0
  37. package/{_entries → docs/_entries}/18_datafilter.md +0 -0
  38. package/{_entries → docs/_entries}/19_data-url.md +0 -0
  39. package/{_entries → docs/_entries}/20_draganddrop.md +0 -0
  40. package/{_entries → docs/_entries}/21_keyboardsupport.md +0 -0
  41. package/{_entries → docs/_entries}/22_oncanmove.md +0 -0
  42. package/{_entries → docs/_entries}/23_oncanmoveto.md +2 -2
  43. package/{_entries → docs/_entries}/24_oncanselectnode.md +0 -0
  44. package/{_entries → docs/_entries}/25_oncreateli.md +2 -2
  45. package/{_entries → docs/_entries}/26_ondragmove.md +0 -0
  46. package/{_entries → docs/_entries}/27_ondragstop.md +0 -0
  47. package/{_entries → docs/_entries}/28_onismovehandle.md +0 -0
  48. package/{_entries → docs/_entries}/29_onloadfailed.md +0 -0
  49. package/{_entries → docs/_entries}/30_onloading.md +2 -2
  50. package/{_entries → docs/_entries}/31_openedicon.md +0 -0
  51. package/{_entries → docs/_entries}/32_openfolderdelay.md +2 -0
  52. package/{_entries → docs/_entries}/33_rtl.md +0 -0
  53. package/{_entries → docs/_entries}/34_savestate.md +0 -0
  54. package/{_entries → docs/_entries}/35_selectable.md +0 -0
  55. package/{_entries → docs/_entries}/36_showemptyfolder.md +0 -0
  56. package/{_entries → docs/_entries}/37_slide.md +0 -0
  57. package/{_entries → docs/_entries}/38_start_dnd_delay.md +0 -0
  58. package/{_entries → docs/_entries}/39_tabindex.md +0 -0
  59. package/{_entries → docs/_entries}/40_usecontextmenu.md +0 -0
  60. package/{_entries → docs/_entries}/41_functions.md +0 -0
  61. package/{_entries → docs/_entries}/42_addparentnode.md +1 -1
  62. package/{_entries → docs/_entries}/43_addnodeafter.md +1 -1
  63. package/{_entries → docs/_entries}/44_addnodebefore.md +1 -1
  64. package/{_entries → docs/_entries}/45_appendnode.md +5 -5
  65. package/{_entries → docs/_entries}/46_closenode.md +0 -0
  66. package/{_entries → docs/_entries}/47_destroy.md +0 -0
  67. package/{_entries → docs/_entries}/48_getnodebycallback.md +0 -0
  68. package/{_entries → docs/_entries}/49_getnodebyid.md +0 -0
  69. package/{_entries → docs/_entries}/50_getnodebyhtmlelement.md +2 -2
  70. package/{_entries → docs/_entries}/51_getselectednode.md +0 -0
  71. package/{_entries → docs/_entries}/52_getstate.md +0 -0
  72. package/{_entries → docs/_entries}/53_gettree.md +1 -1
  73. package/{_entries → docs/_entries}/54_isdragging.md +1 -1
  74. package/{_entries → docs/_entries}/55_loaddata.md +3 -3
  75. package/{_entries → docs/_entries}/56_loaddatafromurl.md +4 -4
  76. package/{_entries → docs/_entries}/57_movedown.md +0 -0
  77. package/{_entries → docs/_entries}/58_movenode.md +3 -3
  78. package/{_entries → docs/_entries}/59_moveup.md +0 -0
  79. package/{_entries → docs/_entries}/60_opennode.md +3 -3
  80. package/docs/_entries/61_prependnode.md +21 -0
  81. package/{_entries → docs/_entries}/62_refresh.md +0 -0
  82. package/{_entries → docs/_entries}/63_reload.md +2 -2
  83. package/{_entries → docs/_entries}/64_removenode.md +0 -0
  84. package/{_entries → docs/_entries}/65_selectnode.md +0 -0
  85. package/{_entries → docs/_entries}/66_scrolltonode.md +0 -0
  86. package/{_entries → docs/_entries}/67_setoption.md +0 -0
  87. package/{_entries → docs/_entries}/68_setstate.md +0 -0
  88. package/{_entries → docs/_entries}/69_toggle.md +0 -0
  89. package/{_entries → docs/_entries}/70_tojson.md +0 -0
  90. package/{_entries → docs/_entries}/71_updatenode.md +1 -1
  91. package/{_entries → docs/_entries}/72_events.md +0 -0
  92. package/{_entries → docs/_entries}/73_tree-click.md +0 -0
  93. package/{_entries → docs/_entries}/74_tree-close.md +0 -0
  94. package/{_entries → docs/_entries}/75_tree-contextmenu.md +0 -0
  95. package/{_entries → docs/_entries}/76_tree-dblclick.md +0 -0
  96. package/{_entries → docs/_entries}/77_tree-init.md +0 -0
  97. package/{_entries → docs/_entries}/78_tree-load-data.md +0 -0
  98. package/{_entries → docs/_entries}/79_tree-loading-data.md +0 -0
  99. package/{_entries → docs/_entries}/80_tree-move.md +0 -0
  100. package/{_entries → docs/_entries}/81_tree-refresh.md +0 -0
  101. package/{_entries → docs/_entries}/82_tree-open.md +0 -0
  102. package/{_entries → docs/_entries}/83_tree-select.md +0 -0
  103. package/{_entries → docs/_entries}/84_multiple-selection.md +0 -0
  104. package/{_entries → docs/_entries}/85_add-to-selection.md +0 -0
  105. package/{_entries → docs/_entries}/86_get-selected-nodes.md +0 -0
  106. package/{_entries → docs/_entries}/87_is-node-selected.md +1 -1
  107. package/{_entries → docs/_entries}/88_remove-from-selection.md +0 -0
  108. package/{_entries → docs/_entries}/89_node-functions.md +0 -0
  109. package/{_entries → docs/_entries}/90_children.md +0 -0
  110. package/{_entries → docs/_entries}/91_getdata.md +2 -2
  111. package/{_entries → docs/_entries}/92_getlevel.md +0 -0
  112. package/docs/_entries/93_getnextnode.md +15 -0
  113. package/{_entries → docs/_entries}/94_getnextsibling.md +0 -0
  114. package/{_entries/95_getpreviousnode.md → docs/_entries/95_getnextvisiblenode.md} +1 -1
  115. package/docs/_entries/96_getpreviousnode.md +0 -0
  116. package/{_entries/96_getprevioussibling.md → docs/_entries/97_getprevioussibling.md} +0 -0
  117. package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
  118. package/{_entries/97_parent.md → docs/_entries/99_parent.md} +1 -1
  119. package/{_entries → docs/_entries}/insert.py +0 -0
  120. package/{_entries → docs/_entries}/renumber.py +0 -0
  121. package/{_examples → docs/_examples}/01_load_json_data.html +3 -5
  122. package/{_examples → docs/_examples}/02_load_json_data_from_server.html +3 -5
  123. package/{_examples → docs/_examples}/03_drag_and_drop.html +3 -5
  124. package/{_examples → docs/_examples}/04_save_state.html +3 -5
  125. package/{_examples → docs/_examples}/05_load_on_demand.html +3 -5
  126. package/{_examples → docs/_examples}/06_autoescape.html +3 -5
  127. package/{_examples → docs/_examples}/07_autoscroll.html +3 -5
  128. package/{_examples → docs/_examples}/08_multiple_select.html +3 -5
  129. package/{_examples → docs/_examples}/09_custom_html.html +3 -5
  130. package/{_examples → docs/_examples}/10_icon_buttons.html +3 -5
  131. package/{_examples → docs/_examples}/11_right-to-left.html +3 -5
  132. package/{_examples → docs/_examples}/12_button_on_right.html +3 -5
  133. package/docs/_examples/13_drag_outside.html +48 -0
  134. package/{_examples → docs/_examples}/14_filter.html +7 -9
  135. package/docs/_layouts/example.html +7 -0
  136. package/{_layouts/base.html → docs/_layouts/page.html} +4 -11
  137. package/docs/documentation.css +3 -0
  138. package/docs/index.html +65 -0
  139. package/docs/jqtree.css +189 -0
  140. package/docs/package.json +22 -0
  141. package/docs/pnpm-lock.yaml +798 -0
  142. package/docs/postcss.config.js +7 -0
  143. package/{static → docs/static}/bower.json +1 -2
  144. package/{static → docs/static}/bower_components/fontawesome/css/all.min.css +0 -0
  145. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.eot +0 -0
  146. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.svg +0 -0
  147. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.ttf +0 -0
  148. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.woff +0 -0
  149. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  150. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.eot +0 -0
  151. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.svg +0 -0
  152. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.ttf +0 -0
  153. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.woff +0 -0
  154. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  155. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.eot +0 -0
  156. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.svg +0 -0
  157. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.ttf +0 -0
  158. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.woff +0 -0
  159. package/{static → docs/static}/bower_components/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  160. package/{static → docs/static}/bower_components/jquery/dist/jquery.js +209 -97
  161. package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -0
  162. package/{static → docs/static}/bower_components/jquery-mockjax/dist/jquery.mockjax.js +0 -0
  163. package/docs/static/documentation.css +1453 -0
  164. package/docs/static/documentation.js +26 -0
  165. package/{static → docs/static}/example.css +5 -38
  166. package/{static → docs/static}/example.postcss +5 -35
  167. package/{static → docs/static}/example_data.js +0 -0
  168. package/{static → docs/static}/examples/autoescape.js +0 -0
  169. package/{static → docs/static}/examples/autoscroll.js +0 -0
  170. package/{static → docs/static}/examples/button-on-right.js +0 -0
  171. package/{static → docs/static}/examples/custom_html.js +5 -9
  172. package/{static → docs/static}/examples/drag-outside.js +0 -0
  173. package/{static → docs/static}/examples/drag_and_drop.js +0 -0
  174. package/{static → docs/static}/examples/filter.js +2 -2
  175. package/{static → docs/static}/examples/icon_buttons.js +0 -0
  176. package/{static → docs/static}/examples/load_json_data.js +0 -0
  177. package/{static → docs/static}/examples/load_json_data_from_server.js +0 -0
  178. package/{static → docs/static}/examples/load_on_demand.js +0 -0
  179. package/{static → docs/static}/examples/multiple_select.js +0 -0
  180. package/{static → docs/static}/examples/right-to-left.js +0 -0
  181. package/{static → docs/static}/examples/save_state.js +0 -0
  182. package/{static → docs/static}/monokai.css +0 -0
  183. package/{static → docs/static}/spinner.gif +0 -0
  184. package/docs/tailwind.config.js +16 -0
  185. package/docs/tree.jquery.js +21 -0
  186. package/lib/dataLoader.js +5 -31
  187. package/lib/dragAndDropHandler.js +26 -135
  188. package/lib/elementsRenderer.js +29 -59
  189. package/lib/keyHandler.js +8 -32
  190. package/lib/mouse.widget.js +16 -77
  191. package/lib/node.js +60 -125
  192. package/lib/nodeElement.js +8 -75
  193. package/lib/playwright/coverage.js +101 -0
  194. package/lib/playwright/playwright.test.js +212 -182
  195. package/lib/playwright/testUtils.js +201 -0
  196. package/lib/saveStateHandler.js +12 -61
  197. package/lib/scrollHandler.js +17 -74
  198. package/lib/selectNodeHandler.js +5 -24
  199. package/lib/simple.widget.js +18 -53
  200. package/lib/test/jqTree/create.test.js +0 -4
  201. package/lib/test/jqTree/events.test.js +10 -16
  202. package/lib/test/jqTree/keyboard.test.js +0 -6
  203. package/lib/test/jqTree/loadOnDemand.test.js +107 -139
  204. package/lib/test/jqTree/methods.test.js +136 -159
  205. package/lib/test/jqTree/options.test.js +53 -63
  206. package/lib/test/node.test.js +127 -72
  207. package/lib/test/nodeUtil.test.js +0 -1
  208. package/lib/test/support/jqTreeMatchers.js +4 -9
  209. package/lib/test/support/setupTests.js +0 -4
  210. package/lib/test/support/testUtil.js +2 -11
  211. package/lib/test/support/treeStructure.js +0 -6
  212. package/lib/test/util.test.js +0 -1
  213. package/lib/tree.jquery.js +32 -243
  214. package/lib/util.js +0 -6
  215. package/lib/version.js +1 -1
  216. package/package.json +54 -54
  217. package/src/dragAndDropHandler.ts +8 -4
  218. package/src/jqtreeOptions.ts +1 -1
  219. package/src/keyHandler.ts +3 -3
  220. package/src/node.ts +43 -12
  221. package/src/playwright/.eslintrc +2 -2
  222. package/src/playwright/coverage.ts +41 -0
  223. package/src/playwright/playwright.test.ts +50 -52
  224. package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-darwin.png +0 -0
  225. package/src/playwright/playwright.test.ts-snapshots/with-dragAndDrop-moves-a-node-1-Chromium-linux.png +0 -0
  226. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-darwin.png +0 -0
  227. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-displays-a-tree-1-Chromium-linux.png +0 -0
  228. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-darwin.png +0 -0
  229. package/src/playwright/playwright.test.ts-snapshots/without-dragAndDrop-selects-a-node-1-Chromium-linux.png +0 -0
  230. package/src/playwright/testUtils.ts +122 -0
  231. package/src/test/.eslintrc +15 -3
  232. package/src/test/jqTree/events.test.ts +10 -9
  233. package/src/test/jqTree/loadOnDemand.test.ts +10 -10
  234. package/src/test/jqTree/methods.test.ts +37 -45
  235. package/src/test/jqTree/options.test.ts +26 -28
  236. package/src/test/node.test.ts +146 -54
  237. package/src/tree.jquery.d.ts +1 -1
  238. package/src/tree.jquery.ts +6 -5
  239. package/src/version.ts +1 -1
  240. package/tree.jquery.debug.js +217 -867
  241. package/tree.jquery.debug.js.map +1 -1
  242. package/tree.jquery.js +3 -3
  243. package/tree.jquery.js.map +1 -1
  244. package/_entries/61_prependnode.md +0 -21
  245. package/_entries/93_getnextnode.md +0 -12
  246. package/_examples/13_drag_outside.html +0 -26
  247. package/_layouts/frontpage.html +0 -20
  248. package/_layouts/page.html +0 -7
  249. package/index.html +0 -48
  250. package/jest-browser.config.js +0 -15
  251. package/jest-playwright.config.js +0 -21
  252. package/jest.config.js +0 -8
  253. package/lib/playwright/testUtil.js +0 -459
  254. package/lib/playwright/visualRegression.js +0 -193
  255. package/production +0 -5
  256. package/src/playwright/screenshots/displays_a_tree_Desktop.png +0 -0
  257. package/src/playwright/screenshots/displays_a_tree_iPhone 6.png +0 -0
  258. package/src/playwright/screenshots/moves_a_node_Desktop.png +0 -0
  259. package/src/playwright/screenshots/moves_a_node_iPhone 6.png +0 -0
  260. package/src/playwright/screenshots/opens_a_node_Desktop.png +0 -0
  261. package/src/playwright/screenshots/opens_a_node_iPhone 6.png +0 -0
  262. package/src/playwright/screenshots/selects_a_node_Desktop.png +0 -0
  263. package/src/playwright/screenshots/selects_a_node_iPhone 6.png +0 -0
  264. package/src/playwright/testUtil.ts +0 -170
  265. package/src/playwright/visualRegression.ts +0 -88
  266. package/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css +0 -6
  267. package/static/bower_components/bootstrap/dist/css/bootstrap.min.css +0 -6
  268. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot +0 -0
  269. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg +0 -288
  270. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf +0 -0
  271. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff +0 -0
  272. package/static/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 +0 -0
  273. package/static/bower_components/bootstrap/dist/js/bootstrap.min.js +0 -6
  274. package/static/bower_components/jquery/dist/jquery.min.js +0 -2
  275. package/static/documentation.css +0 -171
  276. package/static/documentation.js +0 -48
@@ -1,7 +1,7 @@
1
1
  /*
2
- JqTree 1.6.2
2
+ JqTree 1.7.0
3
3
 
4
- Copyright 2021 Marco Braak
4
+ Copyright 2022 Marco Braak
5
5
 
6
6
  Licensed under the Apache License, Version 2.0 (the "License");
7
7
  you may not use this file except in compliance with the License.
@@ -20,19 +20,43 @@ limitations under the License.
20
20
  var jqtree = (function (exports) {
21
21
  'use strict';
22
22
 
23
+ function _iterableToArrayLimit(arr, i) {
24
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
25
+ if (null != _i) {
26
+ var _s,
27
+ _e,
28
+ _x,
29
+ _r,
30
+ _arr = [],
31
+ _n = !0,
32
+ _d = !1;
33
+ try {
34
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
35
+ if (Object(_i) !== _i) return;
36
+ _n = !1;
37
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
38
+ } catch (err) {
39
+ _d = !0, _e = err;
40
+ } finally {
41
+ try {
42
+ if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
43
+ } finally {
44
+ if (_d) throw _e;
45
+ }
46
+ }
47
+ return _arr;
48
+ }
49
+ }
23
50
  function ownKeys(object, enumerableOnly) {
24
51
  var keys = Object.keys(object);
25
-
26
52
  if (Object.getOwnPropertySymbols) {
27
53
  var symbols = Object.getOwnPropertySymbols(object);
28
54
  enumerableOnly && (symbols = symbols.filter(function (sym) {
29
55
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
30
56
  })), keys.push.apply(keys, symbols);
31
57
  }
32
-
33
58
  return keys;
34
59
  }
35
-
36
60
  function _objectSpread2(target) {
37
61
  for (var i = 1; i < arguments.length; i++) {
38
62
  var source = null != arguments[i] ? arguments[i] : {};
@@ -42,10 +66,8 @@ var jqtree = (function (exports) {
42
66
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
43
67
  });
44
68
  }
45
-
46
69
  return target;
47
70
  }
48
-
49
71
  function _typeof(obj) {
50
72
  "@babel/helpers - typeof";
51
73
 
@@ -55,23 +77,20 @@ var jqtree = (function (exports) {
55
77
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
56
78
  }, _typeof(obj);
57
79
  }
58
-
59
80
  function _classCallCheck(instance, Constructor) {
60
81
  if (!(instance instanceof Constructor)) {
61
82
  throw new TypeError("Cannot call a class as a function");
62
83
  }
63
84
  }
64
-
65
85
  function _defineProperties(target, props) {
66
86
  for (var i = 0; i < props.length; i++) {
67
87
  var descriptor = props[i];
68
88
  descriptor.enumerable = descriptor.enumerable || false;
69
89
  descriptor.configurable = true;
70
90
  if ("value" in descriptor) descriptor.writable = true;
71
- Object.defineProperty(target, descriptor.key, descriptor);
91
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
72
92
  }
73
93
  }
74
-
75
94
  function _createClass(Constructor, protoProps, staticProps) {
76
95
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
77
96
  if (staticProps) _defineProperties(Constructor, staticProps);
@@ -80,8 +99,8 @@ var jqtree = (function (exports) {
80
99
  });
81
100
  return Constructor;
82
101
  }
83
-
84
102
  function _defineProperty(obj, key, value) {
103
+ key = _toPropertyKey(key);
85
104
  if (key in obj) {
86
105
  Object.defineProperty(obj, key, {
87
106
  value: value,
@@ -92,49 +111,41 @@ var jqtree = (function (exports) {
92
111
  } else {
93
112
  obj[key] = value;
94
113
  }
95
-
96
114
  return obj;
97
115
  }
98
-
99
116
  function _inherits(subClass, superClass) {
100
117
  if (typeof superClass !== "function" && superClass !== null) {
101
118
  throw new TypeError("Super expression must either be null or a function");
102
119
  }
103
-
120
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
121
+ constructor: {
122
+ value: subClass,
123
+ writable: true,
124
+ configurable: true
125
+ }
126
+ });
104
127
  Object.defineProperty(subClass, "prototype", {
105
- value: Object.create(superClass && superClass.prototype, {
106
- constructor: {
107
- value: subClass,
108
- writable: true,
109
- configurable: true
110
- }
111
- }),
112
128
  writable: false
113
129
  });
114
130
  if (superClass) _setPrototypeOf(subClass, superClass);
115
131
  }
116
-
117
132
  function _getPrototypeOf(o) {
118
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
133
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
119
134
  return o.__proto__ || Object.getPrototypeOf(o);
120
135
  };
121
136
  return _getPrototypeOf(o);
122
137
  }
123
-
124
138
  function _setPrototypeOf(o, p) {
125
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
139
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
126
140
  o.__proto__ = p;
127
141
  return o;
128
142
  };
129
-
130
143
  return _setPrototypeOf(o, p);
131
144
  }
132
-
133
145
  function _isNativeReflectConstruct() {
134
146
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
135
147
  if (Reflect.construct.sham) return false;
136
148
  if (typeof Proxy === "function") return true;
137
-
138
149
  try {
139
150
  Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
140
151
  return true;
@@ -142,112 +153,63 @@ var jqtree = (function (exports) {
142
153
  return false;
143
154
  }
144
155
  }
145
-
146
156
  function _assertThisInitialized(self) {
147
157
  if (self === void 0) {
148
158
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
149
159
  }
150
-
151
160
  return self;
152
161
  }
153
-
154
162
  function _possibleConstructorReturn(self, call) {
155
163
  if (call && (typeof call === "object" || typeof call === "function")) {
156
164
  return call;
157
165
  } else if (call !== void 0) {
158
166
  throw new TypeError("Derived constructors may only return object or undefined");
159
167
  }
160
-
161
168
  return _assertThisInitialized(self);
162
169
  }
163
-
164
170
  function _createSuper(Derived) {
165
171
  var hasNativeReflectConstruct = _isNativeReflectConstruct();
166
-
167
172
  return function _createSuperInternal() {
168
173
  var Super = _getPrototypeOf(Derived),
169
- result;
170
-
174
+ result;
171
175
  if (hasNativeReflectConstruct) {
172
176
  var NewTarget = _getPrototypeOf(this).constructor;
173
-
174
177
  result = Reflect.construct(Super, arguments, NewTarget);
175
178
  } else {
176
179
  result = Super.apply(this, arguments);
177
180
  }
178
-
179
181
  return _possibleConstructorReturn(this, result);
180
182
  };
181
183
  }
182
-
183
184
  function _superPropBase(object, property) {
184
185
  while (!Object.prototype.hasOwnProperty.call(object, property)) {
185
186
  object = _getPrototypeOf(object);
186
187
  if (object === null) break;
187
188
  }
188
-
189
189
  return object;
190
190
  }
191
-
192
191
  function _get() {
193
192
  if (typeof Reflect !== "undefined" && Reflect.get) {
194
- _get = Reflect.get;
193
+ _get = Reflect.get.bind();
195
194
  } else {
196
195
  _get = function _get(target, property, receiver) {
197
196
  var base = _superPropBase(target, property);
198
-
199
197
  if (!base) return;
200
198
  var desc = Object.getOwnPropertyDescriptor(base, property);
201
-
202
199
  if (desc.get) {
203
200
  return desc.get.call(arguments.length < 3 ? target : receiver);
204
201
  }
205
-
206
202
  return desc.value;
207
203
  };
208
204
  }
209
-
210
205
  return _get.apply(this, arguments);
211
206
  }
212
-
213
207
  function _slicedToArray(arr, i) {
214
208
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
215
209
  }
216
-
217
210
  function _arrayWithHoles(arr) {
218
211
  if (Array.isArray(arr)) return arr;
219
212
  }
220
-
221
- function _iterableToArrayLimit(arr, i) {
222
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
223
-
224
- if (_i == null) return;
225
- var _arr = [];
226
- var _n = true;
227
- var _d = false;
228
-
229
- var _s, _e;
230
-
231
- try {
232
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
233
- _arr.push(_s.value);
234
-
235
- if (i && _arr.length === i) break;
236
- }
237
- } catch (err) {
238
- _d = true;
239
- _e = err;
240
- } finally {
241
- try {
242
- if (!_n && _i["return"] != null) _i["return"]();
243
- } finally {
244
- if (_d) throw _e;
245
- }
246
- }
247
-
248
- return _arr;
249
- }
250
-
251
213
  function _unsupportedIterableToArray(o, minLen) {
252
214
  if (!o) return;
253
215
  if (typeof o === "string") return _arrayLikeToArray(o, minLen);
@@ -256,29 +218,21 @@ var jqtree = (function (exports) {
256
218
  if (n === "Map" || n === "Set") return Array.from(o);
257
219
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
258
220
  }
259
-
260
221
  function _arrayLikeToArray(arr, len) {
261
222
  if (len == null || len > arr.length) len = arr.length;
262
-
263
223
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
264
-
265
224
  return arr2;
266
225
  }
267
-
268
226
  function _nonIterableRest() {
269
227
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
270
228
  }
271
-
272
229
  function _createForOfIteratorHelper(o, allowArrayLike) {
273
230
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
274
-
275
231
  if (!it) {
276
232
  if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
277
233
  if (it) o = it;
278
234
  var i = 0;
279
-
280
235
  var F = function () {};
281
-
282
236
  return {
283
237
  s: F,
284
238
  n: function () {
@@ -296,13 +250,11 @@ var jqtree = (function (exports) {
296
250
  f: F
297
251
  };
298
252
  }
299
-
300
253
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
301
254
  }
302
-
303
255
  var normalCompletion = true,
304
- didErr = false,
305
- err;
256
+ didErr = false,
257
+ err;
306
258
  return {
307
259
  s: function () {
308
260
  it = it.call(o);
@@ -325,18 +277,30 @@ var jqtree = (function (exports) {
325
277
  }
326
278
  };
327
279
  }
280
+ function _toPrimitive(input, hint) {
281
+ if (typeof input !== "object" || input === null) return input;
282
+ var prim = input[Symbol.toPrimitive];
283
+ if (prim !== undefined) {
284
+ var res = prim.call(input, hint || "default");
285
+ if (typeof res !== "object") return res;
286
+ throw new TypeError("@@toPrimitive must return a primitive value.");
287
+ }
288
+ return (hint === "string" ? String : Number)(input);
289
+ }
290
+ function _toPropertyKey(arg) {
291
+ var key = _toPrimitive(arg, "string");
292
+ return typeof key === "symbol" ? key : String(key);
293
+ }
328
294
 
329
- var version = "1.6.2";
295
+ var version = "1.7.0";
330
296
 
331
297
  var Position;
332
-
333
298
  (function (Position) {
334
299
  Position[Position["Before"] = 1] = "Before";
335
300
  Position[Position["After"] = 2] = "After";
336
301
  Position[Position["Inside"] = 3] = "Inside";
337
302
  Position[Position["None"] = 4] = "None";
338
303
  })(Position || (Position = {}));
339
-
340
304
  var positionNames = {
341
305
  before: Position.Before,
342
306
  after: Position.After,
@@ -351,62 +315,45 @@ var jqtree = (function (exports) {
351
315
  }
352
316
  }
353
317
  }
354
-
355
318
  return "";
356
319
  };
357
320
  var getPosition = function getPosition(name) {
358
321
  return positionNames[name];
359
322
  };
360
-
361
323
  var isNodeRecordWithChildren = function isNodeRecordWithChildren(data) {
362
324
  return _typeof(data) === "object" && "children" in data && data["children"] instanceof Array;
363
325
  };
364
-
365
326
  var Node = /*#__PURE__*/function () {
366
327
  function Node() {
367
328
  var o = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
368
329
  var isRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
369
330
  var nodeClass = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Node;
370
-
371
331
  _classCallCheck(this, Node);
372
-
373
332
  _defineProperty(this, "id", void 0);
374
-
375
333
  _defineProperty(this, "name", void 0);
376
-
377
334
  _defineProperty(this, "children", void 0);
378
-
379
335
  _defineProperty(this, "parent", void 0);
380
-
381
336
  _defineProperty(this, "idMapping", void 0);
382
-
383
337
  _defineProperty(this, "tree", void 0);
384
-
385
338
  _defineProperty(this, "nodeClass", void 0);
386
-
387
339
  _defineProperty(this, "load_on_demand", void 0);
388
-
389
340
  _defineProperty(this, "is_open", void 0);
390
-
391
341
  _defineProperty(this, "element", void 0);
392
-
393
342
  _defineProperty(this, "is_loading", void 0);
394
-
395
343
  _defineProperty(this, "isEmptyFolder", void 0);
396
-
397
344
  this.name = "";
398
345
  this.isEmptyFolder = false;
399
346
  this.load_on_demand = false;
400
347
  this.setData(o);
401
348
  this.children = [];
402
349
  this.parent = null;
403
-
404
350
  if (isRoot) {
405
351
  this.idMapping = new Map();
406
352
  this.tree = this;
407
353
  this.nodeClass = nodeClass;
408
354
  }
409
355
  }
356
+
410
357
  /*
411
358
  Set the data of this node.
412
359
  setData(string): set the name of the node
@@ -418,8 +365,6 @@ var jqtree = (function (exports) {
418
365
  * This is an internal function; it is not in the docs
419
366
  * Does not remove existing node values
420
367
  */
421
-
422
-
423
368
  _createClass(Node, [{
424
369
  key: "setData",
425
370
  value: function setData(o) {
@@ -431,7 +376,6 @@ var jqtree = (function (exports) {
431
376
  for (var _key in o) {
432
377
  if (Object.prototype.hasOwnProperty.call(o, _key)) {
433
378
  var value = o[_key];
434
-
435
379
  if (_key === "label" || _key === "name") {
436
380
  // You can use the 'label' key instead of 'name'; this is a legacy feature
437
381
  if (typeof value === "string") {
@@ -445,6 +389,7 @@ var jqtree = (function (exports) {
445
389
  }
446
390
  }
447
391
  }
392
+
448
393
  /*
449
394
  Create tree from data.
450
395
  Structure of data is:
@@ -461,23 +406,17 @@ var jqtree = (function (exports) {
461
406
  }
462
407
  ]
463
408
  */
464
-
465
409
  }, {
466
410
  key: "loadFromData",
467
411
  value: function loadFromData(data) {
468
412
  this.removeChildren();
469
-
470
413
  var _iterator = _createForOfIteratorHelper(data),
471
- _step;
472
-
414
+ _step;
473
415
  try {
474
416
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
475
417
  var o = _step.value;
476
-
477
418
  var _node = this.createNode(o);
478
-
479
419
  this.addChild(_node);
480
-
481
420
  if (isNodeRecordWithChildren(o)) {
482
421
  if (o.children.length === 0) {
483
422
  _node.isEmptyFolder = true;
@@ -491,22 +430,22 @@ var jqtree = (function (exports) {
491
430
  } finally {
492
431
  _iterator.f();
493
432
  }
494
-
495
433
  return this;
496
434
  }
435
+
497
436
  /*
498
437
  Add child.
499
438
  tree.addChild(
500
439
  new Node('child1')
501
440
  );
502
441
  */
503
-
504
442
  }, {
505
443
  key: "addChild",
506
444
  value: function addChild(node) {
507
445
  this.children.push(node);
508
446
  node.setParent(this);
509
447
  }
448
+
510
449
  /*
511
450
  Add child at position. Index starts at 0.
512
451
  tree.addChildAtPosition(
@@ -514,18 +453,17 @@ var jqtree = (function (exports) {
514
453
  1
515
454
  );
516
455
  */
517
-
518
456
  }, {
519
457
  key: "addChildAtPosition",
520
458
  value: function addChildAtPosition(node, index) {
521
459
  this.children.splice(index, 0, node);
522
460
  node.setParent(this);
523
461
  }
462
+
524
463
  /*
525
464
  Remove child. This also removes the children of the node.
526
465
  tree.removeChild(tree.children[0]);
527
466
  */
528
-
529
467
  }, {
530
468
  key: "removeChild",
531
469
  value: function removeChild(node) {
@@ -533,23 +471,23 @@ var jqtree = (function (exports) {
533
471
  node.removeChildren();
534
472
  this.doRemoveChild(node);
535
473
  }
474
+
536
475
  /*
537
476
  Get child index.
538
477
  var index = getChildIndex(node);
539
478
  */
540
-
541
479
  }, {
542
480
  key: "getChildIndex",
543
481
  value: function getChildIndex(node) {
544
482
  return this.children.indexOf(node);
545
483
  }
484
+
546
485
  /*
547
486
  Does the tree have children?
548
487
  if (tree.hasChildren()) {
549
488
  //
550
489
  }
551
490
  */
552
-
553
491
  }, {
554
492
  key: "hasChildren",
555
493
  value: function hasChildren() {
@@ -560,6 +498,7 @@ var jqtree = (function (exports) {
560
498
  value: function isFolder() {
561
499
  return this.hasChildren() || this.load_on_demand;
562
500
  }
501
+
563
502
  /*
564
503
  Iterate over all the nodes in the tree.
565
504
  Calls callback with (node, level).
@@ -572,20 +511,17 @@ var jqtree = (function (exports) {
572
511
  }
573
512
  );
574
513
  */
575
-
576
514
  }, {
577
515
  key: "iterate",
578
516
  value: function iterate(callback) {
579
517
  var _iterate = function _iterate(node, level) {
580
518
  if (node.children) {
581
519
  var _iterator2 = _createForOfIteratorHelper(node.children),
582
- _step2;
583
-
520
+ _step2;
584
521
  try {
585
522
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
586
523
  var child = _step2.value;
587
524
  var result = callback(child, level);
588
-
589
525
  if (result && child.hasChildren()) {
590
526
  _iterate(child, level + 1);
591
527
  }
@@ -597,16 +533,15 @@ var jqtree = (function (exports) {
597
533
  }
598
534
  }
599
535
  };
600
-
601
536
  _iterate(this, 0);
602
537
  }
538
+
603
539
  /*
604
540
  Move node relative to another node.
605
541
  Argument position: Position.BEFORE, Position.AFTER or Position.Inside
606
542
  // move node1 after node2
607
543
  tree.moveNode(node1, node2, Position.AFTER);
608
544
  */
609
-
610
545
  }, {
611
546
  key: "moveNode",
612
547
  value: function moveNode(movedNode, targetNode, position) {
@@ -616,7 +551,6 @@ var jqtree = (function (exports) {
616
551
  return false;
617
552
  } else {
618
553
  movedNode.parent.doRemoveChild(movedNode);
619
-
620
554
  switch (position) {
621
555
  case Position.After:
622
556
  {
@@ -624,60 +558,50 @@ var jqtree = (function (exports) {
624
558
  targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode) + 1);
625
559
  return true;
626
560
  }
627
-
628
561
  return false;
629
562
  }
630
-
631
563
  case Position.Before:
632
564
  {
633
565
  if (targetNode.parent) {
634
566
  targetNode.parent.addChildAtPosition(movedNode, targetNode.parent.getChildIndex(targetNode));
635
567
  return true;
636
568
  }
637
-
638
569
  return false;
639
570
  }
640
-
641
571
  case Position.Inside:
642
572
  {
643
573
  // move inside as first child
644
574
  targetNode.addChildAtPosition(movedNode, 0);
645
575
  return true;
646
576
  }
647
-
648
577
  default:
649
578
  return false;
650
579
  }
651
580
  }
652
581
  }
582
+
653
583
  /*
654
584
  Get the tree as data.
655
585
  */
656
-
657
586
  }, {
658
587
  key: "getData",
659
588
  value: function getData() {
660
589
  var includeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
661
-
662
590
  var getDataFromNodes = function getDataFromNodes(nodes) {
663
591
  return nodes.map(function (node) {
664
592
  var tmpNode = {};
665
-
666
593
  for (var k in node) {
667
594
  if (["parent", "children", "element", "idMapping", "load_on_demand", "nodeClass", "tree", "isEmptyFolder"].indexOf(k) === -1 && Object.prototype.hasOwnProperty.call(node, k)) {
668
595
  var v = node[k];
669
596
  tmpNode[k] = v;
670
597
  }
671
598
  }
672
-
673
599
  if (node.hasChildren()) {
674
600
  tmpNode["children"] = getDataFromNodes(node.children);
675
601
  }
676
-
677
602
  return tmpNode;
678
603
  });
679
604
  };
680
-
681
605
  if (includeParent) {
682
606
  return getDataFromNodes([this]);
683
607
  } else {
@@ -697,11 +621,9 @@ var jqtree = (function (exports) {
697
621
  var node = this.getNodeByCallback(function (n) {
698
622
  return n.name === name;
699
623
  });
700
-
701
624
  if (!node) {
702
625
  throw "Node with name ".concat(name, " not found");
703
626
  }
704
-
705
627
  return node;
706
628
  }
707
629
  }, {
@@ -727,14 +649,11 @@ var jqtree = (function (exports) {
727
649
  return null;
728
650
  } else {
729
651
  var _node2 = this.createNode(nodeInfo);
730
-
731
652
  var childIndex = this.parent.getChildIndex(this);
732
653
  this.parent.addChildAtPosition(_node2, childIndex + 1);
733
-
734
654
  if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
735
655
  _node2.loadFromData(nodeInfo.children);
736
656
  }
737
-
738
657
  return _node2;
739
658
  }
740
659
  }
@@ -745,14 +664,11 @@ var jqtree = (function (exports) {
745
664
  return null;
746
665
  } else {
747
666
  var _node3 = this.createNode(nodeInfo);
748
-
749
667
  var childIndex = this.parent.getChildIndex(this);
750
668
  this.parent.addChildAtPosition(_node3, childIndex);
751
-
752
669
  if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
753
670
  _node3.loadFromData(nodeInfo.children);
754
671
  }
755
-
756
672
  return _node3;
757
673
  }
758
674
  }
@@ -763,16 +679,12 @@ var jqtree = (function (exports) {
763
679
  return null;
764
680
  } else {
765
681
  var newParent = this.createNode(nodeInfo);
766
-
767
682
  if (this.tree) {
768
683
  newParent.setParent(this.tree);
769
684
  }
770
-
771
685
  var originalParent = this.parent;
772
-
773
686
  var _iterator3 = _createForOfIteratorHelper(originalParent.children),
774
- _step3;
775
-
687
+ _step3;
776
688
  try {
777
689
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
778
690
  var child = _step3.value;
@@ -783,7 +695,6 @@ var jqtree = (function (exports) {
783
695
  } finally {
784
696
  _iterator3.f();
785
697
  }
786
-
787
698
  originalParent.children = [];
788
699
  originalParent.addChild(newParent);
789
700
  return newParent;
@@ -802,11 +713,9 @@ var jqtree = (function (exports) {
802
713
  value: function append(nodeInfo) {
803
714
  var node = this.createNode(nodeInfo);
804
715
  this.addChild(node);
805
-
806
716
  if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
807
717
  node.loadFromData(nodeInfo.children);
808
718
  }
809
-
810
719
  return node;
811
720
  }
812
721
  }, {
@@ -814,26 +723,21 @@ var jqtree = (function (exports) {
814
723
  value: function prepend(nodeInfo) {
815
724
  var node = this.createNode(nodeInfo);
816
725
  this.addChildAtPosition(node, 0);
817
-
818
726
  if (isNodeRecordWithChildren(nodeInfo) && nodeInfo.children.length) {
819
727
  node.loadFromData(nodeInfo.children);
820
728
  }
821
-
822
729
  return node;
823
730
  }
824
731
  }, {
825
732
  key: "isParentOf",
826
733
  value: function isParentOf(node) {
827
734
  var parent = node.parent;
828
-
829
735
  while (parent) {
830
736
  if (parent === this) {
831
737
  return true;
832
738
  }
833
-
834
739
  parent = parent.parent;
835
740
  }
836
-
837
741
  return false;
838
742
  }
839
743
  }, {
@@ -846,7 +750,6 @@ var jqtree = (function (exports) {
846
750
  level += 1;
847
751
  node = node.parent;
848
752
  }
849
-
850
753
  return level;
851
754
  }
852
755
  }, {
@@ -872,10 +775,8 @@ var jqtree = (function (exports) {
872
775
  key: "removeChildren",
873
776
  value: function removeChildren() {
874
777
  var _this = this;
875
-
876
778
  this.iterate(function (child) {
877
779
  var _this$tree;
878
-
879
780
  (_this$tree = _this.tree) === null || _this$tree === void 0 ? void 0 : _this$tree.removeNodeFromIndex(child);
880
781
  return true;
881
782
  });
@@ -888,7 +789,6 @@ var jqtree = (function (exports) {
888
789
  return null;
889
790
  } else {
890
791
  var previousIndex = this.parent.getChildIndex(this) - 1;
891
-
892
792
  if (previousIndex >= 0) {
893
793
  return this.parent.children[previousIndex];
894
794
  } else {
@@ -903,7 +803,6 @@ var jqtree = (function (exports) {
903
803
  return null;
904
804
  } else {
905
805
  var nextIndex = this.parent.getChildIndex(this) + 1;
906
-
907
806
  if (nextIndex < this.parent.children.length) {
908
807
  return this.parent.children[nextIndex];
909
808
  } else {
@@ -926,7 +825,6 @@ var jqtree = (function (exports) {
926
825
  if (f(node)) {
927
826
  result.push(node);
928
827
  }
929
-
930
828
  return true;
931
829
  });
932
830
  return result;
@@ -935,8 +833,23 @@ var jqtree = (function (exports) {
935
833
  key: "getNextNode",
936
834
  value: function getNextNode() {
937
835
  var includeChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
938
-
939
- if (includeChildren && this.hasChildren() && this.is_open) {
836
+ if (includeChildren && this.hasChildren()) {
837
+ return this.children[0];
838
+ } else if (!this.parent) {
839
+ return null;
840
+ } else {
841
+ var nextSibling = this.getNextSibling();
842
+ if (nextSibling) {
843
+ return nextSibling;
844
+ } else {
845
+ return this.parent.getNextNode(false);
846
+ }
847
+ }
848
+ }
849
+ }, {
850
+ key: "getNextVisibleNode",
851
+ value: function getNextVisibleNode() {
852
+ if (this.hasChildren() && this.is_open) {
940
853
  // First child
941
854
  return this.children[0];
942
855
  } else {
@@ -944,7 +857,6 @@ var jqtree = (function (exports) {
944
857
  return null;
945
858
  } else {
946
859
  var nextSibling = this.getNextSibling();
947
-
948
860
  if (nextSibling) {
949
861
  // Next sibling
950
862
  return nextSibling;
@@ -962,17 +874,30 @@ var jqtree = (function (exports) {
962
874
  return null;
963
875
  } else {
964
876
  var previousSibling = this.getPreviousSibling();
965
-
966
- if (previousSibling) {
967
- if (!previousSibling.hasChildren() || !previousSibling.is_open) {
968
- // Previous sibling
969
- return previousSibling;
970
- } else {
971
- // Last child of previous sibling
972
- return previousSibling.getLastChild();
973
- }
877
+ if (!previousSibling) {
878
+ return this.getParent();
879
+ } else if (previousSibling.hasChildren()) {
880
+ return previousSibling.getLastChild();
974
881
  } else {
882
+ return previousSibling;
883
+ }
884
+ }
885
+ }
886
+ }, {
887
+ key: "getPreviousVisibleNode",
888
+ value: function getPreviousVisibleNode() {
889
+ if (!this.parent) {
890
+ return null;
891
+ } else {
892
+ var previousSibling = this.getPreviousSibling();
893
+ if (!previousSibling) {
975
894
  return this.getParent();
895
+ } else if (!previousSibling.hasChildren() || !previousSibling.is_open) {
896
+ // Previous sibling
897
+ return previousSibling;
898
+ } else {
899
+ // Last child of previous sibling
900
+ return previousSibling.getLastChild();
976
901
  }
977
902
  }
978
903
  }
@@ -996,40 +921,33 @@ var jqtree = (function (exports) {
996
921
  return null;
997
922
  } else {
998
923
  var lastChild = this.children[this.children.length - 1];
999
-
1000
924
  if (!(lastChild.hasChildren() && lastChild.is_open)) {
1001
925
  return lastChild;
1002
926
  } else {
1003
927
  return lastChild.getLastChild();
1004
928
  }
1005
929
  }
1006
- } // Init Node from data without making it the root of the tree
930
+ }
1007
931
 
932
+ // Init Node from data without making it the root of the tree
1008
933
  }, {
1009
934
  key: "initFromData",
1010
935
  value: function initFromData(data) {
1011
936
  var _this2 = this;
1012
-
1013
937
  var addNode = function addNode(nodeData) {
1014
938
  _this2.setData(nodeData);
1015
-
1016
939
  if (isNodeRecordWithChildren(nodeData) && nodeData.children.length) {
1017
940
  addChildren(nodeData.children);
1018
941
  }
1019
942
  };
1020
-
1021
943
  var addChildren = function addChildren(childrenData) {
1022
944
  var _iterator4 = _createForOfIteratorHelper(childrenData),
1023
- _step4;
1024
-
945
+ _step4;
1025
946
  try {
1026
947
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1027
948
  var child = _step4.value;
1028
-
1029
949
  var _node4 = _this2.createNode();
1030
-
1031
950
  _node4.initFromData(child);
1032
-
1033
951
  _this2.addChild(_node4);
1034
952
  }
1035
953
  } catch (err) {
@@ -1038,14 +956,12 @@ var jqtree = (function (exports) {
1038
956
  _iterator4.f();
1039
957
  }
1040
958
  };
1041
-
1042
959
  addNode(data);
1043
960
  }
1044
961
  }, {
1045
962
  key: "setParent",
1046
963
  value: function setParent(parent) {
1047
964
  var _this$tree2;
1048
-
1049
965
  this.parent = parent;
1050
966
  this.tree = parent.tree;
1051
967
  (_this$tree2 = this.tree) === null || _this$tree2 === void 0 ? void 0 : _this$tree2.addNodeToIndex(this);
@@ -1054,7 +970,6 @@ var jqtree = (function (exports) {
1054
970
  key: "doRemoveChild",
1055
971
  value: function doRemoveChild(node) {
1056
972
  var _this$tree3;
1057
-
1058
973
  this.children.splice(this.getChildIndex(node), 1);
1059
974
  (_this$tree3 = this.tree) === null || _this$tree3 === void 0 ? void 0 : _this$tree3.removeNodeFromIndex(node);
1060
975
  }
@@ -1062,7 +977,6 @@ var jqtree = (function (exports) {
1062
977
  key: "getNodeClass",
1063
978
  value: function getNodeClass() {
1064
979
  var _this$tree4;
1065
-
1066
980
  return this.nodeClass || (this === null || this === void 0 ? void 0 : (_this$tree4 = this.tree) === null || _this$tree4 === void 0 ? void 0 : _this$tree4.nodeClass) || Node;
1067
981
  }
1068
982
  }, {
@@ -1072,32 +986,21 @@ var jqtree = (function (exports) {
1072
986
  return new nodeClass(nodeData);
1073
987
  }
1074
988
  }]);
1075
-
1076
989
  return Node;
1077
990
  }();
1078
991
 
1079
992
  var DragAndDropHandler = /*#__PURE__*/function () {
1080
993
  function DragAndDropHandler(treeWidget) {
1081
994
  _classCallCheck(this, DragAndDropHandler);
1082
-
1083
995
  _defineProperty(this, "hitAreas", void 0);
1084
-
1085
996
  _defineProperty(this, "isDragging", void 0);
1086
-
1087
997
  _defineProperty(this, "currentItem", void 0);
1088
-
1089
998
  _defineProperty(this, "hoveredArea", void 0);
1090
-
1091
999
  _defineProperty(this, "positionInfo", void 0);
1092
-
1093
1000
  _defineProperty(this, "treeWidget", void 0);
1094
-
1095
1001
  _defineProperty(this, "dragElement", void 0);
1096
-
1097
1002
  _defineProperty(this, "previousGhost", void 0);
1098
-
1099
1003
  _defineProperty(this, "openFolderTimer", void 0);
1100
-
1101
1004
  this.treeWidget = treeWidget;
1102
1005
  this.hoveredArea = null;
1103
1006
  this.hitAreas = [];
@@ -1105,28 +1008,22 @@ var jqtree = (function (exports) {
1105
1008
  this.currentItem = null;
1106
1009
  this.positionInfo = null;
1107
1010
  }
1108
-
1109
1011
  _createClass(DragAndDropHandler, [{
1110
1012
  key: "mouseCapture",
1111
1013
  value: function mouseCapture(positionInfo) {
1112
1014
  var $element = jQuery(positionInfo.target);
1113
-
1114
1015
  if (!this.mustCaptureElement($element)) {
1115
1016
  return null;
1116
1017
  }
1117
-
1118
1018
  if (this.treeWidget.options.onIsMoveHandle && !this.treeWidget.options.onIsMoveHandle($element)) {
1119
1019
  return null;
1120
1020
  }
1121
-
1122
1021
  var nodeElement = this.treeWidget._getNodeElement($element);
1123
-
1124
1022
  if (nodeElement && this.treeWidget.options.onCanMove) {
1125
1023
  if (!this.treeWidget.options.onCanMove(nodeElement.node)) {
1126
1024
  nodeElement = null;
1127
1025
  }
1128
1026
  }
1129
-
1130
1027
  this.currentItem = nodeElement;
1131
1028
  return this.currentItem != null;
1132
1029
  }
@@ -1134,11 +1031,9 @@ var jqtree = (function (exports) {
1134
1031
  key: "mouseStart",
1135
1032
  value: function mouseStart(positionInfo) {
1136
1033
  var _this$treeWidget$opti;
1137
-
1138
1034
  if (!this.currentItem || positionInfo.pageX === undefined || positionInfo.pageY === undefined) {
1139
1035
  return false;
1140
1036
  }
1141
-
1142
1037
  this.refresh();
1143
1038
  var offset = jQuery(positionInfo.target).offset();
1144
1039
  var left = offset ? offset.left : 0;
@@ -1156,25 +1051,22 @@ var jqtree = (function (exports) {
1156
1051
  if (!this.currentItem || !this.dragElement || positionInfo.pageX === undefined || positionInfo.pageY === undefined) {
1157
1052
  return false;
1158
1053
  }
1159
-
1160
1054
  this.dragElement.move(positionInfo.pageX, positionInfo.pageY);
1161
1055
  this.positionInfo = positionInfo;
1162
1056
  var area = this.findHoveredArea(positionInfo.pageX, positionInfo.pageY);
1163
-
1164
1057
  if (area && this.canMoveToArea(area)) {
1165
1058
  if (!area.node.isFolder()) {
1166
1059
  this.stopOpenFolderTimer();
1167
1060
  }
1168
-
1169
1061
  if (this.hoveredArea !== area) {
1170
- this.hoveredArea = area; // If this is a closed folder, start timer to open it
1062
+ this.hoveredArea = area;
1171
1063
 
1064
+ // If this is a closed folder, start timer to open it
1172
1065
  if (this.mustOpenFolderTimer(area)) {
1173
1066
  this.startOpenFolderTimer(area.node);
1174
1067
  } else {
1175
1068
  this.stopOpenFolderTimer();
1176
1069
  }
1177
-
1178
1070
  this.updateDropHint();
1179
1071
  }
1180
1072
  } else {
@@ -1182,13 +1074,11 @@ var jqtree = (function (exports) {
1182
1074
  this.stopOpenFolderTimer();
1183
1075
  this.hoveredArea = area;
1184
1076
  }
1185
-
1186
1077
  if (!area) {
1187
1078
  if (this.treeWidget.options.onDragMove) {
1188
1079
  this.treeWidget.options.onDragMove(this.currentItem.node, positionInfo.originalEvent);
1189
1080
  }
1190
1081
  }
1191
-
1192
1082
  return true;
1193
1083
  }
1194
1084
  }, {
@@ -1200,32 +1090,26 @@ var jqtree = (function (exports) {
1200
1090
  this.removeDropHint();
1201
1091
  this.removeHitAreas();
1202
1092
  var currentItem = this.currentItem;
1203
-
1204
1093
  if (this.currentItem) {
1205
1094
  this.currentItem.$element.removeClass("jqtree-moving");
1206
1095
  this.currentItem = null;
1207
1096
  }
1208
-
1209
1097
  this.isDragging = false;
1210
1098
  this.positionInfo = null;
1211
-
1212
1099
  if (!this.hoveredArea && currentItem) {
1213
1100
  if (this.treeWidget.options.onDragStop) {
1214
1101
  this.treeWidget.options.onDragStop(currentItem.node, positionInfo.originalEvent);
1215
1102
  }
1216
1103
  }
1217
-
1218
1104
  return false;
1219
1105
  }
1220
1106
  }, {
1221
1107
  key: "refresh",
1222
1108
  value: function refresh() {
1223
1109
  this.removeHitAreas();
1224
-
1225
1110
  if (this.currentItem) {
1226
1111
  this.generateHitAreas();
1227
1112
  this.currentItem = this.treeWidget._getNodeElementForNode(this.currentItem.node);
1228
-
1229
1113
  if (this.isDragging) {
1230
1114
  this.currentItem.$element.addClass("jqtree-moving");
1231
1115
  }
@@ -1252,11 +1136,9 @@ var jqtree = (function (exports) {
1252
1136
  if (!this.treeWidget.options.onCanMoveTo) {
1253
1137
  return true;
1254
1138
  }
1255
-
1256
1139
  if (!this.currentItem) {
1257
1140
  return false;
1258
1141
  }
1259
-
1260
1142
  var positionName = getPositionName(area.position);
1261
1143
  return this.treeWidget.options.onCanMoveTo(this.currentItem.node, area.node, positionName);
1262
1144
  }
@@ -1289,18 +1171,14 @@ var jqtree = (function (exports) {
1289
1171
  key: "findHoveredArea",
1290
1172
  value: function findHoveredArea(x, y) {
1291
1173
  var dimensions = this.getTreeDimensions();
1292
-
1293
1174
  if (x < dimensions.left || y < dimensions.top || x > dimensions.right || y > dimensions.bottom) {
1294
1175
  return null;
1295
1176
  }
1296
-
1297
1177
  var low = 0;
1298
1178
  var high = this.hitAreas.length;
1299
-
1300
1179
  while (low < high) {
1301
1180
  var mid = low + high >> 1;
1302
1181
  var area = this.hitAreas[mid];
1303
-
1304
1182
  if (y < area.top) {
1305
1183
  high = mid;
1306
1184
  } else if (y > area.bottom) {
@@ -1309,7 +1187,6 @@ var jqtree = (function (exports) {
1309
1187
  return area;
1310
1188
  }
1311
1189
  }
1312
-
1313
1190
  return null;
1314
1191
  }
1315
1192
  }, {
@@ -1323,30 +1200,30 @@ var jqtree = (function (exports) {
1323
1200
  value: function updateDropHint() {
1324
1201
  if (!this.hoveredArea) {
1325
1202
  return;
1326
- } // remove previous drop hint
1327
-
1203
+ }
1328
1204
 
1329
- this.removeDropHint(); // add new drop hint
1205
+ // remove previous drop hint
1206
+ this.removeDropHint();
1330
1207
 
1208
+ // add new drop hint
1331
1209
  var nodeElement = this.treeWidget._getNodeElementForNode(this.hoveredArea.node);
1332
-
1333
1210
  this.previousGhost = nodeElement.addDropHint(this.hoveredArea.position);
1334
1211
  }
1335
1212
  }, {
1336
1213
  key: "startOpenFolderTimer",
1337
1214
  value: function startOpenFolderTimer(folder) {
1338
1215
  var _this = this;
1339
-
1340
1216
  var openFolder = function openFolder() {
1341
1217
  _this.treeWidget._openNode(folder, _this.treeWidget.options.slide, function () {
1342
1218
  _this.refresh();
1343
-
1344
1219
  _this.updateDropHint();
1345
1220
  });
1346
1221
  };
1347
-
1348
1222
  this.stopOpenFolderTimer();
1349
- this.openFolderTimer = window.setTimeout(openFolder, this.treeWidget.options.openFolderDelay);
1223
+ var openFolderDelay = this.treeWidget.options.openFolderDelay;
1224
+ if (openFolderDelay !== false) {
1225
+ this.openFolderTimer = window.setTimeout(openFolder, openFolderDelay);
1226
+ }
1350
1227
  }
1351
1228
  }, {
1352
1229
  key: "stopOpenFolderTimer",
@@ -1360,25 +1237,19 @@ var jqtree = (function (exports) {
1360
1237
  key: "moveItem",
1361
1238
  value: function moveItem(positionInfo) {
1362
1239
  var _this2 = this;
1363
-
1364
1240
  if (this.currentItem && this.hoveredArea && this.hoveredArea.position !== Position.None && this.canMoveToArea(this.hoveredArea)) {
1365
1241
  var movedNode = this.currentItem.node;
1366
1242
  var targetNode = this.hoveredArea.node;
1367
1243
  var position = this.hoveredArea.position;
1368
1244
  var previousParent = movedNode.parent;
1369
-
1370
1245
  if (position === Position.Inside) {
1371
1246
  this.hoveredArea.node.is_open = true;
1372
1247
  }
1373
-
1374
1248
  var doMove = function doMove() {
1375
1249
  _this2.treeWidget.tree.moveNode(movedNode, targetNode, position);
1376
-
1377
1250
  _this2.treeWidget.element.empty();
1378
-
1379
1251
  _this2.treeWidget._refreshElements(null);
1380
1252
  };
1381
-
1382
1253
  var event = this.treeWidget._triggerEvent("tree.move", {
1383
1254
  move_info: {
1384
1255
  moved_node: movedNode,
@@ -1389,7 +1260,6 @@ var jqtree = (function (exports) {
1389
1260
  original_event: positionInfo.originalEvent
1390
1261
  }
1391
1262
  });
1392
-
1393
1263
  if (!event.isDefaultPrevented()) {
1394
1264
  doMove();
1395
1265
  }
@@ -1401,7 +1271,6 @@ var jqtree = (function (exports) {
1401
1271
  // Return the dimensions of the tree. Add a margin to the bottom to allow
1402
1272
  // to drag-and-drop after the last element.
1403
1273
  var offset = this.treeWidget.element.offset();
1404
-
1405
1274
  if (!offset) {
1406
1275
  return {
1407
1276
  left: 0,
@@ -1413,9 +1282,7 @@ var jqtree = (function (exports) {
1413
1282
  var el = this.treeWidget.element;
1414
1283
  var width = el.width() || 0;
1415
1284
  var height = el.height() || 0;
1416
-
1417
1285
  var left = offset.left + this.treeWidget._getScrollLeft();
1418
-
1419
1286
  return {
1420
1287
  left: left,
1421
1288
  top: offset.top,
@@ -1425,43 +1292,31 @@ var jqtree = (function (exports) {
1425
1292
  }
1426
1293
  }
1427
1294
  }]);
1428
-
1429
1295
  return DragAndDropHandler;
1430
1296
  }();
1431
-
1432
1297
  var VisibleNodeIterator = /*#__PURE__*/function () {
1433
1298
  function VisibleNodeIterator(tree) {
1434
1299
  _classCallCheck(this, VisibleNodeIterator);
1435
-
1436
1300
  _defineProperty(this, "tree", void 0);
1437
-
1438
1301
  this.tree = tree;
1439
1302
  }
1440
-
1441
1303
  _createClass(VisibleNodeIterator, [{
1442
1304
  key: "iterate",
1443
1305
  value: function iterate() {
1444
1306
  var _this3 = this;
1445
-
1446
1307
  var isFirstNode = true;
1447
-
1448
1308
  var _iterateNode = function _iterateNode(node, nextNode) {
1449
1309
  var mustIterateInside = (node.is_open || !node.element) && node.hasChildren();
1450
1310
  var $element = null;
1451
-
1452
1311
  if (node.element) {
1453
1312
  $element = jQuery(node.element);
1454
-
1455
1313
  if (!$element.is(":visible")) {
1456
1314
  return;
1457
1315
  }
1458
-
1459
1316
  if (isFirstNode) {
1460
1317
  _this3.handleFirstNode(node);
1461
-
1462
1318
  isFirstNode = false;
1463
1319
  }
1464
-
1465
1320
  if (!node.hasChildren()) {
1466
1321
  _this3.handleNode(node, nextNode, $element);
1467
1322
  } else if (node.is_open) {
@@ -1472,7 +1327,6 @@ var jqtree = (function (exports) {
1472
1327
  _this3.handleClosedFolder(node, nextNode, $element);
1473
1328
  }
1474
1329
  }
1475
-
1476
1330
  if (mustIterateInside) {
1477
1331
  var childrenLength = node.children.length;
1478
1332
  node.children.forEach(function (_, i) {
@@ -1482,45 +1336,31 @@ var jqtree = (function (exports) {
1482
1336
  _iterateNode(node.children[i], node.children[i + 1]);
1483
1337
  }
1484
1338
  });
1485
-
1486
1339
  if (node.is_open && $element) {
1487
1340
  _this3.handleAfterOpenFolder(node, nextNode);
1488
1341
  }
1489
1342
  }
1490
1343
  };
1491
-
1492
1344
  _iterateNode(this.tree, null);
1493
1345
  }
1494
1346
  }]);
1495
-
1496
1347
  return VisibleNodeIterator;
1497
1348
  }();
1498
-
1499
1349
  var HitAreasGenerator = /*#__PURE__*/function (_VisibleNodeIterator) {
1500
1350
  _inherits(HitAreasGenerator, _VisibleNodeIterator);
1501
-
1502
1351
  var _super = _createSuper(HitAreasGenerator);
1503
-
1504
1352
  function HitAreasGenerator(tree, currentNode, treeBottom) {
1505
1353
  var _this4;
1506
-
1507
1354
  _classCallCheck(this, HitAreasGenerator);
1508
-
1509
1355
  _this4 = _super.call(this, tree);
1510
-
1511
1356
  _defineProperty(_assertThisInitialized(_this4), "currentNode", void 0);
1512
-
1513
1357
  _defineProperty(_assertThisInitialized(_this4), "treeBottom", void 0);
1514
-
1515
1358
  _defineProperty(_assertThisInitialized(_this4), "positions", void 0);
1516
-
1517
1359
  _defineProperty(_assertThisInitialized(_this4), "lastTop", void 0);
1518
-
1519
1360
  _this4.currentNode = currentNode;
1520
1361
  _this4.treeBottom = treeBottom;
1521
1362
  return _this4;
1522
1363
  }
1523
-
1524
1364
  _createClass(HitAreasGenerator, [{
1525
1365
  key: "generate",
1526
1366
  value: function generate() {
@@ -1535,23 +1375,18 @@ var jqtree = (function (exports) {
1535
1375
  var previousTop = -1;
1536
1376
  var group = [];
1537
1377
  var hitAreas = [];
1538
-
1539
1378
  var _iterator = _createForOfIteratorHelper(positions),
1540
- _step;
1541
-
1379
+ _step;
1542
1380
  try {
1543
1381
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1544
1382
  var position = _step.value;
1545
-
1546
1383
  if (position.top !== previousTop && group.length) {
1547
1384
  if (group.length) {
1548
1385
  this.generateHitAreasForGroup(hitAreas, group, previousTop, position.top);
1549
1386
  }
1550
-
1551
1387
  previousTop = position.top;
1552
1388
  group = [];
1553
1389
  }
1554
-
1555
1390
  group.push(position);
1556
1391
  }
1557
1392
  } catch (err) {
@@ -1559,7 +1394,6 @@ var jqtree = (function (exports) {
1559
1394
  } finally {
1560
1395
  _iterator.f();
1561
1396
  }
1562
-
1563
1397
  this.generateHitAreasForGroup(hitAreas, group, previousTop, this.treeBottom);
1564
1398
  return hitAreas;
1565
1399
  }
@@ -1570,27 +1404,27 @@ var jqtree = (function (exports) {
1570
1404
  // Cannot move inside current item
1571
1405
  // Stop iterating
1572
1406
  return false;
1573
- } // Cannot move before current item
1574
-
1407
+ }
1575
1408
 
1409
+ // Cannot move before current item
1576
1410
  if (node.children[0] !== this.currentNode) {
1577
1411
  this.addPosition(node, Position.Inside, this.getTop($element));
1578
- } // Continue iterating
1579
-
1412
+ }
1580
1413
 
1414
+ // Continue iterating
1581
1415
  return true;
1582
1416
  }
1583
1417
  }, {
1584
1418
  key: "handleClosedFolder",
1585
1419
  value: function handleClosedFolder(node, nextNode, $element) {
1586
1420
  var top = this.getTop($element);
1587
-
1588
1421
  if (node === this.currentNode) {
1589
1422
  // Cannot move after current item
1590
1423
  this.addPosition(node, Position.None, top);
1591
1424
  } else {
1592
- this.addPosition(node, Position.Inside, top); // Cannot move before current item
1425
+ this.addPosition(node, Position.Inside, top);
1593
1426
 
1427
+ // Cannot move before current item
1594
1428
  if (nextNode !== this.currentNode) {
1595
1429
  this.addPosition(node, Position.After, top);
1596
1430
  }
@@ -1617,14 +1451,12 @@ var jqtree = (function (exports) {
1617
1451
  key: "handleNode",
1618
1452
  value: function handleNode(node, nextNode, $element) {
1619
1453
  var top = this.getTop($element);
1620
-
1621
1454
  if (node === this.currentNode) {
1622
1455
  // Cannot move inside current item
1623
1456
  this.addPosition(node, Position.None, top);
1624
1457
  } else {
1625
1458
  this.addPosition(node, Position.Inside, top);
1626
1459
  }
1627
-
1628
1460
  if (nextNode === this.currentNode || node === this.currentNode) {
1629
1461
  // Cannot move before or after current item
1630
1462
  this.addPosition(node, Position.None, top);
@@ -1658,7 +1490,6 @@ var jqtree = (function (exports) {
1658
1490
  var areaHeight = Math.round((bottom - top) / positionCount);
1659
1491
  var areaTop = top;
1660
1492
  var i = 0;
1661
-
1662
1493
  while (i < positionCount) {
1663
1494
  var position = positionsInGroup[i];
1664
1495
  hitAreas.push({
@@ -1672,34 +1503,25 @@ var jqtree = (function (exports) {
1672
1503
  }
1673
1504
  }
1674
1505
  }]);
1675
-
1676
1506
  return HitAreasGenerator;
1677
1507
  }(VisibleNodeIterator);
1678
-
1679
1508
  var DragElement = /*#__PURE__*/function () {
1680
1509
  function DragElement(nodeName, offsetX, offsetY, $tree, autoEscape) {
1681
1510
  _classCallCheck(this, DragElement);
1682
-
1683
1511
  _defineProperty(this, "offsetX", void 0);
1684
-
1685
1512
  _defineProperty(this, "offsetY", void 0);
1686
-
1687
1513
  _defineProperty(this, "$element", void 0);
1688
-
1689
1514
  this.offsetX = offsetX;
1690
1515
  this.offsetY = offsetY;
1691
1516
  this.$element = jQuery("<span>").addClass("jqtree-title jqtree-dragging");
1692
-
1693
1517
  if (autoEscape) {
1694
1518
  this.$element.text(nodeName);
1695
1519
  } else {
1696
1520
  this.$element.html(nodeName);
1697
1521
  }
1698
-
1699
1522
  this.$element.css("position", "absolute");
1700
1523
  $tree.append(this.$element);
1701
1524
  }
1702
-
1703
1525
  _createClass(DragElement, [{
1704
1526
  key: "move",
1705
1527
  value: function move(pageX, pageY) {
@@ -1714,7 +1536,6 @@ var jqtree = (function (exports) {
1714
1536
  this.$element.remove();
1715
1537
  }
1716
1538
  }]);
1717
-
1718
1539
  return DragElement;
1719
1540
  }();
1720
1541
 
@@ -1731,18 +1552,13 @@ var jqtree = (function (exports) {
1731
1552
  var ElementsRenderer = /*#__PURE__*/function () {
1732
1553
  function ElementsRenderer(treeWidget) {
1733
1554
  _classCallCheck(this, ElementsRenderer);
1734
-
1735
1555
  _defineProperty(this, "openedIconElement", void 0);
1736
-
1737
1556
  _defineProperty(this, "closedIconElement", void 0);
1738
-
1739
1557
  _defineProperty(this, "treeWidget", void 0);
1740
-
1741
1558
  this.treeWidget = treeWidget;
1742
1559
  this.openedIconElement = this.createButtonElement(treeWidget.options.openedIcon || "+");
1743
1560
  this.closedIconElement = this.createButtonElement(treeWidget.options.closedIcon || "-");
1744
1561
  }
1745
-
1746
1562
  _createClass(ElementsRenderer, [{
1747
1563
  key: "render",
1748
1564
  value: function render(fromNode) {
@@ -1763,15 +1579,19 @@ var jqtree = (function (exports) {
1763
1579
  key: "renderFromNode",
1764
1580
  value: function renderFromNode(node) {
1765
1581
  // remember current li
1766
- var $previousLi = jQuery(node.element); // create element
1582
+ var $previousLi = jQuery(node.element);
1767
1583
 
1584
+ // create element
1768
1585
  var li = this.createLi(node, node.getLevel());
1769
- this.attachNodeData(node, li); // add element to dom
1586
+ this.attachNodeData(node, li);
1770
1587
 
1771
- $previousLi.after(li); // remove previous li
1588
+ // add element to dom
1589
+ $previousLi.after(li);
1772
1590
 
1773
- $previousLi.remove(); // create children
1591
+ // remove previous li
1592
+ $previousLi.remove();
1774
1593
 
1594
+ // create children
1775
1595
  if (node.children) {
1776
1596
  this.createDomElements(li, node.children, false, node.getLevel() + 1);
1777
1597
  }
@@ -1781,17 +1601,14 @@ var jqtree = (function (exports) {
1781
1601
  value: function createDomElements(element, children, isRootNode, level) {
1782
1602
  var ul = this.createUl(isRootNode);
1783
1603
  element.appendChild(ul);
1784
-
1785
1604
  var _iterator = _createForOfIteratorHelper(children),
1786
- _step;
1787
-
1605
+ _step;
1788
1606
  try {
1789
1607
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
1790
1608
  var child = _step.value;
1791
1609
  var li = this.createLi(child, level);
1792
1610
  ul.appendChild(li);
1793
1611
  this.attachNodeData(child, li);
1794
-
1795
1612
  if (child.hasChildren()) {
1796
1613
  this.createDomElements(li, child.children, false, level + 1);
1797
1614
  }
@@ -1813,23 +1630,19 @@ var jqtree = (function (exports) {
1813
1630
  value: function createUl(isRootNode) {
1814
1631
  var classString;
1815
1632
  var role;
1816
-
1817
1633
  if (!isRootNode) {
1818
1634
  classString = "";
1819
1635
  role = "group";
1820
1636
  } else {
1821
1637
  classString = "jqtree-tree";
1822
1638
  role = "tree";
1823
-
1824
1639
  if (this.treeWidget.options.rtl) {
1825
1640
  classString += " jqtree-rtl";
1826
1641
  }
1827
1642
  }
1828
-
1829
1643
  if (this.treeWidget.options.dragAndDrop) {
1830
1644
  classString += " jqtree-dnd";
1831
1645
  }
1832
-
1833
1646
  var ul = document.createElement("ul");
1834
1647
  ul.className = "jqtree_common ".concat(classString);
1835
1648
  ul.setAttribute("role", role);
@@ -1841,11 +1654,9 @@ var jqtree = (function (exports) {
1841
1654
  var isSelected = Boolean(this.treeWidget.selectNodeHandler.isNodeSelected(node));
1842
1655
  var mustShowFolder = node.isFolder() || node.isEmptyFolder && this.treeWidget.options.showEmptyFolder;
1843
1656
  var li = mustShowFolder ? this.createFolderLi(node, level, isSelected) : this.createNodeLi(node, level, isSelected);
1844
-
1845
1657
  if (this.treeWidget.options.onCreateLi) {
1846
1658
  this.treeWidget.options.onCreateLi(node, jQuery(li), isSelected);
1847
1659
  }
1848
-
1849
1660
  return li;
1850
1661
  }
1851
1662
  }, {
@@ -1853,56 +1664,57 @@ var jqtree = (function (exports) {
1853
1664
  value: function createFolderLi(node, level, isSelected) {
1854
1665
  var buttonClasses = this.getButtonClasses(node);
1855
1666
  var folderClasses = this.getFolderClasses(node, isSelected);
1856
- var iconElement = node.is_open ? this.openedIconElement : this.closedIconElement; // li
1667
+ var iconElement = node.is_open ? this.openedIconElement : this.closedIconElement;
1857
1668
 
1669
+ // li
1858
1670
  var li = document.createElement("li");
1859
1671
  li.className = "jqtree_common ".concat(folderClasses);
1860
- li.setAttribute("role", "presentation"); // div
1672
+ li.setAttribute("role", "presentation");
1861
1673
 
1674
+ // div
1862
1675
  var div = document.createElement("div");
1863
1676
  div.className = "jqtree-element jqtree_common";
1864
1677
  div.setAttribute("role", "presentation");
1865
- li.appendChild(div); // button link
1678
+ li.appendChild(div);
1866
1679
 
1680
+ // button link
1867
1681
  var buttonLink = document.createElement("a");
1868
1682
  buttonLink.className = buttonClasses;
1869
1683
  buttonLink.appendChild(iconElement.cloneNode(true));
1870
1684
  buttonLink.setAttribute("role", "presentation");
1871
1685
  buttonLink.setAttribute("aria-hidden", "true");
1872
-
1873
1686
  if (this.treeWidget.options.buttonLeft) {
1874
1687
  div.appendChild(buttonLink);
1875
- } // title span
1876
-
1688
+ }
1877
1689
 
1690
+ // title span
1878
1691
  div.appendChild(this.createTitleSpan(node.name, level, isSelected, node.is_open, true));
1879
-
1880
1692
  if (!this.treeWidget.options.buttonLeft) {
1881
1693
  div.appendChild(buttonLink);
1882
1694
  }
1883
-
1884
1695
  return li;
1885
1696
  }
1886
1697
  }, {
1887
1698
  key: "createNodeLi",
1888
1699
  value: function createNodeLi(node, level, isSelected) {
1889
1700
  var liClasses = ["jqtree_common"];
1890
-
1891
1701
  if (isSelected) {
1892
1702
  liClasses.push("jqtree-selected");
1893
1703
  }
1704
+ var classString = liClasses.join(" ");
1894
1705
 
1895
- var classString = liClasses.join(" "); // li
1896
-
1706
+ // li
1897
1707
  var li = document.createElement("li");
1898
1708
  li.className = classString;
1899
- li.setAttribute("role", "presentation"); // div
1709
+ li.setAttribute("role", "presentation");
1900
1710
 
1711
+ // div
1901
1712
  var div = document.createElement("div");
1902
1713
  div.className = "jqtree-element jqtree_common";
1903
1714
  div.setAttribute("role", "presentation");
1904
- li.appendChild(div); // title span
1715
+ li.appendChild(div);
1905
1716
 
1717
+ // title span
1906
1718
  div.appendChild(this.createTitleSpan(node.name, level, isSelected, node.is_open, false));
1907
1719
  return li;
1908
1720
  }
@@ -1911,68 +1723,55 @@ var jqtree = (function (exports) {
1911
1723
  value: function createTitleSpan(nodeName, level, isSelected, isOpen, isFolder) {
1912
1724
  var titleSpan = document.createElement("span");
1913
1725
  var classes = "jqtree-title jqtree_common";
1914
-
1915
1726
  if (isFolder) {
1916
1727
  classes += " jqtree-title-folder";
1917
1728
  }
1918
-
1919
1729
  classes += " jqtree-title-button-".concat(this.treeWidget.options.buttonLeft ? "left" : "right");
1920
1730
  titleSpan.className = classes;
1921
1731
  titleSpan.setAttribute("role", "treeitem");
1922
1732
  titleSpan.setAttribute("aria-level", "".concat(level));
1923
1733
  titleSpan.setAttribute("aria-selected", getBoolString(isSelected));
1924
1734
  titleSpan.setAttribute("aria-expanded", getBoolString(isOpen));
1925
-
1926
1735
  if (isSelected) {
1927
1736
  var tabIndex = this.treeWidget.options.tabIndex;
1928
-
1929
1737
  if (tabIndex !== undefined) {
1930
1738
  titleSpan.setAttribute("tabindex", "".concat(tabIndex));
1931
1739
  }
1932
1740
  }
1933
-
1934
1741
  if (this.treeWidget.options.autoEscape) {
1935
1742
  titleSpan.textContent = nodeName;
1936
1743
  } else {
1937
1744
  titleSpan.innerHTML = nodeName;
1938
1745
  }
1939
-
1940
1746
  return titleSpan;
1941
1747
  }
1942
1748
  }, {
1943
1749
  key: "getButtonClasses",
1944
1750
  value: function getButtonClasses(node) {
1945
1751
  var classes = ["jqtree-toggler", "jqtree_common"];
1946
-
1947
1752
  if (!node.is_open) {
1948
1753
  classes.push("jqtree-closed");
1949
1754
  }
1950
-
1951
1755
  if (this.treeWidget.options.buttonLeft) {
1952
1756
  classes.push("jqtree-toggler-left");
1953
1757
  } else {
1954
1758
  classes.push("jqtree-toggler-right");
1955
1759
  }
1956
-
1957
1760
  return classes.join(" ");
1958
1761
  }
1959
1762
  }, {
1960
1763
  key: "getFolderClasses",
1961
1764
  value: function getFolderClasses(node, isSelected) {
1962
1765
  var classes = ["jqtree-folder"];
1963
-
1964
1766
  if (!node.is_open) {
1965
1767
  classes.push("jqtree-closed");
1966
1768
  }
1967
-
1968
1769
  if (isSelected) {
1969
1770
  classes.push("jqtree-selected");
1970
1771
  }
1971
-
1972
1772
  if (node.is_loading) {
1973
1773
  classes.push("jqtree-loading");
1974
1774
  }
1975
-
1976
1775
  return classes.join(" ");
1977
1776
  }
1978
1777
  }, {
@@ -1988,56 +1787,42 @@ var jqtree = (function (exports) {
1988
1787
  }
1989
1788
  }
1990
1789
  }]);
1991
-
1992
1790
  return ElementsRenderer;
1993
1791
  }();
1994
1792
 
1995
1793
  var DataLoader = /*#__PURE__*/function () {
1996
1794
  function DataLoader(treeWidget) {
1997
1795
  _classCallCheck(this, DataLoader);
1998
-
1999
1796
  _defineProperty(this, "treeWidget", void 0);
2000
-
2001
1797
  this.treeWidget = treeWidget;
2002
1798
  }
2003
-
2004
1799
  _createClass(DataLoader, [{
2005
1800
  key: "loadFromUrl",
2006
1801
  value: function loadFromUrl(urlInfo, parentNode, onFinished) {
2007
1802
  var _this = this;
2008
-
2009
1803
  if (!urlInfo) {
2010
1804
  return;
2011
1805
  }
2012
-
2013
1806
  var $el = this.getDomElement(parentNode);
2014
1807
  this.addLoadingClass($el);
2015
1808
  this.notifyLoading(true, parentNode, $el);
2016
-
2017
1809
  var stopLoading = function stopLoading() {
2018
1810
  _this.removeLoadingClass($el);
2019
-
2020
1811
  _this.notifyLoading(false, parentNode, $el);
2021
1812
  };
2022
-
2023
1813
  var handleSuccess = function handleSuccess(data) {
2024
1814
  stopLoading();
2025
-
2026
1815
  _this.treeWidget.loadData(_this.parseData(data), parentNode);
2027
-
2028
1816
  if (onFinished && typeof onFinished === "function") {
2029
1817
  onFinished();
2030
1818
  }
2031
1819
  };
2032
-
2033
1820
  var handleError = function handleError(jqXHR) {
2034
1821
  stopLoading();
2035
-
2036
1822
  if (_this.treeWidget.options.onLoadFailed) {
2037
1823
  _this.treeWidget.options.onLoadFailed(jqXHR);
2038
1824
  }
2039
1825
  };
2040
-
2041
1826
  this.submitRequest(urlInfo, handleSuccess, handleError);
2042
1827
  }
2043
1828
  }, {
@@ -2069,7 +1854,6 @@ var jqtree = (function (exports) {
2069
1854
  if (this.treeWidget.options.onLoading) {
2070
1855
  this.treeWidget.options.onLoading(isLoading, node, $el);
2071
1856
  }
2072
-
2073
1857
  this.treeWidget._triggerEvent("tree.loading_data", {
2074
1858
  isLoading: isLoading,
2075
1859
  node: node,
@@ -2080,11 +1864,9 @@ var jqtree = (function (exports) {
2080
1864
  key: "submitRequest",
2081
1865
  value: function submitRequest(urlInfoInput, handleSuccess, handleError) {
2082
1866
  var _ajaxSettings$method;
2083
-
2084
1867
  var urlInfo = typeof urlInfoInput === "string" ? {
2085
1868
  url: urlInfoInput
2086
1869
  } : urlInfoInput;
2087
-
2088
1870
  var ajaxSettings = _objectSpread2({
2089
1871
  method: "GET",
2090
1872
  cache: false,
@@ -2092,7 +1874,6 @@ var jqtree = (function (exports) {
2092
1874
  success: handleSuccess,
2093
1875
  error: handleError
2094
1876
  }, urlInfo);
2095
-
2096
1877
  ajaxSettings.method = ((_ajaxSettings$method = ajaxSettings.method) === null || _ajaxSettings$method === void 0 ? void 0 : _ajaxSettings$method.toUpperCase()) || "GET";
2097
1878
  void jQuery.ajax(ajaxSettings);
2098
1879
  }
@@ -2100,7 +1881,6 @@ var jqtree = (function (exports) {
2100
1881
  key: "parseData",
2101
1882
  value: function parseData(data) {
2102
1883
  var dataFilter = this.treeWidget.options.dataFilter;
2103
-
2104
1884
  var getParsedData = function getParsedData() {
2105
1885
  if (typeof data === "string") {
2106
1886
  return JSON.parse(data);
@@ -2108,9 +1888,7 @@ var jqtree = (function (exports) {
2108
1888
  return data;
2109
1889
  }
2110
1890
  };
2111
-
2112
1891
  var parsedData = getParsedData();
2113
-
2114
1892
  if (dataFilter) {
2115
1893
  return dataFilter(parsedData);
2116
1894
  } else {
@@ -2118,56 +1896,41 @@ var jqtree = (function (exports) {
2118
1896
  }
2119
1897
  }
2120
1898
  }]);
2121
-
2122
1899
  return DataLoader;
2123
1900
  }();
2124
1901
 
2125
1902
  var KeyHandler = /*#__PURE__*/function () {
2126
1903
  function KeyHandler(treeWidget) {
2127
1904
  var _this = this;
2128
-
2129
1905
  _classCallCheck(this, KeyHandler);
2130
-
2131
1906
  _defineProperty(this, "treeWidget", void 0);
2132
-
2133
1907
  _defineProperty(this, "handleKeyDown", function (e) {
2134
1908
  if (!_this.canHandleKeyboard()) {
2135
1909
  return true;
2136
1910
  }
2137
-
2138
1911
  var selectedNode = _this.treeWidget.getSelectedNode();
2139
-
2140
1912
  if (!selectedNode) {
2141
1913
  return true;
2142
1914
  }
2143
-
2144
1915
  var key = e.which;
2145
-
2146
1916
  switch (key) {
2147
1917
  case KeyHandler.DOWN:
2148
1918
  return _this.moveDown(selectedNode);
2149
-
2150
1919
  case KeyHandler.UP:
2151
1920
  return _this.moveUp(selectedNode);
2152
-
2153
1921
  case KeyHandler.RIGHT:
2154
1922
  return _this.moveRight(selectedNode);
2155
-
2156
1923
  case KeyHandler.LEFT:
2157
1924
  return _this.moveLeft(selectedNode);
2158
-
2159
1925
  default:
2160
1926
  return true;
2161
1927
  }
2162
1928
  });
2163
-
2164
1929
  this.treeWidget = treeWidget;
2165
-
2166
1930
  if (treeWidget.options.keyboardSupport) {
2167
1931
  jQuery(document).on("keydown.jqtree", this.handleKeyDown);
2168
1932
  }
2169
1933
  }
2170
-
2171
1934
  _createClass(KeyHandler, [{
2172
1935
  key: "deinit",
2173
1936
  value: function deinit() {
@@ -2176,12 +1939,12 @@ var jqtree = (function (exports) {
2176
1939
  }, {
2177
1940
  key: "moveDown",
2178
1941
  value: function moveDown(selectedNode) {
2179
- return this.selectNode(selectedNode.getNextNode());
1942
+ return this.selectNode(selectedNode.getNextVisibleNode());
2180
1943
  }
2181
1944
  }, {
2182
1945
  key: "moveUp",
2183
1946
  value: function moveUp(selectedNode) {
2184
- return this.selectNode(selectedNode.getPreviousNode());
1947
+ return this.selectNode(selectedNode.getPreviousVisibleNode());
2185
1948
  }
2186
1949
  }, {
2187
1950
  key: "moveRight",
@@ -2192,7 +1955,7 @@ var jqtree = (function (exports) {
2192
1955
  // folder node
2193
1956
  if (selectedNode.is_open) {
2194
1957
  // Right moves to the first child of an open node
2195
- return this.selectNode(selectedNode.getNextNode());
1958
+ return this.selectNode(selectedNode.getNextVisibleNode());
2196
1959
  } else {
2197
1960
  // Right expands a closed node
2198
1961
  this.treeWidget.openNode(selectedNode);
@@ -2219,11 +1982,9 @@ var jqtree = (function (exports) {
2219
1982
  return true;
2220
1983
  } else {
2221
1984
  this.treeWidget.selectNode(node);
2222
-
2223
1985
  if (!this.treeWidget.scrollHandler.isScrolledIntoView(jQuery(node.element).find(".jqtree-element"))) {
2224
1986
  this.treeWidget.scrollToNode(node);
2225
1987
  }
2226
-
2227
1988
  return false;
2228
1989
  }
2229
1990
  }
@@ -2233,53 +1994,41 @@ var jqtree = (function (exports) {
2233
1994
  return (this.treeWidget.options.keyboardSupport || false) && this.treeWidget.selectNodeHandler.isFocusOnTree();
2234
1995
  }
2235
1996
  }]);
2236
-
2237
1997
  return KeyHandler;
2238
1998
  }();
2239
-
2240
1999
  _defineProperty(KeyHandler, "LEFT", 37);
2241
-
2242
2000
  _defineProperty(KeyHandler, "UP", 38);
2243
-
2244
2001
  _defineProperty(KeyHandler, "RIGHT", 39);
2245
-
2246
2002
  _defineProperty(KeyHandler, "DOWN", 40);
2247
2003
 
2248
2004
  var _register = function register(widgetClass, widgetName) {
2249
2005
  var getDataKey = function getDataKey() {
2250
2006
  return "simple_widget_".concat(widgetName);
2251
2007
  };
2252
-
2253
2008
  var getWidgetData = function getWidgetData(el, dataKey) {
2254
2009
  var widget = jQuery.data(el, dataKey);
2255
-
2256
2010
  if (widget && widget instanceof SimpleWidget) {
2257
2011
  return widget;
2258
2012
  } else {
2259
2013
  return null;
2260
2014
  }
2261
2015
  };
2262
-
2263
2016
  var createWidget = function createWidget($el, options) {
2264
2017
  var dataKey = getDataKey();
2265
-
2266
2018
  var _iterator = _createForOfIteratorHelper($el.get()),
2267
- _step;
2268
-
2019
+ _step;
2269
2020
  try {
2270
2021
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2271
2022
  var el = _step.value;
2272
2023
  var existingWidget = getWidgetData(el, dataKey);
2273
-
2274
2024
  if (!existingWidget) {
2275
2025
  var simpleWidgetClass = widgetClass;
2276
2026
  var widget = new simpleWidgetClass(el, options);
2277
-
2278
2027
  if (!jQuery.data(el, dataKey)) {
2279
2028
  jQuery.data(el, dataKey, widget);
2280
- } // Call init after setting data, so we can call methods
2281
-
2029
+ }
2282
2030
 
2031
+ // Call init after setting data, so we can call methods
2283
2032
  widget.init();
2284
2033
  }
2285
2034
  }
@@ -2288,25 +2037,19 @@ var jqtree = (function (exports) {
2288
2037
  } finally {
2289
2038
  _iterator.f();
2290
2039
  }
2291
-
2292
2040
  return $el;
2293
2041
  };
2294
-
2295
2042
  var destroyWidget = function destroyWidget($el) {
2296
2043
  var dataKey = getDataKey();
2297
-
2298
2044
  var _iterator2 = _createForOfIteratorHelper($el.get()),
2299
- _step2;
2300
-
2045
+ _step2;
2301
2046
  try {
2302
2047
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2303
2048
  var el = _step2.value;
2304
2049
  var widget = getWidgetData(el, dataKey);
2305
-
2306
2050
  if (widget) {
2307
2051
  widget.destroy();
2308
2052
  }
2309
-
2310
2053
  jQuery.removeData(el, dataKey);
2311
2054
  }
2312
2055
  } catch (err) {
@@ -2315,22 +2058,17 @@ var jqtree = (function (exports) {
2315
2058
  _iterator2.f();
2316
2059
  }
2317
2060
  };
2318
-
2319
2061
  var callFunction = function callFunction($el, functionName, args) {
2320
2062
  var result = null;
2321
-
2322
2063
  var _iterator3 = _createForOfIteratorHelper($el.get()),
2323
- _step3;
2324
-
2064
+ _step3;
2325
2065
  try {
2326
2066
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2327
2067
  var el = _step3.value;
2328
2068
  var widget = jQuery.data(el, getDataKey());
2329
-
2330
2069
  if (widget && widget instanceof SimpleWidget) {
2331
2070
  var simpleWidget = widget;
2332
2071
  var widgetFunction = simpleWidget[functionName];
2333
-
2334
2072
  if (widgetFunction && typeof widgetFunction === "function") {
2335
2073
  result = widgetFunction.apply(widget, args);
2336
2074
  }
@@ -2341,11 +2079,10 @@ var jqtree = (function (exports) {
2341
2079
  } finally {
2342
2080
  _iterator3.f();
2343
2081
  }
2344
-
2345
2082
  return result;
2346
- }; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2347
-
2083
+ };
2348
2084
 
2085
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2349
2086
  jQuery.fn[widgetName] = function (argument1) {
2350
2087
  if (!argument1) {
2351
2088
  return createWidget(this, null);
@@ -2354,7 +2091,6 @@ var jqtree = (function (exports) {
2354
2091
  return createWidget(this, options);
2355
2092
  } else if (typeof argument1 === "string" && argument1[0] !== "_") {
2356
2093
  var functionName = argument1;
2357
-
2358
2094
  if (functionName === "destroy") {
2359
2095
  return destroyWidget(this);
2360
2096
  } else if (functionName === "get_widget_class") {
@@ -2363,27 +2099,22 @@ var jqtree = (function (exports) {
2363
2099
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2364
2100
  args[_key - 1] = arguments[_key];
2365
2101
  }
2366
-
2367
2102
  return callFunction(this, functionName, args);
2368
2103
  }
2369
2104
  }
2370
2105
  };
2371
2106
  };
2372
-
2373
2107
  var SimpleWidget = /*#__PURE__*/function () {
2374
2108
  function SimpleWidget(el, options) {
2375
2109
  _classCallCheck(this, SimpleWidget);
2376
-
2377
2110
  _defineProperty(this, "options", void 0);
2378
-
2379
2111
  _defineProperty(this, "$el", void 0);
2112
+ this.$el = jQuery(el);
2380
2113
 
2381
- this.$el = jQuery(el); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2382
-
2114
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2383
2115
  var defaults = this.constructor["defaults"];
2384
2116
  this.options = _objectSpread2(_objectSpread2({}, defaults), options);
2385
2117
  }
2386
-
2387
2118
  _createClass(SimpleWidget, [{
2388
2119
  key: "destroy",
2389
2120
  value: function destroy() {
@@ -2391,11 +2122,13 @@ var jqtree = (function (exports) {
2391
2122
  }
2392
2123
  }, {
2393
2124
  key: "init",
2394
- value: function init() {//
2125
+ value: function init() {
2126
+ //
2395
2127
  }
2396
2128
  }, {
2397
2129
  key: "deinit",
2398
- value: function deinit() {//
2130
+ value: function deinit() {
2131
+ //
2399
2132
  }
2400
2133
  }], [{
2401
2134
  key: "register",
@@ -2403,10 +2136,8 @@ var jqtree = (function (exports) {
2403
2136
  _register(widgetClass, widgetName);
2404
2137
  }
2405
2138
  }]);
2406
-
2407
2139
  return SimpleWidget;
2408
2140
  }();
2409
-
2410
2141
  _defineProperty(SimpleWidget, "defaults", {});
2411
2142
 
2412
2143
  var getPositionInfoFromMouseEvent = function getPositionInfoFromMouseEvent(e) {
@@ -2417,7 +2148,6 @@ var jqtree = (function (exports) {
2417
2148
  originalEvent: e
2418
2149
  };
2419
2150
  };
2420
-
2421
2151
  var getPositionInfoFromTouch = function getPositionInfoFromTouch(touch, e) {
2422
2152
  return {
2423
2153
  pageX: touch.pageX,
@@ -2426,102 +2156,72 @@ var jqtree = (function (exports) {
2426
2156
  originalEvent: e
2427
2157
  };
2428
2158
  };
2429
-
2430
2159
  var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
2431
2160
  _inherits(MouseWidget, _SimpleWidget);
2432
-
2433
2161
  var _super = _createSuper(MouseWidget);
2434
-
2435
2162
  function MouseWidget() {
2436
2163
  var _this;
2437
-
2438
2164
  _classCallCheck(this, MouseWidget);
2439
-
2440
2165
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2441
2166
  args[_key] = arguments[_key];
2442
2167
  }
2443
-
2444
2168
  _this = _super.call.apply(_super, [this].concat(args));
2445
-
2446
2169
  _defineProperty(_assertThisInitialized(_this), "isMouseStarted", void 0);
2447
-
2448
2170
  _defineProperty(_assertThisInitialized(_this), "mouseDownInfo", void 0);
2449
-
2450
2171
  _defineProperty(_assertThisInitialized(_this), "mouseDelayTimer", void 0);
2451
-
2452
2172
  _defineProperty(_assertThisInitialized(_this), "isMouseDelayMet", void 0);
2453
-
2454
2173
  _defineProperty(_assertThisInitialized(_this), "mouseDown", function (e) {
2455
2174
  // Left mouse button?
2456
2175
  if (e.button !== 0) {
2457
2176
  return;
2458
2177
  }
2459
-
2460
2178
  var result = _this.handleMouseDown(getPositionInfoFromMouseEvent(e));
2461
-
2462
2179
  if (result && e.cancelable) {
2463
2180
  e.preventDefault();
2464
2181
  }
2465
2182
  });
2466
-
2467
2183
  _defineProperty(_assertThisInitialized(_this), "mouseMove", function (e) {
2468
2184
  _this.handleMouseMove(e, getPositionInfoFromMouseEvent(e));
2469
2185
  });
2470
-
2471
2186
  _defineProperty(_assertThisInitialized(_this), "mouseUp", function (e) {
2472
2187
  _this.handleMouseUp(getPositionInfoFromMouseEvent(e));
2473
2188
  });
2474
-
2475
2189
  _defineProperty(_assertThisInitialized(_this), "touchStart", function (e) {
2476
2190
  if (!e) {
2477
2191
  return;
2478
2192
  }
2479
-
2480
2193
  if (e.touches.length > 1) {
2481
2194
  return;
2482
2195
  }
2483
-
2484
2196
  var touch = e.changedTouches[0];
2485
-
2486
2197
  _this.handleMouseDown(getPositionInfoFromTouch(touch, e));
2487
2198
  });
2488
-
2489
2199
  _defineProperty(_assertThisInitialized(_this), "touchMove", function (e) {
2490
2200
  if (!e) {
2491
2201
  return;
2492
2202
  }
2493
-
2494
2203
  if (e.touches.length > 1) {
2495
2204
  return;
2496
2205
  }
2497
-
2498
2206
  var touch = e.changedTouches[0];
2499
-
2500
2207
  _this.handleMouseMove(e, getPositionInfoFromTouch(touch, e));
2501
2208
  });
2502
-
2503
2209
  _defineProperty(_assertThisInitialized(_this), "touchEnd", function (e) {
2504
2210
  if (!e) {
2505
2211
  return;
2506
2212
  }
2507
-
2508
2213
  if (e.touches.length > 1) {
2509
2214
  return;
2510
2215
  }
2511
-
2512
2216
  var touch = e.changedTouches[0];
2513
-
2514
2217
  _this.handleMouseUp(getPositionInfoFromTouch(touch, e));
2515
2218
  });
2516
-
2517
2219
  return _this;
2518
2220
  }
2519
-
2520
2221
  _createClass(MouseWidget, [{
2521
2222
  key: "init",
2522
2223
  value: function init() {
2523
2224
  var element = this.$el.get(0);
2524
-
2525
2225
  if (element) {
2526
2226
  element.addEventListener("mousedown", this.mouseDown, {
2527
2227
  passive: false
@@ -2530,7 +2230,6 @@ var jqtree = (function (exports) {
2530
2230
  passive: false
2531
2231
  });
2532
2232
  }
2533
-
2534
2233
  this.isMouseStarted = false;
2535
2234
  this.mouseDelayTimer = null;
2536
2235
  this.isMouseDelayMet = false;
@@ -2540,18 +2239,17 @@ var jqtree = (function (exports) {
2540
2239
  key: "deinit",
2541
2240
  value: function deinit() {
2542
2241
  var el = this.$el.get(0);
2543
-
2544
2242
  if (el) {
2545
2243
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2546
2244
  el.removeEventListener("mousedown", this.mouseDown, {
2547
2245
  passive: false
2548
- }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2246
+ });
2549
2247
 
2248
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2550
2249
  el.removeEventListener("touchstart", this.touchStart, {
2551
2250
  passive: false
2552
2251
  });
2553
2252
  }
2554
-
2555
2253
  this.removeMouseMoveEventListeners();
2556
2254
  }
2557
2255
  }, {
@@ -2561,13 +2259,10 @@ var jqtree = (function (exports) {
2561
2259
  if (this.isMouseStarted) {
2562
2260
  this.handleMouseUp(positionInfo);
2563
2261
  }
2564
-
2565
2262
  this.mouseDownInfo = positionInfo;
2566
-
2567
2263
  if (!this.mouseCapture(positionInfo)) {
2568
2264
  return false;
2569
2265
  }
2570
-
2571
2266
  this.handleStartMouse();
2572
2267
  return true;
2573
2268
  }
@@ -2587,7 +2282,6 @@ var jqtree = (function (exports) {
2587
2282
  passive: false
2588
2283
  });
2589
2284
  var mouseDelay = this.getMouseDelay();
2590
-
2591
2285
  if (mouseDelay) {
2592
2286
  this.startMouseDelayTimer(mouseDelay);
2593
2287
  } else {
@@ -2598,11 +2292,9 @@ var jqtree = (function (exports) {
2598
2292
  key: "startMouseDelayTimer",
2599
2293
  value: function startMouseDelayTimer(mouseDelay) {
2600
2294
  var _this2 = this;
2601
-
2602
2295
  if (this.mouseDelayTimer) {
2603
2296
  clearTimeout(this.mouseDelayTimer);
2604
2297
  }
2605
-
2606
2298
  this.mouseDelayTimer = window.setTimeout(function () {
2607
2299
  if (_this2.mouseDownInfo) {
2608
2300
  _this2.isMouseDelayMet = true;
@@ -2615,25 +2307,19 @@ var jqtree = (function (exports) {
2615
2307
  value: function handleMouseMove(e, positionInfo) {
2616
2308
  if (this.isMouseStarted) {
2617
2309
  this.mouseDrag(positionInfo);
2618
-
2619
2310
  if (e.cancelable) {
2620
2311
  e.preventDefault();
2621
2312
  }
2622
-
2623
2313
  return;
2624
2314
  }
2625
-
2626
2315
  if (!this.isMouseDelayMet) {
2627
2316
  return;
2628
2317
  }
2629
-
2630
2318
  if (this.mouseDownInfo) {
2631
2319
  this.isMouseStarted = this.mouseStart(this.mouseDownInfo) !== false;
2632
2320
  }
2633
-
2634
2321
  if (this.isMouseStarted) {
2635
2322
  this.mouseDrag(positionInfo);
2636
-
2637
2323
  if (e.cancelable) {
2638
2324
  e.preventDefault();
2639
2325
  }
@@ -2647,7 +2333,6 @@ var jqtree = (function (exports) {
2647
2333
  this.removeMouseMoveEventListeners();
2648
2334
  this.isMouseDelayMet = false;
2649
2335
  this.mouseDownInfo = null;
2650
-
2651
2336
  if (this.isMouseStarted) {
2652
2337
  this.isMouseStarted = false;
2653
2338
  this.mouseStop(positionInfo);
@@ -2659,41 +2344,35 @@ var jqtree = (function (exports) {
2659
2344
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2660
2345
  document.removeEventListener("mousemove", this.mouseMove, {
2661
2346
  passive: false
2662
- }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2663
-
2347
+ });
2348
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2664
2349
  document.removeEventListener("touchmove", this.touchMove, {
2665
2350
  passive: false
2666
- }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2667
-
2351
+ });
2352
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2668
2353
  document.removeEventListener("mouseup", this.mouseUp, {
2669
2354
  passive: false
2670
- }); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2671
-
2355
+ });
2356
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
2672
2357
  document.removeEventListener("touchend", this.touchEnd, {
2673
2358
  passive: false
2674
2359
  });
2675
2360
  }
2676
2361
  }]);
2677
-
2678
2362
  return MouseWidget;
2679
2363
  }(SimpleWidget);
2680
2364
 
2681
2365
  var SaveStateHandler = /*#__PURE__*/function () {
2682
2366
  function SaveStateHandler(treeWidget) {
2683
2367
  _classCallCheck(this, SaveStateHandler);
2684
-
2685
2368
  _defineProperty(this, "treeWidget", void 0);
2686
-
2687
2369
  _defineProperty(this, "_supportsLocalStorage", void 0);
2688
-
2689
2370
  this.treeWidget = treeWidget;
2690
2371
  }
2691
-
2692
2372
  _createClass(SaveStateHandler, [{
2693
2373
  key: "saveState",
2694
2374
  value: function saveState() {
2695
2375
  var state = JSON.stringify(this.getState());
2696
-
2697
2376
  if (this.treeWidget.options.onSetStateFromStorage) {
2698
2377
  this.treeWidget.options.onSetStateFromStorage(state);
2699
2378
  } else if (this.supportsLocalStorage()) {
@@ -2704,7 +2383,6 @@ var jqtree = (function (exports) {
2704
2383
  key: "getStateFromStorage",
2705
2384
  value: function getStateFromStorage() {
2706
2385
  var jsonData = this.loadFromStorage();
2707
-
2708
2386
  if (jsonData) {
2709
2387
  return this.parseState(jsonData);
2710
2388
  } else {
@@ -2715,44 +2393,36 @@ var jqtree = (function (exports) {
2715
2393
  key: "getState",
2716
2394
  value: function getState() {
2717
2395
  var _this = this;
2718
-
2719
2396
  var getOpenNodeIds = function getOpenNodeIds() {
2720
2397
  var openNodes = [];
2721
-
2722
2398
  _this.treeWidget.tree.iterate(function (node) {
2723
2399
  if (node.is_open && node.id && node.hasChildren()) {
2724
2400
  openNodes.push(node.id);
2725
2401
  }
2726
-
2727
2402
  return true;
2728
2403
  });
2729
-
2730
2404
  return openNodes;
2731
2405
  };
2732
-
2733
2406
  var getSelectedNodeIds = function getSelectedNodeIds() {
2734
2407
  var selectedNodeIds = [];
2735
-
2736
2408
  _this.treeWidget.getSelectedNodes().forEach(function (node) {
2737
2409
  if (node.id != null) {
2738
2410
  selectedNodeIds.push(node.id);
2739
2411
  }
2740
2412
  });
2741
-
2742
2413
  return selectedNodeIds;
2743
2414
  };
2744
-
2745
2415
  return {
2746
2416
  open_nodes: getOpenNodeIds(),
2747
2417
  selected_node: getSelectedNodeIds()
2748
2418
  };
2749
2419
  }
2420
+
2750
2421
  /*
2751
2422
  Set initial state
2752
2423
  Don't handle nodes that are loaded on demand
2753
2424
  result: must load on demand
2754
2425
  */
2755
-
2756
2426
  }, {
2757
2427
  key: "setInitialState",
2758
2428
  value: function setInitialState(state) {
@@ -2760,16 +2430,13 @@ var jqtree = (function (exports) {
2760
2430
  return false;
2761
2431
  } else {
2762
2432
  var mustLoadOnDemand = false;
2763
-
2764
2433
  if (state.open_nodes) {
2765
2434
  mustLoadOnDemand = this.openInitialNodes(state.open_nodes);
2766
2435
  }
2767
-
2768
2436
  if (state.selected_node) {
2769
2437
  this.resetSelection();
2770
2438
  this.selectInitialNodes(state.selected_node);
2771
2439
  }
2772
-
2773
2440
  return mustLoadOnDemand;
2774
2441
  }
2775
2442
  }
@@ -2786,7 +2453,6 @@ var jqtree = (function (exports) {
2786
2453
  key: "getNodeIdToBeSelected",
2787
2454
  value: function getNodeIdToBeSelected() {
2788
2455
  var state = this.getStateFromStorage();
2789
-
2790
2456
  if (state && state.selected_node) {
2791
2457
  return state.selected_node[0];
2792
2458
  } else {
@@ -2796,13 +2462,13 @@ var jqtree = (function (exports) {
2796
2462
  }, {
2797
2463
  key: "parseState",
2798
2464
  value: function parseState(jsonData) {
2799
- var state = JSON.parse(jsonData); // Check if selected_node is an int (instead of an array)
2465
+ var state = JSON.parse(jsonData);
2800
2466
 
2467
+ // Check if selected_node is an int (instead of an array)
2801
2468
  if (state && state.selected_node && isInt(state.selected_node)) {
2802
2469
  // Convert to array
2803
2470
  state.selected_node = [state.selected_node];
2804
2471
  }
2805
-
2806
2472
  return state;
2807
2473
  }
2808
2474
  }, {
@@ -2820,15 +2486,12 @@ var jqtree = (function (exports) {
2820
2486
  key: "openInitialNodes",
2821
2487
  value: function openInitialNodes(nodeIds) {
2822
2488
  var mustLoadOnDemand = false;
2823
-
2824
2489
  var _iterator = _createForOfIteratorHelper(nodeIds),
2825
- _step;
2826
-
2490
+ _step;
2827
2491
  try {
2828
2492
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2829
2493
  var nodeId = _step.value;
2830
2494
  var node = this.treeWidget.getNodeById(nodeId);
2831
-
2832
2495
  if (node) {
2833
2496
  if (!node.load_on_demand) {
2834
2497
  node.is_open = true;
@@ -2842,22 +2505,18 @@ var jqtree = (function (exports) {
2842
2505
  } finally {
2843
2506
  _iterator.f();
2844
2507
  }
2845
-
2846
2508
  return mustLoadOnDemand;
2847
2509
  }
2848
2510
  }, {
2849
2511
  key: "selectInitialNodes",
2850
2512
  value: function selectInitialNodes(nodeIds) {
2851
2513
  var selectCount = 0;
2852
-
2853
2514
  var _iterator2 = _createForOfIteratorHelper(nodeIds),
2854
- _step2;
2855
-
2515
+ _step2;
2856
2516
  try {
2857
2517
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2858
2518
  var nodeId = _step2.value;
2859
2519
  var node = this.treeWidget.getNodeById(nodeId);
2860
-
2861
2520
  if (node) {
2862
2521
  selectCount += 1;
2863
2522
  this.treeWidget.selectNodeHandler.addToSelection(node);
@@ -2868,7 +2527,6 @@ var jqtree = (function (exports) {
2868
2527
  } finally {
2869
2528
  _iterator2.f();
2870
2529
  }
2871
-
2872
2530
  return selectCount !== 0;
2873
2531
  }
2874
2532
  }, {
@@ -2884,22 +2542,16 @@ var jqtree = (function (exports) {
2884
2542
  key: "doSetInitialStateOnDemand",
2885
2543
  value: function doSetInitialStateOnDemand(nodeIdsParam, selectedNodes, cbFinished) {
2886
2544
  var _this2 = this;
2887
-
2888
2545
  var loadingCount = 0;
2889
2546
  var nodeIds = nodeIdsParam;
2890
-
2891
2547
  var openNodes = function openNodes() {
2892
2548
  var newNodesIds = [];
2893
-
2894
2549
  var _iterator3 = _createForOfIteratorHelper(nodeIds),
2895
- _step3;
2896
-
2550
+ _step3;
2897
2551
  try {
2898
2552
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2899
2553
  var nodeId = _step3.value;
2900
-
2901
2554
  var node = _this2.treeWidget.getNodeById(nodeId);
2902
-
2903
2555
  if (!node) {
2904
2556
  newNodesIds.push(nodeId);
2905
2557
  } else {
@@ -2917,27 +2569,21 @@ var jqtree = (function (exports) {
2917
2569
  } finally {
2918
2570
  _iterator3.f();
2919
2571
  }
2920
-
2921
2572
  nodeIds = newNodesIds;
2922
-
2923
2573
  if (_this2.selectInitialNodes(selectedNodes)) {
2924
2574
  _this2.treeWidget._refreshElements(null);
2925
2575
  }
2926
-
2927
2576
  if (loadingCount === 0) {
2928
2577
  cbFinished();
2929
2578
  }
2930
2579
  };
2931
-
2932
2580
  var loadAndOpenNode = function loadAndOpenNode(node) {
2933
2581
  loadingCount += 1;
2934
-
2935
2582
  _this2.treeWidget._openNode(node, false, function () {
2936
2583
  loadingCount -= 1;
2937
2584
  openNodes();
2938
2585
  });
2939
2586
  };
2940
-
2941
2587
  openNodes();
2942
2588
  }
2943
2589
  }, {
@@ -2965,41 +2611,30 @@ var jqtree = (function (exports) {
2965
2611
  } catch (error) {
2966
2612
  return false;
2967
2613
  }
2968
-
2969
2614
  return true;
2970
2615
  }
2971
2616
  };
2972
-
2973
2617
  if (this._supportsLocalStorage == null) {
2974
2618
  this._supportsLocalStorage = testSupport();
2975
2619
  }
2976
-
2977
2620
  return this._supportsLocalStorage;
2978
2621
  }
2979
2622
  }]);
2980
-
2981
2623
  return SaveStateHandler;
2982
2624
  }();
2983
2625
 
2984
2626
  var ScrollHandler = /*#__PURE__*/function () {
2985
2627
  function ScrollHandler(treeWidget) {
2986
2628
  _classCallCheck(this, ScrollHandler);
2987
-
2988
2629
  _defineProperty(this, "treeWidget", void 0);
2989
-
2990
2630
  _defineProperty(this, "previousTop", void 0);
2991
-
2992
2631
  _defineProperty(this, "isInitialized", void 0);
2993
-
2994
2632
  _defineProperty(this, "$scrollParent", void 0);
2995
-
2996
2633
  _defineProperty(this, "scrollParentTop", void 0);
2997
-
2998
2634
  this.treeWidget = treeWidget;
2999
2635
  this.previousTop = -1;
3000
2636
  this.isInitialized = false;
3001
2637
  }
3002
-
3003
2638
  _createClass(ScrollHandler, [{
3004
2639
  key: "checkScrolling",
3005
2640
  value: function checkScrolling() {
@@ -3011,7 +2646,6 @@ var jqtree = (function (exports) {
3011
2646
  key: "scrollToY",
3012
2647
  value: function scrollToY(top) {
3013
2648
  this.ensureInit();
3014
-
3015
2649
  if (this.$scrollParent) {
3016
2650
  this.$scrollParent[0].scrollTop = top;
3017
2651
  } else {
@@ -3029,7 +2663,6 @@ var jqtree = (function (exports) {
3029
2663
  var elementTop;
3030
2664
  var viewTop;
3031
2665
  var elHeight = $element.height() || 0;
3032
-
3033
2666
  if (this.$scrollParent) {
3034
2667
  viewTop = 0;
3035
2668
  viewBottom = this.$scrollParent.height() || 0;
@@ -3041,13 +2674,10 @@ var jqtree = (function (exports) {
3041
2674
  viewTop = jQuery(window).scrollTop() || 0;
3042
2675
  var windowHeight = jQuery(window).height() || 0;
3043
2676
  viewBottom = viewTop + windowHeight;
3044
-
3045
2677
  var _offset = $element.offset();
3046
-
3047
2678
  elementTop = _offset ? _offset.top : 0;
3048
2679
  elementBottom = elementTop + elHeight;
3049
2680
  }
3050
-
3051
2681
  return elementBottom <= viewBottom && elementTop >= viewTop;
3052
2682
  }
3053
2683
  }, {
@@ -3063,68 +2693,46 @@ var jqtree = (function (exports) {
3063
2693
  key: "initScrollParent",
3064
2694
  value: function initScrollParent() {
3065
2695
  var _this = this;
3066
-
3067
2696
  var getParentWithOverflow = function getParentWithOverflow() {
3068
2697
  var cssAttributes = ["overflow", "overflow-y"];
3069
-
3070
2698
  var hasOverFlow = function hasOverFlow($el) {
3071
- var _iterator = _createForOfIteratorHelper(cssAttributes),
3072
- _step;
3073
-
3074
- try {
3075
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
3076
- var attr = _step.value;
3077
- var overflowValue = $el.css(attr);
3078
-
3079
- if (overflowValue === "auto" || overflowValue === "scroll") {
3080
- return true;
3081
- }
2699
+ for (var _i = 0, _cssAttributes = cssAttributes; _i < _cssAttributes.length; _i++) {
2700
+ var attr = _cssAttributes[_i];
2701
+ var overflowValue = $el.css(attr);
2702
+ if (overflowValue === "auto" || overflowValue === "scroll") {
2703
+ return true;
3082
2704
  }
3083
- } catch (err) {
3084
- _iterator.e(err);
3085
- } finally {
3086
- _iterator.f();
3087
2705
  }
3088
-
3089
2706
  return false;
3090
2707
  };
3091
-
3092
2708
  if (hasOverFlow(_this.treeWidget.$el)) {
3093
2709
  return _this.treeWidget.$el;
3094
2710
  }
3095
-
3096
- var _iterator2 = _createForOfIteratorHelper(_this.treeWidget.$el.parents().get()),
3097
- _step2;
3098
-
2711
+ var _iterator = _createForOfIteratorHelper(_this.treeWidget.$el.parents().get()),
2712
+ _step;
3099
2713
  try {
3100
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3101
- var el = _step2.value;
2714
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2715
+ var el = _step.value;
3102
2716
  var $el = jQuery(el);
3103
-
3104
2717
  if (hasOverFlow($el)) {
3105
2718
  return $el;
3106
2719
  }
3107
2720
  }
3108
2721
  } catch (err) {
3109
- _iterator2.e(err);
2722
+ _iterator.e(err);
3110
2723
  } finally {
3111
- _iterator2.f();
2724
+ _iterator.f();
3112
2725
  }
3113
-
3114
2726
  return null;
3115
2727
  };
3116
-
3117
2728
  var setDocumentAsScrollParent = function setDocumentAsScrollParent() {
3118
2729
  _this.scrollParentTop = 0;
3119
2730
  _this.$scrollParent = null;
3120
2731
  };
3121
-
3122
2732
  if (this.treeWidget.$el.css("position") === "fixed") {
3123
2733
  setDocumentAsScrollParent();
3124
2734
  }
3125
-
3126
2735
  var $scrollParent = getParentWithOverflow();
3127
-
3128
2736
  if ($scrollParent && $scrollParent.length && $scrollParent[0].tagName !== "HTML") {
3129
2737
  this.$scrollParent = $scrollParent;
3130
2738
  var offset = this.$scrollParent.offset();
@@ -3132,7 +2740,6 @@ var jqtree = (function (exports) {
3132
2740
  } else {
3133
2741
  setDocumentAsScrollParent();
3134
2742
  }
3135
-
3136
2743
  this.isInitialized = true;
3137
2744
  }
3138
2745
  }, {
@@ -3146,13 +2753,10 @@ var jqtree = (function (exports) {
3146
2753
  key: "handleVerticalScrollingWithScrollParent",
3147
2754
  value: function handleVerticalScrollingWithScrollParent(area) {
3148
2755
  var scrollParent = this.$scrollParent && this.$scrollParent[0];
3149
-
3150
2756
  if (!scrollParent) {
3151
2757
  return;
3152
2758
  }
3153
-
3154
2759
  var distanceBottom = this.scrollParentTop + scrollParent.offsetHeight - area.bottom;
3155
-
3156
2760
  if (distanceBottom < 20) {
3157
2761
  scrollParent.scrollTop += 20;
3158
2762
  this.treeWidget.refreshHitAreas();
@@ -3168,12 +2772,10 @@ var jqtree = (function (exports) {
3168
2772
  value: function handleVerticalScrollingWithDocument(area) {
3169
2773
  var scrollTop = jQuery(document).scrollTop() || 0;
3170
2774
  var distanceTop = area.top - scrollTop;
3171
-
3172
2775
  if (distanceTop < 20) {
3173
2776
  jQuery(document).scrollTop(scrollTop - 20);
3174
2777
  } else {
3175
2778
  var windowHeight = jQuery(window).height() || 0;
3176
-
3177
2779
  if (windowHeight - (area.bottom - scrollTop) < 20) {
3178
2780
  jQuery(document).scrollTop(scrollTop + 20);
3179
2781
  }
@@ -3183,10 +2785,8 @@ var jqtree = (function (exports) {
3183
2785
  key: "checkVerticalScrolling",
3184
2786
  value: function checkVerticalScrolling() {
3185
2787
  var hoveredArea = this.treeWidget.dndHandler.hoveredArea;
3186
-
3187
2788
  if (hoveredArea && hoveredArea.top !== this.previousTop) {
3188
2789
  this.previousTop = hoveredArea.top;
3189
-
3190
2790
  if (this.$scrollParent) {
3191
2791
  this.handleVerticalScrollingWithScrollParent(hoveredArea);
3192
2792
  } else {
@@ -3198,11 +2798,9 @@ var jqtree = (function (exports) {
3198
2798
  key: "checkHorizontalScrolling",
3199
2799
  value: function checkHorizontalScrolling() {
3200
2800
  var positionInfo = this.treeWidget.dndHandler.positionInfo;
3201
-
3202
2801
  if (!positionInfo) {
3203
2802
  return;
3204
2803
  }
3205
-
3206
2804
  if (this.$scrollParent) {
3207
2805
  this.handleHorizontalScrollingWithParent(positionInfo);
3208
2806
  } else {
@@ -3215,14 +2813,11 @@ var jqtree = (function (exports) {
3215
2813
  if (positionInfo.pageX === undefined || positionInfo.pageY === undefined) {
3216
2814
  return;
3217
2815
  }
3218
-
3219
2816
  var $scrollParent = this.$scrollParent;
3220
2817
  var scrollParentOffset = $scrollParent && $scrollParent.offset();
3221
-
3222
2818
  if (!($scrollParent && scrollParentOffset)) {
3223
2819
  return;
3224
2820
  }
3225
-
3226
2821
  var scrollParent = $scrollParent[0];
3227
2822
  var canScrollRight = scrollParent.scrollLeft + scrollParent.clientWidth < scrollParent.scrollWidth;
3228
2823
  var canScrollLeft = scrollParent.scrollLeft > 0;
@@ -3230,7 +2825,6 @@ var jqtree = (function (exports) {
3230
2825
  var leftEdge = scrollParentOffset.left;
3231
2826
  var isNearRightEdge = positionInfo.pageX > rightEdge - 20;
3232
2827
  var isNearLeftEdge = positionInfo.pageX < leftEdge + 20;
3233
-
3234
2828
  if (isNearRightEdge && canScrollRight) {
3235
2829
  scrollParent.scrollLeft = Math.min(scrollParent.scrollLeft + 20, scrollParent.scrollWidth);
3236
2830
  } else if (isNearLeftEdge && canScrollLeft) {
@@ -3243,14 +2837,12 @@ var jqtree = (function (exports) {
3243
2837
  if (positionInfo.pageX === undefined || positionInfo.pageY === undefined) {
3244
2838
  return;
3245
2839
  }
3246
-
3247
2840
  var $document = jQuery(document);
3248
2841
  var scrollLeft = $document.scrollLeft() || 0;
3249
2842
  var windowWidth = jQuery(window).width() || 0;
3250
2843
  var canScrollLeft = scrollLeft > 0;
3251
2844
  var isNearRightEdge = positionInfo.pageX > windowWidth - 20;
3252
2845
  var isNearLeftEdge = positionInfo.pageX - scrollLeft < 20;
3253
-
3254
2846
  if (isNearRightEdge) {
3255
2847
  $document.scrollLeft(scrollLeft + 20);
3256
2848
  } else if (isNearLeftEdge && canScrollLeft) {
@@ -3258,30 +2850,23 @@ var jqtree = (function (exports) {
3258
2850
  }
3259
2851
  }
3260
2852
  }]);
3261
-
3262
2853
  return ScrollHandler;
3263
2854
  }();
3264
2855
 
3265
2856
  var SelectNodeHandler = /*#__PURE__*/function () {
3266
2857
  function SelectNodeHandler(treeWidget) {
3267
2858
  _classCallCheck(this, SelectNodeHandler);
3268
-
3269
2859
  _defineProperty(this, "treeWidget", void 0);
3270
-
3271
2860
  _defineProperty(this, "selectedNodes", void 0);
3272
-
3273
2861
  _defineProperty(this, "selectedSingleNode", void 0);
3274
-
3275
2862
  this.treeWidget = treeWidget;
3276
2863
  this.selectedNodes = new Set();
3277
2864
  this.clear();
3278
2865
  }
3279
-
3280
2866
  _createClass(SelectNodeHandler, [{
3281
2867
  key: "getSelectedNode",
3282
2868
  value: function getSelectedNode() {
3283
2869
  var selectedNodes = this.getSelectedNodes();
3284
-
3285
2870
  if (selectedNodes.length) {
3286
2871
  return selectedNodes[0];
3287
2872
  } else {
@@ -3292,14 +2877,12 @@ var jqtree = (function (exports) {
3292
2877
  key: "getSelectedNodes",
3293
2878
  value: function getSelectedNodes() {
3294
2879
  var _this = this;
3295
-
3296
2880
  if (this.selectedSingleNode) {
3297
2881
  return [this.selectedSingleNode];
3298
2882
  } else {
3299
2883
  var selectedNodes = [];
3300
2884
  this.selectedNodes.forEach(function (id) {
3301
2885
  var node = _this.treeWidget.getNodeById(id);
3302
-
3303
2886
  if (node) {
3304
2887
  selectedNodes.push(node);
3305
2888
  }
@@ -3318,17 +2901,14 @@ var jqtree = (function (exports) {
3318
2901
  }
3319
2902
  } else {
3320
2903
  var selectedNodes = [];
3321
-
3322
2904
  for (var id in this.selectedNodes) {
3323
2905
  if (Object.prototype.hasOwnProperty.call(this.selectedNodes, id)) {
3324
2906
  var node = this.treeWidget.getNodeById(id);
3325
-
3326
2907
  if (node && parent.isParentOf(node)) {
3327
2908
  selectedNodes.push(node);
3328
2909
  }
3329
2910
  }
3330
2911
  }
3331
-
3332
2912
  return selectedNodes;
3333
2913
  }
3334
2914
  }
@@ -3353,22 +2933,18 @@ var jqtree = (function (exports) {
3353
2933
  key: "removeFromSelection",
3354
2934
  value: function removeFromSelection(node) {
3355
2935
  var _this2 = this;
3356
-
3357
2936
  var includeChildren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3358
-
3359
2937
  if (node.id == null) {
3360
2938
  if (this.selectedSingleNode && node.element === this.selectedSingleNode.element) {
3361
2939
  this.selectedSingleNode = null;
3362
2940
  }
3363
2941
  } else {
3364
2942
  this.selectedNodes["delete"](node.id);
3365
-
3366
2943
  if (includeChildren) {
3367
2944
  node.iterate(function () {
3368
2945
  if (node.id != null) {
3369
2946
  _this2.selectedNodes["delete"](node.id);
3370
2947
  }
3371
-
3372
2948
  return true;
3373
2949
  });
3374
2950
  }
@@ -3390,37 +2966,28 @@ var jqtree = (function (exports) {
3390
2966
  return Boolean(activeElement && activeElement.tagName === "SPAN" && this.treeWidget._containsElement(activeElement));
3391
2967
  }
3392
2968
  }]);
3393
-
3394
2969
  return SelectNodeHandler;
3395
2970
  }();
3396
2971
 
3397
2972
  var NodeElement = /*#__PURE__*/function () {
3398
2973
  function NodeElement(node, treeWidget) {
3399
2974
  _classCallCheck(this, NodeElement);
3400
-
3401
2975
  _defineProperty(this, "node", void 0);
3402
-
3403
2976
  _defineProperty(this, "$element", void 0);
3404
-
3405
2977
  _defineProperty(this, "treeWidget", void 0);
3406
-
3407
2978
  this.init(node, treeWidget);
3408
2979
  }
3409
-
3410
2980
  _createClass(NodeElement, [{
3411
2981
  key: "init",
3412
2982
  value: function init(node, treeWidget) {
3413
2983
  this.node = node;
3414
2984
  this.treeWidget = treeWidget;
3415
-
3416
2985
  if (!node.element) {
3417
2986
  var element = this.treeWidget.element.get(0);
3418
-
3419
2987
  if (element) {
3420
2988
  node.element = element;
3421
2989
  }
3422
2990
  }
3423
-
3424
2991
  if (node.element) {
3425
2992
  this.$element = jQuery(node.element);
3426
2993
  }
@@ -3438,13 +3005,11 @@ var jqtree = (function (exports) {
3438
3005
  key: "select",
3439
3006
  value: function select(mustSetFocus) {
3440
3007
  var _this$treeWidget$opti;
3441
-
3442
3008
  var $li = this.getLi();
3443
3009
  $li.addClass("jqtree-selected");
3444
3010
  $li.attr("aria-selected", "true");
3445
3011
  var $span = this.getSpan();
3446
3012
  $span.attr("tabindex", (_this$treeWidget$opti = this.treeWidget.options.tabIndex) !== null && _this$treeWidget$opti !== void 0 ? _this$treeWidget$opti : null);
3447
-
3448
3013
  if (mustSetFocus) {
3449
3014
  $span.trigger("focus");
3450
3015
  }
@@ -3480,61 +3045,45 @@ var jqtree = (function (exports) {
3480
3045
  return position === Position.Inside;
3481
3046
  }
3482
3047
  }]);
3483
-
3484
3048
  return NodeElement;
3485
3049
  }();
3486
3050
  var FolderElement = /*#__PURE__*/function (_NodeElement) {
3487
3051
  _inherits(FolderElement, _NodeElement);
3488
-
3489
3052
  var _super = _createSuper(FolderElement);
3490
-
3491
3053
  function FolderElement() {
3492
3054
  _classCallCheck(this, FolderElement);
3493
-
3494
3055
  return _super.apply(this, arguments);
3495
3056
  }
3496
-
3497
3057
  _createClass(FolderElement, [{
3498
3058
  key: "open",
3499
3059
  value: function open(onFinished) {
3500
3060
  var _this = this;
3501
-
3502
3061
  var slide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
3503
3062
  var animationSpeed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "fast";
3504
-
3505
3063
  if (this.node.is_open) {
3506
3064
  return;
3507
3065
  }
3508
-
3509
3066
  this.node.is_open = true;
3510
3067
  var $button = this.getButton();
3511
3068
  $button.removeClass("jqtree-closed");
3512
3069
  $button.html("");
3513
3070
  var buttonEl = $button.get(0);
3514
-
3515
3071
  if (buttonEl) {
3516
3072
  var icon = this.treeWidget.renderer.openedIconElement.cloneNode(true);
3517
3073
  buttonEl.appendChild(icon);
3518
3074
  }
3519
-
3520
3075
  var doOpen = function doOpen() {
3521
3076
  var $li = _this.getLi();
3522
-
3523
3077
  $li.removeClass("jqtree-closed");
3524
-
3525
3078
  var $span = _this.getSpan();
3526
-
3527
3079
  $span.attr("aria-expanded", "true");
3528
-
3529
3080
  if (onFinished) {
3530
3081
  onFinished(_this.node);
3531
3082
  }
3532
-
3533
3083
  _this.treeWidget._triggerEvent("tree.open", {
3534
3084
  node: _this.node
3535
3085
  });
3536
3086
  };
3537
-
3538
3087
  if (slide) {
3539
3088
  this.getUl().slideDown(animationSpeed, doOpen);
3540
3089
  } else {
@@ -3546,39 +3095,29 @@ var jqtree = (function (exports) {
3546
3095
  key: "close",
3547
3096
  value: function close() {
3548
3097
  var _this2 = this;
3549
-
3550
3098
  var slide = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
3551
3099
  var animationSpeed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "fast";
3552
-
3553
3100
  if (!this.node.is_open) {
3554
3101
  return;
3555
3102
  }
3556
-
3557
3103
  this.node.is_open = false;
3558
3104
  var $button = this.getButton();
3559
3105
  $button.addClass("jqtree-closed");
3560
3106
  $button.html("");
3561
3107
  var buttonEl = $button.get(0);
3562
-
3563
3108
  if (buttonEl) {
3564
3109
  var icon = this.treeWidget.renderer.closedIconElement.cloneNode(true);
3565
3110
  buttonEl.appendChild(icon);
3566
3111
  }
3567
-
3568
3112
  var doClose = function doClose() {
3569
3113
  var $li = _this2.getLi();
3570
-
3571
3114
  $li.addClass("jqtree-closed");
3572
-
3573
3115
  var $span = _this2.getSpan();
3574
-
3575
3116
  $span.attr("aria-expanded", "false");
3576
-
3577
3117
  _this2.treeWidget._triggerEvent("tree.close", {
3578
3118
  node: _this2.node
3579
3119
  });
3580
3120
  };
3581
-
3582
3121
  if (slide) {
3583
3122
  this.getUl().slideUp(animationSpeed, doClose);
3584
3123
  } else {
@@ -3597,15 +3136,12 @@ var jqtree = (function (exports) {
3597
3136
  return this.$element.children(".jqtree-element").find("a.jqtree-toggler");
3598
3137
  }
3599
3138
  }]);
3600
-
3601
3139
  return FolderElement;
3602
3140
  }(NodeElement);
3603
3141
  var BorderDropHint = /*#__PURE__*/function () {
3604
3142
  function BorderDropHint($element, scrollLeft) {
3605
3143
  _classCallCheck(this, BorderDropHint);
3606
-
3607
3144
  _defineProperty(this, "$hint", void 0);
3608
-
3609
3145
  var $div = $element.children(".jqtree-element");
3610
3146
  var elWidth = $element.width() || 0;
3611
3147
  var width = Math.max(elWidth + scrollLeft - 4, 0);
@@ -3618,31 +3154,23 @@ var jqtree = (function (exports) {
3618
3154
  height: height
3619
3155
  });
3620
3156
  }
3621
-
3622
3157
  _createClass(BorderDropHint, [{
3623
3158
  key: "remove",
3624
3159
  value: function remove() {
3625
3160
  this.$hint.remove();
3626
3161
  }
3627
3162
  }]);
3628
-
3629
3163
  return BorderDropHint;
3630
3164
  }();
3631
-
3632
3165
  var GhostDropHint = /*#__PURE__*/function () {
3633
3166
  function GhostDropHint(node, $element, position) {
3634
3167
  _classCallCheck(this, GhostDropHint);
3635
-
3636
3168
  _defineProperty(this, "$element", void 0);
3637
-
3638
3169
  _defineProperty(this, "node", void 0);
3639
-
3640
3170
  _defineProperty(this, "$ghost", void 0);
3641
-
3642
3171
  this.$element = $element;
3643
3172
  this.node = node;
3644
3173
  this.$ghost = jQuery("<li class=\"jqtree_common jqtree-ghost\"><span class=\"jqtree_common jqtree-circle\"></span>\n <span class=\"jqtree_common jqtree-line\"></span></li>");
3645
-
3646
3174
  if (position === Position.After) {
3647
3175
  this.moveAfter();
3648
3176
  } else if (position === Position.Before) {
@@ -3655,7 +3183,6 @@ var jqtree = (function (exports) {
3655
3183
  }
3656
3184
  }
3657
3185
  }
3658
-
3659
3186
  _createClass(GhostDropHint, [{
3660
3187
  key: "remove",
3661
3188
  value: function remove() {
@@ -3675,7 +3202,6 @@ var jqtree = (function (exports) {
3675
3202
  key: "moveInsideOpenFolder",
3676
3203
  value: function moveInsideOpenFolder() {
3677
3204
  var childElement = this.node.children[0].element;
3678
-
3679
3205
  if (childElement) {
3680
3206
  jQuery(childElement).before(this.$ghost);
3681
3207
  }
@@ -3687,7 +3213,6 @@ var jqtree = (function (exports) {
3687
3213
  this.$ghost.addClass("jqtree-inside");
3688
3214
  }
3689
3215
  }]);
3690
-
3691
3216
  return GhostDropHint;
3692
3217
  }();
3693
3218
 
@@ -3695,67 +3220,45 @@ var jqtree = (function (exports) {
3695
3220
  var PARAM_IS_EMPTY = "Parameter is empty: ";
3696
3221
  var JqTreeWidget = /*#__PURE__*/function (_MouseWidget) {
3697
3222
  _inherits(JqTreeWidget, _MouseWidget);
3698
-
3699
3223
  var _super = _createSuper(JqTreeWidget);
3700
-
3701
3224
  function JqTreeWidget() {
3702
3225
  var _this;
3703
-
3704
3226
  _classCallCheck(this, JqTreeWidget);
3705
-
3706
3227
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3707
3228
  args[_key] = arguments[_key];
3708
3229
  }
3709
-
3710
3230
  _this = _super.call.apply(_super, [this].concat(args));
3711
-
3712
3231
  _defineProperty(_assertThisInitialized(_this), "element", void 0);
3713
-
3714
3232
  _defineProperty(_assertThisInitialized(_this), "tree", void 0);
3715
-
3716
3233
  _defineProperty(_assertThisInitialized(_this), "dndHandler", void 0);
3717
-
3718
3234
  _defineProperty(_assertThisInitialized(_this), "renderer", void 0);
3719
-
3720
3235
  _defineProperty(_assertThisInitialized(_this), "dataLoader", void 0);
3721
-
3722
3236
  _defineProperty(_assertThisInitialized(_this), "scrollHandler", void 0);
3723
-
3724
3237
  _defineProperty(_assertThisInitialized(_this), "selectNodeHandler", void 0);
3725
-
3726
3238
  _defineProperty(_assertThisInitialized(_this), "isInitialized", void 0);
3727
-
3728
3239
  _defineProperty(_assertThisInitialized(_this), "saveStateHandler", void 0);
3729
-
3730
3240
  _defineProperty(_assertThisInitialized(_this), "keyHandler", void 0);
3731
-
3732
3241
  _defineProperty(_assertThisInitialized(_this), "handleClick", function (e) {
3733
3242
  var clickTarget = _this.getClickTarget(e.target);
3734
-
3735
3243
  if (clickTarget) {
3736
3244
  if (clickTarget.type === "button") {
3737
3245
  _this.toggle(clickTarget.node, _this.options.slide);
3738
-
3739
3246
  e.preventDefault();
3740
3247
  e.stopPropagation();
3741
3248
  } else if (clickTarget.type === "label") {
3742
3249
  var _node2 = clickTarget.node;
3743
-
3744
3250
  var event = _this._triggerEvent("tree.click", {
3745
3251
  node: _node2,
3746
3252
  click_event: e
3747
3253
  });
3748
-
3749
3254
  if (!event.isDefaultPrevented()) {
3750
3255
  _this.doSelectNode(_node2);
3751
3256
  }
3752
3257
  }
3753
3258
  }
3754
3259
  });
3755
-
3756
3260
  _defineProperty(_assertThisInitialized(_this), "handleDblclick", function (e) {
3757
3261
  var clickTarget = _this.getClickTarget(e.target);
3758
-
3759
3262
  if ((clickTarget === null || clickTarget === void 0 ? void 0 : clickTarget.type) === "label") {
3760
3263
  _this._triggerEvent("tree.dblclick", {
3761
3264
  node: clickTarget.node,
@@ -3763,49 +3266,37 @@ var jqtree = (function (exports) {
3763
3266
  });
3764
3267
  }
3765
3268
  });
3766
-
3767
3269
  _defineProperty(_assertThisInitialized(_this), "handleContextmenu", function (e) {
3768
3270
  var $div = jQuery(e.target).closest("ul.jqtree-tree .jqtree-element");
3769
-
3770
3271
  if ($div.length) {
3771
3272
  var _node3 = _this.getNode($div);
3772
-
3773
3273
  if (_node3) {
3774
3274
  e.preventDefault();
3775
3275
  e.stopPropagation();
3776
-
3777
3276
  _this._triggerEvent("tree.contextmenu", {
3778
3277
  node: _node3,
3779
3278
  click_event: e
3780
3279
  });
3781
-
3782
3280
  return false;
3783
3281
  }
3784
3282
  }
3785
-
3786
3283
  return null;
3787
3284
  });
3788
-
3789
3285
  return _this;
3790
3286
  }
3791
-
3792
3287
  _createClass(JqTreeWidget, [{
3793
3288
  key: "toggle",
3794
3289
  value: function toggle(node) {
3795
3290
  var slideParam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
3796
-
3797
3291
  if (!node) {
3798
3292
  throw Error(NODE_PARAM_IS_EMPTY);
3799
3293
  }
3800
-
3801
3294
  var slide = slideParam !== null && slideParam !== void 0 ? slideParam : this.options.slide;
3802
-
3803
3295
  if (node.is_open) {
3804
3296
  this.closeNode(node, slide);
3805
3297
  } else {
3806
3298
  this.openNode(node, slide);
3807
3299
  }
3808
-
3809
3300
  return this.element;
3810
3301
  }
3811
3302
  }, {
@@ -3835,6 +3326,7 @@ var jqtree = (function (exports) {
3835
3326
  this.doLoadData(data, parentNode);
3836
3327
  return this.element;
3837
3328
  }
3329
+
3838
3330
  /*
3839
3331
  signatures:
3840
3332
  - loadDataFromUrl(url, parent_node=null, on_finished=null)
@@ -3848,7 +3340,6 @@ var jqtree = (function (exports) {
3848
3340
  loadDataFromUrl(null, function() { console.log('finished'); });
3849
3341
  loadDataFromUrl(node1, function() { console.log('finished'); });
3850
3342
  */
3851
-
3852
3343
  }, {
3853
3344
  key: "loadDataFromUrl",
3854
3345
  value: function loadDataFromUrl(param1, param2, param3) {
@@ -3859,7 +3350,6 @@ var jqtree = (function (exports) {
3859
3350
  // first parameter is not url
3860
3351
  this.doLoadDataFromUrl(null, param1, param2);
3861
3352
  }
3862
-
3863
3353
  return this.element;
3864
3354
  }
3865
3355
  }, {
@@ -3872,7 +3362,6 @@ var jqtree = (function (exports) {
3872
3362
  key: "refresh",
3873
3363
  value: function refresh() {
3874
3364
  this._refreshElements(null);
3875
-
3876
3365
  return this.element;
3877
3366
  }
3878
3367
  }, {
@@ -3909,15 +3398,12 @@ var jqtree = (function (exports) {
3909
3398
  key: "openNode",
3910
3399
  value: function openNode(node, param1, param2) {
3911
3400
  var _this2 = this;
3912
-
3913
3401
  if (!node) {
3914
3402
  throw Error(NODE_PARAM_IS_EMPTY);
3915
3403
  }
3916
-
3917
3404
  var parseParams = function parseParams() {
3918
3405
  var onFinished;
3919
3406
  var slide;
3920
-
3921
3407
  if (isFunction(param1)) {
3922
3408
  onFinished = param1;
3923
3409
  slide = null;
@@ -3925,23 +3411,17 @@ var jqtree = (function (exports) {
3925
3411
  slide = param1;
3926
3412
  onFinished = param2;
3927
3413
  }
3928
-
3929
3414
  if (slide == null) {
3930
3415
  var _this2$options$slide;
3931
-
3932
3416
  slide = (_this2$options$slide = _this2.options.slide) !== null && _this2$options$slide !== void 0 ? _this2$options$slide : false;
3933
3417
  }
3934
-
3935
3418
  return [slide, onFinished];
3936
3419
  };
3937
-
3938
3420
  var _parseParams = parseParams(),
3939
- _parseParams2 = _slicedToArray(_parseParams, 2),
3940
- slide = _parseParams2[0],
3941
- onFinished = _parseParams2[1];
3942
-
3421
+ _parseParams2 = _slicedToArray(_parseParams, 2),
3422
+ slide = _parseParams2[0],
3423
+ onFinished = _parseParams2[1];
3943
3424
  this._openNode(node, slide, onFinished);
3944
-
3945
3425
  return this.element;
3946
3426
  }
3947
3427
  }, {
@@ -3950,14 +3430,11 @@ var jqtree = (function (exports) {
3950
3430
  if (!node) {
3951
3431
  throw Error(NODE_PARAM_IS_EMPTY);
3952
3432
  }
3953
-
3954
3433
  var slide = slideParam !== null && slideParam !== void 0 ? slideParam : this.options.slide;
3955
-
3956
3434
  if (node.isFolder() || node.isEmptyFolder) {
3957
3435
  new FolderElement(node, this).close(slide, this.options.animationSpeed);
3958
3436
  this.saveState();
3959
3437
  }
3960
-
3961
3438
  return this.element;
3962
3439
  }
3963
3440
  }, {
@@ -3975,11 +3452,9 @@ var jqtree = (function (exports) {
3975
3452
  key: "addNodeAfter",
3976
3453
  value: function addNodeAfter(newNodeInfo, existingNode) {
3977
3454
  var newNode = existingNode.addAfter(newNodeInfo);
3978
-
3979
3455
  if (newNode) {
3980
3456
  this._refreshElements(existingNode.parent);
3981
3457
  }
3982
-
3983
3458
  return newNode;
3984
3459
  }
3985
3460
  }, {
@@ -3988,13 +3463,10 @@ var jqtree = (function (exports) {
3988
3463
  if (!existingNode) {
3989
3464
  throw Error(PARAM_IS_EMPTY + "existingNode");
3990
3465
  }
3991
-
3992
3466
  var newNode = existingNode.addBefore(newNodeInfo);
3993
-
3994
3467
  if (newNode) {
3995
3468
  this._refreshElements(existingNode.parent);
3996
3469
  }
3997
-
3998
3470
  return newNode;
3999
3471
  }
4000
3472
  }, {
@@ -4003,13 +3475,10 @@ var jqtree = (function (exports) {
4003
3475
  if (!existingNode) {
4004
3476
  throw Error(PARAM_IS_EMPTY + "existingNode");
4005
3477
  }
4006
-
4007
3478
  var newNode = existingNode.addParent(newNodeInfo);
4008
-
4009
3479
  if (newNode) {
4010
3480
  this._refreshElements(newNode.parent);
4011
3481
  }
4012
-
4013
3482
  return newNode;
4014
3483
  }
4015
3484
  }, {
@@ -4018,18 +3487,14 @@ var jqtree = (function (exports) {
4018
3487
  if (!node) {
4019
3488
  throw Error(NODE_PARAM_IS_EMPTY);
4020
3489
  }
4021
-
4022
3490
  if (!node.parent) {
4023
3491
  throw Error("Node has no parent");
4024
3492
  }
4025
-
4026
3493
  this.selectNodeHandler.removeFromSelection(node, true); // including children
4027
3494
 
4028
3495
  var parent = node.parent;
4029
3496
  node.remove();
4030
-
4031
3497
  this._refreshElements(parent);
4032
-
4033
3498
  return this.element;
4034
3499
  }
4035
3500
  }, {
@@ -4037,9 +3502,7 @@ var jqtree = (function (exports) {
4037
3502
  value: function appendNode(newNodeInfo, parentNodeParam) {
4038
3503
  var parentNode = parentNodeParam || this.tree;
4039
3504
  var node = parentNode.append(newNodeInfo);
4040
-
4041
3505
  this._refreshElements(parentNode);
4042
-
4043
3506
  return node;
4044
3507
  }
4045
3508
  }, {
@@ -4047,9 +3510,7 @@ var jqtree = (function (exports) {
4047
3510
  value: function prependNode(newNodeInfo, parentNodeParam) {
4048
3511
  var parentNode = parentNodeParam !== null && parentNodeParam !== void 0 ? parentNodeParam : this.tree;
4049
3512
  var node = parentNode.prepend(newNodeInfo);
4050
-
4051
3513
  this._refreshElements(parentNode);
4052
-
4053
3514
  return node;
4054
3515
  }
4055
3516
  }, {
@@ -4058,36 +3519,27 @@ var jqtree = (function (exports) {
4058
3519
  if (!node) {
4059
3520
  throw Error(NODE_PARAM_IS_EMPTY);
4060
3521
  }
4061
-
4062
3522
  var idIsChanged = _typeof(data) === "object" && data.id && data.id !== node.id;
4063
-
4064
3523
  if (idIsChanged) {
4065
3524
  this.tree.removeNodeFromIndex(node);
4066
3525
  }
4067
-
4068
3526
  node.setData(data);
4069
-
4070
3527
  if (idIsChanged) {
4071
3528
  this.tree.addNodeToIndex(node);
4072
3529
  }
4073
-
4074
3530
  if (_typeof(data) === "object" && data["children"] && data["children"] instanceof Array) {
4075
3531
  node.removeChildren();
4076
-
4077
3532
  if (data.children.length) {
4078
3533
  node.loadFromData(data.children);
4079
3534
  }
4080
3535
  }
4081
-
4082
3536
  this._refreshElements(node);
4083
-
4084
3537
  return this.element;
4085
3538
  }
4086
3539
  }, {
4087
3540
  key: "isSelectedNodeInSubtree",
4088
3541
  value: function isSelectedNodeInSubtree(subtree) {
4089
3542
  var selectedNode = this.getSelectedNode();
4090
-
4091
3543
  if (!selectedNode) {
4092
3544
  return false;
4093
3545
  } else {
@@ -4100,19 +3552,14 @@ var jqtree = (function (exports) {
4100
3552
  if (!node) {
4101
3553
  throw Error(NODE_PARAM_IS_EMPTY);
4102
3554
  }
4103
-
4104
3555
  if (!targetNode) {
4105
3556
  throw Error(PARAM_IS_EMPTY + "targetNode");
4106
3557
  }
4107
-
4108
3558
  var positionIndex = getPosition(position);
4109
-
4110
3559
  if (positionIndex !== undefined) {
4111
3560
  this.tree.moveNode(node, targetNode, positionIndex);
4112
-
4113
3561
  this._refreshElements(null);
4114
3562
  }
4115
-
4116
3563
  return this.element;
4117
3564
  }
4118
3565
  }, {
@@ -4126,11 +3573,8 @@ var jqtree = (function (exports) {
4126
3573
  if (!node) {
4127
3574
  throw Error(NODE_PARAM_IS_EMPTY);
4128
3575
  }
4129
-
4130
3576
  this.selectNodeHandler.addToSelection(node);
4131
-
4132
3577
  this._getNodeElementForNode(node).select(mustSetFocus === undefined ? true : mustSetFocus);
4133
-
4134
3578
  this.saveState();
4135
3579
  return this.element;
4136
3580
  }
@@ -4145,7 +3589,6 @@ var jqtree = (function (exports) {
4145
3589
  if (!node) {
4146
3590
  throw Error(NODE_PARAM_IS_EMPTY);
4147
3591
  }
4148
-
4149
3592
  return this.selectNodeHandler.isNodeSelected(node);
4150
3593
  }
4151
3594
  }, {
@@ -4154,11 +3597,8 @@ var jqtree = (function (exports) {
4154
3597
  if (!node) {
4155
3598
  throw Error(NODE_PARAM_IS_EMPTY);
4156
3599
  }
4157
-
4158
3600
  this.selectNodeHandler.removeFromSelection(node);
4159
-
4160
3601
  this._getNodeElementForNode(node).deselect();
4161
-
4162
3602
  this.saveState();
4163
3603
  return this.element;
4164
3604
  }
@@ -4168,7 +3608,6 @@ var jqtree = (function (exports) {
4168
3608
  if (!node) {
4169
3609
  throw Error(NODE_PARAM_IS_EMPTY);
4170
3610
  }
4171
-
4172
3611
  var nodeOffset = jQuery(node.element).offset();
4173
3612
  var nodeTop = nodeOffset ? nodeOffset.top : 0;
4174
3613
  var treeOffset = this.$el.offset();
@@ -4186,9 +3625,7 @@ var jqtree = (function (exports) {
4186
3625
  key: "setState",
4187
3626
  value: function setState(state) {
4188
3627
  this.saveStateHandler.setInitialState(state);
4189
-
4190
3628
  this._refreshElements(null);
4191
-
4192
3629
  return this.element;
4193
3630
  }
4194
3631
  }, {
@@ -4201,22 +3638,18 @@ var jqtree = (function (exports) {
4201
3638
  key: "moveDown",
4202
3639
  value: function moveDown() {
4203
3640
  var selectedNode = this.getSelectedNode();
4204
-
4205
3641
  if (selectedNode) {
4206
3642
  this.keyHandler.moveDown(selectedNode);
4207
3643
  }
4208
-
4209
3644
  return this.element;
4210
3645
  }
4211
3646
  }, {
4212
3647
  key: "moveUp",
4213
3648
  value: function moveUp() {
4214
3649
  var selectedNode = this.getSelectedNode();
4215
-
4216
3650
  if (selectedNode) {
4217
3651
  this.keyHandler.moveUp(selectedNode);
4218
3652
  }
4219
-
4220
3653
  return this.element;
4221
3654
  }
4222
3655
  }, {
@@ -4235,51 +3668,43 @@ var jqtree = (function (exports) {
4235
3668
  key: "_openNode",
4236
3669
  value: function _openNode(node) {
4237
3670
  var _this3 = this;
4238
-
4239
3671
  var slide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
4240
3672
  var onFinished = arguments.length > 2 ? arguments[2] : undefined;
4241
-
4242
3673
  var doOpenNode = function doOpenNode(_node, _slide, _onFinished) {
4243
3674
  var folderElement = new FolderElement(_node, _this3);
4244
3675
  folderElement.open(_onFinished, _slide, _this3.options.animationSpeed);
4245
3676
  };
4246
-
4247
3677
  if (node.isFolder() || node.isEmptyFolder) {
4248
3678
  if (node.load_on_demand) {
4249
3679
  this.loadFolderOnDemand(node, slide, onFinished);
4250
3680
  } else {
4251
3681
  var parent = node.parent;
4252
-
4253
3682
  while (parent) {
4254
3683
  // nb: do not open root element
4255
3684
  if (parent.parent) {
4256
3685
  doOpenNode(parent, false, null);
4257
3686
  }
4258
-
4259
3687
  parent = parent.parent;
4260
3688
  }
4261
-
4262
3689
  doOpenNode(node, slide, onFinished);
4263
3690
  this.saveState();
4264
3691
  }
4265
3692
  }
4266
3693
  }
3694
+
4267
3695
  /*
4268
3696
  Redraw the tree or part of the tree.
4269
3697
  from_node: redraw this subtree
4270
3698
  */
4271
-
4272
3699
  }, {
4273
3700
  key: "_refreshElements",
4274
3701
  value: function _refreshElements(fromNode) {
4275
3702
  var mustSetFocus = this.selectNodeHandler.isFocusOnTree();
4276
3703
  var mustSelect = fromNode ? this.isSelectedNodeInSubtree(fromNode) : false;
4277
3704
  this.renderer.render(fromNode);
4278
-
4279
3705
  if (mustSelect) {
4280
3706
  this.selectCurrentNode(mustSetFocus);
4281
3707
  }
4282
-
4283
3708
  this._triggerEvent("tree.refresh");
4284
3709
  }
4285
3710
  }, {
@@ -4295,7 +3720,6 @@ var jqtree = (function (exports) {
4295
3720
  key: "_getNodeElement",
4296
3721
  value: function _getNodeElement($element) {
4297
3722
  var node = this.getNode($element);
4298
-
4299
3723
  if (node) {
4300
3724
  return this._getNodeElementForNode(node);
4301
3725
  } else {
@@ -4317,15 +3741,12 @@ var jqtree = (function (exports) {
4317
3741
  key: "init",
4318
3742
  value: function init() {
4319
3743
  _get(_getPrototypeOf(JqTreeWidget.prototype), "init", this).call(this);
4320
-
4321
3744
  this.element = this.$el;
4322
3745
  this.isInitialized = false;
4323
3746
  this.options.rtl = this.getRtlOption();
4324
-
4325
3747
  if (this.options.closedIcon == null) {
4326
3748
  this.options.closedIcon = this.getDefaultClosedIcon();
4327
3749
  }
4328
-
4329
3750
  this.renderer = new ElementsRenderer(this);
4330
3751
  this.dataLoader = new DataLoader(this);
4331
3752
  this.saveStateHandler = new SaveStateHandler(this);
@@ -4336,7 +3757,6 @@ var jqtree = (function (exports) {
4336
3757
  this.initData();
4337
3758
  this.element.on("click", this.handleClick);
4338
3759
  this.element.on("dblclick", this.handleDblclick);
4339
-
4340
3760
  if (this.options.useContextMenu) {
4341
3761
  this.element.on("contextmenu", this.handleContextmenu);
4342
3762
  }
@@ -4348,7 +3768,6 @@ var jqtree = (function (exports) {
4348
3768
  this.element.off();
4349
3769
  this.keyHandler.deinit();
4350
3770
  this.tree = new Node({}, true);
4351
-
4352
3771
  _get(_getPrototypeOf(JqTreeWidget.prototype), "deinit", this).call(this);
4353
3772
  }
4354
3773
  }, {
@@ -4393,7 +3812,6 @@ var jqtree = (function (exports) {
4393
3812
  key: "getMouseDelay",
4394
3813
  value: function getMouseDelay() {
4395
3814
  var _this$options$startDn;
4396
-
4397
3815
  return (_this$options$startDn = this.options.startDndDelay) !== null && _this$options$startDn !== void 0 ? _this$options$startDn : 0;
4398
3816
  }
4399
3817
  }, {
@@ -4403,7 +3821,6 @@ var jqtree = (function (exports) {
4403
3821
  this.doLoadData(this.options.data, null);
4404
3822
  } else {
4405
3823
  var dataUrl = this.getDataUrlInfo(null);
4406
-
4407
3824
  if (dataUrl) {
4408
3825
  this.doLoadDataFromUrl(null, null, null);
4409
3826
  } else {
@@ -4415,9 +3832,7 @@ var jqtree = (function (exports) {
4415
3832
  key: "getDataUrlInfo",
4416
3833
  value: function getDataUrlInfo(node) {
4417
3834
  var _this4 = this;
4418
-
4419
3835
  var dataUrl = this.options.dataUrl || this.element.data("url");
4420
-
4421
3836
  var getUrlFromString = function getUrlFromString(url) {
4422
3837
  var urlInfo = {
4423
3838
  url: url
@@ -4425,7 +3840,6 @@ var jqtree = (function (exports) {
4425
3840
  setUrlInfoData(urlInfo);
4426
3841
  return urlInfo;
4427
3842
  };
4428
-
4429
3843
  var setUrlInfoData = function setUrlInfoData(urlInfo) {
4430
3844
  if (node !== null && node !== void 0 && node.id) {
4431
3845
  // Load on demand of a subtree; add node parameter
@@ -4436,7 +3850,6 @@ var jqtree = (function (exports) {
4436
3850
  } else {
4437
3851
  // Add selected_node parameter
4438
3852
  var selectedNodeId = _this4.getNodeIdToBeSelected();
4439
-
4440
3853
  if (selectedNodeId) {
4441
3854
  var _data = {
4442
3855
  selected_node: selectedNodeId
@@ -4445,7 +3858,6 @@ var jqtree = (function (exports) {
4445
3858
  }
4446
3859
  }
4447
3860
  };
4448
-
4449
3861
  if (typeof dataUrl === "function") {
4450
3862
  return dataUrl(node);
4451
3863
  } else if (typeof dataUrl === "string") {
@@ -4470,68 +3882,57 @@ var jqtree = (function (exports) {
4470
3882
  key: "initTree",
4471
3883
  value: function initTree(data) {
4472
3884
  var _this5 = this;
4473
-
4474
3885
  var doInit = function doInit() {
4475
3886
  if (!_this5.isInitialized) {
4476
3887
  _this5.isInitialized = true;
4477
-
4478
3888
  _this5._triggerEvent("tree.init");
4479
3889
  }
4480
3890
  };
4481
-
4482
3891
  if (!this.options.nodeClass) {
4483
3892
  return;
4484
3893
  }
4485
-
4486
3894
  this.tree = new this.options.nodeClass(null, true, this.options.nodeClass);
4487
3895
  this.selectNodeHandler.clear();
4488
3896
  this.tree.loadFromData(data);
4489
3897
  var mustLoadOnDemand = this.setInitialState();
4490
-
4491
3898
  this._refreshElements(null);
4492
-
4493
3899
  if (!mustLoadOnDemand) {
4494
3900
  doInit();
4495
3901
  } else {
4496
3902
  // Load data on demand and then init the tree
4497
3903
  this.setInitialStateOnDemand(doInit);
4498
3904
  }
4499
- } // Set initial state, either by restoring the state or auto-opening nodes
4500
- // result: must load nodes on demand?
3905
+ }
4501
3906
 
3907
+ // Set initial state, either by restoring the state or auto-opening nodes
3908
+ // result: must load nodes on demand?
4502
3909
  }, {
4503
3910
  key: "setInitialState",
4504
3911
  value: function setInitialState() {
4505
3912
  var _this6 = this;
4506
-
4507
3913
  var restoreState = function restoreState() {
4508
3914
  // result: is state restored, must load on demand?
4509
3915
  if (!_this6.options.saveState) {
4510
3916
  return [false, false];
4511
3917
  } else {
4512
3918
  var state = _this6.saveStateHandler.getStateFromStorage();
4513
-
4514
3919
  if (!state) {
4515
3920
  return [false, false];
4516
3921
  } else {
4517
- var _mustLoadOnDemand = _this6.saveStateHandler.setInitialState(state); // return true: the state is restored
4518
-
3922
+ var _mustLoadOnDemand = _this6.saveStateHandler.setInitialState(state);
4519
3923
 
3924
+ // return true: the state is restored
4520
3925
  return [true, _mustLoadOnDemand];
4521
3926
  }
4522
3927
  }
4523
3928
  };
4524
-
4525
3929
  var autoOpenNodes = function autoOpenNodes() {
4526
3930
  // result: must load on demand?
4527
3931
  if (_this6.options.autoOpen === false) {
4528
3932
  return false;
4529
3933
  }
4530
-
4531
3934
  var maxLevel = _this6.getAutoOpenMaxLevel();
4532
-
4533
3935
  var mustLoadOnDemand = false;
4534
-
4535
3936
  _this6.tree.iterate(function (node, level) {
4536
3937
  if (node.load_on_demand) {
4537
3938
  mustLoadOnDemand = true;
@@ -4543,82 +3944,66 @@ var jqtree = (function (exports) {
4543
3944
  return level !== maxLevel;
4544
3945
  }
4545
3946
  });
4546
-
4547
3947
  return mustLoadOnDemand;
4548
3948
  };
4549
-
4550
3949
  var _restoreState = restoreState(),
4551
- _restoreState2 = _slicedToArray(_restoreState, 2),
4552
- isRestored = _restoreState2[0],
4553
- mustLoadOnDemand = _restoreState2[1]; // eslint-disable-line prefer-const
4554
-
3950
+ _restoreState2 = _slicedToArray(_restoreState, 2),
3951
+ isRestored = _restoreState2[0],
3952
+ mustLoadOnDemand = _restoreState2[1]; // eslint-disable-line prefer-const
4555
3953
 
4556
3954
  if (!isRestored) {
4557
3955
  mustLoadOnDemand = autoOpenNodes();
4558
3956
  }
4559
-
4560
3957
  return mustLoadOnDemand;
4561
- } // Set the initial state for nodes that are loaded on demand
4562
- // Call cb_finished when done
3958
+ }
4563
3959
 
3960
+ // Set the initial state for nodes that are loaded on demand
3961
+ // Call cb_finished when done
4564
3962
  }, {
4565
3963
  key: "setInitialStateOnDemand",
4566
3964
  value: function setInitialStateOnDemand(cbFinished) {
4567
3965
  var _this7 = this;
4568
-
4569
3966
  var restoreState = function restoreState() {
4570
3967
  if (!_this7.options.saveState) {
4571
3968
  return false;
4572
3969
  } else {
4573
3970
  var state = _this7.saveStateHandler.getStateFromStorage();
4574
-
4575
3971
  if (!state) {
4576
3972
  return false;
4577
3973
  } else {
4578
3974
  _this7.saveStateHandler.setInitialStateOnDemand(state, cbFinished);
4579
-
4580
3975
  return true;
4581
3976
  }
4582
3977
  }
4583
3978
  };
4584
-
4585
3979
  var autoOpenNodes = function autoOpenNodes() {
4586
3980
  var maxLevel = _this7.getAutoOpenMaxLevel();
4587
-
4588
3981
  var loadingCount = 0;
4589
-
4590
3982
  var loadAndOpenNode = function loadAndOpenNode(node) {
4591
3983
  loadingCount += 1;
4592
-
4593
3984
  _this7._openNode(node, false, function () {
4594
3985
  loadingCount -= 1;
4595
3986
  openNodes();
4596
3987
  });
4597
3988
  };
4598
-
4599
3989
  var openNodes = function openNodes() {
4600
3990
  _this7.tree.iterate(function (node, level) {
4601
3991
  if (node.load_on_demand) {
4602
3992
  if (!node.is_loading) {
4603
3993
  loadAndOpenNode(node);
4604
3994
  }
4605
-
4606
3995
  return false;
4607
3996
  } else {
4608
3997
  _this7._openNode(node, false, null);
4609
-
4610
3998
  return level !== maxLevel;
4611
3999
  }
4612
4000
  });
4613
-
4614
4001
  if (loadingCount === 0) {
4615
4002
  cbFinished();
4616
4003
  }
4617
4004
  };
4618
-
4619
4005
  openNodes();
4620
4006
  };
4621
-
4622
4007
  if (!restoreState()) {
4623
4008
  autoOpenNodes();
4624
4009
  }
@@ -4641,10 +4026,8 @@ var jqtree = (function (exports) {
4641
4026
  value: function getClickTarget(element) {
4642
4027
  var $target = jQuery(element);
4643
4028
  var $button = $target.closest(".jqtree-toggler");
4644
-
4645
4029
  if ($button.length) {
4646
4030
  var _node4 = this.getNode($button);
4647
-
4648
4031
  if (_node4) {
4649
4032
  return {
4650
4033
  type: "button",
@@ -4653,10 +4036,8 @@ var jqtree = (function (exports) {
4653
4036
  }
4654
4037
  } else {
4655
4038
  var $el = $target.closest(".jqtree-element");
4656
-
4657
4039
  if ($el.length) {
4658
4040
  var _node5 = this.getNode($el);
4659
-
4660
4041
  if (_node5) {
4661
4042
  return {
4662
4043
  type: "label",
@@ -4665,14 +4046,12 @@ var jqtree = (function (exports) {
4665
4046
  }
4666
4047
  }
4667
4048
  }
4668
-
4669
4049
  return null;
4670
4050
  }
4671
4051
  }, {
4672
4052
  key: "getNode",
4673
4053
  value: function getNode($element) {
4674
4054
  var $li = $element.closest("li.jqtree_common");
4675
-
4676
4055
  if ($li.length === 0) {
4677
4056
  return null;
4678
4057
  } else {
@@ -4690,10 +4069,8 @@ var jqtree = (function (exports) {
4690
4069
  key: "selectCurrentNode",
4691
4070
  value: function selectCurrentNode(mustSetFocus) {
4692
4071
  var node = this.getSelectedNode();
4693
-
4694
4072
  if (node) {
4695
4073
  var nodeElement = this._getNodeElementForNode(node);
4696
-
4697
4074
  if (nodeElement) {
4698
4075
  nodeElement.select(mustSetFocus);
4699
4076
  }
@@ -4703,7 +4080,6 @@ var jqtree = (function (exports) {
4703
4080
  key: "deselectCurrentNode",
4704
4081
  value: function deselectCurrentNode() {
4705
4082
  var node = this.getSelectedNode();
4706
-
4707
4083
  if (node) {
4708
4084
  this.removeFromSelection(node);
4709
4085
  }
@@ -4726,7 +4102,6 @@ var jqtree = (function (exports) {
4726
4102
  return this.options.rtl;
4727
4103
  } else {
4728
4104
  var dataRtl = this.element.data("rtl");
4729
-
4730
4105
  if (dataRtl !== null && dataRtl !== false && dataRtl !== undefined) {
4731
4106
  return true;
4732
4107
  } else {
@@ -4738,27 +4113,22 @@ var jqtree = (function (exports) {
4738
4113
  key: "doSelectNode",
4739
4114
  value: function doSelectNode(node, optionsParam) {
4740
4115
  var _this8 = this;
4741
-
4742
4116
  var saveState = function saveState() {
4743
4117
  if (_this8.options.saveState) {
4744
4118
  _this8.saveStateHandler.saveState();
4745
4119
  }
4746
4120
  };
4747
-
4748
4121
  if (!node) {
4749
4122
  // Called with empty node -> deselect current node
4750
4123
  this.deselectCurrentNode();
4751
4124
  saveState();
4752
4125
  return;
4753
4126
  }
4754
-
4755
4127
  var defaultOptions = {
4756
4128
  mustSetFocus: true,
4757
4129
  mustToggle: true
4758
4130
  };
4759
-
4760
4131
  var selectOptions = _objectSpread2(_objectSpread2({}, defaultOptions), optionsParam || {});
4761
-
4762
4132
  var canSelect = function canSelect() {
4763
4133
  if (_this8.options.onCanSelectNode) {
4764
4134
  return _this8.options.selectable === true && _this8.options.onCanSelectNode(node);
@@ -4766,23 +4136,18 @@ var jqtree = (function (exports) {
4766
4136
  return _this8.options.selectable === true;
4767
4137
  }
4768
4138
  };
4769
-
4770
4139
  var openParents = function openParents() {
4771
4140
  var parent = node.parent;
4772
-
4773
4141
  if (parent && parent.parent && !parent.is_open) {
4774
4142
  _this8.openNode(parent, false);
4775
4143
  }
4776
4144
  };
4777
-
4778
4145
  if (!canSelect()) {
4779
4146
  return;
4780
4147
  }
4781
-
4782
4148
  if (this.selectNodeHandler.isNodeSelected(node)) {
4783
4149
  if (selectOptions.mustToggle) {
4784
4150
  this.deselectCurrentNode();
4785
-
4786
4151
  this._triggerEvent("tree.select", {
4787
4152
  node: null,
4788
4153
  previous_node: node
@@ -4792,47 +4157,39 @@ var jqtree = (function (exports) {
4792
4157
  var deselectedNode = this.getSelectedNode() || null;
4793
4158
  this.deselectCurrentNode();
4794
4159
  this.addToSelection(node, selectOptions.mustSetFocus);
4795
-
4796
4160
  this._triggerEvent("tree.select", {
4797
4161
  node: node,
4798
4162
  deselected_node: deselectedNode
4799
4163
  });
4800
-
4801
4164
  openParents();
4802
4165
  }
4803
-
4804
4166
  saveState();
4805
4167
  }
4806
4168
  }, {
4807
4169
  key: "doLoadData",
4808
4170
  value: function doLoadData(data, parentNode) {
4809
- if (!data) {
4810
- return;
4811
- } else {
4812
- this._triggerEvent("tree.load_data", {
4813
- tree_data: data
4814
- });
4815
-
4171
+ if (data) {
4816
4172
  if (parentNode) {
4817
4173
  this.deselectNodes(parentNode);
4818
4174
  this.loadSubtree(data, parentNode);
4819
4175
  } else {
4820
4176
  this.initTree(data);
4821
4177
  }
4822
-
4823
4178
  if (this.isDragging()) {
4824
4179
  this.dndHandler.refresh();
4825
4180
  }
4826
4181
  }
4182
+ this._triggerEvent("tree.load_data", {
4183
+ tree_data: data,
4184
+ parent_node: parentNode
4185
+ });
4827
4186
  }
4828
4187
  }, {
4829
4188
  key: "deselectNodes",
4830
4189
  value: function deselectNodes(parentNode) {
4831
4190
  var selectedNodesUnderParent = this.selectNodeHandler.getSelectedNodesUnder(parentNode);
4832
-
4833
4191
  var _iterator = _createForOfIteratorHelper(selectedNodesUnderParent),
4834
- _step;
4835
-
4192
+ _step;
4836
4193
  try {
4837
4194
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
4838
4195
  var n = _step.value;
@@ -4850,7 +4207,6 @@ var jqtree = (function (exports) {
4850
4207
  parentNode.loadFromData(data);
4851
4208
  parentNode.load_on_demand = false;
4852
4209
  parentNode.is_loading = false;
4853
-
4854
4210
  this._refreshElements(parentNode);
4855
4211
  }
4856
4212
  }, {
@@ -4863,7 +4219,6 @@ var jqtree = (function (exports) {
4863
4219
  key: "loadFolderOnDemand",
4864
4220
  value: function loadFolderOnDemand(node) {
4865
4221
  var _this9 = this;
4866
-
4867
4222
  var slide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
4868
4223
  var onFinished = arguments.length > 2 ? arguments[2] : undefined;
4869
4224
  node.is_loading = true;
@@ -4872,10 +4227,8 @@ var jqtree = (function (exports) {
4872
4227
  });
4873
4228
  }
4874
4229
  }]);
4875
-
4876
4230
  return JqTreeWidget;
4877
4231
  }(MouseWidget);
4878
-
4879
4232
  _defineProperty(JqTreeWidget, "defaults", {
4880
4233
  animationSpeed: "fast",
4881
4234
  autoEscape: true,
@@ -4922,13 +4275,10 @@ var jqtree = (function (exports) {
4922
4275
  tabIndex: 0,
4923
4276
  useContextMenu: true
4924
4277
  });
4925
-
4926
4278
  SimpleWidget.register(JqTreeWidget, "tree");
4927
4279
 
4928
4280
  exports.JqTreeWidget = JqTreeWidget;
4929
4281
 
4930
- Object.defineProperty(exports, '__esModule', { value: true });
4931
-
4932
4282
  return exports;
4933
4283
 
4934
4284
  })({});