# HG changeset patch # User Goffi # Date 1592582233 -7200 # Node ID 61f3efd69fc31ac73f089873d21309efc5a5e9cf # Parent 0e4a2e0da4383f9ec1a25ccdd4bd1be5f6e370d2 js (common): prevent default behaviour for drag and drop: we don't want that a file dropped on Libervia open the file diff -r 0e4a2e0da438 -r 61f3efd69fc3 sat_templates/templates/default/static/common.js --- a/sat_templates/templates/default/static/common.js Fri Jun 19 17:57:13 2020 +0200 +++ b/sat_templates/templates/default/static/common.js Fri Jun 19 17:57:13 2020 +0200 @@ -174,3 +174,30 @@ /* adapt height to content, specially useful for iframe */ elt.style.height = elt.contentWindow.document.body.scrollHeight + 80 + 'px'; } + +/* we don't want default behaviour which load a dragged file */ + +window.addEventListener("dragenter", function(e) { + console.log(e.target.tagName + " " + e.target.type); + if (e.target.tagName != "INPUT" || e.target.type != "file") { + e.preventDefault(); + e.dataTransfer.effectAllowed = "none"; + e.dataTransfer.dropEffect = "none"; + } +}, false); + +window.addEventListener("dragover", function(e) { + if (e.target.tagName != "INPUT" || e.target.type != "file") { + e.preventDefault(); + e.dataTransfer.effectAllowed = "none"; + e.dataTransfer.dropEffect = "none"; + } +}); + +window.addEventListener("drop", function(e) { + if (e.target.tagName != "INPUT" || e.target.type != "file") { + e.preventDefault(); + e.dataTransfer.effectAllowed = "none"; + e.dataTransfer.dropEffect = "none"; + } +});