1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Add support for tw-home message

This commit is contained in:
Jermolene 2014-03-12 22:32:13 +00:00
parent c4119f4f93
commit 50cf9678cb
2 changed files with 31 additions and 14 deletions

View File

@ -55,6 +55,8 @@ exports.startup = function() {
"$:/themes/tiddlywiki/vanilla"
]
});
// Display the default tiddlers
var displayDefaultTiddlers = function() {
// Get the default tiddlers
var defaultTiddlersTitle = "$:/DefaultTiddlers",
defaultTiddlersTiddler = $tw.wiki.getTiddler(defaultTiddlersTitle),
@ -62,13 +64,15 @@ exports.startup = function() {
if(defaultTiddlersTiddler) {
defaultTiddlers = $tw.wiki.filterTiddlers(defaultTiddlersTiddler.fields.text);
}
// Initialise the story and history
// Initialise the story
var storyTitle = "$:/StoryList",
story = [];
for(var t=0; t<defaultTiddlers.length; t++) {
story[t] = defaultTiddlers[t];
}
$tw.wiki.addTiddler({title: storyTitle, text: "", list: story},$tw.wiki.getModificationFields());
};
displayDefaultTiddlers();
// Set up the syncer object
$tw.syncer = new $tw.Syncer({wiki: $tw.wiki});
// Host-specific startup
@ -111,6 +115,10 @@ exports.startup = function() {
$tw.rootWidget.addEventListener("tw-scroll",function(event) {
$tw.pageScroller.handleEvent(event);
});
// Listen for the tw-home message
$tw.rootWidget.addEventListener("tw-home",function(event) {
displayDefaultTiddlers();
});
// Install the save action handlers
$tw.rootWidget.addEventListener("tw-save-wiki",function(event) {
$tw.syncer.saveWiki({

View File

@ -0,0 +1,9 @@
created: 20140312223013470
modified: 20140312223134387
tags: message
title: WidgetMessage: tw-home
type: text/vnd.tiddlywiki
The `tw-home` message resets the story list to the tiddlers defined in [[$:/DefaultTiddlers]]. It does not require any properties on the `event` object.
The cancel tiddler message is usually generated with the ButtonWidget and is handled by the core.