Add 'fiscal/' from commit '102ba84500dbd9655a0471288c3e278652593ca9'
git-subtree-dir: fiscal git-subtree-mainline:d95165fc8fgit-subtree-split:102ba84500
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
// app/static/sidebar.js — abre/fecha a gaveta da sidebar no mobile e
|
||||
// recolhe/expande no desktop, persistindo a preferência de recolher.
|
||||
(function () {
|
||||
var sidebar = document.getElementById("sidebar");
|
||||
var backdrop = document.getElementById("sidebar-backdrop");
|
||||
var btnMenuMobile = document.getElementById("btn-menu-mobile");
|
||||
var btnRecolher = document.getElementById("botao-recolher");
|
||||
if (!sidebar) return;
|
||||
|
||||
function abrirGaveta() {
|
||||
sidebar.classList.add("aberta");
|
||||
if (backdrop) backdrop.classList.add("aberta");
|
||||
}
|
||||
function fecharGaveta() {
|
||||
sidebar.classList.remove("aberta");
|
||||
if (backdrop) backdrop.classList.remove("aberta");
|
||||
}
|
||||
|
||||
if (btnMenuMobile) {
|
||||
btnMenuMobile.addEventListener("click", function () {
|
||||
if (sidebar.classList.contains("aberta")) fecharGaveta();
|
||||
else abrirGaveta();
|
||||
});
|
||||
}
|
||||
if (backdrop) backdrop.addEventListener("click", fecharGaveta);
|
||||
sidebar.querySelectorAll("a").forEach(function (link) {
|
||||
link.addEventListener("click", fecharGaveta);
|
||||
});
|
||||
|
||||
if (btnRecolher) {
|
||||
if (localStorage.getItem("sidebarRecolhida") === "1") {
|
||||
sidebar.classList.add("recolhida");
|
||||
}
|
||||
btnRecolher.addEventListener("click", function () {
|
||||
var recolhida = sidebar.classList.toggle("recolhida");
|
||||
localStorage.setItem("sidebarRecolhida", recolhida ? "1" : "0");
|
||||
});
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user