1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Improvements for #1483

* Rename the global to $tw.dragInProgress for clarity.
* Abort the dragenter so that we don’t get extraneous feedback during
the drag
This commit is contained in:
Jermolene 2015-02-10 23:17:38 +00:00
parent 1b87d9134b
commit 1924eda8a9
2 changed files with 14 additions and 6 deletions

View File

@ -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;
}

View File

@ -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