diff options
author | 0neGal <mail@0negal.com> | 2024-06-08 18:02:48 +0200 |
---|---|---|
committer | 0neGal <mail@0negal.com> | 2024-06-08 18:02:48 +0200 |
commit | dbd8c6b152acc1188d2edd288488aa2da8f6310b (patch) | |
tree | ef5a1752e845a274c889ee18207c3a25e8290b23 /src/app/js/dom_events.js | |
parent | 3904a4492f72ef9a9fd531c0b81f3711541c97e0 (diff) | |
download | Viper-dbd8c6b152acc1188d2edd288488aa2da8f6310b.tar.gz Viper-dbd8c6b152acc1188d2edd288488aa2da8f6310b.zip |
initial commit to better modularize frontend
Far from done, but this pretty much splits everything inside
`src/app/main.js` into separate files.
Diffstat (limited to 'src/app/js/dom_events.js')
-rw-r--r-- | src/app/js/dom_events.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/app/js/dom_events.js b/src/app/js/dom_events.js new file mode 100644 index 0000000..73e9998 --- /dev/null +++ b/src/app/js/dom_events.js @@ -0,0 +1,42 @@ +const settings = require("./settings"); + +let drag_timer; +document.addEventListener("dragover", (e) => { + e.preventDefault(); + e.stopPropagation(); + dragUI.classList.add("shown"); + + clearTimeout(drag_timer); + drag_timer = setTimeout(() => { + dragUI.classList.remove("shown"); + }, 5000) +}) + +document.addEventListener("mouseover", () => { + clearTimeout(drag_timer); + dragUI.classList.remove("shown"); +}) + +document.addEventListener("drop", (e) => { + e.preventDefault(); + e.stopPropagation(); + + dragUI.classList.remove("shown"); + mods.install_from_path(e.dataTransfer.files[0].path); +}) + +document.body.addEventListener("keyup", (e) => { + if (e.key == "Escape") { + Browser.toggle(false); + settings.popup.toggle(false); + } +}) + +document.body.addEventListener("click", (e) => { + if (e.target.tagName.toLowerCase() === "a" + && e.target.protocol != "file:") { + + e.preventDefault(); + shell.openExternal(e.target.href); + } +}) |