2018-07-31 20:09:18 +02:00
|
|
|
import { checkSize } from './utils';
|
2018-02-02 19:22:32 +01:00
|
|
|
|
2017-08-24 23:54:02 +02:00
|
|
|
export default function(state, emitter) {
|
|
|
|
emitter.on('DOMContentLoaded', () => {
|
|
|
|
document.body.addEventListener('dragover', event => {
|
|
|
|
if (state.route === '/') {
|
|
|
|
event.preventDefault();
|
2018-07-31 20:09:18 +02:00
|
|
|
const files = document.querySelector('.uploadedFilesWrapper');
|
|
|
|
files.classList.add('uploadArea--noEvents');
|
2017-08-24 23:54:02 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
document.body.addEventListener('drop', event => {
|
2018-02-01 00:47:34 +01:00
|
|
|
if (state.route === '/' && !state.uploading) {
|
2017-08-24 23:54:02 +02:00
|
|
|
event.preventDefault();
|
2018-02-19 23:29:13 +01:00
|
|
|
document
|
|
|
|
.querySelector('.uploadArea')
|
|
|
|
.classList.remove('uploadArea--dragging');
|
2018-07-31 20:09:18 +02:00
|
|
|
|
2017-08-24 23:54:02 +02:00
|
|
|
const target = event.dataTransfer;
|
2018-07-26 07:26:11 +02:00
|
|
|
|
2018-07-31 20:09:18 +02:00
|
|
|
checkSize(target.files, state.files);
|
|
|
|
|
|
|
|
emitter.emit('addFiles', { files: target.files });
|
2017-08-24 23:54:02 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|