<?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>Harry Bailey &#187; jQuery</title>
	<atom:link href="http://harrybailey.com/category/javascript/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://harrybailey.com</link>
	<description>just a little bit geeky</description>
	<lastBuildDate>Tue, 24 Aug 2010 12:15:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fancybox left and right key problem</title>
		<link>http://harrybailey.com/2010/06/fancybox-left-and-right-key-problem/</link>
		<comments>http://harrybailey.com/2010/06/fancybox-left-and-right-key-problem/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 11:40:04 +0000</pubDate>
		<dc:creator>Harry</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://harrybailey.com/?p=452</guid>
		<description><![CDATA[When you use fancybox, it automatically adds listeners which stop any other use of the Esc, Left and Right keys on your keyboard. The just don&#8217;t work in forms etc inside Fancybox.
This isn&#8217;t such an issue with the escape key, but not being able to use the left and right, for example in text inputs, [...]]]></description>
			<content:encoded><![CDATA[<p>When you use fancybox, it automatically adds listeners which stop any other use of the Esc, Left and Right keys on your keyboard. The just don&#8217;t work in forms etc inside Fancybox.</p>
<p>This isn&#8217;t such an issue with the escape key, but not being able to use the left and right, for example in text inputs, is a pain.</p>
<p>The changes below add an additional option to Fancybox called <strong>useNextPrev</strong> which you can set to false to stop Fancybox adding listeners to these keys. I haven&#8217;t included the escape key as I think it&#8217;s far less of an issue. <span id="more-452"></span></p>
<p>The call to Fancybox after these changes would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.fancybox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>useNextPrev<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Changes needed to the fancybox javascript file:</p>
<p>replace:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">37</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	$.<span style="color: #660066;">fancybox</span>.<span style="color: #660066;">prev</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">39</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	$.<span style="color: #660066;">fancybox</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>with:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentOpts.<span style="color: #660066;">useNextPrev</span> <span style="color: #339933;">&amp;&amp;</span> e.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">37</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	$.<span style="color: #660066;">fancybox</span>.<span style="color: #660066;">prev</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>currentOpts.<span style="color: #660066;">useNextPrev</span> <span style="color: #339933;">&amp;&amp;</span> e.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">39</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
	$.<span style="color: #660066;">fancybox</span>.<span style="color: #660066;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>replace:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fancybox</span>.<span style="color: #660066;">defaults</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		padding				<span style="color: #339933;">:</span>	<span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>
		margin				<span style="color: #339933;">:</span>	<span style="color: #CC0000;">20</span><span style="color: #339933;">,</span></pre></div></div>

<p>with:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fancybox</span>.<span style="color: #660066;">defaults</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		padding				<span style="color: #339933;">:</span>	<span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>
		margin				<span style="color: #339933;">:</span>	<span style="color: #CC0000;">20</span><span style="color: #339933;">,</span>
		useNextPrev			<span style="color: #339933;">:</span>	<span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span></pre></div></div>

<p>And there you have it. By default Fancybox <strong>will</strong> use the left and right keys, but you now have the choice to stop it.</p>
]]></content:encoded>
			<wfw:commentRss>http://harrybailey.com/2010/06/fancybox-left-and-right-key-problem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pimping Fancybox jQuery Lightbox</title>
		<link>http://harrybailey.com/2010/05/pimping-fancybox/</link>
		<comments>http://harrybailey.com/2010/05/pimping-fancybox/#comments</comments>
		<pubDate>Thu, 13 May 2010 00:10:14 +0000</pubDate>
		<dc:creator>Harry</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://harrybailey.com/?p=440</guid>
		<description><![CDATA[I love fancybox. It&#8217;s a great and flexible jQuery lightbox, but I decided there were a couple of things I needed it to do that it doesn&#8217;t, so I dived into the code head first and added a couple of features. Be warned that you need to edit the file jquery.fancybox-1.3.1.js to implement them.
Combined add [...]]]></description>
			<content:encoded><![CDATA[<p>I love <a href="http://fancybox.net/">fancybox</a>. It&#8217;s a great and flexible jQuery lightbox, but I decided there were a couple of things I needed it to do that it doesn&#8217;t, so I dived into the code head first and added a couple of features. Be warned that you need to edit the file jquery.fancybox-1.3.1.js to implement them.</p>
<p><strong>Combined add and fire / show / open</strong><br />
Yes I know you can do this with $.fancybox(content, options)</p>
<p>It&#8217;s tough to add the fancybox listener and fire it at the same time, for example onclick or using a live event. That annoyed me in some circumstances. Previously I have resorted to adding fancybox to anchors on hover so it could fire onclick:<span id="more-440"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.fancybox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">mouseover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>But that&#8217;s not cool. So I added the option to the core.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// replace</span>
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fancybox</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// with</span>
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fancybox</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>options <span style="color: #339933;">===</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			options <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>now<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span>;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// replace</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>;
	<span style="color: #009900;">&#125;</span>;
&nbsp;
	$.<span style="color: #660066;">fancybox</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// with</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>options.<span style="color: #660066;">now</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>;
	<span style="color: #009900;">&#125;</span>;
&nbsp;
	$.<span style="color: #660066;">fancybox</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></div></div>

<p>You can fire it in two ways. If you are also including options then fire it on add by including now:true as an option like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
&nbsp;
    now<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    showCloseButton <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    enableEscapeButton <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>or if you are not setting options then fire it on add like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// note the (1)</span>
$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fancybox</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Either way, fancybox should now open / fire / show as soon as you attach it to an element.</p>
<p>And for my next trick&#8230;.</p>
<p><strong>Stop lightbox vertical movement</strong></p>
<p>The default behavour is for fancybox to centre itself on vertical or horizontal scroll or window resize. I needed (see the final tweak) the box to stay still vertically even if I scrolled, but stay centre horizontally.</p>
<p>To implement this I made this change:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// replace</span>
&nbsp;
		to.<span style="color: #660066;">top</span>	<span style="color: #339933;">=</span> view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>wrap.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> titleh<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>shadow <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span>;
		to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>wrap.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>shadow <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span>;
&nbsp;
		to.<span style="color: #660066;">top</span>	<span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> margin<span style="color: #339933;">,</span> to.<span style="color: #660066;">top</span><span style="color: #009900;">&#41;</span>;
		to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> margin<span style="color: #339933;">,</span> to.<span style="color: #660066;">left</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #006600; font-style: italic;">// with</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>currentOpts.<span style="color: #660066;">centerTopOnScroll</span><span style="color: #009900;">&#41;</span>
                <span style="color: #009900;">&#123;</span>
		    to.<span style="color: #660066;">top</span>	<span style="color: #339933;">=</span> view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>wrap.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> titleh<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>shadow <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span>;
		    to.<span style="color: #660066;">top</span>	<span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> margin<span style="color: #339933;">,</span> to.<span style="color: #660066;">top</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #009900;">&#125;</span>
&nbsp;
		to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>wrap.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>shadow <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span>;
		to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> margin<span style="color: #339933;">,</span> to.<span style="color: #660066;">left</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>and then add that new option to the defaults:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// replace</span>
&nbsp;
		centerOnScroll		<span style="color: #339933;">:</span>	<span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// with</span>
&nbsp;
		centerOnScroll		<span style="color: #339933;">:</span>	<span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		centerTopOnScroll	<span style="color: #339933;">:</span>	<span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span></pre></div></div>

<p>You can then include the new option centerTopOnScroll:false to keep the top position static even on horizontal scroll.</p>
<p>The final change I have made is:</p>
<p><strong>Clone the position and dimensions of an element</strong></p>
<p>This tweak allows you to specify an element to clone. The <strong>original</strong> lightbox created will then be in the position and have the dimensions of the specified element. I bolded original because you can then alter the dimensions and positions yourself using jquery or by updating the content.</p>
<p>To implement this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// replace</span>
&nbsp;
			final_pos <span style="color: #339933;">=</span> fancybox_get_zoom_to<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
			fancybox_process_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #006600; font-style: italic;">// with</span>
&nbsp;
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>currentOpts.<span style="color: #660066;">clonePosition</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// get final_pos from the element we are cloning</span>
				<span style="color: #003366; font-weight: bold;">var</span> pos <span style="color: #339933;">=</span> currentOpts.<span style="color: #660066;">elementToClone</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
				final_pos <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
								height<span style="color: #339933;">:</span>currentOpts.<span style="color: #660066;">elementToClone</span>.<span style="color: #660066;">outerHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
								width<span style="color: #339933;">:</span>currentOpts.<span style="color: #660066;">elementToClone</span>.<span style="color: #660066;">outerWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
								left<span style="color: #339933;">:</span>pos.<span style="color: #660066;">left</span><span style="color: #339933;">,</span>
								top<span style="color: #339933;">:</span>pos.<span style="color: #660066;">top</span>
							<span style="color: #009900;">&#125;</span>;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">else</span>
			<span style="color: #009900;">&#123;</span>
				final_pos <span style="color: #339933;">=</span> fancybox_get_zoom_to<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
&nbsp;
			fancybox_process_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>and</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// replace (after the previous change for vertical scroll)</span>
&nbsp;
to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>wrap.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>shadow <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span>;
to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> margin<span style="color: #339933;">,</span> to.<span style="color: #660066;">left</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #006600; font-style: italic;">// with</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>currentOpts.<span style="color: #660066;">clonePosition</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	to.<span style="color: #660066;">left</span> <span style="color: #339933;">=</span> currentOpts.<span style="color: #660066;">elementToClone</span>.<span style="color: #660066;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">left</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span>
<span style="color: #009900;">&#123;</span>
	to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>wrap.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>shadow <span style="color: #339933;">*</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">0.5</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
to.<span style="color: #660066;">left</span>	<span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> margin<span style="color: #339933;">,</span> to.<span style="color: #660066;">left</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>You then have the choice of including new options:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
clonePosition<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span>
elementToClone<span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#element'</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// a jquery element</span></pre></div></div>

<p>So there you have it.</p>
<p>Combined add and fire / show / open<br />
Stop lightbox vertical movement<br />
Clone the position and dimensions of an element</p>
]]></content:encoded>
			<wfw:commentRss>http://harrybailey.com/2010/05/pimping-fancybox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More powerful jQuery getScript with cache control</title>
		<link>http://harrybailey.com/2010/03/more-powerful-jquery-getscript-with-cache-control/</link>
		<comments>http://harrybailey.com/2010/03/more-powerful-jquery-getscript-with-cache-control/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 09:09:16 +0000</pubDate>
		<dc:creator>Harry</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://harrybailey.com/?p=425</guid>
		<description><![CDATA[If you love getScript as a shortcut method in jQuery but you hate not being able to control whether the script calls from the browsers cache or not then you can override the build in function with a new one which is backwards compatable, so it won&#8217;t break any of your old code, and allows [...]]]></description>
			<content:encoded><![CDATA[<p>If you love getScript as a shortcut method in jQuery but you hate not being able to control whether the script calls from the browsers cache or not then you can override the build in function with a new one which is backwards compatable, so it won&#8217;t break any of your old code, and allows you to choose true or false to caching.</p>
<p><a href="http://jamazon.co.uk/web/2008/07/21/jquerygetscript-does-not-cache/">Read the original post by Jamie Thompson</a></p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
$.<span style="color: #660066;">getScript</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> callback<span style="color: #339933;">,</span> cache<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			type<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;GET&quot;</span><span style="color: #339933;">,</span>
			url<span style="color: #339933;">:</span> url<span style="color: #339933;">,</span>
			success<span style="color: #339933;">:</span> callback<span style="color: #339933;">,</span>
			dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;script&quot;</span><span style="color: #339933;">,</span>
			cache<span style="color: #339933;">:</span> cache
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://harrybailey.com/2010/03/more-powerful-jquery-getscript-with-cache-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery Hover Listener Unbinding</title>
		<link>http://harrybailey.com/2008/11/jquery-hover-and-unbinding/</link>
		<comments>http://harrybailey.com/2008/11/jquery-hover-and-unbinding/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 18:52:36 +0000</pubDate>
		<dc:creator>Harry</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://harrybailey.com/?p=88</guid>
		<description><![CDATA[jQuery has a great helper function called hover which takes two functions as it&#8217;s values.

$&#40;'#hover_div'&#41;.hover&#40;function&#40;&#41;
&#123;
/* something to do on mouseenter */
&#125;,
function&#40;&#41;
&#123;
/* something to do on mouseleave */
&#125;&#41;;

Great when you want a simple way of doing something when your mouse enters or leaves the selected element(s).

But then I needed to unbind the listener from the elements [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jquery.com">jQuery</a> has a great helper function called hover which takes two functions as it&#8217;s values.</p>

<div class="wp_syntax"><div class="code"><pre class="php php" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="">'#hover_div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>hover<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">/* something to do on mouseenter */</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">/* something to do on mouseleave */</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>Great when you want a simple way of doing something when your mouse enters or leaves the selected element(s).</p>
<p><span id="more-88"></span></p>
<p>But then I needed to unbind the listener from the elements and I couldn&#8217;t for the life of me work out how.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/* WRONG */</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hover_div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hover'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009966; font-style: italic;">/* WRONG */</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hover_div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseover'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseout'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009966; font-style: italic;">/* update 2: WRONG - but hopefully in the next release */</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hover_div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseenter mouseleave'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009966; font-style: italic;">/* CORRECT */</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#hover_div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseenter'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseleave'</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p>So there you go. That&#8217;s how to unbind hover().</p>
]]></content:encoded>
			<wfw:commentRss>http://harrybailey.com/2008/11/jquery-hover-and-unbinding/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Disable Select Options in Internet Explorer</title>
		<link>http://harrybailey.com/2008/11/disabling-select-options-in-internet-explorer/</link>
		<comments>http://harrybailey.com/2008/11/disabling-select-options-in-internet-explorer/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 15:15:42 +0000</pubDate>
		<dc:creator>Harry</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://harrybailey.com/?p=38</guid>
		<description><![CDATA[Put your hands up if you hate developing for Internet explorer&#8230;.
That would be most of you then.
I can&#8217;t stand its special ways of doing things, so when I find an easy work around it makes me happy.
The latest one I have had to find and put into practice is a method for disabling some Select [...]]]></description>
			<content:encoded><![CDATA[<p>Put your hands up if you hate developing for Internet explorer&#8230;.</p>
<p>That would be most of you then.</p>
<p>I can&#8217;t stand its special ways of doing things, so when I find an easy work around it makes me happy.</p>
<p>The latest one I have had to find and put into practice is a method for disabling some Select dropdown options in a form. Internet explorer doesn&#8217;t support the disabled attribute on option elements. The following code will only work in standards complaint browsers (not in IE 6 or 7):</p>
<p><span id="more-38"></span></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;select id=&quot;select_1&quot; name=&quot;a_select&quot;&gt;
	&lt;option&gt;Please select...&lt;/option&gt;
	&lt;option disabled=&quot;disabled&quot;&gt;----------&lt;/option&gt;
	&lt;option&gt;One&lt;/option&gt;
	&lt;option disabled=&quot;disabled&quot;&gt;Two&lt;/option&gt;
	&lt;option&gt;Three&lt;/option&gt;
&lt;/select&gt;</pre></div></div>

<p>But there is a simple(ish) workaround we can use. Replace the disabled option elements with empty optgroup elements. This looks good in all browsers except for Safari which won&#8217;t show the option using the below code:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;select id=&quot;select_1&quot; name=&quot;a_select&quot;&gt;
	&lt;option&gt;Please select...&lt;/option&gt;
	&lt;optgroup label=&quot;----------&quot;&gt;&lt;/optgroup&gt;
	&lt;option&gt;One&lt;/option&gt;
	&lt;optgroup label=&quot;Two&quot;&gt;&lt;/optgroup&gt;
	&lt;option&gt;Three&lt;/option&gt;
&lt;/select&gt;</pre></div></div>

<p>By adding a little css styling magic and you end up with an identical outcome in all other modern browsers.</p>
<p>You can then enable and disable using javascript. Many people have written code which makes an option look like it&#8217;s disabled, waits for a click on the option element and then bluring it or focusing the next / previously selected option to make it act like it&#8217;s disabled.</p>
<p>I have come up with functions used with <a href="http://jquery.com">jQuery</a> to disable / enable a select option by <strong>converting it to an optgroup</strong> and back. It is tested in firefox 2 &amp; 3, safari 3, ie 6 + 7, and it works in Opera 9 (although the opgroups jump to the bottom)</p>
<h2>The code</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>
	<span style="color: #009900;">&#123;</span>
		optionDisable<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> ths <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>ths.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tagName'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'option'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				ths.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;optgroup&gt;&amp;nbsp;&lt;/optgroup&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>color<span style="color: #339933;">:</span><span style="color: #3366CC;">'#ccc'</span><span style="color: #339933;">,</span>height<span style="color: #339933;">:</span>ths.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span>ths.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>label<span style="color: #339933;">:</span>ths.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">return</span> ths;
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		optionEnable<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> ths <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #003366; font-weight: bold;">var</span> tag <span style="color: #339933;">=</span> ths.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tagName'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tag <span style="color: #339933;">==</span> <span style="color: #3366CC;">'option'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				ths.<span style="color: #660066;">removeAttr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'disabled'</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>tag <span style="color: #339933;">==</span> <span style="color: #3366CC;">'optgroup'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				ths.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;option /&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>value<span style="color: #339933;">:</span>ths.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span>ths.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'label'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">return</span> ths;
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<h2>Fixes and explainations</h2>
<p>Safari requires a &amp;nbsp; in the optgroup tag to make it visible, and because of this Firefox 2 then required the height:ths.height() to stop it showing a blank line below the optgroup.<br />
Two small fixes.</p>
<p>Additionally (as kindly pointed out by Luenyar below) this will not work if the options you are playing around with are already in an optgroup. That said, it will work but will create unwanted optgroups.</p>
<p>I almost forgot to mention that the functions are chainable!</p>
<h2>Example</h2>
<p>And to put it into practice you could use the following code snippets:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/* a specific option */</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#a_select'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':eq(2)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">optionDisable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009966; font-style: italic;">/* the selected option */</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#a_select option:selected'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">optionDisable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'I am a disabled option!'</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #009966; font-style: italic;">/* enable all options in a select */</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#a_select'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">optionEnable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p><strong>Update:</strong> Be sure to read all the excellent comments for further thoughts and improvements</p>
]]></content:encoded>
			<wfw:commentRss>http://harrybailey.com/2008/11/disabling-select-options-in-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>jCrop &#8211; jQuery&#8217;s Image Cropper</title>
		<link>http://harrybailey.com/2008/11/jcrop-the-jquery-image-cropper/</link>
		<comments>http://harrybailey.com/2008/11/jcrop-the-jquery-image-cropper/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 14:45:21 +0000</pubDate>
		<dc:creator>Harry</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://harrybailey.com/?p=6</guid>
		<description><![CDATA[I have been doing a lot of javascript coding recently. It&#8217;s funny because until six months ago I was a javascript beginner. I had done some js but didn&#8217;t completely get it and began by copying and pasting from other sites in the hope that things would just work. Then again that&#8217;s how I started [...]]]></description>
			<content:encoded><![CDATA[<p>I have been doing a lot of javascript coding recently. It&#8217;s funny because until six months ago I was a javascript beginner. I had done some js but didn&#8217;t completely get it and began by copying and pasting from other sites in the hope that things would just work. Then again that&#8217;s how I started with php too.</p>
<p>As I began to work on <a title="An affordable website you can update yourself" href="http://pageplay.com">PagePlay</a> more and more the javascript needed to be more and more clean and easy to adapt for when we add new functionality.</p>
<p><span id="more-6"></span></p>
<p>The last piece of easy to use goodness I have been working on is the photo editing functionality. When PagePlay first launched it would automatically resize your photos to the width of your template and you could edit the title and alternative text, but the photo would just be a resized version of what you uploaded and the thumbnail version would just be square versions of that photo.</p>
<p>The new photo editing toolbar allows you to select which part of the photo you want to use for each version needed on the site. You can choose your thumbnail, your content (standard) version and then when the new pageitems come in such as photobanner you will be able to crop again from the original for them.</p>
<p>The whole of PagePlays front end functionality is based on the <a title="jQuery - write less, do more" href="http://jquery.com">jQuery</a> javascript library and for the photo editing stuff I have gone with a very new and in development (currently on 0.9.5) but powerful plugin called <a title="jCrop the jQuery Image Cropping Plugin" href="http://deepliquid.com/content/Jcrop.html">jCrop</a>. It has most of the functionality I needed and is simple enough for the end user to understand. It&#8217;s more useful feature for me was it&#8217;s (almost complete) ability to deal with scaled images.</p>
<p>So if you are looking for an image cropper and you already know a little about the jQuery library I suggest you give <a title="jCrop the jQuery Image Cropping Plugin" href="http://deepliquid.com/content/Jcrop.html">jCrop</a> a look.</p>
]]></content:encoded>
			<wfw:commentRss>http://harrybailey.com/2008/11/jcrop-the-jquery-image-cropper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
