Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

exported datelineBuilder

Benjamin King2a05051a5b00
diff --git a/web/js/map/wv.map.datelinebuilder.js b/web/js/map/wv.map.datelinebuilder.js
index 80f87405c..b68619fab 100644
--- a/web/js/map/wv.map.datelinebuilder.js
+++ b/web/js/map/wv.map.datelinebuilder.js
@@ -1,13 +1,15 @@
-var wv = wv || {};
-wv.map = wv.map || {};
+import React from 'react';
+import ReactDOM from 'React-dom';
+import WVC from 'worldview-components';
+import ol from 'openlayers';
-/*
- * @Class
- */
-wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
+import util from '../util/util.js';
+
+var map, overlay1, overlay2, textFactory, lineFactory, textOverlay1, textOverlay2,
+ lineLeft, lineRight, textLeft, textRight, proj;
+
+export default function datelinebuilder(models, config) {
var self = {};
- var map, overlay1, overlay2, textFactory, lineFactory, textOverlay1, textOverlay2,
- lineLeft, lineRight, textLeft, textRight, proj;
/*
* Sets globals and event listeners
*
@@ -21,7 +23,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {object} React Component
*/
- self.init = function (Parent, olMap, date) {
+ self.init = function(Parent, olMap, date) {
var dimensions;
map = olMap;
lineFactory = React.createFactory(WVC.DateLine);
@@ -29,28 +31,28 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
drawDatelines(map, date);
proj = models.proj.selected.id;
- Parent.events.on('moveend', function () {
+ Parent.events.on('moveend', function() {
if (!isGeoProjection()) { return; }
updateLineVisibility(true);
dimensions = position(map);
update(dimensions);
});
- Parent.events.on('drag', function () {
+ Parent.events.on('drag', function() {
if (!isGeoProjection()) { return; }
updateLineVisibility(false);
});
- Parent.events.on('movestart', function () {
+ Parent.events.on('movestart', function() {
if (!isGeoProjection()) { return; }
updateLineVisibility(false);
});
- models.date.events.on('select', function () {
+ models.date.events.on('select', function() {
updateDate(models.date.selected);
});
- models.proj.events.on('select', function () {
+ models.proj.events.on('select', function() {
proj = models.proj.selected.id;
});
};
- var isGeoProjection = function () {
+ var isGeoProjection = function() {
if (proj === 'geographic') {
return true;
}
@@ -72,7 +74,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {object} React Component
*/
- var setLineDefaults = function (Factory, height, lineX, overlay, reactCase, tooltip) {
+ var setLineDefaults = function(Factory, height, lineX, overlay, reactCase, tooltip) {
var props = {
height: height,
lineOver: onHover,
@@ -97,10 +99,10 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {object} React Component
*/
- var setTextDefaults = function (Factory, reactCase, date) {
+ var setTextDefaults = function(Factory, reactCase, date) {
var props = {
- dateLeft: wv.util.toISOStringDate(wv.util.dateAdd(date, 'day', 1)),
- dateRight: wv.util.toISOStringDate(date)
+ dateLeft: util.toISOStringDate(util.dateAdd(date, 'day', 1)),
+ dateRight: util.toISOStringDate(date)
};
return ReactDOM.render(initWidget(Factory, props), reactCase);
};
@@ -116,7 +118,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {object} React Component
*/
- var initWidget = function (Factory, props) {
+ var initWidget = function(Factory, props) {
return Factory(props);
};
@@ -130,7 +132,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var updateLineVisibility = function (boo) {
+ var updateLineVisibility = function(boo) {
var state = {
active: boo
};
@@ -148,7 +150,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var drawDatelines = function (map, date) {
+ var drawDatelines = function(map, date) {
var height, leftLineCase, rightLineCase, leftTextCase, rightTextCase;
leftLineCase = document.createElement('div');
@@ -168,7 +170,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
map.addOverlay(textOverlay2);
textLeft = setTextDefaults(textFactory, leftTextCase, date);
- textRight = setTextDefaults(textFactory, rightTextCase, wv.util.dateAdd(date, 'day', -1));
+ textRight = setTextDefaults(textFactory, rightTextCase, util.dateAdd(date, 'day', -1));
lineLeft = setLineDefaults(lineFactory, height, -180, textOverlay1, leftLineCase, textLeft);
lineRight = setLineDefaults(lineFactory, height, 180, textOverlay2, rightLineCase, textRight);
};
@@ -186,7 +188,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var onHover = function (pixels, overlay, lineX, tooltip) {
+ var onHover = function(pixels, overlay, lineX, tooltip) {
var coords;
coords = map.getCoordinateFromPixel(pixels);
overlay.setPosition([lineX, coords[1]]);
@@ -206,7 +208,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var onMouseOut = function (tooltip) {
+ var onMouseOut = function(tooltip) {
tooltip.setState({
active: false
});
@@ -222,15 +224,15 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var updateDate = function (date) {
+ var updateDate = function(date) {
var leftState, rightState;
leftState = {
- dateLeft: wv.util.toISOStringDate(wv.util.dateAdd(date, 'day', 1)),
- dateRight: wv.util.toISOStringDate(date)
+ dateLeft: util.toISOStringDate(util.dateAdd(date, 'day', 1)),
+ dateRight: util.toISOStringDate(date)
};
rightState = {
- dateLeft: wv.util.toISOStringDate(date),
- dateRight: wv.util.toISOStringDate(wv.util.dateAdd(date, 'day', -1))
+ dateLeft: util.toISOStringDate(date),
+ dateRight: util.toISOStringDate(util.dateAdd(date, 'day', -1))
};
textLeft.setState(leftState);
textRight.setState(rightState);
@@ -246,7 +248,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var position = function (map) {
+ var position = function(map) {
var extent, top, topY, bottomY, bottom, height, startY, topExtent, bottomExtent;
if (map.getSize()[0] === 0) {
@@ -287,7 +289,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var update = function (dimensions) {
+ var update = function(dimensions) {
var state = {
height: dimensions[0]
};
@@ -308,7 +310,7 @@ wv.map.datelinebuilder = wv.map.datelinebuilder || function (models, config) {
*
* @returns {void}
*/
- var drawOverlay = function (coordinate, el) {
+ var drawOverlay = function(coordinate, el) {
var overlay = new ol.Overlay({
element: el,
stopEvent: false