jqtree 1.6.3 → 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.
- package/.github/workflows/ci.yml +21 -19
- package/.tool-versions +1 -0
- package/README.md +1 -1
- package/bower.json +10 -3
- package/config/production +2 -2
- package/config/{rollup.config.js → rollup.config.mjs} +3 -8
- package/docs/Gemfile.lock +3 -3
- package/docs/_config.yml +1 -1
- package/docs/_entries/10_changelog.md +9 -0
- package/docs/_entries/93_getnextnode.md +4 -1
- package/docs/_entries/{95_getpreviousnode.md → 95_getnextvisiblenode.md} +1 -1
- package/docs/_entries/96_getpreviousnode.md +0 -0
- package/docs/_entries/{96_getprevioussibling.md → 97_getprevioussibling.md} +0 -0
- package/docs/_entries/98_getpreviousvisiblenode.md +14 -0
- package/docs/_entries/{97_parent.md → 99_parent.md} +0 -0
- package/docs/package.json +7 -7
- package/docs/pnpm-lock.yaml +138 -108
- package/docs/static/bower.json +1 -1
- package/docs/static/bower_components/jquery/dist/jquery.js +209 -97
- package/docs/static/bower_components/jquery/dist/jquery.min.js +2 -2
- package/docs/static/documentation.css +224 -84
- package/docs/static/example.css +0 -1
- package/docs/tree.jquery.js +2 -2
- package/lib/dataLoader.js +5 -31
- package/lib/dragAndDropHandler.js +19 -132
- package/lib/elementsRenderer.js +29 -59
- package/lib/keyHandler.js +8 -32
- package/lib/mouse.widget.js +13 -74
- package/lib/node.js +60 -125
- package/lib/nodeElement.js +5 -72
- package/lib/playwright/coverage.js +58 -97
- package/lib/playwright/playwright.test.js +148 -210
- package/lib/playwright/testUtils.js +116 -182
- package/lib/saveStateHandler.js +12 -61
- package/lib/scrollHandler.js +17 -74
- package/lib/selectNodeHandler.js +5 -24
- package/lib/simple.widget.js +18 -53
- package/lib/test/jqTree/create.test.js +0 -4
- package/lib/test/jqTree/events.test.js +0 -7
- package/lib/test/jqTree/keyboard.test.js +0 -6
- package/lib/test/jqTree/loadOnDemand.test.js +84 -121
- package/lib/test/jqTree/methods.test.js +107 -150
- package/lib/test/jqTree/options.test.js +32 -54
- package/lib/test/node.test.js +127 -72
- package/lib/test/nodeUtil.test.js +0 -1
- package/lib/test/support/jqTreeMatchers.js +4 -9
- package/lib/test/support/setupTests.js +0 -4
- package/lib/test/support/testUtil.js +2 -11
- package/lib/test/support/treeStructure.js +0 -6
- package/lib/test/util.test.js +0 -1
- package/lib/tree.jquery.js +28 -239
- package/lib/util.js +0 -6
- package/lib/version.js +1 -1
- package/package.json +40 -39
- package/src/keyHandler.ts +3 -3
- package/src/node.ts +43 -12
- package/src/test/.eslintrc +3 -1
- package/src/test/node.test.ts +146 -54
- package/src/tree.jquery.ts +6 -5
- package/src/version.ts +1 -1
- package/tree.jquery.debug.js +202 -855
- package/tree.jquery.debug.js.map +1 -1
- package/tree.jquery.js +2 -2
- package/tree.jquery.js.map +1 -1
package/lib/elementsRenderer.js
CHANGED
|
@@ -4,38 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
8
7
|
var _util = require("./util");
|
|
9
|
-
|
|
8
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
10
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; } } }; }
|
|
11
|
-
|
|
12
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); }
|
|
13
|
-
|
|
14
|
-
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; }
|
|
15
|
-
|
|
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; }
|
|
16
12
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
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, descriptor.key, descriptor); } }
|
|
19
|
-
|
|
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); } }
|
|
20
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; }
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
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); }
|
|
24
18
|
var ElementsRenderer = /*#__PURE__*/function () {
|
|
25
19
|
function ElementsRenderer(treeWidget) {
|
|
26
20
|
_classCallCheck(this, ElementsRenderer);
|
|
27
|
-
|
|
28
21
|
_defineProperty(this, "openedIconElement", void 0);
|
|
29
|
-
|
|
30
22
|
_defineProperty(this, "closedIconElement", void 0);
|
|
31
|
-
|
|
32
23
|
_defineProperty(this, "treeWidget", void 0);
|
|
33
|
-
|
|
34
24
|
this.treeWidget = treeWidget;
|
|
35
25
|
this.openedIconElement = this.createButtonElement(treeWidget.options.openedIcon || "+");
|
|
36
26
|
this.closedIconElement = this.createButtonElement(treeWidget.options.closedIcon || "-");
|
|
37
27
|
}
|
|
38
|
-
|
|
39
28
|
_createClass(ElementsRenderer, [{
|
|
40
29
|
key: "render",
|
|
41
30
|
value: function render(fromNode) {
|
|
@@ -56,15 +45,19 @@ var ElementsRenderer = /*#__PURE__*/function () {
|
|
|
56
45
|
key: "renderFromNode",
|
|
57
46
|
value: function renderFromNode(node) {
|
|
58
47
|
// remember current li
|
|
59
|
-
var $previousLi = jQuery(node.element);
|
|
48
|
+
var $previousLi = jQuery(node.element);
|
|
60
49
|
|
|
50
|
+
// create element
|
|
61
51
|
var li = this.createLi(node, node.getLevel());
|
|
62
|
-
this.attachNodeData(node, li);
|
|
52
|
+
this.attachNodeData(node, li);
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
// add element to dom
|
|
55
|
+
$previousLi.after(li);
|
|
65
56
|
|
|
66
|
-
|
|
57
|
+
// remove previous li
|
|
58
|
+
$previousLi.remove();
|
|
67
59
|
|
|
60
|
+
// create children
|
|
68
61
|
if (node.children) {
|
|
69
62
|
this.createDomElements(li, node.children, false, node.getLevel() + 1);
|
|
70
63
|
}
|
|
@@ -74,17 +67,14 @@ var ElementsRenderer = /*#__PURE__*/function () {
|
|
|
74
67
|
value: function createDomElements(element, children, isRootNode, level) {
|
|
75
68
|
var ul = this.createUl(isRootNode);
|
|
76
69
|
element.appendChild(ul);
|
|
77
|
-
|
|
78
70
|
var _iterator = _createForOfIteratorHelper(children),
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
_step;
|
|
81
72
|
try {
|
|
82
73
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
83
74
|
var child = _step.value;
|
|
84
75
|
var li = this.createLi(child, level);
|
|
85
76
|
ul.appendChild(li);
|
|
86
77
|
this.attachNodeData(child, li);
|
|
87
|
-
|
|
88
78
|
if (child.hasChildren()) {
|
|
89
79
|
this.createDomElements(li, child.children, false, level + 1);
|
|
90
80
|
}
|
|
@@ -106,23 +96,19 @@ var ElementsRenderer = /*#__PURE__*/function () {
|
|
|
106
96
|
value: function createUl(isRootNode) {
|
|
107
97
|
var classString;
|
|
108
98
|
var role;
|
|
109
|
-
|
|
110
99
|
if (!isRootNode) {
|
|
111
100
|
classString = "";
|
|
112
101
|
role = "group";
|
|
113
102
|
} else {
|
|
114
103
|
classString = "jqtree-tree";
|
|
115
104
|
role = "tree";
|
|
116
|
-
|
|
117
105
|
if (this.treeWidget.options.rtl) {
|
|
118
106
|
classString += " jqtree-rtl";
|
|
119
107
|
}
|
|
120
108
|
}
|
|
121
|
-
|
|
122
109
|
if (this.treeWidget.options.dragAndDrop) {
|
|
123
110
|
classString += " jqtree-dnd";
|
|
124
111
|
}
|
|
125
|
-
|
|
126
112
|
var ul = document.createElement("ul");
|
|
127
113
|
ul.className = "jqtree_common ".concat(classString);
|
|
128
114
|
ul.setAttribute("role", role);
|
|
@@ -134,11 +120,9 @@ var ElementsRenderer = /*#__PURE__*/function () {
|
|
|
134
120
|
var isSelected = Boolean(this.treeWidget.selectNodeHandler.isNodeSelected(node));
|
|
135
121
|
var mustShowFolder = node.isFolder() || node.isEmptyFolder && this.treeWidget.options.showEmptyFolder;
|
|
136
122
|
var li = mustShowFolder ? this.createFolderLi(node, level, isSelected) : this.createNodeLi(node, level, isSelected);
|
|
137
|
-
|
|
138
123
|
if (this.treeWidget.options.onCreateLi) {
|
|
139
124
|
this.treeWidget.options.onCreateLi(node, jQuery(li), isSelected);
|
|
140
125
|
}
|
|
141
|
-
|
|
142
126
|
return li;
|
|
143
127
|
}
|
|
144
128
|
}, {
|
|
@@ -146,56 +130,57 @@ var ElementsRenderer = /*#__PURE__*/function () {
|
|
|
146
130
|
value: function createFolderLi(node, level, isSelected) {
|
|
147
131
|
var buttonClasses = this.getButtonClasses(node);
|
|
148
132
|
var folderClasses = this.getFolderClasses(node, isSelected);
|
|
149
|
-
var iconElement = node.is_open ? this.openedIconElement : this.closedIconElement;
|
|
133
|
+
var iconElement = node.is_open ? this.openedIconElement : this.closedIconElement;
|
|
150
134
|
|
|
135
|
+
// li
|
|
151
136
|
var li = document.createElement("li");
|
|
152
137
|
li.className = "jqtree_common ".concat(folderClasses);
|
|
153
|
-
li.setAttribute("role", "presentation");
|
|
138
|
+
li.setAttribute("role", "presentation");
|
|
154
139
|
|
|
140
|
+
// div
|
|
155
141
|
var div = document.createElement("div");
|
|
156
142
|
div.className = "jqtree-element jqtree_common";
|
|
157
143
|
div.setAttribute("role", "presentation");
|
|
158
|
-
li.appendChild(div);
|
|
144
|
+
li.appendChild(div);
|
|
159
145
|
|
|
146
|
+
// button link
|
|
160
147
|
var buttonLink = document.createElement("a");
|
|
161
148
|
buttonLink.className = buttonClasses;
|
|
162
149
|
buttonLink.appendChild(iconElement.cloneNode(true));
|
|
163
150
|
buttonLink.setAttribute("role", "presentation");
|
|
164
151
|
buttonLink.setAttribute("aria-hidden", "true");
|
|
165
|
-
|
|
166
152
|
if (this.treeWidget.options.buttonLeft) {
|
|
167
153
|
div.appendChild(buttonLink);
|
|
168
|
-
}
|
|
169
|
-
|
|
154
|
+
}
|
|
170
155
|
|
|
156
|
+
// title span
|
|
171
157
|
div.appendChild(this.createTitleSpan(node.name, level, isSelected, node.is_open, true));
|
|
172
|
-
|
|
173
158
|
if (!this.treeWidget.options.buttonLeft) {
|
|
174
159
|
div.appendChild(buttonLink);
|
|
175
160
|
}
|
|
176
|
-
|
|
177
161
|
return li;
|
|
178
162
|
}
|
|
179
163
|
}, {
|
|
180
164
|
key: "createNodeLi",
|
|
181
165
|
value: function createNodeLi(node, level, isSelected) {
|
|
182
166
|
var liClasses = ["jqtree_common"];
|
|
183
|
-
|
|
184
167
|
if (isSelected) {
|
|
185
168
|
liClasses.push("jqtree-selected");
|
|
186
169
|
}
|
|
170
|
+
var classString = liClasses.join(" ");
|
|
187
171
|
|
|
188
|
-
|
|
189
|
-
|
|
172
|
+
// li
|
|
190
173
|
var li = document.createElement("li");
|
|
191
174
|
li.className = classString;
|
|
192
|
-
li.setAttribute("role", "presentation");
|
|
175
|
+
li.setAttribute("role", "presentation");
|
|
193
176
|
|
|
177
|
+
// div
|
|
194
178
|
var div = document.createElement("div");
|
|
195
179
|
div.className = "jqtree-element jqtree_common";
|
|
196
180
|
div.setAttribute("role", "presentation");
|
|
197
|
-
li.appendChild(div);
|
|
181
|
+
li.appendChild(div);
|
|
198
182
|
|
|
183
|
+
// title span
|
|
199
184
|
div.appendChild(this.createTitleSpan(node.name, level, isSelected, node.is_open, false));
|
|
200
185
|
return li;
|
|
201
186
|
}
|
|
@@ -204,68 +189,55 @@ var ElementsRenderer = /*#__PURE__*/function () {
|
|
|
204
189
|
value: function createTitleSpan(nodeName, level, isSelected, isOpen, isFolder) {
|
|
205
190
|
var titleSpan = document.createElement("span");
|
|
206
191
|
var classes = "jqtree-title jqtree_common";
|
|
207
|
-
|
|
208
192
|
if (isFolder) {
|
|
209
193
|
classes += " jqtree-title-folder";
|
|
210
194
|
}
|
|
211
|
-
|
|
212
195
|
classes += " jqtree-title-button-".concat(this.treeWidget.options.buttonLeft ? "left" : "right");
|
|
213
196
|
titleSpan.className = classes;
|
|
214
197
|
titleSpan.setAttribute("role", "treeitem");
|
|
215
198
|
titleSpan.setAttribute("aria-level", "".concat(level));
|
|
216
199
|
titleSpan.setAttribute("aria-selected", (0, _util.getBoolString)(isSelected));
|
|
217
200
|
titleSpan.setAttribute("aria-expanded", (0, _util.getBoolString)(isOpen));
|
|
218
|
-
|
|
219
201
|
if (isSelected) {
|
|
220
202
|
var tabIndex = this.treeWidget.options.tabIndex;
|
|
221
|
-
|
|
222
203
|
if (tabIndex !== undefined) {
|
|
223
204
|
titleSpan.setAttribute("tabindex", "".concat(tabIndex));
|
|
224
205
|
}
|
|
225
206
|
}
|
|
226
|
-
|
|
227
207
|
if (this.treeWidget.options.autoEscape) {
|
|
228
208
|
titleSpan.textContent = nodeName;
|
|
229
209
|
} else {
|
|
230
210
|
titleSpan.innerHTML = nodeName;
|
|
231
211
|
}
|
|
232
|
-
|
|
233
212
|
return titleSpan;
|
|
234
213
|
}
|
|
235
214
|
}, {
|
|
236
215
|
key: "getButtonClasses",
|
|
237
216
|
value: function getButtonClasses(node) {
|
|
238
217
|
var classes = ["jqtree-toggler", "jqtree_common"];
|
|
239
|
-
|
|
240
218
|
if (!node.is_open) {
|
|
241
219
|
classes.push("jqtree-closed");
|
|
242
220
|
}
|
|
243
|
-
|
|
244
221
|
if (this.treeWidget.options.buttonLeft) {
|
|
245
222
|
classes.push("jqtree-toggler-left");
|
|
246
223
|
} else {
|
|
247
224
|
classes.push("jqtree-toggler-right");
|
|
248
225
|
}
|
|
249
|
-
|
|
250
226
|
return classes.join(" ");
|
|
251
227
|
}
|
|
252
228
|
}, {
|
|
253
229
|
key: "getFolderClasses",
|
|
254
230
|
value: function getFolderClasses(node, isSelected) {
|
|
255
231
|
var classes = ["jqtree-folder"];
|
|
256
|
-
|
|
257
232
|
if (!node.is_open) {
|
|
258
233
|
classes.push("jqtree-closed");
|
|
259
234
|
}
|
|
260
|
-
|
|
261
235
|
if (isSelected) {
|
|
262
236
|
classes.push("jqtree-selected");
|
|
263
237
|
}
|
|
264
|
-
|
|
265
238
|
if (node.is_loading) {
|
|
266
239
|
classes.push("jqtree-loading");
|
|
267
240
|
}
|
|
268
|
-
|
|
269
241
|
return classes.join(" ");
|
|
270
242
|
}
|
|
271
243
|
}, {
|
|
@@ -281,8 +253,6 @@ var ElementsRenderer = /*#__PURE__*/function () {
|
|
|
281
253
|
}
|
|
282
254
|
}
|
|
283
255
|
}]);
|
|
284
|
-
|
|
285
256
|
return ElementsRenderer;
|
|
286
257
|
}();
|
|
287
|
-
|
|
288
258
|
exports["default"] = ElementsRenderer;
|
package/lib/keyHandler.js
CHANGED
|
@@ -4,61 +4,45 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
8
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
|
|
10
|
-
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, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
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); } }
|
|
12
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; }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
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); }
|
|
16
14
|
var KeyHandler = /*#__PURE__*/function () {
|
|
17
15
|
function KeyHandler(treeWidget) {
|
|
18
16
|
var _this = this;
|
|
19
|
-
|
|
20
17
|
_classCallCheck(this, KeyHandler);
|
|
21
|
-
|
|
22
18
|
_defineProperty(this, "treeWidget", void 0);
|
|
23
|
-
|
|
24
19
|
_defineProperty(this, "handleKeyDown", function (e) {
|
|
25
20
|
if (!_this.canHandleKeyboard()) {
|
|
26
21
|
return true;
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
var selectedNode = _this.treeWidget.getSelectedNode();
|
|
30
|
-
|
|
31
24
|
if (!selectedNode) {
|
|
32
25
|
return true;
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
var key = e.which;
|
|
36
|
-
|
|
37
28
|
switch (key) {
|
|
38
29
|
case KeyHandler.DOWN:
|
|
39
30
|
return _this.moveDown(selectedNode);
|
|
40
|
-
|
|
41
31
|
case KeyHandler.UP:
|
|
42
32
|
return _this.moveUp(selectedNode);
|
|
43
|
-
|
|
44
33
|
case KeyHandler.RIGHT:
|
|
45
34
|
return _this.moveRight(selectedNode);
|
|
46
|
-
|
|
47
35
|
case KeyHandler.LEFT:
|
|
48
36
|
return _this.moveLeft(selectedNode);
|
|
49
|
-
|
|
50
37
|
default:
|
|
51
38
|
return true;
|
|
52
39
|
}
|
|
53
40
|
});
|
|
54
|
-
|
|
55
41
|
this.treeWidget = treeWidget;
|
|
56
|
-
|
|
57
42
|
if (treeWidget.options.keyboardSupport) {
|
|
58
43
|
jQuery(document).on("keydown.jqtree", this.handleKeyDown);
|
|
59
44
|
}
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
_createClass(KeyHandler, [{
|
|
63
47
|
key: "deinit",
|
|
64
48
|
value: function deinit() {
|
|
@@ -67,12 +51,12 @@ var KeyHandler = /*#__PURE__*/function () {
|
|
|
67
51
|
}, {
|
|
68
52
|
key: "moveDown",
|
|
69
53
|
value: function moveDown(selectedNode) {
|
|
70
|
-
return this.selectNode(selectedNode.
|
|
54
|
+
return this.selectNode(selectedNode.getNextVisibleNode());
|
|
71
55
|
}
|
|
72
56
|
}, {
|
|
73
57
|
key: "moveUp",
|
|
74
58
|
value: function moveUp(selectedNode) {
|
|
75
|
-
return this.selectNode(selectedNode.
|
|
59
|
+
return this.selectNode(selectedNode.getPreviousVisibleNode());
|
|
76
60
|
}
|
|
77
61
|
}, {
|
|
78
62
|
key: "moveRight",
|
|
@@ -83,7 +67,7 @@ var KeyHandler = /*#__PURE__*/function () {
|
|
|
83
67
|
// folder node
|
|
84
68
|
if (selectedNode.is_open) {
|
|
85
69
|
// Right moves to the first child of an open node
|
|
86
|
-
return this.selectNode(selectedNode.
|
|
70
|
+
return this.selectNode(selectedNode.getNextVisibleNode());
|
|
87
71
|
} else {
|
|
88
72
|
// Right expands a closed node
|
|
89
73
|
this.treeWidget.openNode(selectedNode);
|
|
@@ -110,11 +94,9 @@ var KeyHandler = /*#__PURE__*/function () {
|
|
|
110
94
|
return true;
|
|
111
95
|
} else {
|
|
112
96
|
this.treeWidget.selectNode(node);
|
|
113
|
-
|
|
114
97
|
if (!this.treeWidget.scrollHandler.isScrolledIntoView(jQuery(node.element).find(".jqtree-element"))) {
|
|
115
98
|
this.treeWidget.scrollToNode(node);
|
|
116
99
|
}
|
|
117
|
-
|
|
118
100
|
return false;
|
|
119
101
|
}
|
|
120
102
|
}
|
|
@@ -124,16 +106,10 @@ var KeyHandler = /*#__PURE__*/function () {
|
|
|
124
106
|
return (this.treeWidget.options.keyboardSupport || false) && this.treeWidget.selectNodeHandler.isFocusOnTree();
|
|
125
107
|
}
|
|
126
108
|
}]);
|
|
127
|
-
|
|
128
109
|
return KeyHandler;
|
|
129
110
|
}();
|
|
130
|
-
|
|
131
111
|
exports["default"] = KeyHandler;
|
|
132
|
-
|
|
133
112
|
_defineProperty(KeyHandler, "LEFT", 37);
|
|
134
|
-
|
|
135
113
|
_defineProperty(KeyHandler, "UP", 38);
|
|
136
|
-
|
|
137
114
|
_defineProperty(KeyHandler, "RIGHT", 39);
|
|
138
|
-
|
|
139
115
|
_defineProperty(KeyHandler, "DOWN", 40);
|
package/lib/mouse.widget.js
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
7
|
var _simple = _interopRequireDefault(require("./simple.widget"));
|
|
11
|
-
|
|
12
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
9
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
14
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
|
-
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, descriptor.key, descriptor); } }
|
|
17
|
-
|
|
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); } }
|
|
18
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; }
|
|
19
|
-
|
|
20
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); }
|
|
21
|
-
|
|
22
14
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
23
|
-
|
|
24
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); }; }
|
|
25
|
-
|
|
26
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); }
|
|
27
|
-
|
|
28
17
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
29
|
-
|
|
30
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; } }
|
|
31
|
-
|
|
32
19
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
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); }
|
|
36
23
|
var getPositionInfoFromMouseEvent = function getPositionInfoFromMouseEvent(e) {
|
|
37
24
|
return {
|
|
38
25
|
pageX: e.pageX,
|
|
@@ -41,7 +28,6 @@ var getPositionInfoFromMouseEvent = function getPositionInfoFromMouseEvent(e) {
|
|
|
41
28
|
originalEvent: e
|
|
42
29
|
};
|
|
43
30
|
};
|
|
44
|
-
|
|
45
31
|
var getPositionInfoFromTouch = function getPositionInfoFromTouch(touch, e) {
|
|
46
32
|
return {
|
|
47
33
|
pageX: touch.pageX,
|
|
@@ -50,102 +36,72 @@ var getPositionInfoFromTouch = function getPositionInfoFromTouch(touch, e) {
|
|
|
50
36
|
originalEvent: e
|
|
51
37
|
};
|
|
52
38
|
};
|
|
53
|
-
|
|
54
39
|
var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
55
40
|
_inherits(MouseWidget, _SimpleWidget);
|
|
56
|
-
|
|
57
41
|
var _super = _createSuper(MouseWidget);
|
|
58
|
-
|
|
59
42
|
function MouseWidget() {
|
|
60
43
|
var _this;
|
|
61
|
-
|
|
62
44
|
_classCallCheck(this, MouseWidget);
|
|
63
|
-
|
|
64
45
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
65
46
|
args[_key] = arguments[_key];
|
|
66
47
|
}
|
|
67
|
-
|
|
68
48
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
69
|
-
|
|
70
49
|
_defineProperty(_assertThisInitialized(_this), "isMouseStarted", void 0);
|
|
71
|
-
|
|
72
50
|
_defineProperty(_assertThisInitialized(_this), "mouseDownInfo", void 0);
|
|
73
|
-
|
|
74
51
|
_defineProperty(_assertThisInitialized(_this), "mouseDelayTimer", void 0);
|
|
75
|
-
|
|
76
52
|
_defineProperty(_assertThisInitialized(_this), "isMouseDelayMet", void 0);
|
|
77
|
-
|
|
78
53
|
_defineProperty(_assertThisInitialized(_this), "mouseDown", function (e) {
|
|
79
54
|
// Left mouse button?
|
|
80
55
|
if (e.button !== 0) {
|
|
81
56
|
return;
|
|
82
57
|
}
|
|
83
|
-
|
|
84
58
|
var result = _this.handleMouseDown(getPositionInfoFromMouseEvent(e));
|
|
85
|
-
|
|
86
59
|
if (result && e.cancelable) {
|
|
87
60
|
e.preventDefault();
|
|
88
61
|
}
|
|
89
62
|
});
|
|
90
|
-
|
|
91
63
|
_defineProperty(_assertThisInitialized(_this), "mouseMove", function (e) {
|
|
92
64
|
_this.handleMouseMove(e, getPositionInfoFromMouseEvent(e));
|
|
93
65
|
});
|
|
94
|
-
|
|
95
66
|
_defineProperty(_assertThisInitialized(_this), "mouseUp", function (e) {
|
|
96
67
|
_this.handleMouseUp(getPositionInfoFromMouseEvent(e));
|
|
97
68
|
});
|
|
98
|
-
|
|
99
69
|
_defineProperty(_assertThisInitialized(_this), "touchStart", function (e) {
|
|
100
70
|
if (!e) {
|
|
101
71
|
return;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
73
|
if (e.touches.length > 1) {
|
|
105
74
|
return;
|
|
106
75
|
}
|
|
107
|
-
|
|
108
76
|
var touch = e.changedTouches[0];
|
|
109
|
-
|
|
110
77
|
_this.handleMouseDown(getPositionInfoFromTouch(touch, e));
|
|
111
78
|
});
|
|
112
|
-
|
|
113
79
|
_defineProperty(_assertThisInitialized(_this), "touchMove", function (e) {
|
|
114
80
|
if (!e) {
|
|
115
81
|
return;
|
|
116
82
|
}
|
|
117
|
-
|
|
118
83
|
if (e.touches.length > 1) {
|
|
119
84
|
return;
|
|
120
85
|
}
|
|
121
|
-
|
|
122
86
|
var touch = e.changedTouches[0];
|
|
123
|
-
|
|
124
87
|
_this.handleMouseMove(e, getPositionInfoFromTouch(touch, e));
|
|
125
88
|
});
|
|
126
|
-
|
|
127
89
|
_defineProperty(_assertThisInitialized(_this), "touchEnd", function (e) {
|
|
128
90
|
if (!e) {
|
|
129
91
|
return;
|
|
130
92
|
}
|
|
131
|
-
|
|
132
93
|
if (e.touches.length > 1) {
|
|
133
94
|
return;
|
|
134
95
|
}
|
|
135
|
-
|
|
136
96
|
var touch = e.changedTouches[0];
|
|
137
|
-
|
|
138
97
|
_this.handleMouseUp(getPositionInfoFromTouch(touch, e));
|
|
139
98
|
});
|
|
140
|
-
|
|
141
99
|
return _this;
|
|
142
100
|
}
|
|
143
|
-
|
|
144
101
|
_createClass(MouseWidget, [{
|
|
145
102
|
key: "init",
|
|
146
103
|
value: function init() {
|
|
147
104
|
var element = this.$el.get(0);
|
|
148
|
-
|
|
149
105
|
if (element) {
|
|
150
106
|
element.addEventListener("mousedown", this.mouseDown, {
|
|
151
107
|
passive: false
|
|
@@ -154,7 +110,6 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
154
110
|
passive: false
|
|
155
111
|
});
|
|
156
112
|
}
|
|
157
|
-
|
|
158
113
|
this.isMouseStarted = false;
|
|
159
114
|
this.mouseDelayTimer = null;
|
|
160
115
|
this.isMouseDelayMet = false;
|
|
@@ -164,18 +119,17 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
164
119
|
key: "deinit",
|
|
165
120
|
value: function deinit() {
|
|
166
121
|
var el = this.$el.get(0);
|
|
167
|
-
|
|
168
122
|
if (el) {
|
|
169
123
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
170
124
|
el.removeEventListener("mousedown", this.mouseDown, {
|
|
171
125
|
passive: false
|
|
172
|
-
});
|
|
126
|
+
});
|
|
173
127
|
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
174
129
|
el.removeEventListener("touchstart", this.touchStart, {
|
|
175
130
|
passive: false
|
|
176
131
|
});
|
|
177
132
|
}
|
|
178
|
-
|
|
179
133
|
this.removeMouseMoveEventListeners();
|
|
180
134
|
}
|
|
181
135
|
}, {
|
|
@@ -185,13 +139,10 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
185
139
|
if (this.isMouseStarted) {
|
|
186
140
|
this.handleMouseUp(positionInfo);
|
|
187
141
|
}
|
|
188
|
-
|
|
189
142
|
this.mouseDownInfo = positionInfo;
|
|
190
|
-
|
|
191
143
|
if (!this.mouseCapture(positionInfo)) {
|
|
192
144
|
return false;
|
|
193
145
|
}
|
|
194
|
-
|
|
195
146
|
this.handleStartMouse();
|
|
196
147
|
return true;
|
|
197
148
|
}
|
|
@@ -211,7 +162,6 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
211
162
|
passive: false
|
|
212
163
|
});
|
|
213
164
|
var mouseDelay = this.getMouseDelay();
|
|
214
|
-
|
|
215
165
|
if (mouseDelay) {
|
|
216
166
|
this.startMouseDelayTimer(mouseDelay);
|
|
217
167
|
} else {
|
|
@@ -222,11 +172,9 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
222
172
|
key: "startMouseDelayTimer",
|
|
223
173
|
value: function startMouseDelayTimer(mouseDelay) {
|
|
224
174
|
var _this2 = this;
|
|
225
|
-
|
|
226
175
|
if (this.mouseDelayTimer) {
|
|
227
176
|
clearTimeout(this.mouseDelayTimer);
|
|
228
177
|
}
|
|
229
|
-
|
|
230
178
|
this.mouseDelayTimer = window.setTimeout(function () {
|
|
231
179
|
if (_this2.mouseDownInfo) {
|
|
232
180
|
_this2.isMouseDelayMet = true;
|
|
@@ -239,25 +187,19 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
239
187
|
value: function handleMouseMove(e, positionInfo) {
|
|
240
188
|
if (this.isMouseStarted) {
|
|
241
189
|
this.mouseDrag(positionInfo);
|
|
242
|
-
|
|
243
190
|
if (e.cancelable) {
|
|
244
191
|
e.preventDefault();
|
|
245
192
|
}
|
|
246
|
-
|
|
247
193
|
return;
|
|
248
194
|
}
|
|
249
|
-
|
|
250
195
|
if (!this.isMouseDelayMet) {
|
|
251
196
|
return;
|
|
252
197
|
}
|
|
253
|
-
|
|
254
198
|
if (this.mouseDownInfo) {
|
|
255
199
|
this.isMouseStarted = this.mouseStart(this.mouseDownInfo) !== false;
|
|
256
200
|
}
|
|
257
|
-
|
|
258
201
|
if (this.isMouseStarted) {
|
|
259
202
|
this.mouseDrag(positionInfo);
|
|
260
|
-
|
|
261
203
|
if (e.cancelable) {
|
|
262
204
|
e.preventDefault();
|
|
263
205
|
}
|
|
@@ -271,7 +213,6 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
271
213
|
this.removeMouseMoveEventListeners();
|
|
272
214
|
this.isMouseDelayMet = false;
|
|
273
215
|
this.mouseDownInfo = null;
|
|
274
|
-
|
|
275
216
|
if (this.isMouseStarted) {
|
|
276
217
|
this.isMouseStarted = false;
|
|
277
218
|
this.mouseStop(positionInfo);
|
|
@@ -283,24 +224,22 @@ var MouseWidget = /*#__PURE__*/function (_SimpleWidget) {
|
|
|
283
224
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
284
225
|
document.removeEventListener("mousemove", this.mouseMove, {
|
|
285
226
|
passive: false
|
|
286
|
-
});
|
|
287
|
-
|
|
227
|
+
});
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
288
229
|
document.removeEventListener("touchmove", this.touchMove, {
|
|
289
230
|
passive: false
|
|
290
|
-
});
|
|
291
|
-
|
|
231
|
+
});
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
292
233
|
document.removeEventListener("mouseup", this.mouseUp, {
|
|
293
234
|
passive: false
|
|
294
|
-
});
|
|
295
|
-
|
|
235
|
+
});
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
296
237
|
document.removeEventListener("touchend", this.touchEnd, {
|
|
297
238
|
passive: false
|
|
298
239
|
});
|
|
299
240
|
}
|
|
300
241
|
}]);
|
|
301
|
-
|
|
302
242
|
return MouseWidget;
|
|
303
243
|
}(_simple["default"]);
|
|
304
|
-
|
|
305
244
|
var _default = MouseWidget;
|
|
306
245
|
exports["default"] = _default;
|