Newer
Older
pre-www / src / assets / js / blocks / alert-bar.js
window.addEventListener('load', (event) => {

    const alerts = document.querySelectorAll('.block-alert-bar')

    alerts.forEach(alert => {
        const modalOpenButton = alert.querySelector('[data-open-alert-modal]')
        const modal = alert.querySelector('[data-alert-modal]')
        const modalCloseButton = alert.querySelector('[data-close-alert-modal]')
        modalOpenButton.addEventListener('click', function(){
            modal.classList.add('is-active')
            modal.setAttribute('aria-hidden', 'false')
        })
        modalCloseButton.addEventListener('click', function(){
            modal.setAttribute('aria-hidden', 'true')
            setTimeout(() => {
                modal.classList.remove('is-active')
            }, 275);
        })
    })
    
})