Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

sbadmin_pro.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*!
  2. * Start Bootstrap - SB Admin Pro v1.3.0 (https://shop.startbootstrap.com/product/sb-admin-pro)
  3. * Copyright 2013-2020 Start Bootstrap
  4. * Licensed under SEE_LICENSE (https://github.com/StartBootstrap/sb-admin-pro/blob/master/LICENSE)
  5. */
  6. (function ($) {
  7. "use strict";
  8. // Enable Bootstrap tooltips via data-attributes globally
  9. $('[data-toggle="tooltip"]').tooltip();
  10. // Enable Bootstrap popovers via data-attributes globally
  11. $('[data-toggle="popover"]').popover();
  12. $(".popover-dismiss").popover({
  13. trigger: "focus"
  14. });
  15. // Add active state to sidbar nav links
  16. var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
  17. $("#layoutSidenav_nav .sidenav a.nav-link").each(function () {
  18. if (this.href === path) {
  19. $(this).addClass("active");
  20. }
  21. });
  22. // Toggle the side navigation
  23. $("#sidebarToggle").on("click", function (e) {
  24. e.preventDefault();
  25. $("body").toggleClass("sidenav-toggled");
  26. });
  27. // Activate Feather icons
  28. feather.replace();
  29. // Activate Bootstrap scrollspy for the sticky nav component
  30. $("body").scrollspy({
  31. target: "#stickyNav",
  32. offset: 82
  33. });
  34. // Scrolls to an offset anchor when a sticky nav link is clicked
  35. $('.nav-sticky a.nav-link[href*="#"]:not([href="#"])').click(function () {
  36. if (
  37. location.pathname.replace(/^\//, "") ==
  38. this.pathname.replace(/^\//, "") &&
  39. location.hostname == this.hostname
  40. ) {
  41. var target = $(this.hash);
  42. target = target.length ? target : $("[name=" + this.hash.slice(1) + "]");
  43. if (target.length) {
  44. $("html, body").animate({
  45. scrollTop: target.offset().top - 81
  46. },
  47. 200
  48. );
  49. return false;
  50. }
  51. }
  52. });
  53. // Click to collapse responsive sidebar
  54. $("#layoutSidenav_content").click(function () {
  55. const BOOTSTRAP_LG_WIDTH = 992;
  56. if (window.innerWidth >= 992) {
  57. return;
  58. }
  59. if ($("body").hasClass("sidenav-toggled")) {
  60. $("body").toggleClass("sidenav-toggled");
  61. }
  62. });
  63. // Init sidebar
  64. let activatedPath = window.location.pathname.match(/([\w-]+\.html)/, '$1');
  65. if (activatedPath) {
  66. activatedPath = activatedPath[0];
  67. } else {
  68. activatedPath = 'index.html';
  69. }
  70. let targetAnchor = $('[href="' + activatedPath + '"]');
  71. let collapseAncestors = targetAnchor.parents('.collapse');
  72. targetAnchor.addClass('active');
  73. collapseAncestors.each(function () {
  74. $(this).addClass('show');
  75. $('[data-target="#' + this.id + '"]').removeClass('collapsed');
  76. })
  77. })(jQuery);