Button actions
Browse files- assets/scripts/src/sholo.js +45 -1
assets/scripts/src/sholo.js
CHANGED
@@ -69,12 +69,56 @@ export default class Sholo {
|
|
69 |
}
|
70 |
|
71 |
const nextClicked = e.target.classList.contains('sholo-next-btn');
|
|
|
|
|
|
|
72 |
if (nextClicked) {
|
73 |
-
this.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
this.overlay.highlight(this.steps[this.currentStep]);
|
|
|
|
|
75 |
}
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
hasHighlightedElement() {
|
79 |
const highlightedElement = this.overlay.getHighlightedElement();
|
80 |
return highlightedElement && highlightedElement.node;
|
|
|
69 |
}
|
70 |
|
71 |
const nextClicked = e.target.classList.contains('sholo-next-btn');
|
72 |
+
const prevClicked = e.target.classList.contains('sholo-prev-btn');
|
73 |
+
const closeClicked = e.target.classList.contains('sholo-close-btn');
|
74 |
+
|
75 |
if (nextClicked) {
|
76 |
+
this.moveNext();
|
77 |
+
} else if (prevClicked) {
|
78 |
+
this.movePrevious();
|
79 |
+
} else if (closeClicked) {
|
80 |
+
this.reset();
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Moves to the previous step if possible
|
86 |
+
* otherwise resets the overlay
|
87 |
+
*/
|
88 |
+
movePrevious() {
|
89 |
+
this.currentStep -= 1;
|
90 |
+
if (this.steps[this.currentStep]) {
|
91 |
this.overlay.highlight(this.steps[this.currentStep]);
|
92 |
+
} else {
|
93 |
+
this.reset();
|
94 |
}
|
95 |
}
|
96 |
|
97 |
+
/**
|
98 |
+
* Moves to the next step if possible
|
99 |
+
* otherwise resets the overlay
|
100 |
+
*/
|
101 |
+
moveNext() {
|
102 |
+
this.currentStep += 1;
|
103 |
+
if (this.steps[this.currentStep]) {
|
104 |
+
this.overlay.highlight(this.steps[this.currentStep]);
|
105 |
+
} else {
|
106 |
+
this.reset();
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Resets the steps if any and clears the overlay
|
112 |
+
*/
|
113 |
+
reset() {
|
114 |
+
this.currentStep = 0;
|
115 |
+
this.overlay.clear();
|
116 |
+
}
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Checks if there is any highlighted element or not
|
120 |
+
* @returns {boolean}
|
121 |
+
*/
|
122 |
hasHighlightedElement() {
|
123 |
const highlightedElement = this.overlay.getHighlightedElement();
|
124 |
return highlightedElement && highlightedElement.node;
|