toggling bookmarklets difficulty

4 views
Skip to first unread message

wolfgang

unread,
Oct 14, 2008, 1:47:47 PM10/14/08
to TiddlyWiki
Hi Eric,

I try to use the ToggleSiteTitles bookmarklet from tiddlytools to
toggle a hypergraph - which works fine for so far.

(http://www.TiddlyTools.com/#ToggleSiteTitles)

These inline scripts are only invoked it they are rendered at startup
time. Therefore I added a hidden span to the PageTemplate to get it
invoked:

<span style='display:none' macro='tiddler ToggleMenuGraph'></span>

- and a systemConfig with the following line:

config.options.chkHideMenuGraph=true;

- because I would like to have the hypergraph initially hidden.

However, this doesn't seem to work and the hypergraph div still shows
at startup.

Where I've gone wrong here?

Regards,

W.

http://dl.getdropbox.com/u/241006/hyperGraph.html#ToggleMenuGraph%20zconfig

Eric Shulman

unread,
Oct 14, 2008, 2:24:15 PM10/14/08
to TiddlyWiki
> Therefore I added a hidden span to the PageTemplate to get it
> invoked:
> <span style='display:none' macro='tiddler ToggleMenuGraph'></span>
> - and a systemConfig with the following line:
> config.options.chkHideMenuGraph=true;
> - because I would like to have the hypergraph initially hidden.
> However, this doesn't seem to work and the hypergraph div still shows
> at startup.

If all you want to do is to *set* the initial state based on the
current option value, this little script will do:

[[InitMenuGraph]]
<script>
var mg=document.getElementById('menuGraph');if(!mg)return;
mg.style.display=config.options.chkHideMenuGraph?'none':'block';
</script>

On the other hand, if you want to create an 'onclick' command link
that *toggles* the display state (and remembers it using a TW option
cookie), this script does the job:

[[ToggleMenuGraph]]
<script label="g">
var mg=document.getElementById('menuGraph');if(!mg)return;
config.options.chkHideMenuGraph=mg.style.display!='none';
mg.style.display=config.options.chkHideMenuGraph?'none':'block';
saveOptionCookie('chkHideMenuGraph');
return false;
</script>

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

wolfgang

unread,
Oct 14, 2008, 3:23:40 PM10/14/08
to TiddlyWiki
> If all you want to do is to *set* the initial state based on the
> current option value, this little script will do:
>
> [[InitMenuGraph]]
> <script>
> var mg=document.getElementById('menuGraph');if(!mg)return;
> mg.style.display=config.options.chkHideMenuGraph?'none':'block';
> </script>
>

Great!

Since I wanted to shorten the prolonged loading time of menuGraph at
start up - and then only invoke it when needed - this little script is
already perfect.

> On the other hand, if you want to create an 'onclick' command link
> that *toggles* the display state (and remembers it using a TW option
> cookie), this script does the job:
>
> [[ToggleMenuGraph]]
> <script label="g">
> var mg=document.getElementById('menuGraph');if(!mg)return;
> config.options.chkHideMenuGraph=mg.style.display!='none';
> mg.style.display=config.options.chkHideMenuGraph?'none':'block';
> saveOptionCookie('chkHideMenuGraph');
> return false;
> </script>
>
> enjoy,

But on the other hand, this custom ToggleMenuGraph script is only half
the size than what I came up with when I converted ToggleSiteTitles to
a bookmarklet by dragging it to my browser bar and copy/pasting it
back into the special menuButtons top menu of Dawn - which doesn't
allow any TW markup like script tiddler transclusion (at least I
wouldn't know how).

So I very happily use both of them at the same time :-)

Thanks for your prompt help,

W.
Reply all
Reply to author
Forward
0 new messages