1import { Controller } from "@hotwired/stimulus" 2import { setCookies } from "cookiesManipulation"; 3 4export default class extends Controller { 5 6 connect() { 7 // console.log(`Hello from ${this.identifier} controller`); 8 } 9 10 notifyGTM() { 11 // console.log("Notify GTM"); 12 // GTM will wait to get this event to add tags based on selection 13 window.dataLayer = window.dataLayer || []; 14 window.dataLayer.push({ "event": "cookies_consent_update" }); 15 } 16 17 toggleChoicesVisibility() { 18 this.element.classList.toggle("show-selection") 19 } 20 21 toggleCookie(e) { 22 const target = e.currentTarget; 23 if (target.classList.contains("cookies-toggler__button--disabled")) return; 24 25 26 e.currentTarget.classList.toggle("cookies-toggler__button--toggled"); 27 } 28 29 decline() { 30 this.consent = { necessary: true, statistics: false, marketing: false } 31 this.updateConsent(); 32 } 33 34 acceptAll() { 35 this.consent = { necessary: true, statistics: true, marketing: true } 36 this.updateConsent(); 37 } 38 39 acceptSelection() { 40 this.consent = { 41 necessary: true, 42 statistics: this.consentFor("statistics"), 43 marketing: this.consentFor("marketing") 44 } 45 this.updateConsent(); 46 } 47 48 updateConsent() { 49 setCookies("cookies_consent", JSON.stringify(this.consent)); 50 this.notifyGTM(); 51 this.element.style.display = "none"; 52 } 53 54 consentFor(cookieType) { 55 const cookieToggler = this.element.querySelector(`.cookies-toggler__button[data-cookie-type="${cookieType}"]`); 56 return cookieToggler.classList.contains("cookies-toggler__button--toggled"); 57 } 58 59};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.