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

    // main elements
    const cb = document.getElementById('cb')
    const initPanel = document.getElementById('cb-init-panel')
    const customPanel = document.getElementById('cb-custom-panel')

    // buttons
    const toggleCustomBtn = document.getElementById('cb-custom')
    const customBtn = document.getElementById('cb-custom-consent')
    const consentBtns = document.querySelectorAll('[data-cb-consent]')

    // toggle custom cookie panel
    toggleCustomBtn.addEventListener('click', () => {
        initPanel.classList.add('hidden')
        customPanel.classList.remove('hidden')
        toggleCustomBtn.classList.add('hidden')
        customBtn.classList.remove('hidden')
        document.getElementById('cb-overlay').classList.add('is-active')
    })

    consentBtns.forEach(button => {
        button.addEventListener('click', () => {
            cb.classList.add('hidden')
            document.getElementById('cb-overlay').classList.remove('is-active')
        })

    })

})