Sha256: 53a6bf4b2340aae821ffe4c6e623d68875325738ff36f930d9457aba0fec9f7b
Contents?: true
Size: 1.34 KB
Versions: 22
Compression:
Stored size: 1.34 KB
Contents
import { Controller } from "@hotwired/stimulus"; import { ConsentCategory } from "../consent"; export default class extends Controller { static targets = ["check"]; declare checkTargets: HTMLInputElement[]; connect(): void { this.checkTargets.forEach((input) => { input.checked = window.ui?.consent.permitted.includes(input.name as ConsentCategory) || input.name === "essential"; }); } permitAll(event: Event): void { event.preventDefault(); window.ui?.consent.permitAll(); this.closeAll(); } denyAll(event: Event): void { event.preventDefault(); window.ui?.consent.denyAll(); this.closeAll(); } save(event: Event): void { event.preventDefault(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion window.ui!.consent.permitted = this.checkTargets .filter((e) => e.checked) .map((e) => e.name) as ConsentCategory[]; this.closeAll(); } manage(event: Event): void { event.preventDefault(); const div = document.body.querySelector( "#personalization-settings" ) as HTMLDivElement; if (!div) return; (this.element as HTMLElement).hidden = true; div.hidden = false; } closeAll(): void { document .querySelectorAll("[data-controller='consent']") .forEach((e: HTMLElement) => (e.hidden = true)); } }
Version data entries
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
shimmer-0.0.21 | src/controllers/consent.ts |
shimmer-0.0.20 | src/controllers/consent.ts |