guides
Version:
Simple way to highlighting DOM elements and guide your users with step-by-step welcome tours in your web app.
211 lines (209 loc) • 8.6 kB
HTML
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>guides.js</title>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="screen.css">
<link rel="stylesheet" type="text/css" href="guides.css">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">guides.js</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#getting-started">getting started</a></li>
<li><a href="#docs">docs</a></li>
<li><a href="#download">download</a></li>
</ul>
<p class="navbar-btn navbar-right">
<button type="button" id="demo" class="demo btn btn-success">Start demo</button>
</p>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div role="main" class="container">
<div class="page-header">
<h1>Guides.js <small>lightweight javascript library for making guided website tours</small></h1>
</div>
<p>Guides.js finds the element you want to highlight, creates a guide element using the html you specified in the configuration options and connects the guide and the highlighted element with an svg arrow.</p>
<p><button type="button" class="demo btn btn-success">Start demo</button></p>
<p><img src="http://i.gyazo.com/c03b02c7bbc24b7e9bdb8e620df20cf7.png" class="img-thumbnail" /></p>
<h3 id="getting-started">Getting Started</h3>
<section>
<p>Once you have downloaded the source, simply include <em>guides.css</em> in the <kbd><head></kbd> of your page:</p>
<p><pre><head>
...
<link rel="stylesheet" type="text/css" href="guides.css" >
</head></pre></p>
<p>and <em>guides.js</em> in your page scripts section. Make sure you include it after <em>jquery</em>:</p>
<p><pre> ...
<script type="text/javascript" src="jquery.js" >
<script type="text/javascript" src="guides.js" >
</body></pre></p>
<p>Note that you can import <em>guides.scss</em> and compile it togerther with your website styles if you are using sass.</p>
</section>
<h3 id="docs">Docs</h3>
<section>
<h4>Dependencies</h4>
<p><em>Guides.js</em> depends on <b>jquery</b>, so you need to make sure you include jquery first.</p>
<h4>Initialization</h4>
<p><em>Guides.js</em> is a jquery plugin and it can be initialized on an element, that will "trigger" the guided tour:</p>
<p><pre>
$('#demo').guides({
guides: [{
element: $('.navbar-brand'),
html: 'Welcome to Guides.js'
}, {
element: $('.navbar'),
html: 'Navigate through guides.js website'
}, {
element: $('#demo'),
html: 'See how it works'
}, {
element: $('#download'),
html: 'Download guides.js'
}, {
element: $('#getting-started'),
html: 'Check out how to get started with guides.js'
}, {
element: $('#docs'),
html: 'Read the docs'
}]
});</pre></p>
<p>Now the tour will start everytime <kbd>$('#demo')</kbd> element is clicked.</p>
<p>If you want to manually start the tour you can do the following:</p>
<p><pre>
var guides = $.guides({
guides: [{
html: 'Welcome to Guides.js'
}, {
element: $('.navbar'),
html: 'Navigate through guides.js website'
}, {
element: $('#demo'),
html: 'See how it works'
}, {
element: $('#download'),
html: 'Download guides.js'
}, {
element: $('#getting-started'),
html: 'Check out how to get started with guides.js'
}, {
element: $('#docs'),
html: 'Read the docs'
}]
});
guides.start();
</pre></p>
<h4>Configuration options</h4>
<h5>The default options are as follows:</h5>
<p><pre>
{
distance: 100,
color: '#fffff',
guides: []
}</pre></p>
<dl class="dl-horizontal">
<dt>distance</dt>
<dd><em>number</em> - distance between the guide text and the element that it is related to.</dd>
<dt>color</dt>
<dd><em>string</em> - arrows and text default color</dd>
<dt>guides</dt>
<dd><em>array of objects</em> - the list of guides</dd>
</dl>
<h5>The guides array</h5>
<p>A guide object looks like this:</p>
<pre>{
element: $('.navbar-brand'),
html: 'Welcome to Guides.js',
color: '#fff'
}</pre>
<dl class="dl-horizontal">
<dt>element</dt>
<dd><span class="label label-default">optional</span> <em>jquery element or string</em> - the element (or selector) you want to highlight; if omitted the guide will be centered</dd>
<dt>html</dt>
<dd><span class="label label-danger">required</span> <em>string</em> - this is the content of the tip: you can enter plain text or markup</dd>
<dt>color</dt>
<dd><span class="label label-default">optional</span> <em>string</em> - arrow and text color (falls back to the default color if not specified)</dd>
<dt>render</dt>
<dd><span class="label label-default">optional</span> <em>function</em> - a callback function that is called before guide is rendered</dd>
</dl>
<h4>Methods</h4>
<dl class="dl-horizontal">
<dt>start</dt>
<dd><kbd>$('#demo').guides('start');</kbd> Starts the guided tour.</dd>
<dt>end</dt>
<dd><kbd>$('#demo').guides('end');</kbd> Exits the guided tour.</dd>
<dt>next</dt>
<dd><kbd>$('#demo').guides('next');</kbd> Moves to the next guide.</dd>
<dt>prev</dt>
<dd><kbd>$('#demo').guides('prev');</kbd> Moves back to the previous guide.</dd>
<dt>destroy</dt>
<dd><kbd>$('#demo').guides('destroy');</kbd> Exits the guided tour and destroys it.</dd>
<dt>setOptions</dt>
<dd><kbd>$('#demo').guides('setOptions', options);</kbd> Extends the guides configuration options with the options sent as a second parameter.</dd>
</dl>
<h4>Events</h4>
<dl class="dl-horizontal">
<dt>start</dt>
<dd><kbd>$('#demo').guides({start: onStartFunction});</kbd> Called after the tour starts.</dd>
<dt>end</dt>
<dd><kbd>$('#demo').guides({end: onEndFunction});</kbd> Called after the tour ends.</dd>
<dt>next</dt>
<dd><kbd>$('#demo').guides({next: onNextFunction});</kbd> Called after showing the next guide.</dd>
<dt>prev</dt>
<dd><kbd>$('#demo').guides({prev: onPrevFunction});</kbd> Called after showing the previous guide.</dd>
<dt>render</dt>
<dd><kbd>$('#demo').guides({render: onRenderFunction});</kbd> Called before a guide is rendered.</dd>
<dt>destroy</dt>
<dd><kbd>$('#demo').guides({destroy: onDestroyFunction});</kbd> Called after destroying.</dd>
</dl>
</section>
<h3 id="download">Download</h3>
<section>
The source is availabe on github: <a href="https://github.com/epetrova/guides/">https://github.com/epetrova/guides/</a>:
<p><pre>git clone https://github.com/epetrova/guides.git</pre></p>
Alternatively, you can install using Bower:
<p><pre>bower install guides</pre></p>
</section>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="./guides.min.js"></script>
<script type="text/javascript">
$('.demo').guides({
guides: [{
html: 'Welcome to Guides.js'
}, {
element: $('.navbar'),
html: 'Navigate through guides.js website'
}, {
element: $('#demo'),
html: 'See how it works'
}, {
element: $('#download'),
html: 'Download guides.js'
}, {
element: $('#getting-started'),
html: 'Check out how to get started with guides.js'
}, {
element: $('#docs'),
html: 'Read the docs'
}]
});
</script>
</body>
</html>