Refactor navigator widget configuration

@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.
print-window-tiddler
Jermolene 2015-06-19 16:44:20 +01:00
rodzic 61a722c7fd
commit b31803608b
3 zmienionych plików z 9 dodań i 9 usunięć

Wyświetl plik

@ -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 {

Wyświetl plik

@ -22,7 +22,7 @@ tc-page-container tc-page-view-$(themeTitle)$ tc-language-$(languageTitle)$
<div class=<<containerClasses>>>
<$navigator story="$:/StoryList" history="$:/HistoryList">
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}}>
<$dropzone>

Wyświetl plik

@ -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