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