npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-product-tour

v1.0.1

Published

This is a javascript library that uses intro.js and js-cookies to manage a Product Tour based on cookies to control when and what already was presented to the user.

Downloads

19

Readme

jsProductTour

This is a javascript library that uses intro.js and js-cookies to manage a Product Tour based on cookies to control when and what already was presented to the user.

Instalation

Bower

Put the package information in the dependencies section of the bower.json file.

    {
        "dependencies": {
            "js-product-tour": "^1.0"
        }
    }

Then run

    bower update

This will install jsProductTour and its own dependencies, wich are introjs and js-cookie.

Configuring the installation

You must import in HTML code the js and css source files of introjs, js-cookie and jsProductTour. The following example is based on a local project, you must change the paths according your project installation:

    <!-- CSS -->
    <link rel="stylesheet" href="bower_components/intro.js/minified/introjs.min.css">
    <link rel="stylesheet" href="bower_components/intro.js/themes/introjs-flattener.css">
    <link rel="stylesheet" href="bower_components/js-product-tour/src/tour.css">

    <!-- JS -->
    <script src="bower_components/intro.js/minified/intro.min.js"></script>
    <script src="bower_components/js-cookie/src/js.cookie.js"></script>
    <script src="bower_components/js-product-tour/src/tour.js"></script>

Using

To use the tour, create an array with the steps (slides) to be showed to the user. Set the version information with a sequential number, that must allways increase, so the library can evaluate wich slides where not yet showed when new releases, news or informations are deployed to the user.

Script example to start a tour:

    var steps = [
        {
            wellcome: true,
            intro: "Wellcome, this slide is allways showed and no version is needed because \n\
                it is set as a 'wellcome' slide. This slide is not linked with any HTML element."
        },
        {
            bye: true,
            intro: "This is also allways showed, but as the last slide!"
        },
        {
            version: 20170627.01,
            element: "#id-element",
            intro: "This is a slide that is gonna be showed next linked element."
        },
        {
            version: 20170627.02,
            element: "#another",
            intro: "Another slide with news related to the another element."
        },
        {
            version: 20170627.03,
            element: "#last-one",
            intro: "Last slide showed."
        },
    ];

    var tour = new Tour(user, steps);

    tour.start();

Laravel use example

At your layout master:

        <!-- HEAD SECTION -->

        <!-- TOUR -->
        <link rel="stylesheet" href="{{asset('bower_components/intro.js/minified/introjs.min.css')}}">
        <link rel="stylesheet" href="{{asset('bower_components/intro.js/themes/introjs-flattener.css')}}">
        <link rel="stylesheet" href="{{asset('bower_components/js-product-tour/src/tour.css')}}">

        <!-- BEFORE END BODY -->

        <!-- TOUR -->
        <script src="{{ asset ("/bower_components/intro.js/minified/intro.min.js")}}"></script>
        <script src="{{ asset ("/bower_components/js-cookie/src/js.cookie.js")}}"></script>
        <script src="{{ asset ("/bower_components/js-product-tour/src/tour.js")}}"></script>
        
        <!-- This is a script of your application with steps configuration -->
        <script src="{{ asset ("/js/showTour.js")}}"></script>

        <!-- execute after document is ready, if using jQuery -->
        <script>
            $(document).ready(function(){
                @if(Auth::check())
                    showTour("{{Auth::user()->email}}");
                @endif
            });
        </script>        

The public/js/showTour.js


function showTour(user) {
    var steps = [
        {
            wellcome: true,
            intro: "Wellcome, this slide is allways showed and no version is needed because \n\
                it is set as a 'wellcome' slide. This slide is not linked with any HTML element."
        },
        {
            bye: true,
            intro: "This is also allways showed, but as the last slide!"
        },
        {
            version: 20170627.01,
            element: "#id-element",
            intro: "This is a slide that is gonna be showed next linked element."
        },
        {
            version: 20170627.02,
            element: "#another",
            intro: "Another slide with news related to the another element."
        },
        {
            version: 20170627.03,
            element: "#last-one",
            intro: "Last slide showed."
        },
    ];

    var tour = new Tour(user, steps);

    tour.start();
}

Step setting

You must see the intro.js documentation (http://introjs.com/) to understand qich options can be set to steps.

Beside the into.js settings, this package use:

  • wellcome and bye: optional boolean settings to define the first and last slide of the tour;
  • version: required number setting to define the version that is used to evaluate if the slide must be shown to the user. You must allways increase this number to new slides, and can erase the oldest slides when believe they are not necessary anymore.