design/public/assets/js/popups.js

32 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-11-16 13:46:05 +00:00
document.addEventListener('DOMContentLoaded', function() {
function setupPopup(triggerId, popupId) {
const trigger = document.getElementById(triggerId);
const popup = document.getElementById(popupId);
if (trigger && popup) {
trigger.addEventListener('click', function() {
popup.style.display = 'flex';
document.body.style.overflow = 'hidden';
});
}
}
// Setup popups
setupPopup('storePageInfoPopupTrigger', 'storePageInfoPopup');
setupPopup('mobileMenuPopupTrigger', 'mobileMenuPopup');
setupPopup('loginRegisterPopupTrigger', 'loginRegisterPopup');
setupPopup('loginRegisterMobilePopupTrigger', 'loginRegisterPopup');
setupPopup('userPageInfoPopupTrigger', 'userPageInfoPopup');// Add more as needed
// Close popups
document.querySelectorAll('.popupMainSecInsideBoxTopBtn').forEach(function(button) {
button.addEventListener('click', function() {
const popup = document.querySelector('.popupMain[style*="display: flex"]');
if (popup) {
popup.style.display = 'none';
document.body.style.overflow = 'auto';
}
});
});
});