diff options
author | xengineering <me@xengineering.eu> | 2021-12-02 14:29:47 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2021-12-02 14:29:47 +0100 |
commit | 93cb69b7ddaa60b3d3351272eb024027e4b0778b (patch) | |
tree | 431b02e7ec8c19a33303cb50efe1792ae9ecbb93 /js | |
parent | 48fc5da790fe8c39def552bc4d52dc91389cf016 (diff) | |
download | libweb-93cb69b7ddaa60b3d3351272eb024027e4b0778b.tar libweb-93cb69b7ddaa60b3d3351272eb024027e4b0778b.tar.zst libweb-93cb69b7ddaa60b3d3351272eb024027e4b0778b.zip |
Restructure whole Repository
Diffstat (limited to 'js')
-rw-r--r-- | js/xengineering.js | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/js/xengineering.js b/js/xengineering.js deleted file mode 100644 index d82db88..0000000 --- a/js/xengineering.js +++ /dev/null @@ -1,71 +0,0 @@ -/* -vim: shiftwidth=2 tabstop=2 expandtab - -libweb - reusable code for websites - - Copyright (C) 2021 xengineering - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -contact via mail: me@xengineering.eu -*/ - -// define menu state -const MenuState = { - Desktop: "Desktop", - MobileCollapsed: "MobileCollapsed", - MobileExpanded: "MobileExpanded" -} -var state; - -// init menu state and add mediaChange handler -var isMobile = window.matchMedia("(max-aspect-ratio: 14/9)"); -mediaChange(isMobile); -isMobile.addListener(mediaChange) - -function mediaChange(isMobile) { - if (isMobile.matches) { - state = MenuState.MobileCollapsed; - handleState(state); - } else { - state = MenuState.Desktop; - handleState(state); - } -} - -function toggleMenu() { - switch (state) { - case MenuState.MobileCollapsed: - state = MenuState.MobileExpanded; - handleState(state); - break; - case MenuState.MobileExpanded: - state = MenuState.MobileCollapsed; - handleState(state); - break; - } -} - -function handleState(state) { - var items = document.getElementsByTagName("a"); - for(var i=0; i<items.length; i++) { - if (items[i].parentNode.tagName == "NAV") { - if (state == MenuState.MobileCollapsed) { - items[i].style.display = "none"; - } else { - items[i].style.display = "block"; - } - } - } -} |