Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Added clipboard.js, added tooltip css util classes, styled copy button

ZachTRicee5f1577769af
diff --git a/Gruntfile.js b/Gruntfile.js
index ea981149a..359a0788a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -29,7 +29,9 @@ var nodeModuleFiles = [
"node_modules/promise-queue/lib/index.js",
"node_modules/openlayers/dist/ol-debug.js",
"node_modules/font-awesome/css/font-awesome.min.css",
- "node_modules/font-awesome/fonts/*"
+ "node_modules/font-awesome/fonts/*",
+ "node_modules/clipboard/dist/clipboard.js",
+ "node_modules/clipboard/dist/clipboard.min.js"
];
// Build date shown in the About box
diff --git a/deploy/wv.css.json b/deploy/wv.css.json
index 8b4b56d05..da854435a 100644
--- a/deploy/wv.css.json
+++ b/deploy/wv.css.json
@@ -1,6 +1,7 @@
[
"web/css/wv.fonts.css",
"web/css/wv.main.css",
+ "web/css/util.css",
"web/css/wv.alert.css",
"web/css/bank.css",
"web/css/wv.map.css",
diff --git a/package.json b/package.json
index 86a63c25d..fb7327101 100644
--- a/package.json
+++ b/package.json
@@ -19,6 +19,7 @@
"bluebird": "3.4.6",
"buster": "0.7.12",
"chromedriver": "2.25.1",
+ "clipboard": "^1.7.1",
"express": "4.15.2",
"font-awesome": "4.7.0",
"geckodriver": "1.2.0",
diff --git a/web/css/util.css b/web/css/util.css
new file mode 100644
index 000000000..c80f24184
--- /dev/null
+++ b/web/css/util.css
@@ -0,0 +1,183 @@
+/*
+ * NASA Worldview
+ *
+ * This code was originally developed at NASA/Goddard Space Flight Center for
+ * the Earth Science Data and Information System (ESDIS) project.
+ *
+ * Copyright (C) 2013 - 2017 United States Government as represented by the
+ * Administrator of the National Aeronautics and Space Administration.
+ * All Rights Reserved.
+ *
+ * Licensed under the NASA Open Source Agreement, Version 1.3
+ * http://opensource.gsfc.nasa.gov/nosa.php
+ */
+
+/*
+ * Util: Tooltips
+ * Based on balloon.css by kazzkiq: https://github.com/kazzkiq/balloon.css
+ */
+button[data-tooltip] {
+ overflow: visible;
+}
+[data-tooltip] {
+ position: relative;
+}
+[data-tooltip]::before,
+[data-tooltip]::after {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
+ filter: alpha(opacity=0);
+ -khtml-opacity: 0;
+ -moz-opacity: 0;
+ opacity: 0;
+ pointer-events: none;
+ -webkit-transition: all 0.18s ease-out 0.18s;
+ transition: all 0.18s ease-out 0.18s;
+ bottom: 100%;
+ left: 50%;
+ position: absolute;
+ z-index: 10;
+ -webkit-transform: translate(-50%, 10px);
+ transform: translate(-50%, 10px);
+ -webkit-transform-origin: top;
+ transform-origin: top;
+}
+[data-tooltip]::after {
+ background: rgba(17, 17, 17, 0.9);
+ border-radius: 4px;
+ color: #fff;
+ content: attr(data-tooltip);
+ font-size: 12px;
+ padding: 8px 16px;
+ white-space: nowrap;
+ margin-bottom: 11px;
+}
+[data-tooltip]::before {
+ background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%280%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
+ background-size: 100% auto;
+ height: 6px;
+ width: 18px;
+ content: "";
+ margin-bottom: 5px;
+}
+[data-tooltip]:hover::before,
+[data-tooltip][data-tooltip-visible]::before,
+[data-tooltip]:hover::after,
+[data-tooltip][data-tooltip-visible]::after {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
+ filter: alpha(opacity=100);
+ -khtml-opacity: 1;
+ -moz-opacity: 1;
+ opacity: 1;
+ pointer-events: auto;
+ -webkit-transform: translate(-50%, 0);
+ transform: translate(-50%, 0);
+}
+[data-tooltip].font-awesome::after {
+ font-family: "FontAwesome";
+}
+[data-tooltip][data-tooltip-break]::after {
+ white-space: pre;
+}
+[data-tooltip-pos="down"]::before,
+[data-tooltip-pos="down"]::after {
+ bottom: auto;
+ left: 50%;
+ top: 100%;
+ -webkit-transform: translate(-50%, -10px);
+ transform: translate(-50%, -10px);
+}
+[data-tooltip-pos="down"]::after {
+ margin-top: 11px;
+}
+[data-tooltip-pos="down"]::before {
+ background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28180%2018%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
+ background-size: 100% auto;
+ height: 6px;
+ width: 18px;
+ margin-top: 5px;
+ margin-bottom: 0;
+}
+[data-tooltip-pos="down"]:hover::before,
+[data-tooltip-pos="down"][data-tooltip-visible]::before,
+[data-tooltip-pos="down"]:hover::after,
+[data-tooltip-pos="down"][data-tooltip-visible]::after {
+ -webkit-transform: translate(-50%, 0);
+ transform: translate(-50%, 0);
+}
+[data-tooltip-pos="left"]::before,
+[data-tooltip-pos="left"]::after {
+ bottom: auto;
+ left: auto;
+ right: 100%;
+ top: 50%;
+ -webkit-transform: translate(10px, -50%);
+ transform: translate(10px, -50%);
+}
+[data-tooltip-pos="left"]::after {
+ margin-right: 11px;
+}
+[data-tooltip-pos="left"]::before {
+ background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28-90%2018%2018%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
+ background-size: 100% auto;
+ height: 18px;
+ width: 6px;
+ margin-right: 5px;
+ margin-bottom: 0;
+}
+[data-tooltip-pos="left"]:hover::before,
+[data-tooltip-pos="left"][data-tooltip-visible]::before,
+[data-tooltip-pos="left"]:hover::after,
+[data-tooltip-pos="left"][data-tooltip-visible]::after {
+ -webkit-transform: translate(0, -50%);
+ transform: translate(0, -50%);
+}
+[data-tooltip-pos="right"]::before,
+[data-tooltip-pos="right"]::after {
+ bottom: auto;
+ left: 100%;
+ top: 50%;
+ -webkit-transform: translate(-10px, -50%);
+ transform: translate(-10px, -50%);
+}
+[data-tooltip-pos="right"]::after {
+ margin-left: 11px;
+}
+[data-tooltip-pos="right"]::before {
+ background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%2890%206%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
+ background-size: 100% auto;
+ height: 18px;
+ width: 6px;
+ margin-bottom: 0;
+ margin-left: 5px;
+}
+[data-tooltip-pos="right"]:hover::before,
+[data-tooltip-pos="right"][data-tooltip-visible]::before,
+[data-tooltip-pos="right"]:hover::after,
+[data-tooltip-pos="right"][data-tooltip-visible]::after {
+ -webkit-transform: translate(0, -50%);
+ transform: translate(0, -50%);
+}
+[data-tooltip-length]::after {
+ white-space: normal;
+}
+[data-tooltip-length="small"]::after {
+ width: 80px;
+}
+[data-tooltip-length="medium"]::after {
+ width: 150px;
+}
+[data-tooltip-length="large"]::after {
+ width: 260px;
+}
+[data-tooltip-length="xlarge"]::after {
+ width: 320px;
+}
+
+@media screen and (min-width: 768px) {
+ [data-tooltip-length="xlarge"]::after {
+ width: 380px;
+ }
+}
+[data-tooltip-length="fit"]::after {
+ width: 100%;
+}
diff --git a/web/css/wv.link.css b/web/css/wv.link.css
index bd640599a..80aeb0925 100644
--- a/web/css/wv.link.css
+++ b/web/css/wv.link.css
@@ -12,6 +12,16 @@
* http://opensource.gsfc.nasa.gov/nosa.php
*/
+.wv-link-panel,
+.wv-link-panel .wv-dialog {
+ overflow: visible;
+}
+
+.wv-link {
+ border-bottom: 1px solid #555;
+ padding-bottom: 12px;
+}
+
.wv-link input[type='text'] {
width: 100%;
cursor: text;
@@ -19,9 +29,96 @@
box-sizing: border-box;
}
-.wv-link {
- border-bottom: 1px solid #555;
- padding-bottom: 12px;
+.wv-link .input-group {
+ position: relative;
+ display: block;
+ width: 100%;
+ margin-top: 10px;
+}
+
+.wv-link .input-group input {
+ position: relative;
+ height: 30px;
+ width: 100%;
+ border: 1px solid #d5d5d5;
+ border-radius: 3px;
+ padding-right: 36px;
+}
+
+.wv-link .input-group-button {
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+
+.wv-link .hide-icon[data-tooltip]::before,
+.wv-link .hide-icon[data-tooltip]::after,
+.wv-link .hide-icon[data-tooltip]:hover::before,
+.wv-link .hide-icon[data-tooltip]:hover::after {
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
+ filter: alpha(opacity=0);
+ -khtml-opacity: 0;
+ -moz-opacity: 0;
+ opacity: 0;
+ pointer-events: none;
+ -webkit-transition: all 0.18s ease-out 0.18s;
+ transition: all 0.18s ease-out 0.18s;
+ bottom: 100%;
+ left: 50%;
+ position: absolute;
+ z-index: 10;
+ -webkit-transform: translate(-50%, 10px);
+ transform: translate(-50%, 10px);
+ -webkit-transform-origin: top;
+ transform-origin: top;
+}
+
+.wv-link [data-tooltip-length="xsmall"]::after {
+ width: 40px;
+}
+
+.wv-link .copy-btn {
+ position: relative;
+ display: inline-block;
+ padding: 0 8px;
+ font-size: 13px;
+ font-weight: 700;
+ line-height: 20px;
+ color: #333;
+ white-space: nowrap;
+ vertical-align: middle;
+ cursor: pointer;
+ background-color: #eee;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#fcfcfc), to(#eee));
+ background-image: linear-gradient(#fcfcfc, #eee);
+ border: 1px solid #d5d5d5;
+ border-radius: 3px;
+ border-top-left-radius: 0;
+ border-bottom-left-radius: 0;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-appearance: none;
+ height: 30px;
+ width: 36px;
+}
+
+.wv-link .copy-btn:hover {
+ text-decoration: none;
+ background-color: #ddd;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#ddd));
+ background-image: linear-gradient(#eee, #ddd);
+ border-color: #ccc;
+}
+
+.wv-link .copy-btn:hover::before {
+ display: none;
+}
+
+.wv-link .copy-btn .clip-icon {
+ margin-top: 2px;
+ font-size: 16px;
}
#wv-link-shorten {
diff --git a/web/css/wv.main.css b/web/css/wv.main.css
index 28fbaafe3..68c4dc9af 100644
--- a/web/css/wv.main.css
+++ b/web/css/wv.main.css
@@ -242,10 +242,6 @@ div.horizontalContainer {
padding: 0;
}
-#permalink_content {
- margin-top: 10px;
-}
-
.hidden {
display: none;
}
diff --git a/web/index.html b/web/index.html
index 7e958e849..230880efc 100644
--- a/web/index.html
+++ b/web/index.html
@@ -76,6 +76,7 @@
<!-- link.prod --> <!-- <link type="text/css" href="css/wv.css?v=20131218215115174" rel="Stylesheet" /> -->
<!-- link.dev --> <link type="text/css" rel="Stylesheet" href="css/wv.fonts.css">
<!-- link.dev --> <link type="text/css" rel="Stylesheet" href="css/wv.main.css">
+ <!-- link.dev --> <link type="text/css" rel="Stylesheet" href="css/util.css">
<!-- link.dev --> <link type="text/css" rel="Stylesheet" href="css/wv.alert.css">
<!-- link.dev --> <link type="text/css" rel="Stylesheet" href="css/bank.css">
<!-- link.dev --> <link type="text/css" rel="Stylesheet" href="css/wv.map.css">
@@ -130,6 +131,9 @@
<!-- link.dev --> <script type="text/javascript" src="ext/node_modules/gifshot/build/custom/gifshot.custom.js"></script>
<!-- link.prod --> <!-- <script type="text/javascript" src="ext/node_modules/gifshot/build/custom/gifshot.custom.min.js"></script> -->
+ <!-- link.dev --> <script type="text/javascript" src="ext/node_modules/clipboard/dist/clipboard.js"></script>
+ <!-- link.prod --> <!-- <script type="text/javascript" src="ext/node_modules/clipboard/dist/clipboard.min.js"></script> -->
+
<!-- link.dev --> <script type="text/javascript" src="ext/main/jquery-2.1.4/jquery.js"></script>
<!-- link.prod --> <!-- <script type="text/javascript" src="ext/main/jquery-2.1.4/jquery.min.js"></script> -->
diff --git a/web/js/link/wv.link.ui.js b/web/js/link/wv.link.ui.js
index 012edb691..9087f692f 100644
--- a/web/js/link/wv.link.ui.js
+++ b/web/js/link/wv.link.ui.js
@@ -19,6 +19,7 @@ wv.link.ui = wv.link.ui || function(models, config) {
var selector = "#" + id;
var $button, $label;
var widgetFactory = React.createFactory(WVC.Share);
+ var clipboard = new Clipboard('.copy-btn');
var init = function() {
$button = $("<input></input>")
@@ -131,14 +132,22 @@ wv.link.ui = wv.link.ui || function(models, config) {
self.show = function() {
var $dialog = wv.ui.getDialog();
var item = "<div id='wv-link' class='wv-link'>" +
- "<input type='text' value='' name='permalink_content' id='permalink_content' readonly/>";
+ "<div class='input-group'>" +
+ "<input type='text' value='' name='permalink_content' id='permalink_content' readonly/>" +
+ "<span class='input-group-button hide-icon' data-balloon-visible data-tooltip='Copied!' data-tooltip-pos='up' data-tooltip-length='xsmall'>" +
+ "<button title='Copy to clipboard' class='copy-btn' data-clipboard-target='#permalink_content'>" +
+ "<span class='clip-icon fa fa-clipboard' aria-hidden='true'></span>" +
+ "</button>" +
+ "</span>" +
+ "</div>";
if (config.features.urlShortening) {
item += "<span autofocus></span><div id='wv-link-shorten'>" +
"<input type='checkbox' value='' id='wv-link-shorten-check' />" +
- "<label id='wv-link-shorten-label' for='wv-link-shorten-check'>Shorten this link</label>" +
+ "<label id='wv-link-shorten-label' for='wv-link-shorten-check'>Shorten link</label>" +
"</div>";
}
item += "</div>";
+
var dialogWidth = '300';
if (wv.util.browser.small) {
dialogWidth = '242';
@@ -166,7 +175,7 @@ wv.link.ui = wv.link.ui || function(models, config) {
$dialog.dialog({
dialogClass: "wv-panel wv-link-panel",
- title: "Copy this link to share:",
+ title: "Copy link to share:",
show: {
effect: "slide",
direction: "up"
@@ -248,6 +257,24 @@ wv.link.ui = wv.link.ui || function(models, config) {
$("#wv-link-shorten-check")
.prop("checked", false);
+
+ clipboard.on('success', function(e) {
+ e.clearSelection();
+
+ $('.wv-link .input-group-button')
+ .removeClass('hide-icon');
+
+ setTimeout(function(){
+ $('.wv-link .input-group-button')
+ .addClass('hide-icon');
+ }, 1000);
+ });
+
+ clipboard.on('error', function(e) {
+ console.error('Link could not be copied!');
+ console.error('Action:', e.action);
+ console.error('Trigger:', e.trigger);
+ });
};
self.initWidget = function() {