Reduce tour launch duplication, refine module interface.

This commit is contained in:
Dannon Baker
2017-12-07 15:58:02 -05:00
parent 3f5aabbf15
commit a2cf121e34
2 changed files with 5 additions and 14 deletions
+4 -3
View File
@@ -96,7 +96,7 @@ var Tours = Backbone.Collection.extend({
model: TourItem
});
let startTourWithData = data => {
let giveTourWithData = data => {
let hookedTourData = hooked_tour_from_data(data);
sessionStorage.setItem("activeGalaxyTour", JSON.stringify(data));
// Store tour steps in sessionStorage to easily persist w/o hackery.
@@ -108,12 +108,13 @@ let startTourWithData = data => {
tour.init();
tour.goTo(0);
tour.restart();
return tour;
};
var giveTourById = tour_id => {
var url = `${gxy_root}api/tours/${tour_id}`;
$.getJSON(url, data => {
startTourWithData(data);
giveTourWithData(data);
});
};
@@ -212,7 +213,7 @@ export function activeGalaxyTourRunner() {
export default {
ToursView: ToursView,
hooked_tour_from_data: hooked_tour_from_data,
giveTourWithData: giveTourWithData,
giveTourById: giveTourById,
activeGalaxyTourRunner: activeGalaxyTourRunner
};
@@ -58,17 +58,7 @@ $(document).ready(function() {
},
_generateTour: function(data) {
var tourData = Tours.default.hooked_tour_from_data(data);
sessionStorage.setItem('activeGalaxyTour', JSON.stringify(data));
// Generate and run the tour
var tour = new Tour(_.extend({
steps: tourData.steps
}));
tour.init();
tour.goTo(0);
tour.restart();
var tour = Tours.startTourWithData(data);
// Force ending the tour when pressing the Execute button
$('#execute').on('mousedown', function() {
if (tour) {