|
@@ -0,0 +1,653 @@
|
|
1
|
+/*
|
|
2
|
+ * jQuery Foundation Joyride Plugin 2.0.3
|
|
3
|
+ * http://foundation.zurb.com
|
|
4
|
+ * Copyright 2012, ZURB
|
|
5
|
+ * Free to use under the MIT license.
|
|
6
|
+ * http://www.opensource.org/licenses/mit-license.php
|
|
7
|
+*/
|
|
8
|
+
|
|
9
|
+/*jslint unparam: true, browser: true, indent: 2 */
|
|
10
|
+
|
|
11
|
+;(function ($, window, undefined) {
|
|
12
|
+ 'use strict';
|
|
13
|
+
|
|
14
|
+ var defaults = {
|
|
15
|
+ 'version' : '2.0.3',
|
|
16
|
+ 'tipLocation' : 'bottom', // 'top' or 'bottom' in relation to parent
|
|
17
|
+ 'nubPosition' : 'auto', // override on a per tooltip bases
|
|
18
|
+ 'scrollSpeed' : 300, // Page scrolling speed in milliseconds
|
|
19
|
+ 'timer' : 0, // 0 = no timer , all other numbers = timer in milliseconds
|
|
20
|
+ 'startTimerOnClick' : true, // true or false - true requires clicking the first button start the timer
|
|
21
|
+ 'startOffset' : 0, // the index of the tooltip you want to start on (index of the li)
|
|
22
|
+ 'nextButton' : true, // true or false to control whether a next button is used
|
|
23
|
+ 'tipAnimation' : 'fade', // 'pop' or 'fade' in each tip
|
|
24
|
+ 'pauseAfter' : [], // array of indexes where to pause the tour after
|
|
25
|
+ 'tipAnimationFadeSpeed': 300, // when tipAnimation = 'fade' this is speed in milliseconds for the transition
|
|
26
|
+ 'cookieMonster' : false, // true or false to control whether cookies are used
|
|
27
|
+ 'cookieName' : 'joyride', // Name the cookie you'll use
|
|
28
|
+ 'cookieDomain' : false, // Will this cookie be attached to a domain, ie. '.notableapp.com'
|
|
29
|
+ 'tipContainer' : 'body', // Where will the tip be attached
|
|
30
|
+ 'postRideCallback' : $.noop, // A method to call once the tour closes (canceled or complete)
|
|
31
|
+ 'postStepCallback' : $.noop, // A method to call after each step
|
|
32
|
+ 'template' : { // HTML segments for tip layout
|
|
33
|
+ 'link' : '<a href="#close" class="joyride-close-tip">X</a>',
|
|
34
|
+ 'timer' : '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>',
|
|
35
|
+ 'tip' : '<div class="joyride-tip-guide"><span class="joyride-nub"></span></div>',
|
|
36
|
+ 'wrapper' : '<div class="joyride-content-wrapper"></div>',
|
|
37
|
+ 'button' : '<a href="#" class="joyride-next-tip"></a>'
|
|
38
|
+ }
|
|
39
|
+ },
|
|
40
|
+
|
|
41
|
+ Modernizr = Modernizr || false,
|
|
42
|
+
|
|
43
|
+ settings = {},
|
|
44
|
+
|
|
45
|
+ methods = {
|
|
46
|
+
|
|
47
|
+ init : function (opts) {
|
|
48
|
+ return this.each(function () {
|
|
49
|
+
|
|
50
|
+ if ($.isEmptyObject(settings)) {
|
|
51
|
+ settings = $.extend(true, defaults, opts);
|
|
52
|
+
|
|
53
|
+ // non configurable settings
|
|
54
|
+ settings.document = window.document;
|
|
55
|
+ settings.$document = $(settings.document);
|
|
56
|
+ settings.$window = $(window);
|
|
57
|
+ settings.$content_el = $(this);
|
|
58
|
+ settings.body_offset = $(settings.tipContainer).position();
|
|
59
|
+ settings.$tip_content = $('> li', settings.$content_el);
|
|
60
|
+ settings.paused = false;
|
|
61
|
+ settings.attempts = 0;
|
|
62
|
+
|
|
63
|
+ settings.tipLocationPatterns = {
|
|
64
|
+ top: ['bottom'],
|
|
65
|
+ bottom: [], // bottom should not need to be repositioned
|
|
66
|
+ left: ['right', 'top', 'bottom'],
|
|
67
|
+ right: ['left', 'top', 'bottom']
|
|
68
|
+ };
|
|
69
|
+
|
|
70
|
+ // are we using jQuery 1.7+
|
|
71
|
+ methods.jquery_check();
|
|
72
|
+
|
|
73
|
+ // can we create cookies?
|
|
74
|
+ if (!$.isFunction($.cookie)) {
|
|
75
|
+ settings.cookieMonster = false;
|
|
76
|
+ }
|
|
77
|
+
|
|
78
|
+ // generate the tips and insert into dom.
|
|
79
|
+ if (!settings.cookieMonster || !$.cookie(settings.cookieName)) {
|
|
80
|
+
|
|
81
|
+ settings.$tip_content.each(function (index) {
|
|
82
|
+ methods.create({$li : $(this), index : index});
|
|
83
|
+ });
|
|
84
|
+
|
|
85
|
+ // show first tip
|
|
86
|
+ if (!settings.startTimerOnClick && settings.timer > 0) {
|
|
87
|
+ methods.show('init');
|
|
88
|
+ methods.startTimer();
|
|
89
|
+ } else {
|
|
90
|
+ methods.show('init');
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+ settings.$document.on('click.joyride', '.joyride-next-tip, .joyride-modal-bg', function (e) {
|
|
96
|
+ e.preventDefault();
|
|
97
|
+
|
|
98
|
+ if (settings.$li.next().length < 1) {
|
|
99
|
+ methods.end();
|
|
100
|
+ } else if (settings.timer > 0) {
|
|
101
|
+ clearTimeout(settings.automate);
|
|
102
|
+ methods.hide();
|
|
103
|
+ methods.show();
|
|
104
|
+ methods.startTimer();
|
|
105
|
+ } else {
|
|
106
|
+ methods.hide();
|
|
107
|
+ methods.show();
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ });
|
|
111
|
+
|
|
112
|
+ settings.$document.on('click.joyride', '.joyride-close-tip', function (e) {
|
|
113
|
+ e.preventDefault();
|
|
114
|
+ methods.end();
|
|
115
|
+ });
|
|
116
|
+
|
|
117
|
+ settings.$window.bind('resize.joyride', function (e) {
|
|
118
|
+ if (methods.is_phone()) {
|
|
119
|
+ methods.pos_phone();
|
|
120
|
+ } else {
|
|
121
|
+ methods.pos_default();
|
|
122
|
+ }
|
|
123
|
+ });
|
|
124
|
+ } else {
|
|
125
|
+ methods.restart();
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+ });
|
|
129
|
+ },
|
|
130
|
+
|
|
131
|
+ // call this method when you want to resume the tour
|
|
132
|
+ resume : function () {
|
|
133
|
+ methods.set_li();
|
|
134
|
+ methods.show();
|
|
135
|
+ },
|
|
136
|
+
|
|
137
|
+ nextTip: function(){
|
|
138
|
+ if (settings.$li.next().length < 1) {
|
|
139
|
+ methods.end();
|
|
140
|
+ } else if (settings.timer > 0) {
|
|
141
|
+ clearTimeout(settings.automate);
|
|
142
|
+ methods.hide();
|
|
143
|
+ methods.show();
|
|
144
|
+ methods.startTimer();
|
|
145
|
+ } else {
|
|
146
|
+ methods.hide();
|
|
147
|
+ methods.show();
|
|
148
|
+ }
|
|
149
|
+ },
|
|
150
|
+
|
|
151
|
+ tip_template : function (opts) {
|
|
152
|
+ var $blank, content;
|
|
153
|
+
|
|
154
|
+ opts.tip_class = opts.tip_class || '';
|
|
155
|
+
|
|
156
|
+ $blank = $(settings.template.tip).addClass(opts.tip_class);
|
|
157
|
+ content = $.trim($(opts.li).html()) +
|
|
158
|
+ methods.button_text(opts.button_text) +
|
|
159
|
+ settings.template.link +
|
|
160
|
+ methods.timer_instance(opts.index);
|
|
161
|
+
|
|
162
|
+ $blank.append($(settings.template.wrapper));
|
|
163
|
+ $blank.first().attr('data-index', opts.index);
|
|
164
|
+ $('.joyride-content-wrapper', $blank).append(content);
|
|
165
|
+
|
|
166
|
+ return $blank[0];
|
|
167
|
+ },
|
|
168
|
+
|
|
169
|
+ timer_instance : function (index) {
|
|
170
|
+ var txt;
|
|
171
|
+
|
|
172
|
+ if ((index === 0 && settings.startTimerOnClick && settings.timer > 0) || settings.timer === 0) {
|
|
173
|
+ txt = '';
|
|
174
|
+ } else {
|
|
175
|
+ txt = methods.outerHTML($(settings.template.timer)[0]);
|
|
176
|
+ }
|
|
177
|
+ return txt;
|
|
178
|
+ },
|
|
179
|
+
|
|
180
|
+ button_text : function (txt) {
|
|
181
|
+ if (settings.nextButton) {
|
|
182
|
+ txt = $.trim(txt) || 'Next';
|
|
183
|
+ txt = methods.outerHTML($(settings.template.button).append(txt)[0]);
|
|
184
|
+ } else {
|
|
185
|
+ txt = '';
|
|
186
|
+ }
|
|
187
|
+ return txt;
|
|
188
|
+ },
|
|
189
|
+
|
|
190
|
+ create : function (opts) {
|
|
191
|
+ // backwards compatibility with data-text attribute
|
|
192
|
+ var buttonText = opts.$li.attr('data-button') || opts.$li.attr('data-text'),
|
|
193
|
+ tipClass = opts.$li.attr('class'),
|
|
194
|
+ $tip_content = $(methods.tip_template({
|
|
195
|
+ tip_class : tipClass,
|
|
196
|
+ index : opts.index,
|
|
197
|
+ button_text : buttonText,
|
|
198
|
+ li : opts.$li
|
|
199
|
+ }));
|
|
200
|
+
|
|
201
|
+ $(settings.tipContainer).append($tip_content);
|
|
202
|
+ },
|
|
203
|
+
|
|
204
|
+ show : function (init) {
|
|
205
|
+ var opts = {}, ii, opts_arr = [], opts_len = 0, p,
|
|
206
|
+ $timer = null;
|
|
207
|
+
|
|
208
|
+ // are we paused?
|
|
209
|
+ if (settings.$li === undefined || ($.inArray(settings.$li.index(), settings.pauseAfter) === -1)) {
|
|
210
|
+
|
|
211
|
+ // don't go to the next li if the tour was paused
|
|
212
|
+ if (settings.paused) {
|
|
213
|
+ settings.paused = false;
|
|
214
|
+ } else {
|
|
215
|
+ methods.set_li(init);
|
|
216
|
+ }
|
|
217
|
+
|
|
218
|
+ settings.attempts = 0;
|
|
219
|
+
|
|
220
|
+ if (settings.$li.length && settings.$target.length > 0) {
|
|
221
|
+ opts_arr = (settings.$li.data('options') || ':').split(';');
|
|
222
|
+ opts_len = opts_arr.length;
|
|
223
|
+
|
|
224
|
+ // parse options
|
|
225
|
+ for (ii = opts_len - 1; ii >= 0; ii--) {
|
|
226
|
+ p = opts_arr[ii].split(':');
|
|
227
|
+
|
|
228
|
+ if (p.length === 2) {
|
|
229
|
+ opts[$.trim(p[0])] = $.trim(p[1]);
|
|
230
|
+ }
|
|
231
|
+ }
|
|
232
|
+
|
|
233
|
+ settings.tipSettings = $.extend({}, settings, opts);
|
|
234
|
+
|
|
235
|
+ settings.tipSettings.tipLocationPattern = settings.tipLocationPatterns[settings.tipSettings.tipLocation];
|
|
236
|
+
|
|
237
|
+ // scroll if not modal
|
|
238
|
+ if (!/body/i.test(settings.$target.selector)) {
|
|
239
|
+ methods.scroll_to();
|
|
240
|
+ }
|
|
241
|
+
|
|
242
|
+ if (methods.is_phone()) {
|
|
243
|
+ methods.pos_phone(true);
|
|
244
|
+ } else {
|
|
245
|
+ methods.pos_default(true);
|
|
246
|
+ }
|
|
247
|
+
|
|
248
|
+ $timer = $('.joyride-timer-indicator', settings.$next_tip);
|
|
249
|
+
|
|
250
|
+ if (/pop/i.test(settings.tipAnimation)) {
|
|
251
|
+
|
|
252
|
+ $timer.outerWidth(0);
|
|
253
|
+
|
|
254
|
+ if (settings.timer > 0) {
|
|
255
|
+
|
|
256
|
+ settings.$next_tip.show();
|
|
257
|
+ $timer.animate({
|
|
258
|
+ width: $('.joyride-timer-indicator-wrap', settings.$next_tip).outerWidth()
|
|
259
|
+ }, settings.timer);
|
|
260
|
+
|
|
261
|
+ } else {
|
|
262
|
+
|
|
263
|
+ settings.$next_tip.show();
|
|
264
|
+
|
|
265
|
+ }
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+ } else if (/fade/i.test(settings.tipAnimation)) {
|
|
269
|
+
|
|
270
|
+ $timer.outerWidth(0);
|
|
271
|
+
|
|
272
|
+ if (settings.timer > 0) {
|
|
273
|
+
|
|
274
|
+ settings.$next_tip.fadeIn(settings.tipAnimationFadeSpeed);
|
|
275
|
+
|
|
276
|
+ settings.$next_tip.show();
|
|
277
|
+ $timer.animate({
|
|
278
|
+ width: $('.joyride-timer-indicator-wrap', settings.$next_tip).outerWidth()
|
|
279
|
+ }, settings.timer);
|
|
280
|
+
|
|
281
|
+ } else {
|
|
282
|
+
|
|
283
|
+ settings.$next_tip.fadeIn(settings.tipAnimationFadeSpeed);
|
|
284
|
+
|
|
285
|
+ }
|
|
286
|
+ }
|
|
287
|
+
|
|
288
|
+ settings.$current_tip = settings.$next_tip;
|
|
289
|
+
|
|
290
|
+ // skip non-existent targets
|
|
291
|
+ } else if (settings.$li && settings.$target.length < 1) {
|
|
292
|
+
|
|
293
|
+ methods.show();
|
|
294
|
+
|
|
295
|
+ } else {
|
|
296
|
+
|
|
297
|
+ methods.end();
|
|
298
|
+
|
|
299
|
+ }
|
|
300
|
+ } else {
|
|
301
|
+
|
|
302
|
+ settings.paused = true;
|
|
303
|
+
|
|
304
|
+ }
|
|
305
|
+
|
|
306
|
+ },
|
|
307
|
+
|
|
308
|
+ // detect phones with media queries if supported.
|
|
309
|
+ is_phone : function () {
|
|
310
|
+ if (Modernizr) {
|
|
311
|
+ return Modernizr.mq('only screen and (max-width: 767px)');
|
|
312
|
+ }
|
|
313
|
+
|
|
314
|
+ return (settings.$window.width() < 767) ? true : false;
|
|
315
|
+ },
|
|
316
|
+
|
|
317
|
+ hide : function () {
|
|
318
|
+ settings.postStepCallback(settings.$li.index(), settings.$current_tip);
|
|
319
|
+ $('.joyride-modal-bg').hide();
|
|
320
|
+ settings.$current_tip.hide();
|
|
321
|
+ },
|
|
322
|
+
|
|
323
|
+ set_li : function (init) {
|
|
324
|
+ if (init) {
|
|
325
|
+ settings.$li = settings.$tip_content.eq(settings.startOffset);
|
|
326
|
+ methods.set_next_tip();
|
|
327
|
+ settings.$current_tip = settings.$next_tip;
|
|
328
|
+ } else {
|
|
329
|
+ settings.$li = settings.$li.next();
|
|
330
|
+ methods.set_next_tip();
|
|
331
|
+ }
|
|
332
|
+
|
|
333
|
+ methods.set_target();
|
|
334
|
+ },
|
|
335
|
+
|
|
336
|
+ set_next_tip : function () {
|
|
337
|
+ settings.$next_tip = $('.joyride-tip-guide[data-index=' + settings.$li.index() + ']');
|
|
338
|
+ },
|
|
339
|
+
|
|
340
|
+ set_target : function () {
|
|
341
|
+ var cl = settings.$li.attr('data-class'),
|
|
342
|
+ id = settings.$li.attr('data-id'),
|
|
343
|
+ $sel = function () {
|
|
344
|
+ if (id) {
|
|
345
|
+ return $(settings.document.getElementById(id));
|
|
346
|
+ } else if (cl) {
|
|
347
|
+ return $('.' + cl).first();
|
|
348
|
+ } else {
|
|
349
|
+ return $('body');
|
|
350
|
+ }
|
|
351
|
+ };
|
|
352
|
+
|
|
353
|
+ settings.$target = $sel();
|
|
354
|
+ },
|
|
355
|
+
|
|
356
|
+ scroll_to : function () {
|
|
357
|
+ var window_half, tipOffset;
|
|
358
|
+
|
|
359
|
+ window_half = settings.$window.height() / 2;
|
|
360
|
+ tipOffset = Math.ceil(settings.$target.offset().top - window_half + settings.$next_tip.outerHeight());
|
|
361
|
+
|
|
362
|
+ $("html, body").stop().animate({
|
|
363
|
+ scrollTop: tipOffset
|
|
364
|
+ }, settings.scrollSpeed);
|
|
365
|
+ },
|
|
366
|
+
|
|
367
|
+ paused : function () {
|
|
368
|
+ if (($.inArray((settings.$li.index() + 1), settings.pauseAfter) === -1)) {
|
|
369
|
+ return true;
|
|
370
|
+ }
|
|
371
|
+
|
|
372
|
+ return false;
|
|
373
|
+ },
|
|
374
|
+
|
|
375
|
+ destroy : function () {
|
|
376
|
+ settings.$document.off('.joyride');
|
|
377
|
+ $(window).off('.joyride');
|
|
378
|
+ $('.joyride-close-tip, .joyride-next-tip, .joyride-modal-bg').off('.joyride');
|
|
379
|
+ $('.joyride-tip-guide, .joyride-modal-bg').remove();
|
|
380
|
+ clearTimeout(settings.automate);
|
|
381
|
+ settings = {};
|
|
382
|
+ },
|
|
383
|
+
|
|
384
|
+ restart : function () {
|
|
385
|
+ methods.hide();
|
|
386
|
+ settings.$li = undefined;
|
|
387
|
+ methods.show('init');
|
|
388
|
+ },
|
|
389
|
+
|
|
390
|
+ pos_default : function (init) {
|
|
391
|
+ var half_fold = Math.ceil(settings.$window.height() / 2),
|
|
392
|
+ tip_position = settings.$next_tip.offset(),
|
|
393
|
+ $nub = $('.joyride-nub', settings.$next_tip),
|
|
394
|
+ nub_height = Math.ceil($nub.outerHeight() / 2),
|
|
395
|
+ toggle = init || false;
|
|
396
|
+
|
|
397
|
+ // tip must not be "display: none" to calculate position
|
|
398
|
+ if (toggle) {
|
|
399
|
+ settings.$next_tip.css('visibility', 'hidden');
|
|
400
|
+ settings.$next_tip.show();
|
|
401
|
+ }
|
|
402
|
+
|
|
403
|
+ if (!/body/i.test(settings.$target.selector)) {
|
|
404
|
+
|
|
405
|
+ if (methods.bottom()) {
|
|
406
|
+ settings.$next_tip.css({
|
|
407
|
+ top: (settings.$target.offset().top + nub_height + settings.$target.outerHeight()),
|
|
408
|
+ left: settings.$target.offset().left});
|
|
409
|
+
|
|
410
|
+ methods.nub_position($nub, settings.tipSettings.nubPosition, 'top');
|
|
411
|
+
|
|
412
|
+ } else if (methods.top()) {
|
|
413
|
+
|
|
414
|
+ settings.$next_tip.css({
|
|
415
|
+ top: (settings.$target.offset().top - settings.$next_tip.outerHeight() - nub_height),
|
|
416
|
+ left: settings.$target.offset().left});
|
|
417
|
+
|
|
418
|
+ methods.nub_position($nub, settings.tipSettings.nubPosition, 'bottom');
|
|
419
|
+
|
|
420
|
+ } else if (methods.right()) {
|
|
421
|
+
|
|
422
|
+ settings.$next_tip.css({
|
|
423
|
+ top: settings.$target.offset().top,
|
|
424
|
+ left: (settings.$target.outerWidth() + settings.$target.offset().left)});
|
|
425
|
+
|
|
426
|
+ methods.nub_position($nub, settings.tipSettings.nubPosition, 'left');
|
|
427
|
+
|
|
428
|
+ } else if (methods.left()) {
|
|
429
|
+
|
|
430
|
+ settings.$next_tip.css({
|
|
431
|
+ top: settings.$target.offset().top,
|
|
432
|
+ left: (settings.$target.offset().left - settings.$next_tip.outerWidth() - nub_height)});
|
|
433
|
+
|
|
434
|
+ methods.nub_position($nub, settings.tipSettings.nubPosition, 'right');
|
|
435
|
+
|
|
436
|
+ }
|
|
437
|
+
|
|
438
|
+ if (!methods.visible(methods.corners(settings.$next_tip)) && settings.attempts < settings.tipSettings.tipLocationPattern.length) {
|
|
439
|
+
|
|
440
|
+ $nub.removeClass('bottom')
|
|
441
|
+ .removeClass('top')
|
|
442
|
+ .removeClass('right')
|
|
443
|
+ .removeClass('left');
|
|
444
|
+
|
|
445
|
+ settings.tipSettings.tipLocation = settings.tipSettings.tipLocationPattern[settings.attempts];
|
|
446
|
+
|
|
447
|
+ settings.attempts++;
|
|
448
|
+
|
|
449
|
+ methods.pos_default(true);
|
|
450
|
+
|
|
451
|
+ }
|
|
452
|
+
|
|
453
|
+ } else if (settings.$li.length) {
|
|
454
|
+
|
|
455
|
+ methods.pos_modal($nub);
|
|
456
|
+
|
|
457
|
+ }
|
|
458
|
+
|
|
459
|
+ if (toggle) {
|
|
460
|
+ settings.$next_tip.hide();
|
|
461
|
+ settings.$next_tip.css('visibility', 'visible');
|
|
462
|
+ }
|
|
463
|
+
|
|
464
|
+ },
|
|
465
|
+
|
|
466
|
+ pos_phone : function (init) {
|
|
467
|
+ var tip_height = settings.$next_tip.outerHeight(),
|
|
468
|
+ tip_offset = settings.$next_tip.offset(),
|
|
469
|
+ target_height = settings.$target.outerHeight(),
|
|
470
|
+ $nub = $('.joyride-nub', settings.$next_tip),
|
|
471
|
+ nub_height = Math.ceil($nub.outerHeight() / 2),
|
|
472
|
+ toggle = init || false;
|
|
473
|
+
|
|
474
|
+ $nub.removeClass('bottom')
|
|
475
|
+ .removeClass('top')
|
|
476
|
+ .removeClass('right')
|
|
477
|
+ .removeClass('left');
|
|
478
|
+
|
|
479
|
+ if (toggle) {
|
|
480
|
+ settings.$next_tip.css('visibility', 'hidden');
|
|
481
|
+ settings.$next_tip.show();
|
|
482
|
+ }
|
|
483
|
+
|
|
484
|
+ if (!/body/i.test(settings.$target.selector)) {
|
|
485
|
+
|
|
486
|
+ if (methods.top()) {
|
|
487
|
+
|
|
488
|
+ settings.$next_tip.offset({top: settings.$target.offset().top - tip_height - nub_height});
|
|
489
|
+ $nub.addClass('bottom');
|
|
490
|
+
|
|
491
|
+ } else {
|
|
492
|
+
|
|
493
|
+ settings.$next_tip.offset({top: settings.$target.offset().top + target_height + nub_height});
|
|
494
|
+ $nub.addClass('top');
|
|
495
|
+
|
|
496
|
+ }
|
|
497
|
+
|
|
498
|
+ } else if (settings.$li.length) {
|
|
499
|
+
|
|
500
|
+ methods.pos_modal($nub);
|
|
501
|
+
|
|
502
|
+ }
|
|
503
|
+
|
|
504
|
+ if (toggle) {
|
|
505
|
+ settings.$next_tip.hide();
|
|
506
|
+ settings.$next_tip.css('visibility', 'visible');
|
|
507
|
+ }
|
|
508
|
+ },
|
|
509
|
+
|
|
510
|
+ pos_modal : function ($nub) {
|
|
511
|
+ methods.center();
|
|
512
|
+ $nub.hide();
|
|
513
|
+
|
|
514
|
+ if ($('.joyride-modal-bg').length < 1) {
|
|
515
|
+ $('body').append('<div class="joyride-modal-bg">').show();
|
|
516
|
+ }
|
|
517
|
+
|
|
518
|
+ if (/pop/i.test(settings.tipAnimation)) {
|
|
519
|
+ $('.joyride-modal-bg').show();
|
|
520
|
+ } else {
|
|
521
|
+ $('.joyride-modal-bg').fadeIn(settings.tipAnimationFadeSpeed);
|
|
522
|
+ }
|
|
523
|
+ },
|
|
524
|
+
|
|
525
|
+ center : function () {
|
|
526
|
+ var $w = settings.$window;
|
|
527
|
+
|
|
528
|
+ settings.$next_tip.css({
|
|
529
|
+ top : ((($w.height() - settings.$next_tip.outerHeight()) / 2) + $w.scrollTop()),
|
|
530
|
+ left : ((($w.width() - settings.$next_tip.outerWidth()) / 2) + $w.scrollLeft())
|
|
531
|
+ });
|
|
532
|
+
|
|
533
|
+ return true;
|
|
534
|
+ },
|
|
535
|
+
|
|
536
|
+ bottom : function () {
|
|
537
|
+ return /bottom/i.test(settings.tipSettings.tipLocation);
|
|
538
|
+ },
|
|
539
|
+
|
|
540
|
+ top : function () {
|
|
541
|
+ return /top/i.test(settings.tipSettings.tipLocation);
|
|
542
|
+ },
|
|
543
|
+
|
|
544
|
+ right : function () {
|
|
545
|
+ return /right/i.test(settings.tipSettings.tipLocation);
|
|
546
|
+ },
|
|
547
|
+
|
|
548
|
+ left : function () {
|
|
549
|
+ return /left/i.test(settings.tipSettings.tipLocation);
|
|
550
|
+ },
|
|
551
|
+
|
|
552
|
+ corners : function (el) {
|
|
553
|
+ var w = settings.$window,
|
|
554
|
+ right = w.width() + w.scrollLeft(),
|
|
555
|
+ bottom = w.width() + w.scrollTop();
|
|
556
|
+
|
|
557
|
+ return [
|
|
558
|
+ el.offset().top <= w.scrollTop(),
|
|
559
|
+ right <= el.offset().left + el.outerWidth(),
|
|
560
|
+ bottom <= el.offset().top + el.outerHeight(),
|
|
561
|
+ w.scrollLeft() >= el.offset().left
|
|
562
|
+ ];
|
|
563
|
+ },
|
|
564
|
+
|
|
565
|
+ visible : function (hidden_corners) {
|
|
566
|
+ var i = hidden_corners.length;
|
|
567
|
+
|
|
568
|
+ while (i--) {
|
|
569
|
+ if (hidden_corners[i]) return false;
|
|
570
|
+ }
|
|
571
|
+
|
|
572
|
+ return true;
|
|
573
|
+ },
|
|
574
|
+
|
|
575
|
+ nub_position : function (nub, pos, def) {
|
|
576
|
+ if (pos === 'auto') {
|
|
577
|
+ nub.addClass(def);
|
|
578
|
+ } else {
|
|
579
|
+ nub.addClass(pos);
|
|
580
|
+ }
|
|
581
|
+ },
|
|
582
|
+
|
|
583
|
+ startTimer : function () {
|
|
584
|
+ if (settings.$li.length) {
|
|
585
|
+ settings.automate = setTimeout(function () {
|
|
586
|
+ methods.hide();
|
|
587
|
+ methods.show();
|
|
588
|
+ methods.startTimer();
|
|
589
|
+ }, settings.timer);
|
|
590
|
+ } else {
|
|
591
|
+ clearTimeout(settings.automate);
|
|
592
|
+ }
|
|
593
|
+ },
|
|
594
|
+
|
|
595
|
+ end : function () {
|
|
596
|
+ if (settings.cookieMonster) {
|
|
597
|
+ $.cookie(settings.cookieName, 'ridden', { expires: 365, domain: settings.cookieDomain });
|
|
598
|
+ }
|
|
599
|
+
|
|
600
|
+ if (settings.timer > 0) {
|
|
601
|
+ clearTimeout(settings.automate);
|
|
602
|
+ }
|
|
603
|
+
|
|
604
|
+ $('.joyride-modal-bg').hide();
|
|
605
|
+ settings.$current_tip.hide();
|
|
606
|
+ settings.postStepCallback(settings.$li.index(), settings.$current_tip);
|
|
607
|
+ settings.postRideCallback(settings.$li.index(), settings.$current_tip);
|
|
608
|
+ },
|
|
609
|
+
|
|
610
|
+ jquery_check : function () {
|
|
611
|
+ // define on() and off() for older jQuery
|
|
612
|
+ if (!$.isFunction($.fn.on)) {
|
|
613
|
+
|
|
614
|
+ $.fn.on = function (types, sel, fn) {
|
|
615
|
+
|
|
616
|
+ return this.delegate(sel, types, fn);
|
|
617
|
+
|
|
618
|
+ };
|
|
619
|
+
|
|
620
|
+ $.fn.off = function (types, sel, fn) {
|
|
621
|
+
|
|
622
|
+ return this.undelegate(sel, types, fn);
|
|
623
|
+
|
|
624
|
+ };
|
|
625
|
+
|
|
626
|
+ return false;
|
|
627
|
+ }
|
|
628
|
+
|
|
629
|
+ return true;
|
|
630
|
+ },
|
|
631
|
+
|
|
632
|
+ outerHTML : function (el) {
|
|
633
|
+ // support FireFox < 11
|
|
634
|
+ return el.outerHTML || new XMLSerializer().serializeToString(el);
|
|
635
|
+ },
|
|
636
|
+
|
|
637
|
+ version : function () {
|
|
638
|
+ return settings.version;
|
|
639
|
+ }
|
|
640
|
+
|
|
641
|
+ };
|
|
642
|
+
|
|
643
|
+ $.fn.joyride = function (method) {
|
|
644
|
+ if (methods[method]) {
|
|
645
|
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
|
646
|
+ } else if (typeof method === 'object' || !method) {
|
|
647
|
+ return methods.init.apply(this, arguments);
|
|
648
|
+ } else {
|
|
649
|
+ $.error('Method ' + method + ' does not exist on jQuery.joyride');
|
|
650
|
+ }
|
|
651
|
+ };
|
|
652
|
+
|
|
653
|
+}(jQuery, this));
|