Welcome to mirror list, hosted at ThFree Co, Russian Federation.

myFunctions.js « js « static - github.com/darshanbaral/kitab.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4e9c671c00a7b8c506d95687374295ace775b911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
window.onclick = function (event) {
  checkClick(event);
};
window.ontouchstart = function (event) {
  checkClick(event);
};

checkClick = function (event) {
  let insideMenu = false;
  Array.from(document.querySelectorAll(".show")).forEach((menu) => {
    insideMenu = insideMenu || menu.contains(event.target);
  });
  if (!insideMenu && !event.target.matches(".hover-menu")) {
    Array.from(document.querySelectorAll(".hover-menu")).forEach(
      (hovermenu) => {
        hovermenu.nextElementSibling.style.maxHeight = "0px";
      }
    );
  }
};
let expandMenu = function (x) {
  Array.from(document.querySelectorAll(".hover-menu")).forEach((hovermenu) => {
    hovermenu.nextElementSibling.style.maxHeight = "0px";
  });
  let thisMenu = x.nextElementSibling;
  thisMenu.style.maxHeight = thisMenu.scrollHeight + "px";
};