forked from sprintly/jquery.pageguide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·751 lines (702 loc) · 30.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery.PageGuide, by Sprint.ly</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="docs/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="docs/lib/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<link href="docs/lib/google-code-prettify/prettify.css" type="text/css" rel="stylesheet" />
<link href="docs/css/social_foundicons.css" rel="stylesheet">
<link href="docs/css/entypo.css" rel="stylesheet">
<link href="css/pageguide.css" rel="stylesheet">
<link href="docs/css/docs.css" rel="stylesheet">
<!--[if lt IE 8]>
<link rel="stylesheet" href="css/social_foundicons_ie7.css">
<![endif]-->
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link rel="shortcut icon" href="docs/favicon.ico">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#about">jQuery.PageGuide</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="#usage">Docs</a></li>
<li><a href="#api">API</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="wrapper">
<div class="container">
<div class="row-fluid">
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">jQuery.PageGuide</li>
<li id="nav-home"><a href="http://sprintly.github.com/jquery.pageguide">Project Home</a></li>
<li id="nav-github"><a href="https://github.com/sprintly/jquery.pageguide">Source (Github)</a></li>
<li id="nav-documentation" class="nav-header">Documentation</li>
<li id="nav-about"><a href="#about">About</a></li>
<li id="nav-usage"><a href="#usage">Getting Started</a></li>
<li id="nav-api"><a href="#api">API Reference</a></li>
<li id="nav-examples" class="nav-header">Examples</li>
<li id="nav-example-simple"><a href="#example-simple">Simple</a></li>
<!-- li id="nav-example-ordered-list"><a href="#example-ordered-list">HTML Guide Definition</a></li -->
<!-- li id="nav-example-javascript"><a href="#example-javascript">JavaScript Guide Definition</a></li -->
<li id="nav-example-options"><a href="#example-options">Override Options</a></li>
<li id="nav-example-events"><a href="#example-events">Event Listeners</a></li>
</ul>
</div><!--/.well -->
<div class="sidebar-nav">
<a name="get-pageguide"></a>
<ul class="btn-group big">
<li class="btn" id="btn-github"><i class="foundicon-github"></i>View on <span class="title">Github</span></li>
<li class="btn" id="btn-tarball"><i class="entypo-arrow-down"></i>Download <span class="title">TAR Ball</span></li>
</ul>
</div>
</div><!--/span-->
<div class="span9">
<div class="hero-unit">
<a name="about"></a>
<h1>jQuery.PageGuide</h1>
<p class="plug">Brought to you by <a href="https://sprint.ly/" target="_blank">Sprint.ly</a>, based on a true story by <a href="http://tracelytics.com" target="_blank">Tracelytics</a></p>
<p class="lead">jQuery.PageGuide is a <a href="http://jquery.com" target="_blank">jQuery</a> plugin for building dynamic, interactive visual guides that help your users get familiar with all the features of your site, without the unsightly clutter of static help text.</p>
<p>It all began as a simple modification of the fantastic <span style="color:rgba(248,2,130,1)">Tracelytics</span> <a href="http://tracelytics.github.com/pageguide/" target="_blank">pageguide.js</a>, with intent to make it work as a true jQuery plugin. But while rewriting the code, more and more features kept creeping in, and now it's taken on a life of it's own.</p>
<p>You can dynamically load and unload user guides, fine-tune the positioning of each step, and define event handlers on all parts of the guide (including each step individually) to perform actions in concert with the presentation.</p>
<p>And we have more planned, we can't stop the awesome...</p>
</div>
<div id="usage-container" class="row-fluid section">
<a name="usage"></a>
<h2>Getting Started</h2>
<p>
<ol class="howto">
<li>Download jQuery.PageGuide (<a href="https://github.com/sprintly/jquery.pageguide/tarball/master">TAR</a> or <a href="">Github</a>) and put the files somewhere within your project resource path.</li>
<li>
Include the CSS tag somewhere in the <code>HEAD</code> of the html:
<pre class="prettyprint linenums">
<head>
...
<link href="/path/to/css/pageguide.css" rel="stylesheet">
...
</head>
</pre>
</li>
<li>
Include the JS for jQuery and jQuery.PageGuide at the <em>end</em> of the <code>BODY</code>:
<pre class="prettyprint linenums">
<body>
...
<script src="/path/to/js/jquery.js"></script>
<script src="/path/to/js/jquery.pageguide.js"></script>
</body>
</pre>
<span class="label label-info">Heads up!</span> The same jquery.pageguide.js file will also work with browser-based <a href="http://requirejs.org/docs/whyamd.html" target="_blank">AMD</a> script loaders, like RequireJS.
</li>
<li>
Create a guide. Guides can be defined in both html, by using ordered lists (<code>OL</code>'s), and in JavaScript. Here we're going to build one in JavaScript (the same one that loads by default on this page):
<pre class="prettyprint linenums">
var guide = {
id: 'jQuery.PageGuide',
title: 'Take a quick tour of all the possibilities',
steps: [
{
target: '.hero-unit h1',
content: 'Each step is associated with a "target" element, specified by a CSS selector. jQuery.PageGuide will automatically filter out any steps with targets that are invisible or don\'t exist..',
direction: 'left'
}
]
}
</pre>
</li>
<li>Then, as soon as you're ready (or as soon as jQuery is ready), load the guide. The friendly little help icon will slide into view at the top right of the page:
<pre class="prettyprint linenums">
$(function() {
// Load the default guide!
$.pageguide(defaultGuide);
});
</pre>
<span class="label label-info">Heads up!</span> Make sure to place this code somewhere <em>after</em> the script tags you added in step 3.
</li>
<li>
If you want to swap to a different guide, go right ahead:
<pre class="prettyprint linenums">
// Something different
var guide2 = {...};
$.pageguide('load', guide2);
</pre>
</li>
<li>
And when you're done with that guide, make it go away:
<pre class="prettyprint linenums">
$.pageguide('unload');
</pre>
</li>
</ol>
</p>
</div><!--/row-->
<hr/>
<div id="options-container" class="row-fluid section">
<a name="options"></a>
<h2>Options</h2>
<p>The default settings are good enough to get you started, but there are a ton of options to explore. jQuery.PageGuide allows you to configure settings both globally and for individual guides. Setting options globally will effectively modify the defaults, which can also be overriden when loading a guide for settings that apply only while it's loaded. Keep scrolling to find the <a href="#api">full list of options</a>.</p>
<h3>Setting global options:</h3>
<p>These overrides will apply to all guides that are loaded.</p>
<ol>
<li>
During initialization:
<pre class="prettyprint linenums">
// Guide definition, as described above.
var guide = {...};
// Options to override
var options = {
defaultGuide: guide, // Load this guide as soon as the page is ready
autoAdvanceInterval: 10, // Advance to the next step after 10 seconds
pulse: false // Don't show the pulse animation when a new step is selected
...
}
// Initialize the plugin, the options will be merged with the defaults and apply to any guide loaded
$.pageguide(options);
</pre>
</li>
<li>
After initialization:
<pre class="prettyprint linenums">
// These options will be merged with the existing options, and apply to any guides that get loaded
$.pageguide('options', {
pulse: true, // Turn the pulse effect back on, it's rad
step: {
direction: 'right' // Change the default position of the floating step indicators
}
});
</pre>
</li>
</ol>
<h3>Setting options for a single guide:</h3>
<p>These overrides will only apply to the guide being loaded.</p>
<ul>
<li>
<pre class="prettyprint linenums">
// Guide definition, as described above.
var guide = {...};
// Options to override for this guide only
var options = {
autoAdvanceInterval: 10, // Advance through the guide at 10 second intervals
...
step: {
shadow: false // Disable the translucent box around the target element
}
}
// $.pageguide(); // Only necessary if you haven't already initialized the plugin
$.pageguide('load', guide, options);
</pre>
</li>
</ul>
</div><!--/row-->
<hr/>
<div id="api-container" class="row-fluid section">
<a name="api"></a>
<h2>API Reference</h2>
<p>The two main ways to customize and control jQuery.PageGuide are the guide options, and functions to interact with the interface programmatically. Below you'll find the full list of what's available.</p>
<h3>Options</h3>
<p>
<h4>Default Settings:</h4>
<pre class="prettyprint linenums">
options: {
defaultGuide: "#pageGuide",
autoStart: true,
autoStartDelay: 0,
autoAdvanceInterval: null,
loadingSelector: null,
pulse: true,
events: {},
step: {
direction: 'left',
margin: {top: 100, bottom: 100},
shadow: true,
shadowPadding: '10px',
zIndex: null,
arrow: {
offsetX: 0,
offsetY: 0
},
events: {}
}
}
</pre>
</p>
<p>
<h4>Configurable Options:</h4>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Name</th>
<th>Default</th>
<th>Possible Values</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr><th colspan="4">Guide (options.*)</th></tr>
<tr>
<td>defaultGuide</td>
<td>none</td>
<td>String selector, jQuery selector, Object guide</td>
<td>CSS selector or guide definition object to load when $.pageguide is initialized without a guide as the first argument.</td>
</tr>
<tr>
<td>autoStart</td>
<td>true</td>
<td>true, false</td>
<td>Whether or not to focus on the first visible item immediately on open.</td>
</tr>
<tr>
<td>autoStartDelay</td>
<td>0</td>
<td>(int milliseconds)</td>
<td>Add a delay before automatically selecting the first visible item after the guide is opened.</td>
</tr>
<tr>
<td>autoAdvanceInterval</td>
<td>null</td>
<td>int seconds</td>
<td>Rotate through the visible steps at a regular interval while the guide is open.</td>
</tr>
<tr>
<td>loadingSelector</td>
<td>none</td>
<td>String selector, jQuery selector</td>
<td>The CSS selector for the DOM element used as a loading indicator. PageGuide will wait until this element is no longer visible before starting up.</td>
</tr>
<tr>
<td>pulse</td>
<td>true</td>
<td>true, false</td>
<td>Show an animated effect to further highlight the target element whenever a new step is selected. Requires the step shadow to be set to 'true'.</td>
</tr>
<tr>
<td>events</td>
<td>{}</td>
<td>Object {init, ready, load, unload, open, close, previous, next, step, resize, click} callback functions)</td>
<td>Convenience wrapper to specify guide-level event handlers. These events are bound on load, and automatically removed when the guide is unloaded.</td>
</tr>
<tr>
</tbody>
<tbody>
<tr><th colspan="4">Step (options.step.*)</th></tr>
<tr>
<td>direction</td>
<td>'left'</td>
<td>'top', 'right', 'bottom', 'left'</td>
<td>Position of the floating step number indicator in relation to the target element.</td>
</tr>
<tr>
<td>margin</td>
<td>{top: 100, bottom: 100}</td>
<td>Object {top, bottom} in px</td>
<td>Minimum distance the target element must be from top or bottom of the viewport. If the element is outside of this margin, the window will scroll to bring the element into view.</td>
</tr>
<tr>
<td>shadow</td>
<td>true</td>
<td>true, false</td>
<td>Render a transparent box around the current step's target element.</td>
</tr>
<tr>
<td>shadowPadding</td>
<td>'10px'</td>
<td>String padding, int padding</td>
<td>Applied to all sides of the shadow to pad the height and width around the target element.</td>
</tr>
<tr>
<td>zIndex</td>
<td>null</td>
<td>int z-index</td>
<td>Force the base z-index of the step, which is used when rendering the floating step number indicator and the shadow. If set to null, the target element's z-index is used. The shadow is rendered at a z-index of base + 1, and the floating step number indicator is base + 2.</td>
</tr>
<tr>
<td>arrow</td>
<td>{offsetX: 0, offsetY: 0}</td>
<td>Object {offsetX, offsetY} in px</td>
<td>Additional offset to apply to the floating step indicator to make fine adjustments to positioning.</td>
</tr>
<tr>
<td>events</td>
<td>{}</td>
<td>Object {show, hide, select, deselect} callbacks</td>
<td>Convenience wrapper to specify step-level event handlers. These events are bound to the individual step on load, and automatically removed when the guide is unloaded.</td>
</tr>
</tbody>
</table>
</p>
<h3>Functions</h3>
<p>In the spirit of jQuery, all public functions return the jQuery.PageGuide instance, so they're chainable. For example, if you want to open the guide immediately after loading:
<pre class="prettyprint linenums">
$.pageguide('load', guide, { autoAdvanceInterval: 10 }).open();
</pre>
</p>
<p>
<ul class="jsdocs api-functions">
<li>
<h4 class="name">$.pageguide('options', [options])</h4>
<p class="description">Get or set overrides for base options. If the argument is ommitted, an object containing the current options are returned.</p>
<p class="argument">@param {Object} [options] Options to override for all Guides</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('guide', [guide])</h4>
<p class="description">Get or load a guide. If the argument is ommitted, the currently loaded guide definition is returned.</p>
<p class="argument">@param {String|jQuerySelector|Object} [guide] Guide definition to load</p>
<p class="return">@return {Object|PageGuide} Guide definition if function called with no argument, PageGuide instance if options are specified.</p>
</li>
<li>
<h4 class="name">$.pageguide('load', guide, [options])</h4>
<p class="description">Get or load a guide. If the argument is ommitted, the currently loaded guide definition is returned.</p>
<p class="argument">@param {String|jQuerySelector|Object} [guide] Guide definition to load</p>
<p class="argument">@param {Object} [options] Override options applied only to this guide</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('unload')</h4>
<p class="description">Close and disable the current guide. Removes guide event handlers.</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('open')</h4>
<p class="description">Start the guide. If `options.autoStart` is true, the first step will be selected automatically.</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('close')</h4>
<p class="description">Stop the guide</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('previous')</h4>
<p class="description">Show the visible step prior to the currently selected step.</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('next')</h4>
<p class="description">Advance the guide to the next visible step.</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('showStep', newIdx)</h4>
<p class="description">Select step by index.</p>
<p class="argument">@param {int} newIdx The index (0-based) of the step to select</p>
<p class="argument">@param {int} [direction] If negative, the step number in the message field will scroll to the left, if positive it will scroll to the right. If undefined or 0, it will be calculated automatically.</p>
<p class="return">@return {PageGuide}</p>
</li>
<li>
<h4 class="name">$.pageguide('isLoaded')</h4>
<p class="description">Check if a guide is currently loaded.</p>
<p class="return">@return {Boolean}</p>
</li>
<li>
<h4 class="name">$.pageguide('isOpen')</h4>
<p class="description">Check if the guide is running.</p>
<p class="return">@return {Boolean}</p>
</li>
</ul>
</p>
</div><!--/row-->
<hr/>
<div id="examples-container" class="row-fluid section">
<a name="examples"></a>
<h2>Examples</h2>
<div class="example">
<a name="example-simple"></a>
<h3>Simple Example</h3>
<p>This is a basic example of a guide definition in JavaScript just to get your feet wet.</p>
<pre class="prettyprint linenums example example-simple">
loading...
</pre>
<script class="example example-simple" language="javascript">
var simpleGuide = {
id: 'simple',
'title': 'A very basic example',
steps: [
{
target: '#examples-container pre.example-simple',
content: 'Here I am on top of the target element',
direction: 'top'
},
{
target: '#examples-container pre.example-simple',
content: 'Here I am on the right of the target element',
direction: 'right'
},
{
target: '#examples-container pre.example-simple',
content: 'Here I am on the bottom of the target element',
direction: 'bottom',
margin: {
bottom: 200
}
},
{
target: '#examples-container pre.example-simple',
content: 'Here I am on the left of the target element',
direction: 'left'
}
]
}
</script>
<p><a class="btn btn-primary example example-simple" data-guide="simpleGuide">Try it</a></p>
</div><!--/example-->
<hr/>
<div class="example">
<a name="example-options"></a>
<h3>Override Default Options</h3>
<p>You can customize options when loading a guide, which will be applied only to that guide.</p>
<pre class="prettyprint linenums example example-options">
loading...
</pre>
<script class="example example-options" language="javascript">
var optionsGuide = {
id: 'options',
'title': 'An example of overriding options',
steps: [
{
target: '#examples-container pre.example-options',
content: 'Here I am on top of the target element',
direction: 'top'
},
{
target: '#examples-container pre.example-options',
content: 'Here I am on the right of the target element',
direction: 'right'
},
{
target: '#examples-container pre.example-options',
content: 'Here I am on the bottom of the target element',
direction: 'bottom',
margin: {
bottom: 200
}
},
{
target: '#examples-container pre.example-options',
content: 'Here I am on the left of the target element',
direction: 'left'
}
]
}
var optionsGuideOverrides = {
autoAdvanceInterval: 1, // Rotate through the steps at 1 second intervals
step: {
shadow: false
}
}
</script>
<p><a class="btn btn-primary example example-options" data-guide="optionsGuide">Try it</a></p>
</div><!--/example-->
<hr/>
<div class="example">
<a name="example-events"></a>
<h3>Event Listeners</h3>
<p>You can add event listeners on any part of a guide. In this example, we'll show an alert when an item is selected.</p>
<pre class="prettyprint linenums example example-events">
loading...
</pre>
<script class="example example-events" language="javascript">
var eventsGuide = {
id: 'events',
'title': 'An example showing event listeners',
steps: [
{
target: '#examples-container pre.example-events',
content: 'Here I am on top of the target element',
direction: 'top'
},
{
target: '#examples-container pre.example-events',
content: 'Here I am on the right of the target element',
direction: 'right'
},
{
target: '#examples-container pre.example-events',
content: 'Here I am on the bottom of the target element',
direction: 'bottom',
margin: {
bottom: 200
}
},
{
target: '#examples-container pre.example-events',
content: 'Here I am on the left of the target element',
direction: 'left'
}
]
}
var eventsGuideOverrides = {
events: {
open: function () {
alert("The guide has begun!");
},
close: function () {
alert("The guide has ended!");
}
},
step: {
events: {
select: function() {
alert("Step " + ($(this).data('idx') + 1) + " has been selected!");
}
}
}
}
</script>
<p><a class="btn btn-primary example example-events" data-guide="eventsGuide">Try it</a></p>
</div><!--/example-->
</div><!--/row-->
</div><!--/span-->
</div><!--/row-->
<hr>
<footer>
<p>© Sprint.ly 2012</p>
</footer>
</div><!--/.fluid-container-->
<!-- GitHub ribbon -->
<a href="https://github.com/sprintly/jquery.pageguide"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_left_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
</div><!--/.wrapper-->
<!-- JavaScript
================================================== -->
<!-- Placed at the end of the document so the page loads faster -->
<script src="docs/lib/jquery.js"></script>
<script src="docs/lib/bootstrap/js/bootstrap-dropdown.js"></script>
<script src="docs/lib/google-code-prettify/prettify.js"></script>
<script src="js/jquery.pageguide.js"></script>
<script language="javascript">
/**
* Helper Functions
*/
// View source of current page in a new window
function viewsource(e){
window.open("view-source:" + window.location, 'jquery.pageguide.source');
}
// Smooth scroll to anchor
function scrollTo(e) {
e.preventDefault();
var anchor = e.currentTarget.hash.slice(1);
$t = $('a[name=' + anchor + ']');
if (!$t.size()) return;
var dvh = $(window).height(),
dvtop = $(window).scrollTop(),
eltop = $t.offset().top,
mgn = {top: 100, bottom: 100};
var scrollTo = eltop - mgn.top;
$('html,body').animate({
scrollTop: scrollTo
}, {
duration: 500
});
}
// Example guides
var exampleGuides = {
'simpleGuide': [simpleGuide],
'optionsGuide': [optionsGuide, optionsGuideOverrides],
'eventsGuide': [eventsGuide, eventsGuideOverrides]
};
// Fill a <pre> with the example source
function showExampleSource(i, script) {
var example = $(this).attr('class').match(/example-[^\s]+/i);
$('pre.' + example).html($.trim($(this).html()));
}
// Load an example guide
function loadExample(e) {
e.preventDefault();
var guideAndOptions = exampleGuides[$(e.currentTarget).data('guide')];
if (guideAndOptions.length == 1) {
$.pageguide('load', guideAndOptions[0]).open();
} else {
$.pageguide('load', guideAndOptions[0], guideAndOptions[1]).open();
}
}
// Guide definition for the guide loaded on dom ready
var defaultGuide = {
id: 'jQuery.PageGuide',
title: 'Take a quick tour of all the possibilities',
steps: [
{
target: '.hero-unit h1',
content: 'Welcome to jQuery.PageGuide! Each "step" of the guide is associated with a target DOM element, specified by a CSS selector. Targets that are invisible or don\'t exist at the time the guide is started are automatically filtered out.',
direction: 'left'
},
{
target: '#usage-container h2',
content: 'Follow these simple instructions to get jQuery.PageGuide running on your site. You can also <a class="clickable view-source-link">view source</a> on this page to see how we made it work.',
direction: 'left',
shadow: false,
margin: {
bottom: 500
},
events: {
select: function(e) {
$('a.view-source-link').on('click', viewsource);
},
deselect: function(e) {
$('a.view-source-link').off('click', viewsource);
}
}
},
{
target: '#api-container',
content: 'Once you have the guides up and running, you might want to fine-tune the look and feel of things. Use this reference to unleash the power of jQuery.PageGuide.',
direction: 'left',
shadow: false
},
{
target: '#examples-container',
content: 'Now that you\'ve seen the basics. Check out some examples of what can be done.',
direction: 'left',
shadow: false
}
]
}
// Execute on DOM ready
$(function() {
// Fill the example <pre> blocks
$('script.example').each(showExampleSource);
// Make the <pre> blocks look nice
prettyPrint();
// Activate "Try It" buttons
$('a.example').on('click', loadExample);
// Smoove scroll to anchor links
$('a[href^=#]').on('click', scrollTo);
// Activate the source buttons
$('#btn-github').on('click', function (e) {
e.preventDefault;
window.location = 'https://github.com/sprintly/jquery.pageguide';
})
$('#btn-tarball').on('click', function (e) {
e.preventDefault;
window.location = 'https://github.com/sprintly/jquery.pageguide/tarball/master';
})
/****************************************
* And now for the best part...
***************************************/
// Load the default guide!
$.pageguide(defaultGuide);
// // Or, I could have initialized the plugin first, and loaded the guide later:
// $.pageguide();
// // ... time passes ...
// $.pageguide('load', defaultGuide);
// // To get the current guide definition, use:
// var guide = $.pageguide('guide');
});
</script>
</body>
</html>