dbXapp 2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Loading...
Searching...
No Matches
dbx-menu.js
Go to the documentation of this file.
1// window.addEventListener("resize", function() {
2// "use strict"; window.location.reload();
3// });
4
5
6 document.addEventListener("DOMContentLoaded", function(){
7
8
9 /////// Prevent closing from click inside dropdown
10 document.querySelectorAll('.dropdown-menu').forEach(function(element){
11 element.addEventListener('click', function (e) {
12 e.stopPropagation();
13 });
14 })
15
16
17
18 // make it as accordion for smaller screens
19 if (window.innerWidth < 992) {
20
21 // close all inner dropdowns when parent is closed
22 document.querySelectorAll('.navbar .dropdown').forEach(function(everydropdown){
23 everydropdown.addEventListener('hidden.bs.dropdown', function () {
24 // after dropdown is hidden, then find all submenus
25 this.querySelectorAll('.submenu').forEach(function(everysubmenu){
26 // hide every submenu as well
27 everysubmenu.style.display = 'none';
28 });
29 })
30 });
31
32 document.querySelectorAll('.dropdown-menu a').forEach(function(element){
33 element.addEventListener('click', function (e) {
34
35 let nextEl = this.nextElementSibling;
36 if(nextEl && nextEl.classList.contains('submenu')) {
37 // prevent opening link if link needs to open dropdown
38 e.preventDefault();
39 console.log(nextEl);
40 if(nextEl.style.display == 'block'){
41 nextEl.style.display = 'none';
42 } else {
43 nextEl.style.display = 'block';
44 }
45
46 }
47 });
48 })
49 }
50 // end if innerWidth
51
52 });
53 // DOMContentLoaded end