API

The tables below contain a partial list of the properties and methods of the Shadowbox interface. This reference is not intended to be complete, but is merely offered as a high-level overview of the interface. For a more complete reference including method return and argument types, feel free to browse the source.

Property Description
cache A cache of gallery elements that have already been set up for use. May be properly cleared using clearCache().
current An integer representing the index of the current content object in the current gallery.
dimensions An object containing the current dimensions of the box.
gallery An array containing all elements in the current gallery.
options An object containing the current options in use.
path A string that describes the URL path under which the shadowbox.js script is located. This is automatically determined in init if it is not already set.
player The current “player” object. A player is essentially a JavaScript object that wraps all the functionality needed to handle a certain type of content.
plugins An object that describes which plugins are installed on the client.
version A string containing the current version number.
Method Description
addCache(link, options) Adds the given link element to the Shadowbox element cache. Elements are cached to speed up lookups when they are needed.
buildObject(link, options) Builds an object that is suitable to store in the cache. The resulting object should contain (most of) the following properties:

Property Description
link The original link element
content The value of the link’s href attribute
player The abbreviated name of the player to use for the object
title The title to use for the object
gallery The name of the gallery the object belongs to (optional)
height The height of the object (only necessary for movies)
width The width of the object (only necessary for movies)
options A set of options to use for this object
change(n) Changes to index n in the current gallery.
clearCache() Clears all elements from the cache, removing any event listeners that have been registered.
getCurrent() Gets the current object being displayed.
hasNext() Returns true if there is another item to display in the current gallery. Note that this will always be true in galleries that are continuous.
init(options, callback) Initializes the Shadowbox environment. This function should only ever be called once, in the <head> of the document. If a callback function is passed here, it will be called as soon as Shadowbox (and the document) are ready.
inCache(link) Returns true if the given link element is contained in the cache.
isOpen() Returns true if Shadowbox is currently open.
isPaused() Returns true if Shadowbox is currently in a paused state. This can happen if pause is invoked in the middle of a slideshow.
next() Changes to the next element in the current gallery.
open(object) Opens the given object. This object can be a link element that has already been setup, an object similar to one created by buildObject, or an array of objects.
pause() Pauses the current slideshow (if there is one).
play() Resumes the current slideshow (if there is one).
previous() Changes to the previous element in the current gallery.
removeCache(link) Removes the given link element from the cache.
setup(links, options) Sets up the given link element(s) and adds it to the cache with the given options. If using the using the Sizzle.js CSS selector library, this may be a CSS selector or an array in which the first element is a CSS selector and the second is the context element as described in the Sizzle documentation.
teardown(links) Removes event listeners from the given link element(s) and removes it from the cache. If using the using the Sizzle.js CSS selector library, this may be a CSS selector or an array in which the first element is a CSS selector and the second is the context element as described in the Sizzle documentation.