mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-03 12:23:51 +00:00
Core: Allow startup navigation to be suppressed
Plugins can suppress it so that they can provide their own startup scroll handling
This commit is contained in:
parent
477c41f843
commit
348a0bc8bc
@ -36,7 +36,9 @@ var HELP_OPEN_EXTERNAL_WINDOW = "http://tiddlywiki.com/#WidgetMessage%3A%20tm-op
|
|||||||
|
|
||||||
exports.startup = function() {
|
exports.startup = function() {
|
||||||
// Open startup tiddlers
|
// Open startup tiddlers
|
||||||
openStartupTiddlers();
|
openStartupTiddlers({
|
||||||
|
disableHistory: $tw.boot.disableStartupNavigation
|
||||||
|
});
|
||||||
if($tw.browser) {
|
if($tw.browser) {
|
||||||
// Set up location hash update
|
// Set up location hash update
|
||||||
$tw.wiki.addEventListener("change",function(changes) {
|
$tw.wiki.addEventListener("change",function(changes) {
|
||||||
@ -106,6 +108,7 @@ exports.startup = function() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Process the location hash to open the specified tiddlers. Options:
|
Process the location hash to open the specified tiddlers. Options:
|
||||||
|
disableHistory: if true $:/History is NOT updated
|
||||||
defaultToCurrentStory: If true, the current story is retained as the default, instead of opening the default tiddlers
|
defaultToCurrentStory: If true, the current story is retained as the default, instead of opening the default tiddlers
|
||||||
*/
|
*/
|
||||||
function openStartupTiddlers(options) {
|
function openStartupTiddlers(options) {
|
||||||
@ -146,15 +149,18 @@ function openStartupTiddlers(options) {
|
|||||||
}
|
}
|
||||||
// Save the story list
|
// Save the story list
|
||||||
$tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: "", list: storyList},$tw.wiki.getModificationFields());
|
$tw.wiki.addTiddler({title: DEFAULT_STORY_TITLE, text: "", list: storyList},$tw.wiki.getModificationFields());
|
||||||
// If a target tiddler was specified add it to the history stack
|
// Update history
|
||||||
if(target && target !== "") {
|
if(!options.disableHistory) {
|
||||||
// The target tiddler doesn't need double square brackets, but we'll silently remove them if they're present
|
// If a target tiddler was specified add it to the history stack
|
||||||
if(target.indexOf("[[") === 0 && target.substr(-2) === "]]") {
|
if(target && target !== "") {
|
||||||
target = target.substr(2,target.length - 4);
|
// The target tiddler doesn't need double square brackets, but we'll silently remove them if they're present
|
||||||
}
|
if(target.indexOf("[[") === 0 && target.substr(-2) === "]]") {
|
||||||
$tw.wiki.addToHistory(target);
|
target = target.substr(2,target.length - 4);
|
||||||
} else if(storyList.length > 0) {
|
}
|
||||||
$tw.wiki.addToHistory(storyList[0]);
|
$tw.wiki.addToHistory(target);
|
||||||
|
} else if(storyList.length > 0) {
|
||||||
|
$tw.wiki.addToHistory(storyList[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user