Slimbox added to CNET common libs
Slimbox is awesome and we wanted to use it, but there were a few things I wanted to change about it:
- It should be a class
- You should be able to interact with the options without editing the script itself
- I wanted to have the css assets added to the page automatically
So I made these changes and checked it in. Here’s a quick example of what you can do:
You can also create a set in real time:
//let's create a bunch of images here on the fly
for(var i = 1; i < 5; i++) {
$('slimboxHolder').adopt(
new Element('a').setStyle('cursor','pointer').setProperties({
href:'/wiki/slimbox/image-'+i+'.jpg',
rel: 'anotherLightBoxSet[set2]'
}).adopt(
new Element('img').setProperty('src','/wiki/slimbox/thumb-'+i+'.jpg').setStyle('margin', 2)
)
);
}
//and add a lightbox
new Lightbox({ relString: 'anotherLightBoxSet' }, $('slimboxHolder').getElements('a'));
..and that’s all there is to it…
Follow @clientcide on twitter to get notified of new posts.
To follow me personally on twitter, follow @anutron.
July 24th, 2007 at 9:20 pm
Too bad this doesn’t work in IE6 or IE7.
July 27th, 2007 at 11:57 am
Fixed!
October 1st, 2007 at 7:31 pm
Doesn’t work in Safari on Mac either, alas. FireFox Mac is all right though.