targetj 1.0.2

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/src/TModel.js ADDED
@@ -0,0 +1,761 @@
1
+ function TModel(type, targets) {
2
+
3
+ if (arguments.length === 1 && typeof type === 'object') {
4
+ targets = type;
5
+ type = "";
6
+ }
7
+
8
+ this.type = type ? type : TUtil.getTypeFromCallerFile() || 'blank';
9
+ this.targets = Object.assign({}, targets);
10
+ var uniqueId = tapp.getOid(this.type);
11
+ this.oid = uniqueId.oid;
12
+ this.oidNum = uniqueId.num;
13
+
14
+ this.targetValues = {};
15
+
16
+ this.actualValues = {
17
+ x: 0,
18
+ y: 0,
19
+ width: 0,
20
+ height: 0,
21
+ leftMargin: 0,
22
+ rightMargin: 0,
23
+ topMargin: 0,
24
+ bottomMargin: 0,
25
+ opacity: 1,
26
+ zIndex: 1,
27
+ scale: 1,
28
+ rotate: 0,
29
+ scrollLeft: 0,
30
+ scrollTop: 0,
31
+ textOnly: true,
32
+ html: undefined,
33
+ css: '',
34
+ style: null,
35
+ children: [],
36
+ addedChildren: [],
37
+ allChildren: [],
38
+ isInFlow: true,
39
+ canHaveDom: true,
40
+ canHandleEvents: false,
41
+ isOverflowHidden: false,
42
+ canBeVisible: true,
43
+ canBeBracketed: true,
44
+ isDomDeletable: true
45
+ };
46
+ this.activeTargetKeyMap = {};
47
+
48
+ this.targetUpdatingMap = {};
49
+ this.targetUpdatingList = [];
50
+
51
+ this.updatingChildren = [];
52
+
53
+ this.targetLastUpdateMap = {};
54
+
55
+ this.parent = null;
56
+
57
+ this.$dom = null;
58
+ this.yVisible = false;
59
+ this.xVisible = false;
60
+ this.domHeight = undefined;
61
+ this.domWidth = undefined;
62
+
63
+ this.innerContentWidth = 0;
64
+ this.innerContentHeight = 0;
65
+ this.contentWidth = 0;
66
+ this.contentHeight = 0;
67
+
68
+ this.x = 0;
69
+ this.y = 0;
70
+ this.absX = 0;
71
+ this.absY = 0;
72
+ this.deepY = 0;
73
+ this.deepX = 0;
74
+
75
+ this.inFlowVisibles = [];
76
+
77
+ this.domValues = {};
78
+ }
79
+
80
+ TModel.prototype.getParent = function() {
81
+ return this.parent;
82
+ };
83
+
84
+ TModel.prototype.getRealParent = function() {
85
+ return this.parent;
86
+ };
87
+
88
+ TModel.prototype.getDomParent = function() {
89
+ return this.actualValues.domParent ? this.actualValues.domParent : null;
90
+ };
91
+
92
+ TModel.prototype.getDomHolder = function() {
93
+ return this.getDomParent() ? this.getDomParent().$dom : tapp.$dom;
94
+ };
95
+
96
+ TModel.prototype.hasDomHolderChanged = function() {
97
+
98
+ return this.getDomHolder() && this.getDomHolder().exists() && this.$dom.parent().getAttribute("id") !== this.getDomHolder().attr("id");
99
+ };
100
+
101
+ TModel.prototype.hasDom = function () {
102
+ return !!this.$dom && this.$dom.exists();
103
+ };
104
+
105
+ TModel.prototype.hasChildren = function() {
106
+ return this.getChildren().length > 0;
107
+ };
108
+
109
+ TModel.prototype.getChildren = function() {
110
+ if (!this.getActualValueLastUpdate('allChildren')
111
+ || this.getActualValueLastUpdate('children') >= this.getActualValueLastUpdate('allChildren')
112
+ || this.getActualValueLastUpdate('addedChildren') >= this.getActualValueLastUpdate('allChildren')) {
113
+
114
+ this.actualValues.allChildren = this.actualValues.children.concat(this.actualValues.addedChildren);
115
+
116
+ if (this.actualValues.children.length > 0) {
117
+ var self = this;
118
+ this.actualValues.children.forEach(function(t) { t.parent = self; });
119
+ this.actualValues.allChildren.sort(function(a, b) {
120
+ return !a.canBeBracketed() && b.canBeBracketed() ? -1 : 1;
121
+ });
122
+ }
123
+
124
+ this.targetValues['allChildren'] ? this.setActualValueLastUpdate('allChildren') : this.setTargetValue('allChildren', this.actualValues.allChildren);
125
+ }
126
+
127
+ return this.actualValues.allChildren;
128
+ };
129
+
130
+ TModel.prototype.getAllNestedChildren = function() {
131
+ var nested = [];
132
+
133
+ function traverse(tmodel) {
134
+ if (tmodel.hasChildren()) {
135
+ var list = tmodel.getChildren();
136
+ nested = nested.concat(list);
137
+ list.forEach(function(t) {
138
+ traverse(t);
139
+ });
140
+ }
141
+ }
142
+
143
+ traverse(this);
144
+ return nested;
145
+ };
146
+
147
+ TModel.prototype.getLastChild = function() {
148
+ return this.hasChildren() ? this.getChildren()[this.getChildren().length - 1] : undefined;
149
+ };
150
+
151
+ TModel.prototype.getFirstChild = function() {
152
+ return this.hasChildren() ? this.getChildren()[0] : undefined;
153
+ };
154
+
155
+ TModel.prototype.getChild = function(index) {
156
+ return this.hasChildren() ? this.getChildren()[index] : undefined;
157
+ };
158
+
159
+ TModel.prototype.getChildIndex = function(child) {
160
+ return this.getChildren().indexOf(child);
161
+ };
162
+
163
+ TModel.prototype.getChildrenOids = function() {
164
+ return this.getChildren().oids();
165
+ };
166
+
167
+ TModel.prototype.filterChildren = function(type) {
168
+ return this.getChildren().filter(function(tmodel) {
169
+ return Array.isArray(type) ? type.includes(tmodel.type) : typeof type === 'function' ? type.call(tmodel) : tmodel.type === type;
170
+ });
171
+ };
172
+
173
+ TModel.prototype.findChild = function(type) {
174
+ return this.getChildren().find(function(tmodel, index) {
175
+ var typeResult = typeof type === 'function' ? type.call(tmodel) : tmodel.type === type;
176
+ return typeResult;
177
+ });
178
+ };
179
+
180
+ TModel.prototype.findLastChild = function(type) {
181
+ return this.getChildren().findLast(function(tmodel) {
182
+ return typeof type === 'function' ? type.call(tmodel) : tmodel.type === type;
183
+ });
184
+ };
185
+
186
+ TModel.prototype.getParentValue = function(targetName) {
187
+ var parent = SearchUtil.findParentWithTarget(this, targetName);
188
+ return parent ? parent.getValue(targetName) : undefined;
189
+ };
190
+
191
+ TModel.prototype.getGlobalValue = function(targetName) {
192
+ var tmodel = SearchUtil.findByTarget(targetName);
193
+ return tmodel ? tmodel.getValue(targetName) : undefined;
194
+ };
195
+
196
+ TModel.prototype.getGlobalValueByType = function(type, targetName) {
197
+ var tmodel = SearchUtil.findByType(type);
198
+ return tmodel ? tmodel.getValue(targetName) : undefined;
199
+ };
200
+
201
+ TModel.prototype.getContentHeight = function() {
202
+ return this.contentHeight;
203
+ };
204
+
205
+ TModel.prototype.getInnerContentHeight = function() {
206
+ return 0;
207
+ };
208
+
209
+ TModel.prototype.getInnerHeight = function() {
210
+ return TUtil.isDefined(this.actualValues.innerHeight) ? this.actualValues.innerHeight : this.getHeight();
211
+ };
212
+
213
+ TModel.prototype.getInnerWidth = function() {
214
+ return TUtil.isDefined(this.actualValues.innerWidth) ? this.actualValues.innerWidth : this.getWidth();
215
+ };
216
+
217
+ TModel.prototype.getContentWidth = function() {
218
+ return this.contentWidth;
219
+ };
220
+
221
+ TModel.prototype.getUIDepth = function() {
222
+ var depth = 0;
223
+
224
+ var node = this.parent;
225
+ while (node) {
226
+ depth++;
227
+ node = node.parent;
228
+ }
229
+
230
+ return depth;
231
+ };
232
+
233
+ TModel.prototype.resetVisibleList = function() {
234
+ this.inFlowVisibles.length = 0;
235
+ };
236
+
237
+ TModel.prototype.addToParentVisibleList = function() {
238
+ if (this.isVisible() && this.isInFlow() && this.getParent()) {
239
+ this.getParent().inFlowVisibles.push(this);
240
+ }
241
+ };
242
+
243
+ TModel.prototype.isVisible = function () {
244
+ return this.xVisible && this.yVisible;
245
+ };
246
+
247
+ TModel.prototype.createViewport = function() {
248
+ this.viewport = this.viewport ? this.viewport.reset() : new Viewport(this);
249
+ return this.viewport;
250
+ };
251
+
252
+ TModel.prototype.setLocation = function(viewport) {
253
+ this.x = viewport.getXNext();
254
+ this.y = viewport.getYNext();
255
+
256
+ this.absX = this.getDomParent() ? this.getDomParent().absX + this.x : this.x;
257
+ this.absY = this.getDomParent() ? this.getDomParent().absY + this.y : this.y;
258
+
259
+ var scrollTopHandler = SearchUtil.findFirstScrollTopHandler(this);
260
+ var scrollLeftHandler = SearchUtil.findFirstScrollLeftHandler(this);
261
+
262
+ this.deepX = this.absX + (scrollTopHandler ? scrollTopHandler.getScrollTop() : 0);
263
+ this.deepY = this.absY + (scrollLeftHandler ? scrollLeftHandler.getScrollLeft() : 0);
264
+ };
265
+
266
+ TModel.prototype.shouldCalculateChildrenLocations = function() {
267
+ return this.isVisible() && this.canBeVisible() && (this.hasChildren() || this.getContentHeight() > 0);
268
+ };
269
+
270
+ TModel.prototype.manuallyCalculateChildrenLocations = function() {};
271
+
272
+ TModel.prototype.fixOpacity = function () {
273
+ var opacity = this.getOpacity().toFixed(2);
274
+
275
+ if (this.$dom.opacity() !== opacity) {
276
+ this.$dom.opacity(opacity);
277
+ }
278
+ };
279
+
280
+ TModel.prototype.fixCss = function () {
281
+ var css = this.getCss();
282
+ if (this.$dom.css() !== css) {
283
+ this.$dom.css(css);
284
+ }
285
+ };
286
+
287
+ TModel.prototype.fixStyle = function () {
288
+ var style = this.getStyle();
289
+ if (TUtil.isDefined(style) && this.domValues.style !== style) {
290
+ this.$dom.setStyleByMap(style);
291
+ this.domValues.style = style;
292
+ }
293
+ };
294
+
295
+ TModel.prototype.fixXYRotateScale = function () {
296
+ var x = Math.floor(this.getX()), y = Math.floor(this.getY()), rotate = Math.floor(this.getRotate()), scale = TUtil.formatNum(this.getScale(), 2);
297
+
298
+ if (this.domValues.x !== x || this.domValues.y !== y || this.domValues.rotate !== rotate || this.domValues.scale !== scale) {
299
+ this.$dom.transform(x, y, rotate, scale);
300
+
301
+ this.domValues.y = y;
302
+ this.domValues.x = x;
303
+ this.domValues.rotate = rotate;
304
+ this.domValues.scale = scale;
305
+ }
306
+ };
307
+
308
+ TModel.prototype.fixDim = function () {
309
+ var width = Math.floor(this.getWidth());
310
+ var height = Math.floor(this.getHeight());
311
+
312
+ if (this.$dom.width() !== width || this.$dom.height() !== height) {
313
+ this.$dom.width(width);
314
+ this.$dom.height(height);
315
+ }
316
+ };
317
+
318
+ TModel.prototype.fixZIndex = function () {
319
+
320
+ var zIndex = Math.floor(this.getZIndex());
321
+ if (this.$dom.zIndex() !== zIndex) {
322
+ this.$dom.zIndex(zIndex);
323
+ }
324
+ };
325
+
326
+ TModel.prototype.isMarkedDeleted = function() {
327
+ return this.getValue('tmodelDeletedFlag') === true;
328
+ };
329
+
330
+ TModel.prototype.markAsDeleted = function() {
331
+ this.setTargetValue('tmodelDeletedFlag', true);
332
+ this.getChildren().forEach(function(tmodel) {
333
+ tmodel.markAsDeleted();
334
+ });
335
+ };
336
+
337
+ TModel.prototype.isTextOnly = function() {
338
+ return this.actualValues.textOnly;
339
+ };
340
+
341
+ TModel.prototype.getHtml = function() {
342
+ return this.actualValues.html;
343
+ };
344
+
345
+ TModel.prototype.isOverflowHidden = function () {
346
+ return this.actualValues.isOverflowHidden;
347
+ };
348
+
349
+ TModel.prototype.isInFlow = function() {
350
+ return this.actualValues.isInFlow;
351
+ };
352
+
353
+ TModel.prototype.canHandleEvents = function() {
354
+ return this.actualValues.canHandleEvents;
355
+ };
356
+
357
+ TModel.prototype.canBeBracketed = function() {
358
+ return this.actualValues.canBeBracketed;
359
+ };
360
+
361
+ TModel.prototype.canBeVisible = function() {
362
+ return this.actualValues.canBeVisible;
363
+ };
364
+
365
+ TModel.prototype.canHaveDom = function() {
366
+ return this.actualValues.canHaveDom;
367
+ };
368
+
369
+ TModel.prototype.isDomDeletable = function() {
370
+ return this.actualValues.isDomDeletable;
371
+ };
372
+
373
+ TModel.prototype.getOpacity = function() {
374
+ return this.actualValues.opacity;
375
+ };
376
+
377
+ TModel.prototype.getX = function() {
378
+ return this.actualValues.x;
379
+ };
380
+
381
+ TModel.prototype.getY = function() {
382
+ return this.actualValues.y;
383
+ };
384
+
385
+ TModel.prototype.getZIndex = function() {
386
+ return this.actualValues.zIndex;
387
+ };
388
+
389
+ TModel.prototype.getScale = function() {
390
+ return this.actualValues.scale;
391
+ };
392
+
393
+ TModel.prototype.getValue = function(key) {
394
+ return this.actualValues[key];
395
+ };
396
+
397
+ TModel.prototype.getTopMargin = function () {
398
+ return this.actualValues.topMargin;
399
+ };
400
+
401
+ TModel.prototype.getLeftMargin = function() {
402
+ return this.actualValues.leftMargin;
403
+ };
404
+
405
+ TModel.prototype.getRightMargin = function () {
406
+ return this.actualValues.rightMargin;
407
+ };
408
+
409
+ TModel.prototype.getBottomMargin = function () {
410
+ return this.actualValues.bottomMargin;
411
+ };
412
+
413
+ TModel.prototype.getRotate = function() {
414
+ return this.actualValues.rotate;
415
+ };
416
+
417
+ TModel.prototype.getWidth = function () {
418
+ return this.actualValues.width;
419
+ };
420
+
421
+ TModel.prototype.getHeight = function () {
422
+ return this.actualValues.height;
423
+ };
424
+
425
+ TModel.prototype.getScrollTop = function() {
426
+ return Math.floor(this.actualValues.scrollTop);
427
+ };
428
+
429
+ TModel.prototype.getScrollLeft = function() {
430
+ return Math.floor(this.actualValues.scrollLeft);
431
+ };
432
+
433
+ TModel.prototype.getCss = function() {
434
+ return this.actualValues.css.indexOf('tgt') >= 0 ? this.actualValues.css : !this.actualValues.css ? 'tgt' : 'tgt ' + this.actualValues.css;
435
+ };
436
+
437
+ TModel.prototype.getStyle = function() {
438
+ return this.actualValues.style;
439
+ };
440
+
441
+ TModel.prototype.getScaledWidth = function() {
442
+ return this.getWidth() * this.getScale();
443
+ };
444
+
445
+ TModel.prototype.getScaledHeight = function() {
446
+ return this.getHeight() * this.getScale();
447
+ };
448
+
449
+ TModel.prototype.getTargetStepPercent = function(key, step) {
450
+ var steps = this.getTargetSteps(key);
451
+ step = !TUtil.isDefined(step) ? this.getTargetStep(key) : step;
452
+ return steps ? step / steps : 1;
453
+ };
454
+
455
+ TModel.prototype.resetTargetStep = function(key) {
456
+ if (this.targetValues[key]) {
457
+ this.targetValues[key].step = 0;
458
+ }
459
+ };
460
+
461
+ TModel.prototype.resetTargetCycle = function(key) {
462
+ if (this.targetValues[key]) {
463
+ this.targetValues[key].cycle = 0;
464
+ }
465
+ };
466
+
467
+ TModel.prototype.resetActualTimeStamp = function(key) {
468
+ if (this.targetValues[key]) {
469
+ this.targetValues[key].actualTimeStamp = undefined;
470
+ }
471
+ };
472
+
473
+ TModel.prototype.resetLastActualValue = function(key) {
474
+ if (this.targetValues[key]) {
475
+ this.targetValues[key].lastActualValue = undefined;
476
+ }
477
+ };
478
+
479
+ TModel.prototype.hasTargetUpdatedAfter = function(key, targetKey, tmodel) {
480
+ tmodel = TUtil.isDefined(tmodel) ? tmodel : this;
481
+ var result = false;
482
+ var actualValueLastUpdate = tmodel ? tmodel.getActualValueLastUpdate(targetKey) : 0;
483
+ if (actualValueLastUpdate > 0 && (!this.targetLastUpdateMap[key + "_" + targetKey] || this.targetLastUpdateMap[key + "_" + targetKey] - actualValueLastUpdate < 10)) {
484
+ result = true;
485
+ this.targetLastUpdateMap[key + "_" + targetKey] = browser.now();
486
+ }
487
+
488
+ return result;
489
+ };
490
+
491
+ TModel.prototype.updateTargetStatus = function(key) {
492
+ if (!this.targetValues[key]) return;
493
+
494
+ var cycle = this.getTargetCycle(key);
495
+ var cycles = this.getTargetCycles(key);
496
+ var step = this.getTargetStep(key);
497
+ var steps = this.getTargetSteps(key);
498
+
499
+ this.targetValues[key].status = '';
500
+
501
+ if ((steps > 0 || cycles > 0) && (step < steps || cycle < cycles || !this.doesTargetEqualActual(key))) {
502
+ this.targetValues[key].status = 'updating';
503
+ } else if (this.doesTargetEqualActual(key) || !this.isTargetInLoop(key)) {
504
+ this.targetValues[key].status = 'done';
505
+ }
506
+ };
507
+
508
+ TModel.prototype.getTargetStatus = function(key) {
509
+ return this.targetValues[key] ? this.targetValues[key].status : 0;
510
+ };
511
+
512
+ TModel.prototype.isTargetUpdating = function(key) {
513
+ return this.targetValues[key] && this.targetValues[key].status === 'updating';
514
+ };
515
+
516
+ TModel.prototype.isTargetDone = function(key) {
517
+ return this.targetValues[key] && this.targetValues[key].status === 'done';
518
+ };
519
+
520
+ TModel.prototype.isTargetComplete = function(key) {
521
+ return this.targetValues[key] && this.targetValues[key].status === 'complete';
522
+ };
523
+
524
+ TModel.prototype.hasTargetGotExecuted = function(key) {
525
+ return this.targets[key] ? this.targetValues[key] && this.targetValues[key].executionCounter > 0 : true;
526
+ };
527
+
528
+ TModel.prototype.setTargetComplete = function(key) {
529
+ if (this.targetValues[key]) {
530
+ this.targetValues[key].status = 'complete';
531
+ }
532
+ };
533
+
534
+ TModel.prototype.isTargetEnabled = function(key) {
535
+ var target = this.targets[key];
536
+
537
+ if (!TUtil.isDefined(target) || target.enabledOn === false) return false;
538
+
539
+ var targetEnabled = typeof target.enabledOn === 'function' ? target.enabledOn.call(this, key) : true;
540
+
541
+ return !!targetEnabled;
542
+ };
543
+
544
+ TModel.prototype.isTargetInLoop = function(targetName) {
545
+ return TUtil.isDefined(this.targets[targetName]) && this.targets[targetName].loop;
546
+ };
547
+
548
+ TModel.prototype.enableTargetLoop = function(targetName) {
549
+ if (TUtil.isDefined(this.targets[targetName])) {
550
+ this.targets[targetName].loop = true;
551
+ }
552
+ };
553
+
554
+ TModel.prototype.disableTargetLoop = function(targetName) {
555
+ if (TUtil.isDefined(this.targets[targetName])) {
556
+ this.targets[targetName].loop = false;
557
+ }
558
+ };
559
+
560
+ TModel.prototype.doesTargetEqualActual = function(key) {
561
+ return this.targetValues[key] && this.getTargetValue(key) === this.getValue(key);
562
+ };
563
+
564
+ TModel.prototype.getTargetValue = function(key) {
565
+ return this.targetValues[key] ? (typeof this.targetValues[key].value === 'function' ? this.targetValues[key].value.call(this) : this.targetValues[key].value) : undefined;
566
+ };
567
+
568
+ TModel.prototype.getTargetSteps = function(key) {
569
+ return this.targetValues[key] ? this.targetValues[key].steps || 0 : 0;
570
+ };
571
+
572
+ TModel.prototype.getTargetStep = function(key) {
573
+ return this.targetValues[key] ? this.targetValues[key].step : 0;
574
+ };
575
+
576
+ TModel.prototype.getActualTimeStamp = function(key) {
577
+ return this.targetValues[key] ? this.targetValues[key].actualTimeStamp : undefined;
578
+ };
579
+
580
+ TModel.prototype.getLastActualValue = function(key) {
581
+ return this.targetValues[key] ? this.targetValues[key].lastActualValue : undefined;
582
+ };
583
+
584
+ TModel.prototype.getActualValueLastUpdate = function(key) {
585
+ return this.targetValues[key] ? this.targetValues[key].actualValueLastUpdate : undefined;
586
+ };
587
+
588
+ TModel.prototype.setTargetStep = function(key, value) {
589
+ if (this.targetValues[key]) {
590
+ this.targetValues[key].step = value;
591
+ }
592
+ return this.targetValues[key].step;
593
+ };
594
+
595
+ TModel.prototype.getTargetCycles = function(key) {
596
+ return this.targetValues[key] ? this.targetValues[key].cycles || 0 : 0;
597
+ };
598
+
599
+ TModel.prototype.getTargetCycle = function(key) {
600
+ return this.targetValues[key] ? this.targetValues[key].cycle : 0;
601
+ };
602
+
603
+ TModel.prototype.setTargetCycle = function(key, value) {
604
+ if (this.targetValues[key]) {
605
+ this.targetValues[key].cycle = value;
606
+ }
607
+ };
608
+
609
+ TModel.prototype.setActualTimeStamp = function(key, value) {
610
+ if (this.targetValues[key]) {
611
+ this.targetValues[key].actualTimeStamp = value;
612
+ }
613
+ };
614
+
615
+ TModel.prototype.setLastActualValue = function(key, value) {
616
+ if (this.targetValues[key]) {
617
+ this.targetValues[key].lastActualValue = value;
618
+ }
619
+ };
620
+
621
+ TModel.prototype.setActualValueLastUpdate = function(key) {
622
+ if (this.targetValues[key]) {
623
+ this.targetValues[key].actualValueLastUpdate = browser.now();
624
+ }
625
+ };
626
+
627
+ TModel.prototype.getTargetEasing = function(key) {
628
+ return typeof this.targets[key] === 'object' && this.targets[key].easing ? this.targets[key].easing : undefined;
629
+ };
630
+
631
+ TModel.prototype.getTargetStepInterval = function(key) {
632
+ return this.targetValues[key] ? this.targetValues[key].stepInterval : undefined;
633
+ };
634
+
635
+ TModel.prototype.getTargetEventFunctions = function(key) {
636
+ return this.targetValues[key] ? this.targetValues[key].events: undefined;
637
+ };
638
+
639
+ TModel.prototype.getCallingTargetKey = function(key) {
640
+ return this.targetValues[key] ? this.targetValues[key].callingTargetKey: undefined;
641
+ };
642
+
643
+ TModel.prototype.resetCallingTargetKey = function(key) {
644
+ if (this.targetValues[key]) {
645
+ this.targetValues[key].callingTargetKey = key;
646
+ }
647
+ };
648
+
649
+ TModel.prototype.setTargetValue = function(key, value, steps, stepInterval, cycles, callingTargetKey) {
650
+ if (!TUtil.isDefined(this.targetValues[key]) || value !== this.targetValues[key].value || value !== this.actualValues[key] || steps || cycles || stepInterval || typeof this.targets[key] === 'object') {
651
+
652
+ steps = steps || 0;
653
+ cycles = cycles || 0;
654
+ stepInterval = stepInterval || 0;
655
+
656
+ if (this.targetValues[key]) {
657
+ if (key !== callingTargetKey && (this.targetValues[key].callingTargetKey !== callingTargetKey || value !== this.targetValues[key].value)) {
658
+ this.targetValues[key].step = 0;
659
+ }
660
+ this.targetValues[key].value = value;
661
+ this.targetValues[key].steps = steps;
662
+ this.targetValues[key].cycles = cycles;
663
+ this.targetValues[key].stepInterval = stepInterval;
664
+ this.targetValues[key].callingTargetKey = callingTargetKey;
665
+ } else {
666
+ this.targetValues[key] = Object.assign(TargetUtil.emptyValue(), {
667
+ value: value,
668
+ steps: steps,
669
+ cycles: cycles,
670
+ stepInterval: stepInterval,
671
+ callingTargetKey: callingTargetKey
672
+ });
673
+ TargetUtil.extractInvisibles(this, this.targets[key], key);
674
+ }
675
+
676
+ //take a shortcut and update the actualValues immediately without the need for TargetManager
677
+ if (steps === 0 && cycles === 0) {
678
+ var oldValue = this.actualValues[key];
679
+ this.actualValues[key] = typeof value === 'function' ? value.call(this) : value;
680
+ this.setActualValueLastUpdate(key);
681
+ TargetUtil.handleValueChange(this, key, this.actualValues[key], oldValue, 0, 0);
682
+ }
683
+
684
+ this.updateTargetStatus(key);
685
+
686
+ if (this.isTargetUpdating(key) && key !== callingTargetKey) {
687
+ this.activeTargetKeyMap[key] = true;
688
+ if (!this.targetUpdatingMap[key]) {
689
+ this.targetUpdatingList.push(key);
690
+ this.targetUpdatingMap[key] = key;
691
+ }
692
+ this.resetLastActualValue(key);
693
+ }
694
+
695
+ tapp.manager.scheduleRun(10, 'setTargetValue-' + (this.getParent() ? this.getParent().oid : "") + "-" + this.oid + "-" + key);
696
+ }
697
+ };
698
+
699
+ TModel.prototype.setValue = function(key, value) {
700
+ this.actualValues[key] = value;
701
+ };
702
+
703
+ TModel.prototype.addChild = function(child, index) {
704
+ var addedChildren = this.actualValues.addedChildren;
705
+
706
+ index = !child.canBeBracketed() ? 0 : TUtil.isDefined(index) ? index : addedChildren.length;
707
+ child.parent = this;
708
+
709
+ if (index >= addedChildren.length) {
710
+ addedChildren.push(child);
711
+ } else {
712
+ addedChildren.splice(index, 0, child);
713
+ }
714
+
715
+ this.setActualValueLastUpdate('children');
716
+ this.targetValues['addedChildren'] ? this.setActualValueLastUpdate('addedChildren') : this.setTargetValue('addedChildren', addedChildren);
717
+
718
+ tapp.manager.scheduleRun(10, 'addChild-' + this.oid + "-" + child.oid);
719
+
720
+ return index;
721
+ };
722
+
723
+ TModel.prototype.addUpdatingChild = function(child) {
724
+ if (this.updatingChildren.indexOf(child) === -1) {
725
+ this.updatingChildren.push(child);
726
+ }
727
+ };
728
+
729
+ TModel.prototype.removeUpdatingChild = function(child) {
730
+ var index = this.updatingChildren.indexOf(child);
731
+ if (index >= 0) {
732
+ this.updatingChildren.splice(index, 1);
733
+ }
734
+ };
735
+
736
+ TModel.prototype.addTarget = function(targetName, target) {
737
+ this.targets[targetName] = target;
738
+ this.activeTargetKeyMap[targetName] = true;
739
+ delete this.targetValues[targetName];
740
+
741
+ tapp.manager.scheduleRun(10, 'addTarget-' + this.oid + "-" + targetName);
742
+ };
743
+
744
+ TModel.prototype.deleteTargetValues = function(key) {
745
+ delete this.targetValues[key];
746
+ this.activeTargetKeyMap[key] = true;
747
+
748
+ tapp.manager.scheduleRun(10, 'deleteTargetValues-' + this.oid + "-" + key);
749
+ };
750
+
751
+ TModel.prototype.getTargetHeight = function() {
752
+ return this.getTargetValue('height') || 1;
753
+ };
754
+
755
+ TModel.prototype.getTargetWidth = function() {
756
+ return this.getTargetValue('width') || 1;
757
+ };
758
+
759
+ TModel.prototype.getTargetScale = function() {
760
+ return this.getTargetValue('scale') || 1;
761
+ };