simplabs/ember-introjs

Name: ember-introjs

Owner: simplabs

Description: An Ember Component for intro.js

Created: 2015-08-26 17:59:05.0

Updated: 2017-04-07 14:40:36.0

Pushed: 2015-08-26 19:42:52.0

Homepage: null

Size: 110

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ember-IntroJS Build Status

Ember IntroJS wraps introjs in an Ember Component to guide users through your app.

Installation

ember install npm:ember-introjs bower install

Usage

To declare your steps, you need to declare an array in JavaScript in your Controller:

pp/controllers/ticket.js
rt Ember from 'ember';

rt default Ember.Controller.extend({
eps: Ember.computed(function(){
return [
  {
    element: $('#step1'),
    intro: 'Step 1!'
  },
  {
    element: $('#step2'),
    intro: 'Step2!'
  }
];


Then to use the steps, you can use the steps in your handlebars template:

app/templates/ticket }}
tro-js steps=steps start-if=true}}
Action Hooks

IntroJS supports a series of hooks for getting notified for when users switch between steps or exit. You can subscribe to these actions using the typical actions hash in your Route or Controller:

pp/routes/ticket.js
rt Ember from 'ember';

rt default Ember.Route.extend({
tions: {
introBeforeChange: function(previousStep, nextStep, introJSComponent,
entOfNewStep){
  // You could track user interactions here, e.g. analytics.
  this.sendAnalytics(prevStep);
}


Then pass the name of the action in the handlebars helper that renders the component below.

tro-js steps=steps start-if=true on-before-change="introBeforeChange"}}
on-before-change (currentStep, nextStep, introJSComponent, nextElement)

Called when the user clicks next (or uses their keyboard). Called before on-change. Given the currentStep, the nextStep, the introJSComponent, and the DOM element of the next step.

on-change (step, introJSComponent, currentElement)

Called after on-before-change when the user moves a step (backwards or forward) in the introduction. Gives the current step, the introJS component isntance, and the element of the current step.

on-after-change (step, introJSComponent, currentElement)

Called after on-change when the user moves a step (backwards or forward) in the introduction. Gives the current step, the introJS component isntance, and the element of the current step.

on-exit (step, introJSComponent)

Called when the user quits the intro via the “Skip” button, hitting escape, or clicking outside the overlay. Given the current step, and the introJS component.

on-complete (step, introJSComponent)

Called when the user finishes the intro by clicking “Done” or hitting right on the keyboard until the end. Called with the last step and the introJS component instance.

Intro JS Options

Intro JS has a variety of options available to it. You can see the full list here, but we also provided the full list below. You'll notice that in the list below options all follow the dasherized convention of HTML and ember-cli filenames. The original list uses camelCase names, and so does IntroJS. Ember IntroJS will do the conversion for you.

You can also set other options using the Handlebars helper syntax: `

tro-js steps=steps show-bullets=true}}

Or you could extend your own base class to override defaults instead of specifying them every time in the Handlebars helper:

p/app/components/my-intro-js.js
rt IntroJSComponent from 'ember-introjs/components/intro-js';

rt default IntroJSComponent.extend({
xit-on-esc': true

You can also reopen the class:

rt IntroJSComponent from 'ember-introjs/components/intro-js';

oJSComponent.reopen({
xit-on-esc': true

See setOption to see an example.

Testing Helpers

Ember IntroJS comes with a set of testing helpers.

To use them, first import them in your tests/test-helper.js file:

ests/test-helpers.js

rt 'ember-introjs/helpers';
Running Tests
Building

For more information on using ember-cli, visit http://www.ember-cli.com/.

LICENSE

See the LICENSE file included in this repository.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.