2019-02-13 14:16:22 +01:00
|
|
|
import ProgressBar from './progress-bar';
|
|
|
|
|
|
|
|
const INITIALIZE_EVENT = 'direct-upload:initialize';
|
|
|
|
const START_EVENT = 'direct-upload:start';
|
|
|
|
const PROGRESS_EVENT = 'direct-upload:progress';
|
|
|
|
const ERROR_EVENT = 'direct-upload:error';
|
|
|
|
const END_EVENT = 'direct-upload:end';
|
|
|
|
|
|
|
|
addEventListener(INITIALIZE_EVENT, ({ target, detail: { id, file } }) => {
|
|
|
|
ProgressBar.init(target, id, file);
|
|
|
|
});
|
|
|
|
|
2019-03-06 11:40:09 +01:00
|
|
|
addEventListener(START_EVENT, ({ target, detail: { id } }) => {
|
2019-02-13 14:16:22 +01:00
|
|
|
ProgressBar.start(id);
|
2019-03-06 11:40:09 +01:00
|
|
|
const button = target.form.querySelector('button.primary');
|
|
|
|
if (button) {
|
2019-05-14 17:12:27 +02:00
|
|
|
button.removeAttribute('data-confirm');
|
2019-03-06 11:40:09 +01:00
|
|
|
}
|
2019-02-13 14:16:22 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
addEventListener(PROGRESS_EVENT, ({ detail: { id, progress } }) => {
|
|
|
|
ProgressBar.progress(id, progress);
|
|
|
|
});
|
|
|
|
|
|
|
|
addEventListener(ERROR_EVENT, ({ detail: { id, error } }) => {
|
|
|
|
ProgressBar.error(id, error);
|
|
|
|
});
|
|
|
|
|
|
|
|
addEventListener(END_EVENT, ({ detail: { id } }) => {
|
|
|
|
ProgressBar.end(id);
|
|
|
|
});
|