| 1 |
(function ($) { |
| 2 |
$( function () { |
| 3 |
|
| 4 |
// if Shepherd is undefined, exit. |
| 5 |
if ( ! window.Shepherd ) { |
| 6 |
return; |
| 7 |
} |
| 8 |
|
| 9 |
var button_classes = 'button button-primary'; |
| 10 |
var plugins_page_tour = window.wpbc_plugins_page_tour = new Shepherd.Tour(); |
| 11 |
var main_tour = window.wpbc_main_tour = new Shepherd.Tour(); |
| 12 |
|
| 13 |
// Set up the defaults for each step |
| 14 |
main_tour.options.defaults = plugins_page_tour.options.defaults = { |
| 15 |
classes: 'wpbc_tour_theme202408 wpbc_tour_main', |
| 16 |
showCancelLink: true, |
| 17 |
scrollTo: false, |
| 18 |
tetherOptions: { |
| 19 |
constraints: [ |
| 20 |
{ |
| 21 |
to: 'scrollParent', |
| 22 |
attachment: 'together', |
| 23 |
pin: false |
| 24 |
} |
| 25 |
] |
| 26 |
} |
| 27 |
}; |
| 28 |
|
| 29 |
/* |
| 30 |
Plugins page |
| 31 |
*/ |
| 32 |
|
| 33 |
main_tour.addStep( 'intro', { |
| 34 |
title: wpbc_tour_i18n.plugins_page.title, |
| 35 |
text: wpbc_tour_i18n.plugins_page.text, |
| 36 |
attachTo: '.wpbc_plugins_links__start_tour top', |
| 37 |
buttons: [ |
| 38 |
{ |
| 39 |
classes: button_classes, |
| 40 |
text: wpbc_tour_i18n.plugins_page.button.text, |
| 41 |
action: function() { |
| 42 |
window.location = wpbc_tour_i18n.plugins_page.button.url; |
| 43 |
} |
| 44 |
} |
| 45 |
], |
| 46 |
tetherOptions: { |
| 47 |
constraints: [ |
| 48 |
{ |
| 49 |
to: 'scrollParent', |
| 50 |
attachment: 'together', |
| 51 |
pin: false |
| 52 |
} |
| 53 |
], |
| 54 |
offset: '20px 0' |
| 55 |
}, |
| 56 |
when: { |
| 57 |
show: function() { |
| 58 |
$('body').addClass('plugins_page_highlight_wpbc'); |
| 59 |
var popup = $(this.el); |
| 60 |
var target = $(this.tether.target); |
| 61 |
$('body, html').animate({ |
| 62 |
scrollTop: popup.offset().top - 50 |
| 63 |
}, 500, function() { |
| 64 |
window.scrollTo(0, popup.offset().top - 50); |
| 65 |
}); |
| 66 |
}, |
| 67 |
hide: function() { |
| 68 |
$('body').removeClass('plugins_page_highlight_wpbc'); |
| 69 |
} |
| 70 |
} |
| 71 |
}); |
| 72 |
|
| 73 |
|
| 74 |
/* |
| 75 |
Main Tour steps |
| 76 |
*/ |
| 77 |
|
| 78 |
// 1. Your first backup |
| 79 |
main_tour.addStep( 'main_tour_start', { |
| 80 |
title: wpbc_tour_i18n.setup_page.title, |
| 81 |
text: wpbc_tour_i18n.setup_page.text, |
| 82 |
//attachTo: '.wpbc_page_top__wizard_button_content bottom', |
| 83 |
attachTo: { element: jQuery( '#toplevel_page_wpbc ul li:nth-last-child(2)').get(0), on: 'right'}, |
| 84 |
buttons: [ |
| 85 |
{ |
| 86 |
classes: 'wpbc_tour_end', |
| 87 |
text: wpbc_tour_i18n.button_end_tour.text, |
| 88 |
action: main_tour.cancel |
| 89 |
}, |
| 90 |
{ |
| 91 |
classes: button_classes, |
| 92 |
text: wpbc_tour_i18n.button_next.text, |
| 93 |
action: function() { |
| 94 |
//jQuery('.wpbc_page_top__wizard_button_content .button').trigger('click'); |
| 95 |
jQuery( '#toplevel_page_wpbc ul li:nth-last-child(2) a').get(0).click(); |
| 96 |
} |
| 97 |
} |
| 98 |
], |
| 99 |
tetherOptions: { |
| 100 |
constraints: [ |
| 101 |
{ |
| 102 |
to: 'window', |
| 103 |
attachment: 'together' |
| 104 |
} |
| 105 |
], |
| 106 |
offset: '0 0' |
| 107 |
} |
| 108 |
}); |
| 109 |
|
| 110 |
}); |
| 111 |
|
| 112 |
})(jQuery); |
| 113 |
|
| 114 |
jQuery(document).ready(function(){ |
| 115 |
|
| 116 |
setTimeout(function(){ |
| 117 |
if (jQuery('.wpbc_plugins_links__start_tour').length){ |
| 118 |
wpbc_main_tour.start(); |
| 119 |
} |
| 120 |
if (jQuery('.wpbc_page_top__wizard_button_content').length){ |
| 121 |
wpbc_main_tour.show('main_tour_start'); |
| 122 |
} |
| 123 |
},1000) |
| 124 |
}); |
| 125 |
|