mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Provide function callback when file is dropped
- https://stackoverflow.com/questions/6756583/prevent-browser-from-loading-a-drag-and-dropped-file -
This commit is contained in:
parent
dca26b5810
commit
eec0fc34d2
@ -101,6 +101,18 @@
|
||||
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
$('#part-thumb').on('drop', function(event) {
|
||||
|
||||
var transfer = event.originalEvent.dataTransfer;
|
||||
|
||||
var files = transfer.files;
|
||||
|
||||
console.log('dropped');
|
||||
|
||||
//$(this).removeClass('dragover');
|
||||
});
|
||||
|
||||
$("#show-qr-code").click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'part-qr' part.id %}",
|
||||
|
@ -3,6 +3,16 @@ function inventreeDocReady() {
|
||||
* This will be called for every page that extends "base.html"
|
||||
*/
|
||||
|
||||
window.addEventListener("dragover",function(e){
|
||||
e = e || event;
|
||||
e.preventDefault();
|
||||
},false);
|
||||
|
||||
window.addEventListener("drop",function(e){
|
||||
e = e || event;
|
||||
e.preventDefault();
|
||||
},false);
|
||||
|
||||
/* Add drag-n-drop functionality to any element
|
||||
* marked with the class 'dropzone'
|
||||
*/
|
||||
@ -10,7 +20,19 @@ function inventreeDocReady() {
|
||||
$(this).addClass('dragover');
|
||||
});
|
||||
|
||||
$('.dropzone').on('dragleave', function() {
|
||||
$('.dropzone').on('dragleave drop', function() {
|
||||
$(this).removeClass('dragover');
|
||||
});
|
||||
|
||||
// Callback to launch the 'About' window
|
||||
$('#launch-about').click(function() {
|
||||
var modal = $('#modal-about');
|
||||
|
||||
modal.modal({
|
||||
backdrop: 'static',
|
||||
keyboard: 'false',
|
||||
});
|
||||
|
||||
modal.modal('show');
|
||||
});
|
||||
}
|
@ -88,17 +88,6 @@ $(document).ready(function () {
|
||||
* Ref: static/script/inventree/notification.js
|
||||
*/
|
||||
showCachedAlerts();
|
||||
|
||||
$('#launch-about').click(function() {
|
||||
var modal = $('#modal-about');
|
||||
|
||||
modal.modal({
|
||||
backdrop: 'static',
|
||||
keyboard: 'false',
|
||||
});
|
||||
|
||||
modal.modal('show');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user