Interactive interface for browsing global, full-resolution satellite imagery
Replace date selector with WVC component #902
Benjamin Kingfc439f795914
diff --git a/web/index.html b/web/index.htmlindex 201f77cb2..d3a1f854a 100644--- a/web/index.html+++ b/web/index.html@@ -9,198 +9,118 @@ Copyright (C) 2013 - 2016 United States Government as represented by the AdminisLicensed under the NASA Open Source Agreement, Version 1.3 (http://opensource.gsfc.nasa.gov/nosa.php)--><html>+<head>- <title>@OFFICIAL_NAME@</title>- <meta http-equiv="X-UA-Compatible" content="IE=edge">-- <script type="text/javascript">- if ( /MSIE (\d+\.\d+);/.test(navigator.userAgent) && ! /unsupported/.test(location.search) ) {- var version = parseFloat(navigator.appVersion.split("MSIE")[1]);- if ( version < 9 ) {- document.location.replace("pages/unsupported_browser.html" + location.search);- }- }- </script>-- <link rel="shortcut icon" href="brand/images/wv-icon.ico" type="image/vnd.microsoft.icon" />-- <!-- meta defines -->- <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">- <meta name="apple-mobile-web-app-capable" content="yes">- <meta name="keywords" content="nasa, worldview, nasa worldview, eosdis worldview, satellite imagery, remote sensing, natural hazards, natural disasters, near real-time, nrt, lance, wildfire management, air quality, weather forecasting, agriculture, dust storms, smoke plumes, vegetation, severe storms, shipping, fisheries, floods, drought, oil spills">- <meta name="description" content="Interactive interface for browsing full-resolution, global satellite imagery. Supports time-critical application areas such as wildfire management, air quality measurements, and weather forecasting. Data is generally available within three hours of observation.">- <meta http-equiv="Cache-control" content="no-cache">- <meta http-equiv="Cache-control" content="no-store">- <meta http-equiv="Pragma" content="no-cache">-- <!-- open graph for social sharing -->- <meta property="og:title" content="Worldview: Explore Your Dynamic Planet">- <meta property="og:image" content="images/preview.png" />- <meta property="og:description" content="The NASA Worldview app provides a satellite's perspective of the planet as it looks today and as it has in the past. Worldview is part of NASA’s Earth Observing System Data and Information System. EOSDIS makes the agency's large repository of data accessible and freely available to the public.">-- <link type="text/css" rel="Stylesheet" href="build/wv.css?v=@BUILD_NONCE@">- <script type="text/javascript" src="build/wv.js?v=@BUILD_NONCE@"></script>+ <title>@OFFICIAL_NAME@</title>+ <meta http-equiv="X-UA-Compatible" content="IE=edge">++ <script type="text/javascript">+ if (/MSIE (\d+\.\d+);/.test(navigator.userAgent) && ! /unsupported/.test(location.search)) {+ var version = parseFloat(navigator.appVersion.split("MSIE")[1]);+ if (version < 9) {+ document.location.replace("pages/unsupported_browser.html" + location.search);+ }+ }+ </script>++ <link rel="shortcut icon" href="brand/images/wv-icon.ico" type="image/vnd.microsoft.icon" />++ <!-- meta defines -->+ <meta http-equiv="Content-Type" content="text/html" charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">+ <meta name="apple-mobile-web-app-capable" content="yes">+ <meta name="keywords" content="nasa, worldview, nasa worldview, eosdis worldview, satellite imagery, remote sensing, natural hazards, natural disasters, near real-time, nrt, lance, wildfire management, air quality, weather forecasting, agriculture, dust storms, smoke plumes, vegetation, severe storms, shipping, fisheries, floods, drought, oil spills">+ <meta name="description" content="Interactive interface for browsing full-resolution, global satellite imagery. Supports time-critical application areas such as wildfire management, air quality measurements, and weather forecasting. Data is generally available within three hours of observation.">+ <meta http-equiv="Cache-control" content="no-cache">+ <meta http-equiv="Cache-control" content="no-store">+ <meta http-equiv="Pragma" content="no-cache">++ <!-- open graph for social sharing -->+ <meta property="og:title" content="Worldview: Explore Your Dynamic Planet">+ <meta property="og:image" content="images/preview.png" />+ <meta property="og:description" content="The NASA Worldview app provides a satellite's perspective of the planet as it looks today and as it has in the past. Worldview is part of NASA’s Earth Observing System Data and Information System. EOSDIS makes the agency's large repository of data accessible and freely available to the public.">++ <link type="text/css" rel="Stylesheet" href="build/wv.css?v=@BUILD_NONCE@">+ <script type="text/javascript" src="build/wv.js?v=@BUILD_NONCE@"></script></head><body>- <div data-role="page" id="app">- <div data-role="content">- <ul id="wv-toolbar">- <li id="wv-link-button" class="wv-toolbar-button"></li>- <li id="wv-proj-button" class="wv-toolbar-button"></li>- <li id="wv-image-button" class="wv-toolbar-button"></li>- <li id="wv-info-button" class="wv-toolbar-button wv-status-hide"></li>- </ul>- <a href="/" title="Click to Reset Worldview to Defaults" id="wv-logo"></a>- <section id="productsHolder">- <ul id="productsHolder-tabs"></ul>- <div id="productsHoldertoggleButtonHolder"></div>- <div id="products"></div>- <div id="wv-events"></div>- <div id="wv-data"></div>- </section>- <div id="wv-map" class="wv-map"></div>- <div id="eventsHolder"></div>- <div id="imagedownload"></div>- <div id="dlMap"></div>-- <div id="timewheels" style="display:none"></div>-- <section id="timeline" class="timeline-inner clearfix" style="display: none">- <div id="timeline-header">- <div id="focus-guard-1" class="focus-guard" tabindex="1"></div>- <div id="input-wrapper-year" class="input-wrapper input-wrapper-year selectable">- <div class="date-arrows date-arrow-up" data-interval="year" data-value="1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>- </svg>- </div>- <input type="text" size="4" maxlength="4" class="button-input-group 1-interval-group" id="year-input-group" tabindex="2" />- <div class="date-arrows date-arrow-down" data-interval="year" data-value="-1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>- </svg>- </div>- </div>- <div id="input-wrapper-month" class="input-wrapper input-wrapper-month selectable">- <div class="date-arrows date-arrow-up" data-interval="month" data-value="1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>- </svg>- </div>- <input type="text" size="3" maxlength="3" class="button-input-group 1-interval-group" id="month-input-group" tabindex="3" />- <div class="date-arrows date-arrow-down" data-interval="month" data-value="-1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>- </svg>- </div>- </div>-- <div id="input-wrapper-day" class="input-wrapper input-wrapper-day selectable">- <div class="date-arrows date-arrow-up" data-interval="day" data-value="1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>- </svg>- </div>- <input type="text" size="2" maxlength="2" class="button-input-group 1-interval-group" id="day-input-group" tabindex="4" onkeypress="return (event.charCode >= 48 && event.charCode <= 57) || event.keyCode == 13 || event.keyCode == 9 || even.keyCode == 8" />- <div class="date-arrows date-arrow-down" data-interval="day" data-value="-1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>- </svg>- </div>- </div>-- <div id="input-wrapper-hour" class="input-wrapper input-wrapper-hour">- <div class="date-arrows date-arrow-up" data-interval="hour" data-value="1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>- </svg>- </div>- <input type="text" size="2" maxlength="2" class="button-input-group 1-interval-group" id="hour-input-group" tabindex="5" />- <div class="date-arrows date-arrow-down" data-interval="hour" data-value="-1">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>- </svg>- </div>- </div>-- <div id="input-time-divider" class="input-time-divider">:</div>-- <div id="input-wrapper-minute" class="input-wrapper input-wrapper-minute">- <div class="date-arrows date-arrow-up" data-interval="minute" data-value="10">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="uparrow"></path>- </svg>- </div>- <input type="text" size="2" maxlength="2" step="10" class="button-input-group 10-interval-group" id="minute-input-group" tabindex="6" />- <div class="date-arrows date-arrow-down" data-interval="minute" data-value="-10">- <svg width="25" height="8">- <path d="M 12.5,0 25,8 0,8 z" class="downarrow"></path>- </svg>- </div>- </div>- <div id="input-time-zmark" class="input-time-zmark">Z</div>- <div id="focus-guard-2" class="focus-guard" tabindex="7"></div>- <div id="zoom-buttons-group">- <div id="zoom-btn-container">- <span id="current-zoom" class="zoom-btn zoom-btn-active" data-zoom="3">Days</span>- <div class="wv-tooltip">- <div id="timeline-zoom" class="timeline-zoom">- <span id="zoom-years" class="zoom-btn zoom-btn-inactive zoom-years" data-zoom="1">Years</span>- <span id="zoom-months" class="zoom-btn zoom-btn-inactive zoom-months" data-zoom="2">Months</span>- <span id="zoom-days" class="zoom-btn zoom-btn-inactive zoom-days" data-zoom="3">Days</span>- <span id="zoom-minutes" class="zoom-btn zoom-btn-inactive zoom-minutes" data-zoom="4">Minutes</span>- </div>- </div>- </div>- <div class="button-action-group" id="left-arrow-group" title="Click and hold to animate backwards">- <svg width="24" height="30">- <path- d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"- class="arrow"></path>- </svg>- </div>- <div class="button-action-group" id="right-arrow-group" title="Click and hold to animate forwards">- <svg width="24" height="30" >- <path- d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z"- class="arrow"></path>- </svg>- </div>- </div>- <div class="button-action-group animate-button" id="animate-button" title="Set up animation">- <i id="wv-animate" class="fa fa-video-camera wv-animate"></i>- </div>-- </div>- <div id="timeline-footer">- <div id="wv-animation-widet-case"> </div>+ <div data-role="page" id="app">+ <div data-role="content">+ <ul id="wv-toolbar">+ <li id="wv-link-button" class="wv-toolbar-button"></li>+ <li id="wv-proj-button" class="wv-toolbar-button"></li>+ <li id="wv-image-button" class="wv-toolbar-button"></li>+ <li id="wv-info-button" class="wv-toolbar-button wv-status-hide"></li>+ </ul>+ <section id="wv-sidebar">+ </section>+ <div id="wv-map" class="wv-map"></div>+ <div id="eventsHolder"></div>+ <div id="imagedownload"></div>+ <div id="dlMap"></div>++ <div id="timewheels" style="display:none"></div>++ <section id="timeline" class="timeline-inner clearfix" style="display: none">+ <div id="timeline-header">+ <div id="date-selector-main"></div>+ <div id="zoom-buttons-group">+ <div id="zoom-btn-container">+ <span id="current-zoom" class="zoom-btn zoom-btn-active" data-zoom="3">Days</span>+ <div class="wv-tooltip">+ <div id="timeline-zoom" class="timeline-zoom">+ <span id="zoom-years" class="zoom-btn zoom-btn-inactive zoom-years" data-zoom="1">Years</span>+ <span id="zoom-months" class="zoom-btn zoom-btn-inactive zoom-months" data-zoom="2">Months</span>+ <span id="zoom-days" class="zoom-btn zoom-btn-inactive zoom-days" data-zoom="3">Days</span>+ <span id="zoom-minutes" class="zoom-btn zoom-btn-inactive zoom-minutes" data-zoom="4">Minutes</span></div>- <div id="timeline-hide">- <svg class="hamburger" width="10" height="9">- <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z"></path>- </svg>- </div>- </section>+ </div>+ </div>+ <div class="button-action-group" id="left-arrow-group" title="Click and hold to animate backwards">+ <svg id="timeline-svg" width="24" height="30">+ <path d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z" class="arrow"></path>+ </svg>+ </div>+ <div class="button-action-group" id="right-arrow-group" title="Click and hold to animate forwards">+ <svg width="24" height="30">+ <path d="M 10.240764,0 24,15 10.240764,30 0,30 13.759236,15 0,0 10.240764,0 z" class="arrow"></path>+ </svg>+ </div>+ </div>+ <div class="button-action-group animate-button" id="animate-button" title="Set up animation">+ <i id="wv-animate" class="fa fa-video-camera wv-animate"></i>+ </div></div>+ <div id="timeline-footer">+ <div id="wv-animation-widet-case"> </div>+ </div>+ <div id="timeline-hide">+ <svg class="hamburger" width="10" height="9">+ <path d="M 0,0 0,1 10,1 10,0 0,0 z M 0,4 0,5 10,5 10,4 0,4 z M 0,8 0,9 10,9 10,8 0,8 z"></path>+ </svg>+ </div>+ </section>+</div>- <section id="layer-modal" class="layer-modal">- <header id="layer-modal-header" class="layer-modal-header"></header>- <div id="layer-modal-content" class="layer-modal-content">- <div id="layer-categories" class="layer-categories"></div>- <div id="selected-category" class="selected-category"></div>- <div id="layers-all" class="layers-all"></div>- </div>- <footer></footer>- </section>- <div id="wv-tour-content" class="tour-content"></div>- <div id="wv-image-top" class="wv-image-coords"></div>- <div id="wv-image-right" class="wv-image-coords"></div>- <div id="wv-image-bottom" class="wv-image-coords"></div>- <div id="wv-image-left" class="wv-image-coords"></div>- <div class="backdrop"></div>+ </div>+ <section id="layer-modal" class="layer-modal">+ <header id="layer-modal-header" class="layer-modal-header"></header>+ <div id="layer-modal-content" class="layer-modal-content">+ <div id="layer-categories" class="layer-categories"></div>+ <div id="selected-category" class="selected-category"></div>+ <div id="layers-all" class="layers-all"></div>+ </div>+ <footer></footer>+ </section>+ <div id="wv-tour-content" class="tour-content"></div>+ <div id="wv-image-top" class="wv-image-coords"></div>+ <div id="wv-image-right" class="wv-image-coords"></div>+ <div id="wv-image-bottom" class="wv-image-coords"></div>+ <div id="wv-image-left" class="wv-image-coords"></div>+ <div class="backdrop"></div></body>-</html>++</html>\ No newline at end of filediff --git a/web/js/date/timeline-input.js b/web/js/date/timeline-input.jsindex 8d027ce15..868ab5f5a 100644--- a/web/js/date/timeline-input.js+++ b/web/js/date/timeline-input.js@@ -1,8 +1,11 @@import $ from 'jquery';import util from '../util/util';-import lodashParseInt from 'lodash/parseInt';-import lodashDebounce from 'lodash/debounce';+import { getActiveDateString } from '../compare/util';+import { DateSelector } from 'worldview-components';+import React from 'react';+import ReactDOM from 'react-dom';+const dateSelectorStr = 'date-selector-main';/*** Implements the date input*@@ -12,21 +15,21 @@ export function timelineInput(models, config, ui) {var tl = ui.timeline;var model = models.date;var self = {};- var rollingDate;self.direction = 'forward';self.interval = 'day';self.delta = 1;self.active = false;self.delay = 500;+ self.reactComponent = null;var animator = null;var keyDown;var $incrementBtn = $('#right-arrow-group');var $decrementBtn = $('#left-arrow-group');- var init = function () {+ var init = function() {$incrementBtn- .mousedown(function (e) {+ .mousedown(function(e) {e.preventDefault();switch (ui.timeline.config.currentZoom) {case 1:@@ -48,7 +51,7 @@ export function timelineInput(models, config, ui) {.mouseup(stopper);$decrementBtn- .mousedown(function (e) {+ .mousedown(function(e) {e.preventDefault();switch (ui.timeline.config.currentZoom) {case 1:@@ -71,8 +74,10 @@ export function timelineInput(models, config, ui) {$(document).mouseout(stopper)- .keydown(function (event) {- if (event.target.nodeName === 'INPUT' || keyDown === event.keyCode) return;+ .keydown(function(event) {+ if (event.target.nodeName === 'INPUT' || keyDown === event.keyCode) {+ return;+ }switch (event.keyCode) {case util.key.LEFT:switch (models.date.selectedZoom) {@@ -110,7 +115,7 @@ export function timelineInput(models, config, ui) {}keyDown = event.keyCode;})- .keyup(function (event) {+ .keyup(function(event) {switch (event.keyCode) {case util.key.LEFT:case util.key.RIGHT:@@ -120,146 +125,68 @@ export function timelineInput(models, config, ui) {}keyDown = null;});- // bind click action to interval radio buttons- var $buttons = $('.button-input-group');- var $oneIntervalButtons = $('.1-interval-group');- var $tenIntervalButtons = $('.10-interval-group');- $buttons.unbind();- $oneIntervalButtons.unbind();- $tenIntervalButtons.unbind();-- // FIXME: Quick fix for fixing the propagation- // of events with arrow keys and input field- $oneIntervalButtons.keydown(function (event) {- var interval = $(this)- .attr('id')- .split('-')[0];- event.stopPropagation();- if (event.keyCode === (util.key.LEFT || util.key.RIGHT)) {- event.preventDefault();- $(this)- .select()- .focus();- } else if (event.keyCode === (util.key.UP)) {- event.preventDefault();- roll(interval, 1);- $(this)- .select()- .focus();- } else if (event.keyCode === (util.key.DOWN)) {- event.preventDefault();- roll(interval, -1);- $(this)- .select()- .focus();- }- });-- // FIXME: Quick fix for fixing the propagation- // of events with arrow keys and input field- $tenIntervalButtons.keydown(function (event) {- var interval = $(this)- .attr('id')- .split('-')[0];- event.stopPropagation();- if (event.keyCode === (util.key.LEFT || util.key.RIGHT)) {- event.preventDefault();- $(this)- .select()- .focus();- } else if (event.keyCode === (util.key.UP)) {- event.preventDefault();- roll(interval, 10);- $(this)- .select()- .focus();- } else if (event.keyCode === (util.key.DOWN)) {- event.preventDefault();- roll(interval, -10);- $(this)- .select()- .focus();- }- });-- $buttons.on('focus', function (e) {- e.preventDefault();- $buttons.siblings('.date-arrows')- .css('visibility', '');- $buttons.parent()- .removeClass('selected');- $(this)- .parent()- .addClass('selected');- $(this)- .siblings('.date-arrows')- .css('visibility', 'visible');- });- $buttons.focusout(function (e) {- $buttons.siblings('.date-arrows')- .css('visibility', '');- $buttons.parent()- .removeClass('selected');- });-- var $incrementIntDate = $('.date-arrow-up');- $incrementIntDate.click(roll);- $incrementIntDate.mousedown(function (e) {- e.preventDefault();- });-- var $decrementIntDate = $('.date-arrow-down');- $decrementIntDate.click(roll);- $decrementIntDate.mousedown(function (e) {- e.preventDefault();+ if (util.browser.tests.touchDevice()) {+ $('.button-input-group').prop('disabled', true);+ }+ self.reactComponent = ReactDOM.render(+ React.createElement(DateSelector, getProps()),+ document.getElementById(dateSelectorStr)+ );+ model.events.on('select', date => {+ console.log('select');+ self.reactComponent.setState({ date: date });});- // select all input on focus- $('input')- .focus(function (e) {- $(this)- .select();- })- .mouseup(function (e) {- e.preventDefault();- });-- $('.button-input-group')- .keydown(validateInput)- .focusout(function (event) {- if ($(this)- .hasClass('focus')) {- $(this)- .removeClass('focus');- validateInput.call(this, event);- }- })- .focus(function () {- $(this)- .addClass('focus');- });-- $('#focus-guard-1')- .on('focus', function () {- $('#minute-input-group')- .focus()- .select();+ if (config.features.compare) {+ models.compare.events.on('toggle-state', () => {+ var dateModel = models.date;+ var activeDate =+ model.activeDate === 'selected' ? 'selectedB' : 'selected';+ model.activeDate = activeDate;+ self.reactComponent.setState({+ date: dateModel[activeDate]+ });});- $('#focus-guard-2')- .on('focus', function () {- $('#year-input-group')- .focus()- .select();- });-- if (util.browser.tests.touchDevice()) {- $('.button-input-group')- .prop('disabled', true);}-self.update();};+ var getProps = function() {+ var dateSelection = 'selected';+ var model = models.date;+ var min = model.minDate();+ var max = model.maxDate();+ if (models.compare.active) {+ let compareModel = models.compare;+ dateSelection = getActiveDateString(+ compareModel.active,+ compareModel.isCompareA+ );+ }+ var date = model[dateSelection];+ return {+ width: '120',+ height: '30',+ id: 'main',+ idSuffix: 'animation-widget-main',+ minDate: min,+ maxDate: max,+ maxZoom: model.maxZoom,+ onDateChange: onDateSelect,+ date: date+ };+ };+ var onDateSelect = function(date) {+ var dateSelection = '';+ if (models.compare.active) {+ let compareModel = models.compare;+ dateSelection = getActiveDateString(+ compareModel.active,+ compareModel.isCompareA+ );+ }+ models.date.select(date, dateSelection);+ };/*** Add timeout to date change when buttons are being held so that* date changes don't happen too quickly@@ -273,11 +200,19 @@ export function timelineInput(models, config, ui) {*/var animateByIncrement = function(delta, increment) {self.delta = Math.abs(delta);+ var dateSelection = '';+ if (models.compare.active) {+ let compareModel = models.compare;+ dateSelection = getActiveDateString(+ compareModel.active,+ compareModel.isCompareA+ );+ }function animate() {var nextTime = getNextTimeSelection(delta, increment);if (tl.data.start() <= nextTime <= util.now()) {- models.date.add(increment, delta);- };+ models.date.add(increment, delta, dateSelection);+ }animator = setTimeout(animate, self.delay);}animate();@@ -300,234 +235,42 @@ export function timelineInput(models, config, ui) {var getNextTimeSelection = function(delta, increment) {switch (increment) {case 'year':- return new Date(new Date(model.selected).setUTCFullYear(model.selected.getUTCFullYear() + increment));+ return new Date(+ new Date(model.selected).setUTCFullYear(+ model.selected.getUTCFullYear() + increment+ )+ );case 'month':- return new Date(new Date(model.selected).setUTCMonth(model.selected.getUTCMonth() + increment));+ return new Date(+ new Date(model.selected).setUTCMonth(+ model.selected.getUTCMonth() + increment+ )+ );case 'day':- return new Date(new Date(model.selected).setUTCDate(model.selected.getUTCDate() + increment));+ return new Date(+ new Date(model.selected).setUTCDate(+ model.selected.getUTCDate() + increment+ )+ );case 'minute':- return new Date(new Date(model.selected).setUTCMinutes(model.selected.getUTCMinutes() + increment));- }- };- /**- * Change date input with up or down button and roll date if- * max or min date is reached when changed- *- * @param {String} dataInterval Interval of change- * e.g. months,minutes, years, days- * @param {Number} amt Amount to change- * @return {void}- */- var roll = function (dataInterval, amt) {- var interval = $(this)- .attr('data-interval') || dataInterval;- var amount = lodashParseInt($(this)- .attr('data-value')) || amt;- var date = rollingDate || models.date.selected;- var min = models.date.minDate();- var max = models.date.maxDate();- var newDate = util.rollDate(date, interval, amount, min, max);- if (newDate !== date) {- rollingDate = newDate;- $(this)- .parent()- .css('border-color', '');- updateDateInputs(rollingDate);- debounceDateChange(rollingDate, this);- }- };- /**- * @param {Object} newDate JS date Object- * @param {el} el JS element- * @return {void}- */- var selectNewDate = function(newDate, el) {- model.select(newDate);- $(el)- .parent()- .find('input')- .select();- };- var debounceDateChange = lodashDebounce(selectNewDate, self.delay);-- // TODO: Replace with WVC- var validateInput = function (event) {- var kc = event.keyCode || event.which;- var entered = (kc === 13) || (kc === 9); // carriage return or horizontal tab- if (event.type === 'focusout' || entered) {- if (entered) {- event.preventDefault();- }-- let selected = $(this);- let YMDInterval = selected.attr('id');- let newInput = selected.val();- let selectedDateObj = null;- switch (YMDInterval) {- case 'year-input-group':- if ((newInput > 1000) && (newInput < 9999)) {- selectedDateObj = new Date(- (new Date(model.selected))- .setUTCFullYear(newInput));- }- break;- case 'month-input-group':- if (($.isNumeric(newInput)) &&- (newInput < 13) && (newInput > 0)) {- selectedDateObj = new Date(- (new Date(model.selected))- .setUTCMonth(newInput - 1));- } else {- let validStr = false;- let newIntInput;- newInput = newInput.toUpperCase();-- for (var i = 0; i < model.monthAbbr.length; i++) {- if (newInput === model.monthAbbr[i]) {- validStr = true;- newIntInput = i;- }- }- if (validStr) {- selectedDateObj = new Date(- (new Date(model.selected))- .setUTCMonth(newIntInput));- }- }- break;- case 'day-input-group':- if (newInput > 0 &&- newInput <= (new Date(model.selected.getYear(),- model.selected.getMonth() + 1, 0)- .getDate())) {- selectedDateObj = new Date(- (new Date(model.selected))- .setUTCDate(newInput));- }- break;- case 'hour-input-group':- if ((newInput >= 0) && (newInput <= 23)) {- selectedDateObj = new Date(- (new Date(model.selected))- .setUTCHours(newInput));- }- break;- case 'minute-input-group':- if ((newInput >= 0) && (newInput <= 59)) {- let coeff = 1000 * 60 * 10;- selectedDateObj = new Date(Math.round(- (new Date(model.selected))- .setUTCMinutes(newInput) / coeff) * coeff);- }- break;- }- if ((selectedDateObj > tl.data.start()) &&- (selectedDateObj <= util.now())) {- var parent = selected.parent();- var sib = parent.next('div.input-wrapper.selectable')- .find('input.button-input-group');- if (parent.next('#input-time-divider').length) {- sib = parent.next().next('div.input-wrapper.selectable')- .find('input.button-input-group');- }-- if (entered && sib.length < 1) {- $('#focus-guard-2')- .focus();- }-- if (selectedDateObj) model.select(selectedDateObj);-- $('.button-input-group')- .parent()- .css('border-color', '');-- selected.parent()- .removeClass('selected');-- if (entered) {- sib.select()- .addClass('selected');- }- } else {- selected.parent()- .css('border-color', '#ff0000');- if (event.type !== 'focusout') {- selected.select();- } else {- if (document.selection) {- document.selection.empty();- } else {- window.getSelection()- .removeAllRanges();- }- selected.parent()- .animate({- borderColor: 'rgba(40, 40, 40, .9)'- }, {- complete: function () {- selected.parent()- .css('border-color', '');- }- });- self.update();- }- }+ return new Date(+ new Date(model.selected).setUTCMinutes(+ model.selected.getUTCMinutes() + increment+ )+ );}};- // TODO: Combine with self.update- var updateDateInputs = function (date) {- date = date || models.selected.date;- $('#year-input-group')- .val(date.getUTCFullYear());- $('#month-input-group')- .val(model.monthAbbr[date.getUTCMonth()]);- $('#day-input-group')- .val(util.pad(date.getUTCDate(), 2, '0'));- $('#hour-input-group')- .val(util.pad(date.getUTCHours(), 2, '0'));- $('#minute-input-group')- .val(util.pad(date.getUTCMinutes(), 2, '0'));- };-// TODO: Cleanup- self.update = function (date) {+ self.update = function(date) {var ms = date || new Date(model.selected);var nd = new Date(ms.setUTCDate(ms.getUTCDate() + 1));var pd = new Date(ms.setUTCDate(ms.getUTCDate() - 1));- // Update fields- $('#year-input-group')- .val(model.selected.getUTCFullYear());- $('#month-input-group')- .val(model.monthAbbr[model.selected.getUTCMonth()]);- if (model.selected.getUTCDate() < 10) {- $('#day-input-group')- .val('0' + model.selected.getUTCDate());- } else {- $('#day-input-group')- .val(model.selected.getUTCDate());- }- if (model.selected.getUTCHours() < 10) {- $('#hour-input-group')- .val('0' + model.selected.getUTCHours());- } else {- $('#hour-input-group')- .val(model.selected.getUTCHours());- }- if (model.selected.getUTCMinutes() < 10) {- $('#minute-input-group')- .val('0' + model.selected.getUTCMinutes());- } else {- $('#minute-input-group')- .val(model.selected.getUTCMinutes());- }-// Disable arrows if nothing before/after selection- if ((model.selectedZoom === 4) && ms >= util.now()) {+ if (model.selectedZoom === 4 && ms >= util.now()) {$incrementBtn.addClass('button-disabled');- } else if ((model.selectedZoom !== 4) && nd > util.now()) {+ } else if (model.selectedZoom !== 4 && nd > util.now()) {$incrementBtn.addClass('button-disabled');} else {$incrementBtn.removeClass('button-disabled');@@ -543,4 +286,4 @@ export function timelineInput(models, config, ui) {init();return self;-};+}