Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Make drop-up selector larger & always show all zoom intervals

ZachTRice8197b7484f2f
diff --git a/web/css/timeline.css b/web/css/timeline.css
index 3a020777d..d63327e01 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -402,7 +402,7 @@ g.plot rect.data-bar-invisible {
#timeline-header #timeline-zoom {
display: block;
- width: 66px;
+ width: 80px;
margin-left: auto;
margin-right: auto;
padding: 4px;
@@ -459,9 +459,10 @@ g.plot rect.data-bar-invisible {
text-transform: uppercase;
text-align: center;
font-family: 'Roboto Mono', monospace;
- font-size: 13px;
- line-height: 15px;
+ font-size: 14px;
+ line-height: 16px;
color: #ccc;
+ padding: 2px 0;
}
#timeline-zoom .zoom-btn:hover {
diff --git a/web/index.html b/web/index.html
index 4b46c5527..8048af862 100644
--- a/web/index.html
+++ b/web/index.html
@@ -129,7 +129,7 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
</div>
<div id="input-time-divider">:</div>
-
+
<div id="input-wrapper-minute" class="input-wrapper">
<div class="date-arrows date-arrow-up" data-interval="minute" data-value="10">
<svg width="25" height="8">
@@ -147,12 +147,13 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
<div id="focus-guard-2" class="focus-guard" tabindex="7"></div>
<div id="zoom-buttons-group">
<div id="zoom-btn-container">
- <span id="zoom-days" class="zoom-btn zoom-btn-active" data-zoom="3">Days</span>
+ <span id="current-zoom" class="zoom-btn zoom-btn-active" data-zoom="3">Days</span>
<div class="wv-tooltip">
<div id="timeline-zoom">
- <span id="zoom-minutes" class="zoom-btn zoom-btn-inactive" data-zoom="4">Minutes</span>
- <span id="zoom-months" class="zoom-btn zoom-btn-inactive" data-zoom="2">Months</span>
<span id="zoom-years" class="zoom-btn zoom-btn-inactive" data-zoom="1">Years</span>
+ <span id="zoom-months" class="zoom-btn zoom-btn-inactive" data-zoom="2">Months</span>
+ <span id="zoom-days" class="zoom-btn zoom-btn-inactive" data-zoom="3">Days</span>
+ <span id="zoom-minutes" class="zoom-btn zoom-btn-inactive" data-zoom="4">Minutes</span>
</div>
</div>
</div>
diff --git a/web/js/date/config.js b/web/js/date/config.js
index a48c79b4d..8338e2248 100644
--- a/web/js/date/config.js
+++ b/web/js/date/config.js
@@ -16,6 +16,8 @@ export function timelineConfig(models, config, ui) {
var zoomLevel = model.selectedZoom || 3;
self.zoom = function (level, event) {
+ // clone zoom element when switching zoom level.
+ var clone;
// format of the label
var labelFormat;
// printed type of tick
@@ -197,14 +199,7 @@ export function timelineConfig(models, config, ui) {
});
};
- util.swapNodes('.zoom-btn-active', '#zoom-years');
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $('#zoom-years')
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
+ switchZoom(1);
self.currentZoom = 1;
break;
@@ -355,14 +350,7 @@ export function timelineConfig(models, config, ui) {
});
};
- util.swapNodes('.zoom-btn-active', '#zoom-months');
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $('#zoom-months')
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
+ switchZoom(2);
self.currentZoom = 2;
break;
@@ -522,14 +510,7 @@ export function timelineConfig(models, config, ui) {
}
});
- util.swapNodes('.zoom-btn-active', '#zoom-days');
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $('#zoom-days')
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
+ switchZoom(3);
self.currentZoom = 3;
break;
@@ -726,14 +707,7 @@ export function timelineConfig(models, config, ui) {
}
});
- util.swapNodes('.zoom-btn-active', '#zoom-minutes');
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $('#zoom-minutes')
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
+ switchZoom(4);
self.currentZoom = 4;
break;
@@ -753,6 +727,29 @@ export function timelineConfig(models, config, ui) {
model.events.trigger('timeline-change');
};
+ var switchZoom = function (zoomLevel) {
+ var clone;
+ var zoomElement;
+ switch (zoomLevel) {
+ case 1:
+ zoomElement = '#zoom-years';
+ break;
+ case 2:
+ zoomElement = '#zoom-months';
+ break;
+ case 3:
+ zoomElement = '#zoom-days';
+ break;
+ case 4:
+ zoomElement = '#zoom-minutes';
+ break;
+ }
+ $('#current-zoom').remove();
+ clone = $(zoomElement).clone().prop('id', 'current-zoom')
+ .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
+ $('#zoom-btn-container').prepend(clone);
+ };
+
// Draw ticks based on zoom level
var initTicks = function () {
tl.ticks.boundary.init();
@@ -767,53 +764,23 @@ export function timelineConfig(models, config, ui) {
$('#zoom-btn-container').hover(function () {
$('.wv-tooltip').toggle();
});
- d3.select('#zoom-years')
- .on('click', function (d) {
- util.swapNodes('.zoom-btn-active', this);
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $(this)
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
- self.zoom(1);
- });
- d3.select('#zoom-months')
- .on('click', function (d) {
- util.swapNodes('.zoom-btn-active', this);
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $(this)
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
- self.zoom(2);
- });
- d3.select('#zoom-days')
- .on('click', function (d) {
- util.swapNodes('.zoom-btn-active', this);
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $(this)
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
- self.zoom(3);
- });
- d3.select('#zoom-minutes')
+ $('.zoom-btn-inactive')
.on('click', function (d) {
- util.swapNodes('.zoom-btn-active', this);
- $('.zoom-btn')
- .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
- $(this)
- .removeClass('zoom-btn-inactive').addClass('zoom-btn-active');
- $('#zoom-btn-container').find('.zoom-btn-inactive').sort(function (a, b) {
- return +a.getAttribute('data-zoom') - +b.getAttribute('data-zoom');
- }).appendTo('#timeline-zoom');
- self.zoom(4);
+ var dataZoom = $(this).attr('data-zoom');
+ switch (dataZoom) {
+ case '1':
+ self.zoom(1);
+ break;
+ case '2':
+ self.zoom(2);
+ break;
+ case '4':
+ self.zoom(4);
+ break;
+ default:
+ self.zoom(3);
+ break;
+ }
});
// Default zoom
self.zoom(zoomLevel);
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 3ac9ef341..569ad81b2 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -1027,14 +1027,5 @@ export default (function (self) {
}
};
- // Switch two elements' locations in the dom
- self.swapNodes = function (a, b) {
- a = $(a); b = $(b);
- var tmp = $('<span>').hide();
- a.before(tmp);
- b.before(a);
- tmp.replaceWith(b);
- };
-
return self;
})({});