Pomozte nám zlepšit náš e-shop
<script>
(function() {
// Kód popupu tady (stejný jako jsi měla dříve)
// Vytvoření popup elementu a stylů
const style = document.createElement('style');
style.textContent = `
#exitPopup {
display: none;
position: fixed;
z-index: 9999;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 90%;
max-width: 420px;
background: white;
border: 2px solid #ccc;
border-radius: 12px;
box-shadow: 0 0 20px rgba(0,0,0,0.3);
padding: 20px;
font-family: sans-serif;
}
#exitPopup h3 {
margin-top: 0;
}
.exit-popup-option {
margin-bottom: 10px;
}
#exitPopup button {
background: #111;
color: white;
border: none;
padding: 10px 16px;
border-radius: 8px;
cursor: pointer;
margin-top: 10px;
}
#exitPopup button:hover {
background: #444;
}
`;
document.head.appendChild(style);
// Vytvoření popup HTML
const popup = document.createElement('div');
popup.id = 'exitPopup';
popup.innerHTML = `
<h3>Pomozte nám zlepšit náš obchod – co vám u nás chybělo?</h3>
<form id="exitForm">
<label class="exit-popup-option"><input type="checkbox" name="reason" value="Nenašla jsem svou velikost"> Nenašla jsem svou velikost</label><br>
<label class="exit-popup-option"><input type="checkbox" name="reason" value="Zboží není skladem"> Zboží není skladem</label><br>
<label class="exit-popup-option"><input type="checkbox" name="reason" value="Cena je příliš vysoká"> Cena je příliš vysoká</label><br>
<label class="exit-popup-option"><input type="checkbox" name="reason" value="Styl mě nezaujal"> Styl mě nezaujal</label><br>
<label class="exit-popup-option"><input type="checkbox" name="reason" value="Jen se dívám"> Jen se dívám / prohlížím</label><br>
<label class="exit-popup-option"><input type="checkbox" name="reason" value="Něco jiného"> Něco jiného</label><br>
<button type="submit">Odeslat</button>
</form>
`;
document.body.appendChild(popup);
const FORM_ACTION_URL = 'https://docs.google.com/forms/d/e/1FAIpQLSdeuqQdhVQTuu-Zokzd8pBlyJegL7GmSsgHMua1DHmY8iaaDw/formResponse';
const ENTRY_ID = 'entry.1002707734';
let popupShown = localStorage.getItem("exitPopupShown");
const currentUrl = window.location.href;
const onCheckout = currentUrl.includes('objednavka') || currentUrl.includes('kosik');
if (!popupShown && !onCheckout) {
document.addEventListener("mouseleave", function (e) {
if (e.clientY < 10) {
showExitPopup();
}
});
let lastScrollTop = 0;
window.addEventListener("scroll", function () {
const st = window.pageYOffset || document.documentElement.scrollTop;
if (!popupShown && !onCheckout && window.innerWidth <= 768) {
if (st < lastScrollTop && st < 100) {
showExitPopup();
}
}
lastScrollTop = st <= 0 ? 0 : st;
});
}
function showExitPopup() {
popup.style.display = "block";
localStorage.setItem("exitPopupShown", "true");
}
document.getElementById("exitForm").addEventListener("submit", function (e) {
e.preventDefault();
const selected = Array.from(document.querySelectorAll('input[name="reason"]:checked')).map(el => el.value);
if (selected.length > 0) {
const formData = new FormData();
formData.append(ENTRY_ID, selected.join(', '));
fetch(FORM_ACTION_URL, {
method: 'POST',
mode: 'no-cors',
body: formData
}).then(() => {
popup.style.display = "none";
alert("Děkujeme za zpětnou vazbu ❤️");
});
} else {
alert("Prosím vyberte alespoň jednu možnost.");
}
});
})();
</script>