Interactive interface for browsing global, full-resolution satellite imagery
Move startTour method out of components
ZachTRice59918365d94a
diff --git a/web/js/components/tour/modal-in-progress.js b/web/js/components/tour/modal-in-progress.jsindex 63ef0d242..49b0125b0 100644--- a/web/js/components/tour/modal-in-progress.js+++ b/web/js/components/tour/modal-in-progress.js@@ -61,7 +61,6 @@ class ModalInProgress extends React.Component {currentStepIndex = (currentStepIndex - 1).toString().padStart(0, '0');var currentStoryId = this.props.currentStoryId;stepLink = currentStoryId.stepLink;- console.log(stepLink);// Get URL Link here from JSON file (for each step)// Push Link to Browser URL@@ -153,7 +152,9 @@ class ModalInProgress extends React.Component {<Modal isOpen={this.props.modalInProgress} toggle={this.props.toggleModalInProgress} wrapClassName='tour tour-in-progress' className={this.props.className + ' ' + this.props.currentStory['type']} backdrop={false}><ModalHeader toggle={this.props.toggleModalInProgress} charCode="">{this.props.currentStory['title']}<i className="modal-icon" aria-hidden="true"></i></ModalHeader><ModalBody>+ {/* eslint-disable */}<div dangerouslySetInnerHTML={{ __html: description }} />+ {/* eslint-enable */}</ModalBody><ModalFooter><Steps currentStep={this.props.currentStep} totalSteps={this.props.totalSteps} decreaseStep={this.props.decreaseStep} incrementStep={this.props.incrementStep}></Steps>diff --git a/web/js/components/tour/tour-box.js b/web/js/components/tour/tour-box.jsindex b724e7039..e64dee496 100644--- a/web/js/components/tour/tour-box.js+++ b/web/js/components/tour/tour-box.js@@ -43,7 +43,7 @@ class TourBox extends React.Component {render() {return (- <a href="#" style={this.state.styles} onMouseOver={(e) => this.onMouseOver(e)} onMouseOut={(e) => this.onMouseOut(e)} className={this.props.className} onClick={(e) => this.props.startTour(e, this.props.story, this.props.key, this.props.storyId)}>+ <a href="#" style={this.state.styles} onMouseOver={(e) => this.onMouseOver(e)} onMouseOut={(e) => this.onMouseOut(e)} className={this.props.className} onClick={(e) => this.props.startTour(e, this.props.story, this.props.index, this.props.storyId)}><div className="tour-box-content"><div className="tour-box-header"><h3 className="tour-box-title">{this.props.title}</h3>@@ -58,7 +58,7 @@ class TourBox extends React.Component {}TourBox.propTypes = {- key: PropTypes.number.isRequired,+ index: PropTypes.number.isRequired,story: PropTypes.object.isRequired,storyId: PropTypes.string.isRequired,title: PropTypes.string,diff --git a/web/js/components/tour/tour-boxes.js b/web/js/components/tour/tour-boxes.jsindex a2441d6e9..ac560a70b 100644--- a/web/js/components/tour/tour-boxes.js+++ b/web/js/components/tour/tour-boxes.js@@ -10,7 +10,7 @@ class TourBoxes extends React.Component {<div className="tour-box-row">{storyOrder.map(function(storyId, i) {let story = stories[storyId];- return (<TourBox key={i} story={story} storyId={story.id} title={story.title} description={story.description} backgroundImage={story.backgroundImage} backgroundImageHover={story.backgroundImageHover} startTour={startTour} className={'tour-box ' + story.type}/>);+ return (<TourBox key={i} index={i} story={story} storyId={story.id} title={story.title} description={story.description} backgroundImage={story.backgroundImage} backgroundImageHover={story.backgroundImageHover} startTour={startTour} className={'tour-box ' + story.type}/>);})}</div></div>diff --git a/web/js/components/tour/tour.js b/web/js/components/tour/tour.jsindex 58c01a55c..9677dc9ab 100644--- a/web/js/components/tour/tour.js+++ b/web/js/components/tour/tour.js@@ -8,26 +8,23 @@ class Tour extends React.Component {constructor(props) {super(props);this.state = {- models: this.props.models,- ui: this.props.ui,- config: this.props.config,- stories: this.props.config.stories,- storyOrder: this.props.config.storyOrder,- modalStart: true,- modalInProgress: false,- modalComplete: false,- currentStep: 1,- totalSteps: 10,- tourParameter: this.props.config.parameters.tr || null,- currentStoryIndex: 0,- currentStory: {},- currentStoryId: ''+ models: props.models,+ stories: props.stories,+ storyOrder: props.storyOrder,+ modalStart: props.modalStart,+ modalInProgress: props.modalInProgress,+ modalComplete: props.modalComplete,+ currentStep: props.currentStep,+ totalSteps: props.totalSteps,+ tourParameter: props.tourParameter,+ currentStoryIndex: props.currentStoryIndex,+ currentStory: props.currentStory,+ currentStoryId: props.currentStoryId};this.toggleModalStart = this.toggleModalStart.bind(this);this.toggleModalInProgress = this.toggleModalInProgress.bind(this);this.toggleModalComplete = this.toggleModalComplete.bind(this);- this.startTour = this.startTour.bind(this);this.restartTour = this.restartTour.bind(this);this.incrementStep = this.incrementStep.bind(this);this.decreaseStep = this.decreaseStep.bind(this);@@ -54,19 +51,6 @@ class Tour extends React.Component {});}- startTour(e, currentStory, currentStoryIndex, currentStoryId) {- if (e) e.preventDefault();- this.setState({- steps: 1,- currentStoryIndex: currentStoryIndex,- modalStart: false,- modalInProgress: true,- modalComplete: false,- currentStory: currentStory,- currentStoryId: currentStoryId- });- }-restartTour(e) {e.preventDefault();this.setState({@@ -100,18 +84,16 @@ class Tour extends React.Component {toggleModalStart={this.toggleModalStart}toggleModalInProgress={this.toggleModalInProgress}toggleModalComplete={this.toggleModalComplete}- startTour={this.startTour}+ startTour={this.props.startTour}></TourStart><TourInProgressmodels={this.state.models}- config={this.state.config}- ui={this.state.ui}modalInProgress={this.state.modalInProgress}toggleModalStart={this.toggleModalStart}toggleModalInProgress={this.toggleModalInProgress}toggleModalComplete={this.toggleModalComplete}- startTour={this.startTour}+ startTour={this.props.startTour}currentStep={this.state.currentStep}totalSteps={this.state.totalSteps}incrementStep={this.incrementStep}@@ -139,8 +121,6 @@ class Tour extends React.Component {Tour.propTypes = {models: PropTypes.object.isRequired,- ui: PropTypes.object.isRequired,- config: PropTypes.object.isRequired,stories: PropTypes.object.isRequired,storyOrder: PropTypes.array.isRequired,modalStart: PropTypes.bool.isRequired,@@ -151,7 +131,8 @@ Tour.propTypes = {tourParameter: PropTypes.string,currentStoryIndex: PropTypes.number,currentStory: PropTypes.object,- currentStoryId: PropTypes.string+ currentStoryId: PropTypes.string,+ startTour: PropTypes.func.isRequired};export default Tour;diff --git a/web/js/tour/ui.js b/web/js/tour/ui.jsindex 090c258c2..a2b46824d 100644--- a/web/js/tour/ui.js+++ b/web/js/tour/ui.js@@ -6,18 +6,46 @@ export function tourUi(models, ui, config) {var self = {};var init = function() {- if (!config.features.tour) {+ if (!config.features.tour || !config.stories || !config.storyOrder) {return;}self.reactComponent = ReactDOM.render(- React.createElement(Tour, {- models: models,- ui: ui,- config: config- }),+ React.createElement(Tour, getInitialProps()),document.getElementById('wv-tour'));};++ var getInitialProps = function() {+ return {+ models: models,+ stories: config['stories'],+ storyOrder: config['storyOrder'],+ modalStart: true,+ modalInProgress: false,+ modalComplete: false,+ currentStep: 1,+ totalSteps: 10,+ tourParameter: config.parameters.tr || null,+ currentStoryIndex: 0,+ currentStory: {},+ currentStoryId: '',+ startTour: self.startTour+ };+ };++ self.startTour = function(e, currentStory, currentStoryIndex, currentStoryId) {+ if (e) e.preventDefault();+ self.reactComponent.setState({+ steps: 1,+ currentStoryIndex: currentStoryIndex,+ modalStart: false,+ modalInProgress: true,+ modalComplete: false,+ currentStory: currentStory,+ currentStoryId: currentStoryId+ });+ };+init();return self;}