Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Add escape key commands and click outside of modal to close

ZachTRice1f8bfaca6c07
diff --git a/web/css/tour.css b/web/css/tour.css
index f0de0f368..70c49248f 100644
--- a/web/css/tour.css
+++ b/web/css/tour.css
@@ -741,10 +741,6 @@
.tour {
display: block;
}
-}
-
-/* Breakpoint: Medium (768px to 991px) */
-@media (min-width: 768px) {
/* .tour-start */
.tour-start .modal {
diff --git a/web/js/components/tour/modal-tour-complete.js b/web/js/components/tour/modal-tour-complete.js
index 89e5e85f8..d64644c48 100644
--- a/web/js/components/tour/modal-tour-complete.js
+++ b/web/js/components/tour/modal-tour-complete.js
@@ -20,7 +20,7 @@ class ModalComplete extends React.Component {
}
return (
<div>
- <Modal isOpen={this.props.modalComplete} toggle={this.props.toggleModalComplete} wrapClassName='tour tour-complete' className={this.props.className} backdrop={true}>
+ <Modal isOpen={this.props.modalComplete} toggle={this.props.toggleModalComplete} wrapClassName='tour tour-complete' className={this.props.className} backdrop={'static'} fade={false} keyboard={true}>
<ModalHeader toggle={this.props.toggleModalComplete} charCode="">Story Complete</ModalHeader>
<ModalBody>
<p>You have now completed a story in Worldview. To view more stories, click the "More Stories" button below to explore more events within the app. Click the "Exit Tutorial" button or close this window to start using Worldview on your own.</p>
diff --git a/web/js/components/tour/modal-tour-in-progress.js b/web/js/components/tour/modal-tour-in-progress.js
index 463d286e9..f2fb5c02b 100644
--- a/web/js/components/tour/modal-tour-in-progress.js
+++ b/web/js/components/tour/modal-tour-in-progress.js
@@ -30,6 +30,15 @@ class ModalInProgress extends React.Component {
this.loadLink = this.loadLink.bind(this);
this.setUI = this.setUI.bind(this);
this.processActions = this.processActions.bind(this);
+ this.escFunction = this.escFunction.bind(this);
+ }
+
+ componentDidMount() {
+ document.addEventListener('keydown', this.escFunction, false);
+ }
+
+ componentWillUnmount() {
+ document.removeEventListener('keydown', this.escFunction, false);
}
componentDidUpdate(prevProps) {
@@ -73,6 +82,13 @@ class ModalInProgress extends React.Component {
}
}
+ // Use custom escFunction since tabIndex prevents escape key use on loading WV
+ escFunction(e) {
+ if (e.keyCode === 27 && this.props.modalInProgress) {
+ this.props.toggleModalInProgress(e);
+ }
+ }
+
fetchMetadata(currentStory, stepIndex) {
var description = currentStory.steps[stepIndex]['description'];
var { origin, pathname } = window.location;
@@ -403,7 +419,7 @@ class ModalInProgress extends React.Component {
return (
<div>
- <Modal isOpen={this.props.modalInProgress} toggle={this.props.toggleModalInProgress} onClosed={this.props.showTourAlert} wrapClassName='tour tour-in-progress' className={this.props.className + ' ' + this.props.currentStory['type']} backdrop={false}>
+ <Modal isOpen={this.props.modalInProgress} toggle={this.props.toggleModalInProgress} onClosed={this.props.showTourAlert} wrapClassName='tour tour-in-progress' className={this.props.className + ' ' + this.props.currentStory['type']} backdrop={false} keyboard={false}>
<ModalHeader toggle={this.props.toggleModalInProgress} charCode="">{this.props.currentStory['title']}<i className="modal-icon" aria-hidden="true"></i></ModalHeader>
<ModalBody>
{/* eslint-disable */}
diff --git a/web/js/components/tour/modal-tour-start.js b/web/js/components/tour/modal-tour-start.js
index 4736f862a..c02c2ba9b 100644
--- a/web/js/components/tour/modal-tour-start.js
+++ b/web/js/components/tour/modal-tour-start.js
@@ -11,9 +11,43 @@ class ModalStart extends React.Component {
checked: localStorage.hideTour
};
+ this.setWrapperRef = this.setWrapperRef.bind(this);
+ this.handleClickOutside = this.handleClickOutside.bind(this);
this.handleCheck = this.handleCheck.bind(this);
+ this.escFunction = this.escFunction.bind(this);
}
+ componentDidMount() {
+ document.addEventListener('mousedown', this.handleClickOutside);
+ document.addEventListener('keydown', this.escFunction, false);
+ }
+
+ componentWillUnmount() {
+ document.removeEventListener('mousedown', this.handleClickOutside);
+ document.removeEventListener('keydown', this.escFunction, false);
+ }
+
+ // Set a reference to the inner div for checking clicks outside of the scrollbar
+ setWrapperRef(node) {
+ this.wrapperRef = node;
+ }
+
+ // Use custom escFunction since tabIndex prevents escape key use on loading WV
+ escFunction(e) {
+ if (e.keyCode === 27 && this.props.modalStart) {
+ this.props.toggleModalStart(e);
+ }
+ }
+
+ // Use custom clickOutside function since we contained the clickable area with
+ // CSS to have a cleaner looking scrollbar
+ handleClickOutside(e) {
+ if (this.wrapperRef && !this.wrapperRef.contains(e.target)) {
+ this.props.toggleModalStart(e);
+ }
+ }
+
+ // Handle the show/hide checkbox state
handleCheck() {
this.setState({
checked: !this.state.checked,
@@ -28,7 +62,7 @@ class ModalStart extends React.Component {
render() {
return (
- <Modal isOpen={this.props.modalStart} toggle={this.props.toggleModalStart} onClosed={this.props.showTourAlert} wrapClassName='tour tour-start' className={this.props.className} backdrop={true}>
+ <Modal isOpen={this.props.modalStart} toggle={this.props.toggleModalStart} onClosed={this.props.showTourAlert} wrapClassName='tour tour-start' className={this.props.className} backdrop={true} fade={false} keyboard={false} innerRef={this.setWrapperRef}>
<ModalHeader toggle={this.props.toggleModalStart} charCode="">Welcome to Worldview!</ModalHeader>
<ModalBody>
<TourIntro toggleModalStart={this.props.toggleModalStart}></TourIntro>