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
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
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); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.selectNode = exports.moveMouseToNode = exports.getTreeStructure = exports.findNodeElement = exports.dragAndDrop = void 0;
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
-
var locateTitle = function locateTitle(page, title) {
|
|
12
|
-
return page.locator(".jqtree-title", {
|
|
13
|
-
hasText: title
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var findNodeElement = exports.findNodeElement = /*#__PURE__*/function () {
|
|
17
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(page, title) {
|
|
18
|
-
var titleElement, nodeElement;
|
|
19
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
20
|
-
while (1) switch (_context.prev = _context.next) {
|
|
21
|
-
case 0:
|
|
22
|
-
_context.next = 2;
|
|
23
|
-
return locateTitle(page, title).elementHandle();
|
|
24
|
-
case 2:
|
|
25
|
-
titleElement = _context.sent;
|
|
26
|
-
if (titleElement) {
|
|
27
|
-
_context.next = 5;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
throw new Error("Title element not found: ".concat(title));
|
|
31
|
-
case 5:
|
|
32
|
-
_context.next = 7;
|
|
33
|
-
return titleElement.evaluateHandle(function (el) {
|
|
34
|
-
var li = el.closest("li");
|
|
35
|
-
if (!li) {
|
|
36
|
-
throw Error("Node element not found");
|
|
37
|
-
}
|
|
38
|
-
return li;
|
|
39
|
-
});
|
|
40
|
-
case 7:
|
|
41
|
-
nodeElement = _context.sent;
|
|
42
|
-
return _context.abrupt("return", nodeElement);
|
|
43
|
-
case 9:
|
|
44
|
-
case "end":
|
|
45
|
-
return _context.stop();
|
|
46
|
-
}
|
|
47
|
-
}, _callee);
|
|
48
|
-
}));
|
|
49
|
-
return function findNodeElement(_x, _x2) {
|
|
50
|
-
return _ref.apply(this, arguments);
|
|
51
|
-
};
|
|
52
|
-
}();
|
|
53
|
-
var selectNode = exports.selectNode = /*#__PURE__*/function () {
|
|
54
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(nodeElement) {
|
|
55
|
-
var titleHandle;
|
|
56
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
57
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
58
|
-
case 0:
|
|
59
|
-
_context2.next = 2;
|
|
60
|
-
return nodeElement.$(".jqtree-title");
|
|
61
|
-
case 2:
|
|
62
|
-
titleHandle = _context2.sent;
|
|
63
|
-
if (titleHandle) {
|
|
64
|
-
_context2.next = 5;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
throw new Error("Could not select: title element not found");
|
|
68
|
-
case 5:
|
|
69
|
-
_context2.next = 7;
|
|
70
|
-
return titleHandle.click();
|
|
71
|
-
case 7:
|
|
72
|
-
case "end":
|
|
73
|
-
return _context2.stop();
|
|
74
|
-
}
|
|
75
|
-
}, _callee2);
|
|
76
|
-
}));
|
|
77
|
-
return function selectNode(_x3) {
|
|
78
|
-
return _ref2.apply(this, arguments);
|
|
79
|
-
};
|
|
80
|
-
}();
|
|
81
|
-
var getRect = /*#__PURE__*/function () {
|
|
82
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(elementHandle) {
|
|
83
|
-
var boundingBox;
|
|
84
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
85
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
86
|
-
case 0:
|
|
87
|
-
_context3.next = 2;
|
|
88
|
-
return elementHandle.boundingBox();
|
|
89
|
-
case 2:
|
|
90
|
-
boundingBox = _context3.sent;
|
|
91
|
-
if (boundingBox) {
|
|
92
|
-
_context3.next = 5;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
throw "No bounding box";
|
|
96
|
-
case 5:
|
|
97
|
-
return _context3.abrupt("return", boundingBox);
|
|
98
|
-
case 6:
|
|
99
|
-
case "end":
|
|
100
|
-
return _context3.stop();
|
|
101
|
-
}
|
|
102
|
-
}, _callee3);
|
|
103
|
-
}));
|
|
104
|
-
return function getRect(_x4) {
|
|
105
|
-
return _ref3.apply(this, arguments);
|
|
106
|
-
};
|
|
107
|
-
}();
|
|
108
|
-
var getTreeStructure = exports.getTreeStructure = /*#__PURE__*/function () {
|
|
109
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(page) {
|
|
110
|
-
var structure;
|
|
111
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
112
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
113
|
-
case 0:
|
|
114
|
-
_context4.next = 2;
|
|
115
|
-
return page.evaluate("\n ;\n function getTreeNode($li) {\n const $div = $li.children(\"div.jqtree-element\");\n const $span = $div.children(\"span.jqtree-title\");\n const name = $span.text();\n const selected = $li.hasClass(\"jqtree-selected\");\n\n if ($li.hasClass(\"jqtree-folder\")) {\n const $ul = $li.children(\"ul.jqtree_common\");\n\n return {\n nodeType: \"folder\",\n children: getChildren($ul),\n name,\n open: !$li.hasClass(\"jqtree-closed\"),\n selected,\n };\n } else {\n return {\n nodeType: \"child\",\n name,\n selected,\n };\n }\n }\n\n function getChildren($ul) {\n return $ul\n .children(\"li.jqtree_common\")\n .map((_, li) => {\n return getTreeNode(jQuery(li));\n })\n .get();\n }\n\n JSON.stringify(window.getChildren(jQuery(\"ul.jqtree-tree\")));\n");
|
|
116
|
-
case 2:
|
|
117
|
-
structure = _context4.sent;
|
|
118
|
-
return _context4.abrupt("return", JSON.parse(structure));
|
|
119
|
-
case 4:
|
|
120
|
-
case "end":
|
|
121
|
-
return _context4.stop();
|
|
122
|
-
}
|
|
123
|
-
}, _callee4);
|
|
124
|
-
}));
|
|
125
|
-
return function getTreeStructure(_x5) {
|
|
126
|
-
return _ref4.apply(this, arguments);
|
|
127
|
-
};
|
|
128
|
-
}();
|
|
129
|
-
var getNodeRect = /*#__PURE__*/function () {
|
|
130
|
-
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(page, title) {
|
|
131
|
-
var titleElement, rect;
|
|
132
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
133
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
134
|
-
case 0:
|
|
135
|
-
_context5.next = 2;
|
|
136
|
-
return locateTitle(page, title).elementHandle();
|
|
137
|
-
case 2:
|
|
138
|
-
titleElement = _context5.sent;
|
|
139
|
-
if (titleElement) {
|
|
140
|
-
_context5.next = 5;
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
throw Error("Element not found");
|
|
144
|
-
case 5:
|
|
145
|
-
_context5.next = 7;
|
|
146
|
-
return getRect(titleElement);
|
|
147
|
-
case 7:
|
|
148
|
-
rect = _context5.sent;
|
|
149
|
-
return _context5.abrupt("return", rect);
|
|
150
|
-
case 9:
|
|
151
|
-
case "end":
|
|
152
|
-
return _context5.stop();
|
|
153
|
-
}
|
|
154
|
-
}, _callee5);
|
|
155
|
-
}));
|
|
156
|
-
return function getNodeRect(_x6, _x7) {
|
|
157
|
-
return _ref5.apply(this, arguments);
|
|
158
|
-
};
|
|
159
|
-
}();
|
|
160
|
-
var moveMouseToNode = exports.moveMouseToNode = /*#__PURE__*/function () {
|
|
161
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(page, title) {
|
|
162
|
-
var rect;
|
|
163
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
164
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
165
|
-
case 0:
|
|
166
|
-
_context6.next = 2;
|
|
167
|
-
return getNodeRect(page, title);
|
|
168
|
-
case 2:
|
|
169
|
-
rect = _context6.sent;
|
|
170
|
-
_context6.next = 5;
|
|
171
|
-
return page.mouse.move(rect.x + 10, rect.y + rect.height / 2);
|
|
172
|
-
case 5:
|
|
173
|
-
case "end":
|
|
174
|
-
return _context6.stop();
|
|
175
|
-
}
|
|
176
|
-
}, _callee6);
|
|
177
|
-
}));
|
|
178
|
-
return function moveMouseToNode(_x8, _x9) {
|
|
179
|
-
return _ref6.apply(this, arguments);
|
|
180
|
-
};
|
|
181
|
-
}();
|
|
182
|
-
var dragAndDrop = exports.dragAndDrop = /*#__PURE__*/function () {
|
|
183
|
-
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(page, fromTitle, toTitle) {
|
|
184
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
185
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
186
|
-
case 0:
|
|
187
|
-
_context7.next = 2;
|
|
188
|
-
return moveMouseToNode(page, fromTitle);
|
|
189
|
-
case 2:
|
|
190
|
-
_context7.next = 4;
|
|
191
|
-
return page.mouse.down();
|
|
192
|
-
case 4:
|
|
193
|
-
_context7.next = 6;
|
|
194
|
-
return page.waitForTimeout(200);
|
|
195
|
-
case 6:
|
|
196
|
-
_context7.next = 8;
|
|
197
|
-
return moveMouseToNode(page, toTitle);
|
|
198
|
-
case 8:
|
|
199
|
-
_context7.next = 10;
|
|
200
|
-
return page.mouse.up();
|
|
201
|
-
case 10:
|
|
202
|
-
case "end":
|
|
203
|
-
return _context7.stop();
|
|
204
|
-
}
|
|
205
|
-
}, _callee7);
|
|
206
|
-
}));
|
|
207
|
-
return function dragAndDrop(_x10, _x11, _x12) {
|
|
208
|
-
return _ref7.apply(this, arguments);
|
|
209
|
-
};
|
|
210
|
-
}();
|
package/lib/saveStateHandler.js
DELETED
|
@@ -1,277 +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 SaveStateHandler = exports["default"] = /*#__PURE__*/function () {
|
|
19
|
-
function SaveStateHandler(treeWidget) {
|
|
20
|
-
_classCallCheck(this, SaveStateHandler);
|
|
21
|
-
_defineProperty(this, "treeWidget", void 0);
|
|
22
|
-
_defineProperty(this, "_supportsLocalStorage", void 0);
|
|
23
|
-
this.treeWidget = treeWidget;
|
|
24
|
-
}
|
|
25
|
-
_createClass(SaveStateHandler, [{
|
|
26
|
-
key: "saveState",
|
|
27
|
-
value: function saveState() {
|
|
28
|
-
var state = JSON.stringify(this.getState());
|
|
29
|
-
if (this.treeWidget.options.onSetStateFromStorage) {
|
|
30
|
-
this.treeWidget.options.onSetStateFromStorage(state);
|
|
31
|
-
} else if (this.supportsLocalStorage()) {
|
|
32
|
-
localStorage.setItem(this.getKeyName(), state);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "getStateFromStorage",
|
|
37
|
-
value: function getStateFromStorage() {
|
|
38
|
-
var jsonData = this.loadFromStorage();
|
|
39
|
-
if (jsonData) {
|
|
40
|
-
return this.parseState(jsonData);
|
|
41
|
-
} else {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
key: "getState",
|
|
47
|
-
value: function getState() {
|
|
48
|
-
var _this = this;
|
|
49
|
-
var getOpenNodeIds = function getOpenNodeIds() {
|
|
50
|
-
var openNodes = [];
|
|
51
|
-
_this.treeWidget.tree.iterate(function (node) {
|
|
52
|
-
if (node.is_open && node.id && node.hasChildren()) {
|
|
53
|
-
openNodes.push(node.id);
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
});
|
|
57
|
-
return openNodes;
|
|
58
|
-
};
|
|
59
|
-
var getSelectedNodeIds = function getSelectedNodeIds() {
|
|
60
|
-
var selectedNodeIds = [];
|
|
61
|
-
_this.treeWidget.getSelectedNodes().forEach(function (node) {
|
|
62
|
-
if (node.id != null) {
|
|
63
|
-
selectedNodeIds.push(node.id);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return selectedNodeIds;
|
|
67
|
-
};
|
|
68
|
-
return {
|
|
69
|
-
open_nodes: getOpenNodeIds(),
|
|
70
|
-
selected_node: getSelectedNodeIds()
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/*
|
|
75
|
-
Set initial state
|
|
76
|
-
Don't handle nodes that are loaded on demand
|
|
77
|
-
result: must load on demand
|
|
78
|
-
*/
|
|
79
|
-
}, {
|
|
80
|
-
key: "setInitialState",
|
|
81
|
-
value: function setInitialState(state) {
|
|
82
|
-
if (!state) {
|
|
83
|
-
return false;
|
|
84
|
-
} else {
|
|
85
|
-
var mustLoadOnDemand = false;
|
|
86
|
-
if (state.open_nodes) {
|
|
87
|
-
mustLoadOnDemand = this.openInitialNodes(state.open_nodes);
|
|
88
|
-
}
|
|
89
|
-
if (state.selected_node) {
|
|
90
|
-
this.resetSelection();
|
|
91
|
-
this.selectInitialNodes(state.selected_node);
|
|
92
|
-
}
|
|
93
|
-
return mustLoadOnDemand;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "setInitialStateOnDemand",
|
|
98
|
-
value: function setInitialStateOnDemand(state, cbFinished) {
|
|
99
|
-
if (state) {
|
|
100
|
-
this.doSetInitialStateOnDemand(state.open_nodes, state.selected_node, cbFinished);
|
|
101
|
-
} else {
|
|
102
|
-
cbFinished();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "getNodeIdToBeSelected",
|
|
107
|
-
value: function getNodeIdToBeSelected() {
|
|
108
|
-
var state = this.getStateFromStorage();
|
|
109
|
-
if (state && state.selected_node) {
|
|
110
|
-
return state.selected_node[0] || null;
|
|
111
|
-
} else {
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "parseState",
|
|
117
|
-
value: function parseState(jsonData) {
|
|
118
|
-
var state = JSON.parse(jsonData);
|
|
119
|
-
|
|
120
|
-
// Check if selected_node is an int (instead of an array)
|
|
121
|
-
if (state && state.selected_node && (0, _util.isInt)(state.selected_node)) {
|
|
122
|
-
// Convert to array
|
|
123
|
-
state.selected_node = [state.selected_node];
|
|
124
|
-
}
|
|
125
|
-
return state;
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "loadFromStorage",
|
|
129
|
-
value: function loadFromStorage() {
|
|
130
|
-
if (this.treeWidget.options.onGetStateFromStorage) {
|
|
131
|
-
return this.treeWidget.options.onGetStateFromStorage();
|
|
132
|
-
} else if (this.supportsLocalStorage()) {
|
|
133
|
-
return localStorage.getItem(this.getKeyName());
|
|
134
|
-
} else {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
key: "openInitialNodes",
|
|
140
|
-
value: function openInitialNodes(nodeIds) {
|
|
141
|
-
var mustLoadOnDemand = false;
|
|
142
|
-
var _iterator = _createForOfIteratorHelper(nodeIds),
|
|
143
|
-
_step;
|
|
144
|
-
try {
|
|
145
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
146
|
-
var nodeId = _step.value;
|
|
147
|
-
var node = this.treeWidget.getNodeById(nodeId);
|
|
148
|
-
if (node) {
|
|
149
|
-
if (!node.load_on_demand) {
|
|
150
|
-
node.is_open = true;
|
|
151
|
-
} else {
|
|
152
|
-
mustLoadOnDemand = true;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
} catch (err) {
|
|
157
|
-
_iterator.e(err);
|
|
158
|
-
} finally {
|
|
159
|
-
_iterator.f();
|
|
160
|
-
}
|
|
161
|
-
return mustLoadOnDemand;
|
|
162
|
-
}
|
|
163
|
-
}, {
|
|
164
|
-
key: "selectInitialNodes",
|
|
165
|
-
value: function selectInitialNodes(nodeIds) {
|
|
166
|
-
var selectCount = 0;
|
|
167
|
-
var _iterator2 = _createForOfIteratorHelper(nodeIds),
|
|
168
|
-
_step2;
|
|
169
|
-
try {
|
|
170
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
171
|
-
var nodeId = _step2.value;
|
|
172
|
-
var node = this.treeWidget.getNodeById(nodeId);
|
|
173
|
-
if (node) {
|
|
174
|
-
selectCount += 1;
|
|
175
|
-
this.treeWidget.selectNodeHandler.addToSelection(node);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
} catch (err) {
|
|
179
|
-
_iterator2.e(err);
|
|
180
|
-
} finally {
|
|
181
|
-
_iterator2.f();
|
|
182
|
-
}
|
|
183
|
-
return selectCount !== 0;
|
|
184
|
-
}
|
|
185
|
-
}, {
|
|
186
|
-
key: "resetSelection",
|
|
187
|
-
value: function resetSelection() {
|
|
188
|
-
var selectNodeHandler = this.treeWidget.selectNodeHandler;
|
|
189
|
-
var selectedNodes = selectNodeHandler.getSelectedNodes();
|
|
190
|
-
selectedNodes.forEach(function (node) {
|
|
191
|
-
selectNodeHandler.removeFromSelection(node);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}, {
|
|
195
|
-
key: "doSetInitialStateOnDemand",
|
|
196
|
-
value: function doSetInitialStateOnDemand(nodeIdsParam, selectedNodes, cbFinished) {
|
|
197
|
-
var _this2 = this;
|
|
198
|
-
var loadingCount = 0;
|
|
199
|
-
var nodeIds = nodeIdsParam;
|
|
200
|
-
var openNodes = function openNodes() {
|
|
201
|
-
var newNodesIds = [];
|
|
202
|
-
var _iterator3 = _createForOfIteratorHelper(nodeIds),
|
|
203
|
-
_step3;
|
|
204
|
-
try {
|
|
205
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
206
|
-
var nodeId = _step3.value;
|
|
207
|
-
var node = _this2.treeWidget.getNodeById(nodeId);
|
|
208
|
-
if (!node) {
|
|
209
|
-
newNodesIds.push(nodeId);
|
|
210
|
-
} else {
|
|
211
|
-
if (!node.is_loading) {
|
|
212
|
-
if (node.load_on_demand) {
|
|
213
|
-
loadAndOpenNode(node);
|
|
214
|
-
} else {
|
|
215
|
-
_this2.treeWidget._openNode(node, false, null);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
} catch (err) {
|
|
221
|
-
_iterator3.e(err);
|
|
222
|
-
} finally {
|
|
223
|
-
_iterator3.f();
|
|
224
|
-
}
|
|
225
|
-
nodeIds = newNodesIds;
|
|
226
|
-
if (_this2.selectInitialNodes(selectedNodes)) {
|
|
227
|
-
_this2.treeWidget._refreshElements(null);
|
|
228
|
-
}
|
|
229
|
-
if (loadingCount === 0) {
|
|
230
|
-
cbFinished();
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
var loadAndOpenNode = function loadAndOpenNode(node) {
|
|
234
|
-
loadingCount += 1;
|
|
235
|
-
_this2.treeWidget._openNode(node, false, function () {
|
|
236
|
-
loadingCount -= 1;
|
|
237
|
-
openNodes();
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
openNodes();
|
|
241
|
-
}
|
|
242
|
-
}, {
|
|
243
|
-
key: "getKeyName",
|
|
244
|
-
value: function getKeyName() {
|
|
245
|
-
if (typeof this.treeWidget.options.saveState === "string") {
|
|
246
|
-
return this.treeWidget.options.saveState;
|
|
247
|
-
} else {
|
|
248
|
-
return "tree";
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}, {
|
|
252
|
-
key: "supportsLocalStorage",
|
|
253
|
-
value: function supportsLocalStorage() {
|
|
254
|
-
var testSupport = function testSupport() {
|
|
255
|
-
// Is local storage supported?
|
|
256
|
-
if (localStorage == null) {
|
|
257
|
-
return false;
|
|
258
|
-
} else {
|
|
259
|
-
// Check if it's possible to store an item. Safari does not allow this in private browsing mode.
|
|
260
|
-
try {
|
|
261
|
-
var key = "_storage_test";
|
|
262
|
-
sessionStorage.setItem(key, "value");
|
|
263
|
-
sessionStorage.removeItem(key);
|
|
264
|
-
} catch (error) {
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
if (this._supportsLocalStorage == null) {
|
|
271
|
-
this._supportsLocalStorage = testSupport();
|
|
272
|
-
}
|
|
273
|
-
return this._supportsLocalStorage;
|
|
274
|
-
}
|
|
275
|
-
}]);
|
|
276
|
-
return SaveStateHandler;
|
|
277
|
-
}();
|
|
@@ -1,160 +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 ContainerScrollParent = exports["default"] = /*#__PURE__*/function () {
|
|
15
|
-
function ContainerScrollParent(_ref) {
|
|
16
|
-
var $container = _ref.$container,
|
|
17
|
-
refreshHitAreas = _ref.refreshHitAreas;
|
|
18
|
-
_classCallCheck(this, ContainerScrollParent);
|
|
19
|
-
_defineProperty(this, "$container", void 0);
|
|
20
|
-
_defineProperty(this, "horizontalScrollDirection", void 0);
|
|
21
|
-
_defineProperty(this, "horizontalScrollTimeout", void 0);
|
|
22
|
-
_defineProperty(this, "refreshHitAreas", void 0);
|
|
23
|
-
_defineProperty(this, "scrollParentBottom", void 0);
|
|
24
|
-
_defineProperty(this, "scrollParentTop", void 0);
|
|
25
|
-
_defineProperty(this, "verticalScrollTimeout", void 0);
|
|
26
|
-
_defineProperty(this, "verticalScrollDirection", void 0);
|
|
27
|
-
this.$container = $container;
|
|
28
|
-
this.refreshHitAreas = refreshHitAreas;
|
|
29
|
-
}
|
|
30
|
-
_createClass(ContainerScrollParent, [{
|
|
31
|
-
key: "checkHorizontalScrolling",
|
|
32
|
-
value: function checkHorizontalScrolling(pageX) {
|
|
33
|
-
var newHorizontalScrollDirection = this.getNewHorizontalScrollDirection(pageX);
|
|
34
|
-
if (this.horizontalScrollDirection !== newHorizontalScrollDirection) {
|
|
35
|
-
this.horizontalScrollDirection = newHorizontalScrollDirection;
|
|
36
|
-
if (this.horizontalScrollTimeout != null) {
|
|
37
|
-
window.clearTimeout(this.verticalScrollTimeout);
|
|
38
|
-
}
|
|
39
|
-
if (newHorizontalScrollDirection) {
|
|
40
|
-
this.horizontalScrollTimeout = window.setTimeout(this.scrollHorizontally.bind(this), 40);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}, {
|
|
45
|
-
key: "checkVerticalScrolling",
|
|
46
|
-
value: function checkVerticalScrolling(pageY) {
|
|
47
|
-
var newVerticalScrollDirection = this.getNewVerticalScrollDirection(pageY);
|
|
48
|
-
if (this.verticalScrollDirection !== newVerticalScrollDirection) {
|
|
49
|
-
this.verticalScrollDirection = newVerticalScrollDirection;
|
|
50
|
-
if (this.verticalScrollTimeout != null) {
|
|
51
|
-
window.clearTimeout(this.verticalScrollTimeout);
|
|
52
|
-
this.verticalScrollTimeout = undefined;
|
|
53
|
-
}
|
|
54
|
-
if (newVerticalScrollDirection) {
|
|
55
|
-
this.verticalScrollTimeout = window.setTimeout(this.scrollVertically.bind(this), 40);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, {
|
|
60
|
-
key: "getScrollLeft",
|
|
61
|
-
value: function getScrollLeft() {
|
|
62
|
-
return this.$container.scrollLeft() || 0;
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "scrollToY",
|
|
66
|
-
value: function scrollToY(top) {
|
|
67
|
-
var container = this.$container.get(0);
|
|
68
|
-
container.scrollTop = top;
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "stopScrolling",
|
|
72
|
-
value: function stopScrolling() {
|
|
73
|
-
this.horizontalScrollDirection = undefined;
|
|
74
|
-
this.verticalScrollDirection = undefined;
|
|
75
|
-
this.scrollParentTop = undefined;
|
|
76
|
-
this.scrollParentBottom = undefined;
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
key: "getNewHorizontalScrollDirection",
|
|
80
|
-
value: function getNewHorizontalScrollDirection(pageX) {
|
|
81
|
-
var scrollParentOffset = this.$container.offset();
|
|
82
|
-
if (!scrollParentOffset) {
|
|
83
|
-
return undefined;
|
|
84
|
-
}
|
|
85
|
-
var container = this.$container.get(0);
|
|
86
|
-
var rightEdge = scrollParentOffset.left + container.clientWidth;
|
|
87
|
-
var leftEdge = scrollParentOffset.left;
|
|
88
|
-
var isNearRightEdge = pageX > rightEdge - 20;
|
|
89
|
-
var isNearLeftEdge = pageX < leftEdge + 20;
|
|
90
|
-
if (isNearRightEdge) {
|
|
91
|
-
return "right";
|
|
92
|
-
} else if (isNearLeftEdge) {
|
|
93
|
-
return "left";
|
|
94
|
-
}
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "getNewVerticalScrollDirection",
|
|
99
|
-
value: function getNewVerticalScrollDirection(pageY) {
|
|
100
|
-
if (pageY < this.getScrollParentTop()) {
|
|
101
|
-
return "top";
|
|
102
|
-
}
|
|
103
|
-
if (pageY > this.getScrollParentBottom()) {
|
|
104
|
-
return "bottom";
|
|
105
|
-
}
|
|
106
|
-
return undefined;
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
key: "scrollHorizontally",
|
|
110
|
-
value: function scrollHorizontally() {
|
|
111
|
-
if (!this.horizontalScrollDirection) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
var distance = this.horizontalScrollDirection === "left" ? -20 : 20;
|
|
115
|
-
var container = this.$container.get(0);
|
|
116
|
-
container.scrollBy({
|
|
117
|
-
left: distance,
|
|
118
|
-
top: 0,
|
|
119
|
-
behavior: "instant"
|
|
120
|
-
});
|
|
121
|
-
this.refreshHitAreas();
|
|
122
|
-
setTimeout(this.scrollHorizontally.bind(this), 40);
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "scrollVertically",
|
|
126
|
-
value: function scrollVertically() {
|
|
127
|
-
if (!this.verticalScrollDirection) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
var distance = this.verticalScrollDirection === "top" ? -20 : 20;
|
|
131
|
-
var container = this.$container.get(0);
|
|
132
|
-
container.scrollBy({
|
|
133
|
-
left: 0,
|
|
134
|
-
top: distance,
|
|
135
|
-
behavior: "instant"
|
|
136
|
-
});
|
|
137
|
-
this.refreshHitAreas();
|
|
138
|
-
setTimeout(this.scrollVertically.bind(this), 40);
|
|
139
|
-
}
|
|
140
|
-
}, {
|
|
141
|
-
key: "getScrollParentTop",
|
|
142
|
-
value: function getScrollParentTop() {
|
|
143
|
-
if (this.scrollParentTop == null) {
|
|
144
|
-
var _this$$container$offs;
|
|
145
|
-
this.scrollParentTop = ((_this$$container$offs = this.$container.offset()) === null || _this$$container$offs === void 0 ? void 0 : _this$$container$offs.top) || 0;
|
|
146
|
-
}
|
|
147
|
-
return this.scrollParentTop;
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "getScrollParentBottom",
|
|
151
|
-
value: function getScrollParentBottom() {
|
|
152
|
-
if (this.scrollParentBottom == null) {
|
|
153
|
-
var _this$$container$inne;
|
|
154
|
-
this.scrollParentBottom = this.getScrollParentTop() + ((_this$$container$inne = this.$container.innerHeight()) !== null && _this$$container$inne !== void 0 ? _this$$container$inne : 0);
|
|
155
|
-
}
|
|
156
|
-
return this.scrollParentBottom;
|
|
157
|
-
}
|
|
158
|
-
}]);
|
|
159
|
-
return ContainerScrollParent;
|
|
160
|
-
}();
|