Skip to content
Nerothos edited this page Nov 13, 2015 · 1 revision
    <p>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 <a href="http://github.com/mjijackson/shadowbox">source</a>.</p>

    <table border="0" cellpadding="0" cellspacing="1">
        <thead>
            <tr><th>Property</th><th>Description</th></tr>
        </thead>
        <tbody>
            <tr><td><code><a name="cache">cache</a></code></td><td>A cache of gallery elements that have already been set up for use. May be properly cleared using <a href="#clearcache">clearCache()</a>.</td></tr>
            <tr><td><code>current</code></td><td>An integer representing the index of the current content object in the current gallery.</td></tr>
            <tr><td><code>dimensions</code></td><td>An object containing the current dimensions of the box.</td></tr>
            <tr><td><code>gallery</code></td><td>An array containing all elements in the current gallery.</td></tr>
            <tr><td><code>options</code></td><td>An object containing the current <a href="Options">options</a> in use.</td></tr>
            <tr><td><code>path</code></td><td>A string that describes the URL path under which the shadowbox.js script is located. This is automatically determined in <a href="#init">init</a> if it is not already set.</td></tr>
            <tr><td><code>player</code></td><td>The current "player" object. A player is essentially a JavaScript object that wraps all the functionality needed to handle a certain type of content.</td></tr>
            <tr><td><code>plugins</code></td><td>An object that describes which plugins are installed on the client.</td></tr>
            <tr><td><code>version</code></td><td>A string containing the current version number.</td></tr>
        </tbody>
    </table>

    <table border="0" cellpadding="0" cellspacing="1">
        <thead>
            <tr><th>Method</th><th>Description</th></tr>
        </thead>
        <tbody>
            <tr><td><code><a name="addcache">addCache(link, options)</a></code></td><td>Adds the given link element to the Shadowbox element cache. Elements are cached to speed up lookups when they are needed.</td></tr>
            <tr><td><code><a name="buildobject">buildObject(link, options)</a></code></td><td>
                <p>Builds an object that is suitable to store in the cache. The resulting object should contain (most of) the following properties:</p>
                <table style="width:100%" border="0" cellpadding="0" cellspacing="1">
                    <thead>
                        <tr><th>Property</th><th>Description</th></tr>
                    </thead>
                    <tbody>
                        <tr><td><code>link</code></td><td>The original link element</td></tr>
                        <tr><td><code>content</code></td><td>The value of the link's <code>href</code> attribute</td></tr>
                        <tr><td><code>player</code></td><td>The abbreviated name of the player to use for the object</td></tr>
                        <tr><td><code>title</code></td><td>The title to use for the object</td></tr>
                        <tr><td><code>gallery</code></td><td>The name of the gallery the object belongs to (optional)</td></tr>
                        <tr><td><code>height</code></td><td>The height of the object (only necessary for movies)</td></tr>
                        <tr><td><code>width</code></td><td>The width of the object (only necessary for movies)</td></tr>
                        <tr><td><code>options</code></td><td>A set of <a href="Options">options</a> to use for this object</td></tr>
                    </tbody>
                </table>
            </td></tr>
            <tr><td><code>change(n)</code></td><td>Changes to index <code>n</code> in the current gallery.</td></tr>
            <tr><td><code><a name="clearcache">clearCache()</a></code></td><td>Clears all elements from the <a href="#cache">cache</a>, removing any event listeners that have been registered.</td></tr>
            <tr><td><code>getCurrent()</code></td><td>Gets the current object being displayed.</td></tr>
            <tr><td><code>hasNext()</code></td><td>Returns true if there is another item to display in the current gallery. Note that this will always be true in galleries that are <a href="Options#continuous">continuous</a>.</td></tr>
            <tr><td><code><a name="init">init(options, callback)</a></code></td><td>Initializes the Shadowbox environment. This function should only ever be called once, in the <code>&lt;head&gt;</code> of the document. If a callback function is passed here, it will be called as soon as Shadowbox (and the document) are ready.</td></tr>
            <tr><td><code>inCache(link)</code></td><td>Returns true if the given link element is contained in the cache.</td></tr>
            <tr><td><code>isOpen()</code></td><td>Returns true if Shadowbox is currently open.</td></tr>
            <tr><td><code>isPaused()</code></td><td>Returns true if Shadowbox is currently in a paused state. This can happen if <a href="#pause">pause</a> is invoked in the middle of a slideshow.</td></tr>
            <tr><td><code>next()</code></td><td>Changes to the next element in the current gallery.</td></tr>
            <tr><td><code>open(object)</code></td><td>Opens the given object. This object can be a link element that has already been <a href="#setup">setup</a>, an object similar to one created by <a href="#buildobject">buildObject</a>, or an array of objects.</td></tr>
            <tr><td><code><a name="pause">pause()</a></code></td><td>Pauses the current slideshow (if there is one).</td></tr>
            <tr><td><code>play()</code></td><td>Resumes the current slideshow (if there is one).</td></tr>
            <tr><td><code>previous()</code></td><td>Changes to the previous element in the current gallery.</td></tr>
            <tr><td><code><a name="removecache">removeCache(link)</a></code></td><td>Removes the given link element from the cache.</td></tr>
            <tr><td><code><a name="setup">setup(links, options)</a></code></td><td>Sets up the given link element(s) and <a href="#addcache">adds</a> it to the cache with the given options. If using the <a href="Options#usesizzle">using</a> the <a href="http://sizzlejs.com/">Sizzle.js</a> 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 <a href="http://wiki.github.com/jeresig/sizzle">Sizzle documentation</a>.</td></tr>
            <tr><td><code>teardown(links)</code></td><td>Removes event listeners from the given link element(s) and <a href="#removecache">removes</a> it from the cache. If using the <a href="Options#usesizzle">using</a> the <a href="http://sizzlejs.com/">Sizzle.js</a> 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 <a href="http://wiki.github.com/jeresig/sizzle">Sizzle documentation</a>.</td></tr>

        </tbody>
    </table>

</div>

Clone this wiki locally