mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
parent
320e0af68c
commit
2571f534aa
@ -124,56 +124,60 @@ LinkWidget.prototype.handleClickEvent = function (event) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
LinkWidget.prototype.handleDragStartEvent = function(event) {
|
LinkWidget.prototype.handleDragStartEvent = function(event) {
|
||||||
if(this.to) {
|
if(event.target === this.domNodes[0]) {
|
||||||
// Set the dragging class on the element being dragged
|
if(this.to) {
|
||||||
$tw.utils.addClass(event.target,"tc-tiddlylink-dragging");
|
// Set the dragging class on the element being dragged
|
||||||
// Create the drag image elements
|
$tw.utils.addClass(event.target,"tc-tiddlylink-dragging");
|
||||||
this.dragImage = this.document.createElement("div");
|
// Create the drag image elements
|
||||||
this.dragImage.className = "tc-tiddler-dragger";
|
this.dragImage = this.document.createElement("div");
|
||||||
var inner = this.document.createElement("div");
|
this.dragImage.className = "tc-tiddler-dragger";
|
||||||
inner.className = "tc-tiddler-dragger-inner";
|
var inner = this.document.createElement("div");
|
||||||
inner.appendChild(this.document.createTextNode(this.to));
|
inner.className = "tc-tiddler-dragger-inner";
|
||||||
this.dragImage.appendChild(inner);
|
inner.appendChild(this.document.createTextNode(this.to));
|
||||||
this.document.body.appendChild(this.dragImage);
|
this.dragImage.appendChild(inner);
|
||||||
// Astoundingly, we need to cover the dragger up: http://www.kryogenix.org/code/browser/custom-drag-image.html
|
this.document.body.appendChild(this.dragImage);
|
||||||
var cover = this.document.createElement("div");
|
// Astoundingly, we need to cover the dragger up: http://www.kryogenix.org/code/browser/custom-drag-image.html
|
||||||
cover.className = "tc-tiddler-dragger-cover";
|
var cover = this.document.createElement("div");
|
||||||
cover.style.left = (inner.offsetLeft - 16) + "px";
|
cover.className = "tc-tiddler-dragger-cover";
|
||||||
cover.style.top = (inner.offsetTop - 16) + "px";
|
cover.style.left = (inner.offsetLeft - 16) + "px";
|
||||||
cover.style.width = (inner.offsetWidth + 32) + "px";
|
cover.style.top = (inner.offsetTop - 16) + "px";
|
||||||
cover.style.height = (inner.offsetHeight + 32) + "px";
|
cover.style.width = (inner.offsetWidth + 32) + "px";
|
||||||
this.dragImage.appendChild(cover);
|
cover.style.height = (inner.offsetHeight + 32) + "px";
|
||||||
// Set the data transfer properties
|
this.dragImage.appendChild(cover);
|
||||||
var dataTransfer = event.dataTransfer;
|
// Set the data transfer properties
|
||||||
// First the image
|
var dataTransfer = event.dataTransfer;
|
||||||
dataTransfer.effectAllowed = "copy";
|
// First the image
|
||||||
if(dataTransfer.setDragImage) {
|
dataTransfer.effectAllowed = "copy";
|
||||||
dataTransfer.setDragImage(this.dragImage.firstChild,-16,-16);
|
if(dataTransfer.setDragImage) {
|
||||||
|
dataTransfer.setDragImage(this.dragImage.firstChild,-16,-16);
|
||||||
|
}
|
||||||
|
// Then the data
|
||||||
|
dataTransfer.clearData();
|
||||||
|
var jsonData = this.wiki.getTiddlerAsJson(this.to),
|
||||||
|
textData = this.wiki.getTiddlerText(this.to,"");
|
||||||
|
// IE doesn't like these content types
|
||||||
|
if(!$tw.browser.isIE) {
|
||||||
|
dataTransfer.setData("text/vnd.tiddler",jsonData);
|
||||||
|
dataTransfer.setData("text/plain",textData);
|
||||||
|
dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURI(jsonData));
|
||||||
|
}
|
||||||
|
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURI(jsonData));
|
||||||
|
dataTransfer.setData("Text",textData);
|
||||||
|
event.stopPropagation();
|
||||||
|
} else {
|
||||||
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
// Then the data
|
|
||||||
dataTransfer.clearData();
|
|
||||||
var jsonData = this.wiki.getTiddlerAsJson(this.to),
|
|
||||||
textData = this.wiki.getTiddlerText(this.to,"");
|
|
||||||
// IE doesn't like these content types
|
|
||||||
if(!$tw.browser.isIE) {
|
|
||||||
dataTransfer.setData("text/vnd.tiddler",jsonData);
|
|
||||||
dataTransfer.setData("text/plain",textData);
|
|
||||||
dataTransfer.setData("text/x-moz-url","data:text/vnd.tiddler," + encodeURI(jsonData));
|
|
||||||
}
|
|
||||||
dataTransfer.setData("URL","data:text/vnd.tiddler," + encodeURI(jsonData));
|
|
||||||
dataTransfer.setData("Text",textData);
|
|
||||||
event.stopPropagation();
|
|
||||||
} else {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LinkWidget.prototype.handleDragEndEvent = function(event) {
|
LinkWidget.prototype.handleDragEndEvent = function(event) {
|
||||||
// Remove the dragging class on the element being dragged
|
if(event.target === this.domNodes[0]) {
|
||||||
$tw.utils.removeClass(event.target,"tc-tiddlylink-dragging");
|
// Remove the dragging class on the element being dragged
|
||||||
// Delete the drag image element
|
$tw.utils.removeClass(event.target,"tc-tiddlylink-dragging");
|
||||||
if(this.dragImage) {
|
// Delete the drag image element
|
||||||
this.dragImage.parentNode.removeChild(this.dragImage);
|
if(this.dragImage) {
|
||||||
|
this.dragImage.parentNode.removeChild(this.dragImage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user