Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

extended-ui-tour.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /**
  2. * Tour
  3. */
  4. 'use strict';
  5. (function () {
  6. const startBtn = document.querySelector('#shepherd-example');
  7. function setupTour(tour) {
  8. const backBtnClass = 'btn btn-sm btn-label-secondary md-btn-flat',
  9. nextBtnClass = 'btn btn-sm btn-primary btn-next';
  10. tour.addStep({
  11. title: 'Navbar',
  12. text: 'This is your navbar',
  13. attachTo: { element: '.navbar', on: 'bottom' },
  14. buttons: [
  15. {
  16. action: tour.cancel,
  17. classes: backBtnClass,
  18. text: 'Skip'
  19. },
  20. {
  21. text: 'Next',
  22. classes: nextBtnClass,
  23. action: tour.next
  24. }
  25. ]
  26. });
  27. tour.addStep({
  28. title: 'Card',
  29. text: 'This is a card',
  30. attachTo: { element: '.tour-card', on: 'top' },
  31. buttons: [
  32. {
  33. text: 'Skip',
  34. classes: backBtnClass,
  35. action: tour.cancel
  36. },
  37. {
  38. text: 'Back',
  39. classes: backBtnClass,
  40. action: tour.back
  41. },
  42. {
  43. text: 'Next',
  44. classes: nextBtnClass,
  45. action: tour.next
  46. }
  47. ]
  48. });
  49. tour.addStep({
  50. title: 'Footer',
  51. text: 'This is the Footer',
  52. attachTo: { element: '.footer', on: 'top' },
  53. buttons: [
  54. {
  55. text: 'Skip',
  56. classes: backBtnClass,
  57. action: tour.cancel
  58. },
  59. {
  60. text: 'Back',
  61. classes: backBtnClass,
  62. action: tour.back
  63. },
  64. {
  65. text: 'Next',
  66. classes: nextBtnClass,
  67. action: tour.next
  68. }
  69. ]
  70. });
  71. tour.addStep({
  72. title: 'Upgrade',
  73. text: 'Click here to upgrade plan',
  74. attachTo: { element: '.footer-link', on: 'top' },
  75. buttons: [
  76. {
  77. text: 'Back',
  78. classes: backBtnClass,
  79. action: tour.back
  80. },
  81. {
  82. text: 'Finish',
  83. classes: nextBtnClass,
  84. action: tour.cancel
  85. }
  86. ]
  87. });
  88. return tour;
  89. }
  90. if (startBtn) {
  91. // On start tour button click
  92. startBtn.onclick = function () {
  93. const tourVar = new Shepherd.Tour({
  94. defaultStepOptions: {
  95. scrollTo: false,
  96. cancelIcon: {
  97. enabled: true
  98. }
  99. },
  100. useModalOverlay: true
  101. });
  102. setupTour(tourVar).start();
  103. };
  104. }
  105. // ! Documentation Tour only
  106. const startBtnDocs = document.querySelector('#shepherd-docs-example');
  107. function setupTourDocs(tour) {
  108. const backBtnClass = 'btn btn-sm btn-label-secondary md-btn-flat',
  109. nextBtnClass = 'btn btn-sm btn-primary btn-next';
  110. tour.addStep({
  111. title: 'Navbar',
  112. text: 'This is your navbar',
  113. attachTo: { element: '.navbar', on: 'bottom' },
  114. buttons: [
  115. {
  116. action: tour.cancel,
  117. classes: backBtnClass,
  118. text: 'Skip'
  119. },
  120. {
  121. text: 'Next',
  122. classes: nextBtnClass,
  123. action: tour.next
  124. }
  125. ]
  126. });
  127. tour.addStep({
  128. title: 'Footer',
  129. text: 'This is the Footer',
  130. attachTo: { element: '.footer', on: 'top' },
  131. buttons: [
  132. {
  133. text: 'Skip',
  134. classes: backBtnClass,
  135. action: tour.cancel
  136. },
  137. {
  138. text: 'Back',
  139. classes: backBtnClass,
  140. action: tour.back
  141. },
  142. {
  143. text: 'Next',
  144. classes: nextBtnClass,
  145. action: tour.next
  146. }
  147. ]
  148. });
  149. tour.addStep({
  150. title: 'Social Link',
  151. text: 'Click here share on social media',
  152. attachTo: { element: '.footer-link', on: 'top' },
  153. buttons: [
  154. {
  155. text: 'Back',
  156. classes: backBtnClass,
  157. action: tour.back
  158. },
  159. {
  160. text: 'Finish',
  161. classes: nextBtnClass,
  162. action: tour.cancel
  163. }
  164. ]
  165. });
  166. return tour;
  167. }
  168. if (startBtnDocs) {
  169. // On start tour button click
  170. startBtnDocs.onclick = function () {
  171. const tourDocsVar = new Shepherd.Tour({
  172. defaultStepOptions: {
  173. scrollTo: false,
  174. cancelIcon: {
  175. enabled: true
  176. }
  177. },
  178. useModalOverlay: true
  179. });
  180. setupTourDocs(tourDocsVar).start();
  181. };
  182. }
  183. })();