From 1924eda8a9f604f73b2c4d94e6a0ba19d9c01caa Mon Sep 17 00:00:00 2001 From: Jermolene Date: Tue, 10 Feb 2015 23:17:38 +0000 Subject: [PATCH] Improvements for #1483 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rename the global to $tw.dragInProgress for clarity. * Abort the dragenter so that we don’t get extraneous feedback during the drag --- core/modules/widgets/dropzone.js | 16 ++++++++++++---- core/modules/widgets/link.js | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core/modules/widgets/dropzone.js b/core/modules/widgets/dropzone.js index 34ae850d8..744e3040c 100644 --- a/core/modules/widgets/dropzone.js +++ b/core/modules/widgets/dropzone.js @@ -53,6 +53,10 @@ DropZoneWidget.prototype.render = function(parent,nextSibling) { }; DropZoneWidget.prototype.enterDrag = function() { + // Check for this window being the source of the drag + if($tw.dragInProgress) { + return false; + } // We count enter/leave events this.dragEnterCount = (this.dragEnterCount || 0) + 1; // If we're entering for the first time we need to apply highlighting @@ -83,6 +87,10 @@ DropZoneWidget.prototype.handleDragOverEvent = function(event) { if(["TEXTAREA","INPUT"].indexOf(event.target.tagName) !== -1) { return false; } + // Check for this window being the source of the drag + if($tw.dragInProgress) { + return false; + } // Tell the browser that we're still interested in the drop event.preventDefault(); event.dataTransfer.dropEffect = "copy"; // Explicitly show this is a copy @@ -98,6 +106,10 @@ DropZoneWidget.prototype.handleDropEvent = function(event) { if(["TEXTAREA","INPUT"].indexOf(event.target.tagName) !== -1) { return false; } + // Check for this window being the source of the drag + if($tw.dragInProgress) { + return false; + } var self = this, dataTransfer = event.dataTransfer; // Reset the enter count @@ -134,10 +146,6 @@ DropZoneWidget.prototype.importData = function(dataTransfer) { if(!tiddlerFields.title) { tiddlerFields.title = this.wiki.generateNewTitle("Untitled"); } - if($tw.dragging) { - $tw.dragging = false; - return false; - } this.dispatchEvent({type: "tm-import-tiddlers", param: JSON.stringify([tiddlerFields])}); return; } diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index c4439ecbb..6d0d94610 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -126,7 +126,7 @@ LinkWidget.prototype.handleClickEvent = function(event) { LinkWidget.prototype.handleDragStartEvent = function(event) { if(event.target === this.domNodes[0]) { if(this.to) { - $tw.dragging = true; + $tw.dragInProgress = true; // Set the dragging class on the element being dragged $tw.utils.addClass(event.target,"tc-tiddlylink-dragging"); // Create the drag image elements @@ -174,7 +174,7 @@ LinkWidget.prototype.handleDragStartEvent = function(event) { LinkWidget.prototype.handleDragEndEvent = function(event) { if(event.target === this.domNodes[0]) { - $tw.dragging = false; + $tw.dragInProgress = false; // Remove the dragging class on the element being dragged $tw.utils.removeClass(event.target,"tc-tiddlylink-dragging"); // Delete the drag image element