Mercurial > libervia-templates
comparison sat_templates/templates/default/static/common.js @ 239:61f3efd69fc3
js (common): prevent default behaviour for drag and drop:
we don't want that a file dropped on Libervia open the file
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Jun 2020 17:57:13 +0200 |
parents | 0e69b5843c2f |
children |
comparison
equal
deleted
inserted
replaced
238:0e4a2e0da438 | 239:61f3efd69fc3 |
---|---|
172 | 172 |
173 function fitHeightToContent(elt) { | 173 function fitHeightToContent(elt) { |
174 /* adapt height to content, specially useful for iframe */ | 174 /* adapt height to content, specially useful for iframe */ |
175 elt.style.height = elt.contentWindow.document.body.scrollHeight + 80 + 'px'; | 175 elt.style.height = elt.contentWindow.document.body.scrollHeight + 80 + 'px'; |
176 } | 176 } |
177 | |
178 /* we don't want default behaviour which load a dragged file */ | |
179 | |
180 window.addEventListener("dragenter", function(e) { | |
181 console.log(e.target.tagName + " " + e.target.type); | |
182 if (e.target.tagName != "INPUT" || e.target.type != "file") { | |
183 e.preventDefault(); | |
184 e.dataTransfer.effectAllowed = "none"; | |
185 e.dataTransfer.dropEffect = "none"; | |
186 } | |
187 }, false); | |
188 | |
189 window.addEventListener("dragover", function(e) { | |
190 if (e.target.tagName != "INPUT" || e.target.type != "file") { | |
191 e.preventDefault(); | |
192 e.dataTransfer.effectAllowed = "none"; | |
193 e.dataTransfer.dropEffect = "none"; | |
194 } | |
195 }); | |
196 | |
197 window.addEventListener("drop", function(e) { | |
198 if (e.target.tagName != "INPUT" || e.target.type != "file") { | |
199 e.preventDefault(); | |
200 e.dataTransfer.effectAllowed = "none"; | |
201 e.dataTransfer.dropEffect = "none"; | |
202 } | |
203 }); |