jQuery in XPages #11 – Joyride.js (How to add a website feature tour)

In this article I will demonstrate how you can easily create a website feature tour using the Joyride.js jQuery plugin and XPages. When releasing a new site or new features within a site it is always a good idea to let your users know what’s new and why. This can be done in a number of ways, but Joyride provides a fun and interactive way of showing the new information and can be linked to the wiki or other more formal documentation you create with a release.

Demonstration

The XPages integration of Joyride.js is demonstrated here

Download

The demonstration database can be downloaded from the link above or from here

Joyride.js

Introduction

Have you ever released a new XPage or website and wanted to visually guide a user around the new features or capabilities? Well now you can with Joyridejs in your XPage.

“Joyride gives you everything you need to call out new features in your app or website. Joyride is extremely flexible and lets you take control of how people interact with your tour. ” – http://www.zurb.com/playground/jquery-joyride-feature-tour-plugin

Example

Example – Using my previous article about prettyPhoto.js as an example I can highlight to sections in a visually appealing way and guide new users around the page.

prettyPhoto original XPage
prettyPhoto original XPage

Becomes and interactive site with descriptions and popups showing users around:

Joyride introduction to the site #1
Joyride introduction to the site #1
Joyride introduction to the site #2
Joyride introduction to the site #2

How does it work?

We first have to add our libraries and CSS to the database. I have started to move away from using xp:resources in my source code because the XPage is trying to load the files every time we build and save the XPage which slows down development. I am using the <script> and </link> tags directly within the XPage source itself.

The files are added to the database in the WebContents folder as described in previous articles within this series

	<script src="js/jquery-1.7.2.min.js" clientSide="true"></script>
	<script src="js/jquery.joyride-1.0.3.js" clientSide="true"></script>
  	<link rel="stylesheet" href="css/JoyRide/joyride-1.0.3.css"/>
  	<link rel="stylesheet" href="css/JoyRide/demo-style.css"/>

This plugin is controlled by creating an ordered-list of the elements you wish to highlight and within that list you state the contents of the popup for that element.

The attributes of the list elements controls the functionality of the Joyride:

  • data-id
    • The idTag of the element you wish to display this popup on “addNew”
  • data-text
    • What do you want displayed in the button “Next”
  • class
    • Styling information
  • <h2>
    • The Title of the popup
  • <p>
    • the Text (or HTML) within the popup
  • data-options
    • Gives you more control of the look/feel of the popup “tipLocation:top;tipAnimation:fade”
  	<ol id="joyRideTipContent">
  	  <li data-id="addNew" data-text="Next" class="custom">
  	    <h2>Add a New Image</h2>
  	    <p>Apparently this functionality is available in the live demo :)</p>
  	  </li>
  	  <li data-id="clickOnOne" data-text="Click ME" data-options="tipLocation:top;tipAnimation:fade">
  	    <h2>A simple Lightbox</h2>
  	    <p>You can produce a lightBox Slide show of the images by clicking on one of these</p>
  	  </li>
  	  <li data-id="seeYouTube" data-text="Next">
  	    <h2>See YouTube</h2>
        <p>Clickin on the NotesIn9 image will show you an example of the prettyPhoto running a YouTube video</p>
  	  </li>
  	  <li data-id="inLine" data-text="Close">
  	    <h2>View Inline Content</h2>
        <p>Clickin on the NotesIn9 image will show you an example of the prettyPhoto running a YouTube video</p>
  	  </li>
  	</ol>

At the end of the code we add the activation of the Joyride – this can also be added to a button on the form if you don’t want it loading when the page loads.

	$(window).load(function() {
		$(this).joyride();
	});

Options

Joyride.js comes with a lot of options for changing the presentation of the popups – you will also notice that some of these options are stored within the data-options of the controller ordered-list. It provides another layer of flexibility for being able to control all the popups in the same way or individually depending on what effect you are looking for.

/* Setting your options to override the defaults */
$(this).joyride({
  'tipLocation': 'bottom',         // 'top' or 'bottom' in relation to parent
  'scrollSpeed': 300,              // Page scrolling speed in ms
  'timer': 2000,                   // 0 = off, all other numbers = time(ms )
  'startTimerOnClick': true,       // true/false to start timer on first click
  'nextButton': true,              // true/false for next button visibility
  'tipAnimation': 'pop',           // 'pop' or 'fade' in each tip
  'tipAnimationFadeSpeed': 300,    // if 'fade'- speed in ms of transition
  'cookieMonster': true,           // true/false for whether cookies are used
  'cookieName': 'JoyRide',         // choose your own cookie name
  'cookieDomain': false,           // set to false or yoursite.com
  'tipContainer': body,            // Where the tip be attached if not inline
  'inline': false,                 // true/false for inline positioning
  'tipContent': '#joyRideContent', // The ID of the <ol> used for content
  'postRideCallback': $noop,       // a method to call once the tour closes
  'postStepCallback': $noop        // A method to call after each step
});

Something to think about
You don’t want to show the tour to every user every time for the first week of the new website. There are a number of ways you could control this – how you do it is really up to you….

  • Provide the users a “Click Here” button to take the tour
  • Provide user an opt out option and track their selection in a notesdocument or a cookie.
    • When the user enters the application check the option and do not render the window.joyride() script to start the tour.

Conclusion

In less than 1 hour I was able to knock up the demonstration page for this article – in the real world though you would add this tour option into the website planning from the start. The tags which the tour is displayed on are not going to affect the site if they are not used and can be added as part of the overall design from the start.

These popups are also a very good way of providing helptext to a user.

This is a very simple and very useful plugin which I know has lots of applicability to our applications and customers.

Advertisements

8 thoughts on “jQuery in XPages #11 – Joyride.js (How to add a website feature tour)

  1. Hi Marky,

    This is a very cool feature. Thanks for posting this.

    I don’t know if you noticed, the popups are duplicated at the bottom of the screen on your demo page. That can be fixed by calling the tour the following way

    $(window).joyride({‘postRideCallback’: function(){$(“[id^=’joyRidePopup’]”).remove()}});

    So after the tour it will do a clean up of the popups. Also, if you need this to work on IE 7/8, please use the joyride 1.0.5 version.

    • Thanks for the feedback Rajeev I really appreciate it

      I do not see popups at the bottom of the screen in Chrome or Firefox – which browser are you using?

      I will check out the 1.0.5 version and update it

      thanks 🙂

  2. Is there a way to compute the data-id so that we can just use Xpages component IDs instead of only HTML IDs? I hate the ID of having to double-tag every element I want to visit on a tour with the in addition to having done it in XPages

  3. Wow, this post is nice, my
    Hi there! This blog post couldn’t be written much better!

    Reading through this article reminds me of my previous tarot!
    He constantly kept preaching about this. Many thanks
    for sharing!will go along with your views on this site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s