tour.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <script defer language="javascript">
  2. __js_obj__ = new Shepherd.Tour({
  3. useModalOverlay: __tour_overlay__,
  4. defaultStepOptions: {
  5. classes: 'bx-def-z-index-modal',
  6. showCancelLink: true,
  7. scrollTo: {behavior: "smooth", block: "center"}
  8. }
  9. })
  10. <bx_if:not_preview>
  11. Shepherd.on('cancel', function () {
  12. $.cookie('bx-help-tours-seen-__tour_id__', 1, {expires: 9999});
  13. $.post('__finish_callback_url__', {tour: __tour_id__});
  14. })
  15. </bx_if:not_preview>
  16. $(document).ready(function() {
  17. var bx_help_tour_steps = __steps__;
  18. var bx_help_tour_steps_filtered = [];
  19. for (i in bx_help_tour_steps) {
  20. if (typeof bx_help_tour_steps[i].attachTo !== 'undefined' && bx_help_tour_steps[i].attachTo.element.length) {
  21. //do not show help items for missing elements.
  22. if (!$(bx_help_tour_steps[i].attachTo.element).length) continue;
  23. // if this is a help for a field that is sitting inside a collapsed section then
  24. // we are `uncollapsing` it on this page load
  25. if (!$(bx_help_tour_steps[i].attachTo.element).is(':visible')) {
  26. var sect = $(bx_help_tour_steps[i].attachTo.element).closest('.bx-form-section-hidden');
  27. if (sect.length && sect.hasClass('bx-form-section-hidden')) {
  28. $(sect).children('legend').trigger('click');
  29. sect.removeClass('bx-form-collapsed');
  30. sect.removeClass('bx-form-section-hidden');
  31. }
  32. }
  33. //do not process hidden elements
  34. if (!$(bx_help_tour_steps[i].attachTo.element).is(':visible')) continue;
  35. }
  36. bx_help_tour_steps_filtered.push(bx_help_tour_steps[i]);
  37. }
  38. bx_help_tour_steps = bx_help_tour_steps_filtered;
  39. if (bx_help_tour_steps_filtered) {
  40. var bx_help_tour_steps_active = 0;
  41. for (i in bx_help_tour_steps) {
  42. var aBtns = [];
  43. if (i != (bx_help_tour_steps.length - 1)) {
  44. aBtns.push({
  45. text: '<bx_text_js:_sys_exit />',
  46. action: __js_obj__.cancel,
  47. classes: 'shepherd-button-secondary'
  48. });
  49. aBtns.push({
  50. text: '<bx_text_js:_sys_next />',
  51. action: __js_obj__.next,
  52. classes: 'shepherd-button-primary'
  53. });
  54. } else {
  55. aBtns.push({
  56. text: '<bx_text_js:_sys_done />',
  57. action: __js_obj__.cancel,
  58. classes: 'shepherd-button-primary'
  59. });
  60. }
  61. bx_help_tour_steps[i].buttons = aBtns;
  62. __js_obj__.addStep(bx_help_tour_steps[i]);
  63. bx_help_tour_steps_active++;
  64. }
  65. if (bx_help_tour_steps_active) __js_obj__.start();
  66. }
  67. });
  68. </script>