You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
734 B

4 years ago
  1. const mobileQuery = getComputedStyle(document.body).getPropertyValue("--phoneWidth");
  2. const isMobile = () => window.matchMedia(mobileQuery).matches;
  3. const languageSelector = document.querySelector(".language-selector-current");
  4. const moreLanguagesContainer = document.querySelector(".language-selector__more");
  5. document.body.addEventListener("click", () => {
  6. if (
  7. !isMobile() &&
  8. moreLanguagesContainer &&
  9. !moreLanguagesContainer.classList.contains("hidden")
  10. ) {
  11. moreLanguagesContainer.classList.add("hidden");
  12. }
  13. });
  14. languageSelector &&
  15. languageSelector.addEventListener("click", (e) => {
  16. if (!isMobile()) {
  17. e.stopPropagation();
  18. moreLanguagesContainer.classList.toggle("hidden");
  19. }
  20. });