aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/dom_events.js
blob: 490d2ece6419c4de141c1e1f89513aaf73a4c3ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const popups = require("./popups");
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("click", (e) => {
	if (e.target.tagName.toLowerCase() === "a"
		&& e.target.protocol != "file:") {

		e.preventDefault();
		shell.openExternal(e.target.href);
	}
})