Skip to content

Commit 6b482d4

Browse files
committed
Merged mode-specific defaults, with some refactoring
2 parents f96f78f + 9a72c96 commit 6b482d4

File tree

8 files changed

+47
-17
lines changed

8 files changed

+47
-17
lines changed

example/localTimeSystem/src/LADTickSource.js

-10
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ define(['../../../platform/features/conductor-v2/conductor/src/timeSystems/Local
3838
}
3939
LADTickSource.prototype = Object.create(LocalClock.prototype);
4040

41-
LADTickSource.prototype.tick = function () {
42-
console.log('data tick');
43-
var now = Date.now();
44-
this.listeners.forEach(function (listener){
45-
listener(now);
46-
});
47-
this.timeoutHandle = this.$timeout(this.tick.bind(this), this.period);
48-
};
49-
50-
5141
LADTickSource.prototype.type = function () {
5242
return 'data';
5343
};

example/localTimeSystem/src/LocalTimeSystem.js

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ define([
2626
'./LADTickSource'
2727
], function (TimeSystem, LocalClock, LADTickSource) {
2828
var FIFTEEN_MINUTES = 15 * 60 * 1000,
29+
THIRTY_MINUTES = 30 * 60 * 1000,
2930
DEFAULT_PERIOD = 1000;
3031

3132
/**
@@ -71,8 +72,16 @@ define([
7172
{
7273
key: 'local-default',
7374
name: 'Local 12 hour time system defaults',
75+
mode: 'fixed',
7476
deltas: {start: FIFTEEN_MINUTES, end: 0},
7577
bounds: {start: now - FIFTEEN_MINUTES, end: now}
78+
},
79+
{
80+
key: 'local-default',
81+
name: 'Local 12 hour time system defaults',
82+
mode: 'follow',
83+
deltas: {start: THIRTY_MINUTES, end: 0},
84+
bounds: {start: now - THIRTY_MINUTES, end: now}
7685
}
7786
];
7887
};

platform/features/conductor-v2/conductor/src/timeSystems/LocalClock.js

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ define(['./TickSource'], function (TickSource) {
5454
};
5555

5656
LocalClock.prototype.tick = function () {
57-
console.log('clock tick');
5857
var now = Date.now();
5958
this.listeners.forEach(function (listener){
6059
listener(now);

platform/features/conductor-v2/conductor/src/ui/TimeConductorController.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ define(
253253
/**
254254
* @private
255255
*/
256-
TimeConductorController.prototype.setDeltasFromTimeSystem = function (timeSystem) {
257-
var defaults = timeSystem.defaults()[0];
256+
TimeConductorController.prototype.setDeltasFromMode = function (mode) {
257+
var defaults = mode.defaults();
258258
var deltas = defaults.deltas;
259259

260260
/*
@@ -295,7 +295,7 @@ define(
295295
this.$scope.timeSystemModel.deltaFormat = newTimeSystem.deltaFormat();
296296
var mode = this.conductorService.mode();
297297
mode.timeSystem(newTimeSystem);
298-
this.setDeltasFromTimeSystem(newTimeSystem);
298+
this.setDeltasFromMode(mode);
299299

300300
// If current mode supports ticking, set an appropriate tick
301301
// source from the new time system

platform/features/conductor-v2/conductor/src/ui/modes/FixedMode.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ define(
4343
this.conductor.follow(false);
4444
};
4545

46+
FixedMode.prototype.defaults = function () {
47+
var timeSystem = this.timeSystem();
48+
49+
if (timeSystem){
50+
return timeSystem.defaults().filter(function (d) {
51+
return d.mode === 'fixed';
52+
})[0];
53+
}
54+
};
55+
4656
/**
4757
* Defines behavior to occur when selected time system changes. In
4858
* this case, sets default bounds on the time conductor.
@@ -53,7 +63,7 @@ define(
5363
TimeConductorMode.prototype.timeSystem.apply(this, arguments);
5464

5565
if (timeSystem) {
56-
var defaults = timeSystem.defaults()[0];
66+
var defaults = this.defaults();
5767

5868
var bounds = {
5969
start: defaults.bounds.start,

platform/features/conductor-v2/conductor/src/ui/modes/FollowMode.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ define(
6464
* Get or set tick source. Setting tick source will also start
6565
* listening to it and unlisten from any existing tick source
6666
* @param tickSource
67-
* @returns {undefined|*}
67+
* @returns {TickSource}
6868
*/
6969
FollowMode.prototype.tickSource = function (tickSource) {
7070
if (tickSource) {
@@ -77,6 +77,16 @@ define(
7777
return this._tickSource;
7878
};
7979

80+
FollowMode.prototype.defaults = function () {
81+
var timeSystem = this.timeSystem();
82+
83+
if (timeSystem){
84+
return timeSystem.defaults().filter(function (d) {
85+
return d.mode === 'follow';
86+
})[0];
87+
}
88+
};
89+
8090
/**
8191
* On time system change, default the bounds values in the time
8292
* conductor, using the deltas associated with this mode.
@@ -87,7 +97,7 @@ define(
8797
TimeConductorMode.prototype.timeSystem.apply(this, arguments);
8898

8999
if (timeSystem) {
90-
var defaults = timeSystem.defaults()[0];
100+
var defaults = this.defaults();
91101

92102
if (arguments.length > 0) {
93103
var bounds = {

platform/features/conductor-v2/conductor/src/ui/modes/TimeConductorMode.js

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ define(
6262
return this._key;
6363
};
6464

65+
TimeConductorMode.prototype.defaults = function () {
66+
throw new Error("Not implemented");
67+
};
68+
6569
TimeConductorMode.prototype.destroy = function () {
6670
};
6771

platform/features/conductor-v2/utcTimeSystem/src/UTCTimeSystem.js

+8
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ define([
7070
{
7171
key: 'utc-default',
7272
name: 'UTC time system defaults',
73+
mode: 'follow',
74+
deltas: {start: FIFTEEN_MINUTES, end: 0},
75+
bounds: {start: now - FIFTEEN_MINUTES, end: now}
76+
},
77+
{
78+
key: 'utc-default',
79+
name: 'UTC time system defaults',
80+
mode: 'fixed',
7381
deltas: {start: FIFTEEN_MINUTES, end: 0},
7482
bounds: {start: now - FIFTEEN_MINUTES, end: now}
7583
}

0 commit comments

Comments
 (0)