Spaces:
Running
Running
File size: 4,963 Bytes
8e11898 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
'use script'
// Add backdrop element
$('body').append('<div class="main-backdrop"></div>');
// Enable tooltips everywhere
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function(tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
});
// Show sidebar in mobile
$('#menuLink').on('click', function(e) {
e.preventDefault();
$('body').toggleClass('sidebar-show');
});
// Hide sidebar in mobile
$('body').on('click', '.main-backdrop', function() {
$('body').removeClass('sidebar-show sideright-show');
})
// Sidebar Interaction
const psSidebar = new PerfectScrollbar('#sidebarMenu', {
suppressScrollX: true
});
$('.sidebar .nav-label').on('click', function(e) {
e.preventDefault();
var target = $(this).next('.nav-sidebar');
$(target).slideToggle(function() {
psSidebar.update();
});
});
$('.sidebar .has-sub').on('click', function(e) {
e.preventDefault();
var target = $(this).next('.nav-sub');
$(target).slideToggle(function() {
psSidebar.update();
});
var siblings = $(this).closest('.nav-item').siblings();
siblings.each(function() {
var nav = $(this).find('.nav-sub');
if (nav.is(':visible')) {
nav.slideUp();
}
});
});
$('#sidebarFooterMenu').on('click', function(e) {
e.preventDefault();
$(this).closest('.sidebar').toggleClass('footer-menu-show');
});
// Header mobile effect on scroll
function animateHead() {
if ($(document).scrollTop() > 20) {
$('.main-mobile-header').addClass('scroll');
} else {
$('.main-mobile-header').removeClass('scroll');
}
}
$(window).scroll(function() {
animateHead();
});
// Click interaction anywhere in the page
$(document).on('click touchstart', function(e) {
e.stopPropagation();
// closing sidebar footer menu
if (!$(e.target).closest('.sidebar-footer').length) {
$('.sidebar').removeClass('footer-menu-show');
}
});
// Form search
$('.form-search .form-control').on('focusin focusout', function(e) {
$(this).parent().toggleClass('onfocus');
});
// Show/hide sidebar
$('#menuSidebar').on('click', function(e) {
e.preventDefault();
if (window.matchMedia('(min-width: 992px)').matches) {
$('body').toggleClass('sidebar-hide');
} else {
$('body').toggleClass('sidebar-show');
}
});
// Show/hide sidebar offset
$('#menuSidebarOffset').on('click', function(e) {
e.preventDefault();
$('body').toggleClass('sidebar-show');
});
// Load skin mode
var skinMode = localStorage.getItem('skin-mode');
if (skinMode) {
$('html').attr('data-skin', 'dark');
$('#skinMode .nav-link:last-child').addClass('active').siblings().removeClass('active');
}
// Set skin mode
$('#skinMode .nav-link').on('click', function(e) {
e.preventDefault();
$(this).addClass('active').siblings().removeClass('active');
var mode = $(this).text().toLowerCase();
if (mode == 'dark') {
$('html').attr('data-skin', 'dark');
localStorage.setItem('skin-mode', mode);
} else {
localStorage.removeItem('skin-mode');
$('html').attr('data-skin', '');
}
});
// Load sidebar skin
var sidebarSkin = localStorage.getItem('sidebar-skin');
if (sidebarSkin) {
$('.sidebar').attr('class', 'sidebar sidebar-' + sidebarSkin);
if (sidebarSkin == 'prime') {
$('#sidebarSkin .nav-link:nth-child(2)').addClass('active').siblings().removeClass('active');
} else {
$('#sidebarSkin .nav-link:last-child').addClass('active').siblings().removeClass('active');
}
}
// Set sidebar skin
$('#sidebarSkin .nav-link').on('click', function(e) {
e.preventDefault();
$(this).addClass('active').siblings().removeClass('active');
var skin = $(this).text().toLowerCase();
if (skin == 'default') {
$('.sidebar').attr('class', 'sidebar');
localStorage.removeItem('sidebar-skin');
} else {
$('.sidebar').attr('class', 'sidebar sidebar-' + skin);
localStorage.setItem('sidebar-skin', skin);
}
});
// Direction (LTR,RTL)
$('#layoutDirection .nav-link').on('click', function(e) {
e.preventDefault();
var loc = window.location.href;
var newLoc = '';
if ($(this).is(':last-child')) {
if (loc.includes('/dashboard/')) newLoc = loc.replace('/dashboard/', '/dashboard-rtl/');
if (loc.includes('/apps/')) newLoc = loc.replace('/apps/', '/apps-rtl/');
if (loc.includes('/pages/')) newLoc = loc.replace('/pages/', '/pages-rtl/');
} else {
if (loc.includes('/dashboard-rtl/')) newLoc = loc.replace('/dashboard-rtl/', '/dashboard/');
if (loc.includes('/apps-rtl/')) newLoc = loc.replace('/apps-rtl/', '/apps/');
if (loc.includes('/pages-rtl/')) newLoc = loc.replace('/pages-rtl/', '/pages/');
}
window.location.href = newLoc;
}) |