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 js_ready %}
|
||||||
{{ block.super }}
|
{{ 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() {
|
$("#show-qr-code").click(function() {
|
||||||
launchModalForm(
|
launchModalForm(
|
||||||
"{% url 'part-qr' part.id %}",
|
"{% url 'part-qr' part.id %}",
|
||||||
|
@ -3,6 +3,16 @@ function inventreeDocReady() {
|
|||||||
* This will be called for every page that extends "base.html"
|
* 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
|
/* Add drag-n-drop functionality to any element
|
||||||
* marked with the class 'dropzone'
|
* marked with the class 'dropzone'
|
||||||
*/
|
*/
|
||||||
@ -10,7 +20,19 @@ function inventreeDocReady() {
|
|||||||
$(this).addClass('dragover');
|
$(this).addClass('dragover');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.dropzone').on('dragleave', function() {
|
$('.dropzone').on('dragleave drop', function() {
|
||||||
$(this).removeClass('dragover');
|
$(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
|
* Ref: static/script/inventree/notification.js
|
||||||
*/
|
*/
|
||||||
showCachedAlerts();
|
showCachedAlerts();
|
||||||
|
|
||||||
$('#launch-about').click(function() {
|
|
||||||
var modal = $('#modal-about');
|
|
||||||
|
|
||||||
modal.modal({
|
|
||||||
backdrop: 'static',
|
|
||||||
keyboard: 'false',
|
|
||||||
});
|
|
||||||
|
|
||||||
modal.modal('show');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user