photo_server_json_con_aves22/public/js/optionsSheet.js
2026-04-18 20:14:42 +02:00

59 lines
1.8 KiB
JavaScript

// ===============================
// OPTIONS SHEET — Ordinamento, Raggruppamento, Filtri
// ===============================
document.addEventListener("DOMContentLoaded", () => {
const optionsSheet = document.getElementById("optionsSheet");
const sheetOverlay = document.getElementById("sheetOverlay");
const optionsBtn = document.getElementById("optionsBtn");
// -------------------------------
// APRI / CHIUDI
// -------------------------------
function openOptionsSheet() {
optionsSheet.classList.add("open");
sheetOverlay.classList.add("open");
}
function closeOptionsSheet() {
optionsSheet.classList.remove("open");
sheetOverlay.classList.remove("open");
}
// -------------------------------
// HANDLER CLICK BOTTONI
// -------------------------------
optionsSheet.addEventListener("click", (e) => {
const btn = e.target.closest(".sheet-btn");
if (!btn) return;
const sort = btn.dataset.sort;
const group = btn.dataset.group;
const filter = btn.dataset.filter;
if (sort) window.currentSort = sort;
if (group) window.currentGroup = group;
if (filter) window.currentFilter = filter;
refreshGallery();
closeOptionsSheet();
});
// -------------------------------
// CHIUSURA CLICCANDO FUORI
// -------------------------------
sheetOverlay.addEventListener("click", closeOptionsSheet);
// -------------------------------
// AGGANCIA IL PULSANTE
// -------------------------------
optionsBtn.addEventListener("click", openOptionsSheet);
// -------------------------------
// EXPORT
// -------------------------------
window.openOptionsSheet = openOptionsSheet;
window.closeOptionsSheet = closeOptionsSheet;
});