File size: 3.38Kb
"use strict";
// Preloader Begin
$(window).on('load', function () {
$(".preloader").fadeOut(1750);
});
// Preloader End
// ToolTips Begin
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// ToolTips End
// Dashboard Script
document.addEventListener("DOMContentLoaded", function () {
(function ($) {
// Toggle the sidebar
$("#humbergersidebarToggleTop").on('click', function (e) {
$("body").toggleClass("sidebar-toggled");
$(".sidebar").toggleClass("toggled");
if ($(".sidebar").hasClass("toggled")) {
$('.sidebar .collapse').collapse('hide');
}
});
// When the window is shrunk below 768px, close any open menu accordionsidebar.
$(window).resize(function () {
if ($(window).width() < 768) {
$('.sidebar .collapse').collapse('hide');
}
// When the window is shrunk below 480px, toggle the side navigation.
if ($(window).width() < 480 && !$(".sidebar").hasClass("toggled")) {
$("body").addClass("sidebar-toggled");
$(".sidebar").addClass("toggled");
$('.sidebar .collapse').collapse('hide');
}
});
// When the fixed side navigation is hovered over, prevent the content sidebarwrapper from scrolling.
$('body.fixed-nav .sidebar').on('mousewheel DOMMouseScroll wheel', function (e) {
if ($(window).width() > 768) {
var e0 = e.originalEvent,
delta = e0.wheelDelta || -e0.detail;
this.scrollTop += (delta < 0 ? 1 : -1) * 30;
e.preventDefault();
}
});
// Password toggle
function togglePassword(inputId) {
var passwordField = document.querySelector(inputId);
var icon = passwordField.nextElementSibling;
if (passwordField.type === "password") {
passwordField.type = "text";
icon.classList.remove("fa-eye");
icon.classList.add("fa-eye-slash");
} else {
passwordField.type = "password";
icon.classList.remove("fa-eye-slash");
icon.classList.add("fa-eye");
}
}
// Attach event listeners after DOM content is loaded
document.querySelectorAll('.toggle-password').forEach(function (element) {
element.addEventListener('click', function () {
togglePassword('#passwordField');
});
});
// countdown timer
// Scroll to top
// Get the button
var mybutton = document.getElementById("gobackToTop");
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.display = "block";
} else {
mybutton.style.display = "none";
}
}
// Attach topFunction to global scope
window.topFunction = function () {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
};
})(jQuery);
});