1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Revert "prevents drag and drop import in same window"

This reverts commit 09afa8297a.
This commit is contained in:
Tobias Beer 2015-02-10 23:33:19 +01:00
parent 09afa8297a
commit 30f2c06c9e
3 changed files with 13 additions and 23 deletions

View File

@ -27,14 +27,14 @@ DropZoneWidget.prototype = new Widget();
Render this widget into the DOM
*/
DropZoneWidget.prototype.render = function(parent,nextSibling) {
var domNode;
var self = this;
// Remember parent
this.parentDomNode = parent;
// Compute attributes and execute state
this.computeAttributes();
this.execute();
// Create element
domNode = this.document.createElement("div");
var domNode = this.document.createElement("div");
domNode.className = "tc-dropzone";
// Add event handlers
$tw.utils.addEventListeners(domNode,[
@ -119,27 +119,20 @@ DropZoneWidget.prototype.handleDropEvent = function(event) {
};
DropZoneWidget.prototype.importData = function(dataTransfer) {
var data, dataType, origin, t, tiddlerFields, title;
// Try each provided data type in turn
for(t=0; t<this.importDataTypes.length; t++) {
for(var t=0; t<this.importDataTypes.length; t++) {
if(!$tw.browser.isIE || this.importDataTypes[t].IECompatible) {
// Get the data
dataType = this.importDataTypes[t];
data = dataTransfer.getData(dataType.type);
var dataType = this.importDataTypes[t];
var data = dataTransfer.getData(dataType.type);
// Import the tiddlers in the data
if(data !== "" && data !== null) {
if($tw.log.IMPORT) {
console.log("Importing data type '" + dataType.type + "', data: '" + data + "'")
}
tiddlerFields = dataType.convertToFields(data);
title = tiddlerFields.title;
if(!title) {
var tiddlerFields = dataType.convertToFields(data);
if(!tiddlerFields.title) {
tiddlerFields.title = this.wiki.generateNewTitle("Untitled");
} else {
origin = tiddlerFields["_origin"];
if(origin && origin === window.location.href && $tw.wiki.getTiddler(title)) {
return false;
}
}
this.dispatchEvent({type: "tm-import-tiddlers", param: JSON.stringify([tiddlerFields])});
return;

View File

@ -153,7 +153,7 @@ LinkWidget.prototype.handleDragStartEvent = function(event) {
}
// Then the data
dataTransfer.clearData();
var jsonData = this.wiki.getTiddlerAsJson(this.to,true),
var jsonData = this.wiki.getTiddlerAsJson(this.to),
textData = this.wiki.getTiddlerText(this.to,""),
title = (new RegExp("^" + $tw.config.textPrimitives.wikiLink + "$","mg")).exec(this.to) ? this.to : "[[" + this.to + "]]";
// IE doesn't like these content types

View File

@ -594,20 +594,17 @@ exports.getSubTiddler = function(title,subTiddlerTitle) {
/*
Retrieve a tiddler as a JSON string of the fields
*/
exports.getTiddlerAsJson = function(title,exporting) {
var fields = Object.create(null),
tiddler = this.getTiddler(title);
exports.getTiddlerAsJson = function(title) {
var tiddler = this.getTiddler(title);
if(tiddler) {
var fields = Object.create(null);
$tw.utils.each(tiddler.fields,function(value,name) {
fields[name] = tiddler.getFieldString(name);
});
return JSON.stringify(fields);
} else {
fields["title"] = title;
return JSON.stringify({title: title});
}
if(exporting) {
fields["_origin"] = window.location.href;
}
return JSON.stringify(fields);
};
/*