jqtree 1.7.5 → 1.8.1
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/.eslintrc +13 -3
- package/.github/workflows/ci.yml +6 -6
- package/.github/workflows/codeql-analysis.yml +4 -4
- package/.github/workflows/size.yml +3 -3
- package/.github/workflows/static.yml +1 -1
- package/bower.json +1 -1
- package/config/babel.config.json +1 -1
- package/config/jest.config.js +4 -0
- package/config/jest.polyfills.js +14 -0
- package/config/production +2 -0
- package/devserver/devserver_scroll.js +8 -0
- package/devserver/test_index.html +9 -0
- package/devserver/test_scroll.html +28 -0
- package/devserver/test_scroll_container.html +39 -0
- package/docs/.ruby-version +1 -1
- package/docs/_config.yml +1 -1
- package/docs/_entries/general/changelog.md +11 -0
- package/docs/_entries/multiple_selection/get-selected-nodes.md +1 -1
- package/docs/_entries/node/getnextnode.md +3 -6
- package/docs/_entries/node/getnextsibling.md +1 -1
- package/docs/_entries/node/getnextvisiblenode.md +8 -5
- package/docs/_entries/node/getpreviousnode.md +12 -0
- package/docs/_entries/node/getprevioussibling.md +1 -1
- package/docs/_entries/node/getpreviousvisiblenode.md +6 -5
- package/package.json +35 -29
- package/src/dataLoader.ts +57 -34
- package/src/dragAndDropHandler/dragElement.ts +54 -0
- package/src/dragAndDropHandler/generateHitAreas.ts +176 -0
- package/src/dragAndDropHandler/index.ts +454 -0
- package/src/dragAndDropHandler/iterateVisibleNodes.ts +91 -0
- package/src/dragAndDropHandler/types.ts +13 -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/mouseHandler.ts +385 -0
- package/src/mouseUtils.ts +23 -0
- package/src/node.ts +1 -29
- package/src/nodeElement/borderDropHint.ts +32 -0
- package/src/nodeElement/folderElement.ts +133 -0
- package/src/nodeElement/ghostDropHint.ts +69 -0
- package/src/nodeElement/index.ts +102 -0
- package/src/playwright/coverage.ts +4 -7
- package/src/playwright/playwright.test.ts +150 -53
- package/src/playwright/testUtils.ts +28 -5
- package/src/position.ts +28 -0
- package/src/saveStateHandler.ts +75 -26
- package/src/scrollHandler/containerScrollParent.ts +13 -23
- package/src/scrollHandler/createScrollParent.ts +22 -22
- package/src/scrollHandler/documentScrollParent.ts +16 -13
- package/src/scrollHandler.ts +13 -15
- package/src/selectNodeHandler.ts +10 -16
- package/src/test/jqTree/events.test.ts +97 -30
- package/src/test/jqTree/keyboard.test.ts +18 -23
- package/src/test/jqTree/loadOnDemand.test.ts +22 -15
- package/src/test/jqTree/methods.test.ts +40 -14
- package/src/test/jqTree/mouse.test.ts +82 -0
- package/src/test/jqTree/options.test.ts +24 -12
- package/src/test/node.test.ts +3 -2
- package/src/test/{nodeUtil.test.ts → position.test.ts} +1 -1
- package/src/tree.jquery.ts +314 -208
- package/src/util.ts +12 -0
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +2594 -3419
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +3 -3
- package/tree.jquery.js.map +1 -1
- package/tsconfig.json +5 -3
- package/docs/_entries/functions/get-selected-nodes.md +0 -10
- 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/mouse.widget.ts +0 -266
- package/src/nodeElement.ts +0 -272
- package/src/types.ts +0 -19
package/lib/elementsRenderer.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _util = require("./util");
|
|
8
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
9
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
17
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
-
var ElementsRenderer = exports["default"] = /*#__PURE__*/function () {
|
|
19
|
-
function ElementsRenderer(treeWidget) {
|
|
20
|
-
_classCallCheck(this, ElementsRenderer);
|
|
21
|
-
_defineProperty(this, "openedIconElement", void 0);
|
|
22
|
-
_defineProperty(this, "closedIconElement", void 0);
|
|
23
|
-
_defineProperty(this, "treeWidget", void 0);
|
|
24
|
-
this.treeWidget = treeWidget;
|
|
25
|
-
this.openedIconElement = this.createButtonElement(treeWidget.options.openedIcon || "+");
|
|
26
|
-
this.closedIconElement = this.createButtonElement(treeWidget.options.closedIcon || "-");
|
|
27
|
-
}
|
|
28
|
-
_createClass(ElementsRenderer, [{
|
|
29
|
-
key: "render",
|
|
30
|
-
value: function render(fromNode) {
|
|
31
|
-
if (fromNode && fromNode.parent) {
|
|
32
|
-
this.renderFromNode(fromNode);
|
|
33
|
-
} else {
|
|
34
|
-
this.renderFromRoot();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}, {
|
|
38
|
-
key: "renderFromRoot",
|
|
39
|
-
value: function renderFromRoot() {
|
|
40
|
-
var $element = this.treeWidget.element;
|
|
41
|
-
$element.empty();
|
|
42
|
-
if ($element[0]) {
|
|
43
|
-
this.createDomElements($element[0], this.treeWidget.tree.children, true, 1);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}, {
|
|
47
|
-
key: "renderFromNode",
|
|
48
|
-
value: function renderFromNode(node) {
|
|
49
|
-
// remember current li
|
|
50
|
-
var $previousLi = jQuery(node.element);
|
|
51
|
-
|
|
52
|
-
// create element
|
|
53
|
-
var li = this.createLi(node, node.getLevel());
|
|
54
|
-
this.attachNodeData(node, li);
|
|
55
|
-
|
|
56
|
-
// add element to dom
|
|
57
|
-
$previousLi.after(li);
|
|
58
|
-
|
|
59
|
-
// remove previous li
|
|
60
|
-
$previousLi.remove();
|
|
61
|
-
|
|
62
|
-
// create children
|
|
63
|
-
if (node.children) {
|
|
64
|
-
this.createDomElements(li, node.children, false, node.getLevel() + 1);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "createDomElements",
|
|
69
|
-
value: function createDomElements(element, children, isRootNode, level) {
|
|
70
|
-
var ul = this.createUl(isRootNode);
|
|
71
|
-
element.appendChild(ul);
|
|
72
|
-
var _iterator = _createForOfIteratorHelper(children),
|
|
73
|
-
_step;
|
|
74
|
-
try {
|
|
75
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
76
|
-
var child = _step.value;
|
|
77
|
-
var li = this.createLi(child, level);
|
|
78
|
-
ul.appendChild(li);
|
|
79
|
-
this.attachNodeData(child, li);
|
|
80
|
-
if (child.hasChildren()) {
|
|
81
|
-
this.createDomElements(li, child.children, false, level + 1);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} catch (err) {
|
|
85
|
-
_iterator.e(err);
|
|
86
|
-
} finally {
|
|
87
|
-
_iterator.f();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "attachNodeData",
|
|
92
|
-
value: function attachNodeData(node, li) {
|
|
93
|
-
node.element = li;
|
|
94
|
-
jQuery(li).data("node", node);
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "createUl",
|
|
98
|
-
value: function createUl(isRootNode) {
|
|
99
|
-
var classString;
|
|
100
|
-
var role;
|
|
101
|
-
if (!isRootNode) {
|
|
102
|
-
classString = "";
|
|
103
|
-
role = "group";
|
|
104
|
-
} else {
|
|
105
|
-
classString = "jqtree-tree";
|
|
106
|
-
role = "tree";
|
|
107
|
-
if (this.treeWidget.options.rtl) {
|
|
108
|
-
classString += " jqtree-rtl";
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (this.treeWidget.options.dragAndDrop) {
|
|
112
|
-
classString += " jqtree-dnd";
|
|
113
|
-
}
|
|
114
|
-
var ul = document.createElement("ul");
|
|
115
|
-
ul.className = "jqtree_common ".concat(classString);
|
|
116
|
-
ul.setAttribute("role", role);
|
|
117
|
-
return ul;
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "createLi",
|
|
121
|
-
value: function createLi(node, level) {
|
|
122
|
-
var isSelected = Boolean(this.treeWidget.selectNodeHandler.isNodeSelected(node));
|
|
123
|
-
var mustShowFolder = node.isFolder() || node.isEmptyFolder && this.treeWidget.options.showEmptyFolder;
|
|
124
|
-
var li = mustShowFolder ? this.createFolderLi(node, level, isSelected) : this.createNodeLi(node, level, isSelected);
|
|
125
|
-
if (this.treeWidget.options.onCreateLi) {
|
|
126
|
-
this.treeWidget.options.onCreateLi(node, jQuery(li), isSelected);
|
|
127
|
-
}
|
|
128
|
-
return li;
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "setTreeItemAriaAttributes",
|
|
132
|
-
value: function setTreeItemAriaAttributes(element, name, level, isSelected) {
|
|
133
|
-
element.setAttribute("aria-label", name);
|
|
134
|
-
element.setAttribute("aria-level", "".concat(level));
|
|
135
|
-
element.setAttribute("aria-selected", (0, _util.getBoolString)(isSelected));
|
|
136
|
-
element.setAttribute("role", "treeitem");
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
key: "createFolderLi",
|
|
140
|
-
value: function createFolderLi(node, level, isSelected) {
|
|
141
|
-
var buttonClasses = this.getButtonClasses(node);
|
|
142
|
-
var folderClasses = this.getFolderClasses(node, isSelected);
|
|
143
|
-
var iconElement = node.is_open ? this.openedIconElement : this.closedIconElement;
|
|
144
|
-
|
|
145
|
-
// li
|
|
146
|
-
var li = document.createElement("li");
|
|
147
|
-
li.className = "jqtree_common ".concat(folderClasses);
|
|
148
|
-
li.setAttribute("role", "none");
|
|
149
|
-
|
|
150
|
-
// div
|
|
151
|
-
var div = document.createElement("div");
|
|
152
|
-
div.className = "jqtree-element jqtree_common";
|
|
153
|
-
div.setAttribute("role", "none");
|
|
154
|
-
li.appendChild(div);
|
|
155
|
-
|
|
156
|
-
// button link
|
|
157
|
-
var buttonLink = document.createElement("a");
|
|
158
|
-
buttonLink.className = buttonClasses;
|
|
159
|
-
if (iconElement) {
|
|
160
|
-
buttonLink.appendChild(iconElement.cloneNode(true));
|
|
161
|
-
}
|
|
162
|
-
if (this.treeWidget.options.buttonLeft) {
|
|
163
|
-
div.appendChild(buttonLink);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// title span
|
|
167
|
-
var titleSpan = this.createTitleSpan(node.name, isSelected, true, level);
|
|
168
|
-
titleSpan.setAttribute("aria-expanded", (0, _util.getBoolString)(node.is_open));
|
|
169
|
-
div.appendChild(titleSpan);
|
|
170
|
-
if (!this.treeWidget.options.buttonLeft) {
|
|
171
|
-
div.appendChild(buttonLink);
|
|
172
|
-
}
|
|
173
|
-
return li;
|
|
174
|
-
}
|
|
175
|
-
}, {
|
|
176
|
-
key: "createNodeLi",
|
|
177
|
-
value: function createNodeLi(node, level, isSelected) {
|
|
178
|
-
var liClasses = ["jqtree_common"];
|
|
179
|
-
if (isSelected) {
|
|
180
|
-
liClasses.push("jqtree-selected");
|
|
181
|
-
}
|
|
182
|
-
var classString = liClasses.join(" ");
|
|
183
|
-
|
|
184
|
-
// li
|
|
185
|
-
var li = document.createElement("li");
|
|
186
|
-
li.className = classString;
|
|
187
|
-
li.setAttribute("role", "none");
|
|
188
|
-
|
|
189
|
-
// div
|
|
190
|
-
var div = document.createElement("div");
|
|
191
|
-
div.className = "jqtree-element jqtree_common";
|
|
192
|
-
div.setAttribute("role", "none");
|
|
193
|
-
li.appendChild(div);
|
|
194
|
-
|
|
195
|
-
// title span
|
|
196
|
-
var titleSpan = this.createTitleSpan(node.name, isSelected, false, level);
|
|
197
|
-
div.appendChild(titleSpan);
|
|
198
|
-
return li;
|
|
199
|
-
}
|
|
200
|
-
}, {
|
|
201
|
-
key: "createTitleSpan",
|
|
202
|
-
value: function createTitleSpan(nodeName, isSelected, isFolder, level) {
|
|
203
|
-
var titleSpan = document.createElement("span");
|
|
204
|
-
var classes = "jqtree-title jqtree_common";
|
|
205
|
-
if (isFolder) {
|
|
206
|
-
classes += " jqtree-title-folder";
|
|
207
|
-
}
|
|
208
|
-
classes += " jqtree-title-button-".concat(this.treeWidget.options.buttonLeft ? "left" : "right");
|
|
209
|
-
titleSpan.className = classes;
|
|
210
|
-
if (isSelected) {
|
|
211
|
-
var tabIndex = this.treeWidget.options.tabIndex;
|
|
212
|
-
if (tabIndex !== undefined) {
|
|
213
|
-
titleSpan.setAttribute("tabindex", "".concat(tabIndex));
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
this.setTreeItemAriaAttributes(titleSpan, nodeName, level, isSelected);
|
|
217
|
-
if (this.treeWidget.options.autoEscape) {
|
|
218
|
-
titleSpan.textContent = nodeName;
|
|
219
|
-
} else {
|
|
220
|
-
titleSpan.innerHTML = nodeName;
|
|
221
|
-
}
|
|
222
|
-
return titleSpan;
|
|
223
|
-
}
|
|
224
|
-
}, {
|
|
225
|
-
key: "getButtonClasses",
|
|
226
|
-
value: function getButtonClasses(node) {
|
|
227
|
-
var classes = ["jqtree-toggler", "jqtree_common"];
|
|
228
|
-
if (!node.is_open) {
|
|
229
|
-
classes.push("jqtree-closed");
|
|
230
|
-
}
|
|
231
|
-
if (this.treeWidget.options.buttonLeft) {
|
|
232
|
-
classes.push("jqtree-toggler-left");
|
|
233
|
-
} else {
|
|
234
|
-
classes.push("jqtree-toggler-right");
|
|
235
|
-
}
|
|
236
|
-
return classes.join(" ");
|
|
237
|
-
}
|
|
238
|
-
}, {
|
|
239
|
-
key: "getFolderClasses",
|
|
240
|
-
value: function getFolderClasses(node, isSelected) {
|
|
241
|
-
var classes = ["jqtree-folder"];
|
|
242
|
-
if (!node.is_open) {
|
|
243
|
-
classes.push("jqtree-closed");
|
|
244
|
-
}
|
|
245
|
-
if (isSelected) {
|
|
246
|
-
classes.push("jqtree-selected");
|
|
247
|
-
}
|
|
248
|
-
if (node.is_loading) {
|
|
249
|
-
classes.push("jqtree-loading");
|
|
250
|
-
}
|
|
251
|
-
return classes.join(" ");
|
|
252
|
-
}
|
|
253
|
-
}, {
|
|
254
|
-
key: "createButtonElement",
|
|
255
|
-
value: function createButtonElement(value) {
|
|
256
|
-
if (typeof value === "string") {
|
|
257
|
-
// convert value to html
|
|
258
|
-
var div = document.createElement("div");
|
|
259
|
-
div.innerHTML = value;
|
|
260
|
-
return document.createTextNode(div.innerHTML);
|
|
261
|
-
} else {
|
|
262
|
-
return jQuery(value)[0];
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}]);
|
|
266
|
-
return ElementsRenderer;
|
|
267
|
-
}();
|
package/lib/jqtreeOptions.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/lib/keyHandler.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
13
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
14
|
-
var KeyHandler = exports["default"] = /*#__PURE__*/function () {
|
|
15
|
-
function KeyHandler(treeWidget) {
|
|
16
|
-
var _this = this;
|
|
17
|
-
_classCallCheck(this, KeyHandler);
|
|
18
|
-
_defineProperty(this, "treeWidget", void 0);
|
|
19
|
-
_defineProperty(this, "handleKeyDown", function (e) {
|
|
20
|
-
if (!_this.canHandleKeyboard()) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
var selectedNode = _this.treeWidget.getSelectedNode();
|
|
24
|
-
if (!selectedNode) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
var key = e.which;
|
|
28
|
-
switch (key) {
|
|
29
|
-
case KeyHandler.DOWN:
|
|
30
|
-
return _this.moveDown(selectedNode);
|
|
31
|
-
case KeyHandler.UP:
|
|
32
|
-
return _this.moveUp(selectedNode);
|
|
33
|
-
case KeyHandler.RIGHT:
|
|
34
|
-
return _this.moveRight(selectedNode);
|
|
35
|
-
case KeyHandler.LEFT:
|
|
36
|
-
return _this.moveLeft(selectedNode);
|
|
37
|
-
default:
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
this.treeWidget = treeWidget;
|
|
42
|
-
if (treeWidget.options.keyboardSupport) {
|
|
43
|
-
jQuery(document).on("keydown.jqtree", this.handleKeyDown);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
_createClass(KeyHandler, [{
|
|
47
|
-
key: "deinit",
|
|
48
|
-
value: function deinit() {
|
|
49
|
-
jQuery(document).off("keydown.jqtree");
|
|
50
|
-
}
|
|
51
|
-
}, {
|
|
52
|
-
key: "moveDown",
|
|
53
|
-
value: function moveDown(selectedNode) {
|
|
54
|
-
return this.selectNode(selectedNode.getNextVisibleNode());
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "moveUp",
|
|
58
|
-
value: function moveUp(selectedNode) {
|
|
59
|
-
return this.selectNode(selectedNode.getPreviousVisibleNode());
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "moveRight",
|
|
63
|
-
value: function moveRight(selectedNode) {
|
|
64
|
-
if (!selectedNode.isFolder()) {
|
|
65
|
-
return true;
|
|
66
|
-
} else {
|
|
67
|
-
// folder node
|
|
68
|
-
if (selectedNode.is_open) {
|
|
69
|
-
// Right moves to the first child of an open node
|
|
70
|
-
return this.selectNode(selectedNode.getNextVisibleNode());
|
|
71
|
-
} else {
|
|
72
|
-
// Right expands a closed node
|
|
73
|
-
this.treeWidget.openNode(selectedNode);
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
key: "moveLeft",
|
|
80
|
-
value: function moveLeft(selectedNode) {
|
|
81
|
-
if (selectedNode.isFolder() && selectedNode.is_open) {
|
|
82
|
-
// Left on an open node closes the node
|
|
83
|
-
this.treeWidget.closeNode(selectedNode);
|
|
84
|
-
return false;
|
|
85
|
-
} else {
|
|
86
|
-
// Left on a closed or end node moves focus to the node's parent
|
|
87
|
-
return this.selectNode(selectedNode.getParent());
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "selectNode",
|
|
92
|
-
value: function selectNode(node) {
|
|
93
|
-
if (!node) {
|
|
94
|
-
return true;
|
|
95
|
-
} else {
|
|
96
|
-
this.treeWidget.selectNode(node);
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "canHandleKeyboard",
|
|
102
|
-
value: function canHandleKeyboard() {
|
|
103
|
-
return (this.treeWidget.options.keyboardSupport || false) && this.treeWidget.selectNodeHandler.isFocusOnTree();
|
|
104
|
-
}
|
|
105
|
-
}]);
|
|
106
|
-
return KeyHandler;
|
|
107
|
-
}();
|
|
108
|
-
_defineProperty(KeyHandler, "LEFT", 37);
|
|
109
|
-
_defineProperty(KeyHandler, "UP", 38);
|
|
110
|
-
_defineProperty(KeyHandler, "RIGHT", 39);
|
|
111
|
-
_defineProperty(KeyHandler, "DOWN", 40);
|
package/lib/mouse.widget.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _simple = _interopRequireDefault(require("./simple.widget"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
22
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
23
|
-
This widget does the same a the mouse widget in jqueryui.
|
|
24
|
-
*/
|
|
25
|
-
var getPositionInfoFromMouseEvent = function getPositionInfoFromMouseEvent(e) {
|
|
26
|
-
return {
|
|
27
|
-
pageX: e.pageX,
|
|
28
|
-
pageY: e.pageY,
|
|
29
|
-
target: e.target,
|
|
30
|
-
originalEvent: e
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
var getPositionInfoFromTouch = function getPositionInfoFromTouch(touch, e) {
|
|
34
|
-
return {
|
|
35
|
-
pageX: touch.pageX,
|
|
36
|
-
pageY: touch.pageY,
|
|
37
|
-
target: touch.target,
|
|
38
|
-
originalEvent: e
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
42
|
-
_inherits(MouseWidget, _SimpleWidget);
|
|
43
|
-
var _super = _createSuper(MouseWidget);
|
|
44
|
-
function MouseWidget() {
|
|
45
|
-
var _this;
|
|
46
|
-
_classCallCheck(this, MouseWidget);
|
|
47
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
|
-
args[_key] = arguments[_key];
|
|
49
|
-
}
|
|
50
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "isMouseStarted", void 0);
|
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "mouseDownInfo", void 0);
|
|
53
|
-
_defineProperty(_assertThisInitialized(_this), "mouseDelayTimer", void 0);
|
|
54
|
-
_defineProperty(_assertThisInitialized(_this), "isMouseDelayMet", void 0);
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "mouseDown", function (e) {
|
|
56
|
-
// Left mouse button?
|
|
57
|
-
if (e.button !== 0) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
var result = _this.handleMouseDown(getPositionInfoFromMouseEvent(e));
|
|
61
|
-
if (result && e.cancelable) {
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
_defineProperty(_assertThisInitialized(_this), "mouseMove", function (e) {
|
|
66
|
-
_this.handleMouseMove(e, getPositionInfoFromMouseEvent(e));
|
|
67
|
-
});
|
|
68
|
-
_defineProperty(_assertThisInitialized(_this), "mouseUp", function (e) {
|
|
69
|
-
_this.handleMouseUp(getPositionInfoFromMouseEvent(e));
|
|
70
|
-
});
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "touchStart", function (e) {
|
|
72
|
-
if (!e) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (e.touches.length > 1) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
var touch = e.changedTouches[0];
|
|
79
|
-
if (!touch) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
_this.handleMouseDown(getPositionInfoFromTouch(touch, e));
|
|
83
|
-
});
|
|
84
|
-
_defineProperty(_assertThisInitialized(_this), "touchMove", function (e) {
|
|
85
|
-
if (!e) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (e.touches.length > 1) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
var touch = e.changedTouches[0];
|
|
92
|
-
if (!touch) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
_this.handleMouseMove(e, getPositionInfoFromTouch(touch, e));
|
|
96
|
-
});
|
|
97
|
-
_defineProperty(_assertThisInitialized(_this), "touchEnd", function (e) {
|
|
98
|
-
if (!e) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (e.touches.length > 1) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
var touch = e.changedTouches[0];
|
|
105
|
-
if (!touch) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
_this.handleMouseUp(getPositionInfoFromTouch(touch, e));
|
|
109
|
-
});
|
|
110
|
-
return _this;
|
|
111
|
-
}
|
|
112
|
-
_createClass(MouseWidget, [{
|
|
113
|
-
key: "init",
|
|
114
|
-
value: function init() {
|
|
115
|
-
var element = this.$el.get(0);
|
|
116
|
-
if (element) {
|
|
117
|
-
element.addEventListener("mousedown", this.mouseDown, {
|
|
118
|
-
passive: false
|
|
119
|
-
});
|
|
120
|
-
element.addEventListener("touchstart", this.touchStart, {
|
|
121
|
-
passive: false
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
this.isMouseStarted = false;
|
|
125
|
-
this.mouseDelayTimer = null;
|
|
126
|
-
this.isMouseDelayMet = false;
|
|
127
|
-
this.mouseDownInfo = null;
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "deinit",
|
|
131
|
-
value: function deinit() {
|
|
132
|
-
var el = this.$el.get(0);
|
|
133
|
-
if (el) {
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
135
|
-
el.removeEventListener("mousedown", this.mouseDown, {
|
|
136
|
-
passive: false
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
140
|
-
el.removeEventListener("touchstart", this.touchStart, {
|
|
141
|
-
passive: false
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
this.removeMouseMoveEventListeners();
|
|
145
|
-
}
|
|
146
|
-
}, {
|
|
147
|
-
key: "handleMouseDown",
|
|
148
|
-
value: function handleMouseDown(positionInfo) {
|
|
149
|
-
// We may have missed mouseup (out of window)
|
|
150
|
-
if (this.isMouseStarted) {
|
|
151
|
-
this.handleMouseUp(positionInfo);
|
|
152
|
-
}
|
|
153
|
-
this.mouseDownInfo = positionInfo;
|
|
154
|
-
if (!this.mouseCapture(positionInfo)) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
this.handleStartMouse();
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
key: "handleStartMouse",
|
|
162
|
-
value: function handleStartMouse() {
|
|
163
|
-
document.addEventListener("mousemove", this.mouseMove, {
|
|
164
|
-
passive: false
|
|
165
|
-
});
|
|
166
|
-
document.addEventListener("touchmove", this.touchMove, {
|
|
167
|
-
passive: false
|
|
168
|
-
});
|
|
169
|
-
document.addEventListener("mouseup", this.mouseUp, {
|
|
170
|
-
passive: false
|
|
171
|
-
});
|
|
172
|
-
document.addEventListener("touchend", this.touchEnd, {
|
|
173
|
-
passive: false
|
|
174
|
-
});
|
|
175
|
-
var mouseDelay = this.getMouseDelay();
|
|
176
|
-
if (mouseDelay) {
|
|
177
|
-
this.startMouseDelayTimer(mouseDelay);
|
|
178
|
-
} else {
|
|
179
|
-
this.isMouseDelayMet = true;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
key: "startMouseDelayTimer",
|
|
184
|
-
value: function startMouseDelayTimer(mouseDelay) {
|
|
185
|
-
var _this2 = this;
|
|
186
|
-
if (this.mouseDelayTimer) {
|
|
187
|
-
clearTimeout(this.mouseDelayTimer);
|
|
188
|
-
}
|
|
189
|
-
this.mouseDelayTimer = window.setTimeout(function () {
|
|
190
|
-
if (_this2.mouseDownInfo) {
|
|
191
|
-
_this2.isMouseDelayMet = true;
|
|
192
|
-
}
|
|
193
|
-
}, mouseDelay);
|
|
194
|
-
this.isMouseDelayMet = false;
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
key: "handleMouseMove",
|
|
198
|
-
value: function handleMouseMove(e, positionInfo) {
|
|
199
|
-
if (this.isMouseStarted) {
|
|
200
|
-
this.mouseDrag(positionInfo);
|
|
201
|
-
if (e.cancelable) {
|
|
202
|
-
e.preventDefault();
|
|
203
|
-
}
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (!this.isMouseDelayMet) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (this.mouseDownInfo) {
|
|
210
|
-
this.isMouseStarted = this.mouseStart(this.mouseDownInfo) !== false;
|
|
211
|
-
}
|
|
212
|
-
if (this.isMouseStarted) {
|
|
213
|
-
this.mouseDrag(positionInfo);
|
|
214
|
-
if (e.cancelable) {
|
|
215
|
-
e.preventDefault();
|
|
216
|
-
}
|
|
217
|
-
} else {
|
|
218
|
-
this.handleMouseUp(positionInfo);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}, {
|
|
222
|
-
key: "handleMouseUp",
|
|
223
|
-
value: function handleMouseUp(positionInfo) {
|
|
224
|
-
this.removeMouseMoveEventListeners();
|
|
225
|
-
this.isMouseDelayMet = false;
|
|
226
|
-
this.mouseDownInfo = null;
|
|
227
|
-
if (this.isMouseStarted) {
|
|
228
|
-
this.isMouseStarted = false;
|
|
229
|
-
this.mouseStop(positionInfo);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}, {
|
|
233
|
-
key: "removeMouseMoveEventListeners",
|
|
234
|
-
value: function removeMouseMoveEventListeners() {
|
|
235
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
236
|
-
document.removeEventListener("mousemove", this.mouseMove, {
|
|
237
|
-
passive: false
|
|
238
|
-
});
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
240
|
-
document.removeEventListener("touchmove", this.touchMove, {
|
|
241
|
-
passive: false
|
|
242
|
-
});
|
|
243
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
244
|
-
document.removeEventListener("mouseup", this.mouseUp, {
|
|
245
|
-
passive: false
|
|
246
|
-
});
|
|
247
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
248
|
-
document.removeEventListener("touchend", this.touchEnd, {
|
|
249
|
-
passive: false
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}]);
|
|
253
|
-
return MouseWidget;
|
|
254
|
-
}(_simple["default"]);
|
|
255
|
-
var _default = exports["default"] = MouseWidget;
|