targetj 1.0.74 → 1.0.76

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.
Files changed (44) hide show
  1. package/babel.config.json +17 -0
  2. package/build/$Dom.js +424 -0
  3. package/build/App.js +187 -0
  4. package/build/Bracket.js +157 -0
  5. package/build/BracketGenerator.js +86 -0
  6. package/build/Browser.js +105 -0
  7. package/build/ColorUtil.js +182 -0
  8. package/build/Dim.js +31 -0
  9. package/build/Easing.js +59 -0
  10. package/build/EventListener.js +664 -0
  11. package/build/LoadingManager.js +366 -0
  12. package/build/LocationManager.js +211 -0
  13. package/build/Moves.js +71 -0
  14. package/build/PageManager.js +113 -0
  15. package/build/SearchUtil.js +196 -0
  16. package/build/TModel.js +1000 -0
  17. package/build/TModelManager.js +605 -0
  18. package/build/TUtil.js +188 -0
  19. package/build/TargetExecutor.js +117 -0
  20. package/build/TargetManager.js +197 -0
  21. package/build/TargetUtil.js +299 -0
  22. package/build/Viewport.js +163 -0
  23. package/package.json +11 -4
  24. package/webpack.config.js +14 -1
  25. package/src/$Dom.js +0 -380
  26. package/src/App.js +0 -224
  27. package/src/Bracket.js +0 -212
  28. package/src/Browser.js +0 -122
  29. package/src/ColorUtil.js +0 -166
  30. package/src/Dim.js +0 -21
  31. package/src/Easing.js +0 -41
  32. package/src/EventListener.js +0 -570
  33. package/src/LoadingManager.js +0 -368
  34. package/src/LocationManager.js +0 -236
  35. package/src/Moves.js +0 -59
  36. package/src/PageManager.js +0 -87
  37. package/src/SearchUtil.js +0 -210
  38. package/src/TModel.js +0 -937
  39. package/src/TModelManager.js +0 -575
  40. package/src/TUtil.js +0 -162
  41. package/src/TargetExecutor.js +0 -113
  42. package/src/TargetManager.js +0 -191
  43. package/src/TargetUtil.js +0 -307
  44. package/src/Viewport.js +0 -180
package/src/TModel.js DELETED
@@ -1,937 +0,0 @@
1
- import { tapp, App } from "./App.js";
2
- import { browser } from "./Browser.js";
3
- import { SearchUtil } from "./SearchUtil.js";
4
- import { TUtil } from "./TUtil.js";
5
- import { TargetUtil } from "./TargetUtil.js";
6
- import { TargetExecutor } from "./TargetExecutor";
7
- import { Viewport } from "./Viewport.js";
8
-
9
- function TModel(type, targets) {
10
-
11
- if (arguments.length === 1 && typeof type === 'object') {
12
- targets = type;
13
- type = "";
14
- }
15
-
16
- this.type = type ? type : 'blank';
17
- this.targets = Object.assign({}, targets);
18
- this.activeTargetList = [];
19
- this.activeTargetMap = {};
20
-
21
- var uniqueId = App.getOid(this.type);
22
- this.oid = uniqueId.oid;
23
- this.oidNum = uniqueId.num;
24
-
25
- this.targetValues = {};
26
-
27
- this.actualValues = {
28
- x: 0,
29
- y: 0,
30
- width: 0,
31
- height: 0,
32
- leftMargin: 0,
33
- rightMargin: 0,
34
- topMargin: 0,
35
- bottomMargin: 0,
36
- innerWidth: undefined,
37
- innerHeight: undefined,
38
- opacity: 1,
39
- zIndex: 1,
40
- scale: 1,
41
- rotate: 0,
42
- scrollLeft: 0,
43
- scrollTop: 0,
44
- textOnly: true,
45
- html: undefined,
46
- css: '',
47
- style: null,
48
- borderRadius: 0,
49
- children: [],
50
- addedChildren: [],
51
- allChildren: [],
52
- isInFlow: true,
53
- canHaveDom: true,
54
- canHandleEvents: false,
55
- widthFromDom: false,
56
- heightFromDom: false,
57
- keepEventDefault: false,
58
- isIncluded: true,
59
- canBeBracketed: true,
60
- isDomDeletable: true,
61
- calculateChildren: undefined,
62
- isVisible: undefined
63
- };
64
-
65
- this.updatingTargetList = [];
66
- this.updatingTargetMap = {};
67
-
68
- this.styleTargetList = [];
69
- this.styleTargetMap = {};
70
-
71
- this.updatingChildrenList = [];
72
- this.updatingChildrenMap = {};
73
-
74
- this.targetMethodMap = {};
75
-
76
- this.parent = null;
77
-
78
- this.$dom = null;
79
-
80
- this.visibilityStatus = { top: false, right: false, bottom: false, left: false };
81
- this.visible = false;
82
-
83
- this.domHeight = undefined;
84
- this.domWidth = undefined;
85
-
86
- this.innerContentWidth = 0;
87
- this.innerContentHeight = 0;
88
- this.contentWidth = 0;
89
- this.contentHeight = 0;
90
-
91
- this.x = 0;
92
- this.y = 0;
93
- this.absX = 0;
94
- this.absY = 0;
95
-
96
- this.inFlowVisibles = [];
97
-
98
- this.domValues = {};
99
-
100
- this.initTargets();
101
- }
102
-
103
- TModel.prototype.getParent = function() {
104
- return this.parent;
105
- };
106
-
107
- TModel.prototype.getRealParent = function() {
108
- return this.parent;
109
- };
110
-
111
- TModel.prototype.getDomParent = function() {
112
- return this.actualValues.domParent ? this.actualValues.domParent : null;
113
- };
114
-
115
- TModel.prototype.getDomHolder = function() {
116
- return this.actualValues.domHolder ? this.actualValues.domHolder : this.getDomParent() ? this.getDomParent().$dom : SearchUtil.findParentByTarget(this, 'domHolder') ? SearchUtil.findParentByTarget(this, 'domHolder').$dom : null;
117
- };
118
-
119
- TModel.prototype.addToStyleTargetList = function(key) {
120
- if (!TargetUtil.styleTargetMap[key]) {
121
- return;
122
- }
123
-
124
- key = TargetUtil.transformMap[key] ? 'transform' : TargetUtil.dimMap[key] ? 'dim' : key;
125
-
126
- if (!this.styleTargetMap[key]) {
127
- this.styleTargetList.push(key);
128
- this.styleTargetMap[key] = true;
129
- }
130
- };
131
-
132
- TModel.prototype.bug = function() {
133
- return [
134
- { visible: this.isVisible() },
135
- { visibilityStatus: this.visibilityStatus },
136
- { hasDom: this.hasDom() },
137
- { x: this.getX() },
138
- { y: this.getY() },
139
- { width: this.getWidth() },
140
- { height: this.getHeight() },
141
- { activeTargetList: this.activeTargetList },
142
- { updatingTargetList: this.updatingTargetList },
143
- { styleTargetList: this.styleTargetList },
144
- { children: this.getChildren() },
145
- { targetValues: this.targetValues },
146
- { actualValues: this.actualValues }
147
- ];
148
- };
149
-
150
- TModel.prototype.initTargets = function() {
151
- var self = this;
152
- this.targetValues = {};
153
- this.activeTargetMap = {};
154
- this.activeTargetList = [];
155
- Object.keys(this.targets).forEach(function(key) {
156
- self.processNewTarget(key);
157
- });
158
- };
159
-
160
- TModel.prototype.processNewTarget = function(key) {
161
- TargetUtil.bindTargetName(this.targets, key);
162
-
163
- if (TUtil.isDefined(this.targets[key].initialValue)) {
164
- this.actualValues[key] = this.targets[key].initialValue;
165
- this.addToStyleTargetList(key);
166
- }
167
- if (this.targets[key].active !== false) {
168
- this.addToActiveTargets(key);
169
- }
170
- };
171
-
172
- TModel.prototype.hasDomHolderChanged = function() {
173
- return this.getDomHolder() && this.getDomHolder().exists() && this.$dom.parent().getAttribute("id") !== this.getDomHolder().attr("id");
174
- };
175
-
176
- TModel.prototype.hasDom = function () {
177
- return !!this.$dom && this.$dom.exists();
178
- };
179
-
180
- TModel.prototype.hasChildren = function() {
181
- return this.getChildren().length > 0;
182
- };
183
-
184
- TModel.prototype.getChildren = function() {
185
- var lastUpdateAllChildren = this.getActualValueLastUpdate('allChildren');
186
- var lastUpdateChildren = this.getActualValueLastUpdate('children');
187
- var lastUpdateAddedChildren = this.getActualValueLastUpdate('addedChildren');
188
-
189
- if (!lastUpdateAllChildren ||
190
- lastUpdateChildren >= lastUpdateAllChildren ||
191
- lastUpdateAddedChildren >= lastUpdateAllChildren) {
192
-
193
- var children = this.actualValues.children;
194
- var addedChildren = this.actualValues.addedChildren;
195
-
196
- this.actualValues.allChildren = [].concat(children, addedChildren);
197
-
198
- if (children && children.length > 0) {
199
- var self = this;
200
- children.forEach(function(t) { t.parent = self; });
201
- this.actualValues.allChildren.sort(function(a, b) {
202
- return !a.canBeBracketed() && b.canBeBracketed() ? -1 : 1;
203
- });
204
- }
205
- if (this.targetValues['allChildren']) {
206
- this.setActualValueLastUpdate('allChildren');
207
- } else {
208
- this.setTarget('allChildren', this.actualValues.allChildren);
209
- }
210
- }
211
-
212
- return this.actualValues.allChildren;
213
- };
214
-
215
- TModel.prototype.getAllNestedChildren = function() {
216
- var nested = [];
217
-
218
- function traverse(tmodel) {
219
- if (tmodel.hasChildren()) {
220
- var list = tmodel.getChildren();
221
- nested = nested.concat(list);
222
- list.forEach(function(t) {
223
- traverse(t);
224
- });
225
- }
226
- }
227
-
228
- traverse(this);
229
- return nested;
230
- };
231
-
232
- TModel.prototype.getLastChild = function() {
233
- return this.hasChildren() ? this.getChildren()[this.getChildren().length - 1] : undefined;
234
- };
235
-
236
- TModel.prototype.getFirstChild = function() {
237
- return this.hasChildren() ? this.getChildren()[0] : undefined;
238
- };
239
-
240
- TModel.prototype.getChild = function(index) {
241
- return this.hasChildren() ? this.getChildren()[index] : undefined;
242
- };
243
-
244
- TModel.prototype.getChildIndex = function(child) {
245
- return this.getChildren().indexOf(child);
246
- };
247
-
248
- TModel.prototype.getChildrenOids = function() {
249
- return this.getChildren().oids();
250
- };
251
-
252
- TModel.prototype.filterChildren = function(type) {
253
- return this.getChildren().filter(function(tmodel) {
254
- return Array.isArray(type) ? type.includes(tmodel.type) : typeof type === 'function' ? type.call(tmodel) : tmodel.type === type;
255
- });
256
- };
257
-
258
- TModel.prototype.findChild = function(type) {
259
- return this.getChildren().find(function(child) {
260
- return typeof type === 'function' ? type.call(child) : child.type === type;
261
- });
262
- };
263
-
264
- TModel.prototype.findLastChild = function(type) {
265
- return this.getChildren().findLast(function(child) {
266
- return typeof type === 'function' ? type.call(child) : child.type === type;
267
- });
268
- };
269
-
270
- TModel.prototype.getParentValue = function(targetName) {
271
- var parent = SearchUtil.findParentByTarget(this, targetName);
272
- return parent ? parent.val(targetName) : undefined;
273
- };
274
-
275
- TModel.prototype.getGlobalValue = function(targetName) {
276
- var tmodel = SearchUtil.findByTarget(targetName);
277
- return tmodel ? tmodel.val(targetName) : undefined;
278
- };
279
-
280
- TModel.prototype.getGlobalValueByType = function(type, targetName) {
281
- var tmodel = SearchUtil.findByType(type);
282
- return tmodel ? tmodel.val(targetName) : undefined;
283
- };
284
-
285
- TModel.prototype.getContentHeight = function() {
286
- return this.contentHeight;
287
- };
288
-
289
- TModel.prototype.getInnerContentHeight = function() {
290
- return 0;
291
- };
292
-
293
- TModel.prototype.getInnerHeight = function() {
294
- return TUtil.isDefined(this.actualValues.innerHeight) ? this.actualValues.innerHeight : this.getHeight();
295
- };
296
-
297
- TModel.prototype.getInnerWidth = function() {
298
- return TUtil.isDefined(this.actualValues.innerWidth) ? this.actualValues.innerWidth : this.getWidth();
299
- };
300
-
301
- TModel.prototype.getInnerXEast = function() {
302
- return this.absX + this.getInnerWidth();
303
- };
304
-
305
- TModel.prototype.getOuterXEast = function() {
306
- return this.absX + this.getInnerWidth();
307
- };
308
-
309
- TModel.prototype.getContentWidth = function() {
310
- return this.contentWidth;
311
- };
312
-
313
- TModel.prototype.getUIDepth = function() {
314
- var depth = 0;
315
-
316
- var node = this.parent;
317
- while (node) {
318
- depth++;
319
- node = node.parent;
320
- }
321
-
322
- return depth;
323
- };
324
-
325
- TModel.prototype.resetVisibleList = function() {
326
- this.inFlowVisibles.length = 0;
327
- };
328
-
329
- TModel.prototype.addToParentVisibleList = function() {
330
- if (this.isVisible() && this.isInFlow() && this.getParent()) {
331
- this.getParent().inFlowVisibles.push(this);
332
- }
333
- };
334
-
335
- TModel.prototype.isVisible = function () {
336
- return TUtil.isDefined(this.actualValues.isVisible) ? this.actualValues.isVisible : this.visible;
337
- };
338
-
339
- TModel.prototype.shouldCalculateChildren = function() {
340
- return TUtil.isDefined(this.actualValues.calculateChildren) ?this.actualValues.calculateChildren : this.isVisible() && this.isIncluded() && (this.hasChildren() || this.getContentHeight() > 0);
341
- };
342
-
343
- TModel.prototype.createViewport = function() {
344
- this.viewport = this.viewport ? this.viewport.reset() : new Viewport(this);
345
- return this.viewport;
346
- };
347
-
348
- TModel.prototype.setLocation = function(viewport) {
349
- this.x = viewport.getXNext();
350
- this.y = viewport.getYNext();
351
- };
352
-
353
- TModel.prototype.calculateAbsolutePosition = function(x, y) {
354
- var rect = this.getBoundingRect();
355
- this.absX = rect.left + x;
356
- this.absY = rect.top + y;
357
- };
358
-
359
- TModel.prototype.getBoundingRect = function() {
360
- return TUtil.getBoundingRect(this);
361
- };
362
-
363
- TModel.prototype.isMarkedDeleted = function() {
364
- return this.val('tmodelDeletedFlag') === true;
365
- };
366
-
367
- TModel.prototype.markAsDeleted = function() {
368
- this.val('tmodelDeletedFlag', true);
369
- this.getChildren().forEach(function(tmodel) {
370
- tmodel.markAsDeleted();
371
- });
372
- };
373
-
374
- TModel.prototype.isTextOnly = function() {
375
- return this.actualValues.textOnly;
376
- };
377
-
378
- TModel.prototype.getHtml = function() {
379
- return this.actualValues.html;
380
- };
381
-
382
- TModel.prototype.isInFlow = function() {
383
- return this.actualValues.isInFlow;
384
- };
385
-
386
- TModel.prototype.canHandleEvents = function(eventName) {
387
- var events = this.actualValues.canHandleEvents;
388
- return events === eventName || (Array.isArray(events) && events.includes(eventName));
389
- };
390
-
391
- TModel.prototype.keepEventDefault = function() {
392
- return this.actualValues.keepEventDefault;
393
- };
394
-
395
- TModel.prototype.canBeBracketed = function() {
396
- return this.actualValues.canBeBracketed;
397
- };
398
-
399
- TModel.prototype.isIncluded = function() {
400
- return this.actualValues.isIncluded;
401
- };
402
-
403
- TModel.prototype.canHaveDom = function() {
404
- return this.actualValues.canHaveDom;
405
- };
406
-
407
- TModel.prototype.isDomDeletable = function() {
408
- return this.actualValues.isDomDeletable;
409
- };
410
-
411
- TModel.prototype.getOpacity = function() {
412
- return this.actualValues.opacity;
413
- };
414
-
415
- TModel.prototype.getX = function() {
416
- return this.actualValues.x;
417
- };
418
-
419
- TModel.prototype.getY = function() {
420
- return this.actualValues.y;
421
- };
422
-
423
- TModel.prototype.getZIndex = function() {
424
- return this.actualValues.zIndex;
425
- };
426
-
427
- TModel.prototype.getScale = function() {
428
- return this.actualValues.scale;
429
- };
430
-
431
- TModel.prototype.getMeasuringScale = function() {
432
- return this.actualValues.scale;
433
- };
434
-
435
- TModel.prototype.getTopMargin = function () {
436
- return this.actualValues.topMargin;
437
- };
438
-
439
- TModel.prototype.getLeftMargin = function() {
440
- return this.actualValues.leftMargin;
441
- };
442
-
443
- TModel.prototype.getRightMargin = function () {
444
- return this.actualValues.rightMargin;
445
- };
446
-
447
- TModel.prototype.getBottomMargin = function () {
448
- return this.actualValues.bottomMargin;
449
- };
450
-
451
- TModel.prototype.getRotate = function() {
452
- return this.actualValues.rotate;
453
- };
454
-
455
- TModel.prototype.getWidth = function () {
456
- return this.actualValues.width;
457
- };
458
-
459
- TModel.prototype.getHeight = function () {
460
- return this.actualValues.height;
461
- };
462
-
463
- TModel.prototype.getScrollTop = function() {
464
- return Math.floor(this.actualValues.scrollTop);
465
- };
466
-
467
- TModel.prototype.getScrollLeft = function() {
468
- return Math.floor(this.actualValues.scrollLeft);
469
- };
470
-
471
- TModel.prototype.getCss = function() {
472
- return this.actualValues.css.indexOf('tgt') >= 0 ? this.actualValues.css : !this.actualValues.css ? 'tgt' : 'tgt ' + this.actualValues.css;
473
- };
474
-
475
- TModel.prototype.getStyle = function() {
476
- return this.actualValues.style;
477
- };
478
-
479
- TModel.prototype.getScaledWidth = function() {
480
- return this.getWidth() * this.getScale();
481
- };
482
-
483
- TModel.prototype.getScaledHeight = function() {
484
- return this.getHeight() * this.getScale();
485
- };
486
-
487
- TModel.prototype.getTargetStepPercent = function(key, step) {
488
- var steps = this.getTargetSteps(key);
489
- step = !TUtil.isDefined(step) ? this.getTargetStep(key) : step;
490
- return steps ? step / steps : 1;
491
- };
492
-
493
- TModel.prototype.resetTargetStep = function(key) {
494
- if (this.targetValues[key]) {
495
- this.targetValues[key].step = 0;
496
- }
497
-
498
- return this;
499
- };
500
-
501
- TModel.prototype.resetTargetExecutionCount = function(key) {
502
- if (this.targetValues[key]) {
503
- this.targetValues[key].executionCount = 0;
504
- }
505
-
506
- return this;
507
- };
508
-
509
- TModel.prototype.resetTargetExecutionFlag = function(key) {
510
- if (this.targetValues[key]) {
511
- this.targetValues[key].executionFlag = false;
512
- }
513
-
514
- return this;
515
- };
516
-
517
- TModel.prototype.resetTargetCycle = function(key) {
518
- if (this.targetValues[key]) {
519
- this.targetValues[key].cycle = 0;
520
- }
521
-
522
- return this;
523
- };
524
-
525
- TModel.prototype.resetScheduleTimeStamp = function(key) {
526
- if (this.targetValues[key]) {
527
- this.targetValues[key].scheduleTimeStamp = undefined;
528
- }
529
-
530
- return this;
531
- };
532
-
533
- TModel.prototype.resetTargetInitialValue = function(key) {
534
- if (this.targetValues[key]) {
535
- this.targetValues[key].initialValue = undefined;
536
- }
537
-
538
- return this;
539
- };
540
-
541
- TModel.prototype.updateTargetStatus = function(key) {
542
- var targetValue = this.targetValues[key];
543
-
544
- if (!targetValue) {
545
- return;
546
- }
547
-
548
- var cycle = this.getTargetCycle(key);
549
- var cycles = this.getTargetCycles(key);
550
- var step = this.getTargetStep(key);
551
- var steps = this.getTargetSteps(key);
552
-
553
- if (this.isExecuted(key) && step < steps) {
554
- this.targetValues[key].status = 'updating';
555
- } else if (Array.isArray(targetValue.valueList) && cycle < targetValue.valueList.length - 1) {
556
- this.targetValues[key].status = 'updating';
557
- } else if (!this.isExecuted(key) || this.isTargetInLoop(key) || cycle < cycles) {
558
- this.targetValues[key].status = 'active';
559
- } else {
560
- this.targetValues[key].status = 'done';
561
- }
562
-
563
- if (this.isTargetUpdating(key)) {
564
- this.addToUpdatingTargets(key);
565
- this.removeFromActiveTargets(key);
566
- } else if (this.isTargetActive(key)) {
567
- this.addToActiveTargets(key);
568
- this.removeFromUpdatingTargets(key);
569
- } else {
570
- this.removeFromActiveTargets(key);
571
- this.removeFromUpdatingTargets(key);
572
- tapp.manager.doneTargets.push({ tmodel: this, key: key });
573
- }
574
- return this.targetValues[key].status;
575
- };
576
-
577
- TModel.prototype.getTargetStatus = function(key) {
578
- return this.targetValues[key] ? this.targetValues[key].status : '';
579
- };
580
-
581
- TModel.prototype.isTargetActive = function(key) {
582
- return this.targetValues[key] && this.targetValues[key].status === 'active';
583
- };
584
-
585
- TModel.prototype.isTargetUpdating = function(key) {
586
- return this.targetValues[key] && this.targetValues[key].status === 'updating';
587
- };
588
-
589
- TModel.prototype.isTargetDone = function(key) {
590
- return this.targetValues[key] && this.targetValues[key].status === 'done';
591
- };
592
-
593
- TModel.prototype.isTargetComplete = function(key) {
594
- return this.targetValues[key] && this.targetValues[key].status === 'complete';
595
- };
596
-
597
- TModel.prototype.isExecuted = function(key) {
598
- return this.targetValues[key] && this.targetValues[key].executionFlag;
599
- };
600
-
601
- TModel.prototype.isTargetImperative = function(key) {
602
- return this.targetValues[key] ? this.targetValues[key].isImperative: false;
603
- };
604
-
605
- TModel.prototype.getTargetExecutionCount = function(key) {
606
- return this.targetValues[key] ? this.targetValues[key].executionCount : 0;
607
- };
608
-
609
- TModel.prototype.setTargetComplete = function(key) {
610
- if (this.targetValues[key]) {
611
- this.targetValues[key].status = 'complete';
612
- }
613
- };
614
-
615
- TModel.prototype.isTargetEnabled = function(key) {
616
- if (this.isTargetImperative(key)) {
617
- return true;
618
- }
619
-
620
- var target = this.targets[key];
621
-
622
- if (!TUtil.isDefined(target)) {
623
- return false;
624
- }
625
-
626
- return typeof target.enabledOn === 'function' ? target.enabledOn.call(this) : true;
627
- };
628
-
629
- TModel.prototype.isTargetInLoop = function(key) {
630
- return this.targets[key] ? (typeof this.targets[key].loop === 'function' ? this.targets[key].loop.call(this, key) : this.targets[key].loop) : false;
631
- };
632
-
633
- TModel.prototype.doesTargetEqualActual = function(key) {
634
- if (this.targetValues[key]) {
635
- var deepEquality = this.targets[key] ? this.targets[key].deepEquality : false;
636
- return deepEquality ? TUtil.areEqual(this.getTargetValue(key), this.val(key), deepEquality) : this.getTargetValue(key) === this.val(key);
637
- }
638
-
639
- return false;
640
- };
641
-
642
- TModel.prototype.getTargetValue = function(key) {
643
- return this.targetValues[key] ? (typeof this.targetValues[key].value === 'function' ? this.targetValues[key].value.call(this) : this.targetValues[key].value) : undefined;
644
- };
645
-
646
- TModel.prototype.getTargetSteps = function(key) {
647
- return this.targetValues[key] ? this.targetValues[key].steps || 0 : 0;
648
- };
649
-
650
- TModel.prototype.getTargetStep = function(key) {
651
- return this.targetValues[key] ? this.targetValues[key].step : 0;
652
- };
653
-
654
- TModel.prototype.getScheduleTimeStamp = function(key) {
655
- return this.targetValues[key] ? this.targetValues[key].scheduleTimeStamp : undefined;
656
- };
657
-
658
- TModel.prototype.getTargetInitialValue = function(key) {
659
- return this.targetValues[key] ? this.targetValues[key].initialValue : undefined;
660
- };
661
-
662
- TModel.prototype.getActualValueLastUpdate = function(key) {
663
- return this.targetValues[key] ? this.targetValues[key].actualValueLastUpdate : undefined;
664
- };
665
-
666
- TModel.prototype.getTargetCreationTime = function(key) {
667
- return this.targetValues[key] ? this.targetValues[key].creationTime : undefined;
668
- };
669
-
670
- TModel.prototype.setTargetStep = function(key, value) {
671
- if (this.targetValues[key]) {
672
- this.targetValues[key].step = value;
673
- }
674
- return this.targetValues[key].step;
675
- };
676
-
677
- TModel.prototype.getTargetCycles = function(key) {
678
- return this.targetValues[key] ? this.targetValues[key].cycles || 0 : 0;
679
- };
680
-
681
- TModel.prototype.getTargetCycle = function(key) {
682
- return this.targetValues[key] ? this.targetValues[key].cycle : 0;
683
- };
684
-
685
- TModel.prototype.setTargetCycle = function(key, value) {
686
- if (this.targetValues[key]) {
687
- this.targetValues[key].cycle = value;
688
- }
689
- };
690
-
691
- TModel.prototype.setTargetInterval = function(key, value) {
692
- if (this.targetValues[key]) {
693
- this.targetValues[key].interval = value;
694
- }
695
- return this.targetValues[key].interval;
696
- };
697
-
698
- TModel.prototype.setScheduleTimeStamp = function(key, value) {
699
- if (this.targetValues[key]) {
700
- this.targetValues[key].scheduleTimeStamp = value;
701
- }
702
- };
703
-
704
- TModel.prototype.setTargetInitialValue = function(key, value) {
705
- if (this.targetValues[key]) {
706
- this.targetValues[key].initialValue = value;
707
- }
708
- };
709
-
710
- TModel.prototype.setActualValueLastUpdate = function(key) {
711
- if (this.targetValues[key]) {
712
- this.targetValues[key].actualValueLastUpdate = browser.now();
713
- }
714
- };
715
-
716
- TModel.prototype.getTargetEasing = function(key) {
717
- return typeof this.targetValues[key].easing === 'function' ? this.targetValues[key].easing : undefined;
718
- };
719
-
720
- TModel.prototype.getTargetInterval = function(key) {
721
- return this.targetValues[key] ? this.targetValues[key].interval : undefined;
722
- };
723
-
724
- TModel.prototype.getTargetEventFunctions = function(key) {
725
- return this.targetValues[key] ? this.targetValues[key].events: undefined;
726
- };
727
-
728
- TModel.prototype.setTarget = function(key, value, steps, interval, easing, originalTargetName) {
729
-
730
- originalTargetName = originalTargetName || this.key;
731
- TargetExecutor.executeImperativeTarget(this, key, value, steps, interval, easing, originalTargetName);
732
-
733
- return this;
734
- };
735
-
736
- TModel.prototype.val = function(key, value) {
737
- if (arguments.length === 2) {
738
- this.actualValues[key] = value;
739
- return this;
740
- }
741
- return this.actualValues[key];
742
- };
743
-
744
- TModel.prototype.addValue = function(key, value) {
745
- this.actualValues[key] += value;
746
- return this;
747
- };
748
-
749
- TModel.prototype.multiplyValue = function(key, value) {
750
- this.actualValues[key] *= value;
751
- return this;
752
- };
753
-
754
- TModel.prototype.addChild = function(child, index) {
755
- var addedChildren = this.actualValues.addedChildren;
756
-
757
- index = TUtil.isDefined(index) ? index : addedChildren.length;
758
- child.parent = this;
759
-
760
- if (index >= addedChildren.length) {
761
- addedChildren.push(child);
762
- } else {
763
- addedChildren.splice(index, 0, child);
764
- }
765
-
766
- this.setActualValueLastUpdate('children');
767
- if (this.targetValues['addedChildren']) {
768
- this.setActualValueLastUpdate('addedChildren');
769
- } else {
770
- this.setTarget('addedChildren', addedChildren);
771
- }
772
-
773
- tapp.manager.scheduleRun(10, 'addChild-' + this.oid + "-" + child.oid);
774
-
775
- return this;
776
- };
777
-
778
- TModel.prototype.addToUpdatingChildren = function(child) {
779
- if (!this.updatingChildrenMap[child.oid]) {
780
- this.updatingChildrenMap[child.oid] = true;
781
- this.updatingChildrenList.push(child.oid);
782
- }
783
- };
784
-
785
- TModel.prototype.removeFromUpdatingChildren = function(child) {
786
- if (this.updatingChildrenMap[child.oid]) {
787
- delete this.updatingChildrenMap[child.oid];
788
- var index = this.updatingChildrenList.indexOf(child.oid);
789
- if (index >= 0) {
790
- this.updatingChildrenList.splice(index, 1);
791
- }
792
- }
793
- };
794
-
795
- TModel.prototype.hasUpdatingChildren = function() {
796
- return this.updatingChildrenList.length > 0;
797
- };
798
-
799
- TModel.prototype.hasTargetUpdates = function(key) {
800
- return key ? this.updatingTargetMap[key] === true : this.updatingTargetList.length > 0;
801
- };
802
-
803
- TModel.prototype.removeTarget = function(key) {
804
- delete this.targets[key];
805
- this.removeFromActiveTargets(key);
806
- this.removeFromUpdatingTargets(key);
807
- delete this.targetValues[key];
808
- };
809
-
810
- TModel.prototype.addTarget = function(key, target) {
811
- this.addTargets({ [key]: target });
812
- };
813
-
814
- TModel.prototype.addTargets = function(targets) {
815
- var self = this;
816
- Object.keys(targets).forEach(function(key) {
817
- self.targets[key] = targets[key];
818
- self.removeFromUpdatingTargets(key);
819
- self.processNewTarget(key);
820
- });
821
-
822
- tapp.manager.scheduleRun(10, 'addTargets-' + this.oid);
823
- };
824
-
825
- TModel.prototype.addToActiveTargets = function(key) {
826
- if (!this.activeTargetMap[key]) {
827
- this.activeTargetMap[key] = true;
828
-
829
- if (key === 'start') {
830
- this.activeTargetList.unshift('start');
831
- } else if (key === 'width' || key === 'height') {
832
- var startIndex = this.activeTargetList.indexOf('start');
833
- if (startIndex !== -1) {
834
- this.activeTargetList.splice(1, 0, key);
835
- } else {
836
- this.activeTargetList.unshift(key);
837
- }
838
- } else {
839
- this.activeTargetList.push(key);
840
- }
841
- }
842
- };
843
-
844
- TModel.prototype.removeFromActiveTargets = function(key) {
845
- if (this.activeTargetMap[key]) {
846
- delete this.activeTargetMap[key];
847
- var index = this.activeTargetList.indexOf(key);
848
- if (index >= 0) {
849
- this.activeTargetList.splice(index, 1);
850
- }
851
- }
852
- };
853
-
854
- TModel.prototype.addToUpdatingTargets = function(key) {
855
- if (!this.updatingTargetMap[key]) {
856
- this.updatingTargetMap[key] = true;
857
- this.updatingTargetList.push(key);
858
- if (this.getParent()) {
859
- this.getParent().addToUpdatingChildren(this);
860
- }
861
- }
862
- };
863
-
864
- TModel.prototype.removeFromUpdatingTargets = function(key) {
865
- if (this.updatingTargetMap[key]) {
866
- delete this.updatingTargetMap[key];
867
- var index = this.updatingTargetList.indexOf(key);
868
- if (index >= 0) {
869
- this.updatingTargetList.splice(index, 1);
870
- }
871
- if (this.updatingTargetList.length === 0 && this.getParent()) {
872
- this.getParent().removeFromUpdatingChildren(this);
873
- }
874
- }
875
- };
876
-
877
- TModel.prototype.deleteTargetValue = function(key) {
878
- delete this.targetValues[key];
879
- this.addToActiveTargets(key);
880
- this.removeFromUpdatingTargets(key);
881
-
882
- tapp.manager.scheduleRun(10, 'deleteTargetValue-' + this.oid + "-" + key);
883
- };
884
-
885
- TModel.prototype.resetImperative = function(key) {
886
- var targetValue = this.targetValues[key];
887
-
888
- if (targetValue) {
889
- targetValue.isImperative = false;
890
- targetValue.executionFlag = false;
891
- targetValue.scheduleTimeStamp = undefined;
892
- targetValue.step = 0;
893
- targetValue.cycle = 0;
894
- targetValue.steps = 0;
895
- targetValue.cycles = 0;
896
- targetValue.interval = 0;
897
- }
898
-
899
- return this;
900
- };
901
-
902
- TModel.prototype.activateTarget = function(key) {
903
- return this.activateTargets([key]);
904
- };
905
-
906
- TModel.prototype.activateTargets = function(keys) {
907
- var self = this;
908
- keys.forEach(function(key) {
909
- var targetValue = self.targetValues[key];
910
-
911
- if (targetValue) {
912
- targetValue.executionFlag = false;
913
- targetValue.scheduleTimeStamp = undefined;
914
- targetValue.step = 0;
915
- targetValue.cycle = 0;
916
-
917
- self.updateTargetStatus(key);
918
- } else {
919
- self.addToActiveTargets(key);
920
- }
921
- });
922
-
923
- tapp.manager.scheduleRun(10, 'activateTargets-' + this.oid);
924
-
925
- return this;
926
- };
927
-
928
- TModel.prototype.setTargetMethodName = function(targetName, methodName) {
929
- if (!this.targetMethodMap[targetName]) {
930
- this.targetMethodMap[targetName] = [];
931
- }
932
- if (this.targetMethodMap[targetName].indexOf(methodName) === -1) {
933
- this.targetMethodMap[targetName].push(methodName);
934
- }
935
- };
936
-
937
- export { TModel };