From 9965c64b6fb99e3ac1c17b7689613c8c71f1a29d Mon Sep 17 00:00:00 2001 From: Jermolene Date: Mon, 5 May 2014 15:25:51 +0100 Subject: [PATCH] More refactoring of startup.js --- .../startup/{process-commands.js => commands.js} | 6 +++--- core/modules/startup/{main-render.js => render.js} | 6 +++--- core/modules/startup/rootwidget.js | 8 ++------ core/modules/startup/{setup-story.js => story.js} | 12 +++++++++--- 4 files changed, 17 insertions(+), 15 deletions(-) rename core/modules/startup/{process-commands.js => commands.js} (83%) rename core/modules/startup/{main-render.js => render.js} (96%) rename core/modules/startup/{setup-story.js => story.js} (89%) diff --git a/core/modules/startup/process-commands.js b/core/modules/startup/commands.js similarity index 83% rename from core/modules/startup/process-commands.js rename to core/modules/startup/commands.js index 0727ee7b6..a647d25a9 100644 --- a/core/modules/startup/process-commands.js +++ b/core/modules/startup/commands.js @@ -1,5 +1,5 @@ /*\ -title: $:/core/modules/startup/process-commands.js +title: $:/core/modules/startup/commands.js type: application/javascript module-type: startup @@ -13,9 +13,9 @@ Command processing "use strict"; // Export name and synchronous status -exports.name = "process-commands"; +exports.name = "commands"; exports.platforms = ["node"]; -exports.after = ["setup-story"]; +exports.after = ["story"]; exports.synchronous = false; exports.startup = function(callback) { diff --git a/core/modules/startup/main-render.js b/core/modules/startup/render.js similarity index 96% rename from core/modules/startup/main-render.js rename to core/modules/startup/render.js index d51cc358b..d4ac8933d 100644 --- a/core/modules/startup/main-render.js +++ b/core/modules/startup/render.js @@ -1,5 +1,5 @@ /*\ -title: $:/core/modules/startup/main-render.js +title: $:/core/modules/startup/render.js type: application/javascript module-type: startup @@ -13,9 +13,9 @@ Main stylesheet and page rendering "use strict"; // Export name and synchronous status -exports.name = "main-render"; +exports.name = "render"; exports.platforms = ["browser"]; -exports.after = ["rootwidget"]; +exports.after = ["story"]; exports.synchronous = true; // Time (in ms) that we defer refreshing changes to draft tiddlers diff --git a/core/modules/startup/rootwidget.js b/core/modules/startup/rootwidget.js index 6791fac0d..e1cfaf754 100644 --- a/core/modules/startup/rootwidget.js +++ b/core/modules/startup/rootwidget.js @@ -3,7 +3,7 @@ title: $:/core/modules/startup/rootwidget.js type: application/javascript module-type: startup -Setup the root widget +Setup the root widget and the core root widget handlers \*/ (function(){ @@ -15,7 +15,7 @@ Setup the root widget // Export name and synchronous status exports.name = "rootwidget"; exports.platforms = ["browser"]; -exports.after = ["setup-story"]; +exports.before = ["story"]; exports.synchronous = true; var widget = require("$:/core/modules/widgets/widget.js"); @@ -44,10 +44,6 @@ 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({ diff --git a/core/modules/startup/setup-story.js b/core/modules/startup/story.js similarity index 89% rename from core/modules/startup/setup-story.js rename to core/modules/startup/story.js index fac4a73a0..2634379c5 100644 --- a/core/modules/startup/setup-story.js +++ b/core/modules/startup/story.js @@ -1,5 +1,5 @@ /*\ -title: $:/core/modules/startup/setup-story.js +title: $:/core/modules/startup/story.js type: application/javascript module-type: startup @@ -13,7 +13,7 @@ Load core modules "use strict"; // Export name and synchronous status -exports.name = "setup-story"; +exports.name = "story"; exports.after = ["startup"]; exports.synchronous = true; @@ -41,6 +41,12 @@ exports.startup = function() { openStartupTiddlers({defaultToCurrentStory: true}); } },false) + // Listen for the tw-home message + $tw.rootWidget.addEventListener("tw-home",function(event) { + var storyFilter = $tw.wiki.getTiddlerText(DEFAULT_TIDDLERS_TITLE), + storyList = $tw.wiki.filterTiddlers(storyFilter); + $tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: "", list: storyList},$tw.wiki.getModificationFields()); + }); } }; @@ -77,7 +83,7 @@ function openStartupTiddlers(options) { var currStoryList = $tw.wiki.getTiddlerList(DEFAULT_STORY_TITLE); storyFilter = $tw.utils.stringifyList(currStoryList); } else { - storyFilter = $tw.wiki.getTiddlerText(DEFAULT_TIDDLERS_TITLE); + storyFilter = $tw.wiki.getTiddlerText(DEFAULT_TIDDLERS_TITLE); } } var storyList = $tw.wiki.filterTiddlers(storyFilter);