diff options
Diffstat (limited to 'static/js/khata.js')
-rw-r--r-- | static/js/khata.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/static/js/khata.js b/static/js/khata.js new file mode 100644 index 0000000..b5a56e4 --- /dev/null +++ b/static/js/khata.js @@ -0,0 +1,30 @@ +let toggleHeight = function(elem) { + if (getComputedStyle(elem)["height"] === "0px") { + elem.style.maxHeight = elem.scrollHeight + "px"; + } else { + elem.style.maxHeight = "0px"; + } +}; +let toggleDisplay = function(elem) { + elem.classList.toggle("d-none"); +}; +let zeroHeight = function(elem) { + elem.style.maxHeight = "0px"; +}; +let checkClick = function() { + if (!document.querySelector(".dropdown").contains(event.target)) { + zeroHeight(document.querySelector(".dropdown-content")); + } + if ( + window.matchMedia("(max-width: 750px)").matches && + !document.querySelector("nav").contains(event.target) + ) { + document.querySelector(".all-menu").classList.add("d-none"); + } +}; +window.onclick = function() { + checkClick(); +}; +window.ontouchstart = function() { + checkClick(); +}; |