Spaces:
Paused
Paused
File size: 1,572 Bytes
6fff7cf 4edc3e5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | // components/consent-component.js - Consent modal functionality
import { StateManager } from '../services/state-manager.js';
export const ConsentComponent = {
elements: {
consentModal: null,
consentCheckbox: null,
consentBtn: null,
profileModal: null
},
/**
* Initialize the consent component
*/
init() {
this.elements.consentModal = document.getElementById('consent-modal');
this.elements.consentCheckbox = document.getElementById('consent-checkbox');
this.elements.consentBtn = document.getElementById('consentBtn');
this.elements.profileModal = document.getElementById('profile-modal');
this.attachEventListeners();
},
/**
* Attach event listeners
*/
attachEventListeners() {
// When the checkbox is toggled, enable or disable the button
this.elements.consentCheckbox.addEventListener('change', () => {
if (this.elements.consentCheckbox.checked) {
this.elements.consentBtn.disabled = false;
this.elements.consentBtn.classList.replace('disabled-button', 'ok-button');
} else {
this.elements.consentBtn.disabled = true;
this.elements.consentBtn.classList.replace('ok-button', 'disabled-button');
}
});
// Handle the consent acceptance
this.elements.consentBtn.addEventListener('click', () => {
StateManager.setConsent(true);
this.elements.profileModal.scrollIntoView({
behavior: 'smooth',
inline: 'start',
block: 'nearest'
});
});
}
}; |