1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-04 12:58:01 +00:00

Provide option to suppress navigation for edit/cancel/save

This commit is contained in:
Jermolene 2015-08-05 15:07:19 +01:00
parent 72ed4b2673
commit fdce67399d

View File

@ -220,14 +220,17 @@ NavigatorWidget.prototype.handleEditTiddlerEvent = function(event) {
return false; return false;
} }
// Replace the specified tiddler with a draft in edit mode // Replace the specified tiddler with a draft in edit mode
var draftTiddler = this.makeDraftTiddler(title), var draftTiddler = this.makeDraftTiddler(title);
draftTitle = draftTiddler.fields.title, // Update the story and history if required
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
var draftTitle = draftTiddler.fields.title,
storyList = this.getStoryList(); storyList = this.getStoryList();
this.removeTitleFromStory(storyList,draftTitle); this.removeTitleFromStory(storyList,draftTitle);
this.replaceFirstTitleInStory(storyList,title,draftTitle); this.replaceFirstTitleInStory(storyList,title,draftTitle);
this.addToHistory(draftTitle,event.navigateFromClientRect); this.addToHistory(draftTitle,event.navigateFromClientRect);
this.saveStoryList(storyList); this.saveStoryList(storyList);
return false; return false;
}
}; };
// Delete a tiddler // Delete a tiddler
@ -345,12 +348,14 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
if(isRename) { if(isRename) {
this.wiki.deleteTiddler(draftOf); this.wiki.deleteTiddler(draftOf);
} }
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
// Replace the draft in the story with the original // Replace the draft in the story with the original
this.replaceFirstTitleInStory(storyList,title,draftTitle); this.replaceFirstTitleInStory(storyList,title,draftTitle);
this.addToHistory(draftTitle,event.navigateFromClientRect); this.addToHistory(draftTitle,event.navigateFromClientRect);
if(draftTitle !== this.storyTitle) { if(draftTitle !== this.storyTitle) {
this.saveStoryList(storyList); this.saveStoryList(storyList);
} }
}
// Trigger an autosave // Trigger an autosave
$tw.rootWidget.dispatchEvent({type: "tm-auto-save-wiki"}); $tw.rootWidget.dispatchEvent({type: "tm-auto-save-wiki"});
} }
@ -381,6 +386,7 @@ NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) {
// Remove the draft tiddler // Remove the draft tiddler
if(isConfirmed) { if(isConfirmed) {
this.wiki.deleteTiddler(draftTitle); this.wiki.deleteTiddler(draftTitle);
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
if(originalTiddler) { if(originalTiddler) {
this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle); this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);
this.addToHistory(originalTitle,event.navigateFromClientRect); this.addToHistory(originalTitle,event.navigateFromClientRect);
@ -390,6 +396,7 @@ NavigatorWidget.prototype.handleCancelTiddlerEvent = function(event) {
this.saveStoryList(storyList); this.saveStoryList(storyList);
} }
} }
}
return false; return false;
}; };