38b0bd645c
When clicking on the icon, `event target` would be the icon, not the button. However delegates configures `this` to be the requested event target.
23 lines
808 B
JavaScript
23 lines
808 B
JavaScript
import AutoUploadsControllers from './auto-uploads-controllers.js';
|
|
import { delegate } from '@utils';
|
|
|
|
// Create a controller responsible for managing several concurrent uploads.
|
|
const autoUploadsControllers = new AutoUploadsControllers();
|
|
|
|
function startUpload(input) {
|
|
Array.from(input.files).forEach(file => {
|
|
autoUploadsControllers.upload(input, file);
|
|
});
|
|
}
|
|
|
|
const fileInputSelector = `input[type=file][data-direct-upload-url][data-auto-attach-url]:not([disabled])`;
|
|
delegate('change', fileInputSelector, event => {
|
|
startUpload(event.target);
|
|
});
|
|
|
|
const retryButtonSelector = `button.attachment-error-retry`;
|
|
delegate('click', retryButtonSelector, function() {
|
|
const inputSelector = this.dataset.inputTarget;
|
|
const input = document.querySelector(inputSelector);
|
|
startUpload(input);
|
|
});
|