mirror of
https://gitlab.com/timvisee/send.git
synced 2024-11-08 20:22:45 +01:00
23 lines
576 B
JavaScript
23 lines
576 B
JavaScript
export default function(state, emitter) {
|
|
emitter.on('DOMContentLoaded', () => {
|
|
document.body.addEventListener('dragover', event => {
|
|
if (state.route === '/') {
|
|
event.preventDefault();
|
|
}
|
|
});
|
|
document.body.addEventListener('drop', event => {
|
|
if (
|
|
state.route === '/' &&
|
|
!state.uploading &&
|
|
event.dataTransfer &&
|
|
event.dataTransfer.files
|
|
) {
|
|
event.preventDefault();
|
|
emitter.emit('addFiles', {
|
|
files: Array.from(event.dataTransfer.files)
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|