mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-25 01:20:30 +00:00
Tidying up drag and drop
This commit is contained in:
parent
e39d246317
commit
94287c9ac3
@ -28,7 +28,6 @@ var ImportWidget = function(renderer) {
|
|||||||
ImportWidget.prototype.generate = function() {
|
ImportWidget.prototype.generate = function() {
|
||||||
// Get the parameters from the attributes
|
// Get the parameters from the attributes
|
||||||
this.browse = this.renderer.getAttribute("browse","yes");
|
this.browse = this.renderer.getAttribute("browse","yes");
|
||||||
this.mutate = this.renderer.getAttribute("mutate","yes");
|
|
||||||
this["class"] = this.renderer.getAttribute("class");
|
this["class"] = this.renderer.getAttribute("class");
|
||||||
// Compute classes
|
// Compute classes
|
||||||
var classes = ["tw-import"];
|
var classes = ["tw-import"];
|
||||||
@ -132,7 +131,7 @@ ImportWidget.prototype.handlePasteEvent = function(event) {
|
|||||||
title: self.generateTitle("Untitled"),
|
title: self.generateTitle("Untitled"),
|
||||||
text: str
|
text: str
|
||||||
};
|
};
|
||||||
self.renderer.renderTree.wiki.addTiddler(new $tw.Tiddler(fields));
|
self.storeTiddler(fields);
|
||||||
self.openTiddler(fields.title);
|
self.openTiddler(fields.title);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -160,7 +159,7 @@ ImportWidget.prototype.importData = function(dataTransfer) {
|
|||||||
if(!fields.title) {
|
if(!fields.title) {
|
||||||
fields.title = this.generateTitle("Untitled");
|
fields.title = this.generateTitle("Untitled");
|
||||||
}
|
}
|
||||||
this.renderer.renderTree.wiki.addTiddler(new $tw.Tiddler(fields));
|
this.storeTiddler(fields);
|
||||||
this.openTiddler(fields.title);
|
this.openTiddler(fields.title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -212,7 +211,7 @@ ImportWidget.prototype.importFiles = function(files) {
|
|||||||
var commaPos = event.target.result.indexOf(",");
|
var commaPos = event.target.result.indexOf(",");
|
||||||
if(commaPos !== -1) {
|
if(commaPos !== -1) {
|
||||||
fields.text = event.target.result.substr(commaPos+1);
|
fields.text = event.target.result.substr(commaPos+1);
|
||||||
self.renderer.renderTree.wiki.addTiddler(new $tw.Tiddler(fields));
|
self.storeTiddler(fields);
|
||||||
self.openTiddler(fields.title);
|
self.openTiddler(fields.title);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -221,8 +220,8 @@ ImportWidget.prototype.importFiles = function(files) {
|
|||||||
console.log("No tiddlers found in file ",file.name);
|
console.log("No tiddlers found in file ",file.name);
|
||||||
} else {
|
} else {
|
||||||
$tw.utils.each(tiddlers,function(tiddlerFields) {
|
$tw.utils.each(tiddlers,function(tiddlerFields) {
|
||||||
var title = self.generateTitle(tiddlerFields.title);
|
tiddlerFields.title = self.generateTitle(tiddlerFields.title);
|
||||||
self.renderer.renderTree.wiki.addTiddler(new $tw.Tiddler(tiddlerFields,{title: title}));
|
self.storeTiddler(tiddlerFields);
|
||||||
self.openTiddler(title);
|
self.openTiddler(title);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -239,6 +238,10 @@ ImportWidget.prototype.importFiles = function(files) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ImportWidget.prototype.storeTiddler = function(fields) {
|
||||||
|
this.renderer.renderTree.wiki.addTiddler(new $tw.Tiddler(fields));
|
||||||
|
};
|
||||||
|
|
||||||
ImportWidget.prototype.generateTitle = function(baseTitle) {
|
ImportWidget.prototype.generateTitle = function(baseTitle) {
|
||||||
var c = 0;
|
var c = 0;
|
||||||
do {
|
do {
|
||||||
|
@ -4,7 +4,7 @@ title: $:/templates/ControlPanel
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Import: <$import mutate="sidebar importer" class="tw-drop-zone">
|
Import: <$import class="tw-drop-zone">
|
||||||
|
|
||||||
Drop files here
|
Drop files here
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@ title: $:/templates/PageTemplate
|
|||||||
<!-- The navigator catches navigation events and updates the story and history tiddlers -->
|
<!-- The navigator catches navigation events and updates the story and history tiddlers -->
|
||||||
<$navigator story="$:/StoryList" history="$:/HistoryList">
|
<$navigator story="$:/StoryList" history="$:/HistoryList">
|
||||||
|
|
||||||
|
<$import browse="no" class="tw-drop-zone-fullscreen">
|
||||||
<$import browse="no" mutate="global importer" class="tw-drop-zone-fullscreen">
|
|
||||||
|
|
||||||
<!-- The sidebar header -->
|
<!-- The sidebar header -->
|
||||||
<header class="sidebar-header">
|
<header class="sidebar-header">
|
||||||
|
Loading…
Reference in New Issue
Block a user