<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>mitcho.com &#187; iframe</title>
	<atom:link href="http://mitcho.com/blog/tag/iframe/feed/" rel="self" type="application/rss+xml" />
	<link>http://mitcho.com</link>
	<description></description>
	<lastBuildDate>Thu, 29 Jul 2010 19:14:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Creating an image-sized iframe overlay with Shadowbox</title>
		<link>http://mitcho.com/blog/how-to/creating-an-image-sized-iframe-overlay-with-shadowbox/</link>
		<comments>http://mitcho.com/blog/how-to/creating-an-image-sized-iframe-overlay-with-shadowbox/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 05:33:50 +0000</pubDate>
		<dc:creator>mitcho</dc:creator>
				<category><![CDATA[how to]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MIT]]></category>
		<category><![CDATA[shadowbox]]></category>

		<guid isPermaLink="false">http://mitcho.com/blog/?p=3293</guid>
		<description><![CDATA[I recently have been working with the Shadowbox JavaScript library for an upcoming revision to the MIT Edgerton Digital Collections website. Shadowbox is a nice lightbox library designed to work with various JavaScript libraries like jQuery, prototype, and mootools with a nice modular design. Shadowbox is organized around different &#8220;players&#8221;—one for each kind of media [...]


Related posts:<ol><li><a href='http://mitcho.com/blog/life/im-seriously-dreaming-of-a-white-christmas/' rel='bookmark' title='Permanent Link: I&#8217;m Seriously Dreaming of a White Christmas'>I&#8217;m Seriously Dreaming of a White Christmas</a></li>
<li><a href='http://mitcho.com/blog/life/the-gift-that-keeps-on-giving/' rel='bookmark' title='Permanent Link: The Gift That Keeps On Giving'>The Gift That Keeps On Giving</a></li>
<li><a href='http://mitcho.com/blog/life/atayal-cultural-festival/' rel='bookmark' title='Permanent Link: Atayal cultural festival'>Atayal cultural festival</a></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I recently have been working with the <a href="http://www.shadowbox-js.com/">Shadowbox</a> JavaScript library for an upcoming revision to the MIT <a href="http://edgerton-digital-collections.org">Edgerton Digital Collections</a> website. Shadowbox is a nice <a href="http://en.wikipedia.org/wiki/Lightbox (JavaScript)">lightbox</a> library designed to work with various JavaScript libraries like jQuery, prototype, and mootools with a nice modular design.</p>

<p>Shadowbox is organized around different &#8220;players&#8221;—one for each kind of media that will be displayed. The library by default comes with players for Flash, HTML fragments, <code>iframe</code>s, QuickTime, and Windows Media. Some of these players, like those for images and video, automatically recognize the media size and adjust the lightbox accordingly, while others such as the <code>iframe</code> player can use a set size or can fill the screen. For the Edgerton site, though, we had a need for displaying an <code>iframe</code> but in the dimensions of a set image, so that we could display the image with an overlay. Here are some notes on how to implement a custom player for Shadowbox.</p>

<p><span id="more-3293"></span>
The first step to getting Shadowbox to recognize a custom player is to modify the players loaded by <code>shadowbox.js</code>. I called my player &#8220;hybrid,&#8221; as it&#8217;s like a cross between the <code>iframe</code> and <code>img</code> players.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Shadowbox.<span style="color: #660066;">options</span>.<span style="color: #660066;">players</span><span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;html&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;iframe&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;img&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;hybrid&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>


<p>Now Shadowbox will try to look for the file <code>players/shadowbox-hybrid.js</code>. That&#8217;s where we will create our custom player. Start by duplicating the <code>iframe</code> player file. Next, we can make one more change to <code>shadowbox.js</code>. In the <code>getPlayer</code> function, add a line that will return &#8220;<code>hybrid</code>&#8221; when it recognizes a lightbox which should use the hybrid player. I added the following line, which uses the hybrid player when the text &#8220;<code>galleries</code>&#8221; is in the <code>a</code> tag&#8217;s <code>href</code> attribute.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/galleries/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;hybrid&quot;</span><span style="color: #339933;">;</span></pre></div></div>


<p>Finally, you must actually write the new player. There&#8217;s a readme file which describes the interface:</p>

<blockquote>
<p>All players should implement the same interface. This makes it possible for the Shadowbox class to know what methods to call and properties to check on player objects.</p>
<p>The interface is described here, with some simple explanations of how each method and/or property is to be used.</p>
<dl>
<dt><strong>height</strong></dt>
    <dd>(Number) The height of the object (in pixels)</dd>
<dt><strong>width</strong></dt>
    <dd>(Number) The width of the object (in pixels)</dd>
<dt><strong>ready</strong></dt>
    <dd>(optional, Boolean) True if the content is ready to be loaded, false otherwise. Useful when the script should wait until the content loads before proceeding (see below)</dd>
<dt><strong>resizable</strong></dt>
    <dd>(optional, Boolean) True if the content can be dynamically resized by the script (e.g. images, but not most movie formats)</dd>
<dt><strong>append()</strong></dt>
    <dd>Appends this object to the DOM</dd>
<dt><strong>remove()</strong></dt>
    <dd>Removes this object from the DOM</dd>
<dt><strong>onLoad()</strong></dt>
    <dd>(optional) Called after the content is loaded and the loading layer is hidden</dd>
<dt><strong>onWindowResize()</strong></dt>
    <dd>(optional) Called when the window is resized</dd>
</dl>
</blockquote>

<p>I found these directions quite easy to follow. For our purposes, there was also a note on how to set an object&#8217;s height and width based on an image.</p>

<p>Hopefully these notes are helpful for others who hope to take full advantage of this very powerful JavaScript library.</p>


<p>Related posts:<ol><li><a href='http://mitcho.com/blog/life/im-seriously-dreaming-of-a-white-christmas/' rel='bookmark' title='Permanent Link: I&#8217;m Seriously Dreaming of a White Christmas'>I&#8217;m Seriously Dreaming of a White Christmas</a></li>
<li><a href='http://mitcho.com/blog/life/the-gift-that-keeps-on-giving/' rel='bookmark' title='Permanent Link: The Gift That Keeps On Giving'>The Gift That Keeps On Giving</a></li>
<li><a href='http://mitcho.com/blog/life/atayal-cultural-festival/' rel='bookmark' title='Permanent Link: Atayal cultural festival'>Atayal cultural festival</a></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://mitcho.com/blog/how-to/creating-an-image-sized-iframe-overlay-with-shadowbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
