fix: rebuild mockup with Windows-safe filenames and correct CSS paths
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var modal = document.getElementById('gated-modal');
|
||||
if (!modal) return;
|
||||
|
||||
var overlay = modal.querySelector('.gated-modal__overlay');
|
||||
var closeBtn = modal.querySelector('.gated-modal__close');
|
||||
|
||||
// Open modal on [data-gated] click
|
||||
document.addEventListener('click', function (e) {
|
||||
var trigger = e.target.closest('[data-gated]');
|
||||
if (!trigger) return;
|
||||
e.preventDefault();
|
||||
var materialId = trigger.dataset.gated;
|
||||
var downloadUrl = trigger.dataset.downloadUrl;
|
||||
// Set hidden field + store download URL
|
||||
var hiddenField = modal.querySelector('input[name="material-id"]');
|
||||
if (hiddenField) hiddenField.value = materialId;
|
||||
modal.dataset.downloadUrl = downloadUrl || '';
|
||||
modal.classList.add('gated-modal--open');
|
||||
document.body.style.overflow = 'hidden';
|
||||
});
|
||||
|
||||
function closeModal() {
|
||||
modal.classList.remove('gated-modal--open');
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
if (closeBtn) closeBtn.addEventListener('click', closeModal);
|
||||
if (overlay) overlay.addEventListener('click', closeModal);
|
||||
|
||||
// After CF7 successful submit — trigger download
|
||||
document.addEventListener('wpcf7mailsent', function () {
|
||||
if (modal.classList.contains('gated-modal--open') && modal.dataset.downloadUrl) {
|
||||
window.open(modal.dataset.downloadUrl, '_blank');
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user