var left_side_width = 220; //Sidebar width in pixels $(function () { "use strict"; $('.left-side').toggleClass("collapse-left"); //$(".right-side").toggleClass("strech"); $("[data-bs-toggle='offcanvas']").toggleClass('active_desac'); //Enable sidebar toggle $("[data-bs-toggle='offcanvas']").on('click', function (e) { e.preventDefault(); //If window is small enough, enable sidebar push menu if ($(window).width() <= 992) { $('.row-offcanvas').toggleClass('active'); $('.left-side').removeClass("collapse-left"); $(".right-side").removeClass("strech"); $(".titleModule").removeClass("strech"); $('.row-offcanvas').toggleClass("relative"); $(this).toggleClass('active_desac'); } else { //Else, enable content streching $('.left-side').toggleClass("collapse-left"); $(".titleModule").toggleClass("strech"); $(".right-side").toggleClass("strech"); $(this).toggleClass('active_desac'); } }); //Add hover support for touch devices $('.btn').on('touchstart', function () { $(this).addClass('hover'); }).on('touchend', function () { $(this).removeClass('hover'); }); //Activate tooltips document.querySelectorAll("[data-bs-toggle='tooltip']").forEach(el => new bootstrap.Tooltip(el)); /* * Add collapse and remove events to boxes */ $("[data-widget='collapse']").on('click', function () { //Find the box parent var box = $(this).parents(".box").first(); //Find the body and the footer var bf = box.find(".box-body, .box-footer"); if (!box.hasClass("collapsed-box")) { box.addClass("collapsed-box"); //Convert minus into plus $(this).children(".fa-minus").removeClass("fa-minus").addClass("fa-plus"); bf.slideUp(); } else { box.removeClass("collapsed-box"); //Convert plus into minus $(this).children(".fa-plus").removeClass("fa-plus").addClass("fa-minus"); bf.slideDown(); } }); /* * ADD SLIMSCROLL TO THE TOP NAV DROPDOWNS * --------------------------------------- */ $(".navbar .menu").slimScroll({ height: "200px", alwaysVisible: false, size: "3px" }).css("width", "100%"); /* * INITIALIZE BUTTON TOGGLE * ------------------------ */ $('.btn-group[data-bs-toggle="btn-toggle"]').each(function () { var group = $(this); $(this).find(".btn").on('click', function (e) { group.find(".btn.active").removeClass("active"); $(this).addClass("active"); e.preventDefault(); }); }); $("[data-widget='remove']").on('click', function () { //Find the box parent var box = $(this).parents(".box").first(); box?.slideUp(); }); /* Sidebar tree view */ $(".sidebar .treeview").tree(); /* * Make sure that the sidebar is streched full height * --------------------------------------------- * We are gonna assign a min-height value every time the * wrapper gets resized and upon page load. We will use * Ben Alman's method for detecting the resize event. * **/ function _fix() { //Get window height and the wrapper height var height = $(window).height(); $(".wrapper").css("min-height", height + "px"); var content = $(".wrapper").height(); //If the wrapper height is greater than the window if (content > height) { //then set sidebar height to the wrapper $(".left-side, html, body").css("height", content + "px"); } else { //Otherwise, set the sidebar to the height of the window $(".left-side, html, body").css("height", height + "px"); } } //Fire upon load _fix(); //Fire when wrapper is resized $(".wrapper").on('resize', function () { _fix(); fix_sidebar(); }); //Fix the fixed layout sidebar scroll bug fix_sidebar(); }); $("a").on('click', function (e) { e.preventDefault(); }); $("button").on('click', function (e) { if ($(this).attr('type') !== 'submit') e.preventDefault(); }); function fix_sidebar() { //Make sure the body tag has the .fixed class if (!$("body").hasClass("fixed")) { return; } //Add slimscroll $(".sidebar").slimScroll({ height: ($(window).height() - $(".header").height()) + "px", color: "rgba(0,0,0,0.2)" }); } /*END DEMO*/ /* * SIDEBAR MENU * ------------ * This is a custom plugin for the sidebar menu. It provides a tree view. * * Usage: * $(".sidebar).tree(); * * Note: This plugin does not accept any options. Instead, it only requires a class * added to the element that contains a sub-menu. * * When used with the sidebar, for example, it would look something like this: *