Saq once wrote the InlineTabsPlugin, don't know if it still works with the
latest TW version:
DEMO
Note: you can space out the tabs to make editing easier, the linebreaks
between tabs will be ignored:
{{{
<tabs mytabs>
<tab tab1>
This is my first tab
</tab>
<tab tab2>
This is my second tab
</tab>
<tab tab3>
This is my third tab
with more than one line
</tab>
<tab tab4>
</tab>
</tabs>
}}}
InlineTabsPlugin
//{{{
config.formatters.unshift( {
name: "inlinetabs",
match: "\\<tabs",
lookaheadRegExp: /(?:<tabs (.*)>\n)((?:.|\n)*?)(?:\n<\/tabs>)/mg,
handler: function(w)
{
this.lookaheadRegExp.lastIndex = w.matchStart;
var lookaheadMatch = this.lookaheadRegExp.exec(w.source)
if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
{
var cookie = lookaheadMatch[1];
var wrapper = createTiddlyElement(null,"div",null,cookie);
var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
tabset.setAttribute("cookie",cookie);
var validTab = false;
var firstTab = '';
var tabregexp = /(?:<tab
(.*)>)(?:(?:\n)?)((?:.|\n)*?)(?:<\/tab>)/mg;
while((m = tabregexp.exec(lookaheadMatch[2])) != null)
{
if (firstTab == '') firstTab = m[1];
var tab =
createTiddlyButton(tabset,m[1],m[1],story.onClickInlineTab,"tab
tabUnselected");
tab.setAttribute("tab",m[1]);
tab.setAttribute("content",m[2]);
tab.title = m[1];
if(config.options[cookie] == m[1])
validTab = true;
}
if(!validTab)
config.options[cookie] = firstTab;
w.output.appendChild(wrapper);
story.switchInlineTab(tabset,config.options[cookie]);
w.nextMatch = this.lookaheadRegExp.lastIndex;
}
}
})
Story.prototype.switchInlineTab = function(tabset,tab)
{
var cookie = tabset.getAttribute("cookie");
var theTab = null
var nodes = tabset.childNodes;
for(var t=0; t<nodes.length; t++)
if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab)
{
theTab = nodes[t];
theTab.className = "tab tabSelected";
}
else
nodes[t].className = "tab tabUnselected"
if(theTab)
{
if(tabset.nextSibling && tabset.nextSibling.className ==
"tabContents")
tabset.parentNode.removeChild(tabset.nextSibling);
var tabContent = createTiddlyElement(null,"div",null,"tabContents");
tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
wikify(theTab.getAttribute("content"),tabContent);
if(cookie)
{
config.options[cookie] = tab;
saveOptionCookie(cookie);
}
}
}
Story.prototype.onClickInlineTab = function(e)
{
story.switchInlineTab(this.parentNode,this.getAttribute("tab"));
return false;
}
//}}}
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/tiddlywiki/-/Eczsen5Hs_QJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/tiddlywiki?hl=en.