pianello-api/resources/js/components/dropzone/index.js
Ale Gallo 82f958e5da Committing laravel (part 3)
committing js templating files and components
2023-11-10 16:00:59 +01:00

39 lines
1 KiB
JavaScript

(function () {
"use strict";
// Dropzone
Dropzone.autoDiscover = false;
$(".dropzone").each(function () {
let options = {
accept: (file, done) => {
console.log("Uploaded");
done();
},
};
if ($(this).data("single")) {
options.maxFiles = 1;
}
if ($(this).data("file-types")) {
options.accept = (file, done) => {
if (
$(this).data("file-types").split("|").indexOf(file.type) ===
-1
) {
alert("Error! Files of this type are not accepted");
done("Error! Files of this type are not accepted");
} else {
console.log("Uploaded");
done();
}
};
}
let dz = new Dropzone(this, options);
dz.on("maxfilesexceeded", (file) => {
alert("No more files please!");
});
});
})();