From a1fc221fe2d49af66bfbc80ac6ff01d9bfc0a65c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 17 Sep 2014 12:11:39 +0200 Subject: [PATCH] Added support for multi-drop and Safari --- .../files/js/3rdParty/redactor/plugins/wupload.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wupload.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wupload.js index 3a80b6acc0..c6fd016ef0 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wupload.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wupload.js @@ -49,7 +49,8 @@ RedactorPlugins.wupload = { } // IE and WebKit set 'Files', Firefox sets 'application/x-moz-file' for files being dragged - if (event.dataTransfer.types[0] !== 'Files' && event.dataTransfer.types[0] !== 'application/x-moz-file') { + // and Safari just provides 'Files' along with a huge list of other stuff + if (event.dataTransfer.types[0] !== 'application/x-moz-file' && event.dataTransfer.types.indexOf('Files') === -1) { this._isFile = false; return; @@ -152,14 +153,19 @@ RedactorPlugins.wupload = { event = event.originalEvent || event; - if (event.dataTransfer && event.dataTransfer.files.length == 1) { + if (event.dataTransfer && event.dataTransfer.files.length) { event.preventDefault(); // reset overlay var $containerID = this.$source.wcfIdentify(); this._revertDropArea(undefined, $containerID); - WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'upload_' + $containerID, { file: event.dataTransfer.files[0] }); + for (var $i = 0; $i < event.dataTransfer.files.length; $i++) { + var $file = event.dataTransfer.files[$i]; + if ($file.type) { + WCF.System.Event.fireEvent('com.woltlab.wcf.redactor', 'upload_' + $containerID, { file: $file }); + } + } } }, -- 2.20.1