/*! * weoverlayimg 4.0.20 * * @license GPLv3 for open source use only * or weoverlayimg Commercial License for commercial use */ function openModalWithImage(src) { const modal = document.querySelector('.js-we-overlayimg-modal'); const modalImg = modal.querySelector('.js-we-overlayimg-modal-img'); // Gán ảnh modalImg.src = src; // Chuyển modal vào đúng section đang active const activeSection = document.querySelector('.fp-section.fp-table.fp-is-overflow.active'); if (activeSection && !activeSection.contains(modal)) { activeSection.appendChild(modal); } // Hiển thị modal với animation modal.style.display = 'flex'; modal.classList.add('show'); if (typeof fullpage_api !== 'undefined') { fullpage_api.setAllowScrolling(false); fullpage_api.setKeyboardScrolling(false); } } // Gắn sự kiện click ảnh document.querySelectorAll('.wezoomable').forEach(img => { img.addEventListener('click', () => openModalWithImage(img.src)); }); // Đóng Modal function closeModal() { const modal = document.querySelector('.js-we-overlayimg-modal'); modal.classList.remove('show'); modal.style.display = 'none'; if (typeof fullpage_api !== 'undefined') { fullpage_api.setAllowScrolling(true); fullpage_api.setKeyboardScrolling(true); } } document.querySelector('.js-we-overlayimg-close').addEventListener('click', closeModal); document.querySelector('.js-we-overlayimg-modal').addEventListener('click', function(e) { if (e.target === this) closeModal(); }); document.addEventListener('keydown', function(e) { if (e.key === 'Escape') { const modal = document.querySelector('.js-we-overlayimg-modal'); if (modal && modal.style.display === 'flex') { closeModal(); } } });