jqtree 1.8.6 → 1.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jqTree",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "main": [
5
5
  "jqtree.css",
6
6
  "jqtree-circle.png",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jqtree",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "Tree widget for jQuery",
5
5
  "keywords": [
6
6
  "jquery-plugin",
@@ -1,15 +1,34 @@
1
1
  import { DropHint } from "../dragAndDropHandler/types";
2
+ import { Node } from "../node";
3
+ import { Position } from "../position";
2
4
 
3
5
  class GhostDropHint implements DropHint {
4
6
  private element: HTMLElement;
5
7
  private ghost: HTMLElement;
8
+ private node: Node;
6
9
 
7
- constructor(element: HTMLElement) {
10
+ constructor(node: Node, element: HTMLElement, position: Position) {
8
11
  this.element = element;
12
+ this.node = node;
9
13
  this.ghost = this.createGhostElement();
10
14
 
11
- this.element.after(this.ghost);
12
- this.ghost.classList.add("jqtree-inside");
15
+ switch (position) {
16
+ case Position.After:
17
+ this.moveAfter();
18
+ break;
19
+
20
+ case Position.Before:
21
+ this.moveBefore();
22
+ break;
23
+
24
+ case Position.Inside: {
25
+ if (node.isFolder() && node.is_open) {
26
+ this.moveInsideOpenFolder();
27
+ } else {
28
+ this.moveInside();
29
+ }
30
+ }
31
+ }
13
32
  }
14
33
 
15
34
  private createGhostElement() {
@@ -27,6 +46,27 @@ class GhostDropHint implements DropHint {
27
46
  return ghost;
28
47
  }
29
48
 
49
+ private moveAfter(): void {
50
+ this.element.after(this.ghost);
51
+ }
52
+
53
+ private moveBefore(): void {
54
+ this.element.before(this.ghost);
55
+ }
56
+
57
+ private moveInside(): void {
58
+ this.element.after(this.ghost);
59
+ this.ghost.classList.add("jqtree-inside");
60
+ }
61
+
62
+ private moveInsideOpenFolder(): void {
63
+ const childElement = this.node.children[0]?.element;
64
+
65
+ if (childElement) {
66
+ childElement.before(this.ghost);
67
+ }
68
+ }
69
+
30
70
  public remove(): void {
31
71
  this.ghost.remove();
32
72
  }
@@ -50,7 +50,7 @@ class NodeElement {
50
50
  if (this.mustShowBorderDropHint(position)) {
51
51
  return new BorderDropHint(this.element, this.getScrollLeft());
52
52
  } else {
53
- return new GhostDropHint(this.element);
53
+ return new GhostDropHint(this.node, this.element, position);
54
54
  }
55
55
  }
56
56
 
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
- const version = "1.8.6";
1
+ const version = "1.8.7";
2
2
 
3
3
  export default version;
@@ -1,5 +1,5 @@
1
1
  /*
2
- JqTree 1.8.6
2
+ JqTree 1.8.7
3
3
 
4
4
  Copyright 2024 Marco Braak
5
5
 
@@ -1807,11 +1807,26 @@ var jqtree = (function (exports) {
1807
1807
  }
1808
1808
 
1809
1809
  class GhostDropHint {
1810
- constructor(element) {
1810
+ constructor(node, element, position) {
1811
1811
  this.element = element;
1812
+ this.node = node;
1812
1813
  this.ghost = this.createGhostElement();
1813
- this.element.after(this.ghost);
1814
- this.ghost.classList.add("jqtree-inside");
1814
+ switch (position) {
1815
+ case Position.After:
1816
+ this.moveAfter();
1817
+ break;
1818
+ case Position.Before:
1819
+ this.moveBefore();
1820
+ break;
1821
+ case Position.Inside:
1822
+ {
1823
+ if (node.isFolder() && node.is_open) {
1824
+ this.moveInsideOpenFolder();
1825
+ } else {
1826
+ this.moveInside();
1827
+ }
1828
+ }
1829
+ }
1815
1830
  }
1816
1831
  createGhostElement() {
1817
1832
  const ghost = document.createElement("li");
@@ -1824,6 +1839,22 @@ var jqtree = (function (exports) {
1824
1839
  ghost.append(lineSpan);
1825
1840
  return ghost;
1826
1841
  }
1842
+ moveAfter() {
1843
+ this.element.after(this.ghost);
1844
+ }
1845
+ moveBefore() {
1846
+ this.element.before(this.ghost);
1847
+ }
1848
+ moveInside() {
1849
+ this.element.after(this.ghost);
1850
+ this.ghost.classList.add("jqtree-inside");
1851
+ }
1852
+ moveInsideOpenFolder() {
1853
+ const childElement = this.node.children[0]?.element;
1854
+ if (childElement) {
1855
+ childElement.before(this.ghost);
1856
+ }
1857
+ }
1827
1858
  remove() {
1828
1859
  this.ghost.remove();
1829
1860
  }
@@ -1855,7 +1886,7 @@ var jqtree = (function (exports) {
1855
1886
  if (this.mustShowBorderDropHint(position)) {
1856
1887
  return new BorderDropHint(this.element, this.getScrollLeft());
1857
1888
  } else {
1858
- return new GhostDropHint(this.element);
1889
+ return new GhostDropHint(this.node, this.element, position);
1859
1890
  }
1860
1891
  }
1861
1892
  deselect() {
@@ -2687,7 +2718,7 @@ var jqtree = (function (exports) {
2687
2718
  }
2688
2719
  }
2689
2720
 
2690
- const version = "1.8.6";
2721
+ const version = "1.8.7";
2691
2722
 
2692
2723
  const NODE_PARAM_IS_EMPTY = "Node parameter is empty";
2693
2724
  const PARAM_IS_EMPTY = "Parameter is empty: ";