From a2cf121e34dc4cdb556ffb47337199d1e8a15f1b Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Fri, 1 Dec 2017 15:30:16 -0500 Subject: [PATCH] Reduce tour launch duplication, refine module interface. --- client/galaxy/scripts/mvc/tours.js | 7 ++++--- .../webhooks/demo/tour_generator/static/script.js | 12 +----------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/client/galaxy/scripts/mvc/tours.js b/client/galaxy/scripts/mvc/tours.js index 947161e7f6f..48dacf1740a 100644 --- a/client/galaxy/scripts/mvc/tours.js +++ b/client/galaxy/scripts/mvc/tours.js @@ -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 }; diff --git a/config/plugins/webhooks/demo/tour_generator/static/script.js b/config/plugins/webhooks/demo/tour_generator/static/script.js index 485e7548e5f..d54406b16dc 100644 --- a/config/plugins/webhooks/demo/tour_generator/static/script.js +++ b/config/plugins/webhooks/demo/tour_generator/static/script.js @@ -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) {