--- /dev/null
+/**
+ * Generic interface for drag and Drop file uploads.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2018 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Ui/DragAndDrop
+ */
+define(['Core', 'EventHandler', 'WoltLabSuite/Core/Ui/Redactor/DragAndDrop'], function (Core, EventHandler, UiRedactorDragAndDrop) {
+ /**
+ * @exports WoltLabSuite/Core/Ui/DragAndDrop
+ */
+ return {
+ /**
+ * @param {Object} options
+ */
+ register: function (options) {
+ var uuid = Core.getUuid();
+ options = Core.extend({
+ element: '',
+ elementId: '',
+ onDrop: function(data) {
+ /* data: { file: File } */
+ },
+ onGlobalDrop: function (data) {
+ /* data: { cancelDrop: boolean, event: DragEvent } */
+ }
+ });
+
+ EventHandler.add('com.woltlab.wcf.redactor2', 'dragAndDrop_' + options.elementId, options.onDrop);
+ EventHandler.add('com.woltlab.wcf.redactor2', 'dragAndDrop_globalDrop_' + options.elementId, options.onGlobalDrop);
+
+ UiRedactorDragAndDrop.init({
+ uuid: uuid,
+ $editor: [options.element],
+ $element: [{id: options.elementId}]
+ });
+ }
+ };
+});
*/
_globalDrop: function (event) {
if (event.target.closest('.redactor-layer') === null) {
- event.preventDefault();
+ var eventData = { cancelDrop: true, event: event };
+ _dragArea.forEach(function(data) {
+ //noinspection JSUnresolvedVariable
+ EventHandler.fire('com.woltlab.wcf.redactor2', 'dragAndDrop_globalDrop_' + data.editor.$element[0].id, eventData);
+ });
+
+ if (eventData.cancelDrop) {
+ event.preventDefault();
+ }
}
this._dragLeave(event);