1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-16 23:04:50 +00:00
TiddlyWiki5/core/wiki/macros/toc.tid

187 lines
6.9 KiB
Plaintext
Raw Normal View History

title: $:/core/macros/toc
tags: $:/tags/Macro
2014-11-13 21:39:28 +00:00
\define toc-body(rootTag,tag,sort:"",itemClassFilter)
2014-08-31 13:05:43 +00:00
<ol class="tc-toc">
<$list filter="""[tag[$tag$]!has[draft.of]$sort$]""">
2014-11-13 21:39:28 +00:00
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$list filter="[is[current]toc-link[no]]" emptyMessage="<$link><$view field='caption'><$view field='title'/></$view></$link>">
<$view field="caption">
<$view field="title"/>
</$view>
</$list>
<$list filter="""[all[current]] -[[$rootTag$]]""">
2014-11-13 21:39:28 +00:00
<$macrocall $name="toc-body" rootTag="""$rootTag$""" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$list>
</li>
2014-11-13 21:39:28 +00:00
</$set>
</$list>
</ol>
\end
2014-11-13 21:39:28 +00:00
\define toc(tag,sort:"",itemClassFilter)
<<toc-body rootTag:"""$tag$""" tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""itemClassFilter""">>
\end
2014-11-13 21:39:28 +00:00
\define toc-linked-expandable-body(tag,sort:"",itemClassFilter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
2014-11-13 21:39:28 +00:00
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$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">
2014-11-13 21:39:28 +00:00
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$reveal>
</li>
</$set>
2014-11-13 21:39:28 +00:00
</$set>
\end
2014-11-13 21:39:28 +00:00
\define toc-unlinked-expandable-body(tag,sort:"",itemClassFilter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
2014-11-13 21:39:28 +00:00
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$reveal type="nomatch" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
<$view field="caption">
<$view field="title"/>
</$view>
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
<$view field="caption">
<$view field="title"/>
</$view>
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
2014-11-13 21:39:28 +00:00
<$macrocall $name="toc-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$reveal>
</li>
</$set>
2014-11-13 21:39:28 +00:00
</$set>
\end
2014-11-13 21:39:28 +00:00
\define toc-expandable(tag,sort:"",itemClassFilter)
2014-08-31 13:05:43 +00:00
<ol class="tc-toc toc-expandable">
<$list filter="[tag[$tag$]!has[draft.of]$sort$]">
2014-11-13 21:39:28 +00:00
<$list filter="[is[current]toc-link[no]]" emptyMessage="<<toc-linked-expandable-body tag:'$tag$' sort:'$sort$' itemClassFilter:'$itemClassFilter$'>>">
<<toc-unlinked-expandable-body tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""itemClassFilter""">>
</$list>
</$list>
</ol>
\end
2014-11-13 21:39:28 +00:00
\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
2014-11-13 21:39:28 +00:00
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$link>
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
<$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">
2014-11-13 21:39:28 +00:00
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$reveal>
</li>
</$set>
2014-11-13 21:39:28 +00:00
</$set>
\end
2014-11-13 21:39:28 +00:00
\define toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
2014-11-13 21:39:28 +00:00
<$set name="toc-item-class" filter="""$itemClassFilter$""" value="toc-item-selected" emptyValue="toc-item">
<li class=<<toc-item-class>>>
<$list filter="[all[current]tagging[]limit[1]]" variable="ignore" emptyMessage="<$button class='tc-btn-invisible'>{{$:/core/images/blank}}</$button> <$view field='caption'><$view field='title'/></$view>">
<$reveal type="nomatch" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="open" class="tc-btn-invisible">
{{$:/core/images/right-arrow}}
<$view field="caption">
<$view field="title"/>
</$view>
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="tc-btn-invisible">
{{$:/core/images/down-arrow}}
<$view field="caption">
<$view field="title"/>
</$view>
</$button>
</$reveal>
</$list>
<$reveal type="match" state=<<toc-state>> text="open">
2014-11-13 21:39:28 +00:00
<$macrocall $name="""toc-selective-expandable""" tag=<<currentTiddler>> sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""/>
</$reveal>
</li>
</$set>
2014-11-13 21:39:28 +00:00
</$set>
\end
2014-11-13 21:39:28 +00:00
\define toc-selective-expandable(tag,sort:"",itemClassFilter)
2014-08-31 13:05:43 +00:00
<ol class="tc-toc toc-selective-expandable">
<$list filter="[tag[$tag$]!has[draft.of]$sort$]">
2014-11-13 21:39:28 +00:00
<$list filter="[is[current]toc-link[no]]" variable="ignore" emptyMessage="<<toc-linked-selective-expandable-body tag:'$tag$' sort:'$sort$' itemClassFilter:'$itemClassFilter$'>>">
<<toc-unlinked-selective-expandable-body tag:"""$tag$""" sort:"""$sort$""" itemClassFilter:"""$itemClassFilter$""">>
</$list>
</$list>
</ol>
\end
2014-11-13 21:39:28 +00:00
\define toc-tabbed-selected-item-filter(selectedTiddler)
[all[current]field:title{$selectedTiddler$}]
\end
2014-11-15 12:29:46 +00:00
\define toc-tabbed-external-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText)
2014-11-13 21:39:28 +00:00
<$tiddler tiddler={{$selectedTiddler$}}>
<div class="tc-tabbed-table-of-contents">
<$linkcatcher to="$selectedTiddler$">
2014-11-13 21:39:28 +00:00
<div class="tc-table-of-contents">
<$macrocall $name="toc-selective-expandable" tag="""$tag$""" sort="""$sort$""" itemClassFilter=<<toc-tabbed-selected-item-filter selectedTiddler:"""$selectedTiddler$""">>/>
</div>
</$linkcatcher>
2014-11-13 21:39:28 +00:00
<div class="tc-tabbed-table-of-contents-content">
<h1><$view field="caption"><$view field="title"/></$view></h1>
<$transclude mode="block">$unselectedText$</$transclude>
</div>
</div>
</$tiddler>
\end
\define toc-tabbed-internal-nav(tag,sort:"",selectedTiddler:"$:/temp/toc/selectedTiddler",unselectedText)
<$linkcatcher to="""$selectedTiddler$""">
2014-11-15 12:29:46 +00:00
<$macrocall $name="toc-tabbed-external-nav" tag="""$tag$""" sort="""$sort$""" selectedTiddler="""$selectedTiddler$""" unselectedText="""$unselectedText$"""/>
2014-11-13 21:39:28 +00:00
</$linkcatcher>
\end