targetj 1.0.170 → 1.0.171
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/build/App.js +53 -39
- package/build/BaseModel.js +3 -1
- package/build/DomInit.js +1 -0
- package/build/PageManager.js +4 -0
- package/build/TModel.js +38 -30
- package/build/TUtil.js +12 -0
- package/package.json +1 -1
package/build/App.js
CHANGED
|
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.tRoot = exports.tApp = exports.isRunning = exports.getVisibles = exports.getScreenWidth = exports.getScreenHeight = exports.getRunScheduler = exports.getResizeLastUpdate = exports.getPager = exports.getManager = exports.getLocationManager = exports.getLoader = exports.getEvents = exports.getBrowser = exports.fetchImage = exports.fetch = exports.App = void 0;
|
|
7
|
+
exports.tRoot = exports.tApp = exports.isRunning = exports.getVisibles = exports.getTModelById = exports.getScreenWidth = exports.getScreenHeight = exports.getRunScheduler = exports.getResizeLastUpdate = exports.getPager = exports.getManager = exports.getLocationManager = exports.getLoader = exports.getEvents = exports.getDomTModelById = exports.getBrowser = exports.fetchImage = exports.fetch = exports.App = void 0;
|
|
8
8
|
var _$Dom = require("./$Dom.js");
|
|
9
9
|
var _TModel = require("./TModel.js");
|
|
10
10
|
var _Browser = require("./Browser.js");
|
|
@@ -23,6 +23,11 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
23
23
|
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); }
|
|
24
24
|
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); }); }; }
|
|
25
25
|
var tApp;
|
|
26
|
+
var queuedAppCall = null;
|
|
27
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
28
|
+
exports.tApp = tApp = AppFn();
|
|
29
|
+
tApp.init().start();
|
|
30
|
+
});
|
|
26
31
|
var AppFn = function AppFn() {
|
|
27
32
|
var my = {};
|
|
28
33
|
my.throttle = 0;
|
|
@@ -67,6 +72,10 @@ var AppFn = function AppFn() {
|
|
|
67
72
|
},
|
|
68
73
|
initPageDom: function initPageDom() {
|
|
69
74
|
_DomInit.DomInit.initPageDoms(this.$dom);
|
|
75
|
+
if (queuedAppCall) {
|
|
76
|
+
this.addChild(queuedAppCall);
|
|
77
|
+
queuedAppCall = undefined;
|
|
78
|
+
}
|
|
70
79
|
}
|
|
71
80
|
});
|
|
72
81
|
tmodel.$dom = _$Dom.$Dom.query('#tgjs-root') ? new _$Dom.$Dom('#tgjs-root') : new _$Dom.$Dom('body');
|
|
@@ -154,17 +163,16 @@ var AppFn = function AppFn() {
|
|
|
154
163
|
return my;
|
|
155
164
|
};
|
|
156
165
|
var App = exports.App = function App(firstChild) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
exports.tApp = tApp = AppFn();
|
|
164
|
-
tApp.init().start();
|
|
166
|
+
var _tApp;
|
|
167
|
+
if (!((_tApp = tApp) !== null && _tApp !== void 0 && _tApp.tRoot)) {
|
|
168
|
+
queuedAppCall = firstChild;
|
|
169
|
+
} else if (firstChild) {
|
|
170
|
+
var _tApp2;
|
|
171
|
+
(_tApp2 = tApp) === null || _tApp2 === void 0 || _tApp2.tRoot.addChild(firstChild);
|
|
165
172
|
}
|
|
166
173
|
};
|
|
167
174
|
App.oids = {};
|
|
175
|
+
App.tmodelIdMap = {};
|
|
168
176
|
App.getOid = function (type) {
|
|
169
177
|
var oids = App.oids;
|
|
170
178
|
if (!_TUtil.TUtil.isDefined(oids[type])) {
|
|
@@ -176,64 +184,70 @@ App.getOid = function (type) {
|
|
|
176
184
|
num: num
|
|
177
185
|
};
|
|
178
186
|
};
|
|
179
|
-
App();
|
|
180
187
|
var isRunning = exports.isRunning = function isRunning() {
|
|
181
188
|
return tApp ? tApp.runningFlag : false;
|
|
182
189
|
};
|
|
183
190
|
var tRoot = exports.tRoot = function tRoot() {
|
|
184
|
-
var
|
|
185
|
-
return (
|
|
191
|
+
var _tApp3;
|
|
192
|
+
return (_tApp3 = tApp) === null || _tApp3 === void 0 ? void 0 : _tApp3.tRoot;
|
|
186
193
|
};
|
|
187
194
|
var getEvents = exports.getEvents = function getEvents() {
|
|
188
|
-
var
|
|
189
|
-
return (
|
|
195
|
+
var _tApp4;
|
|
196
|
+
return (_tApp4 = tApp) === null || _tApp4 === void 0 ? void 0 : _tApp4.events;
|
|
190
197
|
};
|
|
191
198
|
var getPager = exports.getPager = function getPager() {
|
|
192
|
-
var
|
|
193
|
-
return (
|
|
199
|
+
var _tApp5;
|
|
200
|
+
return (_tApp5 = tApp) === null || _tApp5 === void 0 ? void 0 : _tApp5.pager;
|
|
194
201
|
};
|
|
195
202
|
var getLoader = exports.getLoader = function getLoader() {
|
|
196
|
-
var
|
|
197
|
-
return (
|
|
203
|
+
var _tApp6;
|
|
204
|
+
return (_tApp6 = tApp) === null || _tApp6 === void 0 ? void 0 : _tApp6.loader;
|
|
198
205
|
};
|
|
199
206
|
var fetch = exports.fetch = function fetch(tmodel, url, query, cacheId) {
|
|
200
|
-
var
|
|
201
|
-
return (
|
|
207
|
+
var _tApp7;
|
|
208
|
+
return (_tApp7 = tApp) === null || _tApp7 === void 0 || (_tApp7 = _tApp7.loader) === null || _tApp7 === void 0 ? void 0 : _tApp7.fetch(tmodel, url, query, cacheId);
|
|
202
209
|
};
|
|
203
210
|
var fetchImage = exports.fetchImage = function fetchImage(tmodel, src, cacheId) {
|
|
204
|
-
var
|
|
205
|
-
return (
|
|
211
|
+
var _tApp8;
|
|
212
|
+
return (_tApp8 = tApp) === null || _tApp8 === void 0 || (_tApp8 = _tApp8.loader) === null || _tApp8 === void 0 ? void 0 : _tApp8.fetchImage(tmodel, src, cacheId);
|
|
206
213
|
};
|
|
207
214
|
var getManager = exports.getManager = function getManager() {
|
|
208
|
-
var
|
|
209
|
-
return (
|
|
215
|
+
var _tApp9;
|
|
216
|
+
return (_tApp9 = tApp) === null || _tApp9 === void 0 ? void 0 : _tApp9.manager;
|
|
210
217
|
};
|
|
211
218
|
var getRunScheduler = exports.getRunScheduler = function getRunScheduler() {
|
|
212
|
-
var
|
|
213
|
-
return (
|
|
219
|
+
var _tApp10;
|
|
220
|
+
return (_tApp10 = tApp) === null || _tApp10 === void 0 ? void 0 : _tApp10.runScheduler;
|
|
214
221
|
};
|
|
215
222
|
var getLocationManager = exports.getLocationManager = function getLocationManager() {
|
|
216
|
-
var
|
|
217
|
-
return (
|
|
223
|
+
var _tApp11;
|
|
224
|
+
return (_tApp11 = tApp) === null || _tApp11 === void 0 ? void 0 : _tApp11.locationManager;
|
|
218
225
|
};
|
|
219
226
|
var getBrowser = exports.getBrowser = function getBrowser() {
|
|
220
|
-
var
|
|
221
|
-
return (
|
|
227
|
+
var _tApp12;
|
|
228
|
+
return (_tApp12 = tApp) === null || _tApp12 === void 0 ? void 0 : _tApp12.browser;
|
|
222
229
|
};
|
|
223
230
|
var getScreenWidth = exports.getScreenWidth = function getScreenWidth() {
|
|
224
|
-
var _tApp$tRoot$val,
|
|
225
|
-
return (_tApp$tRoot$val = (
|
|
231
|
+
var _tApp$tRoot$val, _tApp13;
|
|
232
|
+
return (_tApp$tRoot$val = (_tApp13 = tApp) === null || _tApp13 === void 0 || (_tApp13 = _tApp13.tRoot) === null || _tApp13 === void 0 ? void 0 : _tApp13.val('screenWidth')) !== null && _tApp$tRoot$val !== void 0 ? _tApp$tRoot$val : 0;
|
|
226
233
|
};
|
|
227
234
|
var getScreenHeight = exports.getScreenHeight = function getScreenHeight() {
|
|
228
|
-
var _tApp$tRoot$val2,
|
|
229
|
-
return (_tApp$tRoot$val2 = (
|
|
235
|
+
var _tApp$tRoot$val2, _tApp14;
|
|
236
|
+
return (_tApp$tRoot$val2 = (_tApp14 = tApp) === null || _tApp14 === void 0 || (_tApp14 = _tApp14.tRoot) === null || _tApp14 === void 0 ? void 0 : _tApp14.val('screenHeight')) !== null && _tApp$tRoot$val2 !== void 0 ? _tApp$tRoot$val2 : 0;
|
|
230
237
|
};
|
|
231
238
|
var getVisibles = exports.getVisibles = function getVisibles() {
|
|
232
|
-
var
|
|
233
|
-
return (
|
|
239
|
+
var _tApp15;
|
|
240
|
+
return (_tApp15 = tApp) === null || _tApp15 === void 0 || (_tApp15 = _tApp15.manager) === null || _tApp15 === void 0 ? void 0 : _tApp15.lists.visible;
|
|
234
241
|
};
|
|
235
242
|
var getResizeLastUpdate = exports.getResizeLastUpdate = function getResizeLastUpdate() {
|
|
236
|
-
var
|
|
237
|
-
return (
|
|
243
|
+
var _tApp16;
|
|
244
|
+
return (_tApp16 = tApp) === null || _tApp16 === void 0 ? void 0 : _tApp16.resizeLastUpdate;
|
|
245
|
+
};
|
|
246
|
+
var getTModelById = exports.getTModelById = function getTModelById(id) {
|
|
247
|
+
return App.tmodelIdMap[id];
|
|
248
|
+
};
|
|
249
|
+
var getDomTModelById = exports.getDomTModelById = function getDomTModelById(id) {
|
|
250
|
+
var tmodel = App.tmodelIdMap[id];
|
|
251
|
+
return tmodel && tmodel.targets['sourceDom'] ? tmodel : undefined;
|
|
238
252
|
};
|
|
239
|
-
window.t = window.t ||
|
|
253
|
+
window.t = window.t || getTModelById;
|
package/build/BaseModel.js
CHANGED
|
@@ -38,14 +38,16 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
|
|
|
38
38
|
}
|
|
39
39
|
this.type = type || 'blank';
|
|
40
40
|
this.targets = Object.assign({}, targets);
|
|
41
|
-
if (!oid) {
|
|
41
|
+
if (!_TUtil.TUtil.isDefined(oid)) {
|
|
42
42
|
var uniqueId = _App.App.getOid(this.type);
|
|
43
43
|
this.oid = uniqueId.oid;
|
|
44
44
|
this.oidNum = uniqueId.num;
|
|
45
45
|
} else {
|
|
46
|
+
_App.App.getOid(oid);
|
|
46
47
|
this.oid = oid;
|
|
47
48
|
this.oidNum = 0;
|
|
48
49
|
}
|
|
50
|
+
_App.App.tmodelIdMap[this.oid] = this;
|
|
49
51
|
this._state = {};
|
|
50
52
|
}
|
|
51
53
|
return _createClass(BaseModel, [{
|
package/build/DomInit.js
CHANGED
|
@@ -157,6 +157,7 @@ var DomInit = exports.DomInit = /*#__PURE__*/function () {
|
|
|
157
157
|
_value.$dom.detach();
|
|
158
158
|
delete _value.$dom;
|
|
159
159
|
delete _value.id;
|
|
160
|
+
_value.sourceDom = true;
|
|
160
161
|
_value.shouldBeBracketed = false;
|
|
161
162
|
_value.otype = _value.id || (_parentModel.id || _App.App.getOid('blank').oid) + "_";
|
|
162
163
|
_value.isVisible = !_TUtil.TUtil.isDefined(_value.isVisible) ? function () {
|
package/build/PageManager.js
CHANGED
|
@@ -59,12 +59,14 @@ var PageManager = exports.PageManager = /*#__PURE__*/function () {
|
|
|
59
59
|
_App.tApp.tRoot.$dom.innerHTML("");
|
|
60
60
|
_App.tApp.tRoot = _App.tApp.tRootFactory();
|
|
61
61
|
_App.App.oids = {};
|
|
62
|
+
_App.App.tmodelIdMap = {};
|
|
62
63
|
_App.tApp.pageIsEmpty = true;
|
|
63
64
|
this.lastLink = link;
|
|
64
65
|
_App.tApp.start();
|
|
65
66
|
} else {
|
|
66
67
|
_App.tApp.tRoot = this.pageCache[link].tRoot;
|
|
67
68
|
_App.App.oids = this.pageCache[link].oids;
|
|
69
|
+
_App.App.tmodelIdMap = this.pageCache[link].tmodelIdMap;
|
|
68
70
|
_App.tApp.tRoot.$dom = _$Dom.$Dom.query('#tgjs-root') ? new _$Dom.$Dom('#tgjs-root') : new _$Dom.$Dom('body');
|
|
69
71
|
_App.tApp.tRoot.$dom.innerHTML(this.pageCache[link].html);
|
|
70
72
|
_DomInit.DomInit.initCacheDoms(this.pageCache[link].visibleList);
|
|
@@ -121,6 +123,7 @@ var PageManager = exports.PageManager = /*#__PURE__*/function () {
|
|
|
121
123
|
link: this.lastLink,
|
|
122
124
|
html: html,
|
|
123
125
|
oids: _objectSpread({}, _App.App.oids),
|
|
126
|
+
tmodelIdMap: _objectSpread({}, _App.App.tmodelIdMap),
|
|
124
127
|
visibleList: _toConsumableArray(_App.tApp.manager.lists.visible),
|
|
125
128
|
tRoot: _App.tApp.tRoot
|
|
126
129
|
};
|
|
@@ -141,6 +144,7 @@ var PageManager = exports.PageManager = /*#__PURE__*/function () {
|
|
|
141
144
|
link: document.URL,
|
|
142
145
|
html: _App.tApp.tRoot.$dom.innerHTML(),
|
|
143
146
|
oids: _objectSpread({}, _App.App.oids),
|
|
147
|
+
tmodelIdMap: _objectSpread({}, _App.App.tmodelIdMap),
|
|
144
148
|
visibleList: _toConsumableArray(_App.tApp.manager.lists.visible),
|
|
145
149
|
tRoot: _App.tApp.tRoot
|
|
146
150
|
};
|
package/build/TModel.js
CHANGED
|
@@ -95,6 +95,33 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
95
95
|
this.absX = _TUtil.TUtil.isDefined(this.val('absX')) ? this.val('absX') : this.getParent().absX + x;
|
|
96
96
|
this.absY = _TUtil.TUtil.isDefined(this.val('absY')) ? this.val('absY') : this.getParent().absY + y;
|
|
97
97
|
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "removeChild",
|
|
100
|
+
value: function removeChild(child) {
|
|
101
|
+
if (!child) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this.deletedChildren.push(child);
|
|
105
|
+
this.removeFromUpdatingChildren(child);
|
|
106
|
+
this.childrenUpdateFlag = true;
|
|
107
|
+
(0, _App.getRunScheduler)().schedule(1, 'removeChild-' + this.oid + "-" + child.oid);
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "moveChild",
|
|
112
|
+
value: function moveChild(child, index) {
|
|
113
|
+
this.movedChildren.push({
|
|
114
|
+
index: index,
|
|
115
|
+
child: child
|
|
116
|
+
});
|
|
117
|
+
if (child.hasDom() && child.requiresDomRelocation()) {
|
|
118
|
+
child.domOrderIndex = index;
|
|
119
|
+
child.activate();
|
|
120
|
+
}
|
|
121
|
+
this.childrenUpdateFlag = true;
|
|
122
|
+
(0, _App.getRunScheduler)().schedule(1, 'moveChild-' + this.oid + "-" + child.oid);
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
98
125
|
}, {
|
|
99
126
|
key: "addChild",
|
|
100
127
|
value: function addChild(child) {
|
|
@@ -107,16 +134,20 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
107
134
|
var foundKey = Object.keys(this.actualValues).find(function (key) {
|
|
108
135
|
return _this2.actualValues[key] === child;
|
|
109
136
|
});
|
|
137
|
+
var originalId = child.id;
|
|
110
138
|
if (foundKey) {
|
|
111
139
|
child = new TModel(child.id || foundKey, child);
|
|
112
140
|
this.actualValues[foundKey] = child;
|
|
113
141
|
} else if (_TUtil.TUtil.isDefined(child.otype)) {
|
|
114
142
|
child = new TModel(child.otype, child);
|
|
115
143
|
} else if (_TUtil.TUtil.isDefined(child.id)) {
|
|
116
|
-
child = new TModel(child.id, child, child.id);
|
|
144
|
+
child = new TModel(child.id, child, child.sourceDom ? child.id : undefined);
|
|
117
145
|
} else {
|
|
118
146
|
child = new TModel("".concat(this.oid, "_"), child);
|
|
119
147
|
}
|
|
148
|
+
if (!child.targets['sourceDom'] && _TUtil.TUtil.isDefined(originalId)) {
|
|
149
|
+
child.originalId = originalId;
|
|
150
|
+
}
|
|
120
151
|
}
|
|
121
152
|
this.addedChildren.push({
|
|
122
153
|
index: index,
|
|
@@ -133,33 +164,6 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
133
164
|
}
|
|
134
165
|
return this;
|
|
135
166
|
}
|
|
136
|
-
}, {
|
|
137
|
-
key: "removeChild",
|
|
138
|
-
value: function removeChild(child) {
|
|
139
|
-
if (!child) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
this.deletedChildren.push(child);
|
|
143
|
-
this.removeFromUpdatingChildren(child);
|
|
144
|
-
this.childrenUpdateFlag = true;
|
|
145
|
-
(0, _App.getRunScheduler)().schedule(1, 'removeChild-' + this.oid + "-" + child.oid);
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
}, {
|
|
149
|
-
key: "moveChild",
|
|
150
|
-
value: function moveChild(child, index) {
|
|
151
|
-
this.movedChildren.push({
|
|
152
|
-
index: index,
|
|
153
|
-
child: child
|
|
154
|
-
});
|
|
155
|
-
if (child.hasDom() && child.requiresDomRelocation()) {
|
|
156
|
-
child.domOrderIndex = index;
|
|
157
|
-
child.activate();
|
|
158
|
-
}
|
|
159
|
-
this.childrenUpdateFlag = true;
|
|
160
|
-
(0, _App.getRunScheduler)().schedule(1, 'moveChild-' + this.oid + "-" + child.oid);
|
|
161
|
-
return this;
|
|
162
|
-
}
|
|
163
167
|
}, {
|
|
164
168
|
key: "getChildren",
|
|
165
169
|
value: function getChildren() {
|
|
@@ -186,6 +190,10 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
186
190
|
this.addedChildren.forEach(function (_ref) {
|
|
187
191
|
var index = _ref.index,
|
|
188
192
|
child = _ref.child;
|
|
193
|
+
if (_TUtil.TUtil.isDefined(child.originalId) && (0, _App.getDomTModelById)(child.originalId) && !child.targets['sourceDom']) {
|
|
194
|
+
_TUtil.TUtil.mergeTargets((0, _App.getDomTModelById)(child.originalId), child);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
189
197
|
if (_this3.allChildrenMap[child.oid]) {
|
|
190
198
|
return;
|
|
191
199
|
}
|
|
@@ -642,12 +650,12 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
642
650
|
}, {
|
|
643
651
|
key: "getCenterX",
|
|
644
652
|
value: function getCenterX() {
|
|
645
|
-
return (this.getParentValue('width') - this.getWidth()) / 2;
|
|
653
|
+
return _TUtil.TUtil.isDefined(this.getParentValue('width')) ? (this.getParentValue('width') - this.getWidth()) / 2 : 0;
|
|
646
654
|
}
|
|
647
655
|
}, {
|
|
648
656
|
key: "getCenterY",
|
|
649
657
|
value: function getCenterY() {
|
|
650
|
-
return (this.getParentValue('height') - this.getHeight()) / 2;
|
|
658
|
+
return _TUtil.TUtil.isDefined(this.getParentValue('height')) ? (this.getParentValue('height') - this.getHeight()) / 2 : 0;
|
|
651
659
|
}
|
|
652
660
|
}, {
|
|
653
661
|
key: "getX",
|
package/build/TUtil.js
CHANGED
|
@@ -214,5 +214,17 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
|
|
|
214
214
|
_iterator.f();
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "mergeTargets",
|
|
219
|
+
value: function mergeTargets(tmodel1, tmodel2) {
|
|
220
|
+
var sourceTargets = tmodel2.targets;
|
|
221
|
+
var destTargets = tmodel1.targets;
|
|
222
|
+
Object.keys(sourceTargets).forEach(function (key) {
|
|
223
|
+
if (!TUtil.isDefined(destTargets[key])) {
|
|
224
|
+
destTargets[key] = sourceTargets[key];
|
|
225
|
+
tmodel1.processNewTarget(key);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
217
229
|
}]);
|
|
218
230
|
}();
|
package/package.json
CHANGED