thrrgilag.net/themes/terminal/source/js/languageSelector.js

19 lines
690 B
JavaScript
Raw Normal View History

2019-09-29 17:31:00 +00:00
const mobileQuery = getComputedStyle(document.body).getPropertyValue("--phoneWidth");
const isMobile = () => window.matchMedia(mobileQuery).matches;
if(!isMobile()) {
languageSelector = document.querySelector(".language-selector-current");
moreLanguagesContainer = document.querySelector(".language-selector__more");
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");
});
}