mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Refactored story navigator to work by modifying the story tiddlers
Currently hardwiring the name of the tiddler containing the story
This commit is contained in:
parent
0d45d76af6
commit
aba830ff8c
@ -116,7 +116,7 @@ var App = function() {
|
||||
window.setInterval(function() {
|
||||
me.store.addTiddler(new Tiddler({
|
||||
title: "TiddlyWiki5",
|
||||
text: "This tiddler is new"
|
||||
text: "This tiddler is new at " + (new Date()).toString()
|
||||
}));
|
||||
},3000);
|
||||
// Register an event handler to handle refreshing the DOM
|
||||
|
@ -9,17 +9,20 @@ This browser component manages navigating to new tiddlers in a TiddlyWiki classi
|
||||
/*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) {
|
||||
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");
|
||||
var store = this.navigators.store,
|
||||
tiddler = store.getTiddler(title),
|
||||
storyTiddler = store.getTiddler("StoryTiddlers");
|
||||
if(tiddler) {
|
||||
store.addTiddler(new Tiddler(storyTiddler,{text: title + "\n" + storyTiddler.text}));
|
||||
$("html,body").animate({
|
||||
scrollTop: article.offset().top
|
||||
scrollTop: 0
|
||||
}, 400);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -29,7 +29,7 @@ var Tiddler = function(/* tiddler,fields */) {
|
||||
arg = arguments[c];
|
||||
src = null;
|
||||
if(arg instanceof Tiddler) {
|
||||
src = arg.fields;
|
||||
src = arg.getFields();
|
||||
} else {
|
||||
src = arg;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user