jquery.app.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Theme: Abstack - Bootstrap 4 Web App kit
  3. * Author: Coderthemes
  4. * Module/App: Main Js
  5. */
  6. (function ($) {
  7. 'use strict';
  8. function initNavbar() {
  9. $('.navbar-toggle').on('click', function (event) {
  10. $(this).toggleClass('open');
  11. $('#navigation').slideToggle(400);
  12. });
  13. $('.navigation-menu>li').slice(-2).addClass('last-elements');
  14. $('.navigation-menu li.has-submenu a[href="#"]').on('click', function (e) {
  15. if ($(window).width() < 992) {
  16. e.preventDefault();
  17. $(this).parent('li').toggleClass('open').find('.submenu:first').toggleClass('open');
  18. }
  19. });
  20. }
  21. function initScrollbar() {
  22. $('.slimscroll').slimscroll({
  23. height: 'auto',
  24. position: 'right',
  25. size: "8px",
  26. color: '#9ea5ab'
  27. });
  28. }
  29. // === following js will activate the menu in left side bar based on url ====
  30. function initMenuItem() {
  31. $(".navigation-menu a").each(function () {
  32. if (this.href == window.location.href) {
  33. $(this).parent().addClass("active"); // add active to li of the current link
  34. $(this).parent().parent().parent().addClass("active"); // add active class to an anchor
  35. $(this).parent().parent().parent().parent().parent().addClass("active"); // add active class to an anchor
  36. }
  37. });
  38. }
  39. function initRightbar() {
  40. $(".right-bar-toggle").click(function () {
  41. $(".right-bar").toggle();
  42. $('.wrapper').toggleClass('right-bar-enabled');
  43. });
  44. }
  45. function init() {
  46. initNavbar();
  47. initScrollbar();
  48. initMenuItem();
  49. initRightbar();
  50. }
  51. init();
  52. })(jQuery);