27 lines
821 B
JavaScript
27 lines
821 B
JavaScript
import './bootstrap';
|
||
import htmx from 'htmx.org';
|
||
|
||
// make html globally visible to use the devtools and extensions
|
||
window.htmx = htmx;
|
||
|
||
// global htmx config
|
||
htmx.config.historyEnabled = true; // HX-Boost back/forward support
|
||
htmx.logger = console.log; // verbose logging during dev
|
||
|
||
// calendar toggle
|
||
// * progressive enhancement on html form with no js
|
||
document.addEventListener('change', event => {
|
||
const checkbox = event.target;
|
||
|
||
// ignore anything that isn’t one of our checkboxes
|
||
if (!checkbox.matches('.calendar-toggle')) return;
|
||
|
||
const slug = checkbox.value;
|
||
const show = checkbox.checked;
|
||
|
||
// toggle .hidden on every matching event element
|
||
document
|
||
.querySelectorAll(`[data-calendar="${slug}"]`)
|
||
.forEach(el => el.classList.toggle('hidden', !show));
|
||
});
|