launch js event when initializing dropzone

This commit is contained in:
Julien Fastré 2019-01-15 12:20:09 +01:00
parent 927d7e6e85
commit 7d87a45a55
2 changed files with 28 additions and 0 deletions

View File

@ -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;

View File

@ -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 = () => {