diff --git a/CHANGELOG.md b/CHANGELOG.md index 08bbb8ed8..d19c49413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,4 +22,5 @@ Version 1.5.3 =============== - replace default message on download button below dropzone ; +- launch event when dropzone is initialized, to allow to customize events on dropzone; diff --git a/Resources/public/module/async_upload/uploader.js b/Resources/public/module/async_upload/uploader.js index 2f2b6f74e..9ace4282c 100644 --- a/Resources/public/module/async_upload/uploader.js +++ b/Resources/public/module/async_upload/uploader.js @@ -2,6 +2,25 @@ var algo = 'AES-CBC'; var Dropzone = require('dropzone'); var initializeDownload = require('./downloader.js'); + +/** + * + * define a dropzone for chill usage + * + * An event is launched when dropzone is initialize, allowing to customize events + * on dropzone : + * + * ``` + * window.addEventListener("chill_dropzone_initialized", (e) => { + * // do something with dropzone: + * e.detail.dropzone.on("success", (e) => { + * // see https://www.dropzonejs.com/#event-success + * }); + * }); + * ``` + * + */ + // load css //require('dropzone/dist/basic.css'); require('dropzone/dist/dropzone.css'); @@ -139,6 +158,14 @@ var initialize = function(zone) { zone.insertBefore(created, zone.firstChild); insertDownloadButton(zone, zoneData); + + let event = new CustomEvent("chill_dropzone_initialized", { + detail: { + dropzone: dropzoneI, + zoneData: zoneData + } + }); + window.dispatchEvent(event); }; var createFilename = () => {