Hi. I really like your plugin, and I will definitely buy some addons. I’ve been trying to achieve something, but without success.
I’ve built an overlay element (.my-hidden-bewertungen) for the entire screen size (something like lightbox). This element opens on button click with the class: .my-bewertungen-button. Inside the overlay element, there is a review form shortcode. I can close this element with the close button: .close-bewertungen. Everything is working fine, but I would like to have it automatically close with a delay after the review is sent. This is my current java script code:
(function() {
var buttons = document.querySelectorAll('.my-bewertungen-button');
var elements = document.querySelectorAll('.my-hidden-bewertungen');
var backButton = document.querySelectorAll('.close-bewertungen');
var visibleIndex = null;
for (var i = 0; i < buttons.length; i++) {
(function(i) {
var button = buttons[i];
var element = elements[i];
var backBtn = backButton[i];
button.addEventListener('click', function(event) {
event.preventDefault();
// Überprüfe, ob ein Element bereits sichtbar ist
if (visibleIndex !== null) {
elements[visibleIndex].style.opacity = 0; // Setze die Deckkraft des sichtbaren Elements auf 0
}
if (element.style.display === 'block') {
element.style.display = 'none';
visibleIndex = null; // Setze den Index des sichtbaren Elements auf null
} else {
element.style.display = 'block';
visibleIndex = i; // Setze den Index des sichtbaren Elements auf den aktuellen Index
// Füge die Einblendanimation hinzu
element.style.opacity = 0;
setTimeout(function() {
element.style.opacity = 1;
}, 100); // Ändern Sie die Zeit nach Bedarf, um die Geschwindigkeit der Animation anzupassen
}
});
backBtn.addEventListener('click', function(event) {
event.preventDefault();
// Füge die Ausblendanimation hinzu
element.style.opacity = 0;
setTimeout(function() {
element.style.display = 'none';
visibleIndex = null; // Setze den Index des sichtbaren Elements auf null
}, 500); // Ändern Sie die Zeit nach Bedarf, um die Geschwindigkeit der Animation anzupassen
});
})(i);
}
})();
I’ve tried with a hook:
add_action('site-reviews/review/created', function ($review, $command) {
sleep(1.5); // Verzögerung in Sekunden anpassen
echo '<script type="text/javascript">
var element = document.querySelector(".my-hidden-bewertungen");
element.style.opacity = 0;
setTimeout(function() {
element.style.display = "none";
}, 500);
</script>';
}, 10, 2);
but I have a spinning wheel when sending a review. I’ve tried many options with Chat GPT, but without success.
Maybe you can give me some help?