1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-03 14:59:57 +00:00
TiddlyWiki5/core/wiki/macros/toc.tid
2014-08-28 17:28:32 +01:00

86 lines
2.0 KiB
Plaintext

title: $:/core/macros/toc
tags: $:/tags/Macro
\define toc(tag,sort:"")
<ol>
<$list filter="[tag[$tag$]$sort$]">
<li>
<$link>
<$view field="caption">
<$view field="title"/>
</$view>
</$link>
<$macrocall $name="toc" tag=<<currentTiddler>>/>
</li>
</$list>
</ol>
\end
\define toc-expandable-body(tag,sort:"")
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
<li>
<$link>
<$reveal type="nomatch" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
<$view field="caption">
<$view field="title"/>
</$view>
</$link>
<$reveal type="match" state=<<toc-state>> text="open">
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="$sort$"/>
</$reveal>
</li>
</$set>
\end
\define toc-expandable(tag,sort:"")
<ol>
<$list filter="[tag[$tag$]$sort$]">
<<toc-expandable-body tag:"$tag$" sort:"$sort$">>
</$list>
</ol>
\end
\define toc-selective-expandable-body(tag,sort:"")
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
<li>
<$link>
<$list filter="[all[current]tagging[]limit[1]]">
<$reveal type="nomatch" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
</$list>
<$view field="caption">
<$view field="title"/>
</$view>
</$link>
<$reveal type="match" state=<<toc-state>> text="open">
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort="$sort$"/>
</$reveal>
</li>
</$set>
\end
\define toc-selective-expandable(tag,sort:"")
<ol>
<$list filter="[tag[$tag$]$sort$]">
<<toc-selective-expandable-body tag:"$tag$" sort:"$sort$">>
</$list>
</ol>
\end