.
This commit is contained in:
@@ -28,6 +28,26 @@
|
|||||||
|
|
||||||
document.addEventListener('drop', function (e) { e.preventDefault(); }, false);
|
document.addEventListener('drop', function (e) { e.preventDefault(); }, false);
|
||||||
|
|
||||||
|
function extendInputs(n) {
|
||||||
|
// Makes sure we have n inputs available
|
||||||
|
inputs = $("#rapid-form input[type=file][id^=id_images-]");
|
||||||
|
//fileInput = document.getElementById("id_images-0-image");
|
||||||
|
|
||||||
|
// Make sure we have enough input targets
|
||||||
|
input_diff = (n - inputs.length)
|
||||||
|
console.log("diff", input_diff)
|
||||||
|
|
||||||
|
if (input_diff > 0) {
|
||||||
|
for (let j = 0; j < input_diff; j++) {
|
||||||
|
add_input_form()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need to make sure we include the new ones...
|
||||||
|
inputs = $("#rapid-form input[type=file][id^=id_images-]");
|
||||||
|
}
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
|
||||||
function add_input_form() {
|
function add_input_form() {
|
||||||
var form_idx = $('#id_images-TOTAL_FORMS').val();
|
var form_idx = $('#id_images-TOTAL_FORMS').val();
|
||||||
$('#image_form_set').append($($('#empty_form').html().replace(/__prefix__/g, form_idx)).on("change", input_change));
|
$('#image_form_set').append($($('#empty_form').html().replace(/__prefix__/g, form_idx)).on("change", input_change));
|
||||||
@@ -126,21 +146,7 @@
|
|||||||
$(evt.target).removeClass("drop-target-active");
|
$(evt.target).removeClass("drop-target-active");
|
||||||
|
|
||||||
// Get all input elements
|
// Get all input elements
|
||||||
inputs = $("#rapid-form input[type=file][id^=id_images-]");
|
inputs = extendInputs(evt.dataTransfer.files.length);
|
||||||
//fileInput = document.getElementById("id_images-0-image");
|
|
||||||
|
|
||||||
// Make sure we have enough input targets
|
|
||||||
input_diff = (evt.dataTransfer.files.length - inputs.length)
|
|
||||||
console.log("diff", input_diff)
|
|
||||||
|
|
||||||
if (input_diff > 0) {
|
|
||||||
for (let j = 0; j < input_diff; j++) {
|
|
||||||
add_input_form()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Need to make sure we include the new ones...
|
|
||||||
inputs = $("#rapid-form input[type=file][id^=id_images-]");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through each dropped file and try to assign to an
|
// Loop through each dropped file and try to assign to an
|
||||||
// input element
|
// input element
|
||||||
|
|||||||
Reference in New Issue
Block a user