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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
document.body.addEventListener('drop', event => {
|
2018-11-19 19:48:52 +01:00
|
|
|
if (
|
|
|
|
state.route === '/' &&
|
|
|
|
!state.uploading &&
|
|
|
|
event.dataTransfer &&
|
|
|
|
event.dataTransfer.files
|
|
|
|
) {
|
2017-08-24 23:54:02 +02:00
|
|
|
event.preventDefault();
|
2018-10-31 19:40:54 +01:00
|
|
|
emitter.emit('addFiles', {
|
|
|
|
files: Array.from(event.dataTransfer.files)
|
|
|
|
});
|
2017-08-24 23:54:02 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|