Skip to content

Commit 2db4aa6

Browse files
committedSep 23, 2016
[Time Conductor] Added zoom level label
1 parent 3c95c09 commit 2db4aa6

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed
 

‎platform/commonUI/formats/src/UTCTimeFormat.js

+32
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,38 @@ define([
9595
})[0][0];
9696
}
9797

98+
UTCTimeFormat.prototype.timeUnits = function (timeRange) {
99+
var momentified = moment.duration(timeRange);
100+
return [
101+
["Decades", function (r) {
102+
return r.years() > 15;
103+
}],
104+
["Years", function (r) {
105+
return r.years() > 0;
106+
}],
107+
["Months", function (r) {
108+
return r.months() > 0;
109+
}],
110+
["Days", function (r) {
111+
return r.days() > 0;
112+
}],
113+
["Hours", function (r) {
114+
return r.hours() > 0;
115+
}],
116+
["Minutes", function (r) {
117+
return r.minutes() > 0;
118+
}],
119+
["Seconds", function (r) {
120+
return r.seconds() > 0;
121+
}],
122+
["Milliseconds", function (r) {
123+
return true;
124+
}]
125+
].filter(function (row){
126+
return row[1](momentified);
127+
})[0][0];
128+
};
129+
98130
/**
99131
*
100132
* @param value

‎platform/features/conductor-v2/conductor/bundle.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ define([
6969
"$window",
7070
"timeConductor",
7171
"timeConductorViewService",
72-
"timeSystems[]"
72+
"timeSystems[]",
73+
"formatService"
7374
]
7475
},
7576
{

‎platform/features/conductor-v2/conductor/res/templates/time-conductor.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@
115115
</mct-control>
116116
<!-- Zoom control -->
117117
<div class="l-time-conductor-zoom-w grows flex-elem l-flex-row">
118-
<span class="time-conductor-zoom-current-range flex-elem flex-fixed holder"></span>
118+
<span
119+
class="time-conductor-zoom-current-range flex-elem flex-fixed holder">{{timeUnits}}</span>
119120
<input class="time-conductor-zoom flex-elem" type="range"
120121
ng-model="currentZoom"
121122
ng-mouseUp="tcController.zoomStop(currentZoom)"

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

+11-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ define(
2626
],
2727
function (TimeConductorValidation) {
2828

29-
function TimeConductorController($scope, $window, timeConductor, conductorViewService, timeSystems) {
29+
function TimeConductorController($scope, $window, timeConductor, conductorViewService, timeSystems, formatService) {
3030

3131
var self = this;
3232

@@ -43,6 +43,7 @@ define(
4343
this.conductor = timeConductor;
4444
this.modes = conductorViewService.availableModes();
4545
this.validation = new TimeConductorValidation(this.conductor);
46+
this.formatService = formatService;
4647

4748
// Construct the provided time system definitions
4849
this.timeSystems = timeSystems.map(function (timeSystemConstructor) {
@@ -129,6 +130,8 @@ define(
129130
this.$scope.boundsModel.end = bounds.end;
130131

131132
this.$scope.currentZoom = this.toSliderValue(bounds.end - bounds.start);
133+
this.toTimeUnits(bounds.end - bounds.start);
134+
132135
if (!this.pendingUpdate) {
133136
this.pendingUpdate = true;
134137
this.$window.requestAnimationFrame(function () {
@@ -272,10 +275,16 @@ define(
272275
return {start: center - timeSpan / 2, end: center + timeSpan / 2};
273276
};
274277

278+
TimeConductorController.prototype.toTimeUnits = function (timeSpan) {
279+
if (this.conductor.timeSystem()) {
280+
var timeFormat = this.formatService.getFormat(this.conductor.timeSystem().formats()[0]);
281+
this.$scope.timeUnits = timeFormat.timeUnits && timeFormat.timeUnits(timeSpan);
282+
}
283+
}
284+
275285
TimeConductorController.prototype.zoom = function(sliderValue) {
276286
var bounds = this.toTimeSpan(sliderValue);
277287
this.setFormFromBounds(bounds);
278-
279288
this.conductorViewService.emit("zoom", bounds);
280289
};
281290

0 commit comments

Comments
 (0)
Please sign in to comment.