Skip to content

Commit

Permalink
Use key to retrieve default
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Richards committed Aug 5, 2016
1 parent af7954c commit 46e644e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 54 deletions.
23 changes: 7 additions & 16 deletions example/localTimeSystem/src/LocalTimeSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,14 @@ define([
return this._tickSources;
};

LocalTimeSystem.prototype.defaults = function () {
LocalTimeSystem.prototype.defaults = function (key) {
var now = Math.ceil(Date.now() / 1000) * 1000;
return [
{
key: 'local-default',
name: 'Local 12 hour time system defaults',
mode: 'fixed',
bounds: {start: now - ONE_HOUR, end: now}
},
{
key: 'local-default',
name: 'Local 12 hour time system defaults',
mode: 'follow',
deltas: {start: THIRTY_MINUTES, end: 0},
bounds: {start: now - THIRTY_MINUTES, end: now}
}
];
return {
key: 'local-default',
name: 'Local 12 hour time system defaults',
deltas: {start: THIRTY_MINUTES, end: 0},
bounds: {start: now - THIRTY_MINUTES, end: now}
};
};

return LocalTimeSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ define(
return source.type() === sourceType;
})[0];
}

/**
* Change the selected Time Conductor mode. This will call destroy
* and initialization functions on the relevant modes, setting
Expand Down
10 changes: 0 additions & 10 deletions platform/features/conductor-v2/conductor/src/ui/modes/FixedMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ define(
this.conductor.follow(false);
};

FixedMode.prototype.defaults = function () {
var timeSystem = this.timeSystem();

if (timeSystem){
return timeSystem.defaults().filter(function (d) {
return d.mode === 'fixed';
})[0];
}
};

/**
* Defines behavior to occur when selected time system changes. In
* this case, sets default bounds on the time conductor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ define(
return this._tickSource;
};

FollowMode.prototype.defaults = function () {
var timeSystem = this.timeSystem();

if (timeSystem){
return timeSystem.defaults().filter(function (d) {
return d.mode === 'follow';
})[0];
}
};

/**
* On time system change, default the bounds values in the time
* conductor, using the deltas associated with this mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ define(
};

TimeConductorMode.prototype.defaults = function () {
throw new Error("Not implemented");
var timeSystem = this.timeSystem(),
key = this.key();

if (timeSystem) {
return timeSystem.defaults(key);
}
};

TimeConductorMode.prototype.destroy = function () {
Expand Down
23 changes: 7 additions & 16 deletions platform/features/conductor-v2/utcTimeSystem/src/UTCTimeSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,14 @@ define([
return this._tickSources;
};

UTCTimeSystem.prototype.defaults = function () {
UTCTimeSystem.prototype.defaults = function (key) {
var now = Math.ceil(Date.now() / 1000) * 1000;
return [
{
key: 'utc-default',
name: 'UTC time system defaults',
mode: 'follow',
deltas: {start: FIFTEEN_MINUTES, end: 0},
bounds: {start: now - FIFTEEN_MINUTES, end: now}
},
{
key: 'utc-default',
name: 'UTC time system defaults',
mode: 'fixed',
bounds: {start: now - FIFTEEN_MINUTES, end: now}
}
];
return {
key: 'utc-default',
name: 'UTC time system defaults',
deltas: {start: FIFTEEN_MINUTES, end: 0},
bounds: {start: now - FIFTEEN_MINUTES, end: now}
};
};

return UTCTimeSystem;
Expand Down

0 comments on commit 46e644e

Please sign in to comment.