diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:07:19 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:19:12 +0200 |
| commit | a3da1483a9e689846179159355badfec8073dbec (patch) | |
| tree | 770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /resources/assets/javascripts/lib/drag_and_drop_upload.js | |
current code from svn, revision 62608
Diffstat (limited to 'resources/assets/javascripts/lib/drag_and_drop_upload.js')
| -rw-r--r-- | resources/assets/javascripts/lib/drag_and_drop_upload.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/resources/assets/javascripts/lib/drag_and_drop_upload.js b/resources/assets/javascripts/lib/drag_and_drop_upload.js new file mode 100644 index 0000000..ae37350 --- /dev/null +++ b/resources/assets/javascripts/lib/drag_and_drop_upload.js @@ -0,0 +1,21 @@ +/* Drag and drop file upload */ +const DragAndDropUpload = { + bind: function(form) { + form = form || document; + + jQuery('input[type=file]', form).change(function() { + jQuery(this) + .closest('form') + .submit(); + }); + + // The drag event handling is seriously messed up + // see http://www.quirksmode.org/blog/archives/2009/09/the_html5_drag.html + jQuery(form).on('dragover dragleave', function(event) { + jQuery(this).toggleClass('hovered', event.type === 'dragover'); + return false; + }); + } +}; + +export default DragAndDropUpload; |
