PluginProbe
Property Hive / 2.2.3
Property Hive v2.2.3
2.4.0 2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 All 262 releases
propertyhive / assets / js / tours / tour.js

tour.js in Property Hive 2.2.3, at assets/js/tours/tour.js

61 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 window.addEventListener('load', function ()
2 {
3 const tours = tour_plugin.tours;
4 const driver = window.driver.js.driver;
5
6 function revert_to_first_tab(activeElement, activeStep, options) {
7 jQuery('#propertyhive_metabox_tabs a').eq(0).trigger('click');
8 }
9
10 function revert_to_third_tab(activeElement, activeStep, options) {
11 jQuery('#propertyhive_metabox_tabs a').eq(2).trigger('click');
12 }
13
14 // Function to resolve string to function
15 function getCallbackFunction(callbackName) {
16 const callbacks = {
17 revert_to_first_tab,
18 revert_to_third_tab
19 };
20
21 return callbacks[callbackName] || null;
22 }
23
24 const tourId = 'add-property';
25
26 if (!tours || !tours[tourId]) {
27 console.log('Tour not found');
28 return;
29 }
30
31 const tourSteps = tours[tourId].map((step) => ({
32 ...step,
33 popover: {
34 ...step.popover,
35 onNextClick: step.popover.onNextClick
36 ? (activeElement, activeStep, options) =>
37 getCallbackFunction(step.popover.onNextClick)?.(
38 activeElement,
39 activeStep,
40 { ...options, driver: driverObj } // Pass driverObj explicitly
41 ) || driverObj.moveNext()
42 : () => driverObj.moveNext(), // Default behavior
43 onPrevClick: step.popover.onPrevClick
44 ? (activeElement, activeStep, options) =>
45 getCallbackFunction(step.popover.onPrevClick)?.(
46 activeElement,
47 activeStep,
48 { ...options, driver: driverObj }
49 ) || driverObj.movePrevious()
50 : () => driverObj.movePrevious(), // Default behavior
51 },
52 }));
53
54 const driverObj = driver({
55 showProgress: true,
56 steps: tourSteps,
57 });
58
59 setTimeout(() => { driverObj.drive(0) }, 250);
60 });
61