From 8d4e5747f386a0899d50becb8297b4347df355db Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Wed, 14 Sep 2016 13:44:34 +0200 Subject: [PATCH] Fix folder drag glitch in Firefox issue: * drag'n'drop a folder into the files app in Firefox * the highlight stays there because Firefox doesn't trigger the drop event for folders solution: * behave like the drop event if the dragover event isn't fired for 100ms (only applied in Firefox) --- apps/files/js/file-upload.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index e07093dd17..05224264c1 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -667,8 +667,23 @@ OC.Upload = { OC.Upload._hideProgressBar(); } }); + var disableDropState = function() { + $('#app-content').removeClass('file-drag'); + $('.dropping-to-dir').removeClass('dropping-to-dir'); + $('.dir-drop').removeClass('dir-drop'); + $('.icon-filetype-folder-drag-accept').removeClass('icon-filetype-folder-drag-accept'); + }; + var disableClassOnFirefox = _.debounce(function() { + disableDropState(); + }, 100); fileupload.on('fileuploaddragover', function(e){ $('#app-content').addClass('file-drag'); + // dropping a folder in firefox doesn't cause a drop event + // this is simulated by simply invoke disabling all classes + // once no dragover event isn't noticed anymore + if ($.browser['mozilla']) { + disableClassOnFirefox(); + } $('#emptycontent .icon-folder').addClass('icon-filetype-folder-drag-accept'); var filerow = $(e.delegatedEvent.target).closest('tr'); @@ -685,12 +700,7 @@ OC.Upload = { filerow.find('.thumbnail').addClass('icon-filetype-folder-drag-accept'); } }); - fileupload.on('fileuploaddragleave fileuploaddrop', function (){ - $('#app-content').removeClass('file-drag'); - $('.dropping-to-dir').removeClass('dropping-to-dir'); - $('.dir-drop').removeClass('dir-drop'); - $('.icon-filetype-folder-drag-accept').removeClass('icon-filetype-folder-drag-accept'); - }); + fileupload.on('fileuploaddragleave fileuploaddrop', disableDropState); } else { // for all browsers that don't support the progress bar // IE 8 & 9