Refactoring request: Popup code

1 view
Skip to first unread message

Saq Imtiaz

unread,
Jan 2, 2007, 1:33:36 PM1/2/07
to TiddlyWikiDev
So I've been playing a lot with various types of popup divs in TW over the last few days: lightboxes, dynamic tooltips etc.

One of the things that I realized is that with just a little refactoring, the exisiting popup code could be used for a lot of it.

For example, in Popup.create, we could pass it two extra optional arguments. The first to determine the dom element being created, instead of the default "ol" and the second for a class, instead of "popup".
The default can still be the old values, maintaining backwards compatibility.

Something like this:
Popup.create = function(root
,elem,theClass)
{
Popup.remove();
var popup = createTiddlyElement(document.body,elem? elem :"ol","popup", theClass? theClass :"popup");
Popup.stack.push({root: root, popup: popup});
return popup;
}
Perhaps even a custom id!
Similary, Popup.show performs two main functions:
1) determining the position of the popup
2) displaying the popup and scrolling to ensure its visibility of required.
If the code for determing the position was factored out into a separate function, it could be very useful as well.

I realize these arent the biggest of functions to start off with, but its a real shame to have rewrite the code when its already there.
Cheers,
Saq

Jeremy Ruston

unread,
Jan 2, 2007, 1:40:43 PM1/2/07
to Tiddly...@googlegroups.com
That's a good idea Saq, definitely worth doing. Would you like to ticket it? :)

Cheers

Jeremy


--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com

Saq Imtiaz

unread,
Jan 2, 2007, 1:42:46 PM1/2/07
to Tiddly...@googlegroups.com
Sure thing, why stop now eh? :)
Cheers,
Saq
Reply all
Reply to author
Forward
0 new messages