sigit_design/assets/js/popups.js

42 lines
1.3 KiB
JavaScript

// Function to show the popup
function showPopup() {
var popupLogin = document.getElementById('popupLogin');
if (popupLogin) {
popupLogin.style.display = 'flex';
document.body.style.overflow = 'hidden';
}
}
// Function to hide the popup
function hidePopup() {
var popupLogin = document.getElementById('popupLogin');
var secMainNavMobileShow = document.querySelector('.secMainNavMobileShow');
if (popupLogin) {
popupLogin.style.display = 'none';
// Check if .secMainNavMobileShow is present before enabling scroll
if (!secMainNavMobileShow) {
document.body.style.overflow = '';
}
}
}
// Add event listeners to login buttons
for (let i = 0; i <= 10; i++) { // Assuming you have up to 10 login buttons
let btn = document.getElementById('loginBtn-' + i);
if (btn) {
btn.addEventListener('click', showPopup);
}
}
// Also add an event listener for the base login button
let baseLoginBtn = document.getElementById('loginBtn');
if (baseLoginBtn) {
baseLoginBtn.addEventListener('click', showPopup);
}
// Add event listener to the popup close button
let closeButton = document.querySelector('.popupMainInsideWrapperBoxTopBtn');
if (closeButton) {
closeButton.addEventListener('click', hidePopup);
}