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:
parent
c4119f4f93
commit
50cf9678cb
@ -55,20 +55,24 @@ exports.startup = function() {
|
||||
"$:/themes/tiddlywiki/vanilla"
|
||||
]
|
||||
});
|
||||
// Get the default tiddlers
|
||||
var defaultTiddlersTitle = "$:/DefaultTiddlers",
|
||||
defaultTiddlersTiddler = $tw.wiki.getTiddler(defaultTiddlersTitle),
|
||||
defaultTiddlers = [];
|
||||
if(defaultTiddlersTiddler) {
|
||||
defaultTiddlers = $tw.wiki.filterTiddlers(defaultTiddlersTiddler.fields.text);
|
||||
}
|
||||
// Initialise the story and history
|
||||
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());
|
||||
// Display the default tiddlers
|
||||
var displayDefaultTiddlers = function() {
|
||||
// Get the default tiddlers
|
||||
var defaultTiddlersTitle = "$:/DefaultTiddlers",
|
||||
defaultTiddlersTiddler = $tw.wiki.getTiddler(defaultTiddlersTitle),
|
||||
defaultTiddlers = [];
|
||||
if(defaultTiddlersTiddler) {
|
||||
defaultTiddlers = $tw.wiki.filterTiddlers(defaultTiddlersTiddler.fields.text);
|
||||
}
|
||||
// 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({
|
||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user