sb-admin.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (function($) {
  2. "use strict"; // Start of use strict
  3. // Configure tooltips for collapsed side navigation
  4. $('.navbar-sidenav [data-toggle="tooltip"]').tooltip({
  5. template: '<div class="tooltip navbar-sidenav-tooltip" role="tooltip" style="pointer-events: none;"><div class="arrow"></div><div class="tooltip-inner"></div></div>'
  6. })
  7. // Toggle the side navigation
  8. $("#sidenavToggler").click(function(e) {
  9. e.preventDefault();
  10. $("body").toggleClass("sidenav-toggled");
  11. $(".navbar-sidenav .nav-link-collapse").addClass("collapsed");
  12. $(".navbar-sidenav .sidenav-second-level, .navbar-sidenav .sidenav-third-level").removeClass("show");
  13. });
  14. // Force the toggled class to be removed when a collapsible nav link is clicked
  15. $(".navbar-sidenav .nav-link-collapse").click(function(e) {
  16. e.preventDefault();
  17. $("body").removeClass("sidenav-toggled");
  18. });
  19. // Prevent the content wrapper from scrolling when the fixed side navigation hovered over
  20. $('body.fixed-nav .navbar-sidenav, body.fixed-nav .sidenav-toggler, body.fixed-nav .navbar-collapse').on('mousewheel DOMMouseScroll', function(e) {
  21. var e0 = e.originalEvent,
  22. delta = e0.wheelDelta || -e0.detail;
  23. this.scrollTop += (delta < 0 ? 1 : -1) * 30;
  24. e.preventDefault();
  25. });
  26. // Scroll to top button appear
  27. $(document).scroll(function() {
  28. var scrollDistance = $(this).scrollTop();
  29. if (scrollDistance > 100) {
  30. $('.scroll-to-top').fadeIn();
  31. } else {
  32. $('.scroll-to-top').fadeOut();
  33. }
  34. });
  35. // Configure tooltips globally
  36. $('[data-toggle="tooltip"]').tooltip()
  37. // Smooth scrolling using jQuery easing
  38. $(document).on('click', 'a.scroll-to-top', function(event) {
  39. var $anchor = $(this);
  40. $('html, body').stop().animate({
  41. scrollTop: ($($anchor.attr('href')).offset().top)
  42. }, 1000, 'easeInOutExpo');
  43. event.preventDefault();
  44. });
  45. })(jQuery); // End of use strict