From 270a135fcab4f1b09c3dd27b6544f766e3982b22 Mon Sep 17 00:00:00 2001 From: Marvin Dalheimer Date: Tue, 13 Aug 2019 08:44:06 +0200 Subject: [PATCH] Add body listener for trigger closing language box --- source/js/languageSelector.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/js/languageSelector.js b/source/js/languageSelector.js index 0ea72e2..3002786 100644 --- a/source/js/languageSelector.js +++ b/source/js/languageSelector.js @@ -5,6 +5,12 @@ if(!isMobile()) { languageSelector = document.getElementsByClassName("language-selector-actual")[0]; moreLanguagesContainer = document.getElementsByClassName("language-selector-more")[0]; + document.body.addEventListener("click", () => { + if (moreLanguagesContainer && !moreLanguagesContainer.classList.contains("hidden")) { + moreLanguagesContainer.classList.add("hidden"); + } + }); + languageSelector && languageSelector.addEventListener("click", e => { e.stopPropagation(); moreLanguagesContainer.classList.toggle("hidden");