From b31803608b13c8f34317572958910ae09ff211e7 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 19 Jun 2015 16:44:20 +0100 Subject: [PATCH] Refactor navigator widget configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @felixhayashi sorry I should have realised earlier that it’s worth doing it this way so that we can have different settings for different story rivers. --- core/modules/widgets/navigator.js | 12 +++++------- core/ui/PageTemplate.tid | 2 +- .../tw5.com/tiddlers/widgets/NavigatorWidget.tid | 4 +++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index ea543d058..43542f439 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -123,11 +123,9 @@ NavigatorWidget.prototype.addToStory = function(title,fromTitle) { // First we try to find the position of the story element we navigated from var fromIndex = storyList.indexOf(fromTitle); if(fromIndex >= 0) { - // How to open internal links that were clicked from *within* the story river? - var openLinkFromInsideRiver = $tw.wiki.getTiddlerText("$:/config/Navigation/openLinkFromInsideRiver","below"); // The tiddler is added from inside the river // Determine where to insert the tiddler; Fallback is "below" - switch(openLinkFromInsideRiver) { + switch(this.getAttribute("openLinkFromInsideRiver","below")) { case "top": slot = 0; break; @@ -137,14 +135,14 @@ NavigatorWidget.prototype.addToStory = function(title,fromTitle) { case "above": slot = fromIndex; break; + case "below": // Intentional fall-through default: slot = fromIndex + 1; + break; } } else { - // The tiddler is opened from outside the river. - var openLinkFromOutsideRiver = $tw.wiki.getTiddlerText("$:/config/Navigation/openLinkFromOutsideRiver","top"); - // Determine where to insert the tiddler; Default is "top" - if(openLinkFromOutsideRiver === "bottom") { + // The tiddler is opened from outside the river. Determine where to insert the tiddler; default is "top" + if(this.getAttribute("openLinkFromOutsideRiver","top") === "bottom") { // Insert at bottom slot = storyList.length; } else { diff --git a/core/ui/PageTemplate.tid b/core/ui/PageTemplate.tid index eb800ddc5..974d93cf4 100644 --- a/core/ui/PageTemplate.tid +++ b/core/ui/PageTemplate.tid @@ -22,7 +22,7 @@ tc-page-container tc-page-view-$(themeTitle)$ tc-language-$(languageTitle)$
>> -<$navigator story="$:/StoryList" history="$:/HistoryList"> +<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}}> <$dropzone> diff --git a/editions/tw5.com/tiddlers/widgets/NavigatorWidget.tid b/editions/tw5.com/tiddlers/widgets/NavigatorWidget.tid index e7356a15e..efcf9baf0 100644 --- a/editions/tw5.com/tiddlers/widgets/NavigatorWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/NavigatorWidget.tid @@ -1,5 +1,5 @@ created: 20131024141900000 -modified: 20140226194810214 +modified: 20150619154056283 tags: Widgets title: NavigatorWidget type: text/vnd.tiddlywiki @@ -16,6 +16,8 @@ The navigator widget displays any contained content, and responds to Messages di |!Attribute |!Description | |story |Name of the tiddler containing the story list to be manipulated | |history |Name of the tiddler containing the history list to be manipulated | +|openLinkFromInsideRiver |Determines the location for opening new tiddlers from links within the story river: at the ''top'' or ''bottom'' of the story river, or ''above'' or ''below'' the current tiddler | +|openLinkFromOutsideRiver|Determines the location for opening new tiddlers from linkes outside the story river: at the ''top'' or ''bottom'' of the story river| ! Widget Messages