1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-26 07:13:15 +00:00

Introduce a PageMacros tiddler containing a tabs macro

This is a hacky way of having macro definitions that behave as if they
are global to the wiki.

The new tabs macro itself is cool, though: neatly encapsulates most of
the gubbins around a tab control, and the rendering is quite easy to
style.
This commit is contained in:
Jeremy Ruston 2013-11-04 18:21:20 +00:00
parent e42548997e
commit 63243c5855
5 changed files with 29 additions and 4 deletions

View File

@ -102,8 +102,8 @@ exports.startup = function() {
$tw.rootWidget.addEventListener("tw-clear-password",function(event) {
$tw.crypto.setPassword(null);
});
// Display the PageTemplate
var templateTitle = "$:/core/ui/PageTemplate",
// Display the PageMacros, which includes the PageTemplate
var templateTitle = "$:/core/ui/PageMacros",
parser = $tw.wiki.new_parseTiddler(templateTitle);
$tw.pageWidgetNode = $tw.wiki.makeWidget(parser,{document: document, parentWidget: $tw.rootWidget});
$tw.pageContainer = document.createElement("div");

17
core/ui/PageMacros.tid Normal file
View File

@ -0,0 +1,17 @@
title: $:/core/ui/PageMacros
\define tabs(tabsList,default,state:"$:/currentTab")
<div class="tw-tab-buttons"><$list filter="$tabsList$" variable="currentTab"><$button set=<<qualify "$state$">> setTo=<<currentTab>> default="$default$" selectedClass="tw-tab-selected"><$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/> </$button>
</$list>
</div>
<div class="tw-tab-divider">
</div>
<div class="tw-tab-content">
<$list filter="$tabsList$" variable="currentTab">
<$reveal type="match" state=<<qualify "$state$">> text=<<currentTab>> default="$default$">
<$transclude tiddler=<<currentTab>>/>
</$reveal>
</$list>
</div>
\end
{{$:/core/ui/PageTemplate}}

View File

@ -1,3 +1,3 @@
title: $:/state/moreSideBarTabSet-{$:/core/ui/MoreSideBar|$:/core/ui/MoreSideBar||}{$:/core/ui/SideBar|$:/core/ui/SideBar||}
title: $:/state/moreSideBarTabSet-{$:/core/ui/MoreSideBar|$:/core/ui/MoreSideBar||}{$:/core/ui/SideBar|$:/core/ui/SideBar||}{$:/core/ui/PageTemplate|$:/core/ui/PageTemplate||}
tagsTab

View File

@ -1,3 +1,3 @@
title: $:/state/sideBarTabSet-{$:/core/ui/SideBar|$:/core/ui/SideBar||}
title: $:/state/sideBarTabSet-{$:/core/ui/SideBar|$:/core/ui/SideBar||}{$:/core/ui/PageTemplate|$:/core/ui/PageTemplate||}
openTab

View File

@ -0,0 +1,8 @@
title: TabsExample
tags: samples
Here is an example of the tabs macro:
<<tabs "Docs WikiText Features RoadMap" "WikiText" 1>>
<<tabs "[tag[tips]]" "GoogleChromeTips" 2>>