var as = {}; as.toggleSidebar = function () { if (window.innerWidth < 992) { // Mobile e Tablet: La sidebar si chiude completamente $(".sidebar").toggleClass("expanded"); $("body").toggleClass("sidebar-enable"); } else { // Desktop: La sidebar si restringe, lasciando solo le icone if ($("body").hasClass("sidebar-collapsed")) { $("body").removeClass("sidebar-collapsed"); } else { $("body").addClass("sidebar-collapsed"); } } }; as.hideNotifications = function () { $(".alert-notification").slideUp(600, function () { $(this).remove(); }); }; as.updateSidebarSize = function () { if (window.innerWidth >= 992 && window.innerWidth <= 1199) { window.document.body.classList.add("sidebar-collapsed"); } else { window.document.body.classList.remove("sidebar-collapsed"); } }; as.init = function () { $.ajaxSetup({ headers: { "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"), }, }); // Aggiunto supporto per il tasto hamburger $(".button-menu-mobile").click(as.toggleSidebar); $('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="popover"]').popover(); $(".alert-notification .close").click(as.hideNotifications); setTimeout(as.hideNotifications, 3500); $("a[data-toggle=loader], button[data-toggle=loader]").click(function () { if ($(this).parents("form").valid()) { as.btn.loading($(this), $(this).data("loading-text")); $(this).parents("form").submit(); } }); $(window).resize(as.updateSidebarSize); }; as.updateSidebarSize(); $(document).ready(as.init);