Skip to content

Commit

Permalink
Refactored out modes, time systems, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Jul 18, 2016
1 parent 2f9fbfe commit 0af49ef
Show file tree
Hide file tree
Showing 18 changed files with 817 additions and 288 deletions.
16 changes: 12 additions & 4 deletions platform/features/conductor-v2/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

define([
"./src/TimeConductor",
"./src/TimeConductorController",
"./src/MCTConductorAxis",
"./src/ui/TimeConductorController",
"./src/ui/MCTConductorAxis",
"./src/timeSystems/UTCTimeSystem",
"text!./res/templates/time-conductor.html",
"text!./res/templates/mode-selector/mode-selector.html",
"text!./res/templates/mode-selector/mode-menu.html",
Expand All @@ -32,6 +33,7 @@ define([
TimeConductor,
TimeConductorController,
MCTConductorAxis,
UTCTimeSystem,
timeConductorTemplate,
modeSelectorTemplate,
modeMenuTemplate,
Expand All @@ -52,8 +54,8 @@ define([
"implementation": TimeConductorController,
"depends": [
"$scope",
"$timeout",
"timeConductor"
"timeConductor",
"timeSystems[]"
]
}
],
Expand All @@ -79,6 +81,12 @@ define([
"key": "mode-menu",
"template": modeMenuTemplate
}
],
"timeSystems": [
{
"implementation": UTCTimeSystem,
"depends": ["$timeout"]
}
]
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<div class="contents">
<div class="pane left menu-items">
<ul>
<li ng-repeat="(selected, option) in ngModel.options"
ng-click="ngModel.selected=selected">
<li ng-repeat="option in ngModel.options"
ng-click="ngModel.selected=option">
<a
ng-mouseover="representation.activeMetadata = option"
ng-mouseover="representation.activeMetadata = option.metadata"
ng-mouseleave="representation.activeMetadata = undefined">
<span class="ui-symbol icon type-icon">
{{option.glyph}}
{{option.metadata.glyph}}
</span>
{{option.name}}
{{option.metadata.name}}
</a>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<span ng-controller="ClickAwayController as modeController">
<div class="s-menu-btn"
ng-click="modeController.toggle()">
<span class="title-label">{{ngModel.options[ngModel.selected].label}}</span>
<span class="title-label">{{ngModel.selected.metadata.label}}</span>
</div>
<div class="menu super-menu mini mode-selector-menu"
ng-show="modeController.isActive()">
Expand Down
39 changes: 17 additions & 22 deletions platform/features/conductor-v2/res/templates/time-conductor.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
</style>
<div ng-controller="TimeConductorController as tcController"
class="l-time-conductor l-flex-col {{modeModel.selected}}-mode">
class="l-time-conductor l-flex-col {{modeModel.selected.metadata.key}}-mode {{timeSystemModel.selected.metadata.key}}-time-system">
<!-- Holds inputs and ticks -->
<div class="l-time-conductor-ticks l-row-elem l-flex-row flex-elem no-margin">
<form class="abs l-time-conductor-inputs-holder"
Expand All @@ -17,39 +17,37 @@
<mct-control key="'datetime-field'"
structure="{
format: 'utc',
validate: tcController.validateStart
validate: tcController.validation.validateStart
}"
ng-model="formModel"
ng-mouseup="tcController.changing['start'] = true"
ng-blur="tcController.changing['start'] = false; tcController.updateBoundsFromForm(formModel)"
ng-mouseup="changing['start'] = true"
ng-blur="changing['start'] = false; tcController.updateBoundsFromForm(formModel)"
field="'start'"
class="time-range-start">
</mct-control>
</span>
<span class="l-time-range-input-w start-delta"
ng-class="{'hide':(modeModel.selected === 'fixed')}">
ng-class="{'hide':(modeModel.selected.metadata.key === 'fixed')}">
<mct-control key="'datetime-field'"
structure="{
format: 'duration',
validate: tcController.validateStartDelta
validate: tcController.validation.validateStartDelta
}"
ng-model="formModel"
ng-mouseup="tcController.changing['startDelta'] = true"
ng-blur="tcController.changing['startDelta'] = false; tcController.updateDeltasFromForm(formModel)"
ng-blur="tcController.updateDeltasFromForm(formModel)"
field="'startDelta'"
class="time-delta-start">
</mct-control>
</span>
<span class="l-time-range-input-w end-delta"
ng-class="{'hide':(modeModel.selected === 'fixed')}">
ng-class="{'hide':(modeModel.selected.metadata.key === 'fixed')}">
<mct-control key="'datetime-field'"
structure="{
format: 'duration',
validate: tcController.validateEndDelta
validate: tcController.validation.validateEndDelta
}"
ng-model="formModel"
ng-mouseup="tcController.changing['endDelta'] = true"
ng-blur="tcController.changing['endDelta'] = false; tcController.updateDeltasFromForm(formModel)"
ng-blur="tcController.updateDeltasFromForm(formModel)"
field="'endDelta'"
class="time-delta-end">
</mct-control>
Expand All @@ -59,11 +57,11 @@
<mct-control key="'datetime-field'"
structure="{
format: 'utc',
validate: tcController.validateEnd
validate: tcController.validation.validateEnd
}"
ng-model="formModel"
ng-mouseup="tcController.changing['end'] = true"
ng-blur="tcController.changing['end'] = false; tcController.updateBoundsFromForm(formModel)"
ng-mouseup="changing['end'] = true"
ng-blur="changing['end'] = false; tcController.updateBoundsFromForm(formModel)"
field="'end'"
class="time-range-end">
</mct-control>
Expand All @@ -87,14 +85,11 @@
<mct-control
key="'menu-button'"
class="holder flex-elem menus-up time-system"
ng-model="conductorModel.timeSystem"
structure="{
text: 'UTC',
options: [
{name: 'UTC', key:'utc', glyph:'\u0043'},
{name: 'SCET', key:'scet', glyph:'\u0043'},
{name: 'SCLK', key:'sclk', glyph:'\u0043'}
]}">
text: timeSystemModel.selected.metadata.name,
click: tcController.selectTimeSystem,
options: timeSystemModel.options
}">
</mct-control>
</div>
</div>
6 changes: 4 additions & 2 deletions platform/features/conductor-v2/src/TimeConductor.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,17 @@ define(['EventEmitter'], function (EventEmitter) {
TimeConductor.prototype.bounds = function (newBounds) {
if (arguments.length > 0) {
throwOnError(this.validateBounds(newBounds));
this.boundsVal = newBounds;
//Create a copy to avoid direct mutation of conductor bounds
this.boundsVal = JSON.parse(JSON.stringify(newBounds));
/**
* @event TimeConductor#bounds The start time, end time, or
* both have been updated
* @property {TimeConductorBounds} bounds
*/
this.emit('bounds', this.boundsVal);
}
return this.boundsVal;
//Return a copy to prevent direct mutation of time conductor bounds.
return JSON.parse(JSON.stringify(this.boundsVal));
};

/**
Expand Down
Loading

0 comments on commit 0af49ef

Please sign in to comment.