API for Shadowbox.js

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 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 indicated 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 plugin 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 attribute value of the link’s href
player The object with a player’s name
title The object’s gallery name
gallery (optional) the gallery name with object
height the object’s height (necessary for films)
width the object’s width ( necessary for films)
options the object with a number properties
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. For example, it could be the object with a link that has already been setup, the one similar to one created by buildObject, or a range 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.