1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-16 14:54:51 +00:00
TiddlyWiki5/js/StoryNavigator.js
2011-12-28 16:10:03 +00:00

33 lines
694 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 StoryNavigator = function(navigators) {
this.navigators = navigators;
};
StoryNavigator.prototype.navigateTo = function(title) {
var tiddlerHtml = this.navigators.store.renderTiddler("text/html","SimpleTemplate",title);
if(tiddlerHtml) {
var article = $("<article/>").html(tiddlerHtml);
article.appendTo("body");
$("html,body").animate({
scrollTop: article.offset().top
}, 400);
return false;
} else {
return true;
}
};
exports.StoryNavigator = StoryNavigator;
})();