<?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>Amped about Web Standards &#187; jQuery</title>
	<atom:link href="http://www.ampedwebstandards.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ampedwebstandards.com</link>
	<description>Discussion, code examples, and tutorials on web standards and web programming.</description>
	<lastBuildDate>Fri, 10 Dec 2010 20:04:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Tutorial: Dynamic slideshow with PHP &amp; JQuery</title>
		<link>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/</link>
		<comments>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 08:39:25 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/?p=95</guid>
		<description><![CDATA[When I set out to add database driven player info at NuggetsHoops.com, I knew that I wanted to include code that would display some of the many images that I had set aside for each NBA player. I also knew that I would continue to add new pictures. Application code that could easily display old [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2009%2F03%2F16%2Ftutorial-dynamic-image-slideshow-with-php-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2009%2F03%2F16%2Ftutorial-dynamic-image-slideshow-with-php-jquery%2F&amp;source=aswitzer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>When I set out to add database driven player info at <a title="NuggetsHoops" href="http://nuggetshoops.com">NuggetsHoops.com</a>, I knew that I wanted to include code that would display some of the many images that I had set aside for each NBA player. I also knew that I would continue to add new pictures. Application code that could easily display old and new images, without additional effort for each added image would work best.</p>
<p>I had already written PHP code that could look at a folder and create a list of images to be displayed. When I ran across the powerful<a title="jQuery Cycle Plugin" href="http://jquery.malsup.com/cycle/"> jQuery Cycle Plugin</a>, I had found a great way to display them.</p>
<p>Let&#8217;s get coding. This tutorial depends on PHP 5, jQuery 1.2.3 or later, jQuery Cycle Plugin version 2.51 or later.
<ul>
<li>I&#8217;ll assume you already have <a href="http://apache.org/">Apache</a> and <a href="http://www.php.net/downloads.php">PHP</a> setup and running. Make sure you have a recent version of PHP 5.</li>
<li><a title="jQuery Homepage" href="http://jquery.com/">Download jQuery</a></li>
<li><a title="Download jQuery Cycle Plugin" href="http://jquery.malsup.com/cycle/download.html">Download jQuery Cycle Plugin</a></li>
</ul>
<p>Add the following Javascript to your PHP/HTML to enable and call the Cycle Plugin:</p>
<p><code lang="javascript[lines]"><script src="/scripts/jquery-1.3.2.min.js" type="text/javascript"></script><br />
<script src="/scripts/jquery.cycle.all.min.js" type="text/javascript"></script><br />
<script type="text/javascript">
$(document).ready(function(){
	$('#myslides').cycle({
		fit: 1
	});
});
</script></code></p>
<p>Note that there are <a href="http://www.malsup.com/jquery/cycle/options.html">many options</a> and <a href="http://www.malsup.com/jquery/cycle/browser.html">styles of animation</a> provided by the powerful Cycle plugin.</p>
<p>Add the following PHP to iterate over any folder and dynamically generate img tags using any images found in the folder:<br />
<code lang="php[lines]">$directory = 'images/players/' . $row['imageName'];<br />
try {<br />
	// Styling for images<br />
	echo "
<div id=\"myslides\">";<br />
	foreach ( new DirectoryIterator("../" . $directory) as $item ) {<br />
		if ($item->isFile()) {<br />
			$path = "/" . $directory . "/" . $item;<br />
			echo "<img src=\"" . $path . "\" />";<br />
		}<br />
	}<br />
	echo "</div>
<p>";<br />
}<br />
catch(Exception $e) {<br />
	echo 'No images found for this player.<br />';<br />
}</code></p>
<p>Any img tags within an HTML element of class &#8216;myslides&#8217; (or whatever you initialized the Cycle plugin with in the Javascript) will have the slideshow behavior added to it. The $row array on line 1 is referencing a database query result, but could be set in a number of ways for your specific needs. The DirectoryIterator reference on line 5 is a builtin class in PHP5.</p>
<p>Here&#8217;s the CSS to style the images being displayed in the slideshow:</p>
<p><code lang="css[lines]">#myslides {<br />
width: 340px;<br />
float: right;<br />
        padding: 0;<br />
        margin:  0 auto;<br />
margin-top: 20px;<br />
} </p>
<p>#myslides img {<br />
    padding: 10px;<br />
    border:  1px solid rgb(100,100,100);<br />
    background-color: rgb(230,230,230);<br />
    width: 320px;<br />
    top:  0;<br />
    left: 0<br />
}</code></p>
<p>So, there&#8217;s a very quick walk thru a working example to generate a dynamic slideshow from any folder of images. If you&#8217;d like a full download of the code, or any further explanation, please leave a comment!</p>
<p>You can see this code in action by just clicking on any player&#8217;s name at the  <a href="http://www.nuggetshoops.com/roster.php">NuggetsHoops.com Roster page</a>.</p>
<h2>New &#8211; download the code for this Tutorial</h2>
<p><a class="downloadlink" href="http://www.ampedwebstandards.com/download/1" title="Version1.0 downloaded 4084 times" >Code for Dynamic Image Slideshow with PHP and JQuery (4084)</a></p>
<p><a href="http://www.ampedwebstandards.com/demos/dynamic-image-slideshow-php-jquery/">Demo</a><br />
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
		<item>
		<title>Merry Christmas and Happy Holidays!</title>
		<link>http://www.ampedwebstandards.com/2008/12/24/merry-christmas-and-happy-holidays/</link>
		<comments>http://www.ampedwebstandards.com/2008/12/24/merry-christmas-and-happy-holidays/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 12:50:59 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Microformats]]></category>
		<category><![CDATA[progressive enhancement]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/?p=58</guid>
		<description><![CDATA[One of the best presents a web developer can receive thru-out the year has arrived in December each of the last four years.  If you have been a web developer during that span, you most likely are already aware, but just in case, I will share with you: 2008 24 Ways Each year, a new [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F12%2F24%2Fmerry-christmas-and-happy-holidays%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F12%2F24%2Fmerry-christmas-and-happy-holidays%2F&amp;source=aswitzer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the best presents a web developer can receive thru-out the year has arrived in December each of the last four years. </p>
<p>If you have been a web developer during that span, you most likely are already aware, but just in case, I will share with you:</p>
<p><a title="24 Ways To Impress Your Friends" href="http://24ways.org" target="_blank">2008 24 Ways</a></p>
<p>Each year, a new web themed tip is posted each of the 24 days leading up to Christmas, in a fun holiday themed format. These tips are individual gems, all coming from internet industry super-stars and difference makers.</p>
<p>So do yourself a favor this holiday season and grab your laptop, another glass of eggnog, and head over to 24 Ways and bask in the generously shared ideas and knowledge.</p>
<p>Happy Holidays to All from AmpedWebStandards.com!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2008/12/24/merry-christmas-and-happy-holidays/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Progressive Enhancement with jQuery</title>
		<link>http://www.ampedwebstandards.com/2008/08/29/progressive-enhancement-with-jquery/</link>
		<comments>http://www.ampedwebstandards.com/2008/08/29/progressive-enhancement-with-jquery/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 08:28:18 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[progressive enhancement]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/?p=30</guid>
		<description><![CDATA[While I work on finishing up an overdue post on the amazing An Event Apart San Francisco conference I attended last week, I thought I would at least write about one of the many new concepts that was discussed. Progressive Enhancement (PE) is the concept of adding functionality or enhancements to the presentation and behavior [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F08%2F29%2Fprogressive-enhancement-with-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F08%2F29%2Fprogressive-enhancement-with-jquery%2F&amp;source=aswitzer&amp;style=normal&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><span id="extlinks">While I work on finishing up an overdue post on the amazing An Event Apart San Francisco conference I attended last week, I thought I would at least write about one of the many new concepts that was discussed.</span><br />
<code><script src="/scripts/jquery.js" type="text/javascript"></script></code></p>
<p>Progressive Enhancement (PE) is the concept of adding functionality or enhancements to the presentation and behavior of a webpage, using modern technologies such as CSS and Javascript. The PE approach adds the additional features thru externally linked files in order to avoid forcing older/less capable browsers to process data they don&#8217;t understand or can&#8217;t handle. In other words, the strategy demands that the basic content always be available, then add the fancier layout and features for browsers that can show it.</p>
<p>I&#8217;m going to show a quick but usable example of PE using jQuery. In this example, I am going to show how you can dynamically add an &#8220;external link&#8221; icon &#8211; <img src="/images/external.png" border="0" alt="" /> to links inside a specific area of your webpage.</p>
<p>1. <a href="http://docs.jquery.com/Downloading_jQuery">download the current release of jQuery</a> (at this writing &#8211; 1.2.6) and add it to your webpage in the tag.</p>
<p>2. Next, we will utilize the jQuery approach of executing Javascript code when the Document is loaded and the DOM is ready to be manipulated.</p>
<p><code>$(document).ready(function() { <code>});</code></code></p>
<p>3. Now, if we want to add an image after each external link, we can use the jQuery filter function which will addall elements that match a specified expression.</p>
<p>In the <code>section above, we'll add:</code></p>
<p><code>$("a").filter(".selected")</code></p>
<p>4. The expression will be another function that tests the hostname property of the link to see if it is different that the current page&#8217;s hostname.</p>
<p>Try this:</p>
<p><code>function() { return this.hostname &amp;&amp; this.hostname !== location.hostname; })</code></p>
<p>5. Lastly, we&#8217;ll use jQuery to insert the image after the link that matches the test expression &#8211; namely an external link!</p>
<p><code>.after(' &lt;img src="/images/ext.png" alt="External Link"&gt;');</code></p>
<p>6. Let&#8217;s put it all together!</p>
<p>Here&#8217;s the sum of the Javascript that we&#8217;ve written:</p>
<p><code>$(document).ready(function() {<br />
$('#extlinks a').filter(function() {<br />
return this.hostname &amp;&amp; this.hostname !== location.hostname;<br />
}).after(' &lt;img src="/images/ext.png" alt="External Link"&gt;');<br />
});</code></p>
<p>put that code in a Javascript file and include it after your jQuery code in your page&#8217;s :</p>
<p><code><script src="/scripts/ext-links.js" type="text/javascript"></script></code></p>
<p>That&#8217;s it! Now go give it a try for yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2008/08/29/progressive-enhancement-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

