sidemenu.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. "use strict";
  2. let currentWidth;
  3. (function () {
  4. currentWidth = [window.innerWidth];
  5. var slideMenu = $('.side-menu');
  6. // Toggle Sidebar
  7. $(document).on('click', '[data-bs-toggle="sidebar"]', function (event) {
  8. event.preventDefault();
  9. // $('.app').toggleClass('sidenav-toggled');
  10. if ($('.app').hasClass('sidenav-toggled')) {
  11. $('.app').removeClass('sidenav-toggled');
  12. if ((document.body.classList.contains("double-menu") || document.body.classList.contains("double-menu-tabs")) && !document.body.classList.contains('horizontal')) {
  13. if (document.querySelector('.slide-menu') && window.innerWidth >= 992) {
  14. let slidemenu = document.querySelectorAll('.slide-menu');
  15. slidemenu.forEach(e => {
  16. if (e.classList.contains('double-menu-active')) {
  17. e.classList.remove('double-menu-active')
  18. }
  19. })
  20. let sidemenuActive = document.querySelector('.side-menu__item.active');
  21. if (sidemenuActive?.nextElementSibling) {
  22. let submenu = sidemenuActive.nextElementSibling;
  23. submenu.classList.add('double-menu-active');
  24. document.body.classList.remove('sidenav-toggled');
  25. }
  26. else {
  27. document.body.classList.add('sidenav-toggled');
  28. }
  29. }
  30. }
  31. }
  32. else {
  33. $('.app').addClass('sidenav-toggled');
  34. if (innerWidth >= 992) {
  35. if ((document.body.classList.contains("double-menu") || document.body.classList.contains("double-menu-tabs")) && !document.body.classList.contains('horizontal')) {
  36. if (document.querySelector('.slide-menu')) {
  37. let slidemenu = document.querySelectorAll('.slide-menu');
  38. slidemenu.forEach(e => {
  39. if (e.classList.contains('double-menu-active')) {
  40. e.classList.remove('double-menu-active')
  41. }
  42. })
  43. }
  44. }
  45. }
  46. }
  47. });
  48. responsive();
  49. var toggleSidebar = function () {
  50. var w = $(window);
  51. if (w.outerWidth() <= 1024) {
  52. $("body").addClass("sidebar-gone");
  53. $(document).off("click", "body").on("click", "body", function (e) {
  54. if ($(e.target).hasClass('sidebar-show') || $(e.target).hasClass('search-show')) {
  55. $("body").removeClass("sidebar-show");
  56. $("body").addClass("sidebar-gone");
  57. $("body").removeClass("search-show");
  58. }
  59. });
  60. } else {
  61. $("body").removeClass("sidebar-gone");
  62. }
  63. }
  64. toggleSidebar();
  65. $(window).resize(toggleSidebar);
  66. //sticky-header
  67. $(window).on("scroll", function (e) {
  68. if ($(window).scrollTop() >= 70) {
  69. $('.app-header').addClass('fixed-header');
  70. $('.app-header').addClass('visible-title');
  71. } else {
  72. $('.app-header').removeClass('fixed-header');
  73. $('.app-header').removeClass('visible-title');
  74. }
  75. });
  76. $(window).on("scroll", function (e) {
  77. if ($(window).scrollTop() >= 70) {
  78. $('.horizontal-main').addClass('fixed-header');
  79. $('.horizontal-main').addClass('visible-title');
  80. } else {
  81. $('.horizontal-main').removeClass('fixed-header');
  82. $('.horizontal-main').removeClass('visible-title');
  83. }
  84. });
  85. //p-scroll
  86. const ps = new PerfectScrollbar('.app-sidebar', {
  87. useBothWheelAxes: true,
  88. suppressScrollX: true,
  89. suppressScrollY: false,
  90. });
  91. //sticky-header
  92. $(window).on("scroll", function (e) {
  93. if ($(window).scrollTop() >= 70) {
  94. $('.app-header').addClass('fixed-header');
  95. $('.app-header').addClass('visible-title');
  96. }
  97. else {
  98. $('.app-header').removeClass('fixed-header');
  99. $('.app-header').removeClass('visible-title');
  100. }
  101. });
  102. HorizontalHovermenu();
  103. // for Icon-text Menu
  104. //icontext();
  105. // default layout
  106. hovermenu();
  107. ActiveSubmenu();
  108. })();
  109. function responsive() {
  110. const mediaQuery = window.innerWidth;
  111. currentWidth.push(mediaQuery);
  112. if (currentWidth.length > 2) { currentWidth.shift() }
  113. if (currentWidth.length > 1) {
  114. if ((currentWidth[currentWidth.length - 1] < 992) && (currentWidth[currentWidth.length - 2] >= 992)) {
  115. // less than 992
  116. }
  117. if ((currentWidth[currentWidth.length - 1] >= 992) && (currentWidth[currentWidth.length - 2] < 992)) {
  118. // greater than 992
  119. if (document.body.classList.contains("double-menu") || document.body.classList.contains("double-menu-tabs")) {
  120. document.body.classList.remove("sidenav-toggled");
  121. }
  122. }
  123. }
  124. }
  125. function hovermenu() {
  126. $(".app-sidebar").hover(function () {
  127. if ($('.app').hasClass('sidenav-toggled')) {
  128. $('.app').addClass('sidenav-toggled-open');
  129. }
  130. }, function () {
  131. if ($('.app').hasClass('sidenav-toggled')) {
  132. $('.app').removeClass('sidenav-toggled-open');
  133. }
  134. });
  135. }// ______________ICON-OVERLAY JS start
  136. function iconoverlay() {
  137. $(document).on('click', ".app-content", function (event) {
  138. $('body').removeClass('sidenav-toggled-open');
  139. });
  140. //Mobile menu
  141. var alterClass = function () {
  142. var ww = document.body.clientWidth;
  143. if (ww < 992) {
  144. $('body').removeClass('sidenav-toggled');
  145. } else if (ww >= 991 && !(document.querySelector('.horizontal') !== null)) {
  146. $('body').addClass('sidenav-toggled');
  147. };
  148. };
  149. $(window).resize(function () {
  150. alterClass();
  151. });
  152. //Fire it when the page first loads:
  153. alterClass();
  154. }
  155. // ______________ICON-OVERLAY JS end
  156. // ______________ICON-TEXT JS start
  157. function icontext() {
  158. $(".app-sidebar").off("mouseenter mouseleave");
  159. $(document).on('click', ".app-sidebar", function (event) {
  160. if ($('body').hasClass('sidenav-toggled') == true) {
  161. $('body').addClass('sidenav-toggled-open');
  162. }
  163. });
  164. $(document).on('click', ".main-content", function (event) {
  165. $('body').removeClass('sidenav-toggled-open');
  166. });
  167. }
  168. function doubleLayoutFn() {
  169. doublemenu();
  170. ActiveSubmenu();
  171. if (document.querySelector('.slide-menu') && innerWidth >= 992) {
  172. let sidemenuActive = document.querySelector('.side-menu__item.is-expanded');
  173. if (sidemenuActive?.nextElementSibling) {
  174. document.body.classList.remove('sidenav-toggled');
  175. }
  176. let doubleActive = document.querySelectorAll('.double-menu-active');
  177. if (doubleActive.length) {
  178. doubleActive.forEach(e => e.classList.remove('double-menu-active'))
  179. }
  180. }
  181. }
  182. // ______________DOUBLE-MENU JS start
  183. function doublemenu() {
  184. if (innerWidth >= 992) {
  185. $(".app-sidebar").off("mouseenter mouseleave");
  186. document.body.classList.remove('sidenav-toggled')
  187. }
  188. }
  189. // ______________DOUBLE-MENU JS end
  190. //________________Horizontal js
  191. jQuery(function () {
  192. 'use strict';
  193. document.addEventListener("touchstart", function () { }, false);
  194. jQuery(function () {
  195. jQuery('body').wrapInner('<div class="horizontalMenucontainer" />');
  196. });
  197. }());
  198. // To remove expanded menu on click 'body'
  199. $(document).on('click', '.horizontal-content', function () {
  200. $(".app-sidebar li a").each(function () {
  201. $(this).next().slideUp(300, function () {
  202. $(this).next().removeClass('open');
  203. });
  204. $(this).parent("li").removeClass("is-expanded");
  205. })
  206. })
  207. // page load active menu
  208. setTimeout(() => {
  209. if ($('.slide-item').hasClass('active')) {
  210. $('.app-sidebar').animate({
  211. scrollTop: $('a.slide-item.active').offset().top - 600
  212. }, 600);
  213. }
  214. if ($('.sub-side-menu__item').hasClass('active')) {
  215. $('.app-sidebar').animate({
  216. scrollTop: $('a.sub-side-menu__item.active').offset().top - 600
  217. }, 600);
  218. }
  219. }, 200);
  220. let slideLeft = document.querySelector(".slide-left");
  221. let slideRight = document.querySelector(".slide-right");
  222. slideLeft.addEventListener("click", e => slideClick(), true)
  223. slideRight.addEventListener("click", e => slideClick(), true)
  224. // used to remove is-expanded class and remove class on clicking arrow buttons
  225. function slideClick() {
  226. let slide = document.querySelectorAll(".slide");
  227. let slideMenu = document.querySelectorAll(".slide-menu");
  228. slide.forEach((element, index) => {
  229. if (element.classList.contains("is-expanded") == true) {
  230. element.classList.remove("is-expanded")
  231. }
  232. });
  233. slideMenu.forEach((element, index) => {
  234. if (element.classList.contains("open") == true) {
  235. element.classList.remove("open");
  236. element.style.display = "none";
  237. }
  238. });
  239. }
  240. // horizontal arrows
  241. var sideMenu = $(".side-menu");
  242. var slide = "100px";
  243. let menuWidth = document.querySelector('.horizontal-main')
  244. let menuItems = document.querySelector('.side-menu')
  245. var prevWidth = []
  246. $(window).resize(
  247. () => {
  248. let menuWidth = document.querySelector('.horizontal-main');
  249. let menuItems = document.querySelector('.side-menu');
  250. let mainSidemenuWidth = document.querySelector('.main-sidemenu');
  251. let menuContainerWidth = menuWidth?.offsetWidth - mainSidemenuWidth?.offsetWidth;
  252. let marginLeftValue = Math.ceil(window.getComputedStyle(menuItems).marginLeft.split('px')[0]);
  253. let marginRightValue = Math.ceil(window.getComputedStyle(menuItems).marginRight.split('px')[0]);
  254. let check = menuItems.scrollWidth + (0 - menuWidth?.offsetWidth) + menuContainerWidth;
  255. // to check and adjst the menu on screen size change
  256. if ($('body').hasClass('ltr')) {
  257. if (marginLeftValue >= -check == false && (menuWidth?.offsetWidth - menuContainerWidth) < menuItems.scrollWidth) {
  258. sideMenu.stop(false, true).animate({
  259. marginLeft: -check
  260. }, {
  261. duration: 400
  262. })
  263. }
  264. else {
  265. sideMenu.stop(false, true).animate({
  266. marginLeft: 0
  267. }, {
  268. duration: 400
  269. })
  270. }
  271. }
  272. else {
  273. if (marginRightValue > -check == false && menuWidth?.offsetWidth < menuItems.scrollWidth) {
  274. sideMenu.stop(false, true).animate({
  275. marginRight: -check
  276. }, {
  277. duration: 400
  278. })
  279. }
  280. else {
  281. sideMenu.stop(false, true).animate({
  282. marginRight: 0
  283. }, {
  284. duration: 400
  285. })
  286. }
  287. }
  288. checkHoriMenu();
  289. responsive();
  290. HorizontalHovermenu();
  291. prevWidth.push(window.innerWidth)
  292. if (prevWidth.length > 3) {
  293. prevWidth.shift()
  294. }
  295. let prevValue = prevWidth[prevWidth.length - 2];
  296. if (window.innerWidth >= 992 && prevValue < 992) {
  297. if (document.querySelector('body').classList.contains('horizontal')) {
  298. let li = document.querySelectorAll('.side-menu li')
  299. li.forEach((e, i) => {
  300. e.classList.remove('is-expanded')
  301. })
  302. var animationSpeed = 300;
  303. // first level
  304. var parent = $("[data-bs-toggle='sub-slide']").parents('ul');
  305. var ul = parent.find('ul.slide-menu:visible').slideUp(animationSpeed);
  306. ul.removeClass('open');
  307. var parent1 = $("[data-bs-toggle='sub-slide2']").parents('ul');
  308. var ul1 = parent1.find('ul.sub-slide-menu:visible').slideUp(animationSpeed);
  309. ul1.removeClass('open');
  310. document.body.classList.remove('sidenav-toggled');
  311. }
  312. }
  313. else {
  314. ActiveSubmenu();
  315. }
  316. }
  317. )
  318. function ActiveSubmenu() {
  319. var position = window.location.pathname.split('/');
  320. position = position[position.length - 1];
  321. $(".app-sidebar li a").each(function () {
  322. var $this = $(this);
  323. var pageUrl = $this.attr("href");
  324. let prevValue = [window.innerWidth];
  325. if (prevValue.length > 1) {
  326. prevValue = prevWidth[prevWidth.length - 2];
  327. }
  328. if (pageUrl === position) {
  329. setTimeout(() => {
  330. if ($this.closest('.sub-slide-menu2')) {
  331. $this.closest('.sub-slide-menu2').addClass('open');
  332. if (!document.querySelector('body').classList.contains('horizontal') || window.innerWidth < 992) {
  333. $this.closest('.sub-slide-menu2').slideDown();
  334. }
  335. $this.closest('.sub-slide-menu2').prev().addClass('active');
  336. $this.closest('.sub-slide-menu2').parent().addClass('is-expanded');
  337. }
  338. if ($this.closest('.sub-slide-menu')) {
  339. $this.closest('.sub-slide-menu').addClass('open');
  340. if (!document.querySelector('body').classList.contains('horizontal') || window.innerWidth < 992) {
  341. $this.closest('.sub-slide-menu').slideDown();
  342. }
  343. $this.closest('.sub-slide-menu').parent().addClass('is-expanded');
  344. $this.closest('.sub-slide-menu').prev().addClass('active');
  345. }
  346. if ($this.closest('.slide-menu')) {
  347. $this.closest('.slide-menu').addClass('open');
  348. if (!document.querySelector('body').classList.contains('horizontal') || window.innerWidth < 992) {
  349. $this.closest('.slide-menu').slideDown();
  350. }
  351. $this.closest('.slide-menu').parent().addClass('is-expanded');
  352. $this.closest('.slide-menu').prev().addClass('active');
  353. }
  354. $this.addClass('active');
  355. $this.parent().addClass('active');
  356. if (document.body.classList.contains('double-menu-tabs') || document.body.classList.contains('double-menu')) {
  357. if ($this.closest('.slide-menu').length) {
  358. $this.closest('.slide-menu').addClass('double-menu-active');
  359. }
  360. else {
  361. let slideMenu = document.querySelectorAll('.slide-menu'),
  362. slideNavStatus = false;
  363. slideMenu.forEach(e => {
  364. if(e.classList.contains('double-menu-active')){
  365. slideNavStatus = true;
  366. }
  367. })
  368. if(!slideNavStatus){
  369. document.body.classList.add('sidenav-toggled');
  370. }
  371. }
  372. }
  373. }, 200);
  374. }
  375. });
  376. }
  377. function checkHoriMenu() {
  378. let menuWidth = document.querySelector('.horizontal-main')
  379. let menuItems = document.querySelector('.side-menu')
  380. let mainSidemenuWidth = document.querySelector('.main-sidemenu')
  381. let menuContainerWidth = menuWidth?.offsetWidth - mainSidemenuWidth?.offsetWidth
  382. let marginLeftValue = Math.ceil(window.getComputedStyle(menuItems).marginLeft.split('px')[0]);
  383. let marginRightValue = Math.ceil(window.getComputedStyle(menuItems).marginRight.split('px')[0]);
  384. let check = menuItems.scrollWidth + (0 - menuWidth?.offsetWidth) + menuContainerWidth;
  385. if ($('body').hasClass('ltr')) {
  386. menuItems.style.marginRight = 0
  387. }
  388. else {
  389. menuItems.style.marginLeft = 0;
  390. }
  391. setTimeout(() => {
  392. if (menuItems.scrollWidth - 2 < (menuWidth?.offsetWidth - menuContainerWidth)) {
  393. $("#slide-right").addClass("d-none");
  394. $("#slide-left").addClass("d-none");
  395. }
  396. else if (marginLeftValue != 0) {
  397. $("#slide-left").removeClass("d-none");
  398. }
  399. else if (marginLeftValue != -check) {
  400. $("#slide-right").removeClass("d-none");
  401. }
  402. else if (marginRightValue != 0) {
  403. $("#slide-left").removeClass("d-none");
  404. }
  405. else if (marginRightValue != -check) {
  406. $("#slide-right").removeClass("d-none");
  407. }
  408. if (marginLeftValue == 0 || marginRightValue == 0) {
  409. $("#slide-left").addClass("d-none");
  410. $("#slide-right").removeClass("d-none");
  411. }
  412. }, 200)
  413. }
  414. checkHoriMenu();
  415. $(document).on("click", ".ltr #slide-left", function () {
  416. let menuWidth = document.querySelector('.horizontal-main')
  417. let menuItems = document.querySelector('.side-menu')
  418. let mainSidemenuWidth = document.querySelector('.main-sidemenu')
  419. let menuContainerWidth = menuWidth?.offsetWidth - mainSidemenuWidth?.offsetWidth
  420. let marginLeftValue = Math.ceil(window.getComputedStyle(menuItems).marginLeft.split('px')[0]) + 100;
  421. if (marginLeftValue < 0) {
  422. sideMenu.stop(false, true).animate({
  423. marginLeft: "+=" + slide
  424. }, {
  425. duration: 400
  426. })
  427. if ((menuWidth?.offsetWidth - menuContainerWidth) < menuItems.scrollWidth) {
  428. $("#slide-right").removeClass("d-none");
  429. }
  430. }
  431. else {
  432. $("#slide-left").addClass("d-none");
  433. $("#slide-right").removeClass("d-none");
  434. }
  435. if (marginLeftValue >= 0) {
  436. sideMenu.stop(false, true).animate({
  437. marginLeft: 0
  438. }, {
  439. duration: 400
  440. })
  441. if (menuWidth?.offsetWidth < menuItems.scrollWidth) {
  442. // $("#slide-left").addClass("d-none");
  443. }
  444. }
  445. // to remove dropdown when clicking arrows in horizontal menu
  446. let subNavSub = document.querySelectorAll('.sub-nav-sub');
  447. subNavSub.forEach((e) => {
  448. e.style.display = '';
  449. })
  450. let subNav = document.querySelectorAll('.nav-sub')
  451. subNav.forEach((e) => {
  452. e.style.display = '';
  453. })
  454. //
  455. });
  456. $(document).on("click", ".ltr #slide-right", function () {
  457. let menuWidth = document.querySelector('.app-sidebar')
  458. let menuItems = document.querySelector('.side-menu')
  459. let mainSidemenuWidth = document.querySelector('.main-sidemenu')
  460. let menuContainerWidth = menuWidth?.offsetWidth - mainSidemenuWidth?.offsetWidth
  461. let marginLeftValue = Math.ceil(window.getComputedStyle(menuItems).marginLeft.split('px')[0]) - 100;
  462. let check = menuItems.scrollWidth + (0 - menuWidth?.offsetWidth) + menuContainerWidth;
  463. if (marginLeftValue > -check) {
  464. sideMenu.stop(false, true).animate({
  465. // marginLeft : 0,
  466. marginLeft: "-=" + slide,
  467. marginRight: 0,
  468. }, {
  469. duration: 400
  470. })
  471. }
  472. else {
  473. sideMenu.stop(false, true).animate({
  474. // marginLeft : 0,
  475. marginRight: 0,
  476. marginLeft: -check
  477. }, {
  478. duration: 400
  479. });
  480. $("#slide-right").addClass("d-none");
  481. }
  482. if (marginLeftValue != 0) {
  483. $("#slide-left").removeClass("d-none");
  484. }
  485. // to remove dropdown when clicking arrows in horizontal menu
  486. let subNavSub = document.querySelectorAll('.sub-nav-sub');
  487. subNavSub.forEach((e) => {
  488. e.style.display = '';
  489. })
  490. let subNav = document.querySelectorAll('.nav-sub')
  491. subNav.forEach((e) => {
  492. e.style.display = '';
  493. })
  494. //
  495. });
  496. $(document).on("click", ".rtl #slide-left", function () {
  497. let menuWidth = document.querySelector('.horizontal-main')
  498. let menuItems = document.querySelector('.side-menu')
  499. let mainSidemenuWidth = document.querySelector('.main-sidemenu')
  500. let menuContainerWidth = menuWidth?.offsetWidth - mainSidemenuWidth?.offsetWidth
  501. let marginRightValue = Math.ceil(window.getComputedStyle(menuItems).marginRight.split('px')[0]) + 100;
  502. if (marginRightValue < 0) {
  503. sideMenu.stop(false, true).animate({
  504. // marginRight : 0,
  505. marginLeft: 0,
  506. marginRight: "+=" + slide
  507. }, {
  508. duration: 400
  509. })
  510. if ((menuWidth?.offsetWidth - menuContainerWidth) < menuItems.scrollWidth) {
  511. $("#slide-right").removeClass("d-none");
  512. }
  513. }
  514. else {
  515. $("#slide-left").addClass("d-none");
  516. }
  517. if (marginRightValue >= 0) {
  518. $("#slide-left").addClass("d-none");
  519. sideMenu.stop(false, true).animate({
  520. // marginRight : 0,
  521. marginLeft: 0
  522. }, {
  523. duration: 400
  524. })
  525. }
  526. // to remove dropdown when clicking arrows in horizontal menu
  527. let subNavSub = document.querySelectorAll('.sub-nav-sub');
  528. subNavSub.forEach((e) => {
  529. e.style.display = '';
  530. })
  531. let subNav = document.querySelectorAll('.nav-sub')
  532. subNav.forEach((e) => {
  533. e.style.display = '';
  534. })
  535. //
  536. });
  537. $(document).on("click", ".rtl #slide-right", function () {
  538. let menuWidth = document.querySelector('.app-sidebar')
  539. let menuItems = document.querySelector('.side-menu')
  540. let mainSidemenuWidth = document.querySelector('.main-sidemenu')
  541. let menuContainerWidth = menuWidth?.offsetWidth - mainSidemenuWidth?.offsetWidth
  542. let marginRightValue = Math.ceil(window.getComputedStyle(menuItems).marginRight.split('px')[0]) - 100;
  543. let check = menuItems.scrollWidth + (0 - menuWidth?.offsetWidth) + menuContainerWidth;
  544. if (marginRightValue > -check) {
  545. sideMenu.stop(false, true).animate({
  546. // marginLeft : 0,
  547. marginLeft: 0,
  548. marginRight: "-=" + slide
  549. }, {
  550. duration: 400
  551. })
  552. }
  553. else {
  554. sideMenu.stop(false, true).animate({
  555. // marginLeft : 0,
  556. marginLeft: 0,
  557. marginRight: -check
  558. }, {
  559. duration: 400
  560. })
  561. $("#slide-right").addClass("d-none");
  562. }
  563. if (marginRightValue != 0) {
  564. $("#slide-left").removeClass("d-none");
  565. }
  566. // to remove dropdown when clicking arrows in horizontal menu
  567. let subNavSub = document.querySelectorAll('.sub-nav-sub');
  568. subNavSub.forEach((e) => {
  569. e.style.display = '';
  570. })
  571. let subNav = document.querySelectorAll('.nav-sub')
  572. subNav.forEach((e) => {
  573. e.style.display = '';
  574. })
  575. });
  576. function menuClick() {
  577. $("[data-bs-toggle='slide']").off('click');
  578. $("[data-bs-toggle='sub-slide']").off('click')
  579. $("[data-bs-toggle='sub-slide2']").off('click')
  580. $("[data-bs-toggle='slide']").on('click', function (e) {
  581. var $this = $(this);
  582. var checkElement = $this.next();
  583. var animationSpeed = 300,
  584. slideMenuSelector = '.slide-menu';
  585. if (checkElement.is(slideMenuSelector) && checkElement.is(':visible')) {
  586. checkElement.slideUp(animationSpeed, function () {
  587. checkElement.removeClass('open');
  588. });
  589. checkElement.parent("li").removeClass("is-expanded");
  590. }
  591. else if ((checkElement.is(slideMenuSelector)) && (!checkElement.is(':visible'))) {
  592. var parent = $this.parents('ul').first();
  593. var ul = parent.find('ul[class^="slide-menu"]:visible').slideUp(animationSpeed);
  594. ul.removeClass('open');
  595. var parent_li = $this.parent("li");
  596. checkElement.slideDown(animationSpeed, function () {
  597. checkElement.addClass('open');
  598. parent.find('li.is-expanded').removeClass('is-expanded');
  599. parent_li.addClass('is-expanded');
  600. });
  601. }
  602. if (checkElement.is(slideMenuSelector)) {
  603. e.preventDefault();
  604. }
  605. if (window.innerWidth >= 992) {
  606. if (!checkElement.hasClass('double-menu-active') && !document.body.classList.contains('horizontal') && (document.body.classList.contains('double-menu') || document.body.classList.contains('double-menu-tabs'))) {
  607. if (document.querySelector('.slide-menu')) {
  608. let slidemenu = document.querySelectorAll('.slide-menu');
  609. slidemenu.forEach(e => {
  610. if (e.classList.contains('double-menu-active')) {
  611. e.classList.remove('double-menu-active')
  612. }
  613. })
  614. }
  615. checkElement.addClass('double-menu-active');
  616. document.body.classList.remove("sidenav-toggled")
  617. }
  618. }
  619. });
  620. // Activate sidebar slide toggle
  621. $("[data-bs-toggle='sub-slide']").on('click', function (e) {
  622. var $this = $(this);
  623. var checkElement = $this.next();
  624. var animationSpeed = 300,
  625. slideMenuSelector = '.sub-slide-menu';
  626. if (checkElement.is(slideMenuSelector) && checkElement.is(':visible')) {
  627. checkElement.slideUp(animationSpeed, function () {
  628. checkElement.removeClass('open');
  629. });
  630. checkElement.parent("li").removeClass("is-expanded");
  631. }
  632. else if ((checkElement.is(slideMenuSelector)) && (!checkElement.is(':visible'))) {
  633. var parent = $this.parents('ul').first();
  634. var ul = parent.find('ul[class^="sub-slide-menu"]:visible').slideUp(animationSpeed);
  635. ul.removeClass('open');
  636. var parent_li = $this.parent("li");
  637. checkElement.slideDown(animationSpeed, function () {
  638. checkElement.addClass('open');
  639. parent.find('li.is-expanded').removeClass('is-expanded');
  640. parent_li.addClass('is-expanded');
  641. });
  642. }
  643. if (checkElement.is(slideMenuSelector)) {
  644. e.preventDefault();
  645. }
  646. });
  647. // Activate sidebar slide toggle
  648. $("[data-bs-toggle='sub-slide2']").on('click', function (e) {
  649. var $this = $(this);
  650. var checkElement = $this.next();
  651. var animationSpeed = 300,
  652. slideMenuSelector = '.sub-slide-menu2';
  653. if (checkElement.is(slideMenuSelector) && checkElement.is(':visible')) {
  654. checkElement.slideUp(animationSpeed, function () {
  655. checkElement.removeClass('open');
  656. });
  657. checkElement.parent("li").removeClass("is-expanded");
  658. }
  659. else if ((checkElement.is(slideMenuSelector)) && (!checkElement.is(':visible'))) {
  660. var parent = $this.parents('ul').first();
  661. var ul = parent.find('ul[class^="sub-slide-menu"]:visible').slideUp(animationSpeed);
  662. ul.removeClass('open');
  663. var parent_li = $this.parent("li");
  664. checkElement.slideDown(animationSpeed, function () {
  665. checkElement.addClass('open');
  666. parent.find('li.is-expanded').removeClass('is-expanded');
  667. parent_li.addClass('is-expanded');
  668. });
  669. }
  670. if (checkElement.is(slideMenuSelector)) {
  671. e.preventDefault();
  672. }
  673. });
  674. }
  675. function HorizontalHovermenu() {
  676. let value = document.querySelector('body').classList.contains('horizontal-hover')
  677. if (value && window.innerWidth >= 992) {
  678. $("[data-bs-toggle='slide']").off('click');
  679. $("[data-bs-toggle='sub-slide']").off('click')
  680. $("[data-bs-toggle='sub-slide2']").off('click')
  681. slideClick()
  682. }
  683. else {
  684. menuClick();
  685. }
  686. }
  687. document.querySelector('.main-content').addEventListener('click', () => {
  688. if (document.querySelector('body').classList.contains('horizontal')) {
  689. let li = document.querySelectorAll('.side-menu li')
  690. li.forEach((e, i) => {
  691. e.classList.remove('is-expanded')
  692. })
  693. var animationSpeed = 300;
  694. // first level
  695. var parent = $("[data-bs-toggle='sub-slide']").parents('ul');
  696. var ul = parent.find('ul:visible').slideUp(animationSpeed);
  697. ul.removeClass('open');
  698. var parent1 = $("[data-bs-toggle='sub-slide2']").parents('ul');
  699. var ul1 = parent1.find('ul:visible').slideUp(animationSpeed);
  700. ul1.removeClass('open');
  701. }
  702. }, true)