mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-07-07 12:34:22 +00:00
![Jeremy Ruston](/assets/img/avatar_default.png)
Not done yet, but the tests are passing so it's a good point to check in. The idea is to let macros register for events to handle both the click and the navigation request.
35 lines
667 B
JavaScript
35 lines
667 B
JavaScript
/*\
|
|
title: js/StoryNavigator.js
|
|
|
|
This browser component manages navigating to new tiddlers in a TiddlyWiki classic story style
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, jquery: true */
|
|
"use strict";
|
|
|
|
var Tiddler = require("./Tiddler.js").Tiddler;
|
|
|
|
var StoryNavigator = function(navigators) {
|
|
this.navigators = navigators;
|
|
};
|
|
|
|
StoryNavigator.prototype.navigateTo = function(title,event) {
|
|
var store = this.navigators.store,
|
|
tiddler = store.getTiddler(title);
|
|
if(tiddler) {
|
|
store.invokeMacroMethod(event.target,"navigateTo",{
|
|
event: event,
|
|
target: title
|
|
});
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
};
|
|
|
|
exports.StoryNavigator = StoryNavigator;
|
|
|
|
})();
|