> In StoryViewPlugin, I can see where hitting the "next" button,
> activates the switch/case"next" condition...... my question is ...can
> I put a simple function call inside that case"next" condition that
> activates another bit of code?
Actually, that code doesn't handle the *click* on the next button, it
handles the *creation* of the next button when the macro is rendered.
The next button is actually just a standard TiddlyLink to the next
tiddler in the story. Unfortunately, this means that the standard
TWCore link handler is doing the work when a click is processed, so
adding custom code to that link is problematic, at best.
Fortunately, there *is* a way to achieve your desired goal, by
*redefining* StoryViewerPlugin's "renderLink()" function so that the
"next" link is actually created as a TiddlyButton with a custom
handler, rather than a standard TiddlyLink. Here's the current code:
------------------
renderLink: function(place,tid,target,label) {
// override default labelling with specified text (if any)
if (tid==target) { // self-referential links turn into 'refresh
links'
var
btn=createTiddlyButton(place,null,this.refreshmsg.format([tid]),
function() {
var
here=story.findContainingTiddler(place).getAttribute("tiddler");
story.refreshTiddler(here,null,true);
});
wikify(label,btn);
}
else // create link
wikify(label,createTiddlyLink(place,target,false));
},
------------------
This code mostly creates a standard TiddlyLink, but also has a special
conditional clause that has code to create a custom "refresh link"
when link target is the same as the current tiddler. To add your
special "next" link handling, you could add another conditional clause
with similar code, like this:
----------------------
renderLink: function(place,tid,target,label) {
// override default labelling with specified text (if any)
if (tid==target) { // self-referential links turn into 'refresh
links'
...
} else if (label=="next") { // custom handler for "next" links
var
btn=createTiddlyButton(place,null,store.getTiddler(tid).getSubtitle(),
function() {
var here=story.findContainingTiddler(this);
var target=this.getAttribute("tiddler");
story.displayTiddler(here,target);
// ADD YOUR CUSTOM HANDLING HERE
});
btn.setAttribute("tiddler",tid);
wikify(label,btn);
}
else // create link
wikify(label,createTiddlyLink(place,target,false));
},
--------------------
> Is it ethical to change the Plugin code? Should I recall the plugin
> something different (similiar)? or can I add this requirement in a way
> that does not mesh with the original?
You should create a separate tiddler named StoryViewerPluginTweaks (or
similar), tagged with systemConfig. Then, you put the modified code
in that tiddler. Because tiddlers are processed alphabetically
during startup, StoryViewerPlugin is processed first, and then any
changes contained in StoryViewerPluginTweaks is processed.
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
----
TiddlyTools needs YOUR financial support...
Help ME to continue to help YOU...
make a generous donation today:
http://www.TiddlyTools.com/#Donations
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
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.