kithkin/resources/js/app.js

27 lines
821 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 isnt 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));
});