jqtree 1.7.5 → 1.8.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.
- package/bower.json +1 -1
- package/config/babel.config.json +1 -1
- package/config/production +2 -0
- package/devserver/devserver_scroll.js +8 -0
- package/devserver/test_scroll.html +28 -0
- package/devserver/test_scroll_container.html +39 -0
- package/docs/_config.yml +1 -1
- package/docs/_entries/general/changelog.md +7 -0
- package/package.json +5 -1
- package/src/dataLoader.ts +44 -19
- package/src/dragAndDropHandler/dragElement.ts +42 -0
- package/src/dragAndDropHandler/hitAreasGenerator.ts +175 -0
- package/src/dragAndDropHandler/index.ts +470 -0
- package/src/dragAndDropHandler/types.ts +12 -0
- package/src/dragAndDropHandler/visibleNodeIterator.ts +97 -0
- package/src/elementsRenderer.ts +75 -40
- package/src/jqtreeMethodTypes.ts +40 -0
- package/src/jqtreeOptions.ts +43 -25
- package/src/keyHandler.ts +59 -30
- package/src/mouse.widget.ts +3 -3
- package/src/mouseWidgetTypes.ts +6 -0
- package/src/nodeElement/borderDropHint.ts +32 -0
- package/src/nodeElement/folderElement.ts +133 -0
- package/src/nodeElement/ghostDropHint.ts +68 -0
- package/src/nodeElement/index.ts +101 -0
- package/src/playwright/coverage.ts +1 -4
- package/src/playwright/playwright.test.ts +0 -4
- package/src/saveStateHandler.ts +75 -26
- package/src/scrollHandler.ts +13 -7
- package/src/selectNodeHandler.ts +10 -16
- package/src/test/jqTree/keyboard.test.ts +18 -23
- package/src/test/jqTree/methods.test.ts +32 -3
- package/src/test/jqTree/options.test.ts +15 -4
- package/src/test/node.test.ts +1 -1
- package/src/tree.jquery.ts +239 -57
- package/src/util.ts +3 -0
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +1728 -2576
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +2 -2
- package/tree.jquery.js.map +1 -1
- package/lib/dataLoader.js +0 -123
- package/lib/dragAndDropHandler.js +0 -588
- package/lib/elementsRenderer.js +0 -267
- package/lib/jqtreeOptions.js +0 -1
- package/lib/keyHandler.js +0 -111
- package/lib/mouse.widget.js +0 -255
- package/lib/node.js +0 -708
- package/lib/nodeElement.js +0 -274
- package/lib/nodeUtils.js +0 -10
- package/lib/playwright/coverage.js +0 -99
- package/lib/playwright/playwright.test.js +0 -606
- package/lib/playwright/testUtils.js +0 -210
- package/lib/saveStateHandler.js +0 -277
- package/lib/scrollHandler/containerScrollParent.js +0 -160
- package/lib/scrollHandler/createScrollParent.js +0 -57
- package/lib/scrollHandler/documentScrollParent.js +0 -169
- package/lib/scrollHandler/scrollParent.js +0 -58
- package/lib/scrollHandler/types.js +0 -1
- package/lib/scrollHandler.js +0 -71
- package/lib/selectNodeHandler.js +0 -128
- package/lib/simple.widget.js +0 -158
- package/lib/test/global.d.js +0 -3
- package/lib/test/jqTree/accessibility.test.js +0 -37
- package/lib/test/jqTree/create.test.js +0 -48
- package/lib/test/jqTree/events.test.js +0 -210
- package/lib/test/jqTree/keyboard.test.js +0 -225
- package/lib/test/jqTree/loadOnDemand.test.js +0 -218
- package/lib/test/jqTree/methods.test.js +0 -1348
- package/lib/test/jqTree/options.test.js +0 -548
- package/lib/test/jqTree/scrollHandler/containerScrollParent.test.js +0 -94
- package/lib/test/node.test.js +0 -1202
- package/lib/test/nodeUtil.test.js +0 -27
- package/lib/test/nodeUtils.test.js +0 -20
- package/lib/test/support/exampleData.js +0 -35
- package/lib/test/support/jqTreeMatchers.js +0 -70
- package/lib/test/support/matchers.d.js +0 -1
- package/lib/test/support/setupTests.js +0 -7
- package/lib/test/support/testUtil.js +0 -29
- package/lib/test/support/treeStructure.js +0 -38
- package/lib/test/util.test.js +0 -26
- package/lib/tree.jquery.d.js +0 -1
- package/lib/tree.jquery.js +0 -1105
- package/lib/types.js +0 -1
- package/lib/typings.d.js +0 -2
- package/lib/util.js +0 -15
- package/lib/version.js +0 -8
- package/src/dragAndDropHandler.ts +0 -713
- package/src/nodeElement.ts +0 -272
- package/src/types.ts +0 -19
package/src/nodeElement.ts
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import { Position, Node } from "./node";
|
|
2
|
-
import { JqTreeWidget } from "./tree.jquery";
|
|
3
|
-
import { DropHint } from "./types";
|
|
4
|
-
|
|
5
|
-
export type OnFinishOpenNode = (node: Node) => void;
|
|
6
|
-
|
|
7
|
-
export class NodeElement {
|
|
8
|
-
public node: Node;
|
|
9
|
-
public $element: JQuery<HTMLElement>;
|
|
10
|
-
protected treeWidget: JqTreeWidget;
|
|
11
|
-
|
|
12
|
-
constructor(node: Node, treeWidget: JqTreeWidget) {
|
|
13
|
-
this.init(node, treeWidget);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
public init(node: Node, treeWidget: JqTreeWidget): void {
|
|
17
|
-
this.node = node;
|
|
18
|
-
this.treeWidget = treeWidget;
|
|
19
|
-
|
|
20
|
-
if (!node.element) {
|
|
21
|
-
const element = this.treeWidget.element.get(0);
|
|
22
|
-
|
|
23
|
-
if (element) {
|
|
24
|
-
node.element = element;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (node.element) {
|
|
29
|
-
this.$element = jQuery(node.element);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public addDropHint(position: number): DropHint {
|
|
34
|
-
if (this.mustShowBorderDropHint(position)) {
|
|
35
|
-
return new BorderDropHint(
|
|
36
|
-
this.$element,
|
|
37
|
-
this.treeWidget._getScrollLeft(),
|
|
38
|
-
);
|
|
39
|
-
} else {
|
|
40
|
-
return new GhostDropHint(this.node, this.$element, position);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public select(mustSetFocus: boolean): void {
|
|
45
|
-
const $li = this.getLi();
|
|
46
|
-
|
|
47
|
-
$li.addClass("jqtree-selected");
|
|
48
|
-
|
|
49
|
-
const $span = this.getSpan();
|
|
50
|
-
$span.attr("tabindex", this.treeWidget.options.tabIndex ?? null);
|
|
51
|
-
$span.attr("aria-selected", "true");
|
|
52
|
-
|
|
53
|
-
if (mustSetFocus) {
|
|
54
|
-
$span.trigger("focus");
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public deselect(): void {
|
|
59
|
-
const $li = this.getLi();
|
|
60
|
-
|
|
61
|
-
$li.removeClass("jqtree-selected");
|
|
62
|
-
|
|
63
|
-
const $span = this.getSpan();
|
|
64
|
-
$span.removeAttr("tabindex");
|
|
65
|
-
$span.attr("aria-selected", "false");
|
|
66
|
-
|
|
67
|
-
$span.trigger("blur");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
protected getUl(): JQuery<HTMLElement> {
|
|
71
|
-
return this.$element.children("ul:first");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
protected getSpan(): JQuery<HTMLElement> {
|
|
75
|
-
return this.$element
|
|
76
|
-
.children(".jqtree-element")
|
|
77
|
-
.find("span.jqtree-title");
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
protected getLi(): JQuery<HTMLElement> {
|
|
81
|
-
return this.$element;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
protected mustShowBorderDropHint(position: Position): boolean {
|
|
85
|
-
return position === Position.Inside;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export class FolderElement extends NodeElement {
|
|
90
|
-
public open(
|
|
91
|
-
onFinished: OnFinishOpenNode | null,
|
|
92
|
-
slide = true,
|
|
93
|
-
animationSpeed: JQuery.Duration = "fast",
|
|
94
|
-
): void {
|
|
95
|
-
if (this.node.is_open) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.node.is_open = true;
|
|
100
|
-
|
|
101
|
-
const $button = this.getButton();
|
|
102
|
-
$button.removeClass("jqtree-closed");
|
|
103
|
-
$button.html("");
|
|
104
|
-
|
|
105
|
-
const buttonEl = $button.get(0);
|
|
106
|
-
|
|
107
|
-
if (buttonEl) {
|
|
108
|
-
const openedIconElement =
|
|
109
|
-
this.treeWidget.renderer.openedIconElement;
|
|
110
|
-
|
|
111
|
-
if (openedIconElement) {
|
|
112
|
-
const icon = openedIconElement.cloneNode(true);
|
|
113
|
-
buttonEl.appendChild(icon);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const doOpen = (): void => {
|
|
118
|
-
const $li = this.getLi();
|
|
119
|
-
$li.removeClass("jqtree-closed");
|
|
120
|
-
|
|
121
|
-
const $titleSpan = this.getSpan();
|
|
122
|
-
$titleSpan.attr("aria-expanded", "true");
|
|
123
|
-
|
|
124
|
-
if (onFinished) {
|
|
125
|
-
onFinished(this.node);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
this.treeWidget._triggerEvent("tree.open", {
|
|
129
|
-
node: this.node,
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
if (slide) {
|
|
134
|
-
this.getUl().slideDown(animationSpeed, doOpen);
|
|
135
|
-
} else {
|
|
136
|
-
this.getUl().show();
|
|
137
|
-
doOpen();
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
public close(
|
|
142
|
-
slide = true,
|
|
143
|
-
animationSpeed: JQuery.Duration | undefined = "fast",
|
|
144
|
-
): void {
|
|
145
|
-
if (!this.node.is_open) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
this.node.is_open = false;
|
|
150
|
-
|
|
151
|
-
const $button = this.getButton();
|
|
152
|
-
$button.addClass("jqtree-closed");
|
|
153
|
-
$button.html("");
|
|
154
|
-
|
|
155
|
-
const buttonEl = $button.get(0);
|
|
156
|
-
|
|
157
|
-
if (buttonEl) {
|
|
158
|
-
const closedIconElement =
|
|
159
|
-
this.treeWidget.renderer.closedIconElement;
|
|
160
|
-
|
|
161
|
-
if (closedIconElement) {
|
|
162
|
-
const icon = closedIconElement.cloneNode(true);
|
|
163
|
-
buttonEl.appendChild(icon);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const doClose = (): void => {
|
|
168
|
-
const $li = this.getLi();
|
|
169
|
-
$li.addClass("jqtree-closed");
|
|
170
|
-
|
|
171
|
-
const $titleSpan = this.getSpan();
|
|
172
|
-
$titleSpan.attr("aria-expanded", "false");
|
|
173
|
-
|
|
174
|
-
this.treeWidget._triggerEvent("tree.close", {
|
|
175
|
-
node: this.node,
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
if (slide) {
|
|
180
|
-
this.getUl().slideUp(animationSpeed, doClose);
|
|
181
|
-
} else {
|
|
182
|
-
this.getUl().hide();
|
|
183
|
-
doClose();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
protected mustShowBorderDropHint(position: Position): boolean {
|
|
188
|
-
return !this.node.is_open && position === Position.Inside;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
private getButton(): JQuery {
|
|
192
|
-
return this.$element
|
|
193
|
-
.children(".jqtree-element")
|
|
194
|
-
.find("a.jqtree-toggler");
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export class BorderDropHint implements DropHint {
|
|
199
|
-
private $hint: JQuery<Element>;
|
|
200
|
-
|
|
201
|
-
constructor($element: JQuery<Element>, scrollLeft: number) {
|
|
202
|
-
const $div = $element.children(".jqtree-element");
|
|
203
|
-
|
|
204
|
-
const elWidth = $element.width() || 0;
|
|
205
|
-
const width = Math.max(elWidth + scrollLeft - 4, 0);
|
|
206
|
-
|
|
207
|
-
const elHeight = $div.outerHeight() || 0;
|
|
208
|
-
const height = Math.max(elHeight - 4, 0);
|
|
209
|
-
|
|
210
|
-
this.$hint = jQuery('<span class="jqtree-border"></span>');
|
|
211
|
-
$div.append(this.$hint);
|
|
212
|
-
|
|
213
|
-
this.$hint.css({ width, height });
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
public remove(): void {
|
|
217
|
-
this.$hint.remove();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
class GhostDropHint implements DropHint {
|
|
222
|
-
private $element: JQuery<Element>;
|
|
223
|
-
private node: Node;
|
|
224
|
-
private $ghost: JQuery;
|
|
225
|
-
|
|
226
|
-
constructor(node: Node, $element: JQuery<Element>, position: Position) {
|
|
227
|
-
this.$element = $element;
|
|
228
|
-
|
|
229
|
-
this.node = node;
|
|
230
|
-
this.$ghost = jQuery(
|
|
231
|
-
`<li class="jqtree_common jqtree-ghost"><span class="jqtree_common jqtree-circle"></span>
|
|
232
|
-
<span class="jqtree_common jqtree-line"></span></li>`,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
if (position === Position.After) {
|
|
236
|
-
this.moveAfter();
|
|
237
|
-
} else if (position === Position.Before) {
|
|
238
|
-
this.moveBefore();
|
|
239
|
-
} else if (position === Position.Inside) {
|
|
240
|
-
if (node.isFolder() && node.is_open) {
|
|
241
|
-
this.moveInsideOpenFolder();
|
|
242
|
-
} else {
|
|
243
|
-
this.moveInside();
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
public remove(): void {
|
|
249
|
-
this.$ghost.remove();
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
public moveAfter(): void {
|
|
253
|
-
this.$element.after(this.$ghost);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
public moveBefore(): void {
|
|
257
|
-
this.$element.before(this.$ghost);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
public moveInsideOpenFolder(): void {
|
|
261
|
-
const childElement = this.node.children[0]?.element;
|
|
262
|
-
|
|
263
|
-
if (childElement) {
|
|
264
|
-
jQuery(childElement).before(this.$ghost);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
public moveInside(): void {
|
|
269
|
-
this.$element.after(this.$ghost);
|
|
270
|
-
this.$ghost.addClass("jqtree-inside");
|
|
271
|
-
}
|
|
272
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Node, Position } from "./node";
|
|
2
|
-
|
|
3
|
-
export interface DropHint {
|
|
4
|
-
remove: () => void;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface HitArea {
|
|
8
|
-
top: number;
|
|
9
|
-
bottom: number;
|
|
10
|
-
node: Node;
|
|
11
|
-
position: Position;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface PositionInfo {
|
|
15
|
-
pageX: number | undefined;
|
|
16
|
-
pageY: number | undefined;
|
|
17
|
-
target: HTMLElement;
|
|
18
|
-
originalEvent: Event;
|
|
19
|
-
}
|