Add support for retaining tab content

Fixes #2031
This commit is contained in:
Jermolene 2018-04-08 09:47:57 +01:00
parent f4496d8fd3
commit ea763d0eab
2 changed files with 5 additions and 3 deletions

View File

@ -1,7 +1,7 @@
title: $:/core/macros/tabs
tags: $:/tags/Macro
\define tabs(tabsList,default,state:"$:/state/tab",class,template,buttonTemplate)
\define tabs(tabsList,default,state:"$:/state/tab",class,template,buttonTemplate,retain)
<div class="tc-tab-set $class$">
<div class="tc-tab-buttons $class$">
<$list filter="$tabsList$" variable="currentTab"><$set name="save-currentTiddler" value=<<currentTiddler>>><$tiddler tiddler=<<currentTab>>><$button set=<<qualify "$state$">> setTo=<<currentTab>> default="$default$" selectedClass="tc-tab-selected" tooltip={{!!tooltip}}>
@ -18,7 +18,7 @@ tags: $:/tags/Macro
<div class="tc-tab-content $class$">
<$list filter="$tabsList$" variable="currentTab">
<$reveal type="match" state=<<qualify "$state$">> text=<<currentTab>> default="$default$">
<$reveal type="match" state=<<qualify "$state$">> text=<<currentTab>> default="$default$" retain="""$retain$""">
<$transclude tiddler="$template$" mode="block">

View File

@ -1,6 +1,6 @@
caption: tabs
created: 20131228162203521
modified: 20171113135543552
modified: 20180408084453861
tags: Macros [[Core Macros]]
title: tabs Macro
type: text/vnd.tiddlywiki
@ -25,6 +25,8 @@ By default the tabs are arranged horizontally above the content. To get vertical
: Optionally, the title of a tiddler to use as a [[template|TemplateTiddlers]] for transcluding the content of the selected tab
;buttonTemplate
: Optionally, the title of a tiddler to use as a [[template|TemplateTiddlers]] for transcluding the content of the button for the selected tab
;retain
: Optionally, "yes" specifies that the content of the tabs should be retained when switching to another tab, avoiding re-rendering it (this can be useful to avoid video or audio sources unexpectedly resetting)
Within the template, the title of the selected tab is available in the <<.var currentTab>> variable.