volt-foundation 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,917 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- var Modernizr = Modernizr || false;
5
-
6
- Foundation.libs.joyride = {
7
- name : 'joyride',
8
-
9
- version : '5.4.6',
10
-
11
- defaults : {
12
- expose : false, // turn on or off the expose feature
13
- modal : true, // Whether to cover page with modal during the tour
14
- keyboard : true, // enable left, right and esc keystrokes
15
- tip_location : 'bottom', // 'top' or 'bottom' in relation to parent
16
- nub_position : 'auto', // override on a per tooltip bases
17
- scroll_speed : 1500, // Page scrolling speed in milliseconds, 0 = no scroll animation
18
- scroll_animation : 'linear', // supports 'swing' and 'linear', extend with jQuery UI.
19
- timer : 0, // 0 = no timer , all other numbers = timer in milliseconds
20
- start_timer_on_click : true, // true or false - true requires clicking the first button start the timer
21
- start_offset : 0, // the index of the tooltip you want to start on (index of the li)
22
- next_button : true, // true or false to control whether a next button is used
23
- prev_button : true, // true or false to control whether a prev button is used
24
- tip_animation : 'fade', // 'pop' or 'fade' in each tip
25
- pause_after : [], // array of indexes where to pause the tour after
26
- exposed : [], // array of expose elements
27
- tip_animation_fade_speed : 300, // when tipAnimation = 'fade' this is speed in milliseconds for the transition
28
- cookie_monster : false, // true or false to control whether cookies are used
29
- cookie_name : 'joyride', // Name the cookie you'll use
30
- cookie_domain : false, // Will this cookie be attached to a domain, ie. '.notableapp.com'
31
- cookie_expires : 365, // set when you would like the cookie to expire.
32
- tip_container : 'body', // Where will the tip be attached
33
- abort_on_close : true, // When true, the close event will not fire any callback
34
- tip_location_patterns : {
35
- top: ['bottom'],
36
- bottom: [], // bottom should not need to be repositioned
37
- left: ['right', 'top', 'bottom'],
38
- right: ['left', 'top', 'bottom']
39
- },
40
- post_ride_callback : function (){}, // A method to call once the tour closes (canceled or complete)
41
- post_step_callback : function (){}, // A method to call after each step
42
- pre_step_callback : function (){}, // A method to call before each step
43
- pre_ride_callback : function (){}, // A method to call before the tour starts (passed index, tip, and cloned exposed element)
44
- post_expose_callback : function (){}, // A method to call after an element has been exposed
45
- template : { // HTML segments for tip layout
46
- link : '<a href="#close" class="joyride-close-tip">&times;</a>',
47
- timer : '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>',
48
- tip : '<div class="joyride-tip-guide"><span class="joyride-nub"></span></div>',
49
- wrapper : '<div class="joyride-content-wrapper"></div>',
50
- button : '<a href="#" class="small button joyride-next-tip"></a>',
51
- prev_button : '<a href="#" class="small button joyride-prev-tip"></a>',
52
- modal : '<div class="joyride-modal-bg"></div>',
53
- expose : '<div class="joyride-expose-wrapper"></div>',
54
- expose_cover : '<div class="joyride-expose-cover"></div>'
55
- },
56
- expose_add_class : '' // One or more space-separated class names to be added to exposed element
57
- },
58
-
59
- init : function (scope, method, options) {
60
- Foundation.inherit(this, 'throttle random_str');
61
-
62
- this.settings = this.settings || $.extend({}, this.defaults, (options || method));
63
-
64
- this.bindings(method, options)
65
- },
66
-
67
- go_next : function() {
68
- if (this.settings.$li.next().length < 1) {
69
- this.end();
70
- } else if (this.settings.timer > 0) {
71
- clearTimeout(this.settings.automate);
72
- this.hide();
73
- this.show();
74
- this.startTimer();
75
- } else {
76
- this.hide();
77
- this.show();
78
- }
79
- },
80
-
81
- go_prev : function() {
82
- if (this.settings.$li.prev().length < 1) {
83
- // Do nothing if there are no prev element
84
- } else if (this.settings.timer > 0) {
85
- clearTimeout(this.settings.automate);
86
- this.hide();
87
- this.show(null, true);
88
- this.startTimer();
89
- } else {
90
- this.hide();
91
- this.show(null, true);
92
- }
93
- },
94
-
95
- events : function () {
96
- var self = this;
97
-
98
- $(this.scope)
99
- .off('.joyride')
100
- .on('click.fndtn.joyride', '.joyride-next-tip, .joyride-modal-bg', function (e) {
101
- e.preventDefault();
102
- this.go_next()
103
- }.bind(this))
104
- .on('click.fndtn.joyride', '.joyride-prev-tip', function (e) {
105
- e.preventDefault();
106
- this.go_prev();
107
- }.bind(this))
108
-
109
- .on('click.fndtn.joyride', '.joyride-close-tip', function (e) {
110
- e.preventDefault();
111
- this.end(this.settings.abort_on_close);
112
- }.bind(this))
113
-
114
- .on("keyup.fndtn.joyride", function(e) {
115
- // Don't do anything if keystrokes are disabled
116
- // or if the joyride is not being shown
117
- if (!this.settings.keyboard || !this.settings.riding) return;
118
-
119
- switch (e.which) {
120
- case 39: // right arrow
121
- e.preventDefault();
122
- this.go_next();
123
- break;
124
- case 37: // left arrow
125
- e.preventDefault();
126
- this.go_prev();
127
- break;
128
- case 27: // escape
129
- e.preventDefault();
130
- this.end(this.settings.abort_on_close);
131
- }
132
- }.bind(this));
133
-
134
- $(window)
135
- .off('.joyride')
136
- .on('resize.fndtn.joyride', self.throttle(function () {
137
- if ($('[' + self.attr_name() + ']').length > 0 && self.settings.$next_tip && self.settings.riding) {
138
- if (self.settings.exposed.length > 0) {
139
- var $els = $(self.settings.exposed);
140
-
141
- $els.each(function () {
142
- var $this = $(this);
143
- self.un_expose($this);
144
- self.expose($this);
145
- });
146
- }
147
-
148
- if (self.is_phone()) {
149
- self.pos_phone();
150
- } else {
151
- self.pos_default(false);
152
- }
153
- }
154
- }, 100));
155
- },
156
-
157
- start : function () {
158
- var self = this,
159
- $this = $('[' + this.attr_name() + ']', this.scope),
160
- integer_settings = ['timer', 'scrollSpeed', 'startOffset', 'tipAnimationFadeSpeed', 'cookieExpires'],
161
- int_settings_count = integer_settings.length;
162
-
163
- if (!$this.length > 0) return;
164
-
165
- if (!this.settings.init) this.events();
166
-
167
- this.settings = $this.data(this.attr_name(true) + '-init');
168
-
169
- // non configureable settings
170
- this.settings.$content_el = $this;
171
- this.settings.$body = $(this.settings.tip_container);
172
- this.settings.body_offset = $(this.settings.tip_container).position();
173
- this.settings.$tip_content = this.settings.$content_el.find('> li');
174
- this.settings.paused = false;
175
- this.settings.attempts = 0;
176
- this.settings.riding = true;
177
-
178
- // can we create cookies?
179
- if (typeof $.cookie !== 'function') {
180
- this.settings.cookie_monster = false;
181
- }
182
-
183
- // generate the tips and insert into dom.
184
- if (!this.settings.cookie_monster || this.settings.cookie_monster && !$.cookie(this.settings.cookie_name)) {
185
- this.settings.$tip_content.each(function (index) {
186
- var $this = $(this);
187
- this.settings = $.extend({}, self.defaults, self.data_options($this));
188
-
189
- // Make sure that settings parsed from data_options are integers where necessary
190
- var i = int_settings_count;
191
- while (i--) {
192
- self.settings[integer_settings[i]] = parseInt(self.settings[integer_settings[i]], 10);
193
- }
194
- self.create({$li : $this, index : index});
195
- });
196
-
197
- // show first tip
198
- if (!this.settings.start_timer_on_click && this.settings.timer > 0) {
199
- this.show('init');
200
- this.startTimer();
201
- } else {
202
- this.show('init');
203
- }
204
-
205
- }
206
- },
207
-
208
- resume : function () {
209
- this.set_li();
210
- this.show();
211
- },
212
-
213
- tip_template : function (opts) {
214
- var $blank, content;
215
-
216
- opts.tip_class = opts.tip_class || '';
217
-
218
- $blank = $(this.settings.template.tip).addClass(opts.tip_class);
219
- content = $.trim($(opts.li).html()) +
220
- this.prev_button_text(opts.prev_button_text, opts.index) +
221
- this.button_text(opts.button_text) +
222
- this.settings.template.link +
223
- this.timer_instance(opts.index);
224
-
225
- $blank.append($(this.settings.template.wrapper));
226
- $blank.first().attr(this.add_namespace('data-index'), opts.index);
227
- $('.joyride-content-wrapper', $blank).append(content);
228
-
229
- return $blank[0];
230
- },
231
-
232
- timer_instance : function (index) {
233
- var txt;
234
-
235
- if ((index === 0 && this.settings.start_timer_on_click && this.settings.timer > 0) || this.settings.timer === 0) {
236
- txt = '';
237
- } else {
238
- txt = $(this.settings.template.timer)[0].outerHTML;
239
- }
240
- return txt;
241
- },
242
-
243
- button_text : function (txt) {
244
- if (this.settings.tip_settings.next_button) {
245
- txt = $.trim(txt) || 'Next';
246
- txt = $(this.settings.template.button).append(txt)[0].outerHTML;
247
- } else {
248
- txt = '';
249
- }
250
- return txt;
251
- },
252
-
253
- prev_button_text : function (txt, idx) {
254
- if (this.settings.tip_settings.prev_button) {
255
- txt = $.trim(txt) || 'Previous';
256
-
257
- // Add the disabled class to the button if it's the first element
258
- if (idx == 0)
259
- txt = $(this.settings.template.prev_button).append(txt).addClass('disabled')[0].outerHTML;
260
- else
261
- txt = $(this.settings.template.prev_button).append(txt)[0].outerHTML;
262
- } else {
263
- txt = '';
264
- }
265
- return txt;
266
- },
267
-
268
- create : function (opts) {
269
- this.settings.tip_settings = $.extend({}, this.settings, this.data_options(opts.$li));
270
- var buttonText = opts.$li.attr(this.add_namespace('data-button'))
271
- || opts.$li.attr(this.add_namespace('data-text')),
272
- prevButtonText = opts.$li.attr(this.add_namespace('data-button-prev'))
273
- || opts.$li.attr(this.add_namespace('data-prev-text')),
274
- tipClass = opts.$li.attr('class'),
275
- $tip_content = $(this.tip_template({
276
- tip_class : tipClass,
277
- index : opts.index,
278
- button_text : buttonText,
279
- prev_button_text : prevButtonText,
280
- li : opts.$li
281
- }));
282
-
283
- $(this.settings.tip_container).append($tip_content);
284
- },
285
-
286
- show : function (init, is_prev) {
287
- var $timer = null;
288
-
289
- // are we paused?
290
- if (this.settings.$li === undefined
291
- || ($.inArray(this.settings.$li.index(), this.settings.pause_after) === -1)) {
292
-
293
- // don't go to the next li if the tour was paused
294
- if (this.settings.paused) {
295
- this.settings.paused = false;
296
- } else {
297
- this.set_li(init, is_prev);
298
- }
299
-
300
- this.settings.attempts = 0;
301
-
302
- if (this.settings.$li.length && this.settings.$target.length > 0) {
303
- if (init) { //run when we first start
304
- this.settings.pre_ride_callback(this.settings.$li.index(), this.settings.$next_tip);
305
- if (this.settings.modal) {
306
- this.show_modal();
307
- }
308
- }
309
-
310
- this.settings.pre_step_callback(this.settings.$li.index(), this.settings.$next_tip);
311
-
312
- if (this.settings.modal && this.settings.expose) {
313
- this.expose();
314
- }
315
-
316
- this.settings.tip_settings = $.extend({}, this.settings, this.data_options(this.settings.$li));
317
-
318
- this.settings.timer = parseInt(this.settings.timer, 10);
319
-
320
- this.settings.tip_settings.tip_location_pattern = this.settings.tip_location_patterns[this.settings.tip_settings.tip_location];
321
-
322
- // scroll if not modal
323
- if (!/body/i.test(this.settings.$target.selector)) {
324
- this.scroll_to();
325
- }
326
-
327
- if (this.is_phone()) {
328
- this.pos_phone(true);
329
- } else {
330
- this.pos_default(true);
331
- }
332
-
333
- $timer = this.settings.$next_tip.find('.joyride-timer-indicator');
334
-
335
- if (/pop/i.test(this.settings.tip_animation)) {
336
-
337
- $timer.width(0);
338
-
339
- if (this.settings.timer > 0) {
340
-
341
- this.settings.$next_tip.show();
342
-
343
- setTimeout(function () {
344
- $timer.animate({
345
- width: $timer.parent().width()
346
- }, this.settings.timer, 'linear');
347
- }.bind(this), this.settings.tip_animation_fade_speed);
348
-
349
- } else {
350
- this.settings.$next_tip.show();
351
-
352
- }
353
-
354
-
355
- } else if (/fade/i.test(this.settings.tip_animation)) {
356
-
357
- $timer.width(0);
358
-
359
- if (this.settings.timer > 0) {
360
-
361
- this.settings.$next_tip
362
- .fadeIn(this.settings.tip_animation_fade_speed)
363
- .show();
364
-
365
- setTimeout(function () {
366
- $timer.animate({
367
- width: $timer.parent().width()
368
- }, this.settings.timer, 'linear');
369
- }.bind(this), this.settings.tip_animation_fade_speed);
370
-
371
- } else {
372
- this.settings.$next_tip.fadeIn(this.settings.tip_animation_fade_speed);
373
- }
374
- }
375
-
376
- this.settings.$current_tip = this.settings.$next_tip;
377
-
378
- // skip non-existant targets
379
- } else if (this.settings.$li && this.settings.$target.length < 1) {
380
-
381
- this.show(init, is_prev);
382
-
383
- } else {
384
-
385
- this.end();
386
-
387
- }
388
- } else {
389
-
390
- this.settings.paused = true;
391
-
392
- }
393
-
394
- },
395
-
396
- is_phone : function () {
397
- return matchMedia(Foundation.media_queries.small).matches &&
398
- !matchMedia(Foundation.media_queries.medium).matches;
399
- },
400
-
401
- hide : function () {
402
- if (this.settings.modal && this.settings.expose) {
403
- this.un_expose();
404
- }
405
-
406
- if (!this.settings.modal) {
407
- $('.joyride-modal-bg').hide();
408
- }
409
-
410
- // Prevent scroll bouncing...wait to remove from layout
411
- this.settings.$current_tip.css('visibility', 'hidden');
412
- setTimeout($.proxy(function() {
413
- this.hide();
414
- this.css('visibility', 'visible');
415
- }, this.settings.$current_tip), 0);
416
- this.settings.post_step_callback(this.settings.$li.index(),
417
- this.settings.$current_tip);
418
- },
419
-
420
- set_li : function (init, is_prev) {
421
- if (init) {
422
- this.settings.$li = this.settings.$tip_content.eq(this.settings.start_offset);
423
- this.set_next_tip();
424
- this.settings.$current_tip = this.settings.$next_tip;
425
- } else {
426
- if (is_prev)
427
- this.settings.$li = this.settings.$li.prev();
428
- else
429
- this.settings.$li = this.settings.$li.next();
430
- this.set_next_tip();
431
- }
432
-
433
- this.set_target();
434
- },
435
-
436
- set_next_tip : function () {
437
- this.settings.$next_tip = $(".joyride-tip-guide").eq(this.settings.$li.index());
438
- this.settings.$next_tip.data('closed', '');
439
- },
440
-
441
- set_target : function () {
442
- var cl = this.settings.$li.attr(this.add_namespace('data-class')),
443
- id = this.settings.$li.attr(this.add_namespace('data-id')),
444
- $sel = function () {
445
- if (id) {
446
- return $(document.getElementById(id));
447
- } else if (cl) {
448
- return $('.' + cl).first();
449
- } else {
450
- return $('body');
451
- }
452
- };
453
-
454
- this.settings.$target = $sel();
455
- },
456
-
457
- scroll_to : function () {
458
- var window_half, tipOffset;
459
-
460
- window_half = $(window).height() / 2;
461
- tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.settings.$next_tip.outerHeight());
462
-
463
- if (tipOffset != 0) {
464
- $('html, body').stop().animate({
465
- scrollTop: tipOffset
466
- }, this.settings.scroll_speed, 'swing');
467
- }
468
- },
469
-
470
- paused : function () {
471
- return ($.inArray((this.settings.$li.index() + 1), this.settings.pause_after) === -1);
472
- },
473
-
474
- restart : function () {
475
- this.hide();
476
- this.settings.$li = undefined;
477
- this.show('init');
478
- },
479
-
480
- pos_default : function (init) {
481
- var $nub = this.settings.$next_tip.find('.joyride-nub'),
482
- nub_width = Math.ceil($nub.outerWidth() / 2),
483
- nub_height = Math.ceil($nub.outerHeight() / 2),
484
- toggle = init || false;
485
-
486
- // tip must not be "display: none" to calculate position
487
- if (toggle) {
488
- this.settings.$next_tip.css('visibility', 'hidden');
489
- this.settings.$next_tip.show();
490
- }
491
-
492
- if (!/body/i.test(this.settings.$target.selector)) {
493
- var topAdjustment = this.settings.tip_settings.tipAdjustmentY ? parseInt(this.settings.tip_settings.tipAdjustmentY) : 0,
494
- leftAdjustment = this.settings.tip_settings.tipAdjustmentX ? parseInt(this.settings.tip_settings.tipAdjustmentX) : 0;
495
-
496
- if (this.bottom()) {
497
- if (this.rtl) {
498
- this.settings.$next_tip.css({
499
- top: (this.settings.$target.offset().top + nub_height + this.settings.$target.outerHeight() + topAdjustment),
500
- left: this.settings.$target.offset().left + this.settings.$target.outerWidth() - this.settings.$next_tip.outerWidth() + leftAdjustment});
501
- } else {
502
- this.settings.$next_tip.css({
503
- top: (this.settings.$target.offset().top + nub_height + this.settings.$target.outerHeight() + topAdjustment),
504
- left: this.settings.$target.offset().left + leftAdjustment});
505
- }
506
-
507
- this.nub_position($nub, this.settings.tip_settings.nub_position, 'top');
508
-
509
- } else if (this.top()) {
510
- if (this.rtl) {
511
- this.settings.$next_tip.css({
512
- top: (this.settings.$target.offset().top - this.settings.$next_tip.outerHeight() - nub_height + topAdjustment),
513
- left: this.settings.$target.offset().left + this.settings.$target.outerWidth() - this.settings.$next_tip.outerWidth()});
514
- } else {
515
- this.settings.$next_tip.css({
516
- top: (this.settings.$target.offset().top - this.settings.$next_tip.outerHeight() - nub_height + topAdjustment),
517
- left: this.settings.$target.offset().left + leftAdjustment});
518
- }
519
-
520
- this.nub_position($nub, this.settings.tip_settings.nub_position, 'bottom');
521
-
522
- } else if (this.right()) {
523
-
524
- this.settings.$next_tip.css({
525
- top: this.settings.$target.offset().top + topAdjustment,
526
- left: (this.settings.$target.outerWidth() + this.settings.$target.offset().left + nub_width + leftAdjustment)});
527
-
528
- this.nub_position($nub, this.settings.tip_settings.nub_position, 'left');
529
-
530
- } else if (this.left()) {
531
-
532
- this.settings.$next_tip.css({
533
- top: this.settings.$target.offset().top + topAdjustment,
534
- left: (this.settings.$target.offset().left - this.settings.$next_tip.outerWidth() - nub_width + leftAdjustment)});
535
-
536
- this.nub_position($nub, this.settings.tip_settings.nub_position, 'right');
537
-
538
- }
539
-
540
- if (!this.visible(this.corners(this.settings.$next_tip)) && this.settings.attempts < this.settings.tip_settings.tip_location_pattern.length) {
541
-
542
- $nub.removeClass('bottom')
543
- .removeClass('top')
544
- .removeClass('right')
545
- .removeClass('left');
546
-
547
- this.settings.tip_settings.tip_location = this.settings.tip_settings.tip_location_pattern[this.settings.attempts];
548
-
549
- this.settings.attempts++;
550
-
551
- this.pos_default();
552
-
553
- }
554
-
555
- } else if (this.settings.$li.length) {
556
-
557
- this.pos_modal($nub);
558
-
559
- }
560
-
561
- if (toggle) {
562
- this.settings.$next_tip.hide();
563
- this.settings.$next_tip.css('visibility', 'visible');
564
- }
565
-
566
- },
567
-
568
- pos_phone : function (init) {
569
- var tip_height = this.settings.$next_tip.outerHeight(),
570
- tip_offset = this.settings.$next_tip.offset(),
571
- target_height = this.settings.$target.outerHeight(),
572
- $nub = $('.joyride-nub', this.settings.$next_tip),
573
- nub_height = Math.ceil($nub.outerHeight() / 2),
574
- toggle = init || false;
575
-
576
- $nub.removeClass('bottom')
577
- .removeClass('top')
578
- .removeClass('right')
579
- .removeClass('left');
580
-
581
- if (toggle) {
582
- this.settings.$next_tip.css('visibility', 'hidden');
583
- this.settings.$next_tip.show();
584
- }
585
-
586
- if (!/body/i.test(this.settings.$target.selector)) {
587
-
588
- if (this.top()) {
589
-
590
- this.settings.$next_tip.offset({top: this.settings.$target.offset().top - tip_height - nub_height});
591
- $nub.addClass('bottom');
592
-
593
- } else {
594
-
595
- this.settings.$next_tip.offset({top: this.settings.$target.offset().top + target_height + nub_height});
596
- $nub.addClass('top');
597
-
598
- }
599
-
600
- } else if (this.settings.$li.length) {
601
- this.pos_modal($nub);
602
- }
603
-
604
- if (toggle) {
605
- this.settings.$next_tip.hide();
606
- this.settings.$next_tip.css('visibility', 'visible');
607
- }
608
- },
609
-
610
- pos_modal : function ($nub) {
611
- this.center();
612
- $nub.hide();
613
-
614
- this.show_modal();
615
- },
616
-
617
- show_modal : function () {
618
- if (!this.settings.$next_tip.data('closed')) {
619
- var joyridemodalbg = $('.joyride-modal-bg');
620
- if (joyridemodalbg.length < 1) {
621
- $('body').append(this.settings.template.modal).show();
622
- }
623
-
624
- if (/pop/i.test(this.settings.tip_animation)) {
625
- joyridemodalbg.show();
626
- } else {
627
- joyridemodalbg.fadeIn(this.settings.tip_animation_fade_speed);
628
- }
629
- }
630
- },
631
-
632
- expose : function () {
633
- var expose,
634
- exposeCover,
635
- el,
636
- origCSS,
637
- origClasses,
638
- randId = 'expose-' + this.random_str(6);
639
-
640
- if (arguments.length > 0 && arguments[0] instanceof $) {
641
- el = arguments[0];
642
- } else if(this.settings.$target && !/body/i.test(this.settings.$target.selector)){
643
- el = this.settings.$target;
644
- } else {
645
- return false;
646
- }
647
-
648
- if(el.length < 1){
649
- if(window.console){
650
- console.error('element not valid', el);
651
- }
652
- return false;
653
- }
654
-
655
- expose = $(this.settings.template.expose);
656
- this.settings.$body.append(expose);
657
- expose.css({
658
- top: el.offset().top,
659
- left: el.offset().left,
660
- width: el.outerWidth(true),
661
- height: el.outerHeight(true)
662
- });
663
-
664
- exposeCover = $(this.settings.template.expose_cover);
665
-
666
- origCSS = {
667
- zIndex: el.css('z-index'),
668
- position: el.css('position')
669
- };
670
-
671
- origClasses = el.attr('class') == null ? '' : el.attr('class');
672
-
673
- el.css('z-index',parseInt(expose.css('z-index'))+1);
674
-
675
- if (origCSS.position == 'static') {
676
- el.css('position','relative');
677
- }
678
-
679
- el.data('expose-css',origCSS);
680
- el.data('orig-class', origClasses);
681
- el.attr('class', origClasses + ' ' + this.settings.expose_add_class);
682
-
683
- exposeCover.css({
684
- top: el.offset().top,
685
- left: el.offset().left,
686
- width: el.outerWidth(true),
687
- height: el.outerHeight(true)
688
- });
689
-
690
- if (this.settings.modal) this.show_modal();
691
-
692
- this.settings.$body.append(exposeCover);
693
- expose.addClass(randId);
694
- exposeCover.addClass(randId);
695
- el.data('expose', randId);
696
- this.settings.post_expose_callback(this.settings.$li.index(), this.settings.$next_tip, el);
697
- this.add_exposed(el);
698
- },
699
-
700
- un_expose : function () {
701
- var exposeId,
702
- el,
703
- expose ,
704
- origCSS,
705
- origClasses,
706
- clearAll = false;
707
-
708
- if (arguments.length > 0 && arguments[0] instanceof $) {
709
- el = arguments[0];
710
- } else if(this.settings.$target && !/body/i.test(this.settings.$target.selector)){
711
- el = this.settings.$target;
712
- } else {
713
- return false;
714
- }
715
-
716
- if(el.length < 1){
717
- if (window.console) {
718
- console.error('element not valid', el);
719
- }
720
- return false;
721
- }
722
-
723
- exposeId = el.data('expose');
724
- expose = $('.' + exposeId);
725
-
726
- if (arguments.length > 1) {
727
- clearAll = arguments[1];
728
- }
729
-
730
- if (clearAll === true) {
731
- $('.joyride-expose-wrapper,.joyride-expose-cover').remove();
732
- } else {
733
- expose.remove();
734
- }
735
-
736
- origCSS = el.data('expose-css');
737
-
738
- if (origCSS.zIndex == 'auto') {
739
- el.css('z-index', '');
740
- } else {
741
- el.css('z-index', origCSS.zIndex);
742
- }
743
-
744
- if (origCSS.position != el.css('position')) {
745
- if(origCSS.position == 'static') {// this is default, no need to set it.
746
- el.css('position', '');
747
- } else {
748
- el.css('position', origCSS.position);
749
- }
750
- }
751
-
752
- origClasses = el.data('orig-class');
753
- el.attr('class', origClasses);
754
- el.removeData('orig-classes');
755
-
756
- el.removeData('expose');
757
- el.removeData('expose-z-index');
758
- this.remove_exposed(el);
759
- },
760
-
761
- add_exposed: function(el){
762
- this.settings.exposed = this.settings.exposed || [];
763
- if (el instanceof $ || typeof el === 'object') {
764
- this.settings.exposed.push(el[0]);
765
- } else if (typeof el == 'string') {
766
- this.settings.exposed.push(el);
767
- }
768
- },
769
-
770
- remove_exposed: function(el){
771
- var search, i;
772
- if (el instanceof $) {
773
- search = el[0]
774
- } else if (typeof el == 'string'){
775
- search = el;
776
- }
777
-
778
- this.settings.exposed = this.settings.exposed || [];
779
- i = this.settings.exposed.length;
780
-
781
- while (i--) {
782
- if (this.settings.exposed[i] == search) {
783
- this.settings.exposed.splice(i, 1);
784
- return;
785
- }
786
- }
787
- },
788
-
789
- center : function () {
790
- var $w = $(window);
791
-
792
- this.settings.$next_tip.css({
793
- top : ((($w.height() - this.settings.$next_tip.outerHeight()) / 2) + $w.scrollTop()),
794
- left : ((($w.width() - this.settings.$next_tip.outerWidth()) / 2) + $w.scrollLeft())
795
- });
796
-
797
- return true;
798
- },
799
-
800
- bottom : function () {
801
- return /bottom/i.test(this.settings.tip_settings.tip_location);
802
- },
803
-
804
- top : function () {
805
- return /top/i.test(this.settings.tip_settings.tip_location);
806
- },
807
-
808
- right : function () {
809
- return /right/i.test(this.settings.tip_settings.tip_location);
810
- },
811
-
812
- left : function () {
813
- return /left/i.test(this.settings.tip_settings.tip_location);
814
- },
815
-
816
- corners : function (el) {
817
- var w = $(window),
818
- window_half = w.height() / 2,
819
- //using this to calculate since scroll may not have finished yet.
820
- tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.settings.$next_tip.outerHeight()),
821
- right = w.width() + w.scrollLeft(),
822
- offsetBottom = w.height() + tipOffset,
823
- bottom = w.height() + w.scrollTop(),
824
- top = w.scrollTop();
825
-
826
- if (tipOffset < top) {
827
- if (tipOffset < 0) {
828
- top = 0;
829
- } else {
830
- top = tipOffset;
831
- }
832
- }
833
-
834
- if (offsetBottom > bottom) {
835
- bottom = offsetBottom;
836
- }
837
-
838
- return [
839
- el.offset().top < top,
840
- right < el.offset().left + el.outerWidth(),
841
- bottom < el.offset().top + el.outerHeight(),
842
- w.scrollLeft() > el.offset().left
843
- ];
844
- },
845
-
846
- visible : function (hidden_corners) {
847
- var i = hidden_corners.length;
848
-
849
- while (i--) {
850
- if (hidden_corners[i]) return false;
851
- }
852
-
853
- return true;
854
- },
855
-
856
- nub_position : function (nub, pos, def) {
857
- if (pos === 'auto') {
858
- nub.addClass(def);
859
- } else {
860
- nub.addClass(pos);
861
- }
862
- },
863
-
864
- startTimer : function () {
865
- if (this.settings.$li.length) {
866
- this.settings.automate = setTimeout(function () {
867
- this.hide();
868
- this.show();
869
- this.startTimer();
870
- }.bind(this), this.settings.timer);
871
- } else {
872
- clearTimeout(this.settings.automate);
873
- }
874
- },
875
-
876
- end : function (abort) {
877
- if (this.settings.cookie_monster) {
878
- $.cookie(this.settings.cookie_name, 'ridden', { expires: this.settings.cookie_expires, domain: this.settings.cookie_domain });
879
- }
880
-
881
- if (this.settings.timer > 0) {
882
- clearTimeout(this.settings.automate);
883
- }
884
-
885
- if (this.settings.modal && this.settings.expose) {
886
- this.un_expose();
887
- }
888
-
889
- // Unplug keystrokes listener
890
- $(this.scope).off('keyup.joyride')
891
-
892
- this.settings.$next_tip.data('closed', true);
893
- this.settings.riding = false;
894
-
895
- $('.joyride-modal-bg').hide();
896
- this.settings.$current_tip.hide();
897
-
898
- if (typeof abort === 'undefined' || abort === false) {
899
- this.settings.post_step_callback(this.settings.$li.index(), this.settings.$current_tip);
900
- this.settings.post_ride_callback(this.settings.$li.index(), this.settings.$current_tip);
901
- }
902
-
903
- $('.joyride-tip-guide').remove();
904
- },
905
-
906
- off : function () {
907
- $(this.scope).off('.joyride');
908
- $(window).off('.joyride');
909
- $('.joyride-close-tip, .joyride-next-tip, .joyride-modal-bg').off('.joyride');
910
- $('.joyride-tip-guide, .joyride-modal-bg').remove();
911
- clearTimeout(this.settings.automate);
912
- this.settings = {};
913
- },
914
-
915
- reflow : function () {}
916
- };
917
- }(jQuery, window, window.document));