targetj 1.0.51 → 1.0.53
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/Exports.js +1 -0
- package/package.json +1 -1
- package/src/Bracket.js +6 -7
- package/src/LocationManager.js +13 -19
- package/src/TModel.js +80 -65
- package/src/TModelManager.js +9 -0
- package/src/TUtil.js +3 -5
- package/src/TargetManager.js +61 -132
- package/src/TargetUtil.js +32 -32
package/Exports.js
CHANGED
package/package.json
CHANGED
package/src/Bracket.js
CHANGED
|
@@ -5,15 +5,14 @@ import { browser } from "./Browser.js";
|
|
|
5
5
|
|
|
6
6
|
function Bracket(parent) {
|
|
7
7
|
|
|
8
|
-
var tm = new TModel("BI"
|
|
9
|
-
tm.parent = parent;
|
|
10
|
-
tm.newFlag = true;
|
|
11
|
-
|
|
12
|
-
tm.targets = {
|
|
8
|
+
var tm = new TModel("BI", {
|
|
13
9
|
canHaveDom: false,
|
|
14
|
-
outerXEast: 0
|
|
15
|
-
};
|
|
10
|
+
outerXEast: 0
|
|
11
|
+
});
|
|
16
12
|
|
|
13
|
+
tm.parent = parent;
|
|
14
|
+
tm.newFlag = true;
|
|
15
|
+
|
|
17
16
|
tm.getWidth = function() {
|
|
18
17
|
return this.getContentWidth();
|
|
19
18
|
};
|
package/src/LocationManager.js
CHANGED
|
@@ -18,18 +18,7 @@ LocationManager.prototype.calculateAll = function() {
|
|
|
18
18
|
this.locationCount.length = 0;
|
|
19
19
|
this.startTime = browser.now();
|
|
20
20
|
|
|
21
|
-
this.calculate();
|
|
22
|
-
|
|
23
|
-
if (tapp.targetManager.doneTargets.length > 0) {
|
|
24
|
-
tapp.targetManager.doneTargets.forEach(function(target) {
|
|
25
|
-
//imperative call is possible till this gets executed so we need to make sure that it is still done
|
|
26
|
-
if (target.tmodel.isTargetDone(target.key)) {
|
|
27
|
-
target.tmodel.setTargetComplete(target.key);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
tapp.manager.scheduleRun(10, "done to complete");
|
|
32
|
-
}
|
|
21
|
+
this.calculate();
|
|
33
22
|
};
|
|
34
23
|
|
|
35
24
|
LocationManager.prototype.calculate = function() {
|
|
@@ -90,7 +79,7 @@ LocationManager.prototype.calculateContainer = function(container) {
|
|
|
90
79
|
|
|
91
80
|
if (!child.targetUpdatingMap.x) {
|
|
92
81
|
if (TUtil.isDefined(child.targets.x)) {
|
|
93
|
-
tapp.targetManager.setTargetValue(child, 'x');
|
|
82
|
+
//tapp.targetManager.setTargetValue(child, 'x');
|
|
94
83
|
} else if (!TUtil.isDefined(child.targetValues.x)) {
|
|
95
84
|
child.setValue('x', child.x);
|
|
96
85
|
}
|
|
@@ -98,7 +87,7 @@ LocationManager.prototype.calculateContainer = function(container) {
|
|
|
98
87
|
|
|
99
88
|
if (!child.targetUpdatingMap.y) {
|
|
100
89
|
if (TUtil.isDefined(child.targets.y)) {
|
|
101
|
-
tapp.targetManager.setTargetValue(child, 'y');
|
|
90
|
+
//tapp.targetManager.setTargetValue(child, 'y');
|
|
102
91
|
} else if (!TUtil.isDefined(child.targetValues.y)) {
|
|
103
92
|
child.setValue('y', child.y);
|
|
104
93
|
}
|
|
@@ -120,9 +109,14 @@ LocationManager.prototype.calculateContainer = function(container) {
|
|
|
120
109
|
var childLastHeight = child.getHeight();
|
|
121
110
|
|
|
122
111
|
if (child.hasChildren()) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
112
|
+
if (child.isTargetEnabled('width')) {
|
|
113
|
+
TargetUtil.assignValueArray(child, 'width');
|
|
114
|
+
tapp.targetManager.setJustActualValue(child, 'width');
|
|
115
|
+
}
|
|
116
|
+
if (child.isTargetEnabled('height')) {
|
|
117
|
+
TargetUtil.assignValueArray(child, 'height');
|
|
118
|
+
tapp.targetManager.setJustActualValue(child, 'height');
|
|
119
|
+
}
|
|
126
120
|
}
|
|
127
121
|
|
|
128
122
|
if (child.getHeight() !== childLastHeight && tapp.events.isScrollTopHandler(child.getParent())
|
|
@@ -143,8 +137,8 @@ LocationManager.prototype.calculateContainer = function(container) {
|
|
|
143
137
|
viewport.calcContentWidthHeight();
|
|
144
138
|
};
|
|
145
139
|
|
|
146
|
-
LocationManager.prototype.calculateTargets = function(tmodel) {
|
|
147
|
-
tapp.targetManager.setTargetValues(tmodel);
|
|
140
|
+
LocationManager.prototype.calculateTargets = function(tmodel) {
|
|
141
|
+
tapp.targetManager.setTargetValues(tmodel, Object.keys(tmodel.activeTargetKeyMap));
|
|
148
142
|
tapp.targetManager.setActualValues(tmodel);
|
|
149
143
|
|
|
150
144
|
if (!TUtil.isDefined(tmodel.targetValues.width) && tmodel.hasDom()) TargetUtil.setWidthFromDom(tmodel);
|
package/src/TModel.js
CHANGED
|
@@ -11,9 +11,15 @@ function TModel(type, targets) {
|
|
|
11
11
|
targets = type;
|
|
12
12
|
type = "";
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
var self = this;
|
|
15
16
|
this.type = type ? type : 'blank';
|
|
16
|
-
this.targets = Object.assign({}, targets);
|
|
17
|
+
this.targets = Object.assign({}, targets);
|
|
18
|
+
this.activeTargetKeyMap = {};
|
|
19
|
+
Object.keys(this.targets).forEach(function(key) {
|
|
20
|
+
self.activeTargetKeyMap[key] = true;
|
|
21
|
+
});
|
|
22
|
+
|
|
17
23
|
var uniqueId = App.getOid(this.type);
|
|
18
24
|
this.oid = uniqueId.oid;
|
|
19
25
|
this.oidNum = uniqueId.num;
|
|
@@ -54,9 +60,7 @@ function TModel(type, targets) {
|
|
|
54
60
|
calculateChildren: undefined,
|
|
55
61
|
isVisible: undefined
|
|
56
62
|
};
|
|
57
|
-
|
|
58
|
-
this.activeTargetKeyMap = {};
|
|
59
|
-
|
|
63
|
+
|
|
60
64
|
this.targetUpdatingMap = {};
|
|
61
65
|
this.targetUpdatingList = [];
|
|
62
66
|
|
|
@@ -489,9 +493,9 @@ TModel.prototype.resetTargetCycle = function(key) {
|
|
|
489
493
|
}
|
|
490
494
|
};
|
|
491
495
|
|
|
492
|
-
TModel.prototype.
|
|
496
|
+
TModel.prototype.resetScheduleTimeStamp = function(key) {
|
|
493
497
|
if (this.targetValues[key]) {
|
|
494
|
-
this.targetValues[key].
|
|
498
|
+
this.targetValues[key].scheduleTimeStamp = undefined;
|
|
495
499
|
}
|
|
496
500
|
};
|
|
497
501
|
|
|
@@ -523,17 +527,25 @@ TModel.prototype.updateTargetStatus = function(key) {
|
|
|
523
527
|
|
|
524
528
|
this.targetValues[key].status = '';
|
|
525
529
|
|
|
526
|
-
if (
|
|
530
|
+
if (step < steps || cycle < cycles || !this.doesTargetEqualActual(key)) {
|
|
527
531
|
this.targetValues[key].status = 'updating';
|
|
528
|
-
} else if (this.
|
|
532
|
+
} else if (!this.hasTargetGotExecuted(key) || this.isTargetInLoop(key)) {
|
|
533
|
+
this.targetValues[key].status = 'active';
|
|
534
|
+
} else {
|
|
529
535
|
this.targetValues[key].status = 'done';
|
|
530
536
|
}
|
|
537
|
+
|
|
538
|
+
return this.targetValues[key].status;
|
|
531
539
|
};
|
|
532
540
|
|
|
533
|
-
TModel.prototype.getTargetStatus = function(key) {
|
|
541
|
+
TModel.prototype.getTargetStatus = function(key) {
|
|
534
542
|
return this.targetValues[key] ? this.targetValues[key].status : 0;
|
|
535
543
|
};
|
|
536
544
|
|
|
545
|
+
TModel.prototype.isTargetActive = function(key) {
|
|
546
|
+
return this.targetValues[key] && this.targetValues[key].status === 'active';
|
|
547
|
+
};
|
|
548
|
+
|
|
537
549
|
TModel.prototype.isTargetUpdating = function(key) {
|
|
538
550
|
return this.targetValues[key] && this.targetValues[key].status === 'updating';
|
|
539
551
|
};
|
|
@@ -547,7 +559,15 @@ TModel.prototype.isTargetComplete = function(key) {
|
|
|
547
559
|
};
|
|
548
560
|
|
|
549
561
|
TModel.prototype.hasTargetGotExecuted = function(key) {
|
|
550
|
-
return this.targets[key] ? this.targetValues[key] && this.targetValues[key].
|
|
562
|
+
return this.targets[key] ? this.targetValues[key] && this.targetValues[key].executionCount > 0 : true;
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
TModel.prototype.isTargetImperative = function(key) {
|
|
566
|
+
return this.targetValues[key] ? this.targetValues[key] && this.targetValues[key].callingTargetKey !== key : false;
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
TModel.prototype.getTargetExecutionCount = function(key) {
|
|
570
|
+
return this.targetValues[key] ? this.targetValues[key].executionCount : 0;
|
|
551
571
|
};
|
|
552
572
|
|
|
553
573
|
TModel.prototype.setTargetComplete = function(key) {
|
|
@@ -559,11 +579,9 @@ TModel.prototype.setTargetComplete = function(key) {
|
|
|
559
579
|
TModel.prototype.isTargetEnabled = function(key) {
|
|
560
580
|
var target = this.targets[key];
|
|
561
581
|
|
|
562
|
-
if (!TUtil.isDefined(target)
|
|
582
|
+
if (!TUtil.isDefined(target)) return false;
|
|
563
583
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
return !!targetEnabled;
|
|
584
|
+
return typeof target.enabledOn === 'function' ? target.enabledOn.call(this, key) : target.enabledOn === false ? false : true;
|
|
567
585
|
};
|
|
568
586
|
|
|
569
587
|
TModel.prototype.isTargetInLoop = function(key) {
|
|
@@ -571,11 +589,16 @@ TModel.prototype.isTargetInLoop = function(key) {
|
|
|
571
589
|
};
|
|
572
590
|
|
|
573
591
|
TModel.prototype.doesTargetEqualActual = function(key) {
|
|
574
|
-
|
|
592
|
+
if (this.targetValues[key]) {
|
|
593
|
+
var deepEquality = this.targets[key] ? this.targets[key].deepEquality : false;
|
|
594
|
+
return deepEquality ? TUtil.areEqual(this.getTargetValue(key), this.getValue(key), deepEquality) : this.getTargetValue(key) === this.getValue(key);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
return false;
|
|
575
598
|
};
|
|
576
599
|
|
|
577
600
|
TModel.prototype.getTargetValue = function(key) {
|
|
578
|
-
return this.targetValues[key] ? (typeof this.targetValues[key].value === 'function' ? this.targetValues[key].value.call(this) :
|
|
601
|
+
return this.targetValues[key] ? (typeof this.targetValues[key].value === 'function' ? this.targetValues[key].value.call(this) : this.targetValues[key].value) : undefined;
|
|
579
602
|
};
|
|
580
603
|
|
|
581
604
|
TModel.prototype.getTargetSteps = function(key) {
|
|
@@ -586,8 +609,8 @@ TModel.prototype.getTargetStep = function(key) {
|
|
|
586
609
|
return this.targetValues[key] ? this.targetValues[key].step : 0;
|
|
587
610
|
};
|
|
588
611
|
|
|
589
|
-
TModel.prototype.
|
|
590
|
-
return this.targetValues[key] ? this.targetValues[key].
|
|
612
|
+
TModel.prototype.getScheduleTimeStamp = function(key) {
|
|
613
|
+
return this.targetValues[key] ? this.targetValues[key].scheduleTimeStamp : undefined;
|
|
591
614
|
};
|
|
592
615
|
|
|
593
616
|
TModel.prototype.getLastActualValue = function(key) {
|
|
@@ -619,9 +642,9 @@ TModel.prototype.setTargetCycle = function(key, value) {
|
|
|
619
642
|
}
|
|
620
643
|
};
|
|
621
644
|
|
|
622
|
-
TModel.prototype.
|
|
645
|
+
TModel.prototype.setScheduleTimeStamp = function(key, value) {
|
|
623
646
|
if (this.targetValues[key]) {
|
|
624
|
-
this.targetValues[key].
|
|
647
|
+
this.targetValues[key].scheduleTimeStamp = value;
|
|
625
648
|
}
|
|
626
649
|
};
|
|
627
650
|
|
|
@@ -660,53 +683,45 @@ TModel.prototype.resetCallingTargetKey = function(key) {
|
|
|
660
683
|
};
|
|
661
684
|
|
|
662
685
|
TModel.prototype.setTargetValue = function(key, value, steps, stepInterval, cycles, callingTargetKey) {
|
|
663
|
-
if (!TUtil.isDefined(this.targetValues[key]) || value !== this.targetValues[key].value || value !== this.actualValues[key] || steps || cycles || stepInterval || typeof this.targets[key] === 'object') {
|
|
664
686
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
this.targetValues[key].value = value;
|
|
674
|
-
this.targetValues[key].steps = steps;
|
|
675
|
-
this.targetValues[key].cycles = cycles;
|
|
676
|
-
this.targetValues[key].stepInterval = stepInterval;
|
|
677
|
-
this.targetValues[key].callingTargetKey = callingTargetKey;
|
|
678
|
-
} else {
|
|
679
|
-
this.targetValues[key] = Object.assign(TargetUtil.emptyValue(), {
|
|
680
|
-
value: value,
|
|
681
|
-
steps: steps,
|
|
682
|
-
cycles: cycles,
|
|
683
|
-
stepInterval: stepInterval,
|
|
684
|
-
callingTargetKey: callingTargetKey
|
|
685
|
-
});
|
|
686
|
-
TargetUtil.extractInvisibles(this, this.targets[key], key);
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
//take a shortcut and update the actualValues immediately without the need for TargetManager
|
|
690
|
-
if (steps === 0 && cycles === 0) {
|
|
691
|
-
var oldValue = this.actualValues[key];
|
|
692
|
-
this.actualValues[key] = typeof value === 'function' ? value.call(this) : value;
|
|
693
|
-
this.setActualValueLastUpdate(key);
|
|
694
|
-
TargetUtil.handleValueChange(this, key, this.actualValues[key], oldValue, 0, 0);
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
this.updateTargetStatus(key);
|
|
698
|
-
|
|
699
|
-
if (this.isTargetUpdating(key) && key !== callingTargetKey) {
|
|
700
|
-
this.activeTargetKeyMap[key] = true;
|
|
701
|
-
if (!this.targetUpdatingMap[key]) {
|
|
702
|
-
this.targetUpdatingList.push(key);
|
|
703
|
-
this.targetUpdatingMap[key] = key;
|
|
704
|
-
}
|
|
687
|
+
steps = steps || 0;
|
|
688
|
+
cycles = cycles || 0;
|
|
689
|
+
stepInterval = stepInterval || 0;
|
|
690
|
+
|
|
691
|
+
if (this.targetValues[key]) {
|
|
692
|
+
if (key !== callingTargetKey && (this.targetValues[key].callingTargetKey !== callingTargetKey || value !== this.targetValues[key].value)) {
|
|
693
|
+
this.resetTargetStep(key);
|
|
705
694
|
this.resetLastActualValue(key);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
this.targetValues[key].value = value;
|
|
698
|
+
this.targetValues[key].steps = steps;
|
|
699
|
+
this.targetValues[key].cycles = cycles;
|
|
700
|
+
this.targetValues[key].stepInterval = stepInterval;
|
|
701
|
+
this.targetValues[key].callingTargetKey = callingTargetKey;
|
|
702
|
+
} else {
|
|
703
|
+
this.targetValues[key] = Object.assign(TargetUtil.emptyValue(), {
|
|
704
|
+
value: value,
|
|
705
|
+
steps: steps,
|
|
706
|
+
cycles: cycles,
|
|
707
|
+
stepInterval: stepInterval,
|
|
708
|
+
callingTargetKey: callingTargetKey
|
|
709
|
+
});
|
|
710
|
+
TargetUtil.extractInvisibles(this, this.targets[key], key);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
//take a shortcut and update the actualValues immediately without the need for TargetManager
|
|
714
|
+
if (steps === 0 && cycles === 0) {
|
|
715
|
+
var oldValue = this.actualValues[key];
|
|
716
|
+
this.actualValues[key] = typeof value === 'function' ? value.call(this) : value;
|
|
717
|
+
this.setActualValueLastUpdate(key);
|
|
718
|
+
TargetUtil.handleValueChange(this, key, this.actualValues[key], oldValue, 0, 0);
|
|
709
719
|
}
|
|
720
|
+
|
|
721
|
+
this.activeTargetKeyMap[key] = true;
|
|
722
|
+
this.targetValues[key].executionCount++;
|
|
723
|
+
|
|
724
|
+
this.updateTargetStatus(key);
|
|
710
725
|
};
|
|
711
726
|
|
|
712
727
|
TModel.prototype.setValue = function(key, value) {
|
package/src/TModelManager.js
CHANGED
|
@@ -321,6 +321,15 @@ TModelManager.prototype.run = function(oid, delay) {
|
|
|
321
321
|
tapp.locationManager.calculateTargets(tapp.ui);
|
|
322
322
|
|
|
323
323
|
tapp.locationManager.calculateAll();
|
|
324
|
+
|
|
325
|
+
if (tapp.targetManager.doneTargets.length > 0) {
|
|
326
|
+
tapp.targetManager.doneTargets.forEach(function(target) {
|
|
327
|
+
//imperative call is possible till this gets executed so we need to make sure that it is still done
|
|
328
|
+
if (target.tmodel.isTargetDone(target.key)) {
|
|
329
|
+
target.tmodel.setTargetComplete(target.key);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
324
333
|
|
|
325
334
|
tapp.events.resetEvents();
|
|
326
335
|
|
package/src/TUtil.js
CHANGED
|
@@ -57,11 +57,9 @@ TUtil.areEqual = function(a, b, deepEquality) {
|
|
|
57
57
|
|
|
58
58
|
if (deepEquality) {
|
|
59
59
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
60
|
-
} else if (TUtil.isDefined(a) && TUtil.isDefined(b)) {
|
|
61
|
-
return a === b;
|
|
62
60
|
} else {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
61
|
+
return a === b;
|
|
62
|
+
}
|
|
65
63
|
};
|
|
66
64
|
|
|
67
65
|
TUtil.momentum = function (past, current, time) {
|
|
@@ -103,7 +101,7 @@ TUtil.getOptionValue = function(option, defaultValue, tmodel) {
|
|
|
103
101
|
return !TUtil.isDefined(option) ? defaultValue : typeof option === 'function' ? option.call(tmodel) : option;
|
|
104
102
|
};
|
|
105
103
|
|
|
106
|
-
TUtil.executeFunctionByName = function (functionName, context
|
|
104
|
+
TUtil.executeFunctionByName = function (functionName, context) {
|
|
107
105
|
if (!functionName)
|
|
108
106
|
return null;
|
|
109
107
|
|
package/src/TargetManager.js
CHANGED
|
@@ -7,54 +7,42 @@ function TargetManager() {
|
|
|
7
7
|
this.doneTargets = [];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
TargetManager.prototype.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.setTargetValue(tmodel, key, force);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
10
|
+
TargetManager.prototype.setTargetValues = function(tmodel, activeKeys) {
|
|
11
|
+
tmodel.targetUpdatingMap = {};
|
|
12
|
+
tmodel.targetUpdatingList = [];
|
|
13
|
+
tmodel.targetMethodMap = {};
|
|
18
14
|
|
|
19
|
-
TargetManager.prototype.setTargetValues = function(tmodel) {
|
|
20
|
-
|
|
21
|
-
var activeKeys = Object.keys(tmodel.activeTargetKeyMap);
|
|
22
|
-
|
|
23
|
-
if (tmodel.targets !== tmodel.actualValues.targets) {
|
|
24
|
-
tmodel.actualValues.targets = tmodel.targets;
|
|
25
|
-
Object.keys(tmodel.targets).forEach(function(key) {
|
|
26
|
-
if (activeKeys.indexOf(key) === -1) {
|
|
27
|
-
activeKeys.push(key);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
tmodel.targetUpdatingMap = {};
|
|
33
|
-
tmodel.targetUpdatingList = [];
|
|
34
|
-
tmodel.targetMethodMap = {};
|
|
35
|
-
|
|
36
15
|
for (var i = 0; i < activeKeys.length; i++) {
|
|
37
|
-
|
|
38
16
|
var key = activeKeys[i];
|
|
39
|
-
|
|
17
|
+
|
|
40
18
|
if (tmodel.targetUpdatingMap[key]) {
|
|
41
19
|
continue;
|
|
42
|
-
}
|
|
20
|
+
}
|
|
43
21
|
|
|
44
|
-
if (tmodel.
|
|
45
|
-
tmodel.
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
if (tmodel.isTargetImperative(key)) {
|
|
23
|
+
tmodel.setTargetMethodName(key, 'value');
|
|
24
|
+
|
|
25
|
+
if (tmodel.isTargetUpdating(key)) {
|
|
26
|
+
tmodel.targetUpdatingMap[key] = true;
|
|
27
|
+
tmodel.targetUpdatingList.push(key);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
48
30
|
}
|
|
49
31
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (result) {
|
|
53
|
-
tmodel.targetUpdatingMap[key] = true;
|
|
54
|
-
tmodel.targetUpdatingList.push(key);
|
|
55
|
-
} else if (tmodel.isTargetDone(key)) {
|
|
32
|
+
if (tmodel.isTargetDone(key)) {
|
|
56
33
|
this.doneTargets.push({ tmodel: tmodel, key: key });
|
|
34
|
+
} else if (tmodel.isTargetComplete(key)) {
|
|
35
|
+
delete tmodel.activeTargetKeyMap[key];
|
|
36
|
+
} else {
|
|
37
|
+
this.setTargetValue(tmodel, key);
|
|
38
|
+
tmodel.updateTargetStatus(key);
|
|
39
|
+
|
|
40
|
+
if (tmodel.isTargetUpdating(key)) {
|
|
41
|
+
tmodel.targetUpdatingMap[key] = true;
|
|
42
|
+
tmodel.targetUpdatingList.push(key);
|
|
43
|
+
}
|
|
57
44
|
}
|
|
45
|
+
|
|
58
46
|
}
|
|
59
47
|
|
|
60
48
|
if (tmodel.getParent() && tmodel.targetUpdatingList.length === 0) {
|
|
@@ -62,7 +50,7 @@ TargetManager.prototype.setTargetValues = function(tmodel) {
|
|
|
62
50
|
}
|
|
63
51
|
};
|
|
64
52
|
|
|
65
|
-
TargetManager.prototype.setTargetValue = function(tmodel, key
|
|
53
|
+
TargetManager.prototype.setTargetValue = function(tmodel, key) {
|
|
66
54
|
var target = tmodel.targets[key];
|
|
67
55
|
|
|
68
56
|
if (!TUtil.isDefined(target)) {
|
|
@@ -70,76 +58,38 @@ TargetManager.prototype.setTargetValue = function(tmodel, key, force) {
|
|
|
70
58
|
return;
|
|
71
59
|
}
|
|
72
60
|
|
|
73
|
-
if (tmodel.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var valueOnly = target ? !!target.valueOnly : false;
|
|
78
|
-
|
|
79
|
-
if (!TUtil.isDefined(tmodel.getActualTimeStamp(key))) {
|
|
80
|
-
var cycle = tmodel.getTargetCycle(key);
|
|
81
|
-
var valueArray = TargetUtil.getValueStepsCycles(tmodel, target, cycle, valueOnly, key);
|
|
82
|
-
TargetUtil.assignValueArray(tmodel, key, valueArray);
|
|
83
|
-
|
|
84
|
-
if (!force) {
|
|
85
|
-
tmodel.setTargetMethodName(key, 'value');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (tmodel.isTargetInLoop(key)
|
|
90
|
-
|| (!tmodel.isTargetDone(key) && !tmodel.isTargetComplete(key))
|
|
91
|
-
|| TUtil.isDefined(tmodel.getActualTimeStamp(key))
|
|
92
|
-
|| !tmodel.hasTargetGotExecuted(key)) {
|
|
93
|
-
tmodel.activeTargetKeyMap[key] = true;
|
|
94
|
-
} else if (tmodel.activeTargetKeyMap[key]) {
|
|
95
|
-
delete tmodel.activeTargetKeyMap[key];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (TUtil.isDefined(tmodel.getActualTimeStamp(key))) {
|
|
99
|
-
var schedulePeriod = TargetUtil.getActualSchedulePeriod(tmodel, key, tmodel.getTargetStepInterval(key));
|
|
100
|
-
if (schedulePeriod > 0) {
|
|
101
|
-
tapp.manager.scheduleRun(schedulePeriod, "actualInterval__" + tmodel.oid + "__" + key);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return (!tmodel.isTargetDone(key) && !tmodel.isTargetComplete(key)) || !tmodel.doesTargetEqualActual(key);
|
|
106
|
-
} else {
|
|
107
|
-
tmodel.setTargetMethodName(key, 'enabledOn');
|
|
108
|
-
tmodel.activeTargetKeyMap[key] = true;
|
|
61
|
+
if (tmodel.isTargetEnabled(key)) {
|
|
62
|
+
if (tmodel.getScheduleTimeStamp(key) && tmodel.isTargetActive(key) && tmodel.getTargetStepInterval(key) > 0
|
|
63
|
+
&& tmodel.getScheduleTimeStamp(key) + tmodel.getTargetStepInterval(key) <= TargetJ.browser.now()) {
|
|
64
|
+
tmodel.resetScheduleTimeStamp(key);
|
|
109
65
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
TargetManager.prototype.setActualValues = function(tmodel) {
|
|
117
|
-
var i;
|
|
118
|
-
var target;
|
|
119
|
-
var key, keys = [];
|
|
120
|
-
|
|
121
|
-
for (i = 0; i < tmodel.targetUpdatingList.length; i++) {
|
|
122
|
-
key = tmodel.targetUpdatingList[i];
|
|
123
|
-
|
|
124
|
-
target = tmodel.targets[key];
|
|
125
|
-
var status = tmodel.getTargetStatus(key);
|
|
126
|
-
|
|
127
|
-
if (tmodel.isTargetUpdating(key)) {
|
|
128
|
-
keys.push(key);
|
|
66
|
+
|
|
67
|
+
if (!TUtil.isDefined(tmodel.getScheduleTimeStamp(key))) {
|
|
68
|
+
TargetUtil.assignValueArray(tmodel, key);
|
|
69
|
+
tmodel.setTargetMethodName(key, 'value');
|
|
129
70
|
}
|
|
130
71
|
|
|
131
|
-
|
|
132
|
-
|
|
72
|
+
var schedulePeriod = TargetUtil.scheduleExecution(tmodel, key);
|
|
73
|
+
if (schedulePeriod > 0) {
|
|
74
|
+
tapp.manager.scheduleRun(schedulePeriod, "actualInterval__" + tmodel.oid + "__" + key);
|
|
133
75
|
}
|
|
76
|
+
} else {
|
|
77
|
+
tmodel.setTargetMethodName(key, 'enabledOn');
|
|
134
78
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
TargetManager.prototype.setActualValues = function(tmodel, keyList) {
|
|
82
|
+
var i, key;
|
|
83
|
+
keyList = !keyList ? tmodel.targetUpdatingList : keyList;
|
|
84
|
+
var length = keyList.length;
|
|
85
|
+
|
|
86
|
+
for (i = 0; i < length; i++) {
|
|
87
|
+
key = keyList[i];
|
|
138
88
|
|
|
139
|
-
var schedulePeriod = TargetUtil.
|
|
140
|
-
if (schedulePeriod === 0
|
|
89
|
+
var schedulePeriod = TargetUtil.scheduleExecution(tmodel, key);
|
|
90
|
+
if (schedulePeriod === 0) {
|
|
141
91
|
this.setActualValue(tmodel, key);
|
|
142
|
-
} else {
|
|
92
|
+
} else {
|
|
143
93
|
tapp.manager.scheduleRun(schedulePeriod, "actualInterval__" + tmodel.oid + "__" + key);
|
|
144
94
|
}
|
|
145
95
|
}
|
|
@@ -148,9 +98,7 @@ TargetManager.prototype.setActualValues = function(tmodel) {
|
|
|
148
98
|
|
|
149
99
|
TargetManager.prototype.setJustActualValue = function(tmodel, key) {
|
|
150
100
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if (!tmodel.targetValues[key] || (target && typeof target.enabledOn === 'function' && !target.enabledOn.call(tmodel, key))) {
|
|
101
|
+
if (!tmodel.targetUpdatingList[key]) {
|
|
154
102
|
return false;
|
|
155
103
|
}
|
|
156
104
|
|
|
@@ -181,30 +129,18 @@ TargetManager.prototype.setActualValue = function(tmodel, key) {
|
|
|
181
129
|
var easing = TUtil.isDefined(tmodel.getTargetEasing(key)) ? tmodel.getTargetEasing(key) : EasingEffects.linear;
|
|
182
130
|
var cycle = tmodel.getTargetCycle(key);
|
|
183
131
|
var easingStep = easing(tmodel.getTargetStepPercent(key, step));
|
|
184
|
-
var
|
|
185
|
-
var stepInterval = tmodel.getTargetStepInterval(key);
|
|
186
|
-
var lastUpdate = tmodel.getActualValueLastUpdate(key);
|
|
132
|
+
var stepInterval = tmodel.getTargetStepInterval(key) || 0;
|
|
187
133
|
var oldValue = tmodel.actualValues[key], oldStep = step, oldCycle = cycle;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
tmodel.setTargetMethodName(key, 'value');
|
|
191
|
-
|
|
134
|
+
|
|
192
135
|
if (step < steps) {
|
|
193
136
|
if (!TUtil.isDefined(tmodel.getLastActualValue(key))) {
|
|
194
137
|
tmodel.setLastActualValue(key, tmodel.actualValues[key]);
|
|
195
138
|
}
|
|
196
139
|
tmodel.actualValues[key] = typeof targetValue === 'number' ? targetValue * easingStep + tmodel.getLastActualValue(key) * (1 - easingStep) : targetValue;
|
|
197
140
|
|
|
198
|
-
tmodel.setActualValueLastUpdate(key);
|
|
199
141
|
tmodel.setActualValueLastUpdate(key);
|
|
200
142
|
|
|
201
|
-
|
|
202
|
-
if (!TUtil.isDefined(stepInterval) && false) {
|
|
203
|
-
var expectedStepInterval = 10;
|
|
204
|
-
stepIncrease = step > 0 && lastUpdate && tapp.throttle === 0 && expectedStepInterval > 0 ? Math.max(1, Math.floor((now - lastUpdate) / expectedStepInterval)) : 1;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
step = tmodel.setTargetStep(key, step + stepIncrease);
|
|
143
|
+
step = tmodel.setTargetStep(key, step + 1);
|
|
208
144
|
}
|
|
209
145
|
|
|
210
146
|
if (step >= steps) {
|
|
@@ -216,27 +152,20 @@ TargetManager.prototype.setActualValue = function(tmodel, key) {
|
|
|
216
152
|
tmodel.setTargetMethodName(key, 'onStepsEnd');
|
|
217
153
|
}
|
|
218
154
|
|
|
219
|
-
tmodel.updateTargetStatus(key);
|
|
220
|
-
|
|
221
155
|
if (tmodel.getTargetCycle(key) < tmodel.getTargetCycles(key)) {
|
|
222
156
|
tmodel.setTargetCycle(key, tmodel.getTargetCycle(key) + 1);
|
|
223
157
|
|
|
224
|
-
cycleUpdate = true;
|
|
225
158
|
tmodel.resetTargetStep(key);
|
|
226
159
|
tmodel.resetLastActualValue(key);
|
|
227
|
-
}
|
|
228
|
-
|
|
160
|
+
}
|
|
229
161
|
}
|
|
230
162
|
|
|
231
163
|
TargetUtil.handleValueChange(tmodel, key, tmodel.actualValues[key], oldValue, oldStep, oldCycle);
|
|
232
164
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (step < steps || cycleUpdate) {
|
|
238
|
-
tapp.manager.scheduleRun(step < steps ? stepInterval : 0, tmodel.oid + "---" + key + "-" + step + "/" + steps + "-" + cycle + "-" + stepInterval);
|
|
239
|
-
}
|
|
165
|
+
tmodel.resetScheduleTimeStamp(key);
|
|
166
|
+
tmodel.updateTargetStatus(key);
|
|
167
|
+
|
|
168
|
+
tapp.manager.scheduleRun(stepInterval, tmodel.oid + "---" + key + "-" + step + "/" + steps + "-" + cycle + "-" + stepInterval);
|
|
240
169
|
};
|
|
241
170
|
|
|
242
171
|
export { TargetManager };
|
package/src/TargetUtil.js
CHANGED
|
@@ -26,23 +26,28 @@ TargetUtil.emptyValue = function() {
|
|
|
26
26
|
cycles: 0,
|
|
27
27
|
stepInterval: 0,
|
|
28
28
|
lastActualValue: undefined,
|
|
29
|
-
|
|
29
|
+
scheduleTimeStamp: undefined,
|
|
30
30
|
actualValueLastUpdate: 0,
|
|
31
31
|
status: '',
|
|
32
|
-
|
|
32
|
+
executionCount: 0,
|
|
33
33
|
callingTargetKey: undefined
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
TargetUtil.getValueStepsCycles = function(tmodel,
|
|
37
|
+
TargetUtil.getValueStepsCycles = function(tmodel, key) {
|
|
38
|
+
var _target = tmodel.targets[key];
|
|
39
|
+
var valueOnly = _target && _target.valueOnly ? true : false;
|
|
40
|
+
var cycle = tmodel.getTargetCycle(key);
|
|
38
41
|
var value = 0, steps = 0, stepInterval = 0, cycles = 0;
|
|
39
42
|
var lastValue = tmodel.getValue(key);
|
|
40
43
|
|
|
41
44
|
function getValue(target) {
|
|
42
45
|
if (Array.isArray(target)) {
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
if (valueOnly) {
|
|
47
|
+
return [target, steps, stepInterval, cycles];
|
|
48
|
+
} else {
|
|
49
|
+
if (typeof target[0] === 'function') {
|
|
50
|
+
value = target[0].call(tmodel, key, cycle, lastValue);
|
|
46
51
|
} else {
|
|
47
52
|
value = target[0];
|
|
48
53
|
}
|
|
@@ -51,17 +56,15 @@ TargetUtil.getValueStepsCycles = function(tmodel, _target, cycle, valueOnly, key
|
|
|
51
56
|
cycles = target.length >= 4 ? target[3] : cycles;
|
|
52
57
|
|
|
53
58
|
return [value, steps, stepInterval, cycles];
|
|
54
|
-
} else {
|
|
55
|
-
return [target, steps, stepInterval, cycles];
|
|
56
59
|
}
|
|
57
60
|
|
|
58
|
-
} else if (typeof target === 'object' && target
|
|
61
|
+
} else if (typeof target === 'object' && target) {
|
|
59
62
|
value = typeof target.value === 'function' ? target.value.call(tmodel, key, cycle, lastValue) : TUtil.isDefined(target.value) ? target.value : target;
|
|
60
63
|
steps = typeof target.steps === 'function' ? target.steps.call(tmodel, key, cycle) : TUtil.isDefined(target.steps) ? target.steps : 0;
|
|
61
64
|
stepInterval = typeof target.stepInterval === 'function' ? target.stepInterval.call(tmodel, key, cycle, tmodel.getTargetStepInterval(key)) : TUtil.isDefined(target.stepInterval) ? target.stepInterval : 0;
|
|
62
65
|
cycles = typeof target.cycles === 'function' ? target.cycles.call(tmodel, key, cycle, tmodel.getTargetCycles(key)) : TUtil.isDefined(target.cycles) ? target.cycles : 0;
|
|
63
66
|
|
|
64
|
-
if (Array.isArray(value) && valueOnly === false
|
|
67
|
+
if (Array.isArray(value) && valueOnly === false) {
|
|
65
68
|
return getValue(value);
|
|
66
69
|
} else {
|
|
67
70
|
return [value, steps, stepInterval, cycles];
|
|
@@ -88,8 +91,9 @@ TargetUtil.getValueStepsCycles = function(tmodel, _target, cycle, valueOnly, key
|
|
|
88
91
|
return valueArray;
|
|
89
92
|
};
|
|
90
93
|
|
|
91
|
-
TargetUtil.assignValueArray = function(tmodel, key
|
|
92
|
-
|
|
94
|
+
TargetUtil.assignValueArray = function(tmodel, key) {
|
|
95
|
+
var valueArray = TargetUtil.getValueStepsCycles(tmodel, key);
|
|
96
|
+
|
|
93
97
|
if (Array.isArray(valueArray)) {
|
|
94
98
|
var newValue = valueArray[0];
|
|
95
99
|
var newSteps = valueArray[1];
|
|
@@ -97,23 +101,22 @@ TargetUtil.assignValueArray = function(tmodel, key, valueArray) {
|
|
|
97
101
|
var newCycles = valueArray[3];
|
|
98
102
|
var target = tmodel.targets[key];
|
|
99
103
|
|
|
100
|
-
var cycle = tmodel.getTargetCycle(key);
|
|
101
104
|
var targetValue = tmodel.targetValues[key];
|
|
102
105
|
var theValue = targetValue ? targetValue.value : undefined;
|
|
103
|
-
var newValueFlag = !TUtil.areEqual(theValue, newValue,
|
|
106
|
+
var newValueFlag = !TUtil.areEqual(theValue, newValue, tmodel.targets[key] ? !!tmodel.targets[key].deepEquality : false)
|
|
104
107
|
|| !TUtil.isDefined(targetValue)
|
|
105
108
|
|| (!tmodel.isTargetUpdating(key) && !tmodel.doesTargetEqualActual(key));
|
|
106
109
|
|
|
107
110
|
if (newValueFlag || targetValue.steps !== newSteps || targetValue.cycles !== newCycles || targetValue.stepInterval !== newStepInterval) {
|
|
108
111
|
|
|
109
112
|
tmodel.setTargetValue(key, newValue, newSteps, newStepInterval, newCycles, key);
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
|
|
112
114
|
if (newValueFlag) {
|
|
113
115
|
tmodel.resetTargetStep(key);
|
|
114
|
-
|
|
115
116
|
tmodel.resetLastActualValue(key);
|
|
116
117
|
}
|
|
118
|
+
} else {
|
|
119
|
+
tmodel.targetValues[key].executionCount++;
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
};
|
|
@@ -124,31 +127,27 @@ TargetUtil.getIntervalValue = function(tmodel, key, interval) {
|
|
|
124
127
|
return TUtil.isNumber(intervalValue) ? intervalValue : 0;
|
|
125
128
|
};
|
|
126
129
|
|
|
127
|
-
TargetUtil.
|
|
130
|
+
TargetUtil.scheduleExecution = function(tmodel, key) {
|
|
128
131
|
|
|
129
|
-
var now = browser.now();
|
|
130
|
-
var pastPeriod;
|
|
131
132
|
var schedulePeriod = 0;
|
|
133
|
+
var intervalValue = tmodel.getTargetStepInterval(key);
|
|
134
|
+
var now = browser.now();
|
|
132
135
|
|
|
133
136
|
if (intervalValue > 0) {
|
|
134
|
-
if (TUtil.isDefined(tmodel.
|
|
135
|
-
|
|
136
|
-
if (
|
|
137
|
-
schedulePeriod = intervalValue -
|
|
137
|
+
if (TUtil.isDefined(tmodel.getScheduleTimeStamp(key))) {
|
|
138
|
+
var period = now - tmodel.getScheduleTimeStamp(key);
|
|
139
|
+
if (period < intervalValue) {
|
|
140
|
+
schedulePeriod = intervalValue - period;
|
|
138
141
|
} else {
|
|
139
142
|
schedulePeriod = 0;
|
|
140
143
|
}
|
|
141
144
|
} else {
|
|
142
|
-
tmodel.setActualTimeStamp(key, now);
|
|
143
145
|
schedulePeriod = intervalValue;
|
|
144
146
|
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} else {
|
|
150
|
-
schedulePeriod = 0;
|
|
151
|
-
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (schedulePeriod > 0 && !TUtil.isDefined(tmodel.getScheduleTimeStamp(key))) {
|
|
150
|
+
tmodel.setScheduleTimeStamp(key, now);
|
|
152
151
|
}
|
|
153
152
|
|
|
154
153
|
return schedulePeriod;
|
|
@@ -187,6 +186,7 @@ TargetUtil.getTargetSchedulePeriod = function(tmodel, key, intervalValue) {
|
|
|
187
186
|
|
|
188
187
|
TargetUtil.handleValueChange = function(tmodel, key, newValue, lastValue, step, cycle) {
|
|
189
188
|
if (typeof tmodel.targets[key] === 'object' && typeof tmodel.targets[key].onValueChange === 'function') {
|
|
189
|
+
|
|
190
190
|
var valueChanged = !TUtil.areEqual(newValue, lastValue, tmodel.targets[key].deepEquality);
|
|
191
191
|
if (valueChanged) {
|
|
192
192
|
tmodel.targets[key].onValueChange.call(tmodel, key, newValue, lastValue, cycle);
|