"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jquery_1 = __importDefault(require("jquery"));
// Transitions
// -------------------------
// Disable all transitions
function _transitionsDisabled() {
    (0, jquery_1.default)('body').addClass('no-transitions');
}
// Enable all transitions
function _transitionsEnabled() {
    (0, jquery_1.default)('body').removeClass('no-transitions');
}
// Sidebars
// -------------------------
function _sidebarMobileMainToggle() {
    // Elements
    const sidebarMainElement = (0, jquery_1.default)('.sidebar-main'), sidebarMainRestElements = (0, jquery_1.default)('.sidebar:not(.sidebar-main):not(.sidebar-component)'), sidebarMainDesktopToggler = (0, jquery_1.default)('.sidebar-main-toggle'), sidebarMainMobileToggler = (0, jquery_1.default)('.sidebar-mobile-main-toggle'), sidebarCollapsedClass = 'sidebar-collapsed', sidebarMobileExpandedClass = 'sidebar-mobile-expanded';
    // On desktop
    sidebarMainDesktopToggler.on('click', function (e) {
        e.preventDefault();
        sidebarMainElement.toggleClass(sidebarCollapsedClass);
    });
    // On mobile
    sidebarMainMobileToggler.on('click', function (e) {
        e.preventDefault();
        sidebarMainElement.toggleClass(sidebarMobileExpandedClass);
        sidebarMainRestElements.removeClass(sidebarMobileExpandedClass);
    });
}
// Navbar navigation
// -------------------------
function _navigationNavbar() {
    // Prevent dropdown from closing on click
    (0, jquery_1.default)(document).on('click', '.dropdown-content', function (e) {
        e.stopPropagation();
    });
    // Disabled links
    (0, jquery_1.default)('.navbar-nav .disabled a, .nav-item-levels .disabled').on('click', function (e) {
        e.preventDefault();
        e.stopPropagation();
    });
    // Show tabs inside dropdowns
    (0, jquery_1.default)('.dropdown-content a[data-toggle="tab"]').on('click', function (e) {
        (0, jquery_1.default)(this).tab('show');
    });
}
// Header elements toggler
function _headerElements() {
    // Toggle visible state of header elements
    (0, jquery_1.default)('.header-elements-toggle').on('click', function (e) {
        e.preventDefault();
        (0, jquery_1.default)(this).parents('[class*=header-elements-]').find('.header-elements').toggleClass('d-none');
    });
    // Toggle visible state of footer elements
    (0, jquery_1.default)('.footer-elements-toggle').on('click', function (e) {
        e.preventDefault();
        (0, jquery_1.default)(this).parents('.card-footer').find('.footer-elements').toggleClass('d-none');
    });
}
// When content is loaded
document.addEventListener('DOMContentLoaded', () => {
    _transitionsDisabled();
    _sidebarMobileMainToggle();
    _navigationNavbar();
    _headerElements();
});
// When page is fully loaded
window.addEventListener('load', function () {
    _transitionsEnabled();
    (0, jquery_1.default)('body').removeClass('no-js').addClass('js');
});
