1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Add selective expandable table of contents macro

And improve the layout of the examples
This commit is contained in:
Jermolene 2014-08-19 12:30:22 +01:00
parent c4b76ceb0b
commit 58730b7452
5 changed files with 70 additions and 17 deletions

View File

@ -14,7 +14,7 @@ tags: $:/tags/Macro
</ol> </ol>
\end \end
\define toc-body(tag,show-button-filter) \define toc-expandable-body(tag,show-button-filter)
<$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>> <$set name="toc-state" value=<<qualify "$:/state/toc/$tag$-$(currentTiddler)$">>>
<li> <li>
<$link> <$link>
@ -40,7 +40,40 @@ tags: $:/tags/Macro
\define toc-expandable(tag) \define toc-expandable(tag)
<ol> <ol>
<$list filter="[tag[$tag$]]"> <$list filter="[tag[$tag$]]">
<<toc-body tag:"$tag$">> <<toc-expandable-body tag:"$tag$">>
</$list>
</ol>
\end
\define toc-selective-expandable-body(tag,show-button-filter)
<$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="btn-invisible">
{{$:/core/images/right-arrow}}
</$button>
</$reveal>
<$reveal type="match" state=<<toc-state>> text="open">
<$button set=<<toc-state>> setTo="close" class="btn-invisible">
{{$:/core/images/down-arrow}}
</$button>
</$reveal>
</$list>
<$view field="title"/>
</$link>
<$reveal type="match" state=<<toc-state>> text="open">
<$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>>/>
</$reveal>
</li>
</$set>
\end
\define toc-selective-expandable(tag)
<ol>
<$list filter="[tag[$tag$]]">
<<toc-selective-expandable-body tag:"$tag$">>
</$list> </$list>
</ol> </ol>
\end \end

View File

@ -0,0 +1,11 @@
title: TableOfContentsMacro Expandable Example
caption: Expandable
tags: table-of-contents-example
!! Expandable Table of Contents
<$macrocall $name="wikitext-example-without-html"
src="<div class='tw-table-of-contents'>
<<toc-expandable 'Contents'>>
</div>
"/>

View File

@ -0,0 +1,11 @@
title: TableOfContentsMacro Selective Expandable Example
caption: Selective Expandable
tags: table-of-contents-example
!! Selective Expandable Table of Contents
<$macrocall $name="wikitext-example-without-html"
src="<div class='tw-table-of-contents'>
<<toc-selective-expandable 'Contents'>>
</div>
"/>

View File

@ -0,0 +1,11 @@
title: TableOfContentsMacro Simple Example
caption: Simple
tags: table-of-contents-example
!! Simple Table of Contents
<$macrocall $name="wikitext-example-without-html"
src="<div class='tw-table-of-contents'>
<<toc 'Contents'>>
</div>
"/>

View File

@ -10,6 +10,7 @@ There are several variants of the macro:
* `<<toc>>` produces a simple hierarchical tree of links * `<<toc>>` produces a simple hierarchical tree of links
* `<<toc-expandable>>` produces an expandable tree of links * `<<toc-expandable>>` produces an expandable tree of links
* `<<toc-selective-expandable>>` produces an expandable tree of links where the expand/contract buttons are only shown for entries that possess child nodes
! Parameters ! Parameters
@ -18,18 +19,4 @@ There are several variants of the macro:
! Examples ! Examples
!! Simple Table of Contents <<tabs "[tag[table-of-contents-example]]" "TableOfContentsMacro Simple Example">>
<$macrocall $name="wikitext-example-without-html"
src="<div class='tw-table-of-contents'>
<<toc 'Contents'>>
</div>
"/>
!! Expandable Table of Contents
<$macrocall $name="wikitext-example-without-html"
src="<div class='tw-table-of-contents'>
<<toc-expandable 'Contents'>>
</div>
"/>