Giter Site home page Giter Site logo

chensheng1357 / angular-tour Goto Github PK

View Code? Open in Web Editor NEW

This project forked from daftmonk/angular-tour

0.0 1.0 0.0 920 KB

AngularJS directive for giving an interactive tour of your website.

Home Page: http://daftmonk.github.io/angular-tour/

License: MIT License

angular-tour's Introduction

Angular Tour - AngularJS directive for giving a tour of your website.

Demo

Want to see it in action? Visit http://daftmonk.github.io/angular-tour/

Showcase features of your website

Give an interactive tour to showcase the features of your website.

  • Easy to use
  • Responsive to window resizes
  • Smoothly scrolls to each step
  • Control the placement for each tour tip

Supported browsers

Has been tested in

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer 9+

Installation

To install run

bower install angular-tour

Angular Tour has a dependency on jQuery.

Setup

Once bower has downloaded the dependencies for you, you'll need to make sure you add the required libraries to your index file. Your script includes should look something like this:

<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-tour/dist/angular-tour-tpls.min.js"></script>

You'll also probably want to include the default stylesheet for angular tour. (You can replace this with your own stylesheet.)

<link rel="bower_components/angular-tour/dist/angular-tour.css"/>

Lastly, you'll need to include the module in your angular app

angular.module('myApp', ['angular-tour'])

How to use

To begin your tour you'll need a <tour> element to contain all of your tour tips, it must have a step attribute for binding the tour step to your scope.

Add the tourtip attribute to whatever elements you want to add a tip to.

Example markup:

<tour step="currentStep">
  <span tourtip="tip 1"> Highlighted </span>
  <span tourtip="tip 2"> Elements </span>
  <input tourtip="or add it as an attribute to your element" />
</tour>

You can also add callbacks to the tour:

<tour step="currentStep" post-tour="tourComplete()" post-step="stepComplete()">

It is very easy to add a cookie module that remembers what step a user was on. Using the angular-cookie module this is all you need to integrate cookies:

// load cookie, or start new tour
$scope.currentStep = ipCookie('myTour') || 0;

// save cookie after each step
$scope.stepComplete = function() {
  ipCookie('myTour', $scope.currentStep, { expires: 3000 });
};

There are additional attributes that allow you to customize each tour-tip.

tourtip-step (Default: "null"): tour tips play from step 0 onwards, or in the order they were added. You can specify a specific order, e.g.

<span tourtip="tip 2" tourtip-step="1"></span>
<span tourtip="tip 1" tourtip-step="0"></span>
<span tourtip="tip 3" tourtip-step="2"></span>

next-label (Default: "Next"): The text for the next button. placement (Default: "top"): Placement of the tour tip relative to the target element. can be top, right, left, bottom

Inside your tour, you also have access to two scope methods for ending and starting the tour.

<a ng-click="openTour()">Open Tour</a>
<a ng-click="closeTour()">Close Tour</a>

Customization

Defaults

If you'd like to edit the defaults for all your tour, you can inject tourConfig somewhere into your app and modify the following defaults.

{
  placement        : 'top',                  // default placement relative to target. 'top', 'right', 'left', 'bottom'
  animation        : true,                   // if tips fade in
  nextLabel        : 'Next',                 // default text in the next tip button
  scrollSpeed      : 500,                    // page scrolling speed in milliseconds
  offset           : 28                      // how many pixels offset the tip is from the target
}

Customizing Templates

As was already mentioned, you can use your own CSS for styling the tour tips. You can also use your own markup.

If you would like to replace the html template, instead of using the angular-tour-tpls.min.js script, use angular-tour.min.js which doesn't include a template.

The easiest way to add your own template is to use the script directive:

<script id="tour/tour.tpl.html" type="text/ng-template">
  <div class="tour-tip">
      <span class="tour-arrow tt-{{ ttPlacement }}"></span>
      <div class="tour-content-wrapper">
          <p ng-bind="ttContent"></p>
          <a ng-click="setCurrentStep(getCurrentStep() + 1)" ng-bind="ttNextLabel" class="small button tour-next-tip"></a>
          <a ng-click="closeTour()" class="tour-close-tip">ร—</a>
      </div>
  </div>
</script>

License

This project is licensed under the MIT license.

angular-tour's People

Contributors

daftmonk avatar

Watchers

 avatar

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.