<?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>Homespun &#187; jquery</title>
	<atom:link href="http://www.janinedalton.com/blog/archives/category/web-dev/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.janinedalton.com/blog</link>
	<description>Random ramblings from a freelance web developer in Dublin, Ireland</description>
	<lastBuildDate>Fri, 23 Oct 2009 14:25:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=5177</generator>
		<item>
		<title>jQuery: adding Slimbox lightbox effect to Galleria</title>
		<link>http://www.janinedalton.com/blog/archives/2009/jquery-adding-slimbox-lightbox-effect-to-galleria/</link>
		<comments>http://www.janinedalton.com/blog/archives/2009/jquery-adding-slimbox-lightbox-effect-to-galleria/#comments</comments>
		<pubDate>Fri, 08 May 2009 10:58:59 +0000</pubDate>
		<dc:creator>janine</dc:creator>
				<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.janinedalton.com/blog/?p=237</guid>
		<description><![CDATA[Two excellent jQuery scripts which I rely on time and time again are the Galleria image gallery and Slimbox 2, a lightweight Lightbox clone which has recently switched to using the jQuery framework over MooTools (happy days!). Both scripts allow you to add impressive functionality to websites with very little effort. While the built in [...]]]></description>
			<content:encoded><![CDATA[<p>Two excellent <a href="http://www.jquery.com">jQuery</a> scripts which I rely on time and time again are the <a href="http://devkick.com/lab/galleria/">Galleria</a> image gallery and <a href="http://www.digitalia.be/software/slimbox2">Slimbox 2</a>, a lightweight <a href="http://www.huddletogether.com/projects/lightbox2/">Lightbox</a> clone which has recently switched to using the jQuery framework over <a href="http://mootools.net/">MooTools</a> (happy days!). </p>
<p>Both scripts allow you to add impressive functionality to websites with very little effort. While the built in behaviour of Galleria is often ideal, I had a requirement to integrate lightbox functionality into it recently. I would consider myself a jQuery newbie, so this may not be the most elegant approach, but it seems to do the job on my browsers at least.</p>
<p>Galleria allows you to show a list of thumbnails, along with a larger version of one thumbnail. Clicking a different thumbnail enlarges that image instead. I needed to extend this functionality to give 3 image sizes for some of the gallery images: Clicking a thumbnail would give you a &#8220;medium&#8221; version, and clicking the medium version would show a larger version again in a lightbox pop-up.</p>
<p>I achieved this as follows:</p>
<ol>
<li>Firstly, I made sure that I had included all the files needed by both Galleria and Slimbox in the head of my page. (The basic usage instructions on both script sites can fill you in on this.)</li>
<li>I gave any images in the gallery that needed a large lightbox version a longdesc attribute, setting it to the URL of the large version. (Not ideal semantically I know, but this attribute does expect a URL, and in this case the detailed information about the image is just a bigger, more detailed image, so I can live with that.)</li>
<li>Next, I made sure that the clickNext option in my Galleria call was set to false. The clickNext option makes each main gallery image click through to the next to provide an alternative gallery navigation to clicking each thumbnail. However, I need to have some of my main images linking to lightbox pop-ups instead, so I disable this behaviour:<br />
<code><br />
$('#mygallery').galleria({<br />
	history   : false,<br />
	clickNext : false<br />
});<br />
</code>
</li>
<li>Here&#8217;s the key step. I used the onImage option in my Galleria call, to specify a function to add the lightbox behaviour:<br />
<code><br />
$('#mygallery').galleria({<br />
	history   : false,<br />
	clickNext : false,<br />
       onImage: function(image,caption,thumb){<br />
		//#check if thumbnail indicates that a large version of this pic is available<br />
		var large = thumb.attr('longdesc');<br />
		if(large)<br />
		{<br />
			//#if so, link to it and show it in a lightbox<br />
			image.wrap('&lt;a href="' + large + '"&gt;&lt;/a&gt;');<br />
			image.parent('a').slimbox();<br />
		}<br />
	}<br />
});<br />
</code><br />
A sample onImage function is provided in the <a href="http://devkick.com/lab/galleria/demo_01.htm">Galleria advanced demo</a>, which gave me my function outline. The parameters give you access to the thumbnail image, the main image and the image caption, giving you great freedom to extend the functionality. Here, all I want to do is check whether the thumbnail of this main image has a longdesc specified. If so, that means it needs the lightbox effect. So, I wrap a link around the main image, linking to the large version. Finally, I make a call to the Slimbox API to add lightbox functionality to the link I just added. (Note that I first tried just putting rel=&#8221;lightbox&#8221; in the anchor tag, but this seemed to have no effect. The rel attribute may have some other purpose in the Galleria script which overrides this.)
</li>
</ol>
<p>A few short steps and you&#8217;re done. This is the kind of thing that I thought would be a nightmare. For so many years, JavaScript gave me the shudders, but jQuery makes light work of so much. I&#8217;m using it increasingly, but still only now and then, with renewed awe each time. Warning: jQuery has been known to cause giddiness and excessive drooling in web developers. <img src='http://www.janinedalton.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.janinedalton.com/blog/archives/2009/jquery-adding-slimbox-lightbox-effect-to-galleria/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>jQuery Galleria: overwriting div content with large image</title>
		<link>http://www.janinedalton.com/blog/archives/2009/jquery-galleria-overwriting-div-content-with-large-image/</link>
		<comments>http://www.janinedalton.com/blog/archives/2009/jquery-galleria-overwriting-div-content-with-large-image/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 18:00:28 +0000</pubDate>
		<dc:creator>janine</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://www.janinedalton.com/blog/?p=231</guid>
		<description><![CDATA[On implementing a photo gallery using the handy Galleria jQuery plugin recently, I ran into a a couple of issues. Firstly, the current version (1.0) does not work instantly with jQuery 1.3. You get error messages like &#8220;Syntax error, unrecognized expression: [@rel=&#8230;&#8221;. This is easily fixed. You just need to open the Galleria file and [...]]]></description>
			<content:encoded><![CDATA[<p>On implementing a photo gallery using the handy <a href="http://code.google.com/p/galleria/">Galleria</a> <a href="http://www.jquery.com">jQuery</a> plugin recently, I ran into a a couple of issues.</p>
<p>Firstly, the current version (1.0) does not work instantly with jQuery 1.3. You get error messages like &#8220;Syntax error, unrecognized expression: [@rel=&#8230;&#8221;. This is easily fixed. You just need to open the Galleria file and replace @rel with rel, since @rel has been deprecated (there are only a few occurrences).</p>
<p>Once I was up and running, I realised that I needed to do something a little bit different with this implementation. On clicking a thumbnail, I wanted to replace the content of an existing div on the page with the large version of that image. </p>
<p>Galleria automatically shows the large main image above your list of thumbnails. Alternatively, you can specify an element to place the large image in by specifying the _insert option:</p>
<p><code><br />
$('.galleria ul').galleria(<br />
	{<br />
		insert: '#banner'<br />
	}<br />
</code></p>
<p>The only problem was that the div I specified (#banner in the above example) already contained some content. I wanted to replace the content with the large image, but Galleria sensibly appends the large image after any existing HTML in the element.</p>
<p>Another quick change to the Galleria script file seemed to change the behaviour so that the large image container HTML is overwritten instead. In the minified version, just search for _wrapper.empty().append(_img); and add the following line beneath it:</p>
<p><code><br />
_wrapper.empty().append(_img);<br />
/*add line below to overwrite initial non Galleria markup*/<br />
_wrapper.prevAll().remove();<br />
/*end edit*/<br />
_wrapper.siblings('.caption').text(_thumb.attr('title'));<br />
</code> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.janinedalton.com/blog/archives/2009/jquery-galleria-overwriting-div-content-with-large-image/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
