diff --git a/js/Main.js b/js/Main.js
index fd1da8da9..015fb8f8f 100644
--- a/js/Main.js
+++ b/js/Main.js
@@ -15,7 +15,9 @@ var WikiStore = require("./WikiStore.js").WikiStore,
tiddlerOutput = require("./TiddlerOutput.js"),
TextProcessors = require("./TextProcessors.js").TextProcessors,
WikiTextProcessor = require("./WikiTextProcessor.js").WikiTextProcessor,
- TiddlerConverters = require("./TiddlerConverters.js").TiddlerConverters;
+ TiddlerConverters = require("./TiddlerConverters.js").TiddlerConverters,
+ Navigators = require("./Navigators.js").Navigators,
+ StoryNavigator = require("./StoryNavigator.js").StoryNavigator;
var textProcessors = new TextProcessors(),
tiddlerConverters = new TiddlerConverters(),
@@ -76,7 +78,17 @@ for(t=0; t").html(store.renderTiddler("text/html","HelloThere")).appendTo("body");
+// Install the standard navigators
+var navigators = new Navigators({
+ document: document,
+ store: store
+ });
-})();
\ No newline at end of file
+navigators.registerNavigator("StoryNavigator",new StoryNavigator(navigators));
+// Use the story navigator for all links
+navigators.install("a","StoryNavigator");
+
+// Navigate to HelloThere
+navigators.navigateTo("HelloThere","StoryNavigator");
+
+})();
diff --git a/js/Navigators.js b/js/Navigators.js
new file mode 100644
index 000000000..87d4d9ef8
--- /dev/null
+++ b/js/Navigators.js
@@ -0,0 +1,56 @@
+/*\
+title: js/Navigators.js
+
+This browser component manages the available navigators that handle clicking on links to tiddlers.
+
+\*/
+(function(){
+
+/*jslint node: true */
+"use strict";
+
+var util = require("util");
+
+/*
+Options hashmap has mandatory members:
+ document: the DOM document to use
+ store: the wiki store to use
+*/
+var Navigators = function(options) {
+ this.document = options.document;
+ this.store = options.store;
+ this.navigators = {};
+};
+
+Navigators.prototype.registerNavigator = function(name,nav) {
+ this.navigators[name] = nav;
+};
+
+Navigators.prototype.install = function(selector,navname) {
+ var nav = this.navigators[navname];
+ this.document.addEventListener("click",function(e) {
+ var el = e.target,
+ matchesSelector = el.matchesSelector || el.mozMatchesSelector ||
+ el.webkitMatchesSelector || el.oMatchesSelector || el.msMatchesSelector
+ if(matchesSelector && matchesSelector.call(el,selector)) {
+ var r = nav.navigateTo(el.getAttribute("href"));
+ if(!r) {
+ e.preventDefault();
+ } else {
+ el.setAttribute("target","_blank");
+ }
+ return r;
+ }
+ },false);
+};
+
+Navigators.prototype.navigateTo = function(title,navname) {
+ var nav = this.navigators[navname];
+ if(nav) {
+ nav.navigateTo(title);
+ }
+};
+
+exports.Navigators = Navigators;
+
+})();
diff --git a/js/StoryNavigator.js b/js/StoryNavigator.js
new file mode 100644
index 000000000..8b9b2b690
--- /dev/null
+++ b/js/StoryNavigator.js
@@ -0,0 +1,28 @@
+/*\
+title: js/StoryNavigator.js
+
+This browser component manages navigating to new tiddlers in a TiddlyWiki classic story style
+
+\*/
+(function(){
+
+/*jslint node: true */
+"use strict";
+
+var StoryNavigator = function(navigators) {
+ this.navigators = navigators;
+}
+
+StoryNavigator.prototype.navigateTo = function(title) {
+ var tiddlerHtml = this.navigators.store.renderTiddler("text/html",title);
+ if(tiddlerHtml) {
+ $("
").html(tiddlerHtml).appendTo("body");
+ return false;
+ } else {
+ return true;
+ }
+}
+
+exports.StoryNavigator = StoryNavigator;
+
+})();
diff --git a/tiddlywiki5/tiddlywiki5.recipe b/tiddlywiki5/tiddlywiki5.recipe
index 92516a1a4..74a44d975 100644
--- a/tiddlywiki5/tiddlywiki5.recipe
+++ b/tiddlywiki5/tiddlywiki5.recipe
@@ -16,6 +16,8 @@ jsmodule: ../js/WikiTextProcessor.js
jsmodule: ../js/WikiTextParser.js
jsmodule: ../js/WikiTextRules.js
jsmodule: ../js/WikiTextRenderer.js
+jsmodule: ../js/Navigators.js
+jsmodule: ../js/StoryNavigator.js
jsmodule: ../js/Main.js
jsbootstart: BootStart.js