aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/dom_events.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/js/dom_events.js')
-rw-r--r--src/app/js/dom_events.js42
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..c16a838
--- /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);
+ }
+})