Ph: 18112008

Slimbox

Slimbox, the ultimate lightweight Lightbox clone

Version: 1.65
Category: Next Gen Javascript
Introduction Demo Features Requirements Usage Download Get Help Changelog

Introduction

Slimbox is a 4kb visual clone of the popular Lightbox JS v2.0 by Lokesh Dhakar, written using the ultra compact mootools framework. It was designed to be small, efficient, more convenient and 100% compatible with the original Lightbox v2.

Demo

Single images

Gilles at BarvauxGates gets a pie

Image set

These are pictures of the renovation of the Atomium here in Brussels.

Atomium in renovationAlpinists on the atomiumAlpinists on the topmost sphereAtomium sphere at nightNight view of the Atomium

Features

From a functional point of view, Slimbox has the following added features compared to the original Lightbox:

Slimbox is ready to launch as soon as the document is ready. This means that you don’t have to wait for all images of the page to be loaded before clicking on a link launching the Lightbox effect. The left and right arrow keys can be used to navigate through images, and the ESC key can be used to close Slimbox (Warning: in Mozilla browsers, the ESC key is also used to stop GIF images from animating). The dark background overlay can be clicked anywhere to close Slimbox, even on the parts located on the left and right of the image. The script is more robust; for example you can try to start-stop Slimbox very quickly to interrupt the animation then resume it and you won’t notice any bug like in the original Lightbox where sometimes the animation stops or the captions are wrongly sized. Slimbox temporary hides flash animations and other embedded videos while it is open to avoid display bugs in some browsers. With a special option, slimbox allows you to navigate between the first and last images. Slimbox can be launched from the traditional image links inside the page like the original Lightbox, but also directly from a Javascript call using a special method.

From a design point of view, Slimbox is very different from Lightbox:

The code has been entirely rewritten with efficiency in mind for the mootools framework instead of the huge Prototype/Scriptaculous. The script itself is as tiny as 4kb (uncompressed). Slimbox has a much more powerful API, allowing you to apply the Lightbox effect on many kinds of links easily. The Slimbox CSS are simpler and 100% valid (no more CSS hacks). Also, all images used by Slimbox are specified in the CSS instead of the Javascript so it is easier to style. Slimbox does not use the 1 pixel transparent gif image needed by Lightbox.

And of course, it has been tested in all modern browsers: Firefox, Internet Explorer 6+, Opera 8+, Safari 2+ and Camino. It is not compatible with the old Internet Explorer 5.5 and will never be.

The total download size for the required modules of mootools + Slimbox, both minified and gzipped, is currently as small as 16kb.

Requirements

Slimbox 1.6 requires the mootools framework, version 1.2 or more recent. Because mootools is modular, you can make your download smaller by only downloading the modules your scripts are actually using. Here are the core modules required by Slimbox:

Native: all Class: all Element: all Utilities: DomReady Fx: Fx.Tween, Fx.Morph (optionally Fx.Transitions)

The Slimbox download package already includes mootools with the above dependencies only. If you need more dependencies for your own scripts or want to use a different mootools version, you have to build your own version of mootools on the mootools download page.

Slimbox 1.5 is using mootools 1.11 and is also available for download. It provides the same features set as the latest version. Its dependencies are detailed in the provided readme file. You may need to use this version if your entire website is still using mootools 1.11 or if you need compatibility with the old Safari 1.3.

Usage

Usage is exactly the same as for Lightbox, with an extra feature in the “activate” part.

Because Slimbox was designed to be 100% compatible with Lightbox, you can just replace the scripts combination “Prototype + Scriptaculous + Lightbox” with “Mootools + Slimbox” in the header of your pages and your Lightbox effects will work just as well as before. Well, a little better.

Setup

1. Include the script in the header of your page, after the inclusion of the mootools framework:

<script type="text/javascript" src="js/mootools.js"></script>
<script type="text/javascript" src="js/slimbox.js"></script>

There are some options that you can specify inside the script. The default values should be just fine, however if you want you can change the following:

loop: Boolean; if true, allows to navigate between the first and last images of a Slimbox gallery, when there is more than one image to display. Default is false. overlayOpacity: The level of opacity of the background overlay. 1 Is opaque, 0 is completely transparent. You can change the color in the CSS file. Default is 0.8 resizeDuration: The duration of the resize animation for width and height, in milliseconds. Default is 400. resizeTransition: The transition you want to use for the resize animation. You can choose amongst lots of cool transitions that are part of the optional “Transitions” module of mootools, like “Fx.Transitions.Elastic.easeOut”. Many transitions require a longer execution time to look good, so you should adjust the resizeDuration option above as well. initialWidth: The initial width of the box, in pixels. Default is 250. initialHeight: The initial height of the box, in pixels. Default is 250. animateCaption: Boolean; set it to false to disable the caption animation. Default is true. showCounter: Boolean; if true, a counter will be shown at the bottom of the caption zone if there is more than 1 image to display. Default is true. counterText: Allows you to customize or translate the default text for the counter. Inside the text, “{x}” will be replaced by the current image index, and “{y}” will be replaced by the total number of images. Default is “Image {x} of {y}”.

Example of a custom options object:

{
        overlayOpacity: 0.6,
        resizeTransition: Fx.Transitions.Elastic.easeOut,
        counterText: "Image {x} sur {y}"
}

2. Include the CSS file in the header of your page, or add it to an existing CSS style sheet:

<link rel="stylesheet" href="css/slimbox.css" type="text/css" media="screen" />

If you keep the provided CSS as is, you must place the 4 required images in the same folder as the CSS file. Of course you can change the images or move them to another place, then you just need to edit the CSS URLs to reflect your changes. You don’t even need to edit the javascript.

You can also change the fonts for the caption and the image counter, the width of the border around the lightbox, and the background color. You must not change or add other CSS rules.

Activate

Add the rel="lightbox" attribute to the links pointing to your full-sized images. Use the optional title attribute if you want to show a caption:

<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

You can event use HTML in the caption if you want. You must replace the < and > characters with HTML entities and use single quotes instead of double quotes.

For sets of related images that you want to group and make navigable, add a group name to the rel attribute after the “lightbox” word, for example:

<a href="images/image-1.jpg" rel="lightbox-atomium">image #1</a>
<a href="images/image-2.jpg" rel="lightbox-atomium">image #2</a>
<a href="images/image-3.jpg" rel="lightbox-atomium">image #3</a>

I don’t recommend using square brackets “[ ]” for groups in the rel attribute like the original Lightbox scripts does because these characters are invalid for XHTML and XML attributes, meaning that your web page would not validate against the latest standards.

API for Javascript programming

Slimbox.open()

Alternatively, you can also launch Slimbox using Javascript to display a single image or a collection of images.

For a single image, just call the following method, passing the URL of the image as first parameter and optionally a title as second parameter:

Slimbox.open("images/image-1.jpg", "Spheres in construction");

Et voilà.

Download

Slimbox is free software released under MIT License.
If you like it, talk about it and promote it by linking to this page.

Slimbox 1.65 for mootools 1.2

Slimbox 1.53 for mootools 1.11 (NOT compatible with Opera 9.5+ or quirks mode web pages – you have to use strict mode – BUT compatible with the old Safari 1.3)

Get Help

First, please read the FAQ .

If the answer of your question is not there, you can ask it on the Slimbox Google Group.

Please note that I distribute Slimbox “as is”, I don’t get any money for it, and therefore I have no time to do support for it and I won’t answer trivial questions.

Changelog

v1.65 (2008-11-14)

Regression fix: the slimbox fix that hides <select> tags in Internet Explorer to prevent them to appear above the div elements was mistakenly removed in v1.61. It is now working again. Upgraded the provided mootools.js to version 1.2.1.

v1.64 (2008-07-15)

Fixed a bug where in some cases, Flash animations inserted using SWFObject would not show properly after Slimbox closes.

v1.63 (2008-06-10), requires mootools >= 1.2.

Updated code for mootools 1.2. Slimbox is now fully compatible with Opera 9.5+ and quirks mode web pages!

v1.52 (2008-06-08)

Added the “loop” option to allow navigation between the first and last images of a Slimbox gallery, when there is more than one image to display. Fixed a bug which allowed to change the image while Slimbox was closing. API: The Slimbox elements functions now return “this” to allow chaining. Small optimizations.

v1.51 (2008-05-30)

Fixed an error which occurred when Slimbox was used in combination with SWFObject in Firefox. Also fixes a memory leak in Internet Explorer.

v1.5 (2008-05-23)

Most of the code has been rewritten with a new approach. It’s now much smaller! (4kb) Added the “overlayOpacity” option to specify the level of opacity of the overlay. Added the “counterText” option to specify a custom or localized counter text. Slimbox does not take up any space at the bottom of the page any more in some browsers. Now Slimbox does not wait for the caption animation to complete before enabling navigation. So you can navigate faster between images. Keyboard events are now captured when Slimbox is open to prevent page scrolls when using the arrow keys to navigate. You can now have two times the same image in an images set. The CSS file now includes Z-index definitions that are required if your web page design relies on elements with Z-index. The provided GIF images are now smaller. API: Slimbox now extends the Element and Elements classes. You can now associate a Slimbox gallery to any group of link elements using $$(elements).slimbox([options]). API: You can now specify different options for each group of link elements where you applied the slimbox([options]) function. API: When you call slimbox() on elements, you can now specify an optional filter function and an optional mapper function for maximum flexibility (see documentation). The Lightbox compatibility code is now fully optional. It’s implemented in a few lines using the new API and a filter function. API: The main entry point has been renamed from “Lightbox” to “Slimbox” API: Lightbox.show() and Lightbox.open() have been merged into Slimbox.open() The Slimbox distribution now includes mootools, an example page and a Readme file.

v1.41 (2007-06-12)

Fixed a small CSS glitch for “next” and “prev” zones display. Removed the IE “white noise” fix, it is now fixed by mootools 1.1 (thanks digitarald).

v1.4 (2007-05-21), requires mootools >= 1.1.

Updated code for mootools 1.1. Added an option to hide the counter.

v1.31 (2007-05-04)

Fixed the “white noise” bug occurring in dark areas of JPEG images in Internet Explorer. Visibility of objects (including Flash animations) are now set to their original values when Slimbox is closed, instead of always being set to visible. Re-added the hiding of <embed> tags. It was accidentally removed in v1.3.

v1.3 (2007-02-05), requires mootools >= 1.0.

Updated code for mootools 1.0. The caption now animates using a nice slide effect like the original Lightbox. CSS update required. Added an option to set any custom transition from the mootools Transitions class for the resize animation.

v1.22 (2006-11-06)

Now also hides <embed> tags while Slimbox is opened, not just <object> tags. Thanks Felix from Germany.

v1.21 (2006-11-05)

Shorter code, slightly reduced file size.

v1.2 (2006-11-04)

Fixed serious performance issues with long HTML pages in Internet Explorer. Fixed overlay not entirely covering the screen when the window is resized/scrolled in specific cases. Now bulletproof to overlay mad-clicking. Hidden objects now reappear after the overlay fade out effect instead of before it.

v1.1 (2006-10-29), requires mootools >= revision 83.

Now Slimbox is ready to launch as soon as the DOM is ready. Added an option to disable caption animation. Optimized 2 lines of code.

v1.0 (2006-10-22), requires mootools >= revision 77.

Initial release.

Your opinion about this software?

There is currently no comment.


Categories

Ads by Google

Meta

Obtenez un vrai navigateur

This site is optimized for browsers supporting the latest W3C standards.



You are viewing a mobilized version of this site...
View original page here

How do you rate mobile version of this page?

Mobilized by Mowser Mowser