const MAXSIZE = 15*1024*1024; // 5MB size limit
+ let num_images = 0;
+
ns.add_files = function(target) {
let files = [];
for (var i = 0; i < target.files.length; i++) {
ns.reload_images = function() {
kivi.FileDB.retrieve_all((data) => {
$('#stored-images').empty();
+ num_images = data.length;
+
data.forEach(ns.create_thumb_row);
+ ns.set_image_button_enabled();
});
};
let $row = $(event.target).closest(".image-upload-row");
kivi.FileDB.delete_key(key, () => {
$row.remove();
+ num_images--;
+ ns.set_image_button_enabled();
});
};
+ ns.set_image_button_enabled = function() {
+ $('#upload_images_submit').attr("disabled", num_images == 0 || !$('#object_id').val());
+ };
+
+
ns.upload_files = function() {
let id = $('#object_id').val();
let type = $('#object_type').val();
$("#object_description").html(json.description);
$("#object_id").val(json.id);
}
+ ns.set_image_button_enabled();
},
error: () => {
$("#object_description").html("");
$("#object_id").val("");
+ ns.set_image_button_enabled();
}
});
};
ns.init = function() {
ns.reload_images();
};
-
-
});
$(kivi.ImageUpload.init);