mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-22 23:16:53 +00:00
Provide option to suppress navigation for edit/cancel/save
This commit is contained in:
parent
72ed4b2673
commit
fdce67399d
@ -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
|
||||||
storyList = this.getStoryList();
|
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||||
this.removeTitleFromStory(storyList,draftTitle);
|
var draftTitle = draftTiddler.fields.title,
|
||||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
storyList = this.getStoryList();
|
||||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
this.removeTitleFromStory(storyList,draftTitle);
|
||||||
this.saveStoryList(storyList);
|
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||||
return false;
|
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||||
|
this.saveStoryList(storyList);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Delete a tiddler
|
// Delete a tiddler
|
||||||
@ -345,11 +348,13 @@ NavigatorWidget.prototype.handleSaveTiddlerEvent = function(event) {
|
|||||||
if(isRename) {
|
if(isRename) {
|
||||||
this.wiki.deleteTiddler(draftOf);
|
this.wiki.deleteTiddler(draftOf);
|
||||||
}
|
}
|
||||||
// Replace the draft in the story with the original
|
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||||
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
// Replace the draft in the story with the original
|
||||||
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
this.replaceFirstTitleInStory(storyList,title,draftTitle);
|
||||||
if(draftTitle !== this.storyTitle) {
|
this.addToHistory(draftTitle,event.navigateFromClientRect);
|
||||||
this.saveStoryList(storyList);
|
if(draftTitle !== this.storyTitle) {
|
||||||
|
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,13 +386,15 @@ 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(originalTiddler) {
|
if(!event.paramObject || event.paramObject.suppressNavigation !== "yes") {
|
||||||
this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);
|
if(originalTiddler) {
|
||||||
this.addToHistory(originalTitle,event.navigateFromClientRect);
|
this.replaceFirstTitleInStory(storyList,draftTitle,originalTitle);
|
||||||
} else {
|
this.addToHistory(originalTitle,event.navigateFromClientRect);
|
||||||
this.removeTitleFromStory(storyList,draftTitle);
|
} else {
|
||||||
|
this.removeTitleFromStory(storyList,draftTitle);
|
||||||
|
}
|
||||||
|
this.saveStoryList(storyList);
|
||||||
}
|
}
|
||||||
this.saveStoryList(storyList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user