From 56c8dc2226f8083f6637ae70791c838f46613199 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Wed, 7 Nov 2012 16:12:03 +0000 Subject: [PATCH] Fixed problem with navigators that don't have a story or history --- core/modules/macros/navigator.js | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/core/modules/macros/navigator.js b/core/modules/macros/navigator.js index 1e2d244c2..86bc1dcab 100644 --- a/core/modules/macros/navigator.js +++ b/core/modules/macros/navigator.js @@ -56,27 +56,31 @@ exports.eventMap = {}; // Navigate to a specified tiddler exports.eventMap["tw-navigate"] = function(event) { - // Update the story tiddler if specified - this.story = this.getList(this.storyTitle); - // See if the tiddler is already there - var slot = this.findTitleInStory(event.navigateTo,-1); - // If not we need to add it - if(slot === -1) { - // First we try to find the position of the story element we navigated from - slot = this.findTitleInStory(event.navigateFromTitle,-1) + 1; - // Add the tiddler - this.story.splice(slot,0,event.navigateTo); - // Save the story - this.saveList(this.storyTitle,this.story); + if(this.hasParameter("story")) { + // Update the story tiddler if specified + this.story = this.getList(this.storyTitle); + // See if the tiddler is already there + var slot = this.findTitleInStory(event.navigateTo,-1); + // If not we need to add it + if(slot === -1) { + // First we try to find the position of the story element we navigated from + slot = this.findTitleInStory(event.navigateFromTitle,-1) + 1; + // Add the tiddler + this.story.splice(slot,0,event.navigateTo); + // Save the story + this.saveList(this.storyTitle,this.story); + } } // Set the tiddler if specified if(this.hasParameter("set")) { this.wiki.setTextReference(this.params.set,event.navigateTo); } // Add a new record to the top of the history stack - this.history = this.wiki.getTiddlerData(this.historyTitle,[]); - this.history.push({title: event.navigateTo, fromPageRect: event.navigateFromClientRect}); - this.wiki.setTiddlerData(this.historyTitle,this.history); + if(this.hasParameter("history")) { + this.history = this.wiki.getTiddlerData(this.historyTitle,[]); + this.history.push({title: event.navigateTo, fromPageRect: event.navigateFromClientRect}); + this.wiki.setTiddlerData(this.historyTitle,this.history); + } event.stopPropagation(); return false; };