custom.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. Template Name: Monster Admin
  3. Author: Themedesigner
  4. Email: niravjoshi87@gmail.com
  5. File: js
  6. */
  7. $(function() {
  8. "use strict";
  9. $(function() {
  10. $(".preloader").fadeOut();
  11. });
  12. jQuery(document).on('click', '.mega-dropdown', function(e) {
  13. e.stopPropagation()
  14. });
  15. // ==============================================================
  16. // This is for the top header part and sidebar part
  17. // ==============================================================
  18. var set = function() {
  19. var width = (window.innerWidth > 0) ? window.innerWidth : this.screen.width;
  20. var topOffset = 70;
  21. if (width < 500) {
  22. $("body").addClass("mini-sidebar");
  23. $('.navbar-brand span').hide();
  24. $(".scroll-sidebar, .slimScrollDiv").css("overflow-x", "visible").parent().css("overflow", "visible");
  25. $(".sidebartoggler i").addClass("ti-menu");
  26. } else {
  27. $("body").removeClass("mini-sidebar");
  28. $('.navbar-brand span').show();
  29. $(".sidebartoggler i").removeClass("ti-menu");
  30. }
  31. var height = ((window.innerHeight > 0) ? window.innerHeight : this.screen.height) - 1;
  32. height = height - topOffset;
  33. if (height < 1) height = 1;
  34. if (height > topOffset) {
  35. $(".page-wrapper").css("min-height", (height) + "px");
  36. }
  37. };
  38. $(window).ready(set);
  39. $(window).on("resize", set);
  40. // topbar stickey on scroll
  41. $(".fix-header .topbar").stick_in_parent({
  42. });
  43. // this is for close icon when navigation open in mobile view
  44. $(".nav-toggler").click(function() {
  45. $("body").toggleClass("show-sidebar");
  46. $(".nav-toggler i").toggleClass("ti-menu");
  47. $(".nav-toggler i").addClass("ti-close");
  48. });
  49. $(".sidebartoggler").on('click', function() {
  50. $(".sidebartoggler i").toggleClass("ti-menu");
  51. });
  52. // ==============================================================
  53. // Auto select left navbar
  54. // ==============================================================
  55. $(function() {
  56. var url = window.location;
  57. var element = $('ul#sidebarnav a').filter(function() {
  58. return this.href == url;
  59. }).addClass('active').parent().addClass('active');
  60. while (true) {
  61. if (element.is('li')) {
  62. element = element.parent().addClass('in').parent().addClass('active');
  63. } else {
  64. break;
  65. }
  66. }
  67. });
  68. // ==============================================================
  69. // Sidebarmenu
  70. // ==============================================================
  71. $(function() {
  72. $('#sidebarnav').metisMenu();
  73. });
  74. // ==============================================================
  75. // Slimscrollbars
  76. // ==============================================================
  77. $('.scroll-sidebar').slimScroll({
  78. position: 'left',
  79. size: "5px",
  80. height: '100%',
  81. color: '#dcdcdc'
  82. });
  83. // ==============================================================
  84. // Resize all elements
  85. // ==============================================================
  86. $("body").trigger("resize");
  87. });