misc.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. (function($) {
  2. 'use strict';
  3. $(function() {
  4. var body = $('body');
  5. var contentWrapper = $('.content-wrapper');
  6. var scroller = $('.container-scroller');
  7. var footer = $('.footer');
  8. var sidebar = $('.sidebar');
  9. //Add active class to nav-link based on url dynamically
  10. //Active class can be hard coded directly in html file also as required
  11. var current = location.pathname.split("/").slice(-1)[0].replace(/^\/|\/$/g, '');
  12. $('.nav li a', sidebar).each(function() {
  13. var $this = $(this);
  14. if (current === "") {
  15. //for root url
  16. if ($this.attr('href').indexOf("index.html") !== -1) {
  17. $(this).parents('.nav-item').last().addClass('active');
  18. if ($(this).parents('.sub-menu').length) {
  19. $(this).closest('.collapse').addClass('show');
  20. $(this).addClass('active');
  21. }
  22. }
  23. } else {
  24. //for other url
  25. if ($this.attr('href').indexOf(current) !== -1) {
  26. $(this).parents('.nav-item').last().addClass('active');
  27. if ($(this).parents('.sub-menu').length) {
  28. $(this).closest('.collapse').addClass('show');
  29. $(this).addClass('active');
  30. }
  31. }
  32. }
  33. })
  34. //Close other submenu in sidebar on opening any
  35. sidebar.on('show.bs.collapse', '.collapse', function() {
  36. sidebar.find('.collapse.show').collapse('hide');
  37. });
  38. //Change sidebar and content-wrapper height
  39. applyStyles();
  40. function applyStyles() {
  41. //Applying perfect scrollbar
  42. if (!body.hasClass("rtl")) {
  43. if ($('.tab-content .tab-pane.scroll-wrapper').length) {
  44. const settingsPanelScroll = new PerfectScrollbar('.settings-panel .tab-content .tab-pane.scroll-wrapper');
  45. }
  46. if ($('.chats').length) {
  47. const chatsScroll = new PerfectScrollbar('.chats');
  48. }
  49. }
  50. }
  51. //checkbox and radios
  52. $(".form-check label,.form-radio label").append('<i class="input-helper"></i>');
  53. //fullscreen
  54. $("#fullscreen-button").on("click", function toggleFullScreen() {
  55. if ((document.fullScreenElement !== undefined && document.fullScreenElement === null) || (document.msFullscreenElement !== undefined && document.msFullscreenElement === null) || (document.mozFullScreen !== undefined && !document.mozFullScreen) || (document.webkitIsFullScreen !== undefined && !document.webkitIsFullScreen)) {
  56. if (document.documentElement.requestFullScreen) {
  57. document.documentElement.requestFullScreen();
  58. } else if (document.documentElement.mozRequestFullScreen) {
  59. document.documentElement.mozRequestFullScreen();
  60. } else if (document.documentElement.webkitRequestFullScreen) {
  61. document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
  62. } else if (document.documentElement.msRequestFullscreen) {
  63. document.documentElement.msRequestFullscreen();
  64. }
  65. } else {
  66. if (document.cancelFullScreen) {
  67. document.cancelFullScreen();
  68. } else if (document.mozCancelFullScreen) {
  69. document.mozCancelFullScreen();
  70. } else if (document.webkitCancelFullScreen) {
  71. document.webkitCancelFullScreen();
  72. } else if (document.msExitFullscreen) {
  73. document.msExitFullscreen();
  74. }
  75. }
  76. })
  77. });
  78. })(jQuery);