Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Incorporate & style tooltip on hover to timeline zoom

ZachTRicea8542b85d37c
diff --git a/web/css/dateselector.css b/web/css/dateselector.css
index f66ce7c87..14307123a 100644
--- a/web/css/dateselector.css
+++ b/web/css/dateselector.css
@@ -153,7 +153,6 @@
#timeline-footer,
#timeline-hide,
-#timeline-zoom,
.wv-date-selector-widget {
float: left;
}
diff --git a/web/css/timeline.css b/web/css/timeline.css
index 5ade288c5..1c57b225c 100644
--- a/web/css/timeline.css
+++ b/web/css/timeline.css
@@ -310,8 +310,7 @@ g.plot rect.data-bar-invisible {
}
#timeline-footer,
-#timeline-header,
-#timeline-zoom {
+#timeline-header {
float: left;
}
@@ -372,19 +371,37 @@ g.plot rect.data-bar-invisible {
stroke: #4682b4;
}
-#timeline-zoom {
- box-sizing: border-box;
- -moz-box-sizing: border-box;
- -webkit-box-sizing: border-box;
- display: inline-block;
+#timeline-header #timeline-zoom {
+ display: block;
+ width: 66px;
+ margin-left: auto;
+ margin-right: auto;
+ padding: 4px;
+ background-color: rgba(40, 40, 40, 0.9);
+ border-radius: 3px;
+}
+
+#timeline-header #zoom-btn-container {
+ display: block;
+}
+
+#zoom-btn-container .wv-tooltip {
+ display: none;
position: absolute;
- bottom: 60px;
- vertical-align: middle;
- overflow-y: hidden;
- height: 54px;
+ bottom: 100%;
+ border-bottom: 8px solid transparent;
width: 100%;
- border-radius: 5px;
- background-color: rgba(40, 40, 40, 0.9);
+}
+
+#zoom-btn-container .wv-tooltip::after {
+ position: absolute;
+ top: 100%;
+ left: 15%;
+ content: "";
+ border-top: 5px solid #000;
+ border-top: 5px solid rgba(51, 51, 51, 0.9);
+ border-right: 5px solid transparent;
+ border-left: 5px solid transparent;
}
.zoom-btn-active {
@@ -413,30 +430,9 @@ g.plot rect.data-bar-invisible {
text-transform: uppercase;
text-align: center;
font-family: 'Roboto Mono', monospace;
-}
-
-#timeline-zoom .zoom-btn.depth-1 {
- color: #fff;
- font-size: 18px;
- line-height: 20px;
-}
-
-#timeline-zoom .zoom-btn.depth-2 {
- color: #999;
- font-size: 14px;
- line-height: 16px;
-}
-
-#timeline-zoom .zoom-btn.depth-3 {
- color: #666;
- font-size: 12px;
- line-height: 14px;
-}
-
-#timeline-zoom .zoom-btn.depth-4 {
- color: #666;
- font-size: 10px;
- line-height: 14px;
+ font-size: 13px;
+ line-height: 15px;
+ color: #ccc;
}
#timeline-zoom .zoom-btn:hover {
diff --git a/web/css/tooltip.css b/web/css/tooltip.css
index 189569e13..2c384e5eb 100644
--- a/web/css/tooltip.css
+++ b/web/css/tooltip.css
@@ -31,6 +31,7 @@
.wv-tooltip-case .wv-tooltip ul {
background-color: #000;
background-color: hsla(0, 0%, 20%, 0.9);
+ border-radius: 3px;
color: #fff;
padding: 5px 10px;
list-style: none;
diff --git a/web/index.html b/web/index.html
index 0197c5302..0e543534a 100644
--- a/web/index.html
+++ b/web/index.html
@@ -143,12 +143,16 @@ Licensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gs
</div>
<div id="focus-guard-2" class="focus-guard" tabindex="7"></div>
<div id="time-buttons-group" class="">
- <span class="zoom-btn zoom-btn-active" id="zoom-minutes">Minutes</span>
- <ul id="timeline-zoom">
- <li class="zoom-btn" id="zoom-days">Days</li>
- <li class="zoom-btn" id="zoom-months">Months</li>
- <li class="zoom-btn" id="zoom-years">Years</li>
- </ul>
+ <div id="zoom-btn-container">
+ <span id="zoom-days" 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>
+ </div>
+ </div>
+ </div>
<div class="button-action-group" id="left-arrow-group" title="Click and hold to animate backwards">
<svg width="24" height="30">
<path
diff --git a/web/js/date/config.js b/web/js/date/config.js
index 2da8105c7..25aca8811 100644
--- a/web/js/date/config.js
+++ b/web/js/date/config.js
@@ -197,22 +197,14 @@ export function timelineConfig(models, config, ui) {
});
};
- // Update placement of zoom buttons
+ util.swapNodes('.zoom-btn-active', '#zoom-years');
$('.zoom-btn')
- .removeClass(function (index, css) {
- return (css.match(/(^|\s)depth-\S+/g) || [])
- .join(' ');
- })
- .css('margin', '')
- .css('font-size', '');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$('#zoom-years')
- .addClass('depth-1');
- $('#zoom-months')
- .addClass('depth-2');
- $('#zoom-days')
- .addClass('depth-3');
- $('#zoom-minutes')
- .addClass('depth-4');
+ .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.currentZoom = 1;
break;
@@ -363,22 +355,14 @@ export function timelineConfig(models, config, ui) {
});
};
- // Update placement of zoom buttons
+ util.swapNodes('.zoom-btn-active', '#zoom-months');
$('.zoom-btn')
- .removeClass(function (index, css) {
- return (css.match(/(^|\s)depth-\S+/g) || [])
- .join(' ');
- })
- .css('margin', '')
- .css('font-size', '');
- $('#zoom-years')
- .addClass('depth-2');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$('#zoom-months')
- .addClass('depth-1');
- $('#zoom-days')
- .addClass('depth-2');
- $('#zoom-minutes')
- .addClass('depth-3');
+ .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.currentZoom = 2;
break;
@@ -538,22 +522,14 @@ export function timelineConfig(models, config, ui) {
}
});
- // Update placement of zoom buttons
+ util.swapNodes('.zoom-btn-active', '#zoom-days');
$('.zoom-btn')
- .removeClass(function (index, css) {
- return (css.match(/(^|\s)depth-\S+/g) || [])
- .join(' ');
- })
- .css('margin', '')
- .css('font-size', '');
- $('#zoom-years')
- .addClass('depth-3');
- $('#zoom-months')
- .addClass('depth-2');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$('#zoom-days')
- .addClass('depth-1');
- $('#zoom-minutes')
- .addClass('depth-2');
+ .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.currentZoom = 3;
break;
@@ -733,22 +709,14 @@ export function timelineConfig(models, config, ui) {
}
});
- // Update placement of zoom buttons
+ util.swapNodes('.zoom-btn-active', '#zoom-minutes');
$('.zoom-btn')
- .removeClass(function (index, css) {
- return (css.match(/(^|\s)depth-\S+/g) || [])
- .join(' ');
- })
- .css('margin', '')
- .css('font-size', '');
- $('#zoom-years')
- .addClass('depth-4');
- $('#zoom-months')
- .addClass('depth-3');
- $('#zoom-days')
- .addClass('depth-2');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$('#zoom-minutes')
- .addClass('depth-1');
+ .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.currentZoom = 4;
break;
@@ -779,36 +747,55 @@ export function timelineConfig(models, config, ui) {
};
var init = function () {
+ $('#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-selected');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$(this)
- .addClass('zoom-btn-selected');
+ .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-selected');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$(this)
- .addClass('zoom-btn-selected');
+ .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-selected');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$(this)
- .addClass('zoom-btn-selected');
+ .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')
.on('click', function (d) {
+ util.swapNodes('.zoom-btn-active', this);
$('.zoom-btn')
- .removeClass('zoom-btn-selected');
+ .removeClass('zoom-btn-active').addClass('zoom-btn-inactive');
$(this)
- .addClass('zoom-btn-selected');
+ .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);
});
// Default zoom
diff --git a/web/js/util/util.js b/web/js/util/util.js
index 569ad81b2..3ac9ef341 100644
--- a/web/js/util/util.js
+++ b/web/js/util/util.js
@@ -1027,5 +1027,14 @@ 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;
})({});