mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 12:03:11 +00:00
Allow text drag & drop into text fields
We only have to stop the defualt behaviour in case we drag & drop a file (for uploading)
This commit is contained in:
parent
26a38b12ab
commit
b95643e1a6
1 changed files with 12 additions and 7 deletions
|
@ -26,31 +26,36 @@ class Uploader {
|
||||||
}
|
}
|
||||||
|
|
||||||
dragOver(event) {
|
dragOver(event) {
|
||||||
// Prevent dragover event completely and do nothing with it
|
if (event.dataTransfer.types.includes("Files")) {
|
||||||
// This stops the browser from trying to guess which cursor to show
|
// Prevent dragover event completely and do nothing with it
|
||||||
event.preventDefault();
|
// This stops the browser from trying to guess which cursor to show
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dragEnter(event) {
|
dragEnter(event) {
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
// relatedTarget is the target where we entered the drag from
|
// relatedTarget is the target where we entered the drag from
|
||||||
// when dragging from another window, the target is null, otherwise its a DOM element
|
// when dragging from another window, the target is null, otherwise its a DOM element
|
||||||
if (!event.relatedTarget && event.dataTransfer.types.includes("Files")) {
|
if (!event.relatedTarget && event.dataTransfer.types.includes("Files")) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
this.overlay.classList.add("is-dragover");
|
this.overlay.classList.add("is-dragover");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dragLeave(event) {
|
dragLeave(event) {
|
||||||
event.preventDefault();
|
|
||||||
|
|
||||||
// If relatedTarget is null, that means we are no longer dragging over the page
|
// If relatedTarget is null, that means we are no longer dragging over the page
|
||||||
if (!event.relatedTarget) {
|
if (!event.relatedTarget) {
|
||||||
|
event.preventDefault();
|
||||||
this.overlay.classList.remove("is-dragover");
|
this.overlay.classList.remove("is-dragover");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(event) {
|
drop(event) {
|
||||||
|
if (!event.dataTransfer.types.includes("Files")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.overlay.classList.remove("is-dragover");
|
this.overlay.classList.remove("is-dragover");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue