Git Product home page Git Product logo

Comments (1)

IGreatlyDislikeJavascript avatar IGreatlyDislikeJavascript commented on August 26, 2024

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!

from bootstrap-tourist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.