targetj 1.0.97 → 1.0.99
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/README.md +52 -73
- package/build/App.js +98 -64
- package/build/BaseModel.js +31 -8
- package/build/Bracket.js +33 -40
- package/build/BracketGenerator.js +3 -1
- package/build/Browser.js +0 -13
- package/build/EventListener.js +63 -39
- package/build/LoadingManager.js +125 -291
- package/build/LocationManager.js +36 -54
- package/build/PageManager.js +48 -27
- package/build/RunScheduler.js +58 -25
- package/build/TModel.js +40 -13
- package/build/TModelManager.js +27 -12
- package/build/TModelUtil.js +13 -14
- package/build/TUtil.js +8 -37
- package/build/TargetManager.js +1 -1
- package/build/TargetUtil.js +32 -4
- package/build/Viewport.js +11 -73
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -187,7 +187,7 @@ The target will remain active using the loop function, with value() continuing t
|
|
|
187
187
|

|
|
188
188
|
|
|
189
189
|
```bash
|
|
190
|
-
import { App, TModel, getLoader, getScreenHeight, getScreenWidth } from "targetj";
|
|
190
|
+
import { App, TModel, getLoader, getScreenHeight, getScreenWidth, Moves } from "targetj";
|
|
191
191
|
|
|
192
192
|
App(new TModel("apiCall", {
|
|
193
193
|
start() { this.users = 0; },
|
|
@@ -369,43 +369,39 @@ This example demonstrates how to handle scroll events and develop a simple infin
|
|
|
369
369
|
import { App, TModel, getEvents, getScreenHeight, getScreenWidth, } from "targetj";
|
|
370
370
|
|
|
371
371
|
App(new TModel("scroller", {
|
|
372
|
-
canHandleEvents:
|
|
373
|
-
|
|
372
|
+
canHandleEvents: "scrollTop",
|
|
373
|
+
innerOverflowWidth: 0,
|
|
374
374
|
children: {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
return this.visibleChildren.length * 32 < this.getHeight();
|
|
398
|
-
}
|
|
375
|
+
value() {
|
|
376
|
+
const childrenCount = this.getChildren().length;
|
|
377
|
+
return Array.from({ length: 5 }, (_, i) =>
|
|
378
|
+
new TModel("scrollItem", {
|
|
379
|
+
width: 300,
|
|
380
|
+
background: "brown",
|
|
381
|
+
height: 30,
|
|
382
|
+
color: "#fff",
|
|
383
|
+
textAlign: "center",
|
|
384
|
+
lineHeight: 30,
|
|
385
|
+
bottomMargin: 2,
|
|
386
|
+
x() { return this.getCenterX(); },
|
|
387
|
+
html: childrenCount + i,
|
|
388
|
+
})
|
|
389
|
+
);
|
|
390
|
+
},
|
|
391
|
+
enabledOn() {
|
|
392
|
+
return this.visibleChildren.length * 32 < this.getHeight();
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
scrollTop(cycle, lastValue) {
|
|
396
|
+
return Math.max(0, lastValue + getEvents().deltaY());
|
|
399
397
|
},
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
onVisibleChildrenChange: [ 'children' ]
|
|
408
|
-
}));
|
|
398
|
+
width: getScreenWidth,
|
|
399
|
+
height: getScreenHeight,
|
|
400
|
+
onResize: ["width", "height"],
|
|
401
|
+
onScrollEvent: ["scrollTop", "children"],
|
|
402
|
+
onVisibleChildrenChange: ["children"],
|
|
403
|
+
})
|
|
404
|
+
);
|
|
409
405
|
```
|
|
410
406
|
|
|
411
407
|
## Simple Single Page App Example
|
|
@@ -417,16 +413,12 @@ Below is a simple single-page app that demonstrates how to develop a fully-fledg
|
|
|
417
413
|
```bash
|
|
418
414
|
import { App, TModel, getScreenHeight, getScreenWidth, getEvents, getPager } from "targetj";
|
|
419
415
|
|
|
420
|
-
App(
|
|
421
|
-
new TModel("app", {
|
|
422
|
-
start() {
|
|
423
|
-
const urlParts = window.location.href.split("/");
|
|
424
|
-
this.pageName = urlParts[urlParts.length - 1];
|
|
425
|
-
},
|
|
416
|
+
App(new TModel("app", {
|
|
426
417
|
width: getScreenWidth,
|
|
427
418
|
height: getScreenHeight,
|
|
428
419
|
children() {
|
|
429
|
-
|
|
420
|
+
const pageName = window.location.pathname.split("/").pop();
|
|
421
|
+
switch (pageName) {
|
|
430
422
|
case "page1":
|
|
431
423
|
return [Toolbar(), Page1()];
|
|
432
424
|
case "page2":
|
|
@@ -435,7 +427,7 @@ App(
|
|
|
435
427
|
return [Toolbar(), HomePage()];
|
|
436
428
|
}
|
|
437
429
|
},
|
|
438
|
-
onResize: ["width", "height"]
|
|
430
|
+
onResize: ["width", "height"],
|
|
439
431
|
})
|
|
440
432
|
);
|
|
441
433
|
|
|
@@ -443,66 +435,53 @@ const Toolbar = () =>
|
|
|
443
435
|
new TModel("toolbar", {
|
|
444
436
|
start() {
|
|
445
437
|
["home", "page1", "page2"].forEach((menu) => {
|
|
446
|
-
this.addChild(
|
|
447
|
-
new TModel("toolItem", {
|
|
438
|
+
this.addChild(new TModel("toolItem", {
|
|
448
439
|
canHandleEvents: "touch",
|
|
449
440
|
background: "bisque",
|
|
450
441
|
width: 100,
|
|
451
442
|
height: 50,
|
|
452
443
|
lineHeight: 50,
|
|
453
|
-
|
|
444
|
+
outerOverflowWidth: 0,
|
|
454
445
|
opacity: 0.5,
|
|
455
|
-
|
|
456
|
-
active: false,
|
|
457
|
-
value() {
|
|
458
|
-
this.setTarget("opacity", getEvents().isEnterEventHandler(this) ? 1 : 0.5, 20);
|
|
459
|
-
}
|
|
460
|
-
},
|
|
461
|
-
activePage: {
|
|
462
|
-
active: false,
|
|
463
|
-
value() {
|
|
464
|
-
this.setTarget;
|
|
465
|
-
getPager().openLink(menu);
|
|
466
|
-
}
|
|
467
|
-
},
|
|
446
|
+
cursor: "pointer",
|
|
468
447
|
html: menu,
|
|
469
|
-
onEnterEvent
|
|
470
|
-
onLeaveEvent
|
|
471
|
-
onClickEvent
|
|
448
|
+
onEnterEvent() { this.setTarget("opacity", 1, 20); },
|
|
449
|
+
onLeaveEvent() { this.setTarget("opacity", 0.5, 20); },
|
|
450
|
+
onClickEvent() {
|
|
451
|
+
this.setTarget("opacity", 0.5);
|
|
452
|
+
getPager().openLink(menu);
|
|
453
|
+
},
|
|
472
454
|
})
|
|
473
455
|
);
|
|
474
456
|
});
|
|
475
457
|
},
|
|
476
458
|
height: 50,
|
|
477
459
|
width: getScreenWidth,
|
|
478
|
-
onResize: ["width"]
|
|
460
|
+
onResize: ["width"],
|
|
479
461
|
});
|
|
480
462
|
|
|
481
|
-
const HomePage = () =>
|
|
482
|
-
new TModel("homePage", {
|
|
463
|
+
const HomePage = () => new TModel("homePage", {
|
|
483
464
|
background: "yellow",
|
|
484
465
|
width: getScreenWidth,
|
|
485
466
|
height: getScreenHeight,
|
|
486
467
|
html: "home page",
|
|
487
|
-
onResize: ["width", "height"]
|
|
468
|
+
onResize: ["width", "height"],
|
|
488
469
|
});
|
|
489
470
|
|
|
490
|
-
const Page1 = () =>
|
|
491
|
-
new TModel("page1", {
|
|
471
|
+
const Page1 = () => new TModel("page1", {
|
|
492
472
|
background: "blue",
|
|
493
473
|
width: getScreenWidth,
|
|
494
474
|
height: getScreenHeight,
|
|
495
475
|
html: "page 1",
|
|
496
|
-
onResize: ["width", "height"]
|
|
476
|
+
onResize: ["width", "height"],
|
|
497
477
|
});
|
|
498
478
|
|
|
499
|
-
const Page2 = () =>
|
|
500
|
-
new TModel("page2", {
|
|
479
|
+
const Page2 = () => new TModel("page2", {
|
|
501
480
|
background: "green",
|
|
502
481
|
width: getScreenWidth,
|
|
503
482
|
height: getScreenHeight,
|
|
504
483
|
html: "page 2",
|
|
505
|
-
onResize: ["width", "height"]
|
|
484
|
+
onResize: ["width", "height"],
|
|
506
485
|
});
|
|
507
486
|
```
|
|
508
487
|
|
package/build/App.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -16,7 +17,9 @@ var _RunScheduler = require("./RunScheduler.js");
|
|
|
16
17
|
var _TargetManager = require("./TargetManager.js");
|
|
17
18
|
var _TUtil = require("./TUtil.js");
|
|
18
19
|
var _SearchUtil = require("./SearchUtil.js");
|
|
19
|
-
var
|
|
20
|
+
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 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 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 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; }
|
|
21
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
22
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
20
23
|
var tApp;
|
|
21
24
|
var AppFn = function AppFn(firstChild) {
|
|
22
25
|
var my = {};
|
|
@@ -26,7 +29,6 @@ var AppFn = function AppFn(firstChild) {
|
|
|
26
29
|
my.init = function () {
|
|
27
30
|
my.browser = new _Browser.Browser();
|
|
28
31
|
my.browser.setup();
|
|
29
|
-
my.browser.measureScreen();
|
|
30
32
|
my.$document = new _$Dom.$Dom(document);
|
|
31
33
|
my.$window = new _$Dom.$Dom(window);
|
|
32
34
|
my.$window.addEvent("popstate", function (event) {
|
|
@@ -42,37 +44,37 @@ var AppFn = function AppFn(firstChild) {
|
|
|
42
44
|
my.manager = new _TModelManager.TModelManager();
|
|
43
45
|
my.runScheduler = new _RunScheduler.RunScheduler();
|
|
44
46
|
my.tRootFactory = function () {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
var tmodel = new _TModel.TModel('tRoot', {
|
|
48
|
+
start: function start() {
|
|
49
|
+
if (!_$Dom.$Dom.query('#tj-root')) {
|
|
50
|
+
this.$dom = new _$Dom.$Dom();
|
|
51
|
+
this.$dom.create('div');
|
|
52
|
+
this.$dom.setSelector('#tj-root');
|
|
53
|
+
this.$dom.setId('#tj-root');
|
|
54
|
+
this.$dom.attr("tabindex", "0");
|
|
55
|
+
new _$Dom.$Dom('body').insertFirst$Dom(this.$dom);
|
|
56
|
+
} else {
|
|
57
|
+
this.$dom = new _$Dom.$Dom('#tj-root');
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
domHolder: function domHolder() {
|
|
61
|
+
return this.$dom;
|
|
62
|
+
},
|
|
63
|
+
width: function width() {
|
|
64
|
+
return document.documentElement.clientWidth || document.body.clientWidth;
|
|
65
|
+
},
|
|
66
|
+
height: function height() {
|
|
67
|
+
return document.documentElement.clientHeight || document.body.clientHeight;
|
|
64
68
|
}
|
|
65
|
-
|
|
66
|
-
};
|
|
69
|
+
});
|
|
70
|
+
tmodel.oids = {};
|
|
67
71
|
if (my.tRoot) {
|
|
68
|
-
my.tRoot.getChildren().forEach(function (t
|
|
72
|
+
my.tRoot.getChildren().forEach(function (t) {
|
|
69
73
|
var child = new _TModel.TModel(t.type, t.targets);
|
|
70
|
-
child
|
|
71
|
-
child.oid = num > 0 ? "".concat(t.type).concat(num) : t.type;
|
|
72
|
-
tRoot.addChild(child);
|
|
74
|
+
tmodel.addChild(child);
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
|
-
return
|
|
77
|
+
return tmodel;
|
|
76
78
|
};
|
|
77
79
|
my.tRoot = my.tRootFactory();
|
|
78
80
|
if (firstChild) {
|
|
@@ -83,32 +85,51 @@ var AppFn = function AppFn(firstChild) {
|
|
|
83
85
|
}, "", document.URL);
|
|
84
86
|
return my;
|
|
85
87
|
};
|
|
86
|
-
my.start = function () {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
88
|
+
my.start = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
89
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
90
|
+
while (1) switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
my.runningFlag = false;
|
|
93
|
+
my.events.clearAll();
|
|
94
|
+
my.events.removeHandlers(my.$document);
|
|
95
|
+
my.events.addHandlers(my.$document);
|
|
96
|
+
my.events.removeWindowHandlers();
|
|
97
|
+
my.events.addWindowHandlers();
|
|
98
|
+
_context.next = 8;
|
|
99
|
+
return my.runScheduler.resetRuns();
|
|
100
|
+
case 8:
|
|
101
|
+
my.runningFlag = true;
|
|
102
|
+
my.runScheduler.schedule(0, "appStart");
|
|
103
|
+
return _context.abrupt("return", my);
|
|
104
|
+
case 11:
|
|
105
|
+
case "end":
|
|
106
|
+
return _context.stop();
|
|
107
|
+
}
|
|
108
|
+
}, _callee);
|
|
109
|
+
}));
|
|
110
|
+
my.stop = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
111
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
112
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
113
|
+
case 0:
|
|
114
|
+
my.runningFlag = false;
|
|
115
|
+
my.events.removeWindowHandlers();
|
|
116
|
+
my.events.removeHandlers(my.$document);
|
|
117
|
+
my.events.clearAll();
|
|
118
|
+
_context2.next = 6;
|
|
119
|
+
return my.runScheduler.resetRuns();
|
|
120
|
+
case 6:
|
|
121
|
+
return _context2.abrupt("return", my);
|
|
122
|
+
case 7:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context2.stop();
|
|
125
|
+
}
|
|
126
|
+
}, _callee2);
|
|
127
|
+
}));
|
|
107
128
|
my.reset = function () {
|
|
108
129
|
my.manager.lists.visible.forEach(function (tmodel) {
|
|
109
130
|
tmodel.transformMap = {};
|
|
110
131
|
tmodel.styleMap = {};
|
|
111
|
-
|
|
132
|
+
tmodel.allStyleTargetList.forEach(function (key) {
|
|
112
133
|
if (_TUtil.TUtil.isDefined(tmodel.val(key))) {
|
|
113
134
|
tmodel.addToStyleTargetList(key);
|
|
114
135
|
}
|
|
@@ -136,10 +157,12 @@ var App = exports.App = function App(tmodel) {
|
|
|
136
157
|
};
|
|
137
158
|
App.oids = {};
|
|
138
159
|
App.getOid = function (type) {
|
|
139
|
-
|
|
140
|
-
|
|
160
|
+
var _tApp;
|
|
161
|
+
var oids = ((_tApp = tApp) === null || _tApp === void 0 || (_tApp = _tApp.tRoot) === null || _tApp === void 0 ? void 0 : _tApp.oids) || App.oids;
|
|
162
|
+
if (!_TUtil.TUtil.isDefined(oids[type])) {
|
|
163
|
+
oids[type] = 0;
|
|
141
164
|
}
|
|
142
|
-
var num =
|
|
165
|
+
var num = oids[type]++;
|
|
143
166
|
return {
|
|
144
167
|
oid: num > 0 ? "".concat(type).concat(num) : type,
|
|
145
168
|
num: num
|
|
@@ -149,36 +172,47 @@ var isRunning = exports.isRunning = function isRunning() {
|
|
|
149
172
|
return tApp ? tApp.runningFlag : false;
|
|
150
173
|
};
|
|
151
174
|
var tRoot = exports.tRoot = function tRoot() {
|
|
152
|
-
|
|
175
|
+
var _tApp2;
|
|
176
|
+
return (_tApp2 = tApp) === null || _tApp2 === void 0 ? void 0 : _tApp2.tRoot;
|
|
153
177
|
};
|
|
154
178
|
var getEvents = exports.getEvents = function getEvents() {
|
|
155
|
-
|
|
179
|
+
var _tApp3;
|
|
180
|
+
return (_tApp3 = tApp) === null || _tApp3 === void 0 ? void 0 : _tApp3.events;
|
|
156
181
|
};
|
|
157
182
|
var getPager = exports.getPager = function getPager() {
|
|
158
|
-
|
|
183
|
+
var _tApp4;
|
|
184
|
+
return (_tApp4 = tApp) === null || _tApp4 === void 0 ? void 0 : _tApp4.pager;
|
|
159
185
|
};
|
|
160
186
|
var getLoader = exports.getLoader = function getLoader() {
|
|
161
|
-
|
|
187
|
+
var _tApp5;
|
|
188
|
+
return (_tApp5 = tApp) === null || _tApp5 === void 0 ? void 0 : _tApp5.loader;
|
|
162
189
|
};
|
|
163
190
|
var getManager = exports.getManager = function getManager() {
|
|
164
|
-
|
|
191
|
+
var _tApp6;
|
|
192
|
+
return (_tApp6 = tApp) === null || _tApp6 === void 0 ? void 0 : _tApp6.manager;
|
|
165
193
|
};
|
|
166
194
|
var getRunScheduler = exports.getRunScheduler = function getRunScheduler() {
|
|
167
|
-
|
|
195
|
+
var _tApp7;
|
|
196
|
+
return (_tApp7 = tApp) === null || _tApp7 === void 0 ? void 0 : _tApp7.runScheduler;
|
|
168
197
|
};
|
|
169
198
|
var getLocationManager = exports.getLocationManager = function getLocationManager() {
|
|
170
|
-
|
|
199
|
+
var _tApp8;
|
|
200
|
+
return (_tApp8 = tApp) === null || _tApp8 === void 0 ? void 0 : _tApp8.locationManager;
|
|
171
201
|
};
|
|
172
202
|
var getBrowser = exports.getBrowser = function getBrowser() {
|
|
173
|
-
|
|
203
|
+
var _tApp9;
|
|
204
|
+
return (_tApp9 = tApp) === null || _tApp9 === void 0 ? void 0 : _tApp9.browser;
|
|
174
205
|
};
|
|
175
206
|
var getScreenWidth = exports.getScreenWidth = function getScreenWidth() {
|
|
176
|
-
|
|
207
|
+
var _tApp$tRoot$getWidth, _tApp10;
|
|
208
|
+
return (_tApp$tRoot$getWidth = (_tApp10 = tApp) === null || _tApp10 === void 0 || (_tApp10 = _tApp10.tRoot) === null || _tApp10 === void 0 ? void 0 : _tApp10.getWidth()) !== null && _tApp$tRoot$getWidth !== void 0 ? _tApp$tRoot$getWidth : 0;
|
|
177
209
|
};
|
|
178
210
|
var getScreenHeight = exports.getScreenHeight = function getScreenHeight() {
|
|
179
|
-
|
|
211
|
+
var _tApp$tRoot$getHeight, _tApp11;
|
|
212
|
+
return (_tApp$tRoot$getHeight = (_tApp11 = tApp) === null || _tApp11 === void 0 || (_tApp11 = _tApp11.tRoot) === null || _tApp11 === void 0 ? void 0 : _tApp11.getHeight()) !== null && _tApp$tRoot$getHeight !== void 0 ? _tApp$tRoot$getHeight : 0;
|
|
180
213
|
};
|
|
181
214
|
var getVisibles = exports.getVisibles = function getVisibles() {
|
|
182
|
-
|
|
215
|
+
var _tApp12;
|
|
216
|
+
return (_tApp12 = tApp) === null || _tApp12 === void 0 || (_tApp12 = _tApp12.manager) === null || _tApp12 === void 0 ? void 0 : _tApp12.lists.visible;
|
|
183
217
|
};
|
|
184
218
|
window.t = window.t || _SearchUtil.SearchUtil.find;
|
package/build/BaseModel.js
CHANGED
|
@@ -10,9 +10,13 @@ var _TUtil = require("./TUtil.js");
|
|
|
10
10
|
var _TModelUtil = require("./TModelUtil.js");
|
|
11
11
|
var _TargetUtil = require("./TargetUtil.js");
|
|
12
12
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
15
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
16
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
14
17
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15
|
-
function
|
|
18
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
16
20
|
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); }
|
|
17
21
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
18
22
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
@@ -34,8 +38,8 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
34
38
|
var uniqueId = _App.App.getOid(this.type);
|
|
35
39
|
this.oid = uniqueId.oid;
|
|
36
40
|
this.oidNum = uniqueId.num;
|
|
37
|
-
this.targetValues =
|
|
38
|
-
this.actualValues =
|
|
41
|
+
this.targetValues = undefined;
|
|
42
|
+
this.actualValues = undefined;
|
|
39
43
|
this.activeTargetList = [];
|
|
40
44
|
this.activeTargetMap = {};
|
|
41
45
|
this.updatingTargetList = [];
|
|
@@ -43,6 +47,8 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
43
47
|
this.updatingChildrenList = [];
|
|
44
48
|
this.updatingChildrenMap = {};
|
|
45
49
|
this.eventTargets = [];
|
|
50
|
+
this.allStyleTargetList = [];
|
|
51
|
+
this.allStyleTargetMap = {};
|
|
46
52
|
this.styleTargetList = [];
|
|
47
53
|
this.styleTargetMap = {};
|
|
48
54
|
this.parent = null;
|
|
@@ -62,10 +68,18 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
62
68
|
key: "initTargets",
|
|
63
69
|
value: function initTargets() {
|
|
64
70
|
var _this = this;
|
|
65
|
-
this.actualValues = _TModelUtil.TModelUtil.
|
|
71
|
+
this.actualValues = _TModelUtil.TModelUtil.defaultActualValues();
|
|
66
72
|
this.targetValues = {};
|
|
67
73
|
this.activeTargetMap = {};
|
|
68
74
|
this.activeTargetList = [];
|
|
75
|
+
Object.entries(_TModelUtil.TModelUtil.defaultTargets()).forEach(function (_ref) {
|
|
76
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
77
|
+
key = _ref2[0],
|
|
78
|
+
value = _ref2[1];
|
|
79
|
+
if (!(key in _this.targets)) {
|
|
80
|
+
_this.targets[key] = value;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
69
83
|
Object.keys(this.targets).forEach(function (key) {
|
|
70
84
|
_this.processNewTarget(key);
|
|
71
85
|
});
|
|
@@ -78,13 +92,18 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
78
92
|
return;
|
|
79
93
|
}
|
|
80
94
|
_TargetUtil.TargetUtil.bindTargetName(this.targets, key);
|
|
95
|
+
if (_TargetUtil.TargetUtil.targetConditionMap[key]) {
|
|
96
|
+
if (this.eventTargets.indexOf(key === -1)) {
|
|
97
|
+
this.eventTargets.push(key);
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
} else if (_TargetUtil.TargetUtil.otherTargetEventsMap[key]) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
81
103
|
if (_TUtil.TUtil.isDefined(this.targets[key].initialValue)) {
|
|
82
104
|
this.actualValues[key] = this.targets[key].initialValue;
|
|
83
105
|
this.addToStyleTargetList(key);
|
|
84
106
|
}
|
|
85
|
-
if (_TargetUtil.TargetUtil.targetConditionMap[key] && this.eventTargets.indexOf(key === -1)) {
|
|
86
|
-
this.eventTargets.push(key);
|
|
87
|
-
}
|
|
88
107
|
if (this.targets[key].active !== false) {
|
|
89
108
|
this.addToActiveTargets(key);
|
|
90
109
|
}
|
|
@@ -92,13 +111,17 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
92
111
|
}, {
|
|
93
112
|
key: "addToStyleTargetList",
|
|
94
113
|
value: function addToStyleTargetList(key) {
|
|
95
|
-
if (!_TargetUtil.TargetUtil.styleTargetMap[key]) {
|
|
114
|
+
if (!_TargetUtil.TargetUtil.styleTargetMap[key] && !_TargetUtil.TargetUtil.attributeTargetMap[key]) {
|
|
96
115
|
return;
|
|
97
116
|
}
|
|
98
117
|
if (!this.styleTargetMap[key]) {
|
|
99
118
|
this.styleTargetList.push(key);
|
|
100
119
|
this.styleTargetMap[key] = true;
|
|
101
120
|
}
|
|
121
|
+
if (!this.allStyleTargetMap[key]) {
|
|
122
|
+
this.allStyleTargetList.push(key);
|
|
123
|
+
this.allStyleTargetMap[key] = true;
|
|
124
|
+
}
|
|
102
125
|
}
|
|
103
126
|
}, {
|
|
104
127
|
key: "removeTarget",
|