Interactive interface for browsing global, full-resolution satellite imagery
Add worldview components to core #1173
Benjamin Kingd7af9024d975
diff --git a/package-lock.json b/package-lock.jsonindex 1529032ad..62b39b246 100644--- a/package-lock.json+++ b/package-lock.json@@ -4,6 +4,27 @@"lockfileVersion": 1,"requires": true,"dependencies": {+ "@babel/runtime": {+ "version": "7.0.0-beta.54",+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0-beta.54.tgz",+ "integrity": "sha1-Oeu0JyP+fKSz4bAOln6AE41Hyt8=",+ "requires": {+ "core-js": "2.5.7",+ "regenerator-runtime": "0.12.1"+ },+ "dependencies": {+ "core-js": {+ "version": "2.5.7",+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz",+ "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw=="+ },+ "regenerator-runtime": {+ "version": "0.12.1",+ "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz",+ "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg=="+ }+ }+ },"@types/node": {"version": "10.3.3","resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.3.tgz",@@ -854,6 +875,12 @@"resolved": "https://registry.npmjs.org/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz","integrity": "sha1-CvMqmm4Tyno/1QaeYtew9Y0NiUY="},+ "babel-plugin-syntax-object-rest-spread": {+ "version": "6.13.0",+ "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz",+ "integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=",+ "dev": true+ },"babel-plugin-syntax-trailing-function-commas": {"version": "6.22.0","resolved": "https://registry.npmjs.org/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz",@@ -1107,6 +1134,16 @@"babel-runtime": "6.26.0"}},+ "babel-plugin-transform-object-rest-spread": {+ "version": "6.26.0",+ "resolved": "https://registry.npmjs.org/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz",+ "integrity": "sha1-DzZpLVD+9rfi1LOsFHgTepY7ewY=",+ "dev": true,+ "requires": {+ "babel-plugin-syntax-object-rest-spread": "6.13.0",+ "babel-runtime": "6.26.0"+ }+ },"babel-plugin-transform-react-display-name": {"version": "6.25.0","resolved": "https://registry.npmjs.org/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.25.0.tgz",@@ -2345,6 +2382,11 @@"map-obj": "1.0.1"}},+ "can-use-dom": {+ "version": "0.1.0",+ "resolved": "https://registry.npmjs.org/can-use-dom/-/can-use-dom-0.1.0.tgz",+ "integrity": "sha1-IsxKNKCrxDlQ9CxkEQJKP2NmtFo="+ },"caniuse-api": {"version": "1.6.1","resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-1.6.1.tgz",@@ -3375,6 +3417,11 @@}}},+ "css-box-model": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/css-box-model/-/css-box-model-1.0.0.tgz",+ "integrity": "sha512-MGipbCM6/HGmsOwN6Enq1OvNKy8H5Q1XKoyBszxwv2efly7ZVg+HcFILX8O6S0xfj27l1+6P7FyCjcQ90m5HBQ=="+ },"css-color-list": {"version": "0.0.1","resolved": "https://registry.npmjs.org/css-color-list/-/css-color-list-0.0.1.tgz",@@ -7706,6 +7753,11 @@"integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==","dev": true},+ "hoist-non-react-statics": {+ "version": "2.5.5",+ "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz",+ "integrity": "sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw=="+ },"home-or-tmp": {"version": "2.0.0","resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-2.0.0.tgz",@@ -9024,6 +9076,11 @@"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.15.0.tgz","integrity": "sha1-MWI5HY8BQKoiz49rPDTWt/Y9Oqk="},+ "lodash-es": {+ "version": "4.17.10",+ "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.10.tgz",+ "integrity": "sha512-iesFYPmxYYGTcmQK0sL8bX3TGHyM6b2qREaB4kamHfQyfPJP0xgoGxp19nsH16nsfquLdiyKyX3mQkfiSGV8Rg=="+ },"lodash._arraycopy": {"version": "3.0.0","resolved": "https://registry.npmjs.org/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz",@@ -9209,6 +9266,11 @@"integrity": "sha1-lU73UEkmIDjJbR/Jiyj9r58Hcqo=","dev": true},+ "lodash.throttle": {+ "version": "4.1.1",+ "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz",+ "integrity": "sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ="+ },"lodash.tonumber": {"version": "4.0.3","resolved": "https://registry.npmjs.org/lodash.tonumber/-/lodash.tonumber-4.0.3.tgz",@@ -9438,6 +9500,11 @@"mimic-fn": "1.2.0"}},+ "memoize-one": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-4.0.0.tgz",+ "integrity": "sha512-wdpOJ4XBejprGn/xhd1i2XR8Dv1A25FJeIvR7syQhQlz9eXsv+06llcvcmBxlWVGv4C73QBsWA8kxvZozzNwiQ=="+ },"memorystream": {"version": "0.3.1","resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz",@@ -11090,8 +11157,7 @@"performance-now": {"version": "2.1.0","resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",- "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",- "dev": true+ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="},"phantom-proxy": {"version": "0.1.792",@@ -13236,6 +13302,19 @@"resolved": "https://registry.npmjs.org/quickselect/-/quickselect-1.1.1.tgz","integrity": "sha512-qN0Gqdw4c4KGPsBOQafj6yj/PA6c/L63f6CaZ/DCF/xF4Esu3jVmKLUDYxghFx8Kb/O7y9tI7x2RjTSXwdK1iQ=="},+ "raf": {+ "version": "3.4.0",+ "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.0.tgz",+ "integrity": "sha512-pDP/NMRAXoTfrhCfyfSEwJAKLaxBU9eApMeBPB1TkDouZmvPerIClV8lTAd+uF8ZiTaVl69e1FCxQrAd/VTjGw==",+ "requires": {+ "performance-now": "2.1.0"+ }+ },+ "raf-schd": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/raf-schd/-/raf-schd-4.0.0.tgz",+ "integrity": "sha512-m7zq0JkIrECzw9mO5Zcq6jN4KayE34yoIS9hJoiZNXyOAT06PPA8PrR+WtJIeFW09YjUfNkMMN9lrmAt6BURCA=="+ },"ramp": {"version": "2.0.2","resolved": "https://registry.npmjs.org/ramp/-/ramp-2.0.2.tgz",@@ -13456,6 +13535,22 @@}}},+ "react-beautiful-dnd": {+ "version": "8.0.7",+ "resolved": "https://registry.npmjs.org/react-beautiful-dnd/-/react-beautiful-dnd-8.0.7.tgz",+ "integrity": "sha512-j2cClhKuACXp/KcG+YXSrVxZ7AQl13dG9X+ojstR6H2G0yoA+1GZn/O147PWVVScmfk/mSt60GNseH7vjae7vQ==",+ "requires": {+ "@babel/runtime": "7.0.0-beta.54",+ "css-box-model": "1.0.0",+ "memoize-one": "4.0.0",+ "prop-types": "15.6.1",+ "raf-schd": "4.0.0",+ "react-motion": "0.5.2",+ "react-redux": "5.0.7",+ "redux": "4.0.0",+ "tiny-invariant": "0.0.3"+ }+ },"react-dom": {"version": "16.3.1","resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.3.1.tgz",@@ -13474,6 +13569,15 @@}}},+ "react-draggable": {+ "version": "3.0.5",+ "resolved": "https://registry.npmjs.org/react-draggable/-/react-draggable-3.0.5.tgz",+ "integrity": "sha512-qo76q6+pafyGllbmfc+CgWfOkwY9v3UoJa3jp6xG2vdsRY8uJTN1kqNievLj0uVNjEqCvZ0OFiEBxlAJNj3OTg==",+ "requires": {+ "classnames": "2.2.6",+ "prop-types": "15.6.1"+ }+ },"react-input-range": {"version": "1.3.0","resolved": "https://registry.npmjs.org/react-input-range/-/react-input-range-1.3.0.tgz",@@ -13488,6 +13592,52 @@"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz","integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="},+ "react-motion": {+ "version": "0.5.2",+ "resolved": "https://registry.npmjs.org/react-motion/-/react-motion-0.5.2.tgz",+ "integrity": "sha512-9q3YAvHoUiWlP3cK0v+w1N5Z23HXMj4IF4YuvjvWegWqNPfLXsOBE/V7UvQGpXxHFKRQQcNcVQE31g9SB/6qgQ==",+ "requires": {+ "performance-now": "0.2.0",+ "prop-types": "15.6.1",+ "raf": "3.4.0"+ },+ "dependencies": {+ "performance-now": {+ "version": "0.2.0",+ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz",+ "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU="+ }+ }+ },+ "react-popper": {+ "version": "0.10.4",+ "resolved": "https://registry.npmjs.org/react-popper/-/react-popper-0.10.4.tgz",+ "integrity": "sha1-rypBXqIike3VBGeNev2opu4ylao=",+ "requires": {+ "popper.js": "1.14.3",+ "prop-types": "15.6.1"+ }+ },+ "react-redux": {+ "version": "5.0.7",+ "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-5.0.7.tgz",+ "integrity": "sha512-5VI8EV5hdgNgyjfmWzBbdrqUkrVRKlyTKk1sGH3jzM2M2Mhj/seQgPXaz6gVAj2lz/nz688AdTqMO18Lr24Zhg==",+ "requires": {+ "hoist-non-react-statics": "2.5.5",+ "invariant": "2.2.4",+ "lodash": "4.17.10",+ "lodash-es": "4.17.10",+ "loose-envify": "1.3.1",+ "prop-types": "15.6.1"+ },+ "dependencies": {+ "lodash": {+ "version": "4.17.10",+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",+ "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="+ }+ }+ },"react-transition-group": {"version": "2.4.0","resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.4.0.tgz",@@ -13510,6 +13660,21 @@}}},+ "reactstrap": {+ "version": "6.3.1",+ "resolved": "https://registry.npmjs.org/reactstrap/-/reactstrap-6.3.1.tgz",+ "integrity": "sha512-maPXx5DREMfN1Gudx3R3zMoWgjQX+rGSbmEMOux3cr0lLUx5jDR9c3a1HDRgFcDyNKiGMa+MmLPJeFXUl7lihw==",+ "requires": {+ "classnames": "2.2.6",+ "lodash.isfunction": "3.0.9",+ "lodash.isobject": "3.0.2",+ "lodash.tonumber": "4.0.3",+ "prop-types": "15.6.1",+ "react-lifecycles-compat": "3.0.4",+ "react-popper": "0.10.4",+ "react-transition-group": "2.4.0"+ }+ },"read-all-stream": {"version": "3.1.0","resolved": "https://registry.npmjs.org/read-all-stream/-/read-all-stream-3.1.0.tgz",@@ -13765,6 +13930,15 @@}}},+ "redux": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/redux/-/redux-4.0.0.tgz",+ "integrity": "sha512-NnnHF0h0WVE/hXyrB6OlX67LYRuaf/rJcbWvnHHEPCF/Xa/AZpwhs/20WyqzQae5x4SD2F9nPObgBh2rxAgLiA==",+ "requires": {+ "loose-envify": "1.3.1",+ "symbol-observable": "1.2.0"+ }+ },"ref": {"version": "1.3.5","resolved": "https://registry.npmjs.org/ref/-/ref-1.3.5.tgz",@@ -14170,6 +14344,11 @@"resolve-from": "1.0.1"}},+ "resize-observer-polyfill": {+ "version": "1.5.0",+ "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.0.tgz",+ "integrity": "sha512-M2AelyJDVR/oLnToJLtuDJRBBWUGUvvGigj1411hXhAdyFWqMaqHp7TixW3FpiLuVaikIcR1QL+zqoJoZlOgpg=="+ },"resolve": {"version": "1.6.0","resolved": "https://registry.npmjs.org/resolve/-/resolve-1.6.0.tgz",@@ -14351,6 +14530,11 @@"sb-promisify": "2.0.2"}},+ "scrollbarwidth": {+ "version": "0.1.3",+ "resolved": "https://registry.npmjs.org/scrollbarwidth/-/scrollbarwidth-0.1.3.tgz",+ "integrity": "sha1-Gw3mTiiMOMQn9KAf4ApGKgS5T98="+ },"select": {"version": "1.1.2","resolved": "https://registry.npmjs.org/select/-/select-1.1.2.tgz",@@ -14667,6 +14851,17 @@"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=","dev": true},+ "simplebar": {+ "version": "3.0.0-beta.1",+ "resolved": "https://registry.npmjs.org/simplebar/-/simplebar-3.0.0-beta.1.tgz",+ "integrity": "sha1-ds6twWr3YtBAR+7MwXDh7D6U41c=",+ "requires": {+ "can-use-dom": "0.1.0",+ "lodash.throttle": "4.1.1",+ "resize-observer-polyfill": "1.5.0",+ "scrollbarwidth": "0.1.3"+ }+ },"sinon": {"version": "1.17.7","resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz",@@ -16975,6 +17170,11 @@}}},+ "symbol-observable": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",+ "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="+ },"symbol-tree": {"version": "3.2.2","resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",@@ -17347,6 +17547,11 @@"resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.0.2.tgz","integrity": "sha512-2NM0auVBGft5tee/OxP4PI3d8WItkDM+fPnaRAVo6xTDI2knbz9eC5ArWGqtGlYqiH3RU5yMpdyTTO7MguC4ow=="},+ "tiny-invariant": {+ "version": "0.0.3",+ "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-0.0.3.tgz",+ "integrity": "sha512-SA2YwvDrCITM9fTvHTHRpq9W6L2fBsClbqm3maT5PZux4Z73SPPDYwJMtnoWh6WMgmCkJij/LaOlWiqJqFMK8g=="+ },"tinycolor": {"version": "0.0.1","resolved": "https://registry.npmjs.org/tinycolor/-/tinycolor-0.0.1.tgz",diff --git a/package.json b/package.jsonindex f5cdbe223..b51c61e1f 100644--- a/package.json+++ b/package.json@@ -76,6 +76,8 @@"babel-eslint": "^7.2.3","babel-polyfill": "^6.26.0","babel-preset-env": "^1.6.1",+ "babel-preset-react": "^6.24.1",+ "babel-plugin-transform-object-rest-spread": "^6.26.0","babelify": "^7.3.0","browserify": "^14.4.0","browserify-css": "^0.13.1",@@ -121,7 +123,6 @@"yargs": "^11.0.0"},"dependencies": {- "babel-plugin-transform-object-rest-spread": "^6.26.0","bluebird": "3.4.6","bootstrap": "^4.1.0","cachai": "^1.0.2",@@ -139,14 +140,18 @@"jquery-ui-touch-punch": "0.2.3","jquery.joyride": "git+https://[email protected]/nasa-gibs/joyride.git","jscrollpane": "^2.0.22",- "lodash": "4.15.0",+ "lodash": "^4.15.0","nouislider": "7.0.10","ol": "~4.5.0","perfect-scrollbar": "^0.8.1","proj4": "2.3.3","promise-queue": "2.2.3","react": "^16.3.0",+ "react-beautiful-dnd": "^8.0.7","react-dom": "^16.3.0",+ "react-draggable": "^3.0.5",+ "react-input-range": "^1.3.0",+ "reactstrap": "^6.3.1","simplebar": "^3.0.0-beta.1","supercluster": "3.0.2","web-streams-polyfill": "^1.3.2",diff --git a/tasks/buildJS.js b/tasks/buildJS.jsindex 1de7e8edb..855a0a8bc 100644--- a/tasks/buildJS.js+++ b/tasks/buildJS.js@@ -40,20 +40,26 @@ var bundler = browserify(entryPoint, {});if (isProduction) {- bundler = bundler.transform('envify', { // Replace env variables with strings - allows deadcode removal with uglifyify (below) and unglifyjs (see npm script "build:js")+ bundler = bundler.transform('envify', {+ // Replace env variables with strings - allows deadcode removal with uglifyify (below) and unglifyjs (see npm script "build:js")NODE_ENV: process.env.NODE_ENV,global: true});}-bundler = bundler.transform('babelify', { // necessary regardless of dev or prod build- presets: ['env']-}).transform('browserify-shim', {- global: true-});+bundler = bundler+ .transform('babelify', {+ // necessary regardless of dev or prod build+ presets: ['env', 'react'],+ plugins: ['transform-object-rest-spread']+ })+ .transform('browserify-shim', {+ global: true+ });if (isProduction) {- bundler = bundler.transform('uglifyify', { // With sourcemaps turned on, it's ok to uglify in dev+ bundler = bundler.transform('uglifyify', {+ // With sourcemaps turned on, it's ok to uglify in devglobal: true});}@@ -61,10 +67,13 @@ if (isProduction) {function bundle() {const begin = Date.now();var stream = fs.createWriteStream(outputPath);- bundler.bundle().on('error', function(err) {- console.error(err);- this.emit('end');- }).pipe(stream);+ bundler+ .bundle()+ .on('error', function(err) {+ console.error(err);+ this.emit('end');+ })+ .pipe(stream);stream.on('finish', function() {// if production - read bundle file, uglify-js bundle, and rewrite fileif (isProduction) {@@ -90,12 +99,16 @@ function bundle() {if (err) {console.log(err);} else {- console.log(outputPath + ' written in ' + (Date.now() - begin) / 1000 + 's');+ console.log(+ outputPath + ' written in ' + (Date.now() - begin) / 1000 + 's'+ );}});});} else {- console.log(outputPath + ' written in ' + (Date.now() - begin) / 1000 + 's');+ console.log(+ outputPath + ' written in ' + (Date.now() - begin) / 1000 + 's'+ );}});}diff --git a/web/js/animation/gif.js b/web/js/animation/gif.jsindex a8bdd632b..2368580b9 100644--- a/web/js/animation/gif.js+++ b/web/js/animation/gif.js@@ -10,7 +10,8 @@ import lodashThrottle from 'lodash/throttle';import lodashCapitalize from 'lodash/capitalize';import canvg from 'canvg-browser';import FileSaver from 'file-saver';-import { GA as googleAnalytics, GifResSelection } from 'worldview-components';+import googleAnalytics from '../components/util/google-analytics';+import GifResSelection from '../components/animation-widget/gif-panel';import {imageUtilGetLayerOpacities,imageUtilCalculateResolution,@@ -33,7 +34,8 @@ const PALETTE_WARNING ='thresholds, etc.). These modifications cannot be used to take a ' +'snapshot. Would you like to temporarily revert to the original ' +'layer(s)?';-const ROTATE_WARNING = 'Image may not be downloaded when rotated. Would you like to reset rotation?';+const ROTATE_WARNING =+ 'Image may not be downloaded when rotated. Would you like to reset rotation?';const resolutionsGeo = {values: [@@ -78,7 +80,8 @@ export function animationGif(models, config, ui) {var renderPanel = function(options, mountEl) {return ReactDOM.render(React.createElement(GifResSelection, options),- mountEl);+ mountEl+ );};/*@@ -96,14 +99,19 @@ export function animationGif(models, config, ui) {models.anim.events.on('gif-click', setImageCoords);panelCase = document.createElement('div');panelCase.className = 'gif-dialog';- throttleSetDownloadButton = lodashThrottle(setDownloadButtonClass, 300, { trailing: true });+ throttleSetDownloadButton = lodashThrottle(setDownloadButtonClass, 300, {+ trailing: true+ });options = {resolution: '1',onSelectionChange: onSelectionChange,onClick: getGif,valid: true,- resolutions: models.proj.selected.id === 'geographic' ? resolutionsGeo : resolutionsPolar,+ resolutions:+ models.proj.selected.id === 'geographic'+ ? resolutionsGeo+ : resolutionsPolar,onCheck: onchecked,startDate: null,endDate: null,@@ -129,7 +137,10 @@ export function animationGif(models, config, ui) {return {resolution: resolution,- resolutions: models.proj.selected.id === 'geographic' ? resolutionsGeo : resolutionsPolar,+ resolutions:+ models.proj.selected.id === 'geographic'+ ? resolutionsGeo+ : resolutionsPolar,valid: fileSizeValid(),fileSizeEstimate: lodashRound(requestSize / conversionConstant, 3),requestSize: lodashRound(requestSize, 3),@@ -146,20 +157,35 @@ export function animationGif(models, config, ui) {if (!animationCoordinates) return;var numDays, stateObj, dimensions, isGeoProjection;- isGeoProjection = (models.proj.selected.id === 'geographic');+ isGeoProjection = models.proj.selected.id === 'geographic';resolution = selectedRes;stateObj = animModel.rangeState;- numDays = util.getNumberOfDays(new Date(stateObj.startDate), new Date(stateObj.endDate), ui.anim.ui.getInterval());+ numDays = util.getNumberOfDays(+ new Date(stateObj.startDate),+ new Date(stateObj.endDate),+ ui.anim.ui.getInterval()+ );if (!resolution) {let currentZoom = Math.round(ui.map.selected.getView().getZoom());- resolution = imageUtilCalculateResolution(currentZoom, isGeoProjection, models.proj.selected.resolutions);+ resolution = imageUtilCalculateResolution(+ currentZoom,+ isGeoProjection,+ models.proj.selected.resolutions+ );}dimensions = getDimensions(lonlats, models.proj.selected.id, resolution);imgWidth = dimensions[0];imgHeight = dimensions[1];- requestSize = calulateFileSize(resolution, lonlats[0], lonlats[1], numDays, imgWidth, imgHeight);+ requestSize = calulateFileSize(+ resolution,+ lonlats[0],+ lonlats[1],+ numDays,+ imgWidth,+ imgHeight+ );updatePanel(getUpdatedProps());throttleSetDownloadButton();};@@ -169,11 +195,14 @@ export function animationGif(models, config, ui) {};var onSelectionChange = function(selectedRes) {- update(selectedRes, imageUtilGetCoordsFromPixelValues(animationCoordinates, ui.map.selected));+ update(+ selectedRes,+ imageUtilGetCoordsFromPixelValues(animationCoordinates, ui.map.selected)+ );};var fileSizeValid = function() {- return (requestSize < maxGifSize && imgHeight !== 0 && imgWidth !== 0);+ return requestSize < maxGifSize && imgHeight !== 0 && imgWidth !== 0;};var setDownloadButtonClass = function() {@@ -220,9 +249,11 @@ export function animationGif(models, config, ui) {var buildProgressBar = function() {$progress = $('<progress />') // display progress for GIF creation.attr('class', 'wv-gif-progress');- wvui.getDialog()+ wvui+ .getDialog().append($progress)- .dialog({ // dialog for progress+ .dialog({+ // dialog for progresstitle: 'Collecting Images...',width: 300,height: 100@@ -237,46 +268,52 @@ export function animationGif(models, config, ui) {buildProgressBar();progressing = true;uiIndicator.hide(loader);- $progress.parent()- .dialog('option', 'title', 'Creating GIF...'); // set dialog title+ $progress.parent().dialog('option', 'title', 'Creating GIF...'); // set dialog title}$progress.attr('value', captureProgress / 100); // before value set, it is in indeterminate state};imageArra = getImageArray(startDate, endDate, interval);- if (!imageArra) { // won't be true if there are too mant frames+ if (!imageArra) {+ // won't be true if there are too mant framesreturn;}- gifStream.createGIF({- 'gifWidth': imgWidth,- 'gifHeight': imgHeight,- 'images': imageArra,- 'waterMarkXCoordinate': stampHeight * 0.01, // Margin based on GIF Height- 'waterMarkYCoordinate': stampHeight * 0.01, // Margin based on GIF Height- 'waterMarkHeight': stamp.height,- 'waterMark': stampHeight > 20 ? stamp : null,- 'waterMarkWidth': stamp.width,- 'fontSize': dateStamp.fontSize + 'px',- 'textXCoordinate': dateStamp.x,- 'textYCoordinate': dateStamp.y, // date location based on Dimensions- 'textAlign': dateStamp.align, // If textXCoordinate is null this takes precedence- 'textBaseline': 'top', // If textYCoordinate is null this takes precedence- 'fontColor': '#fff',- 'fontWeight': '300',- 'fontFamily': 'Open Sans, sans-serif',- 'progressCallback': onGifProgress,- 'showFrameText': stampHeight > 20,- 'extraLastFrameDelay': 1000,- 'text': '',- 'stroke': {- 'color': '#000',- 'pixels': dateStamp.fontSize * 0.05+ gifStream.createGIF(+ {+ gifWidth: imgWidth,+ gifHeight: imgHeight,+ images: imageArra,+ waterMarkXCoordinate: stampHeight * 0.01, // Margin based on GIF Height+ waterMarkYCoordinate: stampHeight * 0.01, // Margin based on GIF Height+ waterMarkHeight: stamp.height,+ waterMark: stampHeight > 20 ? stamp : null,+ waterMarkWidth: stamp.width,+ fontSize: dateStamp.fontSize + 'px',+ textXCoordinate: dateStamp.x,+ textYCoordinate: dateStamp.y, // date location based on Dimensions+ textAlign: dateStamp.align, // If textXCoordinate is null this takes precedence+ textBaseline: 'top', // If textYCoordinate is null this takes precedence+ fontColor: '#fff',+ fontWeight: '300',+ fontFamily: 'Open Sans, sans-serif',+ progressCallback: onGifProgress,+ showFrameText: stampHeight > 20,+ extraLastFrameDelay: 1000,+ text: '',+ stroke: {+ color: '#000',+ pixels: dateStamp.fontSize * 0.05+ },+ pause: 1},- 'pause': 1- }, onGifComplete);+ onGifComplete+ );};stampProps = getStampProps(stampWidthRatio, breakPointOne, stampWidth);- newImage = svgToPng('brand/images/wv-logo-w-shadow.svg', stampProps.stampHeight);+ newImage = svgToPng(+ 'brand/images/wv-logo-w-shadow.svg',+ stampProps.stampHeight+ );build(newImage, stampProps.dateStamp, stampProps.stampHeight);};@@ -304,17 +341,31 @@ export function animationGif(models, config, ui) {var stampHeightByImageWidth;// Set Logo-stamp dimensions based upon smallest total image dimensionif (lastRequestedDimensions.w < breakPoint) {- stampHeight = (imgWidth * 0.70) / stampWidthRatio < 60 ? ((imgWidth * 0.70) / stampWidthRatio) : 60;- dateStamp.fontSize = lastRequestedDimensions.h > (stampHeight * 1.5) ? lodashRound(stampHeight * 0.65) : 0;+ stampHeight =+ (imgWidth * 0.7) / stampWidthRatio < 60+ ? (imgWidth * 0.7) / stampWidthRatio+ : 60;+ dateStamp.fontSize =+ lastRequestedDimensions.h > stampHeight * 1.5+ ? lodashRound(stampHeight * 0.65)+ : 0;dateStamp.align = 'left';dateStamp.x = imgWidth * 0.01;- dateStamp.y = (imgHeight - (dateStamp.fontSize + (imgHeight * 0.01)) - 4);+ dateStamp.y = imgHeight - (dateStamp.fontSize + imgHeight * 0.01) - 4;} else {stampWidth = imgWidth * 0.4;stampHeightByImageWidth = stampWidth / stampWidthRatio;- stampHeight = stampHeightByImageWidth < 20 ? 20 : stampHeightByImageWidth > 60 ? 60 : stampHeightByImageWidth;- dateStamp.fontSize = lastRequestedDimensions.h > (stampHeight * 1.5) ? lodashRound(stampHeight * 0.65) : 0;- dateStamp.y = (imgHeight - (dateStamp.fontSize + (imgHeight * 0.01)) - 4);+ stampHeight =+ stampHeightByImageWidth < 20+ ? 20+ : stampHeightByImageWidth > 60+ ? 60+ : stampHeightByImageWidth;+ dateStamp.fontSize =+ lastRequestedDimensions.h > stampHeight * 1.5+ ? lodashRound(stampHeight * 0.65)+ : 0;+ dateStamp.y = imgHeight - (dateStamp.fontSize + imgHeight * 0.01) - 4;dateStamp.x = imgWidth * 0.01;dateStamp.align = 'left';}@@ -350,9 +401,12 @@ export function animationGif(models, config, ui) {});return;}- if (lodashFind(layers, {- id: 'Graticule'- }) && models.proj.selected.id === 'geographic') {+ if (+ lodashFind(layers, {+ id: 'Graticule'+ }) &&+ models.proj.selected.id === 'geographic'+ ) {wvui.ask({header: 'Notice',message: GRATICULE_WARNING,@@ -363,8 +417,7 @@ export function animationGif(models, config, ui) {});return;}- if (ui.map.selected.getView()- .getRotation() !== 0.0) {+ if (ui.map.selected.getView().getRotation() !== 0.0) {wvui.ask({header: 'Reset rotation?',message: ROTATE_WARNING,@@ -389,13 +442,13 @@ export function animationGif(models, config, ui) {* @returns {array} array of layer objects**/- var getProducts = function (date) {+ var getProducts = function(date) {var layers = [];var products = models.layers.get({reverse: true,renderable: true});- lodashEach(products, function (layer) {+ lodashEach(products, function(layer) {let layerDate = new Date(date);if (layer.endDate) {if (layerDate > new Date(layer.endDate)) return;@@ -421,8 +474,12 @@ export function animationGif(models, config, ui) {var getDimensions = function(lonlat, proj, res) {var conversionFactor = proj === 'geographic' ? 0.002197 : 256;return [- Math.round((Math.abs(lonlat[1][0] - lonlat[0][0]) / conversionFactor) / Number(res)), // width- Math.round((Math.abs(lonlat[1][1] - lonlat[0][1]) / conversionFactor) / Number(res)) // height+ Math.round(+ Math.abs(lonlat[1][0] - lonlat[0][0]) / conversionFactor / Number(res)+ ), // width+ Math.round(+ Math.abs(lonlat[1][1] - lonlat[0][1]) / conversionFactor / Number(res)+ ) // height];};@@ -448,7 +505,10 @@ export function animationGif(models, config, ui) {var j = 0;var src;var strDate;- var lonlat = imageUtilGetCoordsFromPixelValues(animationCoordinates, ui.map.selected);+ var lonlat = imageUtilGetCoordsFromPixelValues(+ animationCoordinates,+ ui.map.selected+ );var layers;var proj = models.proj.selected.id;var opacities;@@ -475,7 +535,25 @@ export function animationGif(models, config, ui) {layers = imageUtilGetLayers(products, proj);opacities = imageUtilGetLayerOpacities(products);- url = util.format(host + '/' + path + '?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}', 'TIME={1}', lonlat[0][0] + ',' + lonlat[0][1] + ',' + lonlat[1][0] + ',' + lonlat[1][1], epsg, layers.join(','), opacities.join(','), imgWidth, imgHeight);+ url = util.format(+ host ++ '/' ++ path ++ '?{1}&extent={2}&epsg={3}&layers={4}&opacities={5}&worldfile=false&format=image/jpeg&width={6}&height={7}',+ 'TIME={1}',+ lonlat[0][0] ++ ',' ++ lonlat[0][1] ++ ',' ++ lonlat[1][0] ++ ',' ++ lonlat[1][1],+ epsg,+ layers.join(','),+ opacities.join(','),+ imgWidth,+ imgHeight+ );src = util.format(url, strDate);a.push({src: src,@@ -488,7 +566,8 @@ export function animationGif(models, config, ui) {intervalAmount = 1;}current = util.dateAdd(current, ui.anim.ui.getInterval(), intervalAmount);- if (j > 40) { // too many frames+ if (j > 40) {+ // too many framesshowUnavailableReason();uiIndicator.hide(loader);@@ -509,11 +588,12 @@ export function animationGif(models, config, ui) {**/var showUnavailableReason = function() {- var headerMsg = "<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";- var bodyMsg = 'Too many frames were selected. Please request less than 40 frames if you would like to generate a GIF';+ var headerMsg =+ "<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";+ var bodyMsg =+ 'Too many frames were selected. Please request less than 40 frames if you would like to generate a GIF';var callback = function() {- $('#timeline-footer')- .toggleClass('wv-anim-active');+ $('#timeline-footer').toggleClass('wv-anim-active');};wvui.notify(headerMsg + bodyMsg, 'Notice', 600, callback);};@@ -529,11 +609,10 @@ export function animationGif(models, config, ui) {**/var resetRotation = function() {- ui.map.selected.getView()- .animate({- duration: 400,- rotation: 0- });+ ui.map.selected.getView().animate({+ duration: 400,+ rotation: 0+ });};/*@@ -548,7 +627,8 @@ export function animationGif(models, config, ui) {* @returns {void}**/- var onGifComplete = function(obj) { // callback function for when image is finished+ var onGifComplete = function(obj) {+ // callback function for when image is finished$('#timeline-footer').removeClass('wv-anim-active');models.anim.rangeState.state = 'off';if (!obj.error) {@@ -558,21 +638,34 @@ export function animationGif(models, config, ui) {var animatedImage = document.createElement('img');const blobURL = URL.createObjectURL(blob);animatedImage.src = blobURL;- animatedImage.width = lastRequestedDimensions.w > window.innerWidth - 198 ? window.innerWidth - 198 : lastRequestedDimensions.w;- animatedImage.height = lastRequestedDimensions.h > window.innerHeight - 120 ? window.innerHeight - 120 : lastRequestedDimensions.h;- var dlURL = util.format('nasa-worldview-{1}-to-{2}.gif', animModel.rangeState.startDate, animModel.rangeState.endDate);- var downloadSize = lodashRound((blob.size / 1024 * 0.001), 2);+ animatedImage.width =+ lastRequestedDimensions.w > window.innerWidth - 198+ ? window.innerWidth - 198+ : lastRequestedDimensions.w;+ animatedImage.height =+ lastRequestedDimensions.h > window.innerHeight - 120+ ? window.innerHeight - 120+ : lastRequestedDimensions.h;+ var dlURL = util.format(+ 'nasa-worldview-{1}-to-{2}.gif',+ animModel.rangeState.startDate,+ animModel.rangeState.endDate+ );+ var downloadSize = lodashRound((blob.size / 1024) * 0.001, 2);// Create download link and apply button CSS- var $download = $('<button><span class=ui-button-text>Download</span></button>')+ var $download = $(+ '<button><span class=ui-button-text>Download</span></button>'+ ).attr('class', 'wv-button')- .hover(function() {- $(this)- .addClass('ui-state-hover');- }, function() {- $(this)- .removeClass('ui-state-hover');- })+ .hover(+ function() {+ $(this).addClass('ui-state-hover');+ },+ function() {+ $(this).removeClass('ui-state-hover');+ }+ ).click(function(e) {e.preventDefault();FileSaver.saveAs(blob, dlURL);@@ -580,13 +673,16 @@ export function animationGif(models, config, ui) {});var $catalog =- "<div class='gif-results-dialog' style='height: " + animatedImage.height + "px; min-height: 210px;' >" ++ "<div class='gif-results-dialog' style='height: " ++ animatedImage.height ++ "px; min-height: 210px;' >" +'<div>' +'<div><b>' +'Size: ' +'</b></div>' +'<div>' +- downloadSize + ' MB' ++ downloadSize ++ ' MB' +'</div>' +'</div>' +'<div>' +@@ -594,9 +690,9 @@ export function animationGif(models, config, ui) {'Speed: ' +'</b></div>' +'<div>' +- animModel.rangeState.speed + ' fps' ++ animModel.rangeState.speed ++ ' fps' +'</div>' +-'</div>' +'<div>' +'<div><b>' +@@ -619,7 +715,6 @@ export function animationGif(models, config, ui) {'<div>' +lodashCapitalize(ui.anim.widget.getIncrements()) +'</div>' +-'</div>' +'</div>';var $dialogBodyCase = $('<div></div>');@@ -629,12 +724,18 @@ export function animationGif(models, config, ui) {$dialogBodyCase.append($catalog);// calculate the offset of the dialog position based on image size to display it properly// only height needs to be adjusted to center the dialog- var posWidth = lastRequestedDimensions.w * 1 / window.innerWidth;- var posHeight = lastRequestedDimensions.h * 50 / window.innerHeight;- var atString = 'center-' + posWidth.toFixed() + '% center-' + posHeight.toFixed() + '%';+ var posWidth = (lastRequestedDimensions.w * 1) / window.innerWidth;+ var posHeight = (lastRequestedDimensions.h * 50) / window.innerHeight;+ var atString =+ 'center-' ++ posWidth.toFixed() ++ '% center-' ++ posHeight.toFixed() ++ '%';// Create a dialog over the view and place the image there- var $imgDialog = wvui.getDialog()+ var $imgDialog = wvui+ .getDialog().append($dialogBodyCase).append($download);$imgDialog.dialog({@@ -645,25 +746,25 @@ export function animationGif(models, config, ui) {maxWidth: window.innerWidth,maxHeight: window.innerHeight,close: function() {- $imgDialog.find('img')- .remove();+ $imgDialog.find('img').remove();models.anim.rangeState.state = 'on';- $('#timeline-footer')- .toggleClass('wv-anim-active');+ $('#timeline-footer').toggleClass('wv-anim-active');},- position: { // based on image size+ position: {+ // based on image sizemy: 'center center',at: atString,of: window}});} else {- var headerMsg = "<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";- var bodyMsg = 'One or more of the frames requested was unable to be processed';+ var headerMsg =+ "<h3 class='wv-data-unavailable-header'>GIF Not Available</h3>";+ var bodyMsg =+ 'One or more of the frames requested was unable to be processed';uiIndicator.hide(loader);var callback = function() {- $('#timeline-footer')- .toggleClass('wv-anim-active');+ $('#timeline-footer').toggleClass('wv-anim-active');};wvui.notify(headerMsg + bodyMsg, 'Notice', 600, callback);}@@ -711,11 +812,9 @@ export function animationGif(models, config, ui) {};var onCloseSelector = function() {- $('#wv-map')- .insertAfter('#productsHolder'); // retain map element before disabling jcrop+ $('#wv-map').insertAfter('#productsHolder'); // retain map element before disabling jcropjcropAPI.destroy();- $('#timeline-footer')- .toggleClass('wv-anim-active');+ $('#timeline-footer').toggleClass('wv-anim-active');if (models.proj.selected.id === 'geographic') {ui.map.events.trigger('selectiondone');}@@ -733,15 +832,26 @@ export function animationGif(models, config, ui) {* @returns {number} Size of frame**/- var calulateFileSize = function(imgRes, lonlat1, lonlat2, numDays, imgWidth, imgHeight) {+ var calulateFileSize = function(+ imgRes,+ lonlat1,+ lonlat2,+ numDays,+ imgWidth,+ imgHeight+ ) {var conversionFactor;conversionFactor = imageUtilGetConversionFactor(models.proj.selected.id);resolution = imgRes;- imgWidth = Math.round((Math.abs(lonlat2[0] - lonlat1[0]) / conversionFactor) / Number(imgRes));- imgHeight = Math.round((Math.abs(lonlat2[1] - lonlat1[1]) / conversionFactor) / Number(imgRes));+ imgWidth = Math.round(+ Math.abs(lonlat2[0] - lonlat1[0]) / conversionFactor / Number(imgRes)+ );+ imgHeight = Math.round(+ Math.abs(lonlat2[1] - lonlat1[1]) / conversionFactor / Number(imgRes)+ );- return (((imgWidth * imgHeight * 24) / 8388608).toFixed(2) * numDays);+ return ((imgWidth * imgHeight * 24) / 8388608).toFixed(2) * numDays;};/*@@ -756,8 +866,7 @@ export function animationGif(models, config, ui) {**/var removeCrop = function() {- $('#wv-map')- .insertAfter('#productsHolder'); // retain map element before disabling jcrop+ $('#wv-map').insertAfter('#productsHolder'); // retain map element before disabling jcropanimationCoordinates = undefined;jcropAPI.destroy();if (models.proj.selected.id === 'geographic') {@@ -821,7 +930,9 @@ export function animationGif(models, config, ui) {**/var setIconFontSize = function($el, width) {- if (!$el) { return; }+ if (!$el) {+ return;+ }var fontSize = Math.abs(width / 4); // Font size is 25% widthfontSize = fontSize < 30 ? 30 : fontSize > 100 ? 100 : fontSize; // Set max and min font-size@@ -831,7 +942,8 @@ export function animationGif(models, config, ui) {var onBoundingBoxChange = function(c, $dialog, $dlButton) {animationCoordinates = c;- if (c.h !== 0 && c.w !== 0) { // don't save coordinates if empty selection+ if (c.h !== 0 && c.w !== 0) {+ // don't save coordinates if empty selectionpreviousCoords = c;}// var dataSize = calcSize(c);@@ -857,18 +969,28 @@ export function animationGif(models, config, ui) {var $dialog;// Set JCrop selectionif (previousCoords === null || previousCoords === undefined) {- previousCoords = [($(window)- .width() / 2) - 100, ($(window)- .height() / 2) - 100, ($(window)- .width() / 2) + 100, ($(window)- .height() / 2) + 100];- } else { previousCoords = [previousCoords.x, previousCoords.y, previousCoords.x2, previousCoords.y2]; }-- if (models.proj.selected.id === 'geographic') { ui.map.events.trigger('selecting'); }+ previousCoords = [+ $(window).width() / 2 - 100,+ $(window).height() / 2 - 100,+ $(window).width() / 2 + 100,+ $(window).height() / 2 + 100+ ];+ } else {+ previousCoords = [+ previousCoords.x,+ previousCoords.y,+ previousCoords.x2,+ previousCoords.y2+ ];+ }++ if (models.proj.selected.id === 'geographic') {+ ui.map.events.trigger('selecting');+ }starterWidth = previousCoords[0] - previousCoords[2];// Start the image cropping. Show the dialog- $('#wv-map')- .Jcrop({+ $('#wv-map').Jcrop(+ {bgColor: 'black',bgOpacity: 0.3,fullScreen: true,@@ -878,7 +1000,13 @@ export function animationGif(models, config, ui) {},onChange: function(e) {onBoundingBoxChange(e, $dialog, $dlButton);- update(resolution, imageUtilGetCoordsFromPixelValues(animationCoordinates, ui.map.selected));+ update(+ resolution,+ imageUtilGetCoordsFromPixelValues(+ animationCoordinates,+ ui.map.selected+ )+ );},onRelease: function() {removeCrop();@@ -886,25 +1014,29 @@ export function animationGif(models, config, ui) {wvui.close();}}- }, function() {+ },+ function() {var $tracker;$dlButton ="<div class='wv-dl-gif-bt-case'>" +"<i class='fa fa-download'>" +'</div>';jcropAPI = this;- $('#timeline-footer')- .toggleClass('wv-anim-active');+ $('#timeline-footer').toggleClass('wv-anim-active');$dialog = getSelectorDialog(342);$tracker = this.ui.selection.find('.jcrop-tracker');$tracker.append($dlButton);$dlButton = $('.wv-dl-gif-bt-case i');setIconFontSize($dlButton, starterWidth);$dlButton.on('click', getGif);- });+ }+ );- update(null, imageUtilGetCoordsFromPixelValues(animationCoordinates, ui.map.selected));+ update(+ null,+ imageUtilGetCoordsFromPixelValues(animationCoordinates, ui.map.selected)+ );};self.init();return self;-};+}diff --git a/web/js/animation/range-select.js b/web/js/animation/range-select.jsindex e0bcfdcd6..770d30a74 100644--- a/web/js/animation/range-select.js+++ b/web/js/animation/range-select.js@@ -1,7 +1,7 @@import $ from 'jquery';import React from 'react';import ReactDOM from 'react-dom';-import { RangeSelector } from 'worldview-components';+import RangeSelector from '../components/range-selection/range-selection';import d3 from 'd3';import util from '../util/util';diff --git a/web/js/animation/widget.js b/web/js/animation/widget.jsindex 8e059ba8a..6d439bf1b 100644--- a/web/js/animation/widget.js+++ b/web/js/animation/widget.js@@ -1,5 +1,6 @@import $ from 'jquery';-import { AnimationWidget, GA as googleAnalytics } from 'worldview-components';+import AnimationWidget from '../components/animation-widget/animation-widget';+import googleAnalytics from '../components/util/google-analytics';import React from 'react';import ReactDOM from 'react-dom';import lodashWithout from 'lodash/without';diff --git a/web/js/components/animation-widget/animation-widget.js b/web/js/components/animation-widget/animation-widget.jsnew file mode 100644index 000000000..937a429c1--- /dev/null+++ b/web/js/components/animation-widget/animation-widget.js@@ -0,0 +1,201 @@+import React from 'react';+import PropTypes from 'prop-types';+import InputRange from 'react-input-range';+import TimeSelector from '../date-selector/date-selector';+import LoopButton from './loop-button';+import PlayButton from './play-button';+import AnimWidgetHeader from './header';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class AnimationWidget+ * @extends React.Component+ */+class AnimationWidget extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ value: props.sliderSpeed,+ looping: props.looping,+ startDate: props.startDate,+ endDate: props.endDate,+ maxZoom: props.maxZoom,+ header: props.header,+ incrementArray: props.incrementArray,+ increment: props.increment+ };+ }++ /*+ * Sets a new state value when a+ * when the slider is adjusted+ *+ * @method onSlide+ *+ * @param {number} value - Value of the slider+ * selection+ *+ * @return {void}+ */+ onSlide(value) {+ this.props.onSlide(value);+ this.setState({+ value: value+ });+ }++ /*+ * calls the callback, passing the+ * current state elements as parameters+ *+ * @method play+ *+ * @return {void}+ */+ play() {+ this.props.onPushPlay();+ this.setState({+ playing: true+ });+ }+ pause() {+ this.props.onPushPause();+ this.setState({+ playing: false+ });+ }+ /*+ * Sets a new state to say whether or not+ * the animation should loop+ *+ * @method onLoop+ *+ * @param {Object} component - slider react+ * component+ * @param {number} value - Value of the slider+ * selection+ *+ * @return {void}+ */+ onLoop() {+ var loop = true;+ if (this.state.looping) {+ loop = false;+ }+ this.setState({+ looping: loop+ });+ this.props.onPushLoop(loop);+ }+ onDateChange(date, id) {+ const { endDate, startDate } = this.state;+ if (id === 'start') {+ this.setState({+ startDate: date+ });+ this.props.onDateChange(date, endDate);+ } else {+ this.setState({+ endDate: date+ });+ this.props.onDateChange(startDate, date);+ }+ }+ render() {+ return (+ <div+ id="wv-animation-widget"+ className={+ 'wv-animation-widget' + (this.state.maxZoom >= 4 ? ' subdaily' : '')+ }+ >+ <AnimWidgetHeader+ text={this.state.increment}+ toolTipTextArray={this.state.incrementArray}+ onClick={this.props.onZoomSelect}+ />++ <PlayButton+ playing={this.state.playing}+ play={this.play.bind(this)}+ pause={this.pause.bind(this)}+ />+ <LoopButton+ looping={this.state.looping}+ onLoop={this.onLoop.bind(this)}+ />+ <div className="wv-slider-case">+ <InputRange+ step={0.5}+ maxValue={10}+ minValue={0.5}+ value={this.state.value}+ onChange={this.onSlide.bind(this)}+ />+ <span className="wv-slider-label">{this.props.sliderLabel}</span>+ </div>++ <a+ href="javascript:void(null)"+ title="Create Animated GIF"+ className="wv-icon-case"+ onClick={this.props.onPushGIF}+ >+ <i className="fa fa-file-video-o wv-animation-widget-icon" />+ </a>+ <div className="wv-anim-dates-case">+ <TimeSelector+ width="120"+ height="30"+ date={this.state.startDate}+ id="start"+ idSuffix="animation-widget-start"+ onDateChange={this.onDateChange.bind(this)}+ maxDate={this.state.endDate}+ minDate={this.props.minDate}+ maxZoom={this.state.maxZoom}+ />+ <div className="thru-label">To</div>+ <TimeSelector+ width="120"+ height="30"+ date={this.state.endDate}+ id="end"+ idSuffix="animation-widget-end"+ onDateChange={this.onDateChange.bind(this)}+ maxDate={this.props.maxDate}+ minDate={this.state.startDate}+ maxZoom={this.state.maxZoom}+ />+ </div>+ <i className="fa fa-close wv-close" onClick={this.props.onClose} />+ </div>+ );+ }+}++AnimationWidget.propTypes = {+ sliderSpeed: PropTypes.number,+ looping: PropTypes.bool,+ startDate: PropTypes.object,+ endDate: PropTypes.object,+ header: PropTypes.element,+ incrementArray: PropTypes.array,+ increment: PropTypes.string,+ onSlide: PropTypes.func,+ onPushPlay: PropTypes.func,+ onPushPause: PropTypes.func,+ onPushLoop: PropTypes.func,+ onDateChange: PropTypes.func,+ onZoomSelect: PropTypes.func,+ sliderLabel: PropTypes.string,+ onPushGIF: PropTypes.func,+ minDate: PropTypes.object,+ maxDate: PropTypes.object,+ maxZoom: PropTypes.number,+ onClose: PropTypes.func+};++export default AnimationWidget;diff --git a/web/js/components/animation-widget/gif-panel-grid.js b/web/js/components/animation-widget/gif-panel-grid.jsnew file mode 100644index 000000000..447331527--- /dev/null+++ b/web/js/components/animation-widget/gif-panel-grid.js@@ -0,0 +1,65 @@+import React from 'react';+import PropTypes from 'prop-types';+/*+ * A table that updates with image+ * data+ *+ * @class ResolutionTable+ * @extends React.Component+ */+export class GifPanelGrid extends React.Component {+ renderImageSize() {+ var size = this.props.requestSize;+ if (!this.props.valid) {+ return (+ <div id='gif-size' className='gif-size gif-size-invalid grid-child'>+ <i className='fa fa-times fa-fw' />+ <span>{'~' + size + ' MB (Before Compression)'}</span>+ </div>+ );+ } else {+ return (+ <div id='gif-size' className='gif-size grid-child'>+ <span>{'~' + size + ' MB (Before Compression)'} </span>+ </div>+ );+ }+ }+ render() {+ let imageSize = this.renderImageSize();+ return (+ <div className='gif-download-grid'>+ <div className='grid-child label'><span>Start Date: </span></div>+ <div className='grid-child'><span>{this.props.startDate} </span></div>+ <div className='grid-child label'><span>End Date: </span></div>+ <div className='grid-child'><span>{this.props.endDate}</span></div>+ <div className='grid-child label'><span>Speed: </span></div>+ <div className='grid-child'><span>{this.props.speed + ' Frames Per Second'}</span></div>+ <div className='grid-child label'><span>Increment:</span></div>+ <div className='grid-child'><span>{this.props.increment}</span></div>+ <div className='grid-child label'><span>Request Size:</span></div>+ {imageSize}+ <div className='grid-child label'><span>Max Request Size: </span></div>+ <div className={this.props.valid ? 'grid-child gif-max-size' : 'grid-child gif-max-size gif-size-invalid'}>+ <span>{this.props.maxGifSize + ' MB (Before Compression)'}</span>+ </div>+ <div className='grid-child label'><span>Image Dimensions:</span></div>+ <div className='grid-child' id='wv-image-width'>+ <span>{this.props.width + ' x ' + this.props.height + 'px' }</span>+ </div>+ </div>+ );+ }+}+GifPanelGrid.propTypes = {+ width: PropTypes.number,+ height: PropTypes.number,+ maxGifSize: PropTypes.number,+ startDate: PropTypes.string,+ endDate: PropTypes.string,+ speed: PropTypes.number,+ valid: PropTypes.bool,+ requestSize: PropTypes.number,+ fileSizeEstimate: PropTypes.number,+ increment: PropTypes.string+};diff --git a/web/js/components/animation-widget/gif-panel.js b/web/js/components/animation-widget/gif-panel.jsnew file mode 100644index 000000000..9961470f7--- /dev/null+++ b/web/js/components/animation-widget/gif-panel.js@@ -0,0 +1,103 @@+import React from 'react';+import SelectionList from '../util/selector';+import { GifPanelGrid } from './gif-panel-grid';+import Button from '../util/button';+import {Checkbox} from '../util/checkbox';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class resolutionSelection+ * @extends React.Component+ */+export default class GifPanel extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ imgHeight: props.imgHeight,+ imgWidth: props.imgWidth,+ speed: props.speed,+ resolutions: props.resolutions,+ onSelectionChange: props.onSelectionChange,+ resolution: props.resolution,+ valid: props.valid,+ showDates: props.showDates,+ increment: props.increment+ };+ }+ handleChange(type, value) {+ this.setState({+ resolution: value+ });+ this.props.onSelectionChange(value);+ }+ render() {+ return (+ <div className="animation-gif-dialog-wrapper">+ <div className='gif-selector-case'>+ {this.props.firstLabel}+ <SelectionList+ id='gif-resolution'+ optionArray={this.state.resolutions}+ value={this.state.resolution}+ optionName='resolution'+ onChange={this.handleChange.bind(this)}+ />+ </div>+ <GifPanelGrid+ width={this.state.imgWidth}+ height={this.state.imgHeight}+ requestSize={this.state.requestSize}+ maxGifSize={this.props.maxGifSize}+ valid={this.state.valid}+ onClick={this.props.onDownloadClick}+ startDate={this.state.startDate}+ endDate={this.state.endDate}+ speed={this.state.speed}+ increment={this.state.increment}+ />+ <Button+ onClick={this.props.onClick}+ text='Create GIF'+ valid={this.state.valid}+ />+ <Checkbox+ id="wv-checkbox-gif"+ classNames="wv-checkbox-gif"+ title='Check box to remove dates from Animating GIF'+ checked={this.props.checked}+ onCheck={this.props.onCheck}+ label='Include Date Stamps'+ />+ </div>+ );+ }+}++GifPanel.defaultProps = {+ firstLabel: 'Resolution (per pixel):',+ secondLabel: 'Format',+ maxGifSize: 20,+ showDates: true+};+GifPanel.propTypes = {+ firstLabel: PropTypes.string,+ secondLabel: PropTypes.string,+ imgWidth: PropTypes.number,+ imgHeight: PropTypes.number,+ maxGifSize: PropTypes.number,+ showDates: PropTypes.bool,+ onDownloadClick: PropTypes.func,+ onClick: PropTypes.func,+ onCheck: PropTypes.func,+ checked: PropTypes.bool,+ onSelectionChange: PropTypes.func,+ resolutions: PropTypes.object,+ requestSize: PropTypes.string,+ resolution: PropTypes.string,+ speed: PropTypes.number,+ valid: PropTypes.bool,+ increment: PropTypes.string+};diff --git a/web/js/components/animation-widget/header.js b/web/js/components/animation-widget/header.jsnew file mode 100644index 000000000..614d8e3de--- /dev/null+++ b/web/js/components/animation-widget/header.js@@ -0,0 +1,30 @@+import React from 'react';+import PropTypes from 'prop-types';+import Tooltip from '../tooltip/tooltip';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class AnimationWidget+ * @extends React.Component+ */+class animWidgetHeader extends React.Component {+ render() {+ return (+ <div className='wv-animation-widget-header'>+ {'Animate Map in '}+ <Tooltip text={this.props.text} onClick={this.props.onClick} dataArray={this.props.toolTipTextArray}/>+ {' Increments'}+ </div>+ );+ }+}++animWidgetHeader.propTypes = {+ text: PropTypes.string,+ onClick: PropTypes.func,+ toolTipTextArray: PropTypes.array+};++export default animWidgetHeader;diff --git a/web/js/components/animation-widget/loop-button.js b/web/js/components/animation-widget/loop-button.jsnew file mode 100644index 000000000..2326f1054--- /dev/null+++ b/web/js/components/animation-widget/loop-button.js@@ -0,0 +1,30 @@+import React from 'react';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class AnimationWidget+ * @extends React.Component+ */+class LoopButton extends React.Component {+ render() {+ return (+ <a href="javascript:void(null)"+ title={this.props.looping ? 'Stop Loop' : 'Loop video'}+ className={this.props.looping ? 'wv-loop-icon-case wv-icon-case active' : 'wv-loop-icon-case wv-icon-case'}+ onClick={this.props.onLoop}+ >+ <i className='fa fa-retweet wv-animation-widget-icon' />+ </a>+ );+ }+}++LoopButton.propTypes = {+ looping: PropTypes.bool,+ onLoop: PropTypes.func+};++export default LoopButton;diff --git a/web/js/components/animation-widget/play-button.js b/web/js/components/animation-widget/play-button.jsnew file mode 100644index 000000000..e9fc9e8e8--- /dev/null+++ b/web/js/components/animation-widget/play-button.js@@ -0,0 +1,30 @@+import React from 'react';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class AnimationWidget+ * @extends React.Component+ */+class PlayButton extends React.Component {+ render() {+ return (+ <a href="javascript:void(null)" title={this.props.playing ? 'Pause video' : 'Play video'}+ className='wv-anim-play-case wv-icon-case'+ onClick={this.props.playing ? this.props.pause : this.props.play}+ >+ <i className={this.props.playing ? 'fa fa-pause wv-animation-widget-icon' : 'fa fa-play wv-animation-widget-icon'} />+ </a>+ );+ }+}++PlayButton.propTypes = {+ playing: PropTypes.bool,+ pause: PropTypes.func,+ play: PropTypes.func+};++export default PlayButton;diff --git a/web/js/components/compare/opacity-slider.js b/web/js/components/compare/opacity-slider.jsnew file mode 100644index 000000000..38720d075--- /dev/null+++ b/web/js/components/compare/opacity-slider.js@@ -0,0 +1,63 @@+import React from 'react';+import PropTypes from 'prop-types';+import InputRange from 'react-input-range';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class OpacitySlider+ * @extends React.Component+ */+class OpacitySlider extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ value: props.value+ };+ }++ /*+ * Sets a new state value when a+ * when the slider is adjusted+ *+ * @method onSlide+ *+ * @param {number} value - Value of the slider+ * selection+ *+ * @return {void}+ */+ onSlide(value) {+ this.props.onSlide(value);+ this.setState({+ value: value+ });+ }++ render() {+ return (+ <div id="ab-slider-case" className="ab-slider-case">+ <span className="wv-slider-label left">A</span>+ <InputRange+ step={5}+ maxValue={100}+ minValue={0}+ value={this.state.value}+ formatLabel={() => ''}+ onChange={this.onSlide.bind(this)}+ />+ <span className="wv-slider-label right">B</span>+ </div>+ );+ }+}+OpacitySlider.defaultProps = {+ value: 50+};+OpacitySlider.propTypes = {+ value: PropTypes.number,+ onSlide: PropTypes.func+};++export default OpacitySlider;diff --git a/web/js/components/date-selector/date-selector.js b/web/js/components/date-selector/date-selector.jsnew file mode 100644index 000000000..fd8f7d30d--- /dev/null+++ b/web/js/components/date-selector/date-selector.js@@ -0,0 +1,192 @@+import React from 'react';+import PropTypes from 'prop-types';+import DateInputColumn from './input';+import Util from '../util/util';++const util = new Util();++/*+ * A react component, is a draggable svg+ * group. It is a parent component that+ * rerenders when child elements are dragged+ *+ * @class TimelineRangeSelector+ */+class DateSelector extends React.Component {+ /*+ * @constructor+ */+ constructor(props) {+ super(props);+ this.state = {+ date: props.date,+ maxDate: props.maxDate,+ minDate: props.minDate,+ tab: null,+ maxZoom: props.maxZoom+ };+ }+ componentWillReceiveProps(props) {+ this.setState({+ date: props.date,+ maxDate: props.maxDate,+ minDate: props.minDate,+ maxZoom: props.maxZoom+ });+ }+ blur() {+ this.setState({ tab: null });+ }+ nextTab(index) {+ var nextTab;+ var maxTab;+ if (this.state.maxZoom >= 4) {+ maxTab = 5;+ } else {+ maxTab = 3;+ }+ if (index < maxTab) {+ nextTab = index + 1;+ } else {+ nextTab = 1;+ }+ this.setState({+ tab: nextTab+ });+ }+ updateDate(date) {+ this.setState({+ date: date+ });+ this.props.onDateChange(date, this.props.id);+ }+ renderSubdaily() {+ if (this.state.maxZoom >= 4) {+ return (+ <React.Fragment>+ <DateInputColumn+ step={1}+ startDate={new Date(2000)}+ today={new Date()}+ date={this.state.date}+ type="hour"+ inputId={this.props.idSuffix ? 'hour-' + this.props.idSuffix : ''}+ height={this.props.height}+ width={this.props.width}+ updateDate={this.updateDate.bind(this)}+ value={util.pad(this.state.date.getUTCHours(), 2, '0')}+ tabIndex={4}+ focused={this.state.tab === 4}+ nextTab={this.nextTab.bind(this)}+ maxDate={this.props.maxDate}+ minDate={this.props.minDate}+ blur={this.blur.bind(this)}+ fontSize={this.props.fontSize}+ />+ <div className="input-time-divider">:</div>+ <DateInputColumn+ step={10}+ startDate={new Date(2000)}+ today={new Date()}+ date={this.state.date}+ type="minute"+ height={this.props.height}+ width={this.props.width}+ updateDate={this.updateDate.bind(this)}+ value={util.pad(this.state.date.getUTCMinutes(), 2, '0')}+ inputId={this.props.idSuffix ? 'minute-' + this.props.idSuffix : ''}+ tabIndex={5}+ focused={this.state.tab === 5}+ nextTab={this.nextTab.bind(this)}+ maxDate={this.props.maxDate}+ minDate={this.props.minDate}+ blur={this.blur.bind(this)}+ fontSize={this.props.fontSize}+ />+ <div className="input-time-zmark">Z</div>+ </React.Fragment>+ );+ }+ }+ render() {+ return (+ <div className="wv-date-selector-widget">+ <DateInputColumn+ step={1}+ startDate={new Date(2000)}+ today={new Date()}+ date={this.state.date}+ value={this.state.date.getUTCFullYear()}+ type="year"+ height={this.props.height}+ width={this.props.width}+ updateDate={this.updateDate.bind(this)}+ inputId={this.props.idSuffix ? 'year-' + this.props.idSuffix : ''}+ tabIndex={1}+ focused={this.state.tab === 1}+ nextTab={this.nextTab.bind(this)}+ maxDate={this.props.maxDate}+ minDate={this.props.minDate}+ blur={this.blur.bind(this)}+ fontSize={this.props.fontSize}+ />+ <DateInputColumn+ step={1}+ startDate={new Date(2000)}+ today={new Date()}+ date={this.state.date}+ value={util.monthStringArray[this.state.date.getUTCMonth()]}+ type="month"+ inputId={this.props.idSuffix ? 'month-' + this.props.idSuffix : ''}+ height={this.props.height}+ width={this.props.width}+ updateDate={this.updateDate.bind(this)}+ tabIndex={2}+ focused={this.state.tab === 2}+ nextTab={this.nextTab.bind(this)}+ maxDate={this.props.maxDate}+ minDate={this.props.minDate}+ blur={this.blur.bind(this)}+ fontSize={this.props.fontSize}+ />+ <DateInputColumn+ step={1}+ startDate={new Date(2000)}+ today={new Date()}+ date={this.state.date}+ type="day"+ height={this.props.height}+ width={this.props.width}+ updateDate={this.updateDate.bind(this)}+ value={util.pad(this.state.date.getUTCDate(), 2, '0')}+ tabIndex={3}+ inputId={this.props.idSuffix ? 'day-' + this.props.idSuffix : ''}+ focused={this.state.tab === 3}+ nextTab={this.nextTab.bind(this)}+ maxDate={this.props.maxDate}+ minDate={this.props.minDate}+ blur={this.blur.bind(this)}+ fontSize={this.props.fontSize}+ />+ {this.renderSubdaily()}+ </div>+ );+ }+}+DateSelector.defaultProps = {+ fontSize: 15+};+DateSelector.propTypes = {+ date: PropTypes.object,+ maxDate: PropTypes.object,+ minDate: PropTypes.object,+ maxZoom: PropTypes.number,+ onDateChange: PropTypes.func,+ id: PropTypes.string,+ height: PropTypes.string,+ width: PropTypes.string,+ idSuffix: PropTypes.string,+ fontSize: PropTypes.number+};++export default DateSelector;diff --git a/web/js/components/date-selector/input.js b/web/js/components/date-selector/input.jsnew file mode 100644index 000000000..a75e0c564--- /dev/null+++ b/web/js/components/date-selector/input.js@@ -0,0 +1,301 @@+import React from 'react';+import PropTypes from 'prop-types';+import Util from '../util/util';++const util = new Util();++/*+ * A react component, is a draggable svg+ * group. It is a parent component that+ * rerenders when child elements are dragged+ *+ * @class TimelineRangeSelector+ */+class DateInputColumn extends React.Component {+ /*+ * @constructor+ */+ constructor(props) {+ super(props);+ this.state = {+ value: this.props.value,+ valid: true+ };+ this.inputs = [];+ }+ componentDidUpdate() {+ if (this.props.focused) {+ this.inputs[this.props.tabIndex].focus();+ }+ }+ componentWillMount() {+ var size;+ var type;+ type = this.props.type;+ if (type === 'year') {+ size = '4';+ } else if (type === 'day') {+ size = 2;+ } else {+ size = 3;+ }+ this.size = size;+ }+ componentWillReceiveProps(props) {+ this.setState({ value: props.value });+ }+ onKeyPress(e) {+ var kc = e.keyCode;+ if (+ kc === 9 || // tab+ kc === 13+ ) {+ // enter+ e.preventDefault();+ e.stopPropagation();+ }+ }+ onKeyUp(e) {+ var keyCode = e.keyCode;+ var value = e.target.value;+ var newDate;+ var entered = keyCode === 13 || keyCode === 9;+ if (keyCode === 38) {+ // up+ e.preventDefault();+ this.onClickUp();+ return;+ }+ if (keyCode === 40) {+ // down+ e.preventDefault();+ this.onClickDown();+ return;+ }+ if (e.type === 'focusout' || entered) {+ if (this.props.type === 'year' || this.props.type === 'day') {+ if (!((keyCode >= 48 && keyCode <= 57) || entered || keyCode === 8)) {+ return;+ }+ }+ switch (this.props.type) {+ case 'year':+ newDate = this.yearValidation(value);+ break;+ case 'month':+ newDate = this.monthValidation(value);+ break;+ case 'day':+ newDate = this.dayValidation(value);+ break;+ case 'hour':+ newDate = this.hourValidation(value);+ break;+ case 'minute':+ newDate = this.minuteValidation(value);+ break;+ }+ if (newDate) {+ this.props.updateDate(newDate);+ if (entered) {+ // if enetered or tabbed+ this.nextTab();+ }+ } else if (entered) {+ this.setState({+ valid: false+ });+ }+ }+ }+ onClickUp() {+ if (this.props.type === 'minute') {+ this.rollDate(10);+ } else {+ this.rollDate(1);+ }+ this.setState({+ valid: true+ });+ }+ onClickDown() {+ if (this.props.type === 'minute') {+ this.rollDate(-10);+ } else {+ this.rollDate(-1);+ }+ this.setState({+ valid: true+ });+ }+ yearValidation(input) {+ var newDate;+ if (input > 1000 && input < 9999) {+ newDate = new Date(new Date(this.props.date).setUTCFullYear(input));+ return this.validateDate(newDate);+ }+ }++ monthValidation(input) {+ var newDate;+ if (!isNaN(input) && input < 13 && input > 0) {+ newDate = new Date(new Date(this.props.date).setUTCMonth(input - 1));+ if (newDate) {+ this.setState({+ value: util.monthStringArray[input - 1]+ });+ return this.validateDate(newDate);+ }+ } else {+ let realMonth;+ realMonth = util.stringInArray(util.monthStringArray, input);+ if (realMonth !== false) {+ newDate = new Date(new Date(this.props.date).setUTCMonth(realMonth));+ return this.validateDate(newDate);+ } else {+ return false;+ }+ }+ }++ dayValidation(input) {+ var newDate;+ var maxDate;+ var currentDate = this.props.date;++ maxDate = new Date(+ currentDate.getYear(),+ currentDate.getMonth() + 1,+ 0+ ).getDate();++ if (input > 0 && input <= maxDate) {+ newDate = new Date(new Date(currentDate).setUTCDate(input));+ return this.validateDate(newDate);+ }+ }++ hourValidation(input) {+ var newDate;+ if (input >= 0 && input <= 23) {+ newDate = new Date(new Date(this.props.date).setUTCHours(input));+ return this.validateDate(newDate);+ }+ }++ minuteValidation(input) {+ var newDate;+ var coeff = 1000 * 60 * 10;+ if (input >= 0 && input <= 59) {+ newDate = new Date(+ Math.round(new Date(this.props.date).setUTCMinutes(input) / coeff) *+ coeff+ );+ return this.validateDate(newDate);+ }+ }++ rollDate(amt) {+ var newDate = util.rollDate(+ this.props.date,+ this.props.type,+ amt,+ this.props.minDate,+ this.props.maxDate+ );+ this.props.updateDate(newDate);+ }++ blur() {+ this.setState({+ value: this.props.value,+ valid: true+ });++ this.props.blur();+ }+ onChange(e) {+ this.setState({+ value: e.target.value.toUpperCase()+ });+ }+ nextTab() {+ this.props.nextTab(this.props.tabIndex);+ }+ validateDate(date) {+ if (date > this.props.minDate && date <= this.props.maxDate) {+ this.setState({+ valid: true+ });+ return date;+ }+ return false;+ }+ render() {+ return (+ <div+ className={'input-wrapper' + ' input-wrapper-' + this.props.type}+ style={this.state.valid ? {} : { borderColor: '#ff0000' }}+ >+ <div+ onClick={this.onClickUp.bind(this)}+ className="date-arrows date-arrow-up"+ data-interval={this.props.type}+ >+ <svg width="25" height="8">+ <path d="M 12.5,0 25,8 0,8 z" className="uparrow" />+ </svg>+ </div>+ <input+ type="text"+ ref={input => {+ this.inputs[this.props.tabIndex] = input;+ }}+ size={this.size}+ maxLength={this.size}+ className="button-input-group"+ id={this.props.inputId}+ value={this.state.value}+ tabIndex={this.props.tabIndex}+ onKeyUp={this.onKeyUp.bind(this)}+ onKeyDown={this.onKeyPress.bind(this) /* currently not working */}+ onChange={this.onChange.bind(this)}+ style={+ this.props.fontSize ? { fontSize: this.props.fontSize + 'px' } : {}+ }+ step={this.props.step}+ onBlur={this.blur.bind(this)}+ />+ <div+ onClick={this.onClickDown.bind(this)}+ className="date-arrows date-arrow-down"+ data-interval={this.props.type}+ >+ <svg width="25" height="8">+ <path d="M 12.5,0 25,8 0,8 z" className="downarrow" />+ </svg>+ </div>+ </div>+ );+ }+}++DateInputColumn.propTypes = {+ value: PropTypes.node,+ focused: PropTypes.bool,+ tabIndex: PropTypes.number,+ step: PropTypes.number,+ type: PropTypes.string,+ updateDate: PropTypes.func,+ date: PropTypes.object,+ minDate: PropTypes.object,+ maxDate: PropTypes.object,+ maxZoom: PropTypes.number,+ blur: PropTypes.func,+ nextTab: PropTypes.func,+ height: PropTypes.string,+ inputId: PropTypes.string,+ fontSize: PropTypes.number+};++export default DateInputColumn;diff --git a/web/js/components/dateline/dateline.js b/web/js/components/dateline/dateline.jsnew file mode 100644index 000000000..0a95555a4--- /dev/null+++ b/web/js/components/dateline/dateline.js@@ -0,0 +1,146 @@+import React from 'react';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a SVG line who's dimensions and styles+ * are customizable+ *+ * @class Line+ * @extends React.Component+ */+class Line extends React.Component {+ /*+ * Sets state and extents props+ */+ constructor(props) {+ super(props);+ this.state = {+ hovered: false,+ height: props.height,+ active: true+ };+ }++ /*+ * Updates state on svg hover+ *+ * return {Void}+ */+ mouseOver() {+ this.setState({+ hovered: true+ });+ }++ /*+ * Updates state on svg mouseout+ *+ * return {Void}+ */+ mouseOut() {+ this.setState({+ hovered: false+ });+ }++ /*+ * Runs lineOver props method when+ * the invisible line is hovered, passing+ * event properties+ *+ * @param {Object} e - React event object+ * return {Void}+ */+ mouseOverHidden(e) {+ this.props.lineOver(+ [e.clientX, e.clientY],+ this.props.overlay,+ this.props.lineX,+ this.props.tooltip+ );+ }++ /*+ * Runs lineOut props method when+ * the invisible line is not longer hovered, passing+ * the react component to deactivate+ *+ * return {Void}+ */+ mouseOutHidden() {+ this.props.lineOut(this.props.tooltip);+ }++ render() {+ return (+ <svg+ onMouseOver={this.mouseOver.bind(this)}+ onMouseOut={this.mouseOut.bind(this)}+ style={this.props.svgStyle}+ width={this.props.width}+ id={this.props.id}+ height={this.state.height}+ className={this.props.classes}+ >+ <line+ strokeWidth={this.props.strokeWidth}+ stroke={this.props.color}+ opacity={+ this.state.hovered && this.state.active ? this.props.opacity : '0'+ }+ x1={this.props.strokeWidth / 2}+ x2={this.props.strokeWidth / 2}+ strokeDasharray={this.props.dashArray}+ y2={this.state.height}+ y1="0"+ />+ <line+ className="dateline-hidden"+ onMouseOver={this.mouseOverHidden.bind(this)}+ onMouseMove={this.mouseOverHidden.bind(this)}+ onMouseOut={this.mouseOutHidden.bind(this)}+ style={this.props.style}+ opacity="0"+ x1={this.props.strokeWidth / 2}+ x2={this.props.strokeWidth / 2}+ strokeWidth={this.props.strokeWidth}+ stroke={this.props.color}+ y1="0"+ y2={this.state.height}+ />+ </svg>+ );+ }+}+Line.defaultProps = {+ dashArray: '5, 10',+ opacity: '0.5',+ width: '10',+ strokeWidth: '6',+ color: 'white',+ height: 200,+ svgStyle: {+ margin: '0 40px 0 40px',+ transform: 'translateX(-43px)'+ }+};++Line.propTypes = {+ dashArray: PropTypes.string,+ opacity: PropTypes.string,+ width: PropTypes.string,+ strokeWidth: PropTypes.string,+ color: PropTypes.string,+ height: PropTypes.number,+ lineX: PropTypes.number,+ lineOver: PropTypes.func,+ lineOut: PropTypes.func,+ svgStyle: PropTypes.object,+ tooltip: PropTypes.object,+ overlay: PropTypes.object,+ style: PropTypes.object,+ id: PropTypes.string,+ classes: PropTypes.string+};++export default Line;diff --git a/web/js/components/dateline/text.js b/web/js/components/dateline/text.jsnew file mode 100644index 000000000..66e2b9ba4--- /dev/null+++ b/web/js/components/dateline/text.js@@ -0,0 +1,96 @@+import React from 'react';+import PropTypes from 'prop-types';+/*+ * Builds an SVG text box+ *+ * @class LineText+ * @extends React.Component+ */+class LineText extends React.Component {+ /*+ * Sets state and extents props+ */+ constructor(props) {+ super(props);+ this.state = {+ active: false,+ dateRight: props.dateRight,+ dateLeft: props.dateLeft+ };+ }++ render() {+ return (+ <svg className="dateline-text" style={this.props.svgStyle}>+ <rect+ fill={this.props.fill}+ width={this.props.textWidth}+ height={this.props.textHeight}+ x={this.props.x1}+ rx={this.props.recRadius}+ opacity={this.state.active ? this.props.rectOpacity : '0'}+ />+ <text+ y={this.props.textY}+ x={this.props.x1 + 6}+ fill={this.props.color}+ width={this.props.width}+ opacity={this.state.active ? this.props.textOpacity : '0'}+ >+ {this.state.dateLeft}+ </text>+ <rect+ fill={this.props.fill}+ width={this.props.textWidth}+ height={this.props.textHeight}+ x={this.props.x2}+ rx={this.props.recRadius}+ opacity={this.state.active ? this.props.rectOpacity : '0'}+ />+ <text+ y={this.props.textY}+ x={this.props.x2 + 6}+ fill={this.props.color}+ opacity={this.state.active ? this.props.textOpacity : '0'}+ >+ {this.state.dateRight}+ </text>+ </svg>+ );+ }+}+LineText.defaultProps = {+ textOpacity: 0.7,+ rectOpacity: 1,+ width: '300',+ color: 'white',+ textY: 14,+ fill: 'rgba(40,40,40,0.5)',+ x2: 155,+ x1: 45,+ textWidth: 80,+ textHeight: 20,+ recRadius: 3,+ svgStyle: {+ transform: 'translateX(-140px)'+ }+};++LineText.propTypes = {+ textOpacity: PropTypes.number,+ rectOpacity: PropTypes.number,+ width: PropTypes.string,+ color: PropTypes.string,+ textY: PropTypes.number,+ fill: PropTypes.string,+ dateLeft: PropTypes.string,+ dateRight: PropTypes.string,+ x2: PropTypes.number,+ x1: PropTypes.number,+ textWidth: PropTypes.number,+ textHeight: PropTypes.number,+ recRadius: PropTypes.number,+ svgStyle: PropTypes.object+};++export default LineText;diff --git a/web/js/components/image-panel/grid.js b/web/js/components/image-panel/grid.jsnew file mode 100644index 000000000..d1a1b62f9--- /dev/null+++ b/web/js/components/image-panel/grid.js@@ -0,0 +1,62 @@+import React from 'react';+import PropTypes from 'prop-types';+import Button from '../util/button';++/*+ * A table that updates with image+ * data+ *+ * @class ResolutionTable+ * @extends React.Component+ */+export default class ResolutionTable extends React.Component {+ renderImageSize() {+ var size = this.props.fileSize;+ if (!this.props.valid) {+ return (+ <div id='wv-image-size' className='wv-image-size wv-image-size-invalid grid-child'>+ <i className='fa fa-times fa-fw' />+ <span>{'~' + size + 'MB'}</span>+ </div>+ );+ } else {+ return (+ <div id='wv-image-size' className='wv-image-size grid-child'>+ <span>{'~' + size + ' MB'} </span>+ </div>+ );+ }+ }+ render() {+ let imageSize = this.renderImageSize();+ return (+ <div className='wv-image-download-grid'>+ <div className='grid-child grid-head'><span>Raw Size</span></div>+ <div className='grid-child grid-head'><span>Maximum</span></div>+ {imageSize}+ <div className={this.props.valid ? 'grid-child wv-image-max-size' : 'grid-child wv-image-max-size wv-image-size-invalid'} >+ <span>{ this.props.maxImageSize }</span>+ </div>+ <div className='grid-child wv-image-dimensions' id='wv-image-dimensions'>+ <span>{this.props.width + ' x ' + this.props.height + 'px' }</span>+ </div>+ <div className='grid-child wv-image-button'>+ <Button+ className='black'+ text='Download'+ onClick={this.props.onClick}+ valid={this.props.valid}+ />+ </div>+ </div>+ );+ }+}+ResolutionTable.propTypes = {+ height: PropTypes.number,+ width: PropTypes.number,+ valid: PropTypes.bool,+ onClick: PropTypes.func,+ fileSize: PropTypes.string,+ maxImageSize: PropTypes.string+};diff --git a/web/js/components/image-panel/select.js b/web/js/components/image-panel/select.jsnew file mode 100644index 000000000..a927081dd--- /dev/null+++ b/web/js/components/image-panel/select.js@@ -0,0 +1,152 @@+import React from 'react';+import SelectionList from '../util/selector';+import ResTable from './grid';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class resolutionSelection+ * @extends React.Component+ */+export default class ImageResSelection extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ imageSize: props.imageSize,+ imgHeight: props.imgHeight,+ imgWidth: props.imgWidth,+ resolutions: props.resolutions,+ onSelectionChange: props.onSelectionChange,+ fileType: props.fileType,+ fileTypes: props.fileTypes,+ fileSize: props.fileSize,+ proj: this.props.proj,+ worldfile: props.worldfile,+ resolution: props.resolution,+ valid: props.valid+ };+ }+ handleChange(type, value) {+ var fileType = this.state.fileType;+ var resolution = this.state.resolution;+ var worldfile = this.state.worldfile;++ if (type === 'resolution') {+ resolution = value;+ } else if (type === 'worldfile') {+ worldfile = value;+ } else {+ fileType = value;+ }+ this.state = {+ resolution: resolution,+ fileType: fileType,+ worldfile: worldfile+ };+ this.props.onSelectionChange(resolution, worldfile, fileType);+ }+ _renderFileTypeSelect() {+ if (this.props.fileTypeOptions) {+ return (+ <div className='wv-image-header'>+ <SelectionList+ id='wv-image-format'+ optionName='filetype'+ value={this.state.fileType}+ optionArray={this.state.fileTypes}+ onChange={this.handleChange.bind(this)}+ />+ {this.props.secondLabel}+ </div>+ );+ }+ }+ _renderWorldfileSelect() {+ if (this.props.worldFileOptions) {+ return (+ <div className='wv-image-header'>++ {this.state.fileType === 'image/kmz'+ ? <select disabled>+ <option value='false'>No</option>+ </select>+ : <select+ id='wv-image-worldfile'+ value={this.state.worldfile}+ onChange={(e) => this.handleChange('worldfile', e.target.value)}>+ <option value='false'>No</option>+ <option value='true'>Yes</option>+ </select> }+ Worldfile (.zip)+ </div>+ );+ }+ }+ render() {+ var filetypeSelect = this._renderFileTypeSelect();+ var worldfileSelect = this._renderWorldfileSelect();++ return (+ <div className="wv-re-pick-wrapper">+ <div className='wv-image-header'>+ <SelectionList+ id='wv-image-resolution'+ optionArray={this.state.resolutions}+ value={this.state.resolution}+ optionName='resolution'+ onChange={this.handleChange.bind(this)}+ />+ {this.props.firstLabel}+ </div>+ {filetypeSelect}+ {worldfileSelect}+ <ResTable+ width={this.state.imgWidth}+ height={this.state.imgHeight}+ fileSize={this.state.fileSize}+ maxImageSize={this.props.maxImageSize}+ valid={this.state.valid}+ onClick={this.props.onDownloadClick}+ />+ </div>++ );+ }+}++ImageResSelection.defaultProps = {+ firstLabel: 'Resolution (per pixel)',+ secondLabel: 'Format',+ width: '0',+ height: '0',+ imageSize: '0',+ maxImageSize: '250 MB',+ worldfile: false,+ resolution: '1',+ imgHeight: null,+ imgWidth: null,+ worldFileOptions: true,+ fileTypeOptions: true+};+ImageResSelection.propTypes = {+ imageSize: PropTypes.string,+ imgHeight: PropTypes.number,+ imgWidth: PropTypes.number,+ resolutions: PropTypes.object,+ onSelectionChange: PropTypes.func,+ fileType: PropTypes.string,+ fileTypes: PropTypes.object,+ fileSize: PropTypes.string,+ proj: PropTypes.string,+ worldfile: PropTypes.string,+ resolution: PropTypes.string,+ valid: PropTypes.bool,+ onDownloadClick: PropTypes.func,+ firstLabel: PropTypes.string,+ maxImageSize: PropTypes.string,+ worldFileOptions: PropTypes.bool,+ secondLabel: PropTypes.string,+ fileTypeOptions: PropTypes.bool+};diff --git a/web/js/components/layer/list.js b/web/js/components/layer/list.jsnew file mode 100644index 000000000..0f57163f4--- /dev/null+++ b/web/js/components/layer/list.js@@ -0,0 +1,143 @@+import React from 'react';+import PropTypes from 'prop-types';+import LayerRow from './row.js';+import 'whatwg-fetch'; // fetch() polyfill for IE++/*+ * A scrollable list of layers+ * @class LayerList+ * @extends React.Component+ */+class LayerList extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ filteredLayers: props.filteredLayers,+ expandedMetadataLayers: [],+ expandedDateRangesLayers: [],+ activeLayers: props.activeLayers,+ addLayer: props.addLayer,+ removeLayer: props.removeLayer+ };+ }++ /*+ * Toggles expansion of metadata for a layer given that layer's ID and makes+ * an AJAX request for the metadata if it's missing+ *+ * @method toggleMetadataExpansion+ * @param {string} layer - the layer to be toggled+ * @return {void}+ */+ toggleMetadataExpansion(layerId) {+ var { filteredLayers, expandedMetadataLayers } = this.state;+ var isMetadataExpanded = expandedMetadataLayers.find(id => id === layerId);+ if (isMetadataExpanded) {+ expandedMetadataLayers.splice(expandedMetadataLayers.indexOf(layerId), 1);+ expandedMetadataLayers = expandedMetadataLayers.filter(+ id => id !== layerId+ );+ } else {+ expandedMetadataLayers.push(layerId);+ this.setState({ expandedMetadataLayers: expandedMetadataLayers });+ var layer = filteredLayers.find(l => l.id === layerId);+ if (!layer.metadata) {+ var { origin, pathname } = window.location;+ var errorMessage = '<p>There was an error loading layer metadata.</p>';+ var uri = `${origin}${pathname}config/metadata/${+ layer.description+ }.html`;+ fetch(uri)+ .then(res => (res.ok ? res.text() : errorMessage))+ .then(body => {+ // Check that we have a metadata html snippet, rather than a fully+ // formed HTML file. Also avoid executing any script or style tags.+ var isMetadataSnippet = !body.match(+ /<(head|body|html|style|script)[^>]*>/i+ );+ layer.metadata = isMetadataSnippet ? body : errorMessage;+ this.setState({ layers: filteredLayers });+ });+ }+ }+ }++ /*+ * Toggles expansion of date ranges for a layer given that layer's ID+ *+ * @method toggleDateRangesExpansion+ * @param {string} layer - The layer being toggled+ * @return {void}+ */+ toggleDateRangesExpansion(layerId) {+ var { expandedDateRangesLayers } = this.state;+ var isDateRangesExpanded = expandedDateRangesLayers.find(+ id => id === layerId+ );+ if (isDateRangesExpanded) {+ expandedDateRangesLayers = expandedDateRangesLayers.filter(+ id => id !== layerId+ );+ } else {+ expandedDateRangesLayers.push(layerId);+ this.setState({ expandedDateRangesLayers: expandedDateRangesLayers });+ }+ }++ render() {+ var {+ addLayer,+ removeLayer,+ filteredLayers,+ expandedMetadataLayers,+ expandedDateRangesLayers,+ activeLayers+ } = this.state;+ return (+ <div+ style={{+ height: '100%',+ overflowY: 'scroll',+ msOverflowStyle: 'scrollbar',+ WebkitOverflowScrolling: 'touch'+ }}+ >+ {filteredLayers.length < 1 ? <div>No results.</div> : null}+ {filteredLayers.map(layer => {+ var isEnabled = activeLayers.some(l => l.id === layer.id);+ var isMetadataExpanded = expandedMetadataLayers.includes(layer.id);+ var isDateRangesExpanded = expandedDateRangesLayers.includes(+ layer.id+ );+ return (+ <LayerRow+ key={layer.id}+ layer={layer}+ isEnabled={isEnabled}+ isMetadataExpanded={isMetadataExpanded}+ isDateRangesExpanded={isDateRangesExpanded}+ onState={addLayer}+ offState={removeLayer}+ toggleMetadataExpansion={id => this.toggleMetadataExpansion(id)}+ toggleDateRangesExpansion={id =>+ this.toggleDateRangesExpansion(id)+ }+ />+ );+ })}+ </div>+ );+ }+ _setListRef(ref) {+ this._layerList = ref;+ }+}++LayerList.propTypes = {+ addLayer: PropTypes.func,+ removeLayer: PropTypes.func,+ activeLayers: PropTypes.array,+ filteredLayers: PropTypes.array+};++export default LayerList;diff --git a/web/js/components/layer/row.js b/web/js/components/layer/row.jsnew file mode 100644index 000000000..5af997ff2--- /dev/null+++ b/web/js/components/layer/row.js@@ -0,0 +1,499 @@+import React from 'react';+import PropTypes from 'prop-types';+import { ListGroup, ListGroupItem } from 'reactstrap';+import Util from '../util/util.js';++const util = new Util();++/**+ * A single layer search result row+ * @class LayerRow+ * @extends React.Component+ */+class LayerRow extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ checked: props.isEnabled,+ isMetadataExpanded: props.isMetadataExpanded,+ isDateRangesExpanded: props.isDateRangesExpanded+ };+ }++ /**+ * Toggle layer checked state+ * @method toggleCheck+ * @return {void}+ */+ toggleCheck() {+ var { checked } = this.state;+ var { onState, offState, layer } = this.props;+ if (checked) offState(layer.id);+ if (!checked) onState(layer.id);+ this.setState({ checked: !checked });+ }++ /**+ * Toggle switch for the metadata info button and close arrow+ * @method toggleMetadataButtons+ * @param {e} event+ * @return {void}+ */+ toggleMetadataButtons(e) {+ e.stopPropagation(); // Prevent layer from being activated+ var { layer, toggleMetadataExpansion } = this.props;+ this.setState({ isMetadataExpanded: !this.state.isMetadataExpanded });+ toggleMetadataExpansion(layer.id);+ }++ /**+ * Toggle switch for the metadata info button and close arrow+ * @method toggleMetadataButtons+ * @param {e} event+ * @return {void}+ */+ toggleDateRanges(e) {+ e.stopPropagation(); // Prevent layer from being activated+ var { layer, toggleDateRangesExpansion } = this.props;+ this.setState({ isDateRangesExpanded: !this.state.isDateRangesExpanded });+ toggleDateRangesExpansion(layer.id);+ }++ /**+ * dateRangeText - Return text with the temporal range based on layer start+ * and end dates+ *+ * @method toggleMetadataButtons+ * @param {object} layer the layer object+ * @return {string} Return a string with temporal range information+ */+ dateRangeText(layer) {+ var startDate, startDateId, endDate, endDateId;+ var dateRange = '';+ if (layer.startDate) {+ startDate = util.parseDate(layer.startDate);+ if (layer.period === 'subdaily') {+ startDate =+ startDate.getDate() ++ ' ' ++ util.giveMonth(startDate) ++ ' ' ++ startDate.getFullYear() ++ ' ' ++ util.pad(startDate.getHours(), 2, '0') ++ ':' ++ util.pad(startDate.getMinutes(), 2, '0');+ } else if (layer.period === 'yearly') {+ startDate = startDate.getFullYear();+ } else if (layer.period === 'monthly') {+ startDate = util.giveMonth(startDate) + ' ' + startDate.getFullYear();+ } else {+ startDate =+ startDate.getDate() ++ ' ' ++ util.giveMonth(startDate) ++ ' ' ++ startDate.getFullYear();+ }+ if (layer.id) startDateId = layer.id + '-startDate';++ if (layer.endDate) {+ endDate = util.parseDate(layer.endDate);+ if (layer.period === 'subdaily') {+ endDate =+ endDate.getDate() ++ ' ' ++ util.giveMonth(endDate) ++ ' ' ++ endDate.getFullYear() ++ ' ' ++ util.pad(endDate.getHours(), 2, '0') ++ ':' ++ util.pad(endDate.getMinutes(), 2, '0');+ } else if (layer.period === 'yearly') {+ endDate = new Date(endDate.setFullYear(endDate.getFullYear() - 1));+ endDate = endDate.getFullYear();+ } else if (layer.period === 'monthly') {+ endDate = new Date(endDate.setMonth(endDate.getMonth() - 1));+ endDate = util.giveMonth(endDate) + ' ' + endDate.getFullYear();+ } else {+ if (+ layer.dateRanges &&+ layer.dateRanges.slice(-1)[0].dateInterval !== '1'+ ) {+ endDate = new Date(endDate.setTime(endDate.getTime() - 86400000));+ }+ endDate =+ endDate.getDate() ++ ' ' ++ util.giveMonth(endDate) ++ ' ' ++ endDate.getFullYear();+ }+ } else {+ endDate = 'Present';+ }+ if (layer.id) endDateId = layer.id + '-endDate';+ dateRange =+ 'Temporal coverage: <span class="layer-date-start" id=' ++ startDateId ++ '>' ++ startDate ++ '</span> - <span class="layer-end-date" id=' ++ endDateId ++ '>' ++ endDate ++ '</span>';+ }++ return dateRange;+ }++ // this function takes an array of date ranges in this format:+ // [{ layer.period, dateRanges.startDate: Date, dateRanges.endDate: Date, dateRanges.dateInterval: Number}]+ // the array is first sorted, and then checked for any overlap+ dateOverlap(period, dateRanges) {+ var sortedRanges = dateRanges.sort((previous, current) => {+ // get the start date from previous and current+ var previousTime = util.parseDate(previous.startDate);+ previousTime = previousTime.getTime();+ var currentTime = util.parseDate(current.startDate);+ currentTime = currentTime.getTime();++ // if the previous is earlier than the current+ if (previousTime < currentTime) {+ return -1;+ }++ // if the previous time is the same as the current time+ if (previousTime === currentTime) {+ return 0;+ }++ // if the previous time is later than the current time+ return 1;+ });++ var result = sortedRanges.reduce(+ (result, current, idx, arr) => {+ // get the previous range+ if (idx === 0) {+ return result;+ }+ var previous = arr[idx - 1];++ // check for any overlap+ var previousEnd = util.parseDate(previous.endDate);+ // Add dateInterval+ if (previous.dateInterval > 1 && period === 'daily') {+ previousEnd = new Date(+ previousEnd.setTime(+ previousEnd.getTime() ++ (previous.dateInterval * 86400000 - 86400000)+ )+ );+ }+ if (period === 'monthly') {+ previousEnd = new Date(+ previousEnd.setMonth(+ previousEnd.getMonth() + (previous.dateInterval - 1)+ )+ );+ } else if (period === 'yearly') {+ previousEnd = new Date(+ previousEnd.setFullYear(+ previousEnd.getFullYear() + (previous.dateInterval - 1)+ )+ );+ }+ previousEnd = previousEnd.getTime();++ var currentStart = util.parseDate(current.startDate);+ currentStart = currentStart.getTime();++ var overlap = previousEnd >= currentStart;+ // store the result+ if (overlap) {+ // yes, there is overlap+ result.overlap = true;+ // store the specific ranges that overlap+ result.ranges.push({+ previous: previous,+ current: current+ });+ }++ return result;+ },+ {+ overlap: false,+ ranges: []+ }+ );++ // return the final results+ return result;+ }++ componentWillReceiveProps(nextProps) {+ this.setState({+ checked: nextProps.isEnabled,+ isMetadataExpanded: nextProps.isMetadataExpanded,+ isDateRangesExpanded: nextProps.isDateRangesExpanded+ });+ }++ render() {+ var { checked, isMetadataExpanded, isDateRangesExpanded } = this.state;+ var { layer } = this.props;+ var { title, description, subtitle, metadata } = layer;+ var listItems;+ var headerClass = 'layers-all-header has-checkbox';+ if (layer.dateRanges && layer.dateRanges.length > 1) {+ let firstDateRange = true;++ var dateRanges = this.dateOverlap(layer.period, layer.dateRanges);++ if (dateRanges.overlap === false) {+ listItems = layer.dateRanges+ .slice(0)+ .reverse()+ .map(l => {+ let startDate = util.parseDate(l.startDate);+ let endDate = util.parseDate(l.endDate);+ let listItemStartDate;+ let listItemEndDate;++ if (layer.period === 'subdaily') {+ listItemStartDate =+ startDate.getDate() ++ ' ' ++ util.giveMonth(startDate) ++ ' ' ++ startDate.getFullYear() ++ ' ' ++ util.pad(startDate.getHours(), 2, '0') ++ ':' ++ util.pad(startDate.getMinutes(), 2, '0');++ listItemEndDate =+ endDate.getDate() ++ ' ' ++ util.giveMonth(endDate) ++ ' ' ++ endDate.getDate() ++ ' ' ++ util.giveMonth(endDate) ++ ' ' ++ endDate.getFullYear() ++ ' ' ++ util.pad(endDate.getHours(), 2, '0') ++ ':' ++ util.pad(endDate.getMinutes(), 2, '0');++ if (firstDateRange) {+ if (layer.endDate === undefined) {+ listItemEndDate = 'Present';+ }+ firstDateRange = false;+ }++ return (+ <ListGroupItem key={l.startDate + ' - ' + l.endDate}>+ {listItemStartDate + ' - ' + listItemEndDate}+ </ListGroupItem>+ );+ } else if (layer.period === 'yearly') {+ if (l.dateInterval === '1' && l.startDate === l.endDate) {+ listItemStartDate = startDate.getFullYear();++ return (+ <ListGroupItem key={l.startDate}>+ {listItemStartDate}+ </ListGroupItem>+ );+ } else {+ listItemStartDate = startDate.getFullYear();+ if (l.dateInterval !== '1') {+ listItemEndDate = new Date(+ endDate.setFullYear(+ endDate.getFullYear() - 1 + l.dateInterval+ )+ );+ }+ listItemEndDate = endDate.getFullYear();++ if (firstDateRange) {+ if (layer.endDate === undefined) {+ listItemEndDate = 'Present';+ }+ firstDateRange = false;+ }++ return (+ <ListGroupItem key={l.startDate}>+ {listItemStartDate + ' - ' + listItemEndDate}+ </ListGroupItem>+ );+ }+ } else if (layer.period === 'monthly') {+ if (l.dateInterval === '1' && l.startDate === l.endDate) {+ listItemStartDate =+ util.giveMonth(startDate) + ' ' + startDate.getFullYear();++ return (+ <ListGroupItem key={l.startDate}>+ {listItemStartDate}+ </ListGroupItem>+ );+ } else {+ listItemStartDate =+ util.giveMonth(startDate) + ' ' + startDate.getFullYear();+ if (l.dateInterval !== '1') {+ listItemEndDate = new Date(+ endDate.setMonth(endDate.getMonth() - 1 + l.dateInterval)+ );+ }+ listItemEndDate =+ util.giveMonth(endDate) + ' ' + endDate.getFullYear();++ if (firstDateRange) {+ if (layer.endDate === undefined) {+ listItemEndDate = 'Present';+ }+ firstDateRange = false;+ }++ return (+ <ListGroupItem key={l.startDate}>+ {listItemStartDate + ' - ' + listItemEndDate}+ </ListGroupItem>+ );+ }+ } else if (layer.period) {+ if (l.dateInterval === '1' && l.startDate === l.endDate) {+ let listItemStartDate =+ startDate.getDate() ++ ' ' ++ util.giveMonth(startDate) ++ ' ' ++ startDate.getFullYear();++ return (+ <ListGroupItem key={l.startDate + ' - ' + l.endDate}>+ {listItemStartDate}+ </ListGroupItem>+ );+ } else {+ let listItemStartDate =+ startDate.getDate() ++ ' ' ++ util.giveMonth(startDate) ++ ' ' ++ startDate.getFullYear();+ if (l.dateInterval !== '1') {+ listItemEndDate = new Date(+ endDate.setTime(+ endDate.getTime() - 86400000 + l.dateInterval * 86400000+ )+ );+ }+ listItemEndDate =+ endDate.getDate() ++ ' ' ++ util.giveMonth(endDate) ++ ' ' ++ endDate.getFullYear();++ if (firstDateRange) {+ if (layer.endDate === undefined) {+ listItemEndDate = 'Present';+ }+ firstDateRange = false;+ }++ return (+ <ListGroupItem key={l.startDate + ' - ' + l.endDate}>+ {listItemStartDate + ' - ' + listItemEndDate}+ </ListGroupItem>+ );+ }+ }+ });+ }+ }+ if (checked) headerClass += ' checked';++ return (+ <div className="layers-all-layer">+ <div className={headerClass} onClick={() => this.toggleCheck()}>+ <h3>+ {title}+ {description && (+ <span+ className="fa fa-info-circle"+ onClick={e => this.toggleMetadataButtons(e)}+ />+ )}+ </h3>+ {subtitle && <h5>{subtitle}</h5>}+ </div>+ {isMetadataExpanded &&+ metadata && (+ <div className="source-metadata visible">+ {layer.startDate && (+ <p className="layer-date-range">+ <span+ dangerouslySetInnerHTML={{+ __html: this.dateRangeText(layer)+ }}+ />+ {layer.dateRanges &&+ layer.dateRanges.length > 1 &&+ dateRanges.overlap === false && (+ <a+ id="layer-date-ranges-button"+ title="View all date ranges"+ className="layer-date-ranges-button"+ onClick={e => this.toggleDateRanges(e)}+ >+ {' '}+ <sup>*View Dates</sup>+ </a>+ )}+ </p>+ )}+ {isDateRangesExpanded && (+ <div className="layer-date-wrap">+ <p>Date Ranges:</p>+ <ListGroup className="layer-date-ranges">+ {listItems}+ </ListGroup>+ </div>+ )}+ <div dangerouslySetInnerHTML={{ __html: metadata }} />+ <div+ className="metadata-more"+ onClick={e => this.toggleMetadataButtons(e)}+ >+ <span className="ellipsis up">^</span>+ </div>+ </div>+ )}+ </div>+ );+ }+}++LayerRow.propTypes = {+ layer: PropTypes.object,+ isEnabled: PropTypes.bool,+ isMetadataExpanded: PropTypes.bool,+ isDateRangesExpanded: PropTypes.bool,+ onState: PropTypes.func,+ offState: PropTypes.func,+ toggleMetadataExpansion: PropTypes.func,+ toggleDateRangesExpansion: PropTypes.func+};++export default LayerRow;diff --git a/web/js/components/range-selection/dragger-range.js b/web/js/components/range-selection/dragger-range.jsnew file mode 100644index 000000000..e5693d040--- /dev/null+++ b/web/js/components/range-selection/dragger-range.js@@ -0,0 +1,85 @@+import React from 'react';+import PropTypes from 'prop-types';+/*+ * A react component, is a draggable svg+ * rect element+ *+ * @class TimelineDraggerRange+ */+class TimelineDraggerRange extends React.Component {+ /*+ * @constructor+ */+ constructor(props) {+ super(props);+ this.opacity = {+ fillOpacity: this.props.opacity+ };+ }+ checkWidth() {+ var start = this.props.startLocation;+ var end = this.props.endLocation;+ var max = this.props.max;+ var width;++ if (start < 0) {+ start = 0;+ }+ if (end > max) {+ end = max;+ }+ width = end - start;+ if (width < 0) {+ width = 0;+ }+ this.state = {+ width: width,+ startLocation: start+ };+ }+ /*+ * When the component is dragged,+ * this function passes the id+ * and change in x of the drag+ * to onDrag property+ *+ * @method handleDrag+ *+ * @return {void}+ */+ handleDrag(e, d) {+ e.stopPropagation();+ this.props.onDrag(d.deltaX);+ }++ /*+ * @method render+ */+ render() {+ this.checkWidth();+ return (+ <rect+ x={this.state.startLocation}+ fill={this.props.color}+ width={this.state.width}+ style={this.opacity}+ height={this.props.height}+ className='dragger-range'+ onClick={this.props.onClick}+ />+ );+ }+}++TimelineDraggerRange.propTypes = {+ opacity: PropTypes.number,+ startLocation: PropTypes.number,+ endLocation: PropTypes.number,+ max: PropTypes.number,+ height: PropTypes.number,+ onDrag: PropTypes.func,+ onClick: PropTypes.func,+ color: PropTypes.string+};++export default TimelineDraggerRange;diff --git a/web/js/components/range-selection/dragger.js b/web/js/components/range-selection/dragger.jsnew file mode 100644index 000000000..6a8bba136--- /dev/null+++ b/web/js/components/range-selection/dragger.js@@ -0,0 +1,213 @@+import React from 'react';+import PropTypes from 'prop-types';+import Draggable from 'react-draggable';+import lodashRound from 'lodash/round';++/*+ * A react component, is a draggable svg+ * group+ *+ * @class TimelineDragger+ * @extends React.Component+ */+class TimelineDragger extends React.Component {+ /*+ * @constructor+ */+ constructor(props) {+ super(props);+ this.state = {+ position: props.position,+ backgroundColor: props.backgroundColor,+ textColor: props.textColor,+ max: props.max+ };+ }+ /**+ * Update state if position has changed+ * @param {object} props+ */+ componentWillReceiveProps(props) {+ const { position, max } = this.state;+ if (props.position !== position) {+ this.setState({ position: props.position });+ }+ if (props.max !== max) {+ this.setState({ max: props.max });+ }+ }+ getDefaultDragger(visibility) {+ return (+ <React.Fragment>+ <rect+ width={this.props.width}+ height={this.props.height}+ style={{+ fill: this.props.color,+ visibility: visibility+ }}+ />+ {/*+ * this polygon element builds a triangle+ * based on the width and height of the+ * rectangle element+ */}+ <polygon+ points={+ '0,0,' ++ this.props.height / 1.5 ++ ',0 ' ++ this.props.height / 3 ++ ', ' ++ this.props.height / 1.5+ }+ transform={+ 'translate(' ++ -this.props.width * 2.45 ++ ', ' ++ -this.props.height / 2 ++ ')'+ }+ id={this.props.draggerID}+ style={{+ fill: this.state.backgroundColor,+ visibility: visibility,+ stroke: '#000',+ cursor: 'pointer'+ }}+ />+ {this.getText(-1, -12, visibility)}+ </React.Fragment>+ );+ }+ /**+ * Get custom path object which is a+ * guitar pick in this case+ * @param {String} visibility+ * @returns JSX element+ */+ getCustomDragger(visibility) {+ return (+ <React.Fragment>+ <path+ style={{+ fill: this.props.color ? this.props.color : null,+ visibility: visibility+ }}+ d={this.props.path}+ transform={+ 'translate(' ++ -this.props.width / 2 ++ ', ' ++ -this.props.height / 4 ++ ')'+ }+ />+ {this.getText(-5, lodashRound(this.props.height / 6, 4))}+ </React.Fragment>+ );+ }+ /**+ * Return visibility style string+ */+ getVisibility() {+ var visibility = 'visible';+ if (this.state.position < 0 || this.state.position > this.state.max) {+ visibility = 'hidden';+ }+ return visibility;+ }+ /**+ * Return text el to show over dragger+ * @param {number} x | x offset+ * @param {number} y | y offset+ */+ getText(x, y) {+ var visibility = this.getVisibility();+ if (this.props.text) {+ return (+ <text+ x={x}+ y={y}+ alignmentBaseline="middle"+ textAnchor="middle"+ style={{+ fill: this.state.textColor ? this.state.textColor : null,+ visibility: visibility || null+ }}+ >+ {this.props.text}+ </text>+ );+ }+ }+ /*+ * When the component is dragged,+ * this function passes the id+ * and change-in-x of the drag+ * to onDrag callback+ *+ * @method handleDrag+ *+ * @return {void}+ */+ handleDrag(e, d) {+ e.stopPropagation();+ var position = this.state.position + e.movementX;+ this.props.onDrag(d.deltaX, this.props.id, d.x);+ this.setState({ position: position });+ }++ /*+ * @method render+ */+ render() {+ var visibility = this.getVisibility();+ return (+ <Draggable+ onDrag={this.handleDrag.bind(this)}+ position={{ x: this.state.position, y: this.props.yOffset }}+ onStop={this.props.onStop}+ axis="x"+ >+ <g>+ {!this.props.path+ ? this.getDefaultDragger(visibility)+ : this.getCustomDragger(visibility)}+ </g>+ </Draggable>+ );+ }+}+TimelineDragger.defaultProps = {+ visible: true,+ height: 45,+ width: 5,+ color: '#fff',+ position: 0,+ visibility: 'visible',+ yOffset: 0,+ path: null,+ textColor: '#000'+};++TimelineDragger.propTypes = {+ opacity: PropTypes.number,+ max: PropTypes.number,+ height: PropTypes.number,+ onDrag: PropTypes.func,+ onClick: PropTypes.func,+ color: PropTypes.string,+ position: PropTypes.number,+ id: PropTypes.string,+ onStop: PropTypes.func,+ width: PropTypes.number,+ backgroundColor: PropTypes.string,+ draggerID: PropTypes.string,+ yOffset: PropTypes.number,+ path: PropTypes.string,+ textColor: PropTypes.string,+ text: PropTypes.string+};++export default TimelineDragger;diff --git a/web/js/components/range-selection/range-selection.js b/web/js/components/range-selection/range-selection.jsnew file mode 100644index 000000000..9b969903d--- /dev/null+++ b/web/js/components/range-selection/range-selection.js@@ -0,0 +1,168 @@+import React from 'react';+import PropTypes from 'prop-types';+import Dragger from './dragger.js';+import DraggerRange from './dragger-range.js';++/*+ * A react component, is a draggable svg+ * group. It is a parent component that+ * rerenders when child elements are dragged+ *+ * @class TimelineRangeSelector+ */+class TimelineRangeSelector extends React.Component {+ /*+ * @constructor+ */+ constructor(props) {+ super(props);+ this.state = {+ startLocation: props.startLocation,+ endLocation: props.endLocation,+ max: props.max+ };+ }+ componentWillReceiveProps(props) {+ this.setState({+ startLocation: props.startLocation,+ endLocation: props.endLocation,+ max: props.max+ });+ }+ /*+ * When a child component is dragged,+ * this function is called to determine+ * the correct location for each of the+ * child elements after the drag+ *+ * @method handleDrag+ *+ * @param {number} deltaX - change in x+ * @param {string} id - Identifier used to+ * distinguish between the child elements+ *+ * @return {void}+ */+ onItemDrag(deltaX, id) {+ var startX;+ var endX;++ if (id === 'start') {+ startX = deltaX + this.state.startLocation;+ endX = this.state.endLocation;+ if (startX < 0 || startX > endX) {+ return;+ }+ if (startX + this.props.pinWidth >= endX) {+ if (startX + this.props.pinWidth >= this.state.max) {+ return;+ } else {+ endX = startX + this.props.pinWidth;+ }+ }+ } else if (id === 'end') {+ startX = this.state.startLocation;+ endX = deltaX + this.state.endLocation;+ if (endX > this.state.max || startX > endX) {+ return;+ }+ if (startX + 2 * this.props.pinWidth >= endX) {+ startX = endX - this.props.pinWidth;+ }+ } else {+ startX = deltaX + this.state.startLocation;+ endX = deltaX + this.state.endLocation;+ if (endX >= this.state.max || startX < 0) {+ return;+ }+ }+ this.props.onDrag(startX, endX);++ this.setState({+ startLocation: startX,+ endLocation: endX+ });+ }++ /*+ * Send callback with new locations on+ * Drag Stop+ *+ * @method onDragStop+ *+ * @return {void}+ */+ onDragStop() {+ this.props.onDrag(this.state.startLocation, this.state.endLocation);+ }+ onRangeClick(d) {+ this.props.onRangeClick(d.nativeEvent);+ }+ /*+ * @method render+ */+ render() {+ return (+ <svg+ id="wv-timeline-range-selector"+ className="wv-timeline-range-selector"+ >+ <DraggerRange+ width={this.props.pinWidth}+ endLocation={this.state.endLocation}+ opacity={this.props.rangeOpacity}+ color={this.props.rangeColor}+ height={this.props.height}+ startLocation={this.state.startLocation + this.props.pinWidth}+ onClick={this.onRangeClick.bind(this)}+ max={this.state.max}+ id="range"+ />+ <Dragger+ position={this.state.startLocation}+ color={this.props.startColor}+ width={this.props.pinWidth}+ height={this.props.height}+ onDrag={this.onItemDrag.bind(this)}+ onStop={this.onDragStop.bind(this)}+ max={this.state.max}+ draggerID="range-selector-dragger-1"+ backgroundColor={this.props.startTriangleColor}+ first={true}+ id="start"+ />+ <Dragger+ max={this.state.max}+ position={this.state.endLocation}+ color={this.props.endColor}+ width={this.props.pinWidth}+ height={this.props.height}+ first={false}+ draggerID="range-selector-dragger-2"+ onDrag={this.onItemDrag.bind(this)}+ onStop={this.onDragStop.bind(this)}+ backgroundColor={this.props.endTriangleColor}+ id="end"+ />+ </svg>+ );+ }+}++TimelineRangeSelector.propTypes = {+ startLocation: PropTypes.number,+ endLocation: PropTypes.number,+ max: PropTypes.number,+ pinWidth: PropTypes.number,+ height: PropTypes.number,+ onDrag: PropTypes.func,+ onRangeClick: PropTypes.func,+ rangeOpacity: PropTypes.number,+ rangeColor: PropTypes.string,+ startColor: PropTypes.string,+ startTriangleColor: PropTypes.string,+ endColor: PropTypes.string,+ endTriangleColor: PropTypes.string+};++export default TimelineRangeSelector;diff --git a/web/js/components/share/links.js b/web/js/components/share/links.jsnew file mode 100644index 000000000..9e8133925--- /dev/null+++ b/web/js/components/share/links.js@@ -0,0 +1,30 @@+import React from 'react';+import PropTypes from 'prop-types';++class ShareLinks extends React.Component {+ onClick(event, type) {+ event.preventDefault();+ this.props.onClick(type);+ }++ render() {+ return (+ <div id="social-share">+ <a id="fb-share" className="icon-link fa fa-facebook fa-2x" href={this.props.fbLink} onClick={(e) => this.onClick(e, 'facebook')} title="Share via Facebook!" />+ <a id="tw-share" className="icon-link fa fa-twitter fa-2x" href={this.props.twLink} onClick={(e) => this.onClick(e, 'twitter')} title="Share via Twitter!" />+ <a id="rd-share" className="icon-link fa fa-reddit fa-2x" href={this.props.rdLink} onClick={(e) => this.onClick(e, 'reddit')} title="Share via Reddit!" />+ <a id="email-share" className="icon-link fa fa-envelope fa-2x" href={this.props.emailLink} onClick={(e) => this.onClick(e, 'email')} title="Share via Email!" />+ </div>+ );+ }+}++ShareLinks.propTypes = {+ fbLink: PropTypes.string,+ twLink: PropTypes.string,+ rdLink: PropTypes.string,+ emailLink: PropTypes.string,+ onClick: PropTypes.func+};++export default ShareLinks;diff --git a/web/js/components/share/share.js b/web/js/components/share/share.jsnew file mode 100644index 000000000..e8ee7a5e9--- /dev/null+++ b/web/js/components/share/share.js@@ -0,0 +1,39 @@+import React from 'react';+import PropTypes from 'prop-types';+import ShareLinks from './links';++class Share extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ fbLink: props.fbLink,+ twLink: props.twLink,+ rdLink: props.rdLink,+ emailLink: props.emailLink+ };+ }++ render() {+ return (+ <div>+ <ShareLinks+ fbLink={this.state.fbLink}+ twLink={this.state.twLink}+ rdLink={this.state.rdLink}+ emailLink={this.state.emailLink}+ onClick={this.props.clickFunction}+ />+ </div>+ );+ }+}++Share.propTypes = {+ fbLink: PropTypes.string,+ twLink: PropTypes.string,+ rdLink: PropTypes.string,+ emailLink: PropTypes.string,+ clickFunction: PropTypes.func+};++export default Share;diff --git a/web/js/components/sidebar/collapsed-button.js b/web/js/components/sidebar/collapsed-button.jsnew file mode 100644index 000000000..dc66bfa9f--- /dev/null+++ b/web/js/components/sidebar/collapsed-button.js@@ -0,0 +1,32 @@+import React from 'react';+import PropTypes from 'prop-types';++class CollapsedButton extends React.Component {+ render() {+ const { isCollapsed, numberOfLayers, onclick } = this.props;++ return (+ <div+ id="productsHoldertoggleButtonHolder"+ className="toggleButtonHolder"+ style={!isCollapsed ? { display: 'none' } : {}}+ >+ <a+ id="accordionTogglerButton"+ className="accordionToggler dateHolder staticLayers"+ title="Show Layer Selector"+ onClick={onclick}+ >+ {'Layers(' + numberOfLayers.toString() + ')'}+ </a>+ </div>+ );+ }+}+CollapsedButton.propTypes = {+ isCollapsed: PropTypes.bool,+ numberOfLayers: PropTypes.number,+ onclick: PropTypes.func+};++export default CollapsedButton;diff --git a/web/js/components/sidebar/compare.js b/web/js/components/sidebar/compare.jsnew file mode 100644index 000000000..bbd7afb03--- /dev/null+++ b/web/js/components/sidebar/compare.js@@ -0,0 +1,90 @@+import React from 'react';+import PropTypes from 'prop-types';+import Products from './products/products';++import { Nav, NavItem, NavLink, TabContent, TabPane } from 'reactstrap';+const tabHeight = 32;+class CompareCase extends React.Component {+ render() {+ const {+ isActive,+ firstDateObject,+ secondDateObject,+ toggleComparisonObject,+ isCompareA,+ height+ } = this.props;+ const outterClass = 'layer-container sidebar-panel';+ const tabClasses = 'ab-tab';+ return (+ <div className={isActive ? '' : 'hidden '}>+ <div className={outterClass}>+ <div className="ab-tabs-case">+ <Nav tabs>+ <NavItem>+ <NavLink+ className={+ isCompareA+ ? tabClasses + ' first-tab active'+ : tabClasses + ' first-tab'+ }+ onClick={toggleComparisonObject}+ >+ <i className="productsIcon selected icon-layers" />+ {' A: ' + firstDateObject.dateString}+ </NavLink>+ </NavItem>+ <NavItem>+ <NavLink+ className={+ !isCompareA+ ? tabClasses + ' second-tab active'+ : tabClasses + ' second-tab'+ }+ onClick={toggleComparisonObject}+ >+ <i className="productsIcon selected icon-layers" />+ {' B: ' + secondDateObject.dateString}+ </NavLink>+ </NavItem>+ </Nav>+ <TabContent activeTab={isCompareA ? '1' : '2'}>+ <TabPane tabId="1">+ <Products+ isActive={isCompareA}+ activeOverlays={firstDateObject.layers}+ layerGroupName="active"+ height={height - tabHeight}+ />+ </TabPane>+ <TabPane tabId="2">+ <Products+ isActive={!isCompareA}+ activeOverlays={secondDateObject.layers}+ layerGroupName="activeB"+ height={height - tabHeight}+ />+ </TabPane>+ </TabContent>+ </div>+ </div>+ </div>+ );+ }+}+CompareCase.propTypes = {+ activeOverlays: PropTypes.object,+ updateLayer: PropTypes.func,+ getNames: PropTypes.func,+ isActive: PropTypes.bool,+ firstDateObject: PropTypes.object,+ secondDateObject: PropTypes.object,+ onClickCompareTab: PropTypes.func,+ isFirstDateActive: PropTypes.bool,+ getAvailability: PropTypes.func,+ toggleActiveCompare: PropTypes.func,+ toggleComparisonObject: PropTypes.func,+ children: PropTypes.node+};++export default CompareCase;diff --git a/web/js/components/sidebar/data/data.js b/web/js/components/sidebar/data/data.jsnew file mode 100644index 000000000..15d0e0659--- /dev/null+++ b/web/js/components/sidebar/data/data.js@@ -0,0 +1,50 @@+import React from 'react';+import PropTypes from 'prop-types';+// import { Scrollbars } from 'react-custom-scrollbars';+import Product from './product';+import Scrollbars from '../../util/scrollbar';++class Data extends React.Component {+ render() {+ const {+ height,+ data,+ getCounts,+ selected,+ selectProduct,+ showUnavailableReason+ } = this.props;+ const dataArray = Object.entries(data);+ const counts = getCounts();+ return (+ <Scrollbars style={{ maxHeight: height + 'px' }}>+ <div id="wv-data">+ <div className="wv-datalist sidebar-panel content">+ <div id="wv-datacontent">+ {dataArray.map(product => {+ return (+ <Product+ key={product[0]}+ id={product[0]}+ productObject={product[1]}+ countsObject={counts}+ isSelected={selected === product[0]}+ selectProduct={selectProduct}+ showUnavailableReason={showUnavailableReason}+ />+ );+ })}+ </div>+ </div>+ </div>+ </Scrollbars>+ );+ }+}+Data.propTypes = {+ height: PropTypes.number,+ data: PropTypes.object,+ getCounts: PropTypes.func+};++export default Data;diff --git a/web/js/components/sidebar/data/product.js b/web/js/components/sidebar/data/product.jsnew file mode 100644index 000000000..17f00d863--- /dev/null+++ b/web/js/components/sidebar/data/product.js@@ -0,0 +1,82 @@+import React from 'react';+import PropTypes from 'prop-types';+const listId = 'wv-data';+class Data extends React.Component {+ getHeaderContents() {+ const {+ id,+ productObject,+ countsObject,+ isSelected,+ showUnavailableReason+ } = this.props;+ if (!productObject.notSelectable) {+ return (+ <React.Fragment>+ <input type="radio" value={id} checked={isSelected} readOnly={true} />+ <h3+ className="header"+ dangerouslySetInnerHTML={{ __html: productObject.title }}+ />+ <i id={id + 'dynamictext'} className="dynamic">+ {countsObject[id] + ' Selected ' || 0 + ' Selected '}+ </i>+ </React.Fragment>+ );+ } else {+ return (+ <h3 className="header">+ {'Not available for download '}+ <span+ onClick={e => {+ showUnavailableReason();+ }}+ className="link"+ >+ (?)+ </span>+ </h3>+ );+ }+ }+ onSelectProduct() {+ const { selectProduct, id, productObject } = this.props;+ if (productObject.notSelectable) return;+ selectProduct(id);+ }++ render() {+ const { id, productObject, isSelected } = this.props;+ return (+ <div+ className={isSelected ? 'dl-group dl-group-selected ' : 'dl-group'}+ onClick={this.onSelectProduct.bind(this)}+ value={id}+ >+ <div className="head">{this.getHeaderContents()}</div>+ <ul className="wv-datacategory" id={'wv-data' + id}>+ {productObject.items.map((layer, index) => {+ return (+ <li+ key={layer + index}+ id={listId + '-' + id + encodeURIComponent(layer.value)}+ className="item item-static"+ >+ <h4> {layer.label} </h4>+ <p dangerouslySetInnerHTML={{ __html: layer.sublabel }} />+ </li>+ );+ })}+ </ul>+ </div>+ );+ }+}+Data.defaultProps = {+ count: 0+};+Data.propTypes = {+ count: PropTypes.number+};++export default Data;diff --git a/web/js/components/sidebar/events/event.js b/web/js/components/sidebar/events/event.jsnew file mode 100644index 000000000..a8d175e49--- /dev/null+++ b/web/js/components/sidebar/events/event.js@@ -0,0 +1,127 @@+import React from 'react';+import PropTypes from 'prop-types';+import Util from '../../util/util';+import lodashFind from 'lodash/find';+const util = new Util();++class Event extends React.Component {+ getDateLists() {+ const { event, selectedDate } = this.props;+ if (event.geometries.length > 1) {+ return (+ <ul+ className="dates"+ style={!selectedDate ? { display: 'none' } : { display: 'block' }}+ >+ {event.geometries.map((geometry, index) => {+ var date = geometry.date.split('T')[0];+ return (+ <li key={event.id + '-' + date} className="dates">+ <a+ onClick={this.onClick.bind(this, date, null)}+ className={+ selectedDate === date+ ? 'date item-selected active'+ : 'date item-selected '+ }+ >+ {date}+ </a>+ </li>+ );+ })}+ </ul>+ );+ }+ }+ onClick(date, isSelected, e) {+ e.preventDefault();+ e.stopPropagation();+ const { selectEvent, event, deselectEvent } = this.props;+ if (isSelected) {+ deselectEvent();+ } else {+ selectEvent(event.id, date);+ }+ }+ getReferenceList() {+ const { sources, event, selectedDate } = this.props;+ if (!selectedDate) return;+ const references = Array.isArray(event.sources)+ ? event.sources+ : [event.sources];+ if (references.length > 0) {+ return references.map(reference => {+ const source = lodashFind(sources, {+ id: reference.id+ });+ if (reference.url) {+ return (+ <a+ target="_blank"+ className="natural-event-link"+ href={reference.url}+ key={event.id + '-' + reference.id}+ onClick={e => {+ e.stopPropagation();+ }}+ >+ <i className="fa fa-external-link fa-1" />+ {source.title}+ </a>+ );+ } else {+ return source.title + ' ';+ }+ });+ }+ }+ render() {+ const { event, selectedDate, isVisible } = this.props;+ const eventDate = util.parseDateUTC(event.geometries[0].date);+ var dateString =+ util.giveWeekDay(eventDate) ++ ', ' ++ util.giveMonth(eventDate) ++ ' ' ++ eventDate.getUTCDate();+ if (eventDate.getUTCFullYear() !== util.today().getUTCFullYear()) {+ dateString += ', ' + eventDate.getUTCFullYear();+ }+ return (+ <li+ className={+ selectedDate+ ? 'item-selected selectorItem item item-visible'+ : isVisible+ ? 'selectorItem item'+ : 'selectorItem item hidden'+ }+ onClick={this.onClick.bind(this, null, !!selectedDate)}+ >+ <i+ className={'event-icon event-icon-' + event.categories[0].slug}+ title={event.categories[0].title}+ />+ <h4 className="title">+ {event.title}+ <br />+ {dateString}+ </h4>+ <p className="subtitle">{this.getReferenceList()}</p>++ {this.getDateLists()}+ </li>+ );+ }+}+Event.propTypes = {+ event: PropTypes.object,+ selectedDate: PropTypes.string,+ isVisible: PropTypes.bool,+ deselectEvent: PropTypes.func,+ selectEvent: PropTypes.func,+ sources: PropTypes.array+};++export default Event;diff --git a/web/js/components/sidebar/events/events.js b/web/js/components/sidebar/events/events.jsnew file mode 100644index 000000000..ca4df5f8f--- /dev/null+++ b/web/js/components/sidebar/events/events.js@@ -0,0 +1,64 @@+import React from 'react';+import PropTypes from 'prop-types';+// import { Scrollbars } from 'react-custom-scrollbars';+import Event from './event';+import Scrollbars from '../../util/scrollbar';++class Events extends React.Component {+ render() {+ const {+ events,+ selectEvent,+ selectedEvent,+ visibleEvents,+ sources,+ height,+ deselectEvent+ } = this.props;+ return (+ <Scrollbars style={{ maxHeight: height + 'px' }}>+ <div id="wv-events">+ <span+ className="events-loading-text"+ style={!events.length ? { display: 'block' } : { display: 'none' }}+ >+ Loading...+ </span>+ <div+ className="wv-eventslist sidebar-panel"+ style={events.length ? { display: 'block' } : { display: 'none' }}+ >+ <ul id="wv-eventscontent" className="content map-item-list">+ {events.map(event => (+ <Event+ key={event.id}+ event={event}+ selectEvent={selectEvent}+ deselectEvent={deselectEvent}+ selectedDate={+ selectedEvent.id === event.id &&+ (visibleEvents.all || visibleEvents[event.id])+ ? selectedEvent.date+ : null+ }+ isVisible={visibleEvents.all || visibleEvents[event.id]}+ sources={sources}+ />+ ))}+ </ul>+ </div>+ </div>+ </Scrollbars>+ );+ }+}+Events.propTypes = {+ events: PropTypes.array,+ sources: PropTypes.array,+ selectEvent: PropTypes.func,+ selectedEvent: PropTypes.object,+ visibleEvents: PropTypes.object,+ height: PropTypes.number+};++export default Events;diff --git a/web/js/components/sidebar/footer-content.js b/web/js/components/sidebar/footer-content.jsnew file mode 100644index 000000000..54727f2d7--- /dev/null+++ b/web/js/components/sidebar/footer-content.js@@ -0,0 +1,121 @@+import React from 'react';+import PropTypes from 'prop-types';+import Button from '../util/button';+import ModeSelection from './mode-selection';++class FooterContent extends React.Component {+ render() {+ const {+ showListAllButton,+ isCompareMode,+ comparisonType,+ isMobile,+ eventsData,+ activeTab,+ filterEventList,+ onGetData,+ changeCompareMode,+ addLayers,+ toggleMode,+ getDataSelectionCounts,+ getDataSelectionSize+ } = this.props;+ if (activeTab === 'layers') {+ return (+ <React.Fragment>+ <ModeSelection+ isActive={isCompareMode}+ selected={comparisonType}+ onclick={changeCompareMode}+ />+ <div className="product-buttons">+ <Button+ text="+ Add Layers"+ id="layers-add"+ className={isCompareMode ? 'layers-add ' : 'layers-add red'}+ onClick={addLayers}+ />+ <Button+ onClick={toggleMode}+ className={+ isCompareMode+ ? 'compare-toggle-button red'+ : 'compare-toggle-button'+ }+ id="compare-toggle-button"+ style={isMobile ? { display: 'none' } : null}+ text={!isCompareMode ? 'Start Comparison' : 'Exit Comparison'}+ />+ </div>+ </React.Fragment>+ );+ } else if (activeTab === 'events') {+ return (+ <div+ className="events-footer-case"+ style={+ !showListAllButton || !eventsData.events.length+ ? { display: 'none' }+ : { display: 'block' }+ }+ >+ <p>Only selected events and events in current map view are listed</p>+ <Button+ className="red"+ onClick={() => {+ if (filterEventList) {+ filterEventList(true);+ }+ }}+ text="List All"+ />+ </div>+ );+ } else {+ var counts = getDataSelectionCounts();+ var validSize = getDataSelectionSize();+ var countArray = Object.values(counts);+ var noDataSelected =+ countArray.length === 0+ ? true+ : countArray.reduce((a, b) => a + b, 0) === 0;+ return (+ <div className="data-download-footer-case">+ <Button+ onClick={onGetData}+ className={+ noDataSelected+ ? 'wv-data-download-button black no-pointer-events'+ : 'wv-data-download-button red'+ }+ id="compare-toggle-button"+ text={+ validSize+ ? 'Download Data (' + Math.round(validSize * 100) / 100 + ' MB)'+ : noDataSelected+ ? 'No Data Selected'+ : 'Download Selected Data'+ }+ />+ </div>+ );+ }+ }+}++FooterContent.propTypes = {+ showListAllButton: PropTypes.bool,+ isCompareMode: PropTypes.bool,+ comparisonType: PropTypes.string,+ isMobile: PropTypes.bool,+ eventsData: PropTypes.object,+ activeTab: PropTypes.string,+ filterEventList: PropTypes.func,+ onGetData: PropTypes.func,+ changeCompareMode: PropTypes.func,+ addLayers: PropTypes.func,+ toggleMode: PropTypes.func,+ getDataSelectionCounts: PropTypes.func,+ getDataSelectionSize: PropTypes.func+};+export default FooterContent;diff --git a/web/js/components/sidebar/mode-selection.js b/web/js/components/sidebar/mode-selection.jsnew file mode 100644index 000000000..b51074fca--- /dev/null+++ b/web/js/components/sidebar/mode-selection.js@@ -0,0 +1,62 @@+import React from 'react';+import PropTypes from 'prop-types';+import { Button, ButtonGroup } from 'reactstrap';++class ModeSelection extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ selected: props.selected+ };+ }+ onclick(mode) {+ this.props.onclick(mode);+ this.setState({ selected: mode });+ }+ render() {+ const { isActive } = this.props;+ const { selected } = this.state;+ return (+ <div+ id="wv-ab-mode-selection-case"+ className="wv-ab-mode-selection-case"+ style={{ display: isActive ? 'block' : 'none' }}+ >+ <h3>COMPARE MODE:</h3>+ <ButtonGroup size="sm">+ <Button+ id="compare-swipe-button"+ className="compare-button"+ disabled={selected === 'swipe'}+ onClick={this.onclick.bind(this, 'swipe')}+ >+ Swipe+ </Button>+ <Button+ id="compare-opacity-button"+ className="compare-button"+ disabled={selected === 'opacity'}+ onClick={this.onclick.bind(this, 'opacity')}+ >+ Opacity+ </Button>+ <Button+ id="compare-spy-button"+ className="compare-button"+ disabled={selected === 'spy'}+ onClick={this.onclick.bind(this, 'spy')}+ >+ Spy+ </Button>+ </ButtonGroup>+ </div>+ );+ }+}+ModeSelection.propTypes = {+ isActive: PropTypes.bool,+ selected: PropTypes.string,+ onclick: PropTypes.func+};++export default ModeSelection;diff --git a/web/js/components/sidebar/products/layer-list.js b/web/js/components/sidebar/products/layer-list.jsnew file mode 100644index 000000000..aa74fbe4f--- /dev/null+++ b/web/js/components/sidebar/products/layer-list.js@@ -0,0 +1,141 @@+import React from 'react';+import PropTypes from 'prop-types';+import Layer from './layer';+import { SidebarContext } from '../provider';+import { Droppable, DragDropContext } from 'react-beautiful-dnd';+import lodashIsEqual from 'lodash/isEqual';++const reorder = (list, startIndex, endIndex) => {+ const result = Array.from(list);+ const [removed] = result.splice(startIndex, 1);+ result.splice(endIndex, 0, removed);++ return result;+};+class LayerList extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ palettes: {},+ layers: props.layers+ };+ }+ componentWillReceiveProps(props) {+ if (!lodashIsEqual(props.layers, this.state.layers)) {+ this.setState({ layers: props.layers });+ }+ }+ getPalette(layer, palettePromise) {+ if (this.state.palettes[layer.id]) {+ return this.state.palettes[layer.id];+ } else if (layer.palette) {+ palettePromise(layer.id).then(palette => {+ var palettes = this.state.palettes;+ palettes[layer.id] = palette;+ this.setState({+ palettes: palettes+ });+ });+ }+ return null;+ }+ onDragEnd(replaceSubGroup, result) {+ const { layerGroupName, groupId } = this.props;+ const { layers } = this.state;+ if (!result.destination) {+ return;+ }+ if (result.source.index === result.destination.index) {+ return;+ }++ const newLayerArray = reorder(+ layers,+ result.source.index,+ result.destination.index+ );++ replaceSubGroup(newLayerArray, layerGroupName, groupId);+ this.setState({ layers: newLayerArray });+ }+ render() {+ const { groupId, title, layerGroupName } = this.props;+ const { layers } = this.state;+ return (+ <SidebarContext.Consumer>+ {context => (+ <div className="layer-group-case">+ <h3 className="head">{title}</h3>+ <DragDropContext+ onDragEnd={this.onDragEnd.bind(this, context.replaceSubGroup)}+ >+ <Droppable+ droppableId={layerGroupName + '-' + groupId}+ type="layerSubGroup"+ direction="vertical"+ >+ {(provided, snapshot) => {+ return (+ <ul+ id={groupId}+ className="category"+ ref={provided.innerRef}+ >+ {layers.map((object, i) => (+ <Layer+ layer={object}+ groupId={groupId}+ layerGroupName={layerGroupName}+ getLegend={context.getLegend}+ key={i}+ index={i}+ layerClasses="item productsitem"+ zot={+ context.zotsObject[object.id]+ ? context.zotsObject[object.id].value+ : null+ }+ isMobile={context.isMobile}+ names={context.getNames(object.id)}+ checkerBoardPattern={context.checkerBoardPattern}+ palette={this.getPalette(+ object,+ context.palettePromise+ )}+ isDisabled={+ !context.getAvailability(+ object.id,+ undefined,+ layerGroupName+ )+ }+ isVisible={object.visible}+ updateLayer={context.updateLayer}+ runningObject={+ context.runningLayers &&+ context.runningLayers[object.id]+ ? context.runningLayers[object.id]+ : null+ }+ />+ ))}+ {provided.placeholder}+ </ul>+ );+ }}+ </Droppable>+ </DragDropContext>+ </div>+ )}+ </SidebarContext.Consumer>+ );+ }+}+LayerList.propTypes = {+ layers: PropTypes.array,+ groupId: PropTypes.string,+ title: PropTypes.string,+ layerGroupName: PropTypes.string+};++export default LayerList;diff --git a/web/js/components/sidebar/products/layer.js b/web/js/components/sidebar/products/layer.jsnew file mode 100644index 000000000..0840aaed4--- /dev/null+++ b/web/js/components/sidebar/products/layer.js@@ -0,0 +1,203 @@+import React from 'react';+import PropTypes from 'prop-types';+import Legend from './legend';+import { Draggable } from 'react-beautiful-dnd';++const visibilityButtonClasses = 'hdanchor hide hideReg bank-item-img';++class Layer extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ zot: props.zot,+ index: props.index+ };+ }+ componentWillReceiveProps(props) {+ if (props.zot !== this.state.zot) {+ this.setState({ zot: props.zot });+ }+ }+ hover(value) {+ const { updateLayer, layer } = this.props;+ updateLayer(layer.id, 'hover', value);+ }+ toggleVisibility(e) {+ const { updateLayer, layer } = this.props;+ updateLayer(layer.id, 'visibility');+ }+ onRemoveClick(e) {+ const { updateLayer, layer } = this.props;+ updateLayer(layer.id, 'remove');+ }+ onOptionsClick() {+ const { updateLayer, layer } = this.props;+ updateLayer(layer.id, 'options');+ }+ onInfoClick() {+ const { updateLayer, layer } = this.props;+ updateLayer(layer.id, 'info');+ }+ getLegend() {+ const {+ layer,+ palette,+ runningObject,+ getLegend,+ layerGroupName,+ checkerBoardPattern+ } = this.props;+ if (palette) {+ let isRunningData = !!runningObject;+ let colorHex = isRunningData ? runningObject.hex : null;+ return (+ <Legend+ layer={layer}+ palette={palette}+ legends={getLegend(layer.id, layerGroupName)}+ isRunningData={isRunningData}+ checkerBoardPattern={checkerBoardPattern}+ colorHex={colorHex}+ />+ );+ }+ }++ onLayerHover() {}+ getPalette() {}+ render() {+ const { zot } = this.state;+ const {+ layerGroupName,+ layer,+ isDisabled,+ isVisible,+ layerClasses,+ names,+ isMobile,+ index+ } = this.props;+ return (+ <Draggable+ draggableId={layer.id + '-' + layerGroupName}+ index={index}+ direction="vertical"+ >+ {(provided, snapshot) => {+ return (+ <li+ ref={provided.innerRef}+ {...provided.draggableProps}+ {...provided.dragHandleProps}+ id={layerGroupName + '-' + encodeURIComponent(layer.id)}+ className={+ isDisabled+ ? layerClasses + ' disabled layer-hidden'+ : !isVisible+ ? layerClasses + ' layer-hidden'+ : zot+ ? layerClasses + ' layer-enabled layer-visible zotted'+ : layerClasses + ' layer-enabled layer-visible'+ }+ onMouseEnter={this.hover.bind(this, true)}+ onMouseLeave={this.hover.bind(this, false)}+ >+ <a+ className={+ isDisabled+ ? visibilityButtonClasses + ' layer-hidden'+ : !isVisible+ ? visibilityButtonClasses + ' layer-hidden'+ : visibilityButtonClasses + ' layer-enabled layer-visible'+ }+ id={'hide' + encodeURIComponent(layer.id)}+ onClick={this.toggleVisibility.bind(this)}+ title={+ !isVisible && !isDisabled+ ? 'Show Layer'+ : isDisabled+ ? 'No data on selected date for this layer'+ : 'Hide Layer'+ }+ >+ <i+ className={+ isDisabled+ ? 'fa fa-ban layer-eye-icon'+ : !isVisible+ ? 'fa fa-eye-slash layer-eye-icon'+ : 'fa fa-eye layer-eye-icon'+ }+ />+ </a>++ <div+ className={'zot'}+ title={+ zot+ ? 'Layer is overzoomed by ' ++ zot.toString() ++ 'x its maximum zoom level'+ : ''+ }+ >+ <b>!</b>+ </div>+ <div className="layer-main">+ <a+ id={'close' + layerGroupName + encodeURIComponent(layer.id)}+ title={'Remove Layer'}+ className="button close bank-item-img"+ onClick={this.onRemoveClick.bind(this)}+ >+ <i />+ </a>+ <a+ title={'Layer options for ' + names.title}+ className={+ isMobile ? 'hidden wv-layers-options' : 'wv-layers-options'+ }+ onClick={this.onOptionsClick.bind(this)}+ >+ <i className="wv-layers-options-icon" />+ </a>+ <a+ title={'Layer description for ' + names.title}+ className="wv-layers-info"+ onClick={this.onInfoClick.bind(this)}+ >+ <i className="fa fa-info wv-layers-info-icon" />+ </a>+ <h4 title={name.title}>{names.title}</h4>+ <p dangerouslySetInnerHTML={{ __html: names.subtitle }} />+ {this.getLegend()}+ </div>+ </li>+ );+ }}+ </Draggable>+ );+ }+}++Layer.defaultProps = {+ renderedLegend: false,+ palette: {}+};+Layer.propTypes = {+ isVisible: PropTypes.bool,+ layerClasses: PropTypes.string,+ isDisabled: PropTypes.bool,+ updateLayer: PropTypes.func,+ layer: PropTypes.object,+ layerGroupName: PropTypes.string,+ zoomLevel: PropTypes.number,+ zoomLimit: PropTypes.number,+ names: PropTypes.object,+ onAddClick: PropTypes.func,+ isMobile: PropTypes.bool,+ palette: PropTypes.object,+ runningObject: PropTypes.object,+ getLegend: PropTypes.func+};+export default Layer;diff --git a/web/js/components/sidebar/products/legend.js b/web/js/components/sidebar/products/legend.jsnew file mode 100644index 000000000..f575c0793--- /dev/null+++ b/web/js/components/sidebar/products/legend.js@@ -0,0 +1,414 @@+import React from 'react';+import PropTypes from 'prop-types';+import Util from '../../util/util';+import lodashIsEqual from 'lodash/isEqual';++const util = new Util();++class Legend extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ isRunningData: props.isRunningData,+ colorHex: props.colorHex,+ isHoveringCanvas: props.isHoveringCanvas,+ legends: props.legends,+ width: this.props.width+ };+ }+ componentWillReceiveProps(props) {+ if (!lodashIsEqual(props.legends, this.state.legends)) {+ this.setState({ legends: props.legends });+ } else {+ let setState = false;+ if (props.isRunningData !== this.state.isRunningData) {+ setState = true;+ }+ if (props.colorHex !== this.state.colorHex) {+ setState = true;+ }+ if (setState) {+ this.setState({+ isRunningData: props.isRunningData,+ colorHex: props.colorHex+ });+ }+ }+ }+ componentDidMount() {+ this.updateCanvas();+ }+ componentDidUpdate() {+ this.updateCanvas();+ }+ /**+ * g+ */+ getPercent(len, index) {+ var segmentWidth;+ var location;+ const { width } = this.state;+ if (len < 250) {+ segmentWidth = width / len;+ location = segmentWidth * index + 0.5 * segmentWidth;+ return location / width;+ } else if (len) {+ return 0;+ } else {+ return index / len;+ }+ }+ /**+ * OnMouseMove get correct canvas Data+ * @param {Object} canvas | Element+ * @param {Object} e | Event Object+ */+ onHoverColorbar(canvas, e) {+ e.preventDefault();+ e.stopPropagation();+ var boundingRec = e.target.getBoundingClientRect();+ var x = e.clientX - boundingRec.left;+ var y = e.clientY - boundingRec.top;+ var rgba = canvas.current.getContext('2d').getImageData(x, y, 1, 1).data;+ var hex = util.rgbaToHex(rgba[0], rgba[1], rgba[2]);++ this.setState({+ colorHex: hex+ });+ }+ /**+ * On Mouse Enter update State+ * @param {*} e+ */+ onMouseEnter(e) {+ e.preventDefault();+ e.stopPropagation();+ this.setState({+ isRunningData: true,+ isHoveringLegend: true+ });+ }+ /**+ * Find wanted legend object from Hex+ * @param {Object} legend+ * @param {String} hex+ * @param {Number} acceptableDifference+ */+ getLegendObject(legend, hex, acceptableDifference) {+ var units = legend.units || '';+ for (var i = 0, len = legend.colors.length; i < len; i++) {+ if (util.hexColorDelta(legend.colors[i], hex) < acceptableDifference) {+ // If the two colors are close+ return {+ label: legend.tooltips[i] + ' ' + units,+ len: len,+ index: i+ };+ }+ }+ return null;+ }+ /**+ * Update state on MouseOut+ */+ hideValue(e) {+ e.preventDefault();+ e.stopPropagation();+ this.setState({+ isRunningData: false,+ isHoveringLegend: false+ });+ }+ /**+ * Style Canvas bases on updates to legend or canvas-width+ */+ updateCanvas() {+ const { checkerBoardPattern } = this.props;+ const { legends } = this.state;++ legends.forEach((colorMap, index) => {+ if (colorMap.type === 'continuous' || colorMap.type === 'discrete') {+ let ctxStr = 'canvas_' + index;+ if (this[ctxStr]) {+ let newWidth = this[ctxStr].current.getBoundingClientRect().width;+ if (newWidth !== this.state.width) {+ // If scrollbar appears canvas width changes.+ // This value is needed for calculating running data offsets+ this.setState({ width: newWidth });+ }+ this.drawOnCanvas(ctxStr, checkerBoardPattern, colorMap.colors);+ }+ }+ });+ }+ /**+ * Redraw canvas with selected colormap+ * @param {*} ctxStr | String of wanted cavnas+ * @param {*} checkerBoardPattern | Background for canvas threshold+ * @param {*} colors | array of color values+ */+ drawOnCanvas(ctxStr, checkerBoardPattern, colors) {+ var context = this[ctxStr].current.getContext('2d');+ const { height, width } = this.props;+ context.fillStyle = checkerBoardPattern;+ context.fillRect(0, 0, width, height);++ if (colors) {+ var bins = colors.length;+ var binWidth = width / bins;+ var drawWidth = Math.ceil(binWidth);+ colors.forEach((color, i) => {+ context.fillStyle = util.hexToRGBA(color);+ context.fillRect(Math.floor(binWidth * i), 0, drawWidth, height);+ });+ }+ }+ /**+ * @param {Number} index | Selected label Index+ * @param {Number} boxWidth | Width of Each label box+ * @param {Number} textWidth | Label width+ * @param {Number} width | Case width+ */+ getClassLabelStyle(index, boxWidth, textWidth, width) {+ var halfTextWidth = textWidth / 2 || 0;+ var xOffset = boxWidth * index + boxWidth / 2 || 0;+ if (halfTextWidth > xOffset) {+ return { left: '0', visibility: 'visible' };+ } else if (xOffset + halfTextWidth > width) {+ return { right: '0', visibility: 'visible' };+ }+ return { left: xOffset - halfTextWidth + 'px', visibility: 'visible' };+ }+ /**+ * @param {*} xOffset | X px Location of running-data+ * @param {Number} textWidth | px width of text calculated with canvas+ * @param {*} width | Case width+ */+ getRunningLabelStyle(xOffset, textWidth, width) {+ var halfTextWidth = textWidth / 2 || 0;++ if (halfTextWidth > xOffset) {+ return { left: '0' };+ } else if (xOffset + halfTextWidth > width) {+ return { right: '0' };+ }+ return { left: xOffset - halfTextWidth + 'px' };+ }+ /**+ * Render scale-type legends+ * @param {Object} legend+ * @param {Number} index+ * @param {Boolean} isMoreThanOneColorBar+ */+ renderScale(legend, index, isMoreThanOneColorBar) {+ const { layer, width } = this.props;+ const { isRunningData, colorHex, isHoveringLegend } = this.state;++ var percent, textWidth, xOffset, legendObj;+ var toolTipLength = legend.tooltips.length;++ if (isRunningData && colorHex) {+ legendObj = this.getLegendObject(legend, colorHex, 5); // {label,len,index}+ if (legendObj) {+ percent = this.getPercent(legendObj.len, legendObj.index);+ textWidth = util.getTextWidth(legendObj.label, 'Lucida Sans');+ xOffset = this.state.width * percent;+ }+ }++ var min = legend.minLabel || legend.tooltips[0];+ var max = legend.maxLabel || legend.tooltips[toolTipLength];++ min = legend.units ? min + ' ' + legend.units : min;+ max = legend.units ? max + ' ' + legend.units : max;+ return (+ <div+ className={+ legendObj ? 'wv-running wv-palettes-legend' : 'wv-palettes-legend'+ }+ id={layer.id + '_' + legend.id + '_' + index}+ key={layer.id + '_' + legend.id + '_' + index}+ >+ {isMoreThanOneColorBar ? (+ <div className="wv-palettes-title">{legend.title}</div>+ ) : (+ <div className="wv-palettes-title" />+ )}+ <div className="colorbar-case">+ <canvas+ className="wv-palettes-colorbar"+ id={layer.id + '-' + legend.id + index + 'colorbar'}+ width={width}+ height={12}+ ref={this['canvas_' + index]}+ onMouseEnter={this.onMouseEnter.bind(this)}+ onMouseLeave={this.hideValue.bind(this)}+ onMouseMove={this.onHoverColorbar.bind(+ this,+ this['canvas_' + index]+ )}+ />+ <div+ className="wv-running-bar"+ style={{+ left: isHoveringLegend ? 0 : xOffset,+ visibility: legendObj && !isHoveringLegend ? 'visible' : 'hidden'+ }}+ />+ </div>+ <div className="wv-palettes-min">{min}</div>+ <div className="wv-palettes-max"> {max}</div>+ <span+ className="wv-running-label"+ style={+ isRunningData+ ? this.getRunningLabelStyle(xOffset, textWidth, this.state.width)+ : { display: 'none' }+ }+ >+ {legendObj ? legendObj.label : ''}+ </span>+ </div>+ );+ }+ /**+ * Update label & Location on Mousemove+ * @param {String} color | Hex+ * @param {Object} e | Event Object+ */+ onMove(color, e) {+ e.preventDefault();+ e.stopPropagation();+ this.setState({ colorHex: color });+ }+ /**++ * @param {Object} legend | Legend Object+ * @param {Number} index | Legend Index+ */+ renderClasses(legend, index) {+ const { isRunningData, colorHex } = this.state;+ const { width } = this.props;+ const boxWidth = 17; // width (13) + margin (4)+ var legendObj, textWidth;+ if (isRunningData && colorHex) {+ legendObj = this.getLegendObject(legend, colorHex, 40); // {label,len,index}+ if (legendObj) {+ textWidth = util.getTextWidth(legendObj.label, 'Lucida Sans');+ }+ }+ return (+ <div+ className={+ legendObj+ ? 'wv-running wv-palettes-legend wv-palettes-classes'+ : 'wv-palettes-legend wv-palettes-classes'+ }+ key={legend.id + '_' + index}+ >+ {legend.colors.map((color, index) => {+ return (+ <React.Fragment key={legend.id + '-color-' + index}>+ <span+ className={+ legendObj && legendObj.index === index+ ? 'wv-active wv-palettes-class'+ : 'wv-palettes-class'+ }+ style={{ backgroundColor: util.hexToRGBA(color) }}+ onMouseMove={this.onMove.bind(this, color)}+ onMouseEnter={this.onMouseEnter.bind(this)}+ onMouseLeave={this.hideValue.bind(this)}+ dangerouslySetInnerHTML={{ __html: ' ' }}+ />+ {isRunningData && legendObj && index === legendObj.index ? (+ <span+ className="wv-running-category-label"+ style={this.getClassLabelStyle(+ index,+ boxWidth,+ textWidth,+ width+ )}+ >+ {legendObj.label}+ </span>+ ) : (+ ''+ )}+ </React.Fragment>+ );+ })}+ <span+ className="wv-running-category-label"+ style={+ legendObj && isRunningData+ ? this.getClassLabelStyle(+ legendObj.index,+ boxWidth,+ textWidth,+ width+ )+ : {}+ }+ >+ {legendObj ? legendObj.label : ''}+ </span>+ </div>+ );+ }+ /**+ * Render correct legend type+ */+ renderLegends() {+ const { legends } = this.state;+ return legends.map((colorMap, index) => {+ if (colorMap.type === 'continuous' || colorMap.type === 'discrete') {+ this['canvas_' + index] = React.createRef();+ return this.renderScale(colorMap, index, legends.length > 1);+ } else if (colorMap.type === 'classification') {+ return this.renderClasses(colorMap, index);+ }+ });+ }+ render() {+ const { palette, layer } = this.props;+ const { isHoveringLegend } = this.state;+ if (!layer.palette) return;+ return (+ <div+ className={+ isHoveringLegend+ ? 'active-lengend wv-palettes-panel'+ : 'wv-palettes-panel'+ }+ datalayer={layer.id}+ id={palette.id + '_panel'}+ >+ {this.renderLegends()}+ </div>+ );+ }+}+Legend.defaultProps = {+ isRunningData: false,+ isHoveringLegend: false,+ isRunningDataEnabled: true,+ width: 235,+ height: 12+};+Legend.propTypes = {+ palette: PropTypes.object,+ layer: PropTypes.object,+ checkerBoardPattern: PropTypes.object,+ isHoveringLegend: PropTypes.bool,+ isRunningDataEnabled: PropTypes.bool,+ legends: PropTypes.array,+ width: PropTypes.number,+ height: PropTypes.number,+ isRunningData: PropTypes.bool,+ isHoveringCanvas: PropTypes.bool,+ colorHex: PropTypes.string+};++export default Legend;diff --git a/web/js/components/sidebar/products/products.js b/web/js/components/sidebar/products/products.jsnew file mode 100644index 000000000..ca80757e8--- /dev/null+++ b/web/js/components/sidebar/products/products.js@@ -0,0 +1,38 @@+import React from 'react';+import PropTypes from 'prop-types';+import LayerList from './layer-list';+import Scrollbars from '../../util/scrollbar';++class Products extends React.Component {+ render() {+ const { activeOverlays, isActive, layerGroupName, height } = this.props;+ const outterClass = 'layer-container sidebar-panel';+ return (+ <Scrollbars style={{ maxHeight: height + 'px' }}>+ <div+ className={isActive ? outterClass : 'hidden ' + outterClass}+ style={{ display: isActive ? 'block' : 'none' }}+ >+ <LayerList+ title="Overlays"+ groupId="overlays"+ layerGroupName={layerGroupName}+ layers={activeOverlays.overlays}+ />+ <LayerList+ title="Baselayers"+ groupId="baselayers"+ layerGroupName={layerGroupName}+ layers={activeOverlays.baselayers}+ />+ </div>+ </Scrollbars>+ );+ }+}+Products.propTypes = {+ activeOverlays: PropTypes.object,+ palettePromise: PropTypes.func+};++export default Products;diff --git a/web/js/components/sidebar/provider.js b/web/js/components/sidebar/provider.jsnew file mode 100644index 000000000..2db038e23--- /dev/null+++ b/web/js/components/sidebar/provider.js@@ -0,0 +1,35 @@+import React from 'react';+import lodashIsEqual from 'lodash/isEqual';+export const SidebarContext = React.createContext();+export class SidebarProvider extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ updateLayer: props.updateLayer,+ checkerBoardPattern: props.checkerBoardPattern,+ getAvailability: props.getAvailability,+ getNames: props.getNames,+ palettePromise: props.palettePromise,+ runningLayers: props.runningLayers,+ getLegend: props.getLegend,+ zotsObject: props.zotsObject,+ replaceSubGroup: props.replaceSubGroup,+ isMobile: props.isMobile+ };+ }+ componentWillReceiveProps(props, prevProps) {+ if (prevProps.runningLayers !== props.runningLayers) {+ this.setState({ runningLayers: props.runningLayers });+ }+ if (!lodashIsEqual(prevProps.zotsObject, props.zotsObject)) {+ this.setState({ zotsObject: props.zotsObject });+ }+ }+ render() {+ return (+ <SidebarContext.Provider value={this.state}>+ {this.props.children};+ </SidebarContext.Provider>+ );+ }+}diff --git a/web/js/components/sidebar/sidebar.js b/web/js/components/sidebar/sidebar.jsnew file mode 100644index 000000000..3cbd3931a--- /dev/null+++ b/web/js/components/sidebar/sidebar.js@@ -0,0 +1,356 @@+import React from 'react';+import PropTypes from 'prop-types';+import Products from './products/products';+import Events from './events/events';+import Data from './data/data';+// import Tabs from './tabs';+import CompareCase from './compare';+import FooterContent from './footer-content';+import { Nav, NavItem, NavLink, TabContent, TabPane } from 'reactstrap';+import { SidebarProvider as Provider } from './provider';+import CollapsedButton from './collapsed-button';++class Sidebar extends React.Component {+ constructor(props) {+ super(props);+ var wasCollapsedRequested = this.wasCollapsedRequested();+ this.state = {+ activeTab: props.activeTab,+ isCompareMode: props.isCompareMode,+ isCollapsed: wasCollapsedRequested || props.isMobile,+ layers: props.layers,+ firstDateObject: props.firstDateObject,+ secondDateObject: props.secondDateObject,+ isCompareA: props.isCompareA,+ isCollapsedRequested: wasCollapsedRequested,+ comparisonType: props.comparisonType,+ runningLayers: props.runningLayers,+ zotsObject: props.zotsObject,+ isMobile: props.isMobile,+ windowHeight: window.innerHeight,+ subComponentHeight: 700,+ visibleEvents: props.visibleEvents,+ showListAllButton: props.showListAllButton,+ eventsData: props.eventsData,+ selectedEvent: props.selectedEvent,+ selectEvent: props.selectEvent,+ deselectEvent: props.deselectEvent,+ filterEventList: props.filterEventList,+ getDataSelectionCounts: props.getDataSelectionCounts,+ dataDownloadObject: {},+ selectedDataProduct: props.selectedDataProduct,+ showDataUnavailableReason: props.showDataUnavailableReason+ };+ }+ componentDidMount() {+ this.updateDimensions();+ }+ componentDidUpdate() {+ this.updateDimensions();+ }+ updateDimensions() {+ const { isMobile, subComponentHeight, windowHeight } = this.state;++ if (!isMobile) {+ let newHeight;+ let iconHeight = this.iconElement.clientHeight;+ let topOffset = Math.abs(this.iconElement.getBoundingClientRect().top);+ let footerHeight = this.footerElement.clientHeight;+ let tabHeight = 32;+ let basePadding = 110;+ newHeight =+ windowHeight -+ (iconHeight + topOffset + tabHeight + basePadding + footerHeight);+ if (subComponentHeight !== newHeight) {+ this.setState({ subComponentHeight: newHeight });+ }+ } else {+ let newHeight;+ let tabHeight = 32;+ let footerHeight = this.footerElement.clientHeight;+ newHeight = windowHeight - (tabHeight + footerHeight);+ if (subComponentHeight !== newHeight) {+ this.setState({ subComponentHeight: newHeight });+ }+ }+ }+ wasCollapsedRequested() {+ if (this.props.localStorage) {+ return localStorage.getItem('sidebarState') === 'collapsed';+ }+ return false;+ }+ toggleSidebar() {+ var isNowCollapsed = !this.state.isCollapsed;+ if (this.props.localStorage) {+ let storageValue = isNowCollapsed ? 'collapsed' : 'expanded';+ localStorage.setItem('sidebarState', storageValue);+ }+ this.setState({+ isCollapsed: isNowCollapsed,+ isCollapsedRequested: isNowCollapsed+ });+ }+ getProductsToRender(activeTab, isCompareMode) {+ const {+ layers,+ firstDateObject,+ secondDateObject,+ isCompareA,+ subComponentHeight,+ isMobile+ } = this.state;+ const { toggleComparisonObject } = this.props;+ if (isCompareMode) {+ return (+ <CompareCase+ isActive={activeTab === 'layers'}+ firstDateObject={firstDateObject}+ secondDateObject={secondDateObject}+ height={subComponentHeight}+ toggleComparisonObject={toggleComparisonObject}+ isCompareA={isCompareA}+ />+ );+ } else if (!isCompareMode) {+ return (+ <Products+ height={subComponentHeight}+ isActive={activeTab === 'layers'}+ activeOverlays={layers}+ isMobile={isMobile}+ layerGroupName={isCompareA ? 'active' : 'activeB'}+ />+ );+ }+ }++ render() {+ const {+ activeTab,+ isCompareMode,+ runningLayers,+ zotsObject,+ isMobile,+ isCollapsed,+ layers,+ visibleEvents,+ eventsData,+ selectedEvent,+ selectEvent,+ subComponentHeight,+ secondDateObject,+ firstDateObject,+ deselectEvent,+ isCompareA,+ dataDownloadObject,+ selectedDataProduct,+ showDataUnavailableReason,+ showListAllButton,+ comparisonType,+ onGetData,+ filterEventList+ } = this.state;+ const {+ onTabClick,+ palettePromise,+ updateLayer,+ getNames,+ getAvailability,+ getLegend,+ replaceSubGroup,+ getDataSelectionCounts,+ selectDataProduct,+ toggleMode,+ addLayers,+ getDataSelectionSize,+ changeCompareMode,+ checkerBoardPattern+ } = this.props;+ const tabClasses = 'sidebar-tab';+ return (+ <Provider+ palettePromise={palettePromise}+ updateLayer={updateLayer}+ getNames={getNames}+ getAvailability={getAvailability}+ runningLayers={runningLayers}+ getLegend={getLegend}+ zotsObject={zotsObject}+ replaceSubGroup={replaceSubGroup}+ isMobile={isMobile}+ checkerBoardPattern={checkerBoardPattern}+ >+ <a+ href="/"+ title="Click to Reset Worldview to Defaults"+ id="wv-logo"+ ref={iconElement => (this.iconElement = iconElement)}+ />+ <CollapsedButton+ isCollapsed={isCollapsed}+ onclick={this.toggleSidebar.bind(this)}+ numberOfLayers={+ !isCompareMode+ ? layers.baselayers.length + layers.overlays.length+ : isCompareA+ ? firstDateObject.layers.overlays.length ++ firstDateObject.layers.baselayers.length+ : secondDateObject.layers.overlays.length ++ secondDateObject.layers.baselayers.length+ }+ />+ <div id="productsHolder" style={isCollapsed ? { display: 'none' } : {}}>+ <Nav tabs className="main-nav">+ <NavItem>+ <NavLink+ title="products"+ className={+ activeTab === 'layers'+ ? tabClasses + ' first-tab active'+ : tabClasses + ' first-tab'+ }+ onClick={() => onTabClick('layers')}+ >+ <i className="productsIcon selected icon-layers" />+ Products+ </NavLink>+ </NavItem>+ <NavItem>+ <NavLink+ disabled={!!isCompareMode}+ title={+ isCompareMode+ ? 'You must exit comparison mode to use the natural events feature'+ : 'Events'+ }+ className={+ activeTab === 'events'+ ? tabClasses + ' second-tab active'+ : isCompareMode+ ? tabClasses + ' second-tab disabled'+ : tabClasses + ' second-tab'+ }+ onClick={() => onTabClick('events')}+ >+ <i className="productsIcon selected icon-events" />+ Events+ </NavLink>+ </NavItem>+ <NavItem+ style={isMobile ? { display: 'none' } : { display: 'block' }}+ >+ <NavLink+ disabled={!!isCompareMode}+ title={+ isCompareMode+ ? 'You must exit comparison mode to download data'+ : 'events'+ }+ className={+ activeTab === 'download'+ ? tabClasses + ' first-tab active'+ : isCompareMode+ ? tabClasses + ' third-tab disabled'+ : tabClasses + ' third-tab'+ }+ onClick={() => onTabClick('download')}+ >+ <i className="productsIcon selected icon-download" />+ Data+ </NavLink>+ </NavItem>+ <div className="toggleIconHolder">+ <a+ id="accordionTogglerButton"+ className="accordionToggler atcollapse arrow"+ onClick={this.toggleSidebar.bind(this)}+ title="Hide"+ />+ </div>+ </Nav>+ <TabContent activeTab={activeTab}>+ <TabPane tabId="layers">+ {this.getProductsToRender(activeTab, isCompareMode)}+ </TabPane>+ <TabPane tabId="events">+ <Events+ isActive={activeTab === 'events'}+ visibleEvents={visibleEvents}+ events={eventsData.events}+ sources={eventsData.sources}+ selectedEvent={selectedEvent}+ selectEvent={selectEvent}+ deselectEvent={deselectEvent}+ height={subComponentHeight}+ />+ </TabPane>+ <TabPane tabId="download">+ <Data+ isActive={activeTab === 'download'}+ data={dataDownloadObject}+ getCounts={getDataSelectionCounts}+ selected={selectedDataProduct}+ selectProduct={selectDataProduct}+ showUnavailableReason={showDataUnavailableReason}+ height={subComponentHeight}+ />+ </TabPane>+ <footer ref={footerElement => (this.footerElement = footerElement)}>+ <FooterContent+ showListAllButton={showListAllButton}+ isCompareMode={isCompareMode}+ comparisonType={comparisonType}+ isMobile={isMobile}+ eventsData={eventsData}+ activeTab={activeTab}+ filterEventList={filterEventList}+ onGetData={onGetData}+ changeCompareMode={changeCompareMode}+ addLayers={addLayers}+ toggleMode={toggleMode}+ getDataSelectionCounts={getDataSelectionCounts}+ getDataSelectionSize={getDataSelectionSize}+ />+ </footer>+ </TabContent>+ </div>+ </Provider>+ );+ }+}+Sidebar.defaultProps = {+ maxHeight: 700,+ visibleEvents: {}+};+Sidebar.propTypes = {+ activeTab: PropTypes.string,+ isCompareMode: PropTypes.bool,+ isCollapsed: PropTypes.bool,+ toggleSidebar: PropTypes.func,+ updateLayer: PropTypes.func,+ onTabClick: PropTypes.func,+ tabTypes: PropTypes.object,+ layers: PropTypes.object,+ getNames: PropTypes.func,+ firstDateObject: PropTypes.object,+ secondDateObject: PropTypes.object,+ addLayers: PropTypes.func,+ toggleComparisonMode: PropTypes.func,+ getAvailability: PropTypes.func,+ isCompareA: PropTypes.bool,+ toggleComparisonObject: PropTypes.func,+ comparisonType: PropTypes.string,+ toggleMode: PropTypes.func,+ runningLayers: PropTypes.object,+ changeCompareMode: PropTypes.func,+ palettePromise: PropTypes.func,+ localStorage: PropTypes.bool,+ getLegend: PropTypes.func,+ zotsObject: PropTypes.object,+ isMobile: PropTypes.bool,+ replaceSubGroup: PropTypes.func,+ maxHeight: PropTypes.number+};++export default Sidebar;diff --git a/web/js/components/sidebar/tab.js b/web/js/components/sidebar/tab.jsnew file mode 100644index 000000000..344c0e672--- /dev/null+++ b/web/js/components/sidebar/tab.js@@ -0,0 +1,27 @@+import React from 'react';+import PropTypes from 'prop-types';++class Tab extends React.Component {+ render() {+ const { listClasses, isActive, iconClasses, tabName, onclick } = this.props;+ return (+ <li className={isActive ? 'ui-tab-active' + listClasses : listClasses}>+ <a className={isActive ? 'tab activetab' : 'tab'} onClick={onclick}>+ <i className={iconClasses} title={tabName}>+ {tabName}+ </i>+ </a>+ </li>+ );+ }+}+Tab.propTypes = {+ isExpanded: PropTypes.bool,+ tabName: PropTypes.string,+ iconClasses: PropTypes.string,+ isActive: PropTypes.bool,+ listClasses: PropTypes.string,+ onclick: PropTypes.func+};++export default Tab;diff --git a/web/js/components/sidebar/tabs.js b/web/js/components/sidebar/tabs.jsnew file mode 100644index 000000000..ed81b1e20--- /dev/null+++ b/web/js/components/sidebar/tabs.js@@ -0,0 +1,44 @@+import React from 'react';+import PropTypes from 'prop-types';+import Tab from './tab';++class Tabs extends React.Component {+ render() {+ const { activeTab, tabTypes, onTabClick } = this.props;+ return (+ <ul id="productsHolder-tabs">+ <Tab+ listClasses="layerPicker first"+ tabName="Layers"+ isActive={activeTab === 'layers'}+ iconClasses="productsIcon selected icon-layers"+ tabExists={tabTypes.layers}+ onclick={onTabClick}+ />+ <Tab+ listClasses="layerPicker second eventPicker"+ tabName="Events"+ isActive={activeTab === 'events'}+ iconClasses="productsIcon selected icon-events"+ tabExists={tabTypes.events}+ onclick={onTabClick}+ />+ <Tab+ listClasses="layerPicker dataPicker"+ tabName="Data"+ isActive={activeTab === 'download'}+ iconClasses="productsIcon selected icon-download"+ tabExists={tabTypes.download}+ onclick={onTabClick}+ />+ </ul>+ );+ }+}++Tabs.propTypes = {+ activeTab: PropTypes.string,+ tabTypes: PropTypes.object,+ onTabClick: PropTypes.func+};+export default Tabs;diff --git a/web/js/components/tooltip/tooltip.js b/web/js/components/tooltip/tooltip.jsnew file mode 100644index 000000000..d292b45f4--- /dev/null+++ b/web/js/components/tooltip/tooltip.js@@ -0,0 +1,56 @@+import React from 'react';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class AnimationWidget+ * @extends React.Component+ */+class Tooltip extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ hovered: false+ };+ }+ mouseOver() {+ this.setState({+ hovered: true+ });+ }+ mouseOut() {+ this.setState({+ hovered: false+ });+ }+ onClick(str) {+ this.props.onClick(str);+ }+ render() {+ return (+ <div+ onMouseEnter={this.mouseOver.bind(this)}+ onMouseLeave={this.mouseOut.bind(this)}+ className="wv-tooltip-case">+ <span>{this.props.text}</span>+ <div className="wv-tooltip" style={(this.state.hovered) ? {visibility: 'visible'} : {}} >+ <ul>+ {this.props.dataArray.map((dataEl, i) => {+ return <li key={'tooltip-' + dataEl + '-' + i} id={dataEl} onClick={this.onClick.bind(this, dataEl)}>{dataEl}</li>;+ })}+ </ul>+ </div>+ </div>+ );+ }+}++Tooltip.propTypes = {+ onClick: PropTypes.func,+ text: PropTypes.string.isRequired,+ dataArray: PropTypes.array.isRequired+};++export default Tooltip;diff --git a/web/js/components/util/button.js b/web/js/components/util/button.jsnew file mode 100644index 000000000..7a63345a6--- /dev/null+++ b/web/js/components/util/button.js@@ -0,0 +1,43 @@+import React from 'react';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class AnimationWidget+ * @extends React.Component+ */+export default class Button extends React.Component {+ render() {+ return (+ <button+ onClick={this.props.onClick}+ style={this.props.style}+ id={this.props.id}+ disabled={!this.props.valid}+ className={+ this.props.valid+ ? 'wv-button ' + this.props.className+ : 'wv-disabled wv-button ' + this.props.className+ }+ >+ <span className="button-text">{this.props.text}</span>+ </button>+ );+ }+}++Button.defaultProps = {+ className: 'gray',+ valid: true,+ id: '',+ style: null+};+Button.propTypes = {+ onClick: PropTypes.func,+ id: PropTypes.string,+ valid: PropTypes.bool,+ className: PropTypes.string,+ text: PropTypes.string+};diff --git a/web/js/components/util/checkbox.js b/web/js/components/util/checkbox.jsnew file mode 100644index 000000000..ccd3bfb8e--- /dev/null+++ b/web/js/components/util/checkbox.js@@ -0,0 +1,55 @@+import React from 'react';+import PropTypes from 'prop-types';++/*+ * A scrollable list of layers+ * @class LayerList+ * @extends React.Component+ */+export class Checkbox extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ checked: props.checked+ };+ }++ handleChange(e) {+ var boo = !this.state.checked;+ this.setState({+ checked: boo+ });+ this.props.onCheck(boo);+ }+ render() {+ return (+ <div className={this.state.checked ? 'wv-checkbox checked' : 'wv-checkbox'}>+ <input+ type="checkbox"+ id={this.props.id}+ title={this.props.title}+ name={this.props.name}+ checked={this.state.checked}+ className={this.props.classNames}+ onChange={this.handleChange.bind(this)}+ />+ <label htmlFor={this.props.id}>+ {this.props.label}+ </label>+ </div>+ );+ }+};+Checkbox.defaultProps = {+ checked: true+};++Checkbox.propTypes = {+ onCheck: PropTypes.func,+ id: PropTypes.string,+ checked: PropTypes.bool,+ classNames: PropTypes.string,+ title: PropTypes.string,+ name: PropTypes.string,+ label: PropTypes.string+};diff --git a/web/js/components/util/google-analytics.js b/web/js/components/util/google-analytics.jsnew file mode 100644index 000000000..86c2c7b1f--- /dev/null+++ b/web/js/components/util/google-analytics.js@@ -0,0 +1,50 @@+/* eslint-disable */++export default {+ /*+ * Initialize GA tracking if tracking+ * code is present+ *+ * @func init+ * @static+ *+ * @param Category {id} GA tracking code+ *+ * @return {void}+ */+ init(id) {+ if(id) {+ (function(i, s, o, g, r, a, m) {+ i['GoogleAnalyticsObject']=r;+ i[r]=i[r]||function() {+ (i[r].q=i[r].q||[]).push(arguments);+ },+ i[r].l=1*new Date();+ a=s.createElement(o),+ m=s.getElementsByTagName(o)[0];+ a.async=1;+ a.src=g;+ m.parentNode.insertBefore(a, m);+ })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');+ ga('create', id, 'auto');+ ga('send', 'pageview');+ }+ },++ /*+ * @func TrackEventGA+ * @static+ *+ * @param Category {string} Event group name+ * @param Action {string} Type of user interaction+ * @param Label {string} Optional string for better verification of the event+ * @param Value {number} Optional number to associate with event+ *+ * @return {void}+ */+ event(category, action, label, value) {+ if (typeof (ga) !== 'undefined') {+ ga('send', 'event', category, action, label, value);+ }+ }+};diff --git a/web/js/components/util/scrollbar.js b/web/js/components/util/scrollbar.jsnew file mode 100644index 000000000..9f80e0b37--- /dev/null+++ b/web/js/components/util/scrollbar.js@@ -0,0 +1,47 @@+import React from 'react';+import PropTypes from 'prop-types';+import ScrollBar from 'simplebar';+export default class SimpleBar extends React.Component {+ constructor(props) {+ super(props);+ this.state = {+ needsScrollBar: false+ };+ }+ componentDidMount() {+ const element = this.caseEl;+ this.scrollBar = new ScrollBar(element);+ this.content = this.scrollBar.getScrollElement();+ }+ componentDidUpdate() {+ this.updateBoolean();+ this.scrollBar.recalculate(); // Necessary for IE10 and below+ }+ // https://stackoverflow.com/a/42026562/4589331+ updateBoolean() {+ const element = this.content;+ const hasOverflowingChildren = element.offsetHeight < element.scrollHeight;+ if (this.state.needsScrollBar !== hasOverflowingChildren) {+ this.setState({ needsScrollBar: hasOverflowingChildren });+ }+ }+ render() {+ return (+ <div+ style={this.props.style}+ ref={el => {+ this.caseEl = el;+ }}+ className={+ this.state.needsScrollBar ? 'scrollbar-visible' : 'scrollbar-hidden'+ }+ >+ {this.props.children}+ </div>+ );+ }+}++SimpleBar.propTypes = {+ children: PropTypes.node+};diff --git a/web/js/components/util/selector.js b/web/js/components/util/selector.jsnew file mode 100644index 000000000..f56942efb--- /dev/null+++ b/web/js/components/util/selector.js@@ -0,0 +1,40 @@+import React from 'react';+import PropTypes from 'prop-types';++/*+ * A react component, Builds a rather specific+ * interactive widget+ *+ * @class AnimationWidget+ * @extends React.Component+ */+export default class Selector extends React.Component {+ constructor(props) {+ super(props);+ this.props = props;+ this.state = {+ value: props.value+ };+ }+ handleChange(event) {+ this.props.onChange(this.props.optionName, event.target.value);+ }+ render() {+ return (+ <select value={this.props.value} id={this.props.id} onChange={this.handleChange.bind(this)} >+ {this.props.optionArray.values.map((dataEl, i) => {+ return <option key={dataEl.value + '-' + i} value={ dataEl.value } >{ dataEl.text }</option>;+ })}+ </select>+ );+ }+};++Selector.propTypes = {+ onChange: PropTypes.func,+ id: PropTypes.string,+ value: PropTypes.string,+ checked: PropTypes.bool,+ optionArray: PropTypes.object,+ optionName: PropTypes.string+};diff --git a/web/js/components/util/util.js b/web/js/components/util/util.jsnew file mode 100644index 000000000..586d789eb--- /dev/null+++ b/web/js/components/util/util.js@@ -0,0 +1,403 @@+var canvas = null;+export default class Util {+ /*+ * @constructor+ */+ constructor() {+ this.monthStringArray = [+ 'JAN',+ 'FEB',+ 'MAR',+ 'APR',+ 'MAY',+ 'JUN',+ 'JUL',+ 'AUG',+ 'SEP',+ 'OCT',+ 'NOV',+ 'DEC'+ ];+ }++ /**+ * Gets the current day. Use this instead of the Date methods to allow+ * debugging alternate 'now' times.+ *+ * @method today+ * @static+ * @return {Date} The current time with the UTC hours, minutes, and seconds+ * fields set to zero or an overriden value.+ */+ today() {+ return this.clearTimeUTC(this.now());+ }+ hexToRGBA(str) {+ return (+ 'rgba(' ++ parseInt(str.substring(0, 2), 16) ++ ',' ++ parseInt(str.substring(2, 4), 16) ++ ',' ++ parseInt(str.substring(4, 6), 16) ++ ',' ++ parseInt(str.substring(6, 8), 16) ++ ')'+ );+ }++ /**+ * Sets a date to UTC midnight.+ *+ * @method clearTimeUTC+ * @static+ * @param date {Date} date to set the UTC hours, minutes, and seconds+ * to zero.+ * @return {Date} the date object+ */+ clearTimeUTC(date) {+ date.setUTCHours(0);+ date.setUTCMinutes(0);+ date.setUTCSeconds(0);+ date.setUTCMilliseconds(0);+ return date;+ }++ clamp(val, min, max) {+ if (val < min) {+ return min;+ }+ if (val > max) {+ return max;+ }+ return val;+ }++ daysInMonth(d) {+ var y;+ var m;+ if (d.getUTCFullYear) {+ y = d.getUTCFullYear();+ m = d.getUTCMonth();+ } else {+ y = d.year;+ m = d.month;+ }+ var lastDay = new Date(Date.UTC(y, m + 1, 0));+ return lastDay.getUTCDate();+ }++ /**+ * Gets the current time. Use this instead of the Date methods to allow+ * debugging alternate 'now' times.+ *+ * @method now+ * @static+ * @return {Date} The current time or an overriden value.+ */+ now() {+ return new Date();+ }++ stringInArray(arra, value) {+ for (var i = 0, len = arra.length; i < len; i++) {+ if (arra[i] === value) {+ return i;+ }+ }+ return false;+ }++ minDate() {+ return new Date(Date.UTC(1000, 0, 1));+ }++ maxDate() {+ return new Date(Date.UTC(3000, 11, 31));+ }++ /**+ * Parses a UTC ISO 8601 date.+ *+ * @method parseDateUTC+ * @static+ * @param str {string} Date to parse in the form of ``YYYY-MM-DD``.+ * @return {Date} converted string as a date object, throws an exception if+ * the string is invalid+ */+ // NOTE: Older Safari doesn't like Date.parse+ parseDateUTC(dateAsString) {+ var dateTimeArr = dateAsString.split(/T/);+ var yyyymmdd = dateTimeArr[0].split('-');++ // Parse elements of date and time+ var year = yyyymmdd[0];+ var month = yyyymmdd[1] - 1;+ var day = yyyymmdd[2];++ var hour = 0;+ var minute = 0;+ var second = 0;+ var millisecond = 0;++ // Use default of midnight if time is not specified+ if (dateTimeArr.length > 1) {+ var hhmmss = dateTimeArr[1].split(/[:.Z]/);+ hour = hhmmss[0] || 0;+ minute = hhmmss[1] || 0;+ second = hhmmss[2] || 0;+ millisecond = hhmmss[3] || 0;+ }+ var date = new Date(+ Date.UTC(year, month, day, hour, minute, second, millisecond)+ );+ if (isNaN(date.getTime())) {+ throw new Error('Invalid date: ' + dateAsString);+ }+ return date;+ }++ /**+ * Parses a UTC ISO 8601 date to a non UTC date+ *+ * @method parseDate+ * @static+ * @param str {string} Date to parse in the form of YYYY-MM-DDTHH:MM:SSZ`.+ * @return {Date} converted string as a non UTC date object, throws an exception if+ * the string is invalid+ */+ parseDate(dateAsString) {+ var dateTimeArr = dateAsString.split(/T/);++ var yyyymmdd = dateTimeArr[0].split(/[\s-]+/);++ // Parse elements of date and time+ var year = yyyymmdd[0];+ var month = yyyymmdd[1] - 1;+ var day = yyyymmdd[2];++ var hour = 0;+ var minute = 0;+ var second = 0;+ var millisecond = 0;++ // Use default of midnight if time is not specified+ if (dateTimeArr.length > 1) {+ var hhmmss = dateTimeArr[1].split(/[:.Z]/);+ hour = hhmmss[0] || 0;+ minute = hhmmss[1] || 0;+ second = hhmmss[2] || 0;+ millisecond = hhmmss[3] || 0;+ }+ var date = new Date(year, month, day, hour, minute, second, millisecond);+ if (isNaN(date.getTime())) {+ throw new Error('Invalid date: ' + dateAsString);+ }+ return date;+ }++ /**+ * Converts a date into an ISO string with only the date portion.+ *+ * @method toISOStringDate+ * @static+ * @param date {Date} the date to convert+ * @return {string} ISO string in the form of ``YYYY-MM-DD``.+ */+ toISOStringDate(date) {+ return date.toISOString().split('T')[0];+ }++ /**+ * Converts a time into an ISO string without miliseconds.+ *+ * @method toISOStringSeconds+ * @static+ * @param {Date} date the date to convert+ * @return {string} ISO string in the form of `YYYY-MM-DDThh:mm:ssZ`.+ */+ toISOStringSeconds(date) {+ return date.toISOString().split('.')[0] + 'Z';+ }++ /**+ * Returns the month of the year for the given date object+ *+ * @method giveMonth+ * @static+ * @param date {Date} date object of which to determine the Month name+ * @return {String} the full name of the month+ */+ giveMonth(d) {+ var month = [+ 'January',+ 'February',+ 'March',+ 'April',+ 'May',+ 'June',+ 'July',+ 'August',+ 'September',+ 'October',+ 'November',+ 'December'+ ];++ return month[d.getUTCMonth()];+ }++ repeat(value, length) {+ var result = '';+ for (var i = 0; i < length; i++) {+ result += value;+ }+ return result;+ }++ roll(val, min, max) {+ if (val < min) {+ return max - (min - val) + 1;+ }+ if (val > max) {+ return min + (val - max) - 1;+ }+ return val;+ }++ rollRange(date, interval, minDate, maxDate) {+ var y = date.getUTCFullYear();+ var m = date.getUTCMonth();+ var first, last;+ switch (interval) {+ case 'minute':+ var firstMinute = new Date(Date.UTC(y, m, 1, 0, 0));+ var lastMinute = new Date(+ Date.UTC(y, m, this.daysInMonth(date), 23, 59)+ );+ first = new Date(Math.max(firstMinute, minDate)).getUTCMinutes();+ last = new Date(Math.min(lastMinute, maxDate)).getUTCMinutes();+ break;+ case 'hour':+ var firstHour = new Date(Date.UTC(y, m, 1, 0));+ var lastHour = new Date(Date.UTC(y, m, this.daysInMonth(date), 23));+ first = new Date(Math.max(firstHour, minDate)).getUTCHours();+ last = new Date(Math.min(lastHour, maxDate)).getUTCHours();+ break;+ case 'day':+ var firstDay = new Date(Date.UTC(y, m, 1));+ var lastDay = new Date(Date.UTC(y, m, this.daysInMonth(date)));+ first = new Date(Math.max(firstDay, minDate)).getUTCDate();+ last = new Date(Math.min(lastDay, maxDate)).getUTCDate();+ break;+ case 'month':+ var firstMonth = new Date(Date.UTC(y, 0, 1));+ var lastMonth = new Date(Date.UTC(y, 11, 31));+ first = new Date(Math.max(firstMonth, minDate)).getUTCMonth();+ last = new Date(Math.min(lastMonth, maxDate)).getUTCMonth();+ break;+ case 'year':+ var firstYear = this.minDate();+ var lastYear = this.maxDate();+ first = new Date(Math.max(firstYear, minDate)).getUTCFullYear();+ last = new Date(Math.min(lastYear, maxDate)).getUTCFullYear();+ break;+ }+ return { first: first, last: last };+ }+ rgbaToHex(r, g, b) {+ function hex(c) {+ var strHex = c.toString(16);+ return strHex.length === 1 ? '0' + strHex : strHex;+ }+ return hex(r) + hex(g) + hex(b) + 'ff';+ }+ getTextWidth(text, font) {+ // re-use canvas object for better performance+ canvas = canvas || document.createElement('canvas');+ var context = canvas.getContext('2d');+ context.font = font;+ var metrics = context.measureText(text);+ return metrics.width;+ }+ hexColorDelta(hex1, hex2) {+ var r1 = parseInt(hex1.substring(0, 2), 16);+ var g1 = parseInt(hex1.substring(2, 4), 16);+ var b1 = parseInt(hex1.substring(4, 6), 16);+ var r2 = parseInt(hex2.substring(0, 2), 16);+ var g2 = parseInt(hex2.substring(2, 4), 16);+ var b2 = parseInt(hex2.substring(4, 6), 16);+ // calculate differences in 3D Space+ return Math.sqrt(+ Math.pow(r1 - r2, 2) + Math.pow(g1 - g2, 2) + Math.pow(b1 - b2, 2)+ );+ }+ rollDate(date, interval, amount, minDate, maxDate) {+ minDate = minDate || this.minDate();+ maxDate = maxDate || this.maxDate();+ var range = this.rollRange(date, interval, minDate, maxDate);+ var min = range.first;+ var max = range.last;+ var minute = date.getUTCMinutes();+ var hour = date.getUTCHours();+ var day = date.getUTCDate();+ var month = date.getUTCMonth();+ var year = date.getUTCFullYear();+ switch (interval) {+ case 'minute':+ minute = this.roll(minute + amount, 0, 59);+ break;+ case 'hour':+ hour = this.roll(hour + amount, 0, 23);+ break;+ case 'day':+ day = this.roll(day + amount, min, max);+ break;+ case 'month':+ month = this.roll(month + amount, min, max);+ break;+ case 'year':+ year = this.roll(year + amount, min, max);+ break;+ default:+ throw new Error('[rollDate] Invalid interval: ' + interval);+ }+ var daysInMonth = this.daysInMonth({ year: year, month: month });+ if (day > daysInMonth) {+ day = daysInMonth;+ }+ var newDate = new Date(Date.UTC(year, month, day, hour, minute));+ newDate = new Date(this.clamp(newDate, minDate, maxDate));+ return newDate;+ }+ /**+ * Returns the day of week for the given date object+ *+ * @method giveWeekDay+ * @static+ * @param date {Date} date object of which to determine week day+ * @return {String} the full name of the day of the week+ */+ giveWeekDay(d) {+ var day = [+ 'Sunday',+ 'Monday',+ 'Tuesday',+ 'Wednesday',+ 'Thursday',+ 'Friday',+ 'Saturday'+ ];++ return day[d.getUTCDay()];+ }++ pad(value, width, padding) {+ value = '' + value;+ if (value.length < width) {+ var add = width - value.length;+ value = this.repeat(padding, add) + value;+ }+ return value;+ }+}diff --git a/web/js/data/ui.js b/web/js/data/ui.jsindex b5d935596..f51e6e06e 100644--- a/web/js/data/ui.js+++ b/web/js/data/ui.js@@ -1,7 +1,7 @@import $ from 'jquery';import lodashSize from 'lodash/size';import lodashEach from 'lodash/each';-import { GA as GoogleAnalytics } from 'worldview-components';+import googleAnalytics from '../components/util/google-analytics';import olExtent from 'ol/extent';import { dataMap } from './map';@@ -148,7 +148,7 @@ export function dataUi(models, ui, config) {};self.showDownloadList = function() {- GoogleAnalytics.event('Data Download', 'Click', 'Download Button');+ googleAnalytics.event('Data Download', 'Click', 'Download Button');if (selectionListPanel) {selectionListPanel.setVisible(false);}diff --git a/web/js/date/compare-picks.js b/web/js/date/compare-picks.jsindex d8e3f448f..7df1348a6 100644--- a/web/js/date/compare-picks.js+++ b/web/js/date/compare-picks.js@@ -1,6 +1,6 @@import React from 'react';import ReactDOM from 'react-dom';-import { TimelineDragger } from 'worldview-components';+import TimelineDragger from '../components/range-selection/dragger';import { getMaxTimelineWidth } from './util';import $ from 'jquery';import lodashDebounce from 'lodash/debounce';diff --git a/web/js/date/timeline-input.js b/web/js/date/timeline-input.jsindex 0193f9df0..0ede95bdf 100644--- a/web/js/date/timeline-input.js+++ b/web/js/date/timeline-input.js@@ -1,6 +1,6 @@import $ from 'jquery';import util from '../util/util';-import { DateSelector } from 'worldview-components';+import DateSelector from '../components/date-selector/date-selector';import React from 'react';import ReactDOM from 'react-dom';diff --git a/web/js/image/panel.js b/web/js/image/panel.jsindex f2050f746..3652588d9 100644--- a/web/js/image/panel.js+++ b/web/js/image/panel.js@@ -2,7 +2,8 @@ import $ from 'jquery';import 'jquery-ui/button';import 'jquery-ui/dialog';import olProj from 'ol/proj';-import { GA as googleAnalytics, ImageResSelection } from 'worldview-components';+import ImageResSelection from '../components/image-panel/select';+import googleAnalytics from '../components/util/google-analytics';import util from '../util/util';import wvui from '../ui/ui';import React from 'react';diff --git a/web/js/layers/modal.js b/web/js/layers/modal.jsindex d707e2d7d..c51b6ec2e 100644--- a/web/js/layers/modal.js+++ b/web/js/layers/modal.js@@ -8,7 +8,7 @@ import 'isotope-layout';import 'perfect-scrollbar/jquery';import React from 'react';import ReactDOM from 'react-dom';-import { LayerList } from 'worldview-components';+import LayerList from '../components/layer/list';import lodashFind from 'lodash/find';import lodashIndexOf from 'lodash/indexOf';import lodashSortBy from 'lodash/sortBy';diff --git a/web/js/link/ui.js b/web/js/link/ui.jsindex 49383ca9a..856ad0cb2 100644--- a/web/js/link/ui.js+++ b/web/js/link/ui.js@@ -6,7 +6,9 @@ import lodashThrottle from 'lodash/throttle';import React from 'react';import ReactDOM from 'react-dom';import Clipboard from 'clipboard';-import { Share, GA as googleAnalytics } from 'worldview-components';+import Share from '../components/share/share';+import googleAnalytics from '../components/util/google-analytics';+import util from '../util/util';import wvui from '../ui/ui';@@ -17,26 +19,23 @@ export function linkUi(models, config) {var $button, $label;var clipboard = new Clipboard('.copy-btn');- var init = function () {+ var init = function() {$button = $('<input></input>').attr('type', 'checkbox').attr('id', 'wv-link-button-check');$label = $('<label></label>').attr('for', 'wv-link-button-check').attr('title', 'Share this map');- var $icon = $('<i></i>')- .addClass('fa fa-share-square-o fa-2x');+ var $icon = $('<i></i>').addClass('fa fa-share-square-o fa-2x');$label.append($icon);- $(selector)- .append($label);- $(selector)- .append($button);- $button.button({- text: false- })- .click(function () {- var checked = $('#wv-link-button-check')- .prop('checked');+ $(selector).append($label);+ $(selector).append($button);+ $button+ .button({+ text: false+ })+ .click(function() {+ var checked = $('#wv-link-button-check').prop('checked');googleAnalytics.event('Link', 'Click', 'Share link Button');if (checked) {self.show();@@ -48,36 +47,72 @@ export function linkUi(models, config) {};// Calls toQueryString to fetch updated state and returns URL- var replaceHistoryState = lodashThrottle(function () {- if (util.browser.history) {- window.history.replaceState('', '@OFFICIAL_NAME@', '?' + models.link.toQueryString());+ var replaceHistoryState = lodashThrottle(+ function() {+ if (util.browser.history) {+ window.history.replaceState(+ '',+ '@OFFICIAL_NAME@',+ '?' + models.link.toQueryString()+ );+ }+ },+ 2000,+ {+ leading: true,+ trailing: true}- }, 2000, {- leading: true,- trailing: true- });+ );// Facebook: https://developers.facebook.com/docs/sharing/reference/share-dialog#redirect- var facebookUrlParams = function (appId, href, redirectUri, display) {- return 'https://www.facebook.com/dialog/share?' + 'app_id=' + encodeURIComponent(appId) + '&href=' + encodeURIComponent(href) + '&redirect_uri=' + encodeURIComponent(redirectUri) + '&display=' + encodeURIComponent(display);+ var facebookUrlParams = function(appId, href, redirectUri, display) {+ return (+ 'https://www.facebook.com/dialog/share?' ++ 'app_id=' ++ encodeURIComponent(appId) ++ '&href=' ++ encodeURIComponent(href) ++ '&redirect_uri=' ++ encodeURIComponent(redirectUri) ++ '&display=' ++ encodeURIComponent(display)+ );};// Twitter: https://dev.twitter.com/web/tweet-button/parameters#web-intent-example- var twitterUrlParams = function (url, text) {- return 'https://twitter.com/intent/tweet?' + 'url=' + encodeURIComponent(url) + '&text=' + encodeURIComponent(text);+ var twitterUrlParams = function(url, text) {+ return (+ 'https://twitter.com/intent/tweet?' ++ 'url=' ++ encodeURIComponent(url) ++ '&text=' ++ encodeURIComponent(text)+ );};// Reddit: https://www.reddit.com/r/nasa/submit?url=[URL]&title=[TITLE]- var redditUrlParams = function (url, title) {- return 'https://www.reddit.com/r/nasa/submit?' + 'url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title);+ var redditUrlParams = function(url, title) {+ return (+ 'https://www.reddit.com/r/nasa/submit?' ++ 'url=' ++ encodeURIComponent(url) ++ '&title=' ++ encodeURIComponent(title)+ );};// Email: mailto:?subject=[SUBJECT]&body=[BODY]- var emailUrlParams = function (subject, body) {- return 'mailto:?' + 'subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body);+ var emailUrlParams = function(subject, body) {+ return (+ 'mailto:?' ++ 'subject=' ++ encodeURIComponent(subject) ++ '&body=' ++ encodeURIComponent(body)+ );};- var getSharelink = function (type, url) {+ var getSharelink = function(type, url) {var shareMessage = 'Check out what I found in NASA Worldview!';var twMessage = 'Check out what I found in #NASAWorldview -';var emailBody = shareMessage + ' - ' + url;@@ -94,10 +129,10 @@ export function linkUi(models, config) {}return undefined;};- var openPromisedSocial = function (url, win) {+ var openPromisedSocial = function(url, win) {win.location.assign(url);};- var clickFunction = function (type) {+ var clickFunction = function(type) {var href, win;var shareLink = models.link.get();var promise = models.link.shorten();@@ -108,13 +143,14 @@ export function linkUi(models, config) {if (type === 'twitter') {win = window.open('', '_blank');}- promise.done(function (result) {- if (result.status_code === 200) {- href = getSharelink(type, result.data.url);- openPromisedSocial(href, win);- }- })- .fail(function () {+ promise+ .done(function(result) {+ if (result.status_code === 200) {+ href = getSharelink(type, result.data.url);+ openPromisedSocial(href, win);+ }+ })+ .fail(function() {href = getSharelink(type, shareLink);openPromisedSocial(href, win);console.warn('Unable to shorten URL, full link generated.');@@ -125,19 +161,21 @@ export function linkUi(models, config) {}};- self.show = function () {+ self.show = function() {var $dialog = wvui.getDialog();- var item = '<div id=\'wv-link\' class=\'wv-link\'>' +- '<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\'>COPY</button>' ++ var item =+ "<div id='wv-link' class='wv-link'>" ++ "<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'>COPY</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 link</label>' ++ 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 link</label>" +'</div>';}item += '</div>';@@ -154,39 +192,33 @@ export function linkUi(models, config) {// If selected during the animation, the cursor will go to the// end of the input box- var updateLink = function () {- $('#permalink_content')- .val(models.link.get());- $('#wv-link-shorten-check')- .iCheck('uncheck');- $('#permalink_content')- .focus();- $('#permalink_content')- .select();+ var updateLink = function() {+ $('#permalink_content').val(models.link.get());+ $('#wv-link-shorten-check').iCheck('uncheck');+ $('#permalink_content').focus();+ $('#permalink_content').select();};models.link.events.on('update', updateLink);- $dialog.dialog({- dialogClass: 'wv-panel wv-link-panel',- title: 'Copy link to share:',- show: {- effect: 'slide',- direction: 'up'- },- width: dialogWidth,- height: 'auto',- minHeight: 10,- draggable: false,- resizable: false,- autoOpen: false- })- .on('dialogcreate',- $dialog.prepend(item)- )- .on('dialogclose', function () {- $('#wv-link-button-check')- .prop('checked', false);+ $dialog+ .dialog({+ dialogClass: 'wv-panel wv-link-panel',+ title: 'Copy link to share:',+ show: {+ effect: 'slide',+ direction: 'up'+ },+ width: dialogWidth,+ height: 'auto',+ minHeight: 10,+ draggable: false,+ resizable: false,+ autoOpen: false+ })+ .on('dialogcreate', $dialog.prepend(item))+ .on('dialogclose', function() {+ $('#wv-link-button-check').prop('checked', false);$button.button('refresh');models.link.events.off('update', updateLink);});@@ -203,75 +235,66 @@ export function linkUi(models, config) {of: $label});}- $('.ui-dialog')- .zIndex(600);+ $('.ui-dialog').zIndex(600);- $('#permalink_content')- .val(models.link.get());+ $('#permalink_content').val(models.link.get());$dialog.dialog('open');setTimeout(updateLink, 500);- $('#wv-link-shorten-check')- .on('change', function () {- var checked = $('#wv-link-shorten-check')- .prop('checked');- if (checked) {- var promise = models.link.shorten();- googleAnalytics.event('Link', 'Check', 'Shorten');- $('#permalink_content')- .val('Please wait...');- promise.done(function (result) {+ $('#wv-link-shorten-check').on('change', function() {+ var checked = $('#wv-link-shorten-check').prop('checked');+ if (checked) {+ var promise = models.link.shorten();+ googleAnalytics.event('Link', 'Check', 'Shorten');+ $('#permalink_content').val('Please wait...');+ promise+ .done(function(result) {if (result.status_code === 200) {- $('#permalink_content')- .val(result.data.url);+ $('#permalink_content').val(result.data.url);} else {error(result.status_code, result.status_txt);}})- .fail(function (jqXHR, textStatus, errorThrown) {- error(textStatus, errorThrown);- });- } else {- $('#permalink_content')- .val(models.link.get());- googleAnalytics.event('Link', 'Check', 'Lengthen');- }- $('#permalink_content')- .focus();- $('#permalink_content')- .select();- });+ .fail(function(jqXHR, textStatus, errorThrown) {+ error(textStatus, errorThrown);+ });+ } else {+ $('#permalink_content').val(models.link.get());+ googleAnalytics.event('Link', 'Check', 'Lengthen');+ }+ $('#permalink_content').focus();+ $('#permalink_content').select();+ });- var error = function () {+ var error = function() {console.warn('Unable to shorten URL');console.warn.apply(console, arguments);- wvui.notify('Unable to shorten the permalink at this time. ' +- 'Please try again later.');+ wvui.notify(+ 'Unable to shorten the permalink at this time. ' ++ 'Please try again later.'+ );};- $('#wv-link-shorten-check')- .prop('checked', false);+ $('#wv-link-shorten-check').prop('checked', false);- clipboard.on('success', function (e) {+ clipboard.on('success', function(e) {e.clearSelection();- $('.wv-link .input-group-button')- .removeClass('hide-icon');+ $('.wv-link .input-group-button').removeClass('hide-icon');- setTimeout(function () {- $('.wv-link .input-group-button')- .addClass('hide-icon');+ setTimeout(function() {+ $('.wv-link .input-group-button').addClass('hide-icon');}, 1000);});- clipboard.on('error', function (e) {+ 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 () {+ self.initWidget = function() {return React.createElement(Share, {clickFunction: clickFunction,fbLink: '#',@@ -283,4 +306,4 @@ export function linkUi(models, config) {init();return self;-};+}diff --git a/web/js/main.js b/web/js/main.jsindex c762bc792..6fa109809 100644--- a/web/js/main.js+++ b/web/js/main.js@@ -1,7 +1,7 @@import 'babel-polyfill'; // Needed for worldview-components in IE and older browsersimport $ from 'jquery';import lodashEach from 'lodash/each';-import { GA as googleAnalytics } from 'worldview-components';+import googleAnalytics from './components/util/google-analytics';// Utilsimport util from './util/util';diff --git a/web/js/map/compare/opacity.js b/web/js/map/compare/opacity.jsindex 15277a59f..419ce88c0 100644--- a/web/js/map/compare/opacity.js+++ b/web/js/map/compare/opacity.js@@ -1,6 +1,7 @@import React from 'react';import ReactDOM from 'react-dom';-import { OpacitySlider } from 'worldview-components';+import OpacitySlider from '../../components/compare/opacity-slider';+var map;var slider;var value = 50;diff --git a/web/js/map/datelinebuilder.js b/web/js/map/datelinebuilder.jsindex b6ae0ca84..a01da6f57 100644--- a/web/js/map/datelinebuilder.js+++ b/web/js/map/datelinebuilder.js@@ -3,7 +3,8 @@ import ReactDOM from 'react-dom';import OlOverlay from 'ol/overlay';import util from '../util/util';-import { DateLine, LineText } from 'worldview-components';+import DateLine from '../components/dateline/dateline';+import LineText from '../components/dateline/text';var map,overlay1,diff --git a/web/js/map/runningdata.js b/web/js/map/runningdata.jsindex bf09aabf9..9d77b7581 100644--- a/web/js/map/runningdata.js+++ b/web/js/map/runningdata.js@@ -1,9 +1,7 @@-import { Util } from 'worldview-components';+import util from '../util/util';import lodashIsEqual from 'lodash/isEqual';import lodashIsEmpty from 'lodash/isEmpty';-const util = new Util();-export function MapRunningData(models, compareUi) {var self;diff --git a/web/js/sidebar/ui.js b/web/js/sidebar/ui.jsindex a2d9cf1b0..7c5c41689 100644--- a/web/js/sidebar/ui.js+++ b/web/js/sidebar/ui.js@@ -3,7 +3,7 @@ import 'jquery-ui/dialog';import lodashFind from 'lodash/find';import lodashDebounce from 'lodash/debounce';import util from '../util/util';-import { Sidebar } from 'worldview-components';+import Sidebar from '../components/sidebar/sidebar';import React from 'react';import ReactDOM from 'react-dom';import { getCompareObjects } from '../compare/util';diff --git a/web/js/tour.js b/web/js/tour.jsindex 7bf0715e4..ff808bb24 100644--- a/web/js/tour.js+++ b/web/js/tour.js@@ -3,7 +3,7 @@ import 'jquery-ui/dialog';import 'jquery.joyride';import util from './util/util';import wvui from './ui/ui';-import { GA as googleAnalytics } from 'worldview-components';+import googleAnalytics from './components/util/google-analytics';import feedbackModal from './feedback';export default function(models, ui, config) {