gueschla.com/labs/smoothbox

labs · smoothbox · 2007–2008

Smoothbox

Smoothbox put Thickbox's modal window on MooTools. One script, one stylesheet, and any link with class="smoothbox" opened its target in a box over a dimmed page: a single image, a gallery, part of the page, an iframe or an AJAX fragment. After the homepage it was the most-linked page on the domain, and by January 2010 it had 325 comments.

The problem it solved

In 2007 a site chose one JavaScript library and stayed with it. Thickbox, written by Cody Lindley, was the modal box that could show all five kinds of content, but it ran on jQuery. If your site was built on MooTools, using Thickbox meant loading a second framework for a single feature. Smoothbox removed that choice.

The port kept Thickbox's markup and behaviour, so its documentation still applied. The original announcement, in French on 17 March 2007, says the code was trimmed, a few bugs were fixed and a fade was added when the box opens. It worked in every browser of the day except Konqueror, and it degraded cleanly: with JavaScript off, each link still went straight to its image or page.

How it was used

You loaded MooTools, smoothbox.js and smoothbox.css, then marked up ordinary links. These examples are from the original demo page:

<a href="images/single.jpg" title="add a caption to title attribute / or leave blank" class="smoothbox">
  <img src="images/single_t.jpg" alt="Single Image"/></a>

<a href="images/plant1.jpg" class="smoothbox" rel="gallery-plants">…</a>
<a href="images/plant2.jpg" class="smoothbox" rel="gallery-plants">…</a>

<a href="#TB_inline?height=300&width=300&inlineId=myOnPageContent" class="smoothbox">Show</a>

<a href="ajaxOverFlow.htm?keepThis=true&TB_iframe=true&height=250&width=400" class="smoothbox">Example 1</a>

A shared rel value turned images into a gallery with next and previous links. Everything else was configured through the link's own address: TB_inline pointed at a hidden element on the page, TB_iframe=true loaded the target in an iframe, and height and width sized the box. The demo files it opened, ajaxOverFlow.htm and ajaxLogin.htm, were tiny HTML pages; old links to them now land here.

Version history

  • 17 March 2007. First release, at labs.gueschla.com/smoothbox/.
  • 15 May 2007. The date on the Smoothbox page at gueschla.com/labs/smoothbox/, which took over from the subdomain.
  • 12 June 2007. Fixes a flicker each time a page loaded inside the iframe box, starting from a patch a reader posted in the comments.
  • 16 August 2007. The stylesheet becomes fully valid CSS. Opacity moves into the script, and an Internet Explorer hack switches from _attribute to * html.
  • 23 June 2008. A new smoothbox.js for MooTools 1.2, with the old file kept for 1.1 sites. A follow-up note on the page warned that the new version was "all messed up" in Internet Explorer and that the older one was safer for now.

What replaced it

The browser does this now. The <dialog> element, opened with showModal(), puts content in a layer above the page, dims everything behind it through the ::backdrop pseudo-element, makes the rest of the page inert, closes on the Escape key and returns focus where it came from. It has worked in Chrome, Edge, Firefox and Safari since March 2022. The fade Smoothbox added by hand is a few lines of CSS transition.

No library. About ten lines of script and some CSS.
dialog.html

This box is a plain <dialog>. The dimmed page behind it is ::backdrop, the fade is a CSS transition, and Escape closes it without any extra code.

In 2007 the same effect needed a framework, a plugin and a careful look at Internet Explorer 6.

Image galleries are the one part that still takes some script, since the browser has no built-in previous and next. Even there, a dialog and a handful of event listeners do what used to need a plugin.

Where the code is now

The original page offered three downloads: smoothbox.js, smoothbox.css and loading.gif. They are not hosted here. A 2026 search found no repository for Smoothbox from its author. A copy did travel inside a third-party WordPress plugin called ThickBox, whose listing on wordpress.org still mentions "SmoothBox v20080623" and has not been updated since 2014.

labs/smoothbox/index.html15 May 2007 · captured 15 January 2010

Based on Cody Lindley’s Thickbox, MIT License

Smoothbox is the Mootools conversion of Thickbox, a script running on JQuery.

For the description and the features, you can go to Thickbox’s website, as they are basically the same.

The main difference from a user point of view is that I’ve added some effects when the box shows up and on scroll.

Update 23/06/2008 : I have updated smoothbox.js, now it is compatible with mootools 1.2. If you need the old one, you can still download it there. Sorry, no class for the moment, I don’t have enough time.

Edit : Well it seems to be all messed up in IE, I’m going to see what’s going on, for now it’s safer to use the older one.

Update 16/08/2007 : Now Smoothbox uses only 100% W3C Valid CSS. Opacity is now set with Javascript and not in CSS. An IE CSS hack has been updated to use * html instead of _attribute.

Update 12/06/2007 : When you used the iframe and followed some links, the smoothbox was flickering on each page loading. This is fixed.

The top of the original Smoothbox page, written in English. The author line, the download links and the 325 reader comments are left out.