mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-17 11:30:02 +00:00
Extend the navigator widget to maintain the "current-tiddler" field on the history list
This commit is contained in:
parent
9db887748b
commit
9bb600299f
@ -140,7 +140,8 @@ NavigatorWidget.prototype.addToHistory = function(title,fromPageRect) {
|
|||||||
$tw.utils.each(titles,function(title) {
|
$tw.utils.each(titles,function(title) {
|
||||||
historyList.push({title: title, fromPageRect: fromPageRect});
|
historyList.push({title: title, fromPageRect: fromPageRect});
|
||||||
});
|
});
|
||||||
this.wiki.setTiddlerData(this.historyTitle,historyList);
|
this.wiki.setTiddlerData(this.historyTitle,historyList,{"current-tiddler": titles[titles.length-1]});
|
||||||
|
this.wiki.addTiddler(new $tw.Tiddler());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
23
editions/tw5.com/tiddlers/mechanisms/HistoryMechanism.tid
Normal file
23
editions/tw5.com/tiddlers/mechanisms/HistoryMechanism.tid
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
created: 20140213171818824
|
||||||
|
modified: 20140213172236345
|
||||||
|
tags: mechanism
|
||||||
|
title: HistoryMechanism
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
The system tiddler [[$:/HistoryList]] keeps track of a list of tiddlers comprising the navigation history. Each time you click on a link to a tiddler, the title of the target tiddler is added to the top of the stack.
|
||||||
|
|
||||||
|
The history list is stored in JSON to allow additional details about the coordinates of the DOM node that initiated the navigation.
|
||||||
|
|
||||||
|
The history list also maintains the field ''current-tiddler'' that contains the name of the tiddler at the top of the stack. This field can be used like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
<$list filter="[list[$:/StoryList]]" history="$:/HistoryList" storyview="pop">
|
||||||
|
<$button message="tw-close-tiddler" class="btn-invisible btn-mini">×</$button> <$link to={{!!title}}><$view field="title"/> <$reveal type="match" state="$:/HistoryList!!current-tiddler" text=<<currentTiddler>>>✓</$reveal></$link>
|
||||||
|
</$list>
|
||||||
|
```
|
||||||
|
|
||||||
|
Which renders the same as the "Open" sidebar tab, with the addition of a tick against the tiddler that was last navigated to.
|
||||||
|
|
||||||
|
<$list filter="[list[$:/StoryList]]" history="$:/HistoryList" storyview="pop">
|
||||||
|
<$button message="tw-close-tiddler" class="btn-invisible btn-mini">×</$button> <$link to={{!!title}}><$view field="title"/> <$reveal type="match" state="$:/HistoryList!!current-tiddler" text=<<currentTiddler>>>✓</$reveal></$link>
|
||||||
|
</$list>
|
Loading…
x
Reference in New Issue
Block a user