mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
33 lines
740 B
JavaScript
33 lines
740 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.tiddlerExists(title) && 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;
|
|
|
|
})();
|