<?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>WebMuch &#187; jQuery</title>
	<atom:link href="http://webmuch.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://webmuch.com</link>
	<description>Everything about the web</description>
	<lastBuildDate>Tue, 16 Feb 2010 10:05:17 +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>Image Flip Using jQuery</title>
		<link>http://webmuch.com/image-flip-using-jquery/</link>
		<comments>http://webmuch.com/image-flip-using-jquery/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 00:11:42 +0000</pubDate>
		<dc:creator>Aayush</dc:creator>
				<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://webmuch.com/?p=175</guid>
		<description><![CDATA[<img src="http://webmuch.com/wp-content/uploads/2009/06/intro.jpg" alt="Image Flip Using jQuery Introduction Image" title="Image Flip Using jQuery Introduction Image" width="150" height="150" class="alignnone size-full wp-image-189" />In this week's post we will be creating an illusion effect of an image flip using jQuery of course. This thing can be used as a cool gallery kind of a thing. So, hopefully you guys will like it, let's get to it.]]></description>
			<content:encoded><![CDATA[<p>Alright, first of all this is not a real image flip but sort of an illusion, the image does not flip itself in 3D since jQuery does not provide us with an image rotation or a distort feature for HTML elements. I know their are some image rotation plug-ins out their but they don&#8217;t work out very well with animate method of jQuery.</p>
<h3>Preview:</h3>
<p><img src="http://webmuch.com/wp-content/uploads/2009/06/preview.jpg" alt="Image Flip Using jQuery Preview Image" title="Image Flip Using jQuery Preview Image" width="585" height="400" class="alignnone size-full wp-image-188" /><br />
<strong>Note: Image flip with reflection is for demo purposes only, it&#8217;s done using the PHP GD Library and it&#8217;s source files are also included in the source code, so meddle with them if you like.</strong></p>
<p><strong><a href="http://webmuch.com/demos/image_flip_demo/flip.html" alt="First Demo">DEMO-1</a> | <a href="http://webmuch.com/demos/image_flip_demo/vertical_flip.html" alt="Second Demo">DEMO-2</a></strong></p>
<h3>HTML Code:</h3>
<pre class="code">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;head>
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
&lt;title>Image Flip Illusion Using jQuery&lt;/title>
&lt;link rel="stylesheet" type="text/css" href="default.css" />
&lt;/head>

&lt;body>
&lt;div id="container">
	&lt;h1>Image Flip Illusion Using jQuery&lt;/h1>
    &lt;img id="image1" src="images/image1.jpg" />
    &lt;img id="image2" src="images/image2.jpg" />
&lt;/div>
&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">&lt;/script>
&lt;script type="text/javascript" src="hflip.js">&lt;/script>
&lt;/body>
&lt;/html>
</pre>
<h3>CSS Code:</h3>
<pre class="code">
body{
	background-color:#000;
}
h1{
	color:#FFFFFF;
	font-family:Arial;
	font-size:24px;
	font-weight:bold;
}
#container{
	width:400px;
	margin:0px auto;
	height:380px;
	margin-top:50px}
#image1{
	position:absolute;
	cursor:pointer;
	width:300px;
	height:190px;
}
#image2{
	display:none;
	position:absolute;
	cursor:pointer;
}
</pre>
<p>As you can see in the above code, I&#8217;ve placed the two images in a division and given them absolute positioning to assign their positions in the division. </p>
<p>To achieve the Horizontal flip we are basically reducing the width of the first image to 0 pixels, increasing the left side margin from zero to half it&#8217;s width and as soon as we finish that, Increase the width of the second image from zero to it&#8217;s actual width and do the opposite for left side margin what we did for the first image i.e reduce it from half the width of the image to zero.</p>
<p>This process takes place when you click on the first image (#image1) and the same process also takes place when you click on second image (#image2) except for the obvious shuffle in their ids.</p>
<p>Just look at the jQuery code below and you will have a better idea of what&#8217;s happening:</p>
<h3>jQuery:</h3>
<pre class="code">
$(document).ready(function(){
var margin =$("#image1").width()/2;
var width=$("#image1").width();
var height=$("#image1").height();

$("#image2").stop().css({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'});
$("#reflection2").stop().css({width:'0px',height:''+height+'px',marginLeft:''+margin+'px'});

	$("#image1").click(function(){
		$(this).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:500});
		window.setTimeout(function() {
		$("#image2").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:500});
		},500);
	});

	$("#image2").click(function(){
		$(this).stop().animate({width:'0px',height:''+height+'px',marginLeft:''+margin+'px',opacity:'0.5'},{duration:500});
		window.setTimeout(function() {
		$("#image1").stop().animate({width:''+width+'px',height:''+height+'px',marginLeft:'0px',opacity:'1'},{duration:500});
		},500);
	});

});
</pre>
<p><strong>If you want to perform a Vertical flip the jQuery code for that too is included in the source code.</strong></p>
<p>Feel free to leave comments if you appreciate the tutorial or if you have any queries. You can also criticize the work but don&#8217;t be rude.</p>
<p>You can always find some good tutorials and articles on the <a href="http://webmuch.com/resources/" alt="Resources Page">Resources</a> page. You can always reach it using the menu up-top.</p>
<p>Thanks for Reading!</p>
<p><strong><a href="http://webmuch.com/source_files/image_flip_source.zip">Download the Source Code</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://webmuch.com/image-flip-using-jquery/feed/</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
		<item>
		<title>Animated Navigation Bar Using jQuery</title>
		<link>http://webmuch.com/animated-navigation-bar-using-jquery/</link>
		<comments>http://webmuch.com/animated-navigation-bar-using-jquery/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 00:07:58 +0000</pubDate>
		<dc:creator>Aayush</dc:creator>
				<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://webmuch.com/?p=150</guid>
		<description><![CDATA[<img src="http://webmuch.com/wp-content/uploads/2009/06/intro.png" alt="Animated Navigation Bar Using jQuery Introduction Image" title="Animated Navigation Bar Using jQuery Introduction Image" width="150" height="150" class="alignnone size-full wp-image-161" />For my first Article I will be writing on creating an Animated Navigation Bar Using jQuery. Hopefully you guys will like it.]]></description>
			<content:encoded><![CDATA[<p>This is my first guest tutorial at WebMuch so please bear with me if I miss out on anything.</p>
<h3>Preview:</h3>
<p><img class="alignnone size-full wp-image-155" title="Animated Navigation Bar Using jQuery Preview" src="http://webmuch.com/wp-content/uploads/2009/06/preview.png" alt="Animated Navigation Bar Using jQuery Preview" width="585" height="47" /></p>
<h3><a href="http://webmuch.com/demos/jQ_animated_navbar/navbar.html">DEMO!</a></h3>
<p>I am assuming that the readers are well versed with CSS and HTML.</p>
<h3>HTML Code:</h3>
<pre class="code">&lt;div class="container"&gt;
    &lt;div id="navbar1"&gt;
       	&lt;ul id="sprite"&gt;
       		&lt;li id="b0" class="a0"&gt;Home&lt;/li&gt;
                &lt;li id="b1"&gt;News&lt;/li&gt;
                &lt;li id="b2"&gt;Blog&lt;/li&gt;
                &lt;li id="b3"&gt;Pictures&lt;/li&gt;
                &lt;li id="b4"&gt;Videos&lt;/li&gt;
                &lt;li id="b5"&gt;Gallery&lt;/li&gt;
                &lt;li id="b6"&gt;About&lt;/li&gt;
                &lt;li id="b7" style="border-right:1px solid #1f1f1f;"&gt;Contact&lt;/li&gt;
        	&lt;/ul&gt;
        &lt;/div&gt;
&lt;/div&gt;</pre>
<p><strong>*NOTE:</strong> I do not encourage inline styling, I did it because It&#8217;s a sin I was willing to commit.</p>
<h3>CSS Code:</h3>
<pre class="code">html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, code,
del, dfn, em, img, q, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	font-weight: inherit;
	font-style: inherit;
	font-size: 100%;
	font-family: inherit;
	vertical-align: baseline;
}
body{
background-color:#1f1f1f;
}
.container{
	width:960px;
	margin:0px auto;
	color:#FFFFFF;
	font-family:Arial,sans-serif;
	font-size:20px;
	font-weight:bold;
}
#navbar1{
	float:left;
	width:960px;
	height:36px;
	font-size:14px;
	margin:20px 0 0 0;
	background:url(images/navbar_bg.png);
}
#navbar1 ul{
	float:left;
	width:585px;
	height:36px;
	margin-left:188px;
	color:#000000;
}
#navbar1 ul{
	background: url(images/anim_3.png) no-repeat;
	background-position:1px 4px;
}
#navbar1 ul li{
	float:left;
	width:72px;
	margin:3px 0 0 0;
	height:22px;
	display: inline;
	text-align:center;
	padding:7px 0 0 0;
	border-left:1px solid #1f1f1f;
	cursor:pointer;
}</pre>
<p><strong>*NOTE: </strong>This tutorial is only effective when using a predefined width for each button or list item as shown in the above image, this can also be implemented on navigation bars using dynamic widths, but you might have to change the jQuery and the image sprite quite a bit to achieve any kind of consistency in your design. Well to give you a basic explanation as to how we will animate the navigation bar from here on in, we will take a background image equal to the size of the list item, which, on mouse-over positions itself to the left of each respective list item. So, as you can see in my HTML code I have named(id) my unordered list as &#8216;sprite&#8217; with a backround image. I have also named(id) my list items b0,b1,b2,b3&#8230;.b7, depending on the number of list items you wish to have in your navigation bar. I&#8217;ll explain why we are doing this in a bit, after you read through the jQuery code.</p>
<h3>jQuery Code:</h3>
<pre class="code">$(document).ready(function(){
	var selected=0; // Default background position
	var position=0;

	$("#sprite").css({backgroundPosition:''+selected+'px 4px'});

	$("#b0,#b1,#b2,#b3,#b4,#b5,#b6,#b7").css({backgroundPosition:'0px 0px'}).mouseover(function(){
	position=$(this).attr("id").slice(1,2)*($(this).outerWidth());
	/*width of your list item*/
	$("#sprite").stop().animate({backgroundPosition:''+position+'px 4px'},{duration:200});
	});

	$("#b0,#b1,#b2,#b3,#b4,#b5,#b6,#b7").css({backgroundPosition:'0px 0px'}).mouseout(function(){
	$("#sprite").stop().animate({backgroundPosition:''+selected+'px 4px'},{duration:200});
	});
});</pre>
<h3>Step By Step Read Through:</h3>
<ul>
<li>In the first line, we define the default background position of the background image of #sprite (even though, we&#8217;ve already mentioned the default background position in the CSS file, we still have to declare the default background position in jQuery, because for some reason, Internet Explorer shows an error after repeated mouse-over states).</li>
<li>Now, on mouse-over of any of the list items, we simply calculate the background position of the image in the background of #sprite and using the animate method of jQuery we move it to its destined location. For example: On mouse-over of b0, in my case I moved it 0 * 73(width of my button) i.e. 0 pixels from the left of #sprite. On mouse-over of b1, I moved it 1 * 73 i.e. 73 pixels from the left of #sprite. On mouse-over of b2, I moved it 2 * 73 i.e. 146 pixels from the left of #sprite, so on and so forth. That is the very reason I named (id) my list items b0, b1, b2…, so that I can slice out the numerical values from it using slice(1,2).</li>
<li>Using the sliced numerical values we calculate the position of the background image, finally animate it and avoid a list of if else statements for each list item.</li>
<li>On mouse-out of any of the list items the background image comes back to its original position i.e. 0px (var selected;) from the left and 4px from the top.</li>
<li>Now, if you got any of the stuff I&#8217;ve explained there is one question popping in your head that do I have to manually give value to the variable &#8220;selected&#8221; for every page , well to avoid this you just have to edit the jQuery from the top to the one below.</li>
</ul>
<pre class="code">&lt;script type="text/javascript"&gt;
$(document).ready(function(){
	var check;
	var i;
	for(i=0;i&lt;20;i++){
		if($(".a"+i+"").attr("id")){
		check=$(".a"+i+"").attr("id").slice(1,2);
		}
	}

	var selected=check*($("#b0").outerWidth());
	var position;

	$("#sprite").css({backgroundPosition:''+selected+'px 4px'});

	$("#b0,#b1,#b2,#b3,#b4,#b5,#b6,#b7").css({backgroundPosition:'0px 0px'}).mouseover(function(){
	position=$(this).attr("id").slice(1,2)*($("#b0").outerWidth());/*width of your list item*/
	$("#sprite").stop().animate({backgroundPosition:''+position+'px 4px'},{duration:300});
	});

	$("#b0,#b1,#b2,#b3,#b4,#b5,#b6,#b7").css({backgroundPosition:'0px 0px'}).mouseout(function(){
	$("#sprite").stop().animate({backgroundPosition:''+selected+'px 4px'},{duration:300});
	});
});

&lt;/script&gt;</pre>
<p>Now we can easily name the class a0 or a1 or a2 or a4 of our list item (active list item) in our HTML to set the default background position of our background in #sprite and the script basically looks for the class with prefix &#8220;a&#8221; then slices out the next element i.e. 0 or 1 or 2 or 3, etc and multiplies it to the width of the element and gives it a default position from the left.</p>
<p>Feel free to leave comments if you appreciate the tutorial or if you have any problems implementing it.</p>
<p>Thanks for reading.</p>
<p><strong><a href="http://webmuch.com/source_files/Anim_navbar_webmuch.zip">Download the Source Code</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://webmuch.com/animated-navigation-bar-using-jquery/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>How &amp; why you should use Google CDN</title>
		<link>http://webmuch.com/how-why-you-should-use-google-cdn/</link>
		<comments>http://webmuch.com/how-why-you-should-use-google-cdn/#comments</comments>
		<pubDate>Sat, 30 May 2009 14:47:37 +0000</pubDate>
		<dc:creator>Aayush</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://webmuch.com/?p=133</guid>
		<description><![CDATA[<img src="http://webmuch.com/wp-content/uploads/2009/05/intro2.jpg" alt="jQuery Google CDN Image" title="jQuery Google CDN Image" width="150" height="150" class="alignnone size-full wp-image-136" />In this article I will share the importance of using a Google CDN link of our favorite JavaScript library and how to implement it with two different methods.]]></description>
			<content:encoded><![CDATA[<h3>What is Google’s CDN?</h3>
<p>Google CDN stands for Google Content Distribution Network. It provides a loading architecture for the most popular, open source JavaScript libraries.</p>
<p><img class="alignnone size-full wp-image-134" title="Available JavaScript Libraries Image" src="http://webmuch.com/wp-content/uploads/2009/05/preview2.jpg" alt="Available JavaScript Libraries Image" width="585" height="548" /></p>
<h3>Why should I use Google’s CDN links?</h3>
<p>Most of the websites I see, still host their JavaScript Library on their own server (Most, not all). Actually never have I ever seen any Web Development Blog hosting the library on their own server. They always use Google CDN, which is great because it has a number of advantages:</p>
<ol>
<li>Google’s Content Distribution Network has libraries on their various servers across the world and if you use their CDN link, when a user’s browser resolves the URL, their browser will automatically download the file from the closest available server, which will be a much faster download than if you force a user to download the file from your host server in whichever country your website is hosted.</li>
<li>Google’s Content Distribution Network will save you a great deal of bandwidth if you have large traffic on your website and a limited bandwidth with your host.</li>
<li>There is a good chance that the Google hosted version of that library is already cached on the user’s browser cache, as lot of big websites and portals use Google’s CDN links including Google itself and Google’s servers instruct browsers to cache the file for one year if there are quite a few requests for the same hosted file.</li>
</ol>
<h3>How to use Google CDN?</h3>
<p>Google’s CDN provides most of the popular, open source JavaScript Libraries with two ways of using each of them via the direct path in the &lt;script/&gt; tags and via The Google AJAX Libraries API.</p>
<p>To use the Google AJAX Libraries API we need to include the Google &#8220;jsapi&#8221; script:</p>
<pre class="code">&lt;script src="http://www.google.com/jsapi"&gt;&lt;/script&gt;</pre>
<p>The Google AJAX Libraries API provides a simple and powerful google.load() method which accepts two arguments, the first argument to google.load is the name of a library. The second argument is the version of the library:</p>
<pre class="code">&lt;script&gt;
google.load("jquery", "1.3.2");
google.load("jqueryui", "1.7.1");
    google.setOnLoadCallback(function(){
        // use this instead of:
        /*
            $(document).ready(function(){  });
        */
    });
&lt;/script&gt;</pre>
<p>But to use this API, there is a different approach for the ready functions of all the libraries. For example, in the above code, we use google.setOnLoadCallback(function(){  });  instead of jQuery’s ready function. In-fact we use google.setOnLoadCallback(function(){  });  instead of all different library’s ready functions. This can be seen as a drawback or a good feature; I see it as a good feature as it gives me a single ready function for all libraries.</p>
<p>The second method to use Google’s CDN links is by the direct paths of the libraries in the &lt;script/&gt; tags</p>
<p>Below is a list of all the JavaScript Libraries Google CDN provides with the direct paths and google.load implementation:</p>
<h3>jQuery</h3>
<pre class="code">
name: jquery
versions: 1.2.3, 1.2.6, 1.3.0, 1.3.1, 1.3.2
load request: google.load("jquery", "1.3.2");
extras: uncompressed:true, e.g., google.load("jquery", "1.3.2", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
path(u): http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
</pre>
<h3>jQuery UI</h3>
<pre class="code">
name: jqueryui
versions: 1.5.2, 1.5.3, 1.6, 1.7.0, 1.7.1
load request: google.load("jqueryui", "1.7.1");
extras: uncompressed:true, e.g., google.load("jqueryui", "1.7.1", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js
path(u): http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.js
note: This library depends on jquery. Before loading this module, you must load jquery. e.g.:
        google.load("jquery", "1.3.2");
        google.load("jqueryui", "1.7.1");
</pre>
<h3>Prototype</h3>
<pre class="code">
name: prototype
versions: 1.6.0.2, 1.6.0.3
load request: google.load("prototype", "1.6.0.3");
path: http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js
</pre>
<h3>script.aculo.us</h3>
<pre class="code">
name: scriptaculous
versions: 1.8.1, 1.8.2
load request: google.load("scriptaculous", "1.8.2");
path: http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js
note: This library depends on Prototype. Before loading this module, you must load Prototype. e.g.:
        google.load("prototype", "1.6");
        google.load("scriptaculous", "1.8.2");
</pre>
<h3>MooTools</h3>
<pre class="code">
name: mootools
versions: 1.11, 1.2.1, 1.2.2
load request: google.load("mootools", "1.2.2");
extras: uncompressed:true, e.g., google.load("mootools", "1.2.2", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools-yui-compressed.js
path(u): http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js
</pre>
<h3>Dojo</h3>
<pre class="code">
name: dojo
versions: 1.1.1, 1.2.0, 1.2.3, 1.3.0, 1.3.1
load request: google.load("dojo", "1.3.1");
extras: uncompressed:true, e.g., google.load("dojo", "1.3.1", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/dojo/1.3.1/dojo/dojo.xd.js
path(u): http://ajax.googleapis.com/ajax/libs/dojo/1.3.1/dojo/dojo.xd.js.uncompressed.js
</pre>
<h3>SWFObject</h3>
<pre class="code">
name: swfobject
versions: 2.1
load request: google.load("swfobject", "2.1");
extras: uncompressed:true, e.g., google.load("swfobject", "2.1", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js
path(u): http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject_src.js
</pre>
<h3>Yahoo! User Interface Library (YUI)</h3>
<pre class="code">
name: yui
versions: 2.6.0, 2.7.0
load request: load request: google.load("yui", "2.7.0");
extras: uncompressed:true, e.g., google.load("yui", "2.7.0", {uncompressed:true});
path: http://ajax.googleapis.com/ajax/libs/yui/2.7.0/build/yuiloader/yuiloader-min.js
path(u): http://ajax.googleapis.com/ajax/libs/yui/2.7.0/build/yuiloader/yuiloader.js
</pre>
<p>Source: <a href="http://code.google.com/apis/ajaxlibs/documentation/#AjaxLibraries">Google</a></p>
<p>Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://webmuch.com/how-why-you-should-use-google-cdn/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Simple jQuery Slideshow with PHP Image Stripe</title>
		<link>http://webmuch.com/simple-jquery-slideshow-with-php-image-stripe/</link>
		<comments>http://webmuch.com/simple-jquery-slideshow-with-php-image-stripe/#comments</comments>
		<pubDate>Wed, 27 May 2009 09:16:40 +0000</pubDate>
		<dc:creator>Aayush</dc:creator>
				<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://webmuch.com/?p=97</guid>
		<description><![CDATA[<img src="http://webmuch.com/wp-content/uploads/2009/05/intro.jpg" alt="Simple jQuery Slideshow with PHP Image Stripe Image" title="Simple jQuery Slideshow with PHP Image Stripe Image" width="150" height="150" class="alignnone size-full wp-image-102" />In this tutorial we will be making a simple jQuery Slideshow with the output image stripe from the last tutorial on <a href="http://webmuch.com/image-stripe-using-php-gd-library/">PHP GD Library Image Stripe</a>, Thereby making use of it in a real world application.]]></description>
			<content:encoded><![CDATA[<h3>Preview:</h3>
<p><img class="alignnone size-full wp-image-103" title="Simple jQuery Slideshow with PHP Image Stripe Preview Image" src="http://webmuch.com/wp-content/uploads/2009/05/preview1.jpg" alt="Simple jQuery Slideshow with PHP Image Stripe Preview Image" width="585" height="246" /><br />
<a href="http://webmuch.com/demos/jQslideshow/"></p>
<h3>DEMO!</h3>
<p></a><br />
I created the last post on creating an image stripe using PHP GD Library because a friend of mine needed to join some images for his web project and used that technique which I found very interesting, but apart from his use of it, I couldn’t find many real world situations where that technique could be used, but it’s not that I didn’t find any. Therefore this post is dedicated to use that technique in a real world application. So today I will create a slideshow using the output of my last post (Image Stripe using PHP GD Library).</p>
<p>Download the <a href="http://www.webmuch.com/source_files/php_gdImageStripe.zip">source code</a> of my previous post. In the source code, we only need to change the index.php file and the master.css file as we have nothing to do with the image creation using PHP but only the way we present it to the users.</p>
<h3>Index.php:</h3>
<pre class="code">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

&lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;head>
&lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
&lt;title>PHP &#038; jQuery Slideshow&lt;/title>
&lt;!-- stylesheets begin -->

&lt;link rel="stylesheet" type="text/css" href="css/reset.css" />
&lt;link rel="stylesheet" type="text/css" href="css/master.css" />

&lt;!-- stylesheets end -->
&lt;/head>

&lt;body>
&lt;div id="wrap">
	&lt;div id="slideshow">
		&lt;a href="#" class="next">
			Next
		&lt;/a>
	&lt;/div>
&lt;/div>&lt;!-- end container -->

&lt;!--
There is no link to the image file in the markup
as the link to the image is in the css file as a
background-image of the div#slideshow element.
-->

&lt;/body>
&lt;/html>
</pre>
<h3>Explanation:</h3>
<p>In the above code, the markup is fairly simple to understand. We link to the stylesheets and create a wrapper element (div#wrap) inside which we create a slideshow division which contains an anchor tag, simple enough. Please read the CSS code below for the master stylesheet.</p>
<h3>Master.css:</h3>
<pre class="code">
#wrap{
/* a simple enough wrapper */
	width:958px;
	border:1px solid #3b5998;
	border-top:none;
	margin:0 auto;
	background:#b7c4df;
	padding:20px 0;
	overflow:hidden;
}
#slideshow{
	width:600px;
	/* width is the size of at least two visible images in the merged image */
	height:225px;
	background:#ffffff url('../createImage.php') repeat-x;
	/* We link to the createImage.php file itself as the file itself returns the merged image */
	border:1px solid #000;
	margin:30px auto;
	overflow:hidden;
}
a.next{
	float:left;
	width:300px;
	/* To cover the first image out of the two visible */
	height:225px;
	line-height:225px; /*For vertical middle alignment*/
	text-align:center;
	text-decoration:none;
	background:#ffffff;
	font-family:Garamond, Hoefler Text, Palatino, Palatino Linotype, serif;
	font-size:30px;
	font-weight:bold;

	/* Cross Browser Transparency */
	filter:alpha(opacity=50);
	-moz-opacity:0.5;
	-khtml-opacity: 0.5;
	opacity: 0.5;
	/* Cross Browser Transparency */
}
#slideshow a{ color:#000; }
</pre>
<p>Now, Getting back into the making of the slideshow, let’s analyze a little. According to the last tutorial we joined six images with a width of 300 pixels each and a height of 225 pixels each, here according to the CSS above, we are showing the joined image as a repeating background image of an element having a width of 600 pixels hence, showing two of the six images in our stripe. Then we have an anchor tag over the first image of the six with 50% transparency, so it is translucently visible below the anchor.</p>
<p>Moving on, what we want to do here is that we want to animate the background-image to slide leftwards by 300 pixels each time a user clicks on the anchor (which has a class &#8220;next&#8221; assigned to it) and as the image is repeated on the x-axis there is no end to reach for.</p>
<h3>jQuery code for explanation:</h3>
<p>Place the following JavaScript code right after closing the body tag in the index.php file.</p>
<pre class="code">
&lt;script type="text/javascript" language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js">&lt;/script>
&lt;script type="text/javascript" language="JavaScript">
var count = 1;
$(function(){
	$('#slideshow').css({backgroundPosition: '0px 0px'});
	$('a.next').click(function(){
		var x_position = count*-300;
		//console.log(x_position);
		$('#slideshow').animate({backgroundPosition: ''+x_position+'px 0px'});
		count++;
	});
});
&lt;/script>
&lt;!-- scripts end -->
</pre>
<p>In the above code, we started a count from 1 as we will need to increase the value of background position with each click. But first we set the background position of the division with the id of “slideshow” to zeros. This is a good thing to do as we live in a world where Internet Explorer still survives. Then when the anchor (a.next) is clicked we initiate a function where we catch the count multiplied by 300 in a variable (x_position) and a minus sign for animating leftwards and then we animate the background-position with that value. Finally we increase the count by 1 for the next click, therefore, the first time we click the value of x_position is -300, the second time we click, it is -600 and so on.</p>
<p><strong>Note: make sure to comment out or remove the console.log statement as it creates problems in all the browsers except Firefox.</strong></p>
<p>Thanks for reading.</p>
<p><strong><a href="http://www.webmuch.com/source_files/jQslideshow.zip">Download the Source Code</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://webmuch.com/simple-jquery-slideshow-with-php-image-stripe/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Website Build-Up Series &#8211; Sidebar</title>
		<link>http://webmuch.com/website-build-up-series-sidebar/</link>
		<comments>http://webmuch.com/website-build-up-series-sidebar/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 21:33:14 +0000</pubDate>
		<dc:creator>Aayush</dc:creator>
				<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[JavaScript & AJAX]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://webmuch.com/?p=40</guid>
		<description><![CDATA[<img src="http://webmuch.com/wp-content/uploads/2009/04/post-intro-image1.png" alt="Website Build-Up Series - Sidebar Picture" title="Website Build-Up Series - Sidebar Picture" width="150" height="150" class="alignnone size-full wp-image-41" />This is second part of the website build-up series. In this part we'll continue where we left of, we'll make the sidebar with a jQuery accordion and a news box with curved corners and we'll make the main content container ready to work with for the next part.]]></description>
			<content:encoded><![CDATA[<h3>Preview:</h3>
<p><img src="http://webmuch.com/wp-content/uploads/2009/04/preview.png" alt="Website Build-Up Series - Sidebar Preview" title="Website Build-Up Series - Sidebar Preview" width="585" height="452" class="alignnone size-full wp-image-42" /><br />
So as per the preview picture above we will be creating the sidebar of the website and make the main content container ready to work with, for the next part of this tutorial series.</p>
<h3>Preparing:</h3>
<ul>
<li>First we will go to the <a href="http://www.jqueryui.com/">jQueryUI</a> website and click on <a href="http://www.jqueryui.com/download">build custom download</a>.</li>
<li>Now we deselect all the options and then reselect only the ones we need.</li>
</ul>
<p><img src="http://webmuch.com/wp-content/uploads/2009/04/jq_custom.png" alt="Website Build-Up Series - Sidebar Picture" title="Website Build-Up Series - Sidebar Picture" width="550" height="361" class="alignnone size-full wp-image-43" /></p>
<h3>What we need:</h3>
<ul>
<li>We need the UI Core.</li>
<li>We need only one widget: Accordion.</li>
<li>We need only Effects Core.</li>
<li>Make sure to make the download 1.5.3 (Legacy release, for <a href="http://www.jquery.com/">jQuery</a> 1.2.6).</li>
</ul>
<p>Now, open the zip file downloaded and go into the js folder and copy the file &#8220;jquery-ui-1.5.3.custom.min.js&#8221; into a new folder in your website directory, call the folder js. We will not be needing the <a href="http://www.jquery.com/">jQuery</a> JavaScript because we will be using google&#8217;s CDN to jQuery as it saves us bandwidth and it is cached on a lot of computers already, therefore, makes the site faster.</p>
<p>Now, for our curved corners go to: <a href="http://blue-anvil.com/archives/anti-aliased-rounded-corners-with-jquery">blue-anvil</a> and download the Anti-Aliased rounded corners with <a href="http://www.jquery.com/">jQuery</a> zip file. Open the zip file and copy &#8220;jquery.curvycorners.packed.js&#8221; into the js folder of our website directory.</p>
<p>We then include all the JavaScript files in our web page right before ending the body tag:</p>
<pre class="code">&lt;!-- From here --&gt;
&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;&lt;!-- This is google's free link to the jQuery library --&gt;
&lt;script src="./js/jquery-ui-1.5.3.custom.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="./js/jquery.curvycorners.packed.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    //jQuery code here...
&lt;/script&gt;
&lt;!-- Till here --&gt;
&lt;/body&gt;</pre>
<p>So from here we finally start coding. Open our index.html in a text editor and start right where we left off i.e. after closing the header division and we will finish our code right before the end of the main container tag which we made in the last tutorial.</p>
<pre class="code">&lt;/div&gt;&lt;!-- end header --&gt;
&lt;!-- Start here --&gt;
&lt;div id="content-container"&gt;

	&lt;div id="sidebar"&gt;

		&lt;h3&gt;Products:&lt;/h3&gt;
		&lt;div id="accordion-container"&gt;
			&lt;ul id="accordion"&gt;
				&lt;li&gt;
					&lt;a href="#recent" class="heading"&gt;Recent Entries&lt;/a&gt;
					&lt;ul id="recent"&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;
					&lt;a href="#popular" class="heading"&gt;Popular Entries&lt;/a&gt;
					&lt;ul id="popular"&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Recent Entry Title&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;
					&lt;a href="#categories" class="heading"&gt;Categories&lt;/a&gt;
					&lt;ul id="categories"&gt;
						&lt;li&gt;&lt;a href="#"&gt;Category Name&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Category Name&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Category Name&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Category Name&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;Category Name&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;
					&lt;a href="#archive" class="heading"&gt;Archive&lt;/a&gt;
					&lt;ul id="archive"&gt;
						&lt;li&gt;&lt;a href="#"&gt;January 2009&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;January 2009&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;January 2009&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;January 2009&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href="#"&gt;January 2009&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;&lt;!-- end accordion ul --&gt;
		&lt;/div&gt;&lt;!-- end accordion-container --&gt;
		&lt;h3&gt;Latest Updates:&lt;/h3&gt;
		&lt;div id="curved-box" class="corner-this"&gt;
			&lt;marquee onMouseOver=this.scrollAmount=0 onMouseOut=this.scrollAmount=2	scrollamount=2 direction="up"&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
				&lt;p&gt;This is a curved box where you can post latest news. Put up a slider or something.&lt;/p&gt;
			&lt;/marquee&gt;
		&lt;/div&gt;&lt;!-- end curved box --&gt;

	&lt;/div&gt;&lt;!-- end sidebar --&gt;
	&lt;div id="content"&gt;
		This is a content box where you can post latest news. Put up a slider or something.
		This is a content box where you can post latest news. Put up a slider or something.
		This is a content box where you can post latest news. Put up a slider or something.
		This is a content box where you can post latest news. Put up a slider or something.
		This is a content box where you can post latest news. Put up a slider or something.
		This is a content box where you can post latest news. Put up a slider or something.
	&lt;/div&gt;&lt;!-- end content --&gt;
&lt;/div&gt;&lt;!-- end content-container --&gt;
&lt;!-- End here --&gt;
&lt;/div&gt;&lt;!-- end container --&gt;</pre>
<p>In the above code: we opened a new container division in which we floated two divisions: a sidebar division to the left and a content division to the right. I gave the content division just a basic padding and then pasted in some gibberish text which we will remove the next time we start working on it. Then, In the sidebar container there are two main elements the accordion container inside which is an unordered list in which there is another unordered list inside each list item and then there a curved-box division inside which is a marquee tag which I don&#8217;t recommend using but I still have placed it there so the page looks a little more lively. I&#8217;d recommend a great slider you can use instead made with <a href="http://www.jquery.com/">jQuery</a> called <a href="http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding">Easy Slider</a>. Now back to what we are making, below is my CSS code which is quite self explanatory as it is well commented.</p>
<pre class="code">#content-container{
	width:100%;
	height:auto;
	overflow:hidden; /* for clearing the floats inside it */
	float:left;
}
#sidebar{
	width:300px;
	margin-right:5px;
	float:left;
}
#sidebar h3{ /* these are the two headings. Products and Latest Updates */
	font-family:Arial;
	font-size:15px;
	color:#000;
	padding:10px;
}
#content{
	float:left;
	width:634px; /* because of 1px border to this element, else it would be 635px  */
	height:800px; /* temporary */
	padding:10px;
	background:#c4c4c4;
	border-bottom: 1px solid #444; /* temporary */
	border-left: 1px solid #444;
}
/* Accordion */
#accordion-container {
	width: 290px;
	margin:0 0 10px 7px; /* top right bottom left */
}
ul#accordion, ul#accordion ul { background:#f8f7f7; }
ul#accordion { border-bottom: 1px solid #444; }
ul#accordion li {
	border: 1px solid #444;
	border-bottom: none; /* to avoid double borders at bottom */
}
ul#accordion ul li {
	border: none; /* to remove the excess borders from previous properties */
	border-bottom: 1px solid #C2C8D1; /* and then put what we like. */
	padding: 5px 10px;  /* [top | bottom] [left | right] */
}
ul#accordion ul li:last-child { border-bottom: none; } /* to remove the borders from the last list element */
ul#accordion a.heading { /* the big menu names in the accordion */
	background: #d9d4ce;
	color: #46382f;
	display: block;
	font-size: 18px;
	line-height: 18px;
	padding: 10px 5px;
	text-decoration: none;
}
ul#accordion a.heading:hover { /* mouseover the big menu names in the accordion */
	background: #46382f;
	color: #fff;
}
ul#accordion li ul a { /* the inside-menu elements */
	color: #000;
	text-decoration:none;
}
ul#accordion li ul a:hover { border-bottom: 1px dotted #46382f; } /* to give the inside-menu elements mouseover */
/* End Accordion */
#curved-box{
	background:#d9d4ce;
	width:288px;
	height:205px;
	padding:10px;
	border:1px solid #444;
	margin:10px 0 10px 7px;
}
#curved-box p{
	margin-bottom:10px;
	padding-bottom:10px;
	border-bottom: 1px dotted #444;
}</pre>
<p>Even though you have styled all the elements the accordion is not together and the curved box doesn&#8217;t have the curved corners yet. Not to worry we only have to write a few more lines of code to accomplish that. Right before the body tag we inserted our scripts, but if you look carefully we inserted three scripts and a fourth empty script tag with only a comment in it saying jQuery code here. Remove that comment and paste the code below in it&#8217;s place.</p>
<pre class="code">$(function(){
	$('#accordion').accordion();
	$('.corner-this').corner();
});</pre>
<p>Refresh your page and play around with the accordion and admire the anti-aliased curved corners.</p>
<p>Also, I have started my community link feed as you can see in the sidebar (Thanks to Collis Ta&#8217;eed&#8217;s Great <a href="http://nettuts.com/working-with-cmss/hack-together-a-user-contributed-link-feed-with-wordpress-comments/">Tutorial</a>) So please contribute to it. It takes less than a minute to submit a link there. So if you happen to have or know a link to a great tutorial or tip or a great article about web design &amp; development please submit it <a href="http://webmuch.com/community-link-feed/#commentform">here</a></p>
<p>Thank You</p>
<h3>Links:</h3>
<ul>
<li><a href="http://www.jqueryui.com/">jQuery UI</a></li>
<li><a href="http://blue-anvil.com/archives/anti-aliased-rounded-corners-with-jquery">Anti-Aliased Curved Corners &#8211; Blue Anvil</a></li>
<li><a href="http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding">Easy Slider</a></li>
</ul>
<p><strong><a href="http://www.webmuch.com/source_files/website_buildup_series.zip">Download the Source Code</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://webmuch.com/website-build-up-series-sidebar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
