Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

make tour work with AB #1118

Benjamin Kingfa8f9a3d48b3
diff --git a/web/js/tour.js b/web/js/tour.js
index 2cf117537..c42fd838c 100644
--- a/web/js/tour.js
+++ b/web/js/tour.js
@@ -6,18 +6,17 @@ import wvui from './ui/ui';
import { GA as googleAnalytics } from 'worldview-components';
import feedbackModal from './feedback';
-export default function (models, ui, config) {
+export default function(models, ui, config) {
var self = {};
- var init = function () {
- $('#wv-tour')
- .click(function () {
- self.start();
- });
+ var init = function() {
+ $('#wv-tour').click(function() {
+ self.start();
+ });
self.introduction();
};
- self.introduction = function () {
+ self.introduction = function() {
if (!config.features.tour) {
return;
}
@@ -53,21 +52,22 @@ export default function (models, ui, config) {
/**
* Create the splash screen and tour panels and control iteration over them.
*/
- self.start = function (introduction) {
+ self.start = function(introduction) {
if (util.browser.ie && util.browser.version <= 9) {
wvui.unsupported('tour');
return;
}
if (!validScreenSize()) {
- wvui.notify('Unfortunately the @NAME@ tour can only be viewed in larger web browser windows.');
+ wvui.notify(
+ 'Unfortunately the @NAME@ tour can only be viewed in larger web browser windows.'
+ );
return;
}
var $content = $('#wv-tour-content');
- if ($content.children()
- .length === 0) {
- $content.load('pages/tour.html', function () {
+ if ($content.children().length === 0) {
+ $content.load('pages/tour.html', function() {
onLoad(introduction);
});
} else {
@@ -75,26 +75,23 @@ export default function (models, ui, config) {
}
};
- var onLoad = function (introduction) {
+ var onLoad = function(introduction) {
wvui.close();
var $startDialog = $('#wv-tour-intro');
- $startDialog
- .dialog({
- title: 'Welcome to @NAME@!',
- dialogClass: 'tour',
- modal: true,
- width: 700,
- height: 'auto',
- draggable: false,
- resizable: false
- });
+ $startDialog.dialog({
+ title: 'Welcome to @NAME@!',
+ dialogClass: 'tour',
+ modal: true,
+ width: 700,
+ height: 'auto',
+ draggable: false,
+ resizable: false
+ });
if (introduction) {
- $('#wv-tour-skip')
- .show();
+ $('#wv-tour-skip').show();
} else {
- $('#wv-tour-skip')
- .hide();
+ $('#wv-tour-skip').hide();
}
var mapAnchor = document.getElementById('mapPanelTourAnchor');
@@ -102,70 +99,66 @@ export default function (models, ui, config) {
var owner = document.getElementById('wv-map');
mapAnchor = document.createElement('div');
mapAnchor.setAttribute('id', 'mapPanelTourAnchor');
- mapAnchor.setAttribute('style', 'float:right; height:68px; right:14px; top:90px; width:36px; position:relative; z-index:-1');
+ mapAnchor.setAttribute(
+ 'style',
+ 'float:right; height:68px; right:14px; top:90px; width:36px; position:relative; z-index:-1'
+ );
owner.appendChild(mapAnchor);
}
- var endTour = function () {
+ var endTour = function() {
wvui.close();
var $dialog = $('#wv-tour-end');
- $dialog
- .dialog({
- title: 'Finished!',
- dialogClass: 'tour',
- modal: true,
- width: 600,
- height: 'auto',
- draggable: false,
- resizable: false
- });
+ $dialog.dialog({
+ title: 'Finished!',
+ dialogClass: 'tour',
+ modal: true,
+ width: 600,
+ height: 'auto',
+ draggable: false,
+ resizable: false
+ });
feedbackModal.decorate($dialog.find('.feedback'));
- $('#repeat')
- .click(repeatTour);
- $('#done')
- .click(handleDone);
+ $('#repeat').click(repeatTour);
+ $('#done').click(handleDone);
};
/*
* Restart the tour at the beginning.
*/
- var repeatTour = function (e) {
+ var repeatTour = function(e) {
e.stopPropagation();
- $('.ui-dialog-content')
- .dialog('close');
- $('#joyRideTipContent')
- .joyride({
- autoStart: true,
- includepage: true,
- template: {
- 'link': '<a href="#" class="joyride-close-tip">X</a>'
- },
- postStepCallback: function (index, tip) {
- if (index === 5) {
- endTour();
- }
+ $('.ui-dialog-content').dialog('close');
+ $('#joyRideTipContent').joyride({
+ autoStart: true,
+ includepage: true,
+ template: {
+ link: '<a href="#" class="joyride-close-tip">X</a>'
+ },
+ postStepCallback: function(index, tip) {
+ if (index === 5) {
+ endTour();
}
- });
+ }
+ });
};
/*
* Hide the tour.
*/
- var handleDone = function (e) {
+ var handleDone = function(e) {
e.stopPropagation();
- $('.ui-dialog-content')
- .dialog('close');
+ $('.ui-dialog-content').dialog('close');
};
/*
* Close the splash and go straight to worldview.
*/
- var handleSkipTour = function () {
- $('.ui-dialog-content')
- .dialog('close');
+ var handleSkipTour = function() {
+ $('.ui-dialog-content').dialog('close');
};
- var onStop = function (index, tip, button) {
+ var onStop = function(index, tip, button) {
setTourState();
googleAnalytics.event('Tour', 'Click', 'Post Tour View', index + 1);
if (index === 5 && button === false) {
@@ -176,67 +169,63 @@ export default function (models, ui, config) {
/*
* Close the splash and start the tour.
*/
- var handleTakeTour = function (e) {
+ var handleTakeTour = function(e) {
e.stopPropagation();
- $('.ui-dialog-content')
- .dialog('close');
+ $('.ui-dialog-content').dialog('close');
initTourState();
googleAnalytics.event('Tour', 'Click', 'Take Tour');
- $('#joyRideTipContent')
- .joyride({
- autoStart: true,
- includepage: true,
- template: {
- 'link': '<a href="#" class="joyride-close-tip">X</a>'
- },
- postStepCallback: onStop
- });
+ $('#joyRideTipContent').joyride({
+ autoStart: true,
+ includepage: true,
+ template: {
+ link: '<a href="#" class="joyride-close-tip">X</a>'
+ },
+ postStepCallback: onStop
+ });
};
/*
* Toggle the value of the "hideSplash" flag.
*/
- var setDoNotShow = function () {
+ var setDoNotShow = function() {
if (!util.browser.localStorage) return;
var hideSplash = localStorage.getItem('hideSplash');
localStorage.setItem('hideSplash', !hideSplash);
};
// assign events and start
- $('#takeTour')
- .click(handleTakeTour);
- $('#skipTour')
- .click(handleSkipTour);
- $('#dontShowAgain')
- .click(setDoNotShow);
+ $('#takeTour').click(handleTakeTour);
+ $('#skipTour').click(handleSkipTour);
+ $('#dontShowAgain').click(setDoNotShow);
};
- var initTourState = function () {
+ var initTourState = function() {
var map = ui.map.selected;
+ models.layers.reset(models.layers.activeLayers);
+ if (models.compare) {
+ if (models.compare.active) models.compare.toggle();
+ }
models.proj.selectDefault();
models.date.select(util.today());
- models.layers.reset();
+
var leading = models.map.getLeadingExtent();
- map.getView()
- .fit(leading, map.getSize());
+ map.getView().fit(leading, map.getSize());
setTourState();
};
- var setTourState = function () {
+ var setTourState = function() {
ui.sidebar.expandNow();
- ui.sidebar.selectTab('active');
+ ui.sidebar.selectTab('layers');
ui.timeline.expandNow();
models.proj.selectDefault();
};
- var validScreenSize = function () {
- var viewWidth = $(window)
- .width();
- var viewHeight = $(window)
- .height();
+ var validScreenSize = function() {
+ var viewWidth = $(window).width();
+ var viewHeight = $(window).height();
return viewWidth > 800 && viewHeight > 680;
};
init();
return self;
-};
+}