2011-12-13 16:20:56 +00:00
|
|
|
/*\
|
|
|
|
title: js/StoryNavigator.js
|
|
|
|
|
|
|
|
This browser component manages navigating to new tiddlers in a TiddlyWiki classic story style
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2011-12-14 14:11:11 +00:00
|
|
|
/*jslint node: true, jquery: true */
|
2011-12-13 16:20:56 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var StoryNavigator = function(navigators) {
|
|
|
|
this.navigators = navigators;
|
2011-12-14 14:11:11 +00:00
|
|
|
};
|
2011-12-13 16:20:56 +00:00
|
|
|
|
|
|
|
StoryNavigator.prototype.navigateTo = function(title) {
|
2011-12-14 15:45:42 +00:00
|
|
|
var tiddlerHtml = this.navigators.store.renderTiddler("text/html","SimpleTemplate",title);
|
2011-12-13 16:20:56 +00:00
|
|
|
if(tiddlerHtml) {
|
2011-12-28 16:10:03 +00:00
|
|
|
var article = $("<article/>").html(tiddlerHtml);
|
|
|
|
article.appendTo("body");
|
|
|
|
$("html,body").animate({
|
|
|
|
scrollTop: article.offset().top
|
|
|
|
}, 400);
|
2011-12-13 16:20:56 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
2011-12-14 14:11:11 +00:00
|
|
|
};
|
2011-12-13 16:20:56 +00:00
|
|
|
|
|
|
|
exports.StoryNavigator = StoryNavigator;
|
|
|
|
|
|
|
|
})();
|