That's awesome, Michael. Thank you!
Hi all, > Just wanted to let you all know that the jQuery adapter has been updated > to include the kind of sweet jQuery functionality that Mike is talking about > in this email. Head on over and give it a shot if you haven't already. > > http://mjijackson.com/2008/01/22/shadowbox-js-media-viewer-1-0-beta/ > > Thanks, > > Michael > > On Jan 25, 2008, at 4:20 PM, Mike Alsup wrote: > > I'm putting the finishing touches on a media viewer application that I > > coded up recently (think Thickbox). It can be used with jQuery or any > > other library. I created an adapter for jQuery, and I thought that > > somebody on this list might be interested. > > > > > > Michael, > > I really love what you've done with shadowbox. But I dislike having to > add specific markup to drive the behavior. And as a jQuery user I really > want to invoke it like this (for example): > > $('a[href$=swf]').shadowbox(); > > So if you're open to suggestion, I'd love to see a minor modification. > Here's what I changed to make it more amendable to the jQuery calling style. > > 1. Added this method to shadowbox.js (just below the current "setup" fn): > > Shadowbox.setup2 = function(links){ > for(var i = 0, len = links.length; i < len; ++i) > setupLink(links[i]); > }; > > 2. Added this to shadowbox-jquery.js: > > jQuery.fn.shadowbox = function() { > Shadowbox.setup2(this); > }; > > > Now I can call it like this without having to change any markup anywhere, > so it becomes a drop-in replacement: > > $(function() { > var options = { /* whatever */ }; > Shadowbox.init(options); > > $('a[href$=swf]').shadowbox(); > }); > > > Of course there are more restrictions than one might expect from a > traditional jQuery plugin (like not being able to pass options on a per-call > basis), but it's a pretty minor change. Food for thought. > > Mike > > >