diff --git a/client/galaxy/scripts/apps/analysis.js b/client/galaxy/scripts/apps/analysis.js index f4b6ab3ac19..08d3d12f16c 100644 --- a/client/galaxy/scripts/apps/analysis.js +++ b/client/galaxy/scripts/apps/analysis.js @@ -76,7 +76,7 @@ window.app = function app(options, bootstrapped) { show_tours: function(tour_id) { if (tour_id) { - Tours.giveTour(tour_id); + Tours.giveTourById(tour_id); } else { this.page.display(new Tours.ToursView()); } diff --git a/client/galaxy/scripts/mvc/tours.js b/client/galaxy/scripts/mvc/tours.js index fe19aedefa3..8be51232877 100644 --- a/client/galaxy/scripts/mvc/tours.js +++ b/client/galaxy/scripts/mvc/tours.js @@ -4,7 +4,10 @@ import _l from "utils/localization"; * rendering a tour menu. */ -import * as BootstrapTour from "libs/bootstrap-tour"; +// bootstrap-tour configures a window.Tour object; keep a local ref. +import "libs/bootstrap-tour"; +let Tour = window.Tour; + var gxy_root = typeof Galaxy === "undefined" ? "/" : Galaxy.root; var tourpage_template = `

Galaxy Tours

@@ -93,31 +96,8 @@ var Tours = Backbone.Collection.extend({ model: TourItem }); -var giveTour = tour_id => { - var url = `${gxy_root}api/tours/${tour_id}`; - $.getJSON(url, data => { - // Set hooks for additional click and data entry actions. - var tourdata = hooked_tour_from_data(data); - sessionStorage.setItem("activeGalaxyTour", JSON.stringify(data)); - // Store tour steps in sessionStorage to easily persist w/o hackery. - var tour = new Tour( - _.extend( - { - steps: tourdata.steps - }, - tour_opts - ) - ); - // Always clean restart, since this is a new, explicit giveTour execution. - tour.init(); - tour.goTo(0); - tour.restart(); - }); -}; - -var ToursView = Backbone.View.extend({ +export var ToursView = Backbone.View.extend({ title: _l("Tours"), - // initialize initialize: function() { var self = this; this.setElement("
"); @@ -165,7 +145,7 @@ var ToursView = Backbone.View.extend({ ) .on("click", ".tourItem", function(e) { e.preventDefault(); - giveTour($(this).data("tour.id")); + giveTourById($(this).data("tour.id")); }) .on("click", ".tag-selector-button", e => { var elem = $(e.target); @@ -183,9 +163,53 @@ var ToursView = Backbone.View.extend({ } }); +export function 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. + let tour = new Tour(_.extend({ steps: hookedTourData.steps }, tour_opts)); + // Always clean restart, since this is a new, explicit execution. + tour.init(); + tour.goTo(0); + tour.restart(); + return tour; +} + +export function giveTourById(tour_id) { + var url = `${gxy_root}api/tours/${tour_id}`; + $.getJSON(url, data => { + giveTourWithData(data); + }); +} + +export function activeGalaxyTourRunner() { + var et = JSON.parse(sessionStorage.getItem("activeGalaxyTour")); + if (et) { + et = hooked_tour_from_data(et); + if (et && et.steps) { + if (window && window.self === window.top) { + // Only kick off a new tour if this is the toplevel window (non-iframe). This + // functionality actually *could* be useful, but we'd need to handle it better and + // come up with some design guidelines for tours jumping between windows. + // Disabling for now. + var tour = new Tour( + _.extend( + { + steps: et.steps + }, + tour_opts + ) + ); + tour.init(); + tour.restart(); + } + } + } +} + export default { ToursView: ToursView, - hooked_tour_from_data: hooked_tour_from_data, - tour_opts: tour_opts, - giveTour: giveTour + giveTourWithData: giveTourWithData, + giveTourById: giveTourById, + activeGalaxyTourRunner: activeGalaxyTourRunner }; diff --git a/client/galaxy/scripts/onload.js b/client/galaxy/scripts/onload.js index 7ab257568f8..7af85c6fe35 100644 --- a/client/galaxy/scripts/onload.js +++ b/client/galaxy/scripts/onload.js @@ -19,13 +19,12 @@ import layout_modal from "layout/modal"; _.extend(window, layout_modal); import async_save_text from "utils/async-save-text"; window.async_save_text = async_save_text; -import POPUPMENU from "ui/popupmenu"; -window.make_popupmenu = POPUPMENU.make_popupmenu; -window.make_popup_menus = POPUPMENU.make_popup_menus; +import Popupmenu from "ui/popupmenu"; +window.make_popupmenu = Popupmenu.make_popupmenu; +window.make_popup_menus = Popupmenu.make_popup_menus; import init_tag_click_function from "ui/autocom_tagging"; window.init_tag_click_function = init_tag_click_function; -import TOURS from "mvc/tours"; -import QUERY_STRING from "utils/query-string-parsing"; +import Tours from "mvc/tours"; // console.debug( 'galaxy globals loaded' ); // ============================================================================ @@ -89,10 +88,7 @@ function init_refresh_on_change() { .change(function() { var select_field = $(this); var select_val = select_field.val(); - var refresh = false; - var ref_on_change_vals = select_field.attr("refresh_on_change_values"); - if (ref_on_change_vals) { ref_on_change_vals = ref_on_change_vals.split(","); var last_selected_value = select_field.attr("last_selected_value"); @@ -114,10 +110,7 @@ function init_refresh_on_change() { .click(function() { var select_field = $(this); var select_val = select_field.val(); - var refresh = false; - var ref_on_change_vals = select_field.attr("refresh_on_change_values"); - if (ref_on_change_vals) { ref_on_change_vals = ref_on_change_vals.split(","); var last_selected_value = select_field.attr("last_selected_value"); @@ -156,7 +149,7 @@ $(document).ready(() => { $("[title]").tooltip(); } // Make popup menus. - make_popup_menus(); + Popupmenu.make_popup_menus(); // Replace big selects. replace_big_select_inputs(20, 1500); @@ -165,7 +158,7 @@ $(document).ready(() => { // add use_panels=True and set target to self. $("a").click(function() { var anchor = $(this); - var galaxy_main_exists = parent.frames && parent.frames.galaxy_main; + var galaxy_main_exists = window.parent.frames && window.parent.frames.galaxy_main; if (anchor.attr("target") == "galaxy_main" && !galaxy_main_exists) { var href = anchor.attr("href"); if (href.indexOf("?") == -1) { @@ -180,44 +173,26 @@ $(document).ready(() => { return anchor; }); - var et = JSON.parse(sessionStorage.getItem("activeGalaxyTour")); - if (et) { - et = TOURS.hooked_tour_from_data(et); - if (et && et.steps) { - if (window && window.self === window.top) { - // Only kick off a new tour if this is the toplevel window (non-iframe). This - // functionality actually *could* be useful, but we'd need to handle it better and - // come up with some design guidelines for tours jumping between windows. - // Disabling for now. - var tour = new Tour( - _.extend( - { - steps: et.steps - }, - TOURS.tour_opts - ) - ); - tour.init(); - tour.restart(); - } - } - } + Tours.activeGalaxyTourRunner(); function onloadWebhooks() { - if (Galaxy.root !== undefined) { - // Load all webhooks with the type 'onload' - $.getJSON(`${Galaxy.root}api/webhooks/onload/all`, webhooks => { - _.each(webhooks, webhook => { - if (webhook.activate && webhook.script) { - $("