> I loved your CloseHack so much I made a movie
Nice!
I should probably package this as a proper plugin then...
Remind me next week perhaps.
> Your hack at least gets the person back to the "parent" tiddler, is
> there some way of getting the person back to the location where the
> were when they clicked the link?
Do you mean the vertical scrolling position?
That's relatively simple:
---------------
//{{{
(function() {
var _closeTiddler = config.commands.closeTiddler.handler;
config.commands.closeTiddler.handler = function(event, src, title) {
var tiddlerElem = story.getTiddler(title);
var origin = tiddlerElem.getAttribute("origin");
var status = _closeTiddler.apply(this, arguments);
if(origin) {
// hack to provide TiddlyWiki functions with reference element
var root = document.getElementById("tiddlerDisplay");
var el = createTiddlyElement(root, "div", null, null, null, {
style: "position: absolute; top: " + origin + "px;"
});
if(config.options.chkAnimate) {
anim.startAnimating(new Zoomer(title, tiddlerElem, el),
new Scroller(el));
} else {
window.scrollTo(0, ensureVisible(el));
}
el.parentNode.removeChild(el);
}
return status;
};
var _onClickTiddlerLink = onClickTiddlerLink;
onClickTiddlerLink = function(ev) {
var status = _onClickTiddlerLink.apply(this, arguments);
var target = resolveTarget(ev || window.event);
var link = target;
do {
title = link.getAttribute("tiddlyLink");
link = link.parentNode;
} while(title === null && link !== null);
var el = story.getTiddler(title);
var origin = getScrollTop();
el.setAttribute("origin", origin);
return status;
};
// based on http://stackoverflow.com/questions/871399#872537
var getScrollTop = function() {
if(window.pageYOffset) {
return window.pageYOffset;
} else { // IE
var doc = document.documentElement;
doc = doc.clientHeight ? doc : document.body;
return doc.scrollTop;
}
};
})();
//}}}
---------------
However, if you change the story contents (e.g. by closing a tiddler),
the previously recorded scroll position isn't very meaningful anymore...
-- F.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---