Skip to content

Commit

Permalink
Migrated TOI functionality to common controller
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Oct 17, 2016
1 parent 6bea6b3 commit 7a09bc1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 29 deletions.
11 changes: 11 additions & 0 deletions platform/features/conductor-v2/conductor/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ define([
"./src/TimeConductor",
"./src/ui/ConductorAxisController",
"./src/ui/ConductorTOIController",
"./src/ui/TimeOfInterestController",
"./src/ui/MctConductorAxis",
"./src/ui/NumberFormat",
"text!./res/templates/time-conductor.html",
Expand All @@ -39,6 +40,7 @@ define([
TimeConductor,
ConductorAxisController,
ConductorTOIController,
TimeOfInterestController,
MCTConductorAxis,
NumberFormat,
timeConductorTemplate,
Expand Down Expand Up @@ -95,6 +97,15 @@ define([
"timeConductorViewService",
"formatService"
]
},
{
"key": "TimeOfInterestController",
"implementation": TimeOfInterestController,
"depends": [
"$scope",
"timeConductor",
"formatService"
]
}
],
"directives": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@
ng-click="toi.click($event)">
<a class="l-page-button s-icon-button icon-pointer-left"></a>
<div class="l-data-visualization">
<mct-include key="'time-of-interest'" class="show-val"></mct-include>
<div style="position: relative; height: 100%" ng-style="{'left': toi.left + '%'}">
<mct-include key="'time-of-interest'" class="show-val"
parameters = "{'name': 'conductor'}"></mct-include>
</div>
</div>
<a class="l-page-button align-right s-icon-button icon-pointer-right"></a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="l-toi-holder"
ng-class="{ 'pinned': toi.pinned, 'val-to-left': toi.left > 80 }"
ng-style="{'left': toi.left + '%'}">
ng-controller="TimeOfInterestController as toi"
ng-class="{ 'pinned': pinned, 'val-to-left': toi.left > 80 }">
<div class="l-flex-row l-toi">
<span class="flex-elem l-flex-row l-toi-buttons">
<a class="flex-elem t-button-resync icon-button" title="Re-sync Time of Interest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ define(
* labelled 'ticks'. It requires 'start' and 'end' integer values to
* be specified as attributes.
*/
function ConductorTOIController($scope, conductor, conductorViewService, formatService) {
function ConductorTOIController($scope, conductor, conductorViewService) {
this.conductor = conductor;
this.conductorViewService = conductorViewService;
this.formatService = formatService;
this.toiText = undefined;

//Bind all class functions to 'this'
Object.keys(ConductorTOIController.prototype).filter(function (key) {
Expand All @@ -46,9 +44,6 @@ define(
this.conductorViewService.on('zoom', this.setOffsetFromBounds);
this.conductorViewService.on('pan', this.setOffsetFromBounds);
this.conductor.on('timeSystem', this.changeTimeSystem);
if (conductor.timeSystem()) {
this.changeTimeSystem(conductor.timeSystem());
}

$scope.$on('$destroy', this.destroy);

Expand All @@ -66,18 +61,12 @@ define(
var offset = toi - bounds.start;
var duration = bounds.end - bounds.start;
this.left = offset / duration * 100;
this.toiText = this.format.format(toi);
};

ConductorTOIController.prototype.changeTimeSystem = function (timeSystem) {
this.format = this.formatService.getFormat(timeSystem.formats()[0]);
};

ConductorTOIController.prototype.changeTimeOfInterest = function () {
var bounds = this.conductor.bounds();
if (bounds) {
this.setOffsetFromBounds(bounds);
this.pinned = this.conductor.timeOfInterest() !== undefined;
}
};

Expand All @@ -94,14 +83,6 @@ define(
}
};

ConductorTOIController.prototype.dismiss = function () {
this.conductor.timeOfInterest(undefined);
};

ConductorTOIController.prototype.resize = function () {
//Do something?
};

return ConductorTOIController;
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ define(
this.formatService = formatService;
this.format = undefined;
this.toiText = undefined;
this.$scope = $scope;

//Bind all class functions to 'this'
Object.keys(TimeOfInterestController.prototype).filter(function (key) {
Expand All @@ -42,29 +43,40 @@ define(
this[key] = TimeOfInterestController.prototype[key].bind(this);
}.bind(this));

this.conductor.on('timeOfInterest', this.changeTimeOfInterest);
this.conductor.on('timeSystem', this.changeTimeSystem);
conductor.on('timeOfInterest', this.changeTimeOfInterest);
conductor.on('timeSystem', this.changeTimeSystem);
if (conductor.timeSystem()) {
this.changeTimeSystem(conductor.timeSystem());
}

$scope.$on('$destroy', this.destroy);

}

TimeOfInterestController.prototype.changeTimeOfInterest = function (toi) {
this.pinned = (toi !== undefined);
if (toi !== undefined) {
this.$scope.pinned = true;
this.toiText = this.format.format(toi);
} else {
this.$scope.pinned = false;
}
};

TimeOfInterestController.prototype.changeTimeSystem = function (timeSystem) {
this.format = this.formatService.getFormat(timeSystem.formats()[0]);
};

TimeOfInterestController.prototype.destroy = function () {
this.conductor.off('timeOfInterest', this.setOffsetFromBounds);
this.conductor.off('timeOfInterest', this.changeTimeOfInterest);
this.conductor.off('timeSystem', this.changeTimeSystem);
};

TimeOfInterestController.prototype.dismiss = function () {
this.conductor.timeOfInterest(undefined);
};

TimeOfInterestController.prototype.resync = function () {
this.conductor.timeOfInterest(this.conductor.timeOfInterest());
};

return TimeOfInterestController;
}
Expand Down
4 changes: 3 additions & 1 deletion platform/features/plot/res/templates/plot.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
</div>

<div class="gl-plot-wrapper-display-area-and-x-axis">
<mct-include key="'time-of-interest'" class="show-val"></mct-include>
<mct-include key="'time-of-interest'" class="show-val"
parameters = "{'name': 'plot'}"
></mct-include>

<div class="gl-plot-coords"
ng-if="subplot.isHovering() && subplot.getHoverCoordinates()">
Expand Down

0 comments on commit 7a09bc1

Please sign in to comment.