mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-07-19 18:32:50 +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:
parent
1b87d9134b
commit
1924eda8a9
@ -53,6 +53,10 @@ DropZoneWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
DropZoneWidget.prototype.enterDrag = function() {
|
DropZoneWidget.prototype.enterDrag = function() {
|
||||||
|
// Check for this window being the source of the drag
|
||||||
|
if($tw.dragInProgress) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// We count enter/leave events
|
// We count enter/leave events
|
||||||
this.dragEnterCount = (this.dragEnterCount || 0) + 1;
|
this.dragEnterCount = (this.dragEnterCount || 0) + 1;
|
||||||
// If we're entering for the first time we need to apply highlighting
|
// 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) {
|
if(["TEXTAREA","INPUT"].indexOf(event.target.tagName) !== -1) {
|
||||||
return false;
|
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
|
// Tell the browser that we're still interested in the drop
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.dataTransfer.dropEffect = "copy"; // Explicitly show this is a copy
|
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) {
|
if(["TEXTAREA","INPUT"].indexOf(event.target.tagName) !== -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Check for this window being the source of the drag
|
||||||
|
if($tw.dragInProgress) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var self = this,
|
var self = this,
|
||||||
dataTransfer = event.dataTransfer;
|
dataTransfer = event.dataTransfer;
|
||||||
// Reset the enter count
|
// Reset the enter count
|
||||||
@ -134,10 +146,6 @@ DropZoneWidget.prototype.importData = function(dataTransfer) {
|
|||||||
if(!tiddlerFields.title) {
|
if(!tiddlerFields.title) {
|
||||||
tiddlerFields.title = this.wiki.generateNewTitle("Untitled");
|
tiddlerFields.title = this.wiki.generateNewTitle("Untitled");
|
||||||
}
|
}
|
||||||
if($tw.dragging) {
|
|
||||||
$tw.dragging = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.dispatchEvent({type: "tm-import-tiddlers", param: JSON.stringify([tiddlerFields])});
|
this.dispatchEvent({type: "tm-import-tiddlers", param: JSON.stringify([tiddlerFields])});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ LinkWidget.prototype.handleClickEvent = function(event) {
|
|||||||
LinkWidget.prototype.handleDragStartEvent = function(event) {
|
LinkWidget.prototype.handleDragStartEvent = function(event) {
|
||||||
if(event.target === this.domNodes[0]) {
|
if(event.target === this.domNodes[0]) {
|
||||||
if(this.to) {
|
if(this.to) {
|
||||||
$tw.dragging = true;
|
$tw.dragInProgress = true;
|
||||||
// Set the dragging class on the element being dragged
|
// Set the dragging class on the element being dragged
|
||||||
$tw.utils.addClass(event.target,"tc-tiddlylink-dragging");
|
$tw.utils.addClass(event.target,"tc-tiddlylink-dragging");
|
||||||
// Create the drag image elements
|
// Create the drag image elements
|
||||||
@ -174,7 +174,7 @@ LinkWidget.prototype.handleDragStartEvent = function(event) {
|
|||||||
|
|
||||||
LinkWidget.prototype.handleDragEndEvent = function(event) {
|
LinkWidget.prototype.handleDragEndEvent = function(event) {
|
||||||
if(event.target === this.domNodes[0]) {
|
if(event.target === this.domNodes[0]) {
|
||||||
$tw.dragging = false;
|
$tw.dragInProgress = false;
|
||||||
// Remove the dragging class on the element being dragged
|
// Remove the dragging class on the element being dragged
|
||||||
$tw.utils.removeClass(event.target,"tc-tiddlylink-dragging");
|
$tw.utils.removeClass(event.target,"tc-tiddlylink-dragging");
|
||||||
// Delete the drag image element
|
// Delete the drag image element
|
||||||
|
Loading…
x
Reference in New Issue
Block a user