> I've got a very nice script from Mark S.
> 1)
> I would like to use it from a button in a custom toolbar for a
> tiddler.
InlineJavascriptPlugin enables you to quickly create an 'onclick'
command link from *any* script, simply by adding label="..." (and
optional title="...") to the script definition syntax, like this:
<script label="click here" title="this text appears on mousover">
... code goes here ...
</script>
When the plugin detects the label="..." syntax, it creates a command
link using the indicated label text, so that instead of immediately
invoking the script as soon as it is rendered, it is only invoked when
that link is subsequently clicked upon.
To use this command link in a tiddler toolbar definition, first put
the script into a separate tiddler (e.g., "MyCommand") and then
either:
A) In the ViewTemplate or EditTemplate, you can insert the following
immediately preceding or following any existing toolbar definition,
e.g.,:
<div class='toolbar' macro='tiddler MyCommand'></div>
<div class='toolbar' macro='toolbar
[[ToolbarCommands::ViewToolbar]]'></div>
OR
B) Install
http://www.TiddlyTools.com/#CoreTweaks
specifically tweak #608/609/610, which extends the core's toolbar
syntax so that -- in addition to standard toolbar command keywords --
TiddlerNames can be used to 'transclude' content directly into a
toolbar definition. This allows you to use the tiddler name,
MyCommand, anywhere within the standard
[[ToolbarCommands::ViewToolbar]] slice, like this:
|~ViewToolbar|MyCommand closeTiddler closeOthers +editTiddler > fields
syncing permalink references jump|
In either case, the result will be that the 'onclick' inline script
defined in MyCommand will appear as a button in each tiddler's
toolbar, ready to be clicked upon to perform it's scripted actions.
Note that either technique can also be very use for embedding
'regular' macro-based command links as well. For example, create a
tiddler called [[NewTiddlerCommand]] containing just this single
macro:
<<newTiddler>>
Then, either edit the template or the toolbar slice definition to add
a reference to "NewTiddlerCommand". The result will be that the "new
tiddler" command link will then automatically appear in the toolbar of
every tiddler.
enjoy,
-e