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

Minor tweaks to navigator

This commit is contained in:
Jeremy Ruston 2012-10-25 13:04:03 +01:00
parent 73bcb1c31e
commit 723fbf12ce

View File

@ -53,15 +53,10 @@ exports.eventMap = {};
exports.eventMap["tw-navigate"] = function(event) { exports.eventMap["tw-navigate"] = function(event) {
// Update the story tiddler if specified // Update the story tiddler if specified
this.story = this.getList(this.storyTitle); this.story = this.getList(this.storyTitle);
var t,tiddler,slot;
// See if the tiddler is already there // See if the tiddler is already there
for(t=0; t<this.story.length; t++) { var slot = this.findTitleInStory(event.navigateTo,-1);
if(this.story[t] === event.navigateTo) {
tiddler = t;
}
}
// If not we need to add it // If not we need to add it
if(tiddler === undefined) { if(slot === -1) {
// First we try to find the position of the story element we navigated from // First we try to find the position of the story element we navigated from
slot = this.findTitleInStory(event.navigateFromTitle,-1) + 1; slot = this.findTitleInStory(event.navigateFromTitle,-1) + 1;
// Add the tiddler // Add the tiddler
@ -85,12 +80,11 @@ exports.eventMap["tw-navigate"] = function(event) {
exports.eventMap["tw-close"] = function(event) { exports.eventMap["tw-close"] = function(event) {
this.story = this.getList(this.storyTitle); this.story = this.getList(this.storyTitle);
// Look for tiddlers with this title to close // Look for tiddlers with this title to close
for(var t=this.story.length-1; t>=0; t--) { var slot = this.findTitleInStory(event.tiddlerTitle,-1);
if(this.story[t] === event.tiddlerTitle) { if(slot !== -1) {
this.story.splice(t,1); this.story.splice(slot,1);
} this.saveList(this.storyTitle,this.story);
} }
this.saveList(this.storyTitle,this.story);
event.stopPropagation(); event.stopPropagation();
return false; return false;
}; };