Hello guys!
Sometimes I use the tiddlyWiki for taking notes, now I decided to make a
'website' using the tiddlyWiki.
I like opening multiple tiddlers, but I also need now to make some links
close all other tiddlers (it's not nice to have tiddler like 'About' stuck
on the bottom of the page unless manually closed).
As the plugin for single-page tiddler is not what I want, I added a few
lines to treat links beginning with '@' specially - clicking such link
opens selected tiddler and closes all others.
Eg. [[About]] opens tiddler About, [[@About]] or [[About|@About]] replaces
all open tiddlers with About tiddler.
I like my solution, as it's simple to use, and I think other people may
like it as well.
Do you plan any such functionality in future? If you want, you can re-use
my code (patch below).
Cheers,
Jan
==================================================================
--- index_old.htm 2013-02-27 21:37:00.000000000 +0100
+++ index.htm 2013-02-27 21:36:18.000000000 +0100
@@ -7742,10 +7742,12 @@
var title = null;
var fields = null;
var noToggle = null;
+ var closeOthers = null;
do {
title = link.getAttribute("tiddlyLink");
fields = link.getAttribute("tiddlyFields");
noToggle = link.getAttribute("noToggle");
+ closeOthers = link.getAttribute("tiddlyCloseOthers");
link = link.parentNode;
} while(title == null && link != null);
if(!store.isShadowTiddler(title)) {
@@ -7761,6 +7763,8 @@
if(store.getTiddler(title))
fields = null;
story.displayTiddler(target,title,null,true,null,fields,toggling);
+ if(closeOthers)
+ story.closeAllTiddlers(title);
}
clearMessage();
return false;
@@ -7769,6 +7773,11 @@
function
createTiddlyLink(place,title,includeText,className,isStatic,linkedFromTiddler,noToggle)
{
var title = jQuery.trim(title);
+ var closeOthers = false;
+ if(title.charAt(0) == '@'){
+ closeOthers = true;
+ title = title.substring(1);
+ }
var text = includeText ? title : null;
var i = getTiddlyLinkInfo(title,className);
var btn = isStatic ?
createExternalLink(place,store.getTiddlerText("SiteUrl",null) + "#" +
title) :
createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes);
@@ -7776,6 +7785,8 @@
btn.className += ' ' + className;
btn.setAttribute("refresh","link");
btn.setAttribute("tiddlyLink",title);
+ if(closeOthers)
+ btn.setAttribute("tiddlyCloseOthers","true");
if(noToggle)
btn.setAttribute("noToggle","true");
if(linkedFromTiddler) {
==================================================================
--
You received this message because you are subscribed to the Google Groups
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.