1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-17 23:34:50 +00:00

Improved generation of titles for draft tiddlers

This commit is contained in:
Jeremy Ruston 2013-02-04 11:56:11 +00:00
parent b260e6e69a
commit 365974d14f

View File

@ -119,7 +119,7 @@ NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {
for(var t=0; t<this.storyList.length; t++) { for(var t=0; t<this.storyList.length; t++) {
if(this.storyList[t] === event.tiddlerTitle) { if(this.storyList[t] === event.tiddlerTitle) {
// Compute the title for the draft // Compute the title for the draft
var draftTitle = "Draft " + (new Date()) + " of " + event.tiddlerTitle; var draftTitle = this.generateDraftTitle(event.tiddlerTitle);
this.storyList[t] = draftTitle; this.storyList[t] = draftTitle;
// Get the current value of the tiddler we're editing // Get the current value of the tiddler we're editing
var tiddler = this.renderer.renderTree.wiki.getTiddler(event.tiddlerTitle); var tiddler = this.renderer.renderTree.wiki.getTiddler(event.tiddlerTitle);
@ -141,6 +141,18 @@ NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {
return false; return false;
}; };
/*
Generate a title for the draft of a given tiddler
*/
NavigatorWidget.prototype.generateDraftTitle = function(title) {
var c = 0;
do {
var draftTitle = "Draft " + (c ? (c + 1) + " " : "") + "of '" + title + "'";
c++;
} while(this.renderer.renderTree.wiki.tiddlerExists(draftTitle));
return draftTitle;
};
// Take a tiddler out of edit mode, saving the changes // Take a tiddler out of edit mode, saving the changes
NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) { NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
this.getStoryList(); this.getStoryList();