Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Adding a touristManager to the solution #17

Open
vneri opened this issue Jul 16, 2019 · 1 comment
Open

Idea: Adding a touristManager to the solution #17

vneri opened this issue Jul 16, 2019 · 1 comment

Comments

@vneri
Copy link
Contributor

vneri commented Jul 16, 2019

Hi folks,
I started to build a small "Tour Manager" so that you can have multiple tours. With that, you would also have an overview of the tours and would be able to start them right away.

In the attached file, there is an example. A welcome modal with popup, linking to a starting tour. Another modal will show what tours are available. The welcome modal is hardcoded, but it could be easily adapted to be called via function.

I also had the idea to have something like a checkbox for tours that have already been seen until the end/or started in the overview modal.

What are your thoughts on this?
Thanks for the feedback!

touristManager.zip

@IGreatlyDislikeJavascript
Copy link
Owner

Thanks for your contribution. This is a really good idea and something I think will be widely used where more than 1 tour is available.

Right now I have a similar challenge - site "pages" where there is more than one potential tour, which I solve with a horrible hacky solution.

I had some initial thoughts:

You've added "title" and "description" to the tour options, I think these make sense to incorporate into Tourist anyway, even without the tour manager.

I think we should consider making a dynamic tour manager. In your example you create your tour in the js, and then call addTour() for each tour. How about we turn this into a manager with a lazy load?

  1. The relevant tours are stored in one or more separate .js.
  2. TouristManager is instantiated, and an object is passed to TouristManager that identifies all the relevant tours on the page and their details. Note that these are not the individual tour options, they simply identify the tours (and objects that have those tour options).
var allMyTours = {
    {
        name: "WelcomeTour", // identifies the tour in the js from source: option?
        source: "js/my_page_tours.js", // what file is this tour in?
        description: ....,
        ...other options?...
    },
    {
        name: "ExpertTour", // identifies the tour in the js from source: option?
        source: "js/my_page_tours.js", // Could be the same or different files per tour
        ......
    }
};

var manager = new TouristManager({ 
        managedTours: allMyTours,
        lazyload: true,
        ...options?...
});

Then, in js/my_page_tours.js, you would have your normal tour options:

var WelcomeTour = {
    name:"WelcomeTour",
    title:"First steps",
    description:"You will learn the first steps with FP Sign",
    debug:true,
    framework: "bootstrap4",	// or "bootstrap4" depending on your version of bootstrap
};
  1. Tours are then run by calling the Manager and asking for them:

var activeTour = manager.loadTour(...some tour name in allMyTours...);

  1. If lazyload is true, Manager loads the tour on demand:
function loadTour(tourName)
{
    var tourFile = ...find the source .js from the object, by tour name...
    $.getScript(tourFile);
    return new Tour(tourName);
}

This would avoid the scenario where a page that has multiple tours (or even one massive single tour) loads them all into the DOM on page load.

Then we include your tour manager ability to let users select their own tour etc, with templating etc.

What do you think?

I already see one issue to solve, which is the need to duplicate "title" and "description" properties in the options passed to the manager, and the individual tour options.

Also, maybe we can incorporate the manager into Tourist itself, to avoid 2 plugins. This changes the paradigm slightly, because a Tourist instance now doesn't represent one tour but a possibility of multiple tours...

Interesting discussion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants