Fixed drag & drop behavior in Firefox
authorAlexander Ebert <ebert@woltlab.com>
Mon, 21 Aug 2017 12:07:57 +0000 (14:07 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 21 Aug 2017 12:07:57 +0000 (14:07 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Redactor/DragAndDrop.js

index ad8abe04bdb7d145c989f687aafd161a7d8ac52a..56a3d29a54747487d36934b275c0b5b2b565d1e0 100644 (file)
@@ -181,6 +181,20 @@ define(['Dictionary', 'EventHandler', 'Language'], function (Dictionary, EventHa
                        _isDragging = false;
                },
                
+               /**
+                * Handles the global drop event.
+                * 
+                * @param       {Event}         event
+                * @protected
+                */
+               _globalDrop: function (event) {
+                       if (event.target.closest('.redactor-layer') === null) {
+                               event.preventDefault();
+                       }
+                       
+                       this._dragLeave(event);
+               },
+               
                /**
                 * Binds listeners to global events.
                 * 
@@ -192,7 +206,7 @@ define(['Dictionary', 'EventHandler', 'Language'], function (Dictionary, EventHa
                        
                        window.addEventListener('dragover', this._dragOver.bind(this));
                        window.addEventListener('dragleave', this._dragLeave.bind(this));
-                       window.addEventListener('drop', this._dragLeave.bind(this));
+                       window.addEventListener('drop', this._globalDrop.bind(this));
                        
                        _didInit = true;
                }