|
Server : Apache System : Linux s1230 5.15.0-139-generic #149~20.04.1 SMP Tue Jul 14 11:21:49 UTC 2026 x86_64 User : p141464 ( 418825) PHP Version : 7.4.33.12 Disable Function : NONE Directory : /html/relaunch-kmu/wp-content/plugins/wp-gdpr-compliance/Resources/js/components/ |
Upload File : |
import { _readCookie } from '../utils/helpers'
import { _setConsentCookie } from './consent-cookie'
/**
* Front Component for consent bar
*/
export default class ConsentBar {
constructor () {
this.setProperties()
this.init()
}
setProperties () {
this.cookieName = wpgdprcFront.cookieName
this.consentBar = document.querySelector('.wpgdprc-consent-bar')
this.buttonAccept = document.querySelector('.wpgdprc-consent-bar .wpgdprc-button--accept')
this.isLoading = false
}
init () {
if (!this.consentBar) {
return
}
const consentCookie = _readCookie(this.cookieName)
if (consentCookie !== null) {
// Hide consent bar if cookie already set
this.consentBar.style.display = 'none'
return
}
// Move consent bar to the be the first element in the <body>
const body = document.querySelector('body')
body.prepend(this.consentBar)
// Show bar
this.consentBar.style.display = 'block'
this.handleButtonAccept()
}
handleButtonAccept () {
if (!this.buttonAccept) {
return
}
this.buttonAccept.addEventListener('click', event => {
event.preventDefault()
if (this.isLoading) {
return
}
this.isLoading = _setConsentCookie('all')
})
}
}