<?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>Fearless Flyer Web Design &#187; Tutorials</title>
	<atom:link href="http://fearlessflyer.com/tag/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://fearlessflyer.com</link>
	<description>Fearless flyer is a blog that focuses on the latest topics of web design. This includes Wordpress, SEO, Photoshop, jQuery, PHP and CSS. Fearless flyer is owned and operated by Michael Soriano, a seasoned web developer living in Southern California.</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:11:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Create Super Easy jQuery Tabbed Containers</title>
		<link>http://fearlessflyer.com/2012/01/how-to-create-super-easy-jquery-tabbed-containers/</link>
		<comments>http://fearlessflyer.com/2012/01/how-to-create-super-easy-jquery-tabbed-containers/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 18:29:12 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[walkthrough]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=2324</guid>
		<description><![CDATA[In this tutorial I&#8217;m going to show you how to create tabbed containers using jQuery. Tabbed containers is an excellent way of presenting your content. Data is organized where only the current tab&#8217;s section is shown. Once the user clicks on the other tabs, its associated content gracefully appears. View Demo Please note that you ]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I&#8217;m going to show you how to create tabbed containers using jQuery. Tabbed containers is an excellent way of presenting your content. Data is organized where only the current tab&#8217;s section is shown. Once the user clicks on the other tabs, its associated content gracefully appears. </p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/jquery_tabs/">View Demo</a></div>
<p>Please note that you will need to know some HTML / CSS and a little Javascript scripting to follow. Ready to get started? Let&#8217;s begin: </p>
<h3>Set up the HTML:</h3>
<p>First and foremost &#8211; we need the markup. We need this so we know what we are styling and manipulating. We are going to use semantic and valid HTML. In addition, we will keep it as clean as possible &#8211; with no unnecessary DIVs and classes in our code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul id=&quot;tabs&quot;&gt;
      &lt;li&gt;&lt;a href=&quot;#tab1&quot;&gt;Files and Folders&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab2&quot;&gt;User Profiles&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab3&quot;&gt;Contacts&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab4&quot;&gt;Applications&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#tab5&quot;&gt;Monthly Cost&lt;/a&gt;&lt;/li&gt; 
&lt;/ul&gt;
&lt;div class=&quot;container&quot; id=&quot;tab1&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab2&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab3&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab4&quot;&gt;
    ...content goes here
&lt;/div&gt;
&lt;div class=&quot;container&quot; id=&quot;tab5&quot;&gt;
    ...content goes here
&lt;/div&gt;</pre></td></tr></table></div>

<p>As you can see, our markup is pretty self-explanatory. The UL items will be our tabs, while the DIVs below it are the containers. Save your file and view it in the browser: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial1.jpg" alt="tutorial1 How to Create Super Easy jQuery Tabbed Containers" title="tutorial1" width="446" height="399" class="alignnone size-full wp-image-2325" /></p>
<h3>Add Some Sweet Styles:</h3>
<p>I usually like to style the HTML right after. This way &#8211; I can write the script exactly how to behave. Moreover, we can decide if what classes to add via Javascript. </p>
<h6>The Tabs</h6>
<p>Let&#8217;s convert our unordered list into tabs:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#tabs</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">28px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#eff5f9</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">45px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span><span style="color: #993333;">inset</span>  <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #993333;">inset</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	border-top-left-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>  
	border-top-right-radius<span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#tabs</span> li <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">border-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> 
	border-top-left-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>  
	border-top-right-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span>  <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
	box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-2px</span> <span style="color: #933;">2px</span> <span style="color: #cc00cc;">#dadada</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#tabs</span> li a <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</span><span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">7px</span> <span style="color: #933;">14px</span> <span style="color: #933;">6px</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span>  
	border-top-left-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span> 
	border-top-right-radius<span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#ebebeb</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">white</span> <span style="color: #933;">10%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10%</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#ebebeb</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #993333;">white</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span> <span style="color: #933;">-1px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Save your file and view it in the browser: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial2.jpg" alt="tutorial2 How to Create Super Easy jQuery Tabbed Containers" title="tutorial2" width="500" height="284" class="alignnone size-full wp-image-2327" /></p>
<p>Beautiful right? Things are coming along. We also want to add a style for the &#8220;inactive&#8221; state of the tabs. This will be how the tabs will look when they&#8217;re not in focus. Add the code below to your stylesheet:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#tabs</span> li a.inactive<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#666666</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -moz-linear-gradient<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#dedede</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">white</span> <span style="color: #933;">75%</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> -webkit-gradient<span style="color: #00AA00;">&#40;</span>linear<span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">75%</span><span style="color: #00AA00;">,</span> from<span style="color: #00AA00;">&#40;</span><span style="color: #cc00cc;">#dedede</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">,</span> to<span style="color: #00AA00;">&#40;</span><span style="color: #993333;">white</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#tabs</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#tabs</span> li a<span style="color: #6666ff;">.inactive</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#dedede</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Notice that I also added a separate style for <em>:hover</em>. To see how these styles look, you have to manually add class &#8220;inactive&#8221; to the anchor tags in our tabs, and refresh your browser: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial3.jpg" alt="tutorial3 How to Create Super Easy jQuery Tabbed Containers" title="tutorial3" width="439" height="236" class="alignnone work size-full wp-image-2328" /></p>
<h6>The Containers</h6>
<p>The containers styles really depend on you. I just added some general rules such as width and appropriate paddings:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.container</span><span style="color: #00AA00;">&#123;</span> 
	<span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span><span style="color: #993333;">both</span><span style="color: #00AA00;">;</span> 	 	 
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">664px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> 	 
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Now we have a solid look and we can continue with the scripting. Be sure to add some dummy content to your containers before we go on. </p>
<h3>The jQuery</h3>
<p>This part may have the shortest code, but will do a lot of work. Lets include the jQuery library into our page and start our document ready event. Append this code into your HTML:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<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: #006600; font-style: italic;">//our script goes here...</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>Now we need a way make our tabs inactive and hide the containers. Add the lines of code inside our document ready block:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a:not(:first)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.container:not(:first)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The code above adds the class &#8220;inactive&#8221; to all our our tabs &#8211; except the first one using the &#8220;:not(:first)&#8221; filter. The second line hides all of our container divs &#8211; except the first one, again using the said filter.<br />
Refresh your browser and you shall see the effects: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/12/tutorial4.jpg" alt="tutorial4 How to Create Super Easy jQuery Tabbed Containers" title="tutorial4" width="500" height="428" class="alignnone size-full wp-image-2330" /></p>
<p>Now let&#8217;s add a click handler to our tabs along with the events. Add the lines of code also inside document ready:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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: #003366; font-weight: bold;">var</span> t <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: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><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: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>A lot of things are happening here &#8211; first &#8211; we&#8217;ve established a click handler to our tabs. We also created a variable &#8220;t&#8221; that represents the value of the &#8220;href&#8221; attribute for whichever anchor tag that was clicked. For instance, if the first tab was clicked, then &#8220;t&#8221; will be &#8220;#tab1&#8243;. Then we add class &#8220;inactive&#8221; to all of the tabs, while removing &#8220;inactive&#8221; to whichever one was clicked. Then, we hide all of the containers while fading in the one that is &#8220;t&#8221;, i.e. #tab1 or #tab2 and so on. Return false just prevents the anchor links from their default behavior.</p>
<p>Refresh your browser and try it out. So our tabs are in full action. There is one problem though: when you click the current tab &#8211; it still attempts to hide all the containers and show the current one &#8211; we don&#8217;t want this to happen. Let&#8217;s add a conditional block to our code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">//this is the start of our condition </span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tabs li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><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: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inactive'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Wrapping our events inside this if block prevents this unwanted behavior. </p>
<h3>Conclusion</h3>
<p>And there you have it. Wasn&#8217;t that easy? Super Easy? The best thing about this code is it doesn&#8217;t use any images. All of the gradients and shadows are CSS3. Also, it is backwards compatible for users without Javascript. It won&#8217;t work as tabs &#8211; but it will show the full content, and the tabs will still lead them to the right area when clicked. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2012/01/how-to-create-super-easy-jquery-tabbed-containers/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to Add Lightbox to WordPress without a Plugin</title>
		<link>http://fearlessflyer.com/2011/04/how-to-add-lightbox-to-wp-without-plugin/</link>
		<comments>http://fearlessflyer.com/2011/04/how-to-add-lightbox-to-wp-without-plugin/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 05:26:45 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[creative]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[image effects]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[WP Themes]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=2121</guid>
		<description><![CDATA[Many times when I&#8217;m developing themes &#8211; I think of the simplest features to include. Always on top of my list &#8211; is a lightbox effect on images. A lightbox effect is when a thumbnail of an image is clicked, the larger version of the image is faded in &#8211; while the rest of the ]]></description>
			<content:encoded><![CDATA[<p>Many times when I&#8217;m developing themes &#8211; I think of the simplest features to include. Always on top of my list &#8211; is a lightbox effect on images. A lightbox effect is when a thumbnail of an image is clicked, the larger version of the image is faded in &#8211; while the rest of the page is dimmed in the background. This is very useful because it eliminates the need to leave the current page just to view the large version of the image. </p>
<p>Adding it to a WordPress theme has its benefits as well. For one, the code stays with the theme. Anyone who uses it gets this effect automatically. Not to mention, it&#8217;s pretty easy to implement.  </p>
<p>This article will walk you through how to add Lightbox into your WordPress themes. I&#8217;m also going to assume that you have created WordPress themes before, for you will need to know how to work with template files and such. Ready to get started? Let&#8217;s begin. </p>
<h3>Grab Pretty Photo</h3>
<p>There are many lighbox plugins out there. I choose one called Prettyphoto from <a href="http://www.no-margin-for-errors.com/">no-margin-for-errors.com</a>. Prettyphoto uses jQuery, and is quite extensible. But the main reasons why I chose it is because the animation is flawless and the design is awesome. Download the production version from this <a href="http://www.no-margin-for-errors.com/demos/prettyPhoto-jquery-lightbox-clone/prettyPhoto_compressed_3.1.2.zip">link</a></p>
<p>Extract the .zip file into your hard drive. Inside <strong>prettyPhoto_compressed_3.1.2</strong> &#8211; you will find the following folders and files. Copy them according to below:</p>
<ul>
<li><strong>prettyPhoto folder</strong> (from prettyPhoto_compressed_3.1.2\images) and place inside (yourtheme\images\)</li>
<li><strong>prettyPhoto.css</strong> (from prettyPhoto_compressed_3.1.2\css) and place inside your theme root folder</li>
<li><strong>jquery.prettyPhoto.js</strong> (from prettyPhoto_compressed_3.1.2\js) and place inside (yourtheme\scripts\)</li>
</ul>
<h3>Include the Scripts</h3>
<p>First we need jQuery. There is a preferred way to include jQuery into our themes &#8211; that is to use the <strong><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">wp_enqueue_script</a></strong> function. Open <strong>functions.php</strong> and add the code below. *If your theme doesn’t have a functions.php file – go ahead and create one.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> insert_jquery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'insert_jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Note that this is the preferred way because since WordPress is already shipped with a bunch of scripts (including jQuery) &#8211; you might as well use them. It is also considered good practice because updating Worpdress will include these javascript libraries (and how often do you do that!)</p>
<p>Add the Prettyphoto script and css into your theme header.php file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('template_directory'); ?&gt;/prettyPhoto.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; charset=&quot;utf-8&quot; /&gt;
&lt;script src=&quot;&lt;?php bloginfo('template_directory'); ?&gt;/scripts/jquery.prettyPhoto.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Custom Code</h3>
<p>Modify the code in prettyPhoto.css. This step is necessary so the path to the images for prettyPhoto is corrected according to your setup:</p>
<ul>
<li>open <strong>prettyPhoto.css</strong> </li>
<li><strong>CTRL + F</strong> (Find) all instances of “<strong>url(../</strong>”</li>
<li>And replace with “<strong>url(</strong>” *There should be around 100 occurences </li>
<li>Save the file</li>
</ul>
<p>Again, this is due to the location of the images and the css file has changed from the example files from prettyPhoto. This ensures the images needed for our lightbox is functioning properly:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2011/04/lb1.jpg" alt="lb1 How to Add Lightbox to Wordpress without a Plugin" title="lb1" width="576" height="290" class="alignnone size-full wp-image-2125" /></p>
<p>Open <strong>header.php</strong> – and add the following code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>  
jQuery<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: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a[href$='.jpg'], a[href$='.jpeg'], a[href$='.gif'], a[href$='.png']&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prettyPhoto</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	animationSpeed<span style="color: #339933;">:</span> <span style="color: #3366CC;">'normal'</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">/* fast/slow/normal */</span>
	padding<span style="color: #339933;">:</span> <span style="color: #CC0000;">40</span><span style="color: #339933;">,</span> <span style="color: #009966; font-style: italic;">/* padding for each side of the picture */</span>
        opacity<span style="color: #339933;">:</span> <span style="color: #CC0000;">0.35</span><span style="color: #339933;">,</span> <span style="color: #009966; font-style: italic;">/* Value betwee 0 and 1 */</span>
	showTitle<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #006600; font-style: italic;">/* true/false */</span>			
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>What the above code does is selecting all links with the <strong>href</strong> attribute that equals to anything ending in <em>.jpeg, .jpg, .gif</em> and <em>.png</em>, and applying the <em>prettyPhoto()</em> function to it.  This means that any link tag that leads to an image (file extensions mentioned) will trigger prettyPhoto. The script is also enclosed inside a document ready event using a jQuery noConflict wrapper. This is to prevent any compatibility issues with other javascript libraries that maybe included with your theme. </p>
<p>I also went ahead and added some options such as the animation speed, padding and show title to our .prettyPhoto function. For additional customization options – refer to the <a href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/documentation/">no-margin-for-errors documentation</a>.   </p>
<h3>Conclusion</h3>
<p>If all goes well &#8211; you can test your work by clicking on an image that links to another image. This should launch the prettyPhoto code that we&#8217;ve just plugged in. You can also apply the same code to links with inline content, external files, youtube movies or other flash based content. Again, refer to prettyPhoto documentation. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2011/04/how-to-add-lightbox-to-wp-without-plugin/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Yet Another jQuery Accordion Tutorial</title>
		<link>http://fearlessflyer.com/2010/11/yet-another-jquery-accordion-tutorial/</link>
		<comments>http://fearlessflyer.com/2010/11/yet-another-jquery-accordion-tutorial/#comments</comments>
		<pubDate>Sat, 06 Nov 2010 19:22:15 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1905</guid>
		<description><![CDATA[It just about that time some good old fashioned web programming. Today we’re learning how to create an accordion style page – using my most favorite of tools: jQuery and CSS. We will try to accomplish an accordion that is so simple, yet useful enough for you to use in your existing pages. Ready to ]]></description>
			<content:encoded><![CDATA[<p>It just about that time some good old fashioned web programming. Today we’re learning how to create an accordion style page – using my most favorite of tools: jQuery and CSS. We will try to accomplish an accordion that is so simple, yet useful enough for you to use in your existing pages. Ready to get started – let’s begin.</p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/accordion/">View Demo</a></div>
<h3>The Goal:</h3>
<p>We will use clean markup. We’re trying to integrate this into exsting HTML – so we will be generating all extra classes and tags using Javascript.  I imagine most web documents follow the same constant pattern: Heading tags, followed by some content which are a mixture of different DIVS, paragraphs, images etc. This goes on until the next heading tag &#8211; which is usually the same type as the first heading. </p>
<p>Look at the sample mark up below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;h5&gt;Some Heading&lt;/h5&gt;
       &lt;!--content in here--&gt;
&lt;h5&gt;Some Heading&lt;/h5&gt;
       &lt;!--content in here--&gt;
&lt;h5&gt;Some Heading&lt;/h5&gt;
        &lt;!--content in here--&gt;</pre></td></tr></table></div>

<p>We will use the H5 tags as our “<strong>Clicker</strong>” – once clicked, will hide the contents right underneath it. Click it again, and it will show the contents again. </p>
<h3>The Script:</h3>
<p>We start by calling the jQuery library, followed by the document.ready() call:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.4.3.min.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	$<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>
&nbsp;
               <span style="color: #339933;">&lt;!--</span>script goes here<span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>We then loop through each of our particular heading tag (in this case, all of H5).  Once it finds all of them, it checks to see if right next to it is another H5 tag; if it’s not, it adds a class of “<strong>clicker</strong>” to it and appends a span with a minus (-) sign in it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<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><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</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;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</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;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;clicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span&gt;-&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
	<span style="color: #009900;">&#125;</span>					
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If you investigate your code so far – you will see that only the H5 tags that have content OTHER than H5 tags have the class “<strong>clicker</strong>” and the span tag with a minus (-) sign in it: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/11/accordion1.jpg" alt="accordion1 Yet Another jQuery Accordion Tutorial" title="accordion1" width="576" height="298" class="alignnone size-full wp-image-1906" /></p>
<p>Now let’s code the click events:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5.clicker&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</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;">nextUntil</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><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: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'+'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
			<span style="color: #009900;">&#125;</span><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: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">nextUntil</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;h5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</span><span style="color: #009900;">&#41;</span><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: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'span'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>Now that we have our designated clickers, we create a couple of functions that toggle at every click. </p>
<p>The first action, hides the contents below &#8220;<strong>$(this)</strong>&#8221; – which is the tag you just clicked. Remember &#8211; we only want to hide the contents up until the next H5 tag. It also changes the content of the span into a plus (+) symbol.</p>
<p>The second action shows the contents below, and changes the span to a minus (-) symbol. </p>
<h3>Optional Styling:</h3>
<p>At this point you already have a functional accordion. If you’re applying the code to an existing page, you are already working with the current styles.  Although, using CSS3 for say the plus (+) and minus (-) span looks pretty cool – which I’m sure you’d want to use. </p>
<p>Add this code to your styles:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#2daebf</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">alert-overlay.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">repeat-x</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #933;">9px</span> <span style="color: #933;">2px</span> <span style="color: #933;">9px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> 
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1px</span> <span style="color: #933;">3px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-1px</span> <span style="color: #933;">1px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #3333ff;">:Arial</span><span style="color: #00AA00;">,</span> Helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-47px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/*ie 7*/</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#007d9a</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:active</span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#wrap</span> h5 span<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">23px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-shadow</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">-1px</span> <span style="color: #933;">1px</span> rgba<span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span><span style="color: #cc66cc;">0.25</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Of course you have to replace the #wrap h5 with your own class / ids. This creates the css3 button you see in the demo. This code is courtesy of <a href="http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba"> Zurb’s Super Awesome buttons with CSS3 and RGBA:</a>   </p>
<h3>Conclusion</h3>
<p>And that is it! You have yourself an accordion page powered by jQuery.  Feel free to grab this code and improve it. Maybe refactor it into a more plugin like code – make it more reusable. Or even &#8211; fix the choppiness issue in the slideUp / slideDown animation in certain browsers. In any case, please leave a comment on what you think of this code.</p>
<p>You might also be interested in these articles regarding jQuery accordions: </p>
<ul>
<li><a href="http://www.sohtanaka.com/web-design/simple-accordion-w-css-and-jquery/">Simple Accordion w/ CSS and jQuery</a></li>
<li><a href="http://net.tutsplus.com/tutorials/javascript-ajax/exactly-how-to-create-a-custom-jquery-accordion/">Exactly How to Create a Custom jQuery Accordion </a></li>
<li><a href="http://css-tricks.com/grid-accordion-with-jquery/">Grid Accordion with jQuery</a></li>
</ul>
<div class="special">There are no downloads for this tutorial because it&#8217;s pretty simple to follow. View the source code of the demo page to get the code</div>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/accordion/">View Demo</a></div>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/11/yet-another-jquery-accordion-tutorial/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to Create Your Own jQuery Content Slider</title>
		<link>http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/</link>
		<comments>http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/#comments</comments>
		<pubDate>Sun, 15 Aug 2010 19:27:47 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Content Slider]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slideshow]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1762</guid>
		<description><![CDATA[This tutorial will show you how to create your own jQuery content slider. You may ask &#8220;Why create my own if there are hundreds of already made sliders out there?&#8221; This is true: I myself almost always use ready made plugins for my projects. Yet, it is always a good thing to know how they ]]></description>
			<content:encoded><![CDATA[<p>This tutorial will show you how to create your own jQuery content slider. You may ask &#8220;<em>Why create my own if there are hundreds of already made sliders out there?</em>&#8221; This is true: I myself almost <em>always</em> use ready made plugins for my projects. Yet, it is always a good thing to know how they work. It also comes in handy &#8211; if you should ever want to customize it (it’s always harder to edit someone else’s code). </p>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/content-slider/">View the Demo</a></div>
<div class="special">If you choose to skip the tutorial &#8211; you are free to download the source code from this <a href="http://fearlessflyer.com/downloads/content-slider.zip">link</a></div>
<p>So are you ready to get started? Let’s begin: </p>
<h3>Step 1: Create the Base Mark Up</h3>
<p>What we need is a series of images in an unordered list:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
&lt;li&gt;&lt;img src=&quot;image1.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image2.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image3.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image4.jpg&quot; /&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image6.jpg&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Pretty straightforward code – view it in the browser and see a bunch of images listed from top to bottom. </p>
<h3>Step 2: Add jQuery Code to hide unfocused images:</h3>
<p>What we’re trying to achieve is to only show the first image of the list and hide the rest. We do this by applying some CSS rules via jQuery to the mark up we&#8217;ve created. We also want to line up the hidden images to the right – so we can add controls that animate the entire ul a little bit to the left at a time (see illustration below):</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot1.jpg" alt="screenshot1 How to Create Your Own jQuery Content Slider" title="screenshot1" width="576" height="490" class="alignnone size-full wp-image-1763" style="border:none;" /></p>
<p>Add the following code right above the closing head tag:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</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: #003366; font-weight: bold;">var</span> theImage <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul li img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> theWidth <span style="color: #339933;">=</span> theImage.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #006600; font-style: italic;">//wrap into mother div</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">wrap</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;mother&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>					
	<span style="color: #006600; font-style: italic;">//assign height width and overflow hidden to mother</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mother'</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>
		width<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: #000066; font-weight: bold;">return</span> theWidth<span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
		height<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: #000066; font-weight: bold;">return</span> theImage.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
		position<span style="color: #339933;">:</span> <span style="color: #3366CC;">'relative'</span><span style="color: #339933;">,</span>
		overflow<span style="color: #339933;">:</span> <span style="color: #3366CC;">'hidden'</span>  	
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//get total of image sizes and set as width for ul </span>
	<span style="color: #003366; font-weight: bold;">var</span> totalWidth <span style="color: #339933;">=</span> theImage.<span style="color: #660066;">length</span> <span style="color: #339933;">*</span> theWidth<span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</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>
		width<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: #000066; font-weight: bold;">return</span> totalWidth<span style="color: #339933;">;</span>	
	<span style="color: #009900;">&#125;</span>				
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//doc ready</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>In English</strong>: in the first script tag – we have connected to the jQuery library online. Then we go in the <strong>window.load()</strong> event *as supposed to document.ready() – because of an <a href="http://stackoverflow.com/questions/1126272/are-image-properties-part-of-the-dom-jquery-webkit-inconsistency-with-other-br">issue detecting image width and height with webkit browsers</a>. Then we set up a couple of variables which are all the images inside the unordered list, along with their widths. We wrap the unordered list (using the .wrap() function) inside a div called “mother” with the CSS rules I mentioned.</p>
<h3>Step 3: Add “Next” and “Previous” Buttons</h3>
<p>In our HTML – add anchor tags with the class “<em>next</em>” (If you want to move forward the slider) and “<em>previous</em>” (to go backward) inside the list items:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul&gt;
&lt;li&gt;&lt;img src=&quot;image1.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image2.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image3.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image4.jpg&quot; /&gt;&lt;a class=&quot;next&quot; href=&quot;#&quot;&gt;next&lt;/a&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;img src=&quot;image6.jpg&quot; /&gt;&lt;a class=&quot;previous&quot; href=&quot;#&quot;&gt;prev&lt;/a&gt;&lt;a class=&quot;startover&quot; href=&quot;#&quot;&gt;startover&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<p>Note that you will not see these links when you preview the page. This is because they are tucked away outside the visible region of the overflow property we’ve created: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot2.jpg" alt="screenshot2 How to Create Your Own jQuery Content Slider" title="screenshot2" width="576" height="396" class="alignnone size-full wp-image-1764" style="border:none;" /></p>
<h3>Step 3: The Nifty .Animate()Method</h3>
<p>Okay, now we’ve come to the part where we actually see some action. The whole point of what we’re trying to do is to move the list a little to the right – when the &#8220;<em>next</em>&#8221; link is clicked, and to the left if &#8220;<em>previous</em>&#8221; is clicked: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot3.jpg" alt="screenshot3 How to Create Your Own jQuery Content Slider" title="screenshot3" width="576" height="396" class="alignnone size-full wp-image-1765" style="border:none;" /></p>
<p>Add the following javascript code inside the existing script tags:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>theImage<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>		
<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>intIndex<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;">nextAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><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: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</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;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.next&quot;</span><span style="color: #009900;">&#41;</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #3366CC;">&quot;margin-left&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>intIndex <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> theWidth<span style="color: #009900;">&#41;</span>				
					<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</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>$<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;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.previous&quot;</span><span style="color: #009900;">&#41;</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #3366CC;">&quot;margin-left&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>intIndex <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> theWidth<span style="color: #009900;">&#41;</span>				
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</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>$<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;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.startover&quot;</span><span style="color: #009900;">&#41;</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;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #3366CC;">&quot;margin-left&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>				
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</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: #339933;">;</span><span style="color: #006600; font-style: italic;">//close .bind()									 </span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//close .each()</span></pre></td></tr></table></div>

<p><strong>Explanation:</strong> the code above starts out with the “<em>.each</em>” function – which is essentially a loop that looks for each of our images in the list. Then it finds all of the anchor tags next to the images (through <em>.nextAll</em>) and checks them for the assigned class. If the class says <em>“next”</em> – animate the parent (ul) to the left by applying a margin-left CSS property to it. The same thing goes for class<em> “previous”</em>. The only difference is the index is advanced vs. deducted multiplied by the image width. Lastly – is class “<em>startover</em>” which resets the slider to its original position. </p>
<p>Add the CSS code below inside the <em>“head”</em> tag so you can see the links and start testing them:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">&lt;style<span style="color: #00AA00;">&gt;</span>
<span style="color: #00AA00;">*</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul <span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span>
ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.startover</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&lt;/style<span style="color: #00AA00;">&gt;</span></pre></td></tr></table></div>

<h3>
Step 4: Make ‘er Nice and Purrty</h3>
<p>Technically – our slider is done. This section mainly focuses on making it look nice and presentable. So I grab this file: <a href="http://fearlessflyer.com/u/slider-constructor">Slider Constructor from Graphic River</a>. Slider Constructor is a high quality Photoshop filled with shiny slider buttons and controls that will surely bring life to your new slider. Create the buttons of your choice from this file and save them as individual .pngs.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/08/screenshot4.jpg" alt="screenshot4 How to Create Your Own jQuery Content Slider" title="screenshot4" width="576" height="178" class="alignnone size-full wp-image-1766" style="border:none;" /></p>
<p>You can set a different button for each anchor tag in each slide. You can also place them anywhere you want with some CSS positioning. Either add an &#8220;id&#8221; attribute to the individual anchor tags, or an additional class (which is what I did). Below is the CSS for my demo &#8211; of course, you might want to code yours differently:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">ul li a<span style="color: #6666ff;">.next</span>.<span style="color: #993333;">red</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-red.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">57px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">73px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">560px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">237px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span>.<span style="color: #993333;">green</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-green.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">286px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">486px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span>.<span style="color: #993333;">green</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">prev-green.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">67px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">286px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span><span style="color: #6666ff;">.orange</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-orange.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">239px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">62px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">360px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span><span style="color: #6666ff;">.orange</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">prev-orange.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">239px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">62px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.next</span>.<span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">next-blue.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">57px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">129px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">150px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">562px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span>.<span style="color: #000000; font-weight: bold;">blue</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">prev-blue.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">58px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">129px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">150px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.previous</span>.<span style="color: #993333;">silver</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">previous-silver.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">49px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">50px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">305px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">360px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul li a<span style="color: #6666ff;">.startover</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">startover.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">176px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">73px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">280px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">420px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Also &#8211; the good thing about this code is you can place and style the buttons individually. </p>
<h3>Conclusion</h3>
<div class="viewdemo"><a href="http://demo.fearlessflyer.com/html/demo/content-slider/">View the Demo</a></div>
<p>There, there – you’ve just done yourself some good coding <em>Sparky</em>!  Feel free to modify, re-factor and make the code better. This is as basic as it gets – so have fun tweaking it. Make sure you leave a comment or spread the word by retweeting or liking it in facebook. Until next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP</title>
		<link>http://fearlessflyer.com/2010/04/create-a-single-page-portfolio-from-scratch-part-3-jquery-and-php/</link>
		<comments>http://fearlessflyer.com/2010/04/create-a-single-page-portfolio-from-scratch-part-3-jquery-and-php/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 02:40:16 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1369</guid>
		<description><![CDATA[Finally, we have come to the conclusion of this 3 part series. This part focuses on user interactions and functionality of our portfolio. The upper sections of the page I will take you through inserting several plugins as well as custom jQuery code that will make our page alive. This includes a rotating slideshow, expanding ]]></description>
			<content:encoded><![CDATA[<p>Finally, we have come to the conclusion of this 3 part series. This part focuses on user interactions and functionality of our portfolio. The upper sections of the page I will take you through inserting several plugins as well as custom jQuery code that will make our page alive. This includes a rotating slideshow, expanding and hiding sections and a modal view of images – also known as a “<strong>lightbox</strong>” effect. And to wrap it all up, we will add a small PHP snippet into our footer so we will have a working contact form. </p>
<div class="viewdemo">
<a href="http://demo.fearlessflyer.com/html/demo/one/">View the Demo:</a>
</div>
<div class="special">
This tutorial is part 3 of three parts: 1) <strong><a href="http://fearlessflyer.com/2009/11/create-a-single-page-portfolio-from-scratch-part-1-photoshop-mockup/">the Photoshop Mock up</a></strong>, 2) <strong><a href="http://fearlessflyer.com/2009/12/create-a-single-page-portfolio-from-scratch-part-2-html-and-css/">Coding the HTML / CSS</a></strong> and finally 3) <strong><a href="http://fearlessflyer.com/2010/04/create-a-single-page-portfolio-from-scratch-part-3-jquery-and-php/">Adding PHP / jQuery</a>.</strong>
</div>
<p>Are you ready to get your hands dirty? Let’s start coding:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/part3.jpg" alt="part3 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Part 3 of 3" width="576" height="189" class="alignnone size-full wp-image-1370" style="border:0;" /></p>
<h3>Convert the Feature into a jQuery Powered Slideshow:</h3>
<p>Our feature section looks good as it is. Though it would be better if the large image on the right would change and cycle through other images. In other words, we need to convert it into a slideshow of our best work. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp1.jpg" alt="sp1 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Well convert this into a slideshow" width="576" height="323" class="alignnone size-full wp-image-1371" /></p>
<h4>Adding the Script Files</h4>
<p>First thing we need to do is download jQuery. jQuery will be powering all of the javascript we’re using for our page. Head on to <a href="http://jquery.com/">http://jquery.com/</a>, download and save it into our current directory. </p>
<p>Inside the head section of our HTML, insert our script tag:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;jquery-1.3.2.min.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>Now all of jQuery’s magic is in our fingertips. Download the slideshow plugin from:  <a href="http://jquery.malsup.com/cycle/">http://jquery.malsup.com/cycle/</a>. Right below our first script tag, insert directly below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;jquery.cycle.all.2.72.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
	$(document).ready(function(){
		//cycle plugin
		$('.slideshow').cycle({
			fx: 'fade' 
		});
&lt;/script&gt;</pre></td></tr></table></div>

<h4>Getting the images ready:</h4>
<p>Now that our scripts are intact, let’s get our images and our stylesheet ready so the animation will take place. Open <strong>feature.png</strong> in Photoshop and create new guides as shown below. Make sure you cut right down to the pixel. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp2.jpg" alt="sp2 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Add new guides" width="576" height="547" class="alignnone size-full wp-image-1372" /></p>
<p>Cut out the center image and fill with solid color.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp3.jpg" alt="sp3 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Fill with color" width="576" height="547" class="alignnone size-full wp-image-1373" /></p>
<p>Save the file under the same name.</p>
<p>Create several images that will go inside the slideshow -<strong> all must have the same dimensions</strong> &#8211; in our case: 476 pixels and 349 pixels. </p>
<p>Insert the HMTL right below the feature div. Of course you will replace the image names with your images, along with the right path:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;slideshow&quot;&gt;
&lt;img src=&quot;images/feature-1.jpg&quot;/&gt;
&lt;img src=&quot;images/feature-2.jpg&quot;/&gt;
&lt;img src=&quot;images/feature-3.jpg&quot;/&gt;
&lt;img src=&quot;images/feature-4.jpg&quot;/&gt;
&lt;img src=&quot;images/feature-5.jpg&quot;/&gt;		
&lt;/div&gt;</pre></td></tr></table></div>

<p>Append this code inside your existing style.css file:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#feature</span> <span style="color: #6666ff;">.slideshow</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-24px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">21px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This ensures that the slideshow will sit on top of the designated box in the feature div:</p>
<p>Preview index.html in your browser. By now you should see your new slideshow swapping your images in your feature section: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp4.jpg" alt="sp4 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Our slideshow is in place" width="576" height="323" class="alignnone size-full wp-image-1374" /></p>
<p><strong>Next up: The expanding sections, and the “lightbox” effect.</strong></p>
<h3>Adding the “More” click events on the sections below the fold:</h3>
<p>We have two sections below the fold that showcase what our work is all about. One is the useful “<strong>Testimonials</strong>” section – where visitors read what others are saying about our services. And of course, the “<strong>Previous Work</strong>” area – where you plug in screenshots of work that you’ve done. This may be websites, photographs, software; anything that can be screen captured you can apply. </p>
<p>The point is to only show a few of testimonials, and a few thumbnails of your previous work. When visitors click on the “<strong>More</strong>” buttons, the section expands to show the rest. </p>
<p>This approach is also best for people who have plenty of work, but only would like to show a little at first. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp5.jpg" alt="sp5 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="The More Buttons" width="576" height="630" class="alignnone size-full wp-image-1375" /></p>
<p>Insert the code below inside the <strong>$(document)</strong>.ready function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.column:gt(2), #previous-work ul li:gt(3)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#testimonials&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;div class='more'&gt;&lt;a id='more-testimonials'&gt;More Testimonials&lt;/a&gt;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#previous-work&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;div class='more'&gt;&lt;a id='more-previous-work'&gt;More Previous Work&lt;/a&gt;&lt;/div&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#more-testimonials&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<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>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.column:gt(2)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:hidden&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>							
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.column:gt(2)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#more-testimonials&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Less Testimonials&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
			<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.column:gt(2)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#more-testimonials&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;More Testimonials&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
			<span style="color: #009900;">&#125;</span>			
			event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>					  	
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#more-previous-work&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<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>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#previous-work ul li:gt(3)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:hidden&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#previous-work ul li:gt(3)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#more-previous-work&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Less Previous Work&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				
			<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#previous-work ul li:gt(3)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a#more-previous-work&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;More Previous Work&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>			
			event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The above code first hides our testimonial DIVS (that are greater than 3) and our previous work list items (that are greater than 4). Then it alters the HTML of our buttons, as well as toggle our hidden sections to appear while sliding slowly. </p>
<h3>Adding the light show effect for the Portfolio gallery: </h3>
<p>For the portfolio thumbnails &#8211; it would really be nice to add a “lightbox” effect once the images are clicked. Lightbox provide a way for viewers to see the detailed image without physically leaving the page. For our portfolio &#8211; we’re using <a href="http://fancybox.net/">http://fancybox.net/</a></p>
<p>Download: <a href="http://fancybox.googlecode.com/files/jquery.fancybox-1.2.6.zip">http://fancybox.googlecode.com/files/jquery.fancybox-1.2.6.zip</a><br />
Extract the files and copy the folder “<strong>fancybox</strong>” from the unzipped file and place in the root folder of our portfolio. Inside index.html, place the code in the head section:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;./fancybox/jquery.fancybox-1.2.6.pack.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;./fancybox/jquery.fancybox-1.2.6.css&quot; media=&quot;screen&quot; /&gt;</pre></td></tr></table></div>

<p>Inside our custom script tag, (right after the last “<strong>});</strong>”) insert the block of code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a.zoom&quot;</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>
			<span style="color: #3366CC;">'zoomSpeedIn'</span>	<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">'zoomSpeedOut'</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In our unordered list of thumbnails, insert this “<strong>class</strong>” and “<strong>rel</strong>” attributes for each anchor tag:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">class=&quot;zoom&quot; rel=&quot;group&quot;</pre></div></div>

<p>Refresh <strong>index.html</strong> in your browser and click a thumbnail. You should now see the effects of Fancy box from your portfolio:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp-unknown.jpg" alt="sp unknown Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="The lightbox effect" width="576" height="323" class="alignnone size-full wp-image-1377" /></p>
<p><strong>Last step: The contact form.</strong></p>
<h3>Completing the Contact Form with PHP</h3>
<p>Since HTML and javascript doesn’t support contents of a form to be sent through email, we need a little help from PHP to bring our contact form to life. We are now working with server side technology, so won’t be able to test our file without a web server. So in order to test our code, upload your file to your web host or run apache locally using <strong>WAMP</strong> or <strong>MAMP</strong>. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp6.jpg" alt="sp6 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Server side code needs a web server" width="576" height="400" class="alignnone size-full wp-image-1380" /></p>
<p>First thing we have to do is change the extension of <strong>index.html</strong> to <strong>.php</strong>. We will be working with the .php file from now on. You can discard the .html version – or keep it for archive. </p>
<p>Look for the form tag inside <strong>index.php</strong>; add a method and an action attribute:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form id=&quot;contact-form&quot; method=&quot;post&quot; action=&quot;&quot;&gt;</pre></div></div>

<p>This enables our form to use the <strong>$_POST</strong> array and be processed by the same page. To test the contents of our post array, type the following code right above the form:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;pre&gt;
&lt;?php print_r($_POST) ?&gt;</pre></td></tr></table></div>

</pre>
<p>Now, add some stuff to the form fields, click “<strong>Submit</strong>” and see what our pre tags have spitted out: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp7.jpg" alt="sp7 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Contents of our post array" width="576" height="400" class="alignnone size-full wp-image-1381" /></p>
<p>Now we know what we need to work with as far as the contents of our post array. We can now remove the  pre tags and continue to work on our code. Add the following code on the very top of the page (even before the !DOCTYPE declaration):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//see number 1</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array_key_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'send'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//see number 2</span>
<span style="color: #000088;">$to</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'youremail@mail.com'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//this is your email address</span>
	<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'From Your Contact Form'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$comments</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'comments'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  
		<span style="color: #666666; font-style: italic;">//see number 3</span>
<span style="color: #000088;">$message</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Name: <span style="color: #006699; font-weight: bold;">$name</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
	<span style="color: #000088;">$message</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Email: <span style="color: #006699; font-weight: bold;">$email</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$message</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;Comments: <span style="color: #006699; font-weight: bold;">$comments</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//see number 4</span>
	<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to</span><span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>What the above code is doing: </strong></p>
<div class="one">checks to see if the “<strong>submit</strong>” button has been clicked by checking if an array key by the name of “send” exists. If it does, the rest of the code executes:</div>
<div class="two">we’re creating several variables that we can work with – this includes $to – email address to send to, along with the contents of the post array</div>
<div class="three">we’re compiling the message by concatenating the variables we’ve created</div>
<div class="four">finally, the “<strong>mail</strong>” function which is what allows you send mail</div>
<p>Now it’s time to test the code. Enter your email address into the <strong>$to</strong> variable then upload index.php to your web server. Fill out the form fields and click “<strong>submit</strong>”. You should receive an email similar to below:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/sp8.jpg" alt="sp8 Create a Single Page Portfolio from Scratch – Part 3: jQuery and PHP" title="Sample Email" width="576" height="291" class="alignnone size-full wp-image-1382" /></p>
<p>Now remember <strong>that this is a stripped down version of a contact form</strong>. You should seriously consider adding several things such as form validation and formatting the entries for safe and legitimate values. Also add error and success messages to let the user know what’s going on. (I won’t cover such things because as you can see – this tutorial has gone waaay too long).</p>
<h3>Final Words</h3>
<p>There you have it - a complete single page portfolio. We started all the way from scratch: Mocked up the concept in Photoshop, hand coded the HTML, while slicing the images and writing the CSS. We've added some jQuery magic as well as a little bit of PHP functionality. As you see - a lot of work does go into it (and that's just a single page!)</p>
<p>In closing, I hope that you may learn something from this 3 part series. I also would like to thank the script and plugin developers which I included in this tutorial. You can <strong><a href="http://fearlessflyer.com/downloads/single-page-portfolio-final.zip">download the finished product from this link</a></strong>, and of course<strong><a href="http://demo.fearlessflyer.com/html/demo/one/"> view the live demo</a></strong> from here. </p>
<p>I also suggest that you find a <a href="http://www.hostingobserver.com/server-hosting.php"><strong>web hosting server</strong></a> that works well with HTML, PHP and jQuery. This will take care of all your hosting needs.</p>
<div class="special">
This tutorial is part 3 of three parts: 1) <strong><a href="http://fearlessflyer.com/2009/11/create-a-single-page-portfolio-from-scratch-part-1-photoshop-mockup/">the Photoshop Mock up</a></strong>, 2) <strong><a href="http://fearlessflyer.com/2009/12/create-a-single-page-portfolio-from-scratch-part-2-html-and-css/">Coding the HTML / CSS</a></strong> and finally 3) <strong><a href="http://fearlessflyer.com/2010/04/create-a-single-page-portfolio-from-scratch-part-3-jquery-and-php/">Adding PHP / jQuery</a>.</strong>
</div>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/04/create-a-single-page-portfolio-from-scratch-part-3-jquery-and-php/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Automating the Guest Post Process</title>
		<link>http://fearlessflyer.com/2010/04/automating-the-guest-post-process/</link>
		<comments>http://fearlessflyer.com/2010/04/automating-the-guest-post-process/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 18:05:53 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WP Themes]]></category>
		<category><![CDATA[automate]]></category>
		<category><![CDATA[guest posts]]></category>
		<category><![CDATA[tdo mini forms]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1346</guid>
		<description><![CDATA[Ever wonder how to convert your WordPress blog into a more automated posting process? One that can accept guest posts, job listings or even a forum-type of blog? Where users can submit a post, save it into your drafts section and all you have to do is approve or deny? The beauty of the open ]]></description>
			<content:encoded><![CDATA[<p>Ever wonder how to convert your WordPress blog into a more automated posting process? One that can accept guest posts, job listings or even a forum-type of blog? Where users can submit a post, save it into your drafts section and all you have to do is approve or deny? The beauty of the open source community is that someone, somewhere had already thought about doing this, and have already developed a solution. With a combination of several plugins and some custom styling, here is how I was able to automate the guest post submission process here in my blog:</p>
<p>First thing you have to do is check the “<strong>Anyone can Register</strong>” option under “Settings” > “<strong>General</strong>”. Don’t forget to leave the “<strong>New User Default Role</strong>” as “<strong>Subscriber</strong>”.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/auto-1.jpg" alt="auto 1 Automating the Guest Post Process" title="Enabling the Anyone can Register Option" width="576" height="100" class="alignnone size-full wp-image-1347" /></p>
<h3>Lock Down the Registration Process</h3>
<p>Now that you have your site open for registration, it is best that you install these plugins first to enable tighter security:</p>
<div class="pros"><strong><a href="http://bueltge.de/wordpress-login-sicherheit-plugin/652/">Secure WP</a></strong> – as many options that this plugin comes with to enhance security, what I especially need it for is to disable the error messages at login (which this plugin does very well)</div>
<div class="pros"><strong><a href="http://didier.lorphelin.free.fr/blog/index.php/wordpress/sabre/">SABRE</a></strong> &#8211; stands for “Simple Anti Bot Registration Engine”. This produces that image during registration to block “autobots”</div>
<div class="pros"><strong><a href="http://devel.kostdoktorn.se/limit-login-attempts">Limit Login Attempts</a></strong> – the plugin title says it all. Activate this plugin and tweak depending how tight you want login attempts. Note that you’re not going to see any error messages due to the Secure WP plugin</div>
<h3>Hide the WP Admin Panel</h3>
<p>So registration is open, security is tight – you still don’t want users to see your WordPress admin area. Not that there’s anything wrong with that – but it just looks more sophisticated when all is done in the front end. Install the following plugins:</p>
<div class="pros"><strong><a href="http://www.jfarthing.com/wordpress-plugins/theme-my-login-plugin">Theme My Login</a></strong> &#8211; this plugin will generate a page called “<strong>Login</strong>” – this is where your new login forms (includes new registration and forgot password) will sit. Additional options also include custom emails, redirection and moderation. *Make sure you check “<strong>Enable Template Tag</strong>” under “<strong>Optimization</strong>” – You’ll need this in your theme later</div>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/theme-my-login.jpg" alt="theme my login Automating the Guest Post Process" title="Theme My Login Settings" width="576" height="320" class="alignnone size-full wp-image-1352" /></p>
<div class="pros"><strong><a href="http://www.jfarthing.com/wordpress-plugins/theme-my-profile-plugin">Theme My Profile</a></strong> – plugin created by the same author, which ports the users “profile” page into the front end.  Make sure you theme and block admin area ONLY for roles you want.</div>
<p>The following screenshots show the login page, as well as the profile page generated by the plugins that I’ve mentioned:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/registration.jpg" alt="registration Automating the Guest Post Process" title="The New Registration Form" width="576" height="520" class="alignnone size-full wp-image-1353" /></p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/profile.jpg" alt="profile Automating the Guest Post Process" title="The Themed User Profile Page" width="576" height="520" class="alignnone size-full wp-image-1350" /></p>
<h3>TDO Mini Forms</h3>
<p>We’ve come to the meat of the project.  This is the plugin that does all the magic. <a href="http://thedeadone.net/download/tdo-mini-forms-wordpress-plugin/">TDO Mini Forms</a> allows users (registered on not registered) to submit and edit posts to your blog. It comes with its form creator that lets you design the post submission form any way you want. Widgets that let you drag and drop components into your form, as well as a form “<strong>hacker</strong>” that allows even deeper code tweaking. What I especially liked is that it hooks up with your “<strong>Akismet</strong>” for spam protection. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/tdo-mini-forms-1.jpg" alt="tdo mini forms 1 Automating the Guest Post Process" title="TDO Mini Forms Configuration Page" width="576" height="520" class="alignnone size-full wp-image-1354" /></p>
<p>After specifying all the configuration settings with TDO, go ahead and create a form with “Form Creator”. The form creator is a somewhat decent drag and drop interface where you grab the widgets in the bottom and drag it to the form.  Widget settings are applied by clicking on the settings tab and it brings up the settings window as shown below:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/tdo-mini-forms-2.jpg" alt="tdo mini forms 2 Automating the Guest Post Process" title="Form Creator by TDO" width="576" height="520" class="alignnone size-full wp-image-1355" /></p>
<p>Once you’ve decided on the fields and the settings, you can now alter the code to change the verbiage, along with adding HTML elements in order to be able to style it in your stylesheet.  Below shows my contribute form: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/contribute1.jpg" alt="contribute1 Automating the Guest Post Process" title="My newly styled Contribute Form" width="576" height="520" class="alignnone size-full wp-image-1356" /></p>
<h5>Maybe some Custom Code</h5>
<p>Depending on your pages – you might need to add some PHP conditional tags and functions to the theme manually. This is to link the new pages to each other.  Simply copy your theme’s page.php file and rename it to something.php – convert it into a template by adding the code on top of the page:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Template Name: something
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now below the call for the content, add the conditional tag with from the Theme My Login plugin:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> is_user_logged_in<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
   &lt;div &gt;I bet you would like to submit a Guest Post. Click &lt;a href=&quot;yourwebsite.com/conribute&quot;&gt;here&lt;/a&gt; to access the contribute form. &lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The screenshot below shows the custom link to the contribute form that we just created: </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/login.jpg" alt="login Automating the Guest Post Process" title="Custom Link to Contribute" width="576" height="220" class="alignnone size-full wp-image-1349" /></p>
<p>All you have to do now is to wait for guest post submissions and depending on the content &#8211; simply approve, edit or deny. The submissions are saved as draft posts and are in the moderation view of TDO mini forms:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/moderation2.jpg" alt="moderation2 Automating the Guest Post Process" title="The Final Process" width="576" height="813" class="alignnone size-full wp-image-1367" style="border:0;" /></p>
<h3>Conclusion </h3>
<p>Now that you have converted your blog into a more automated (and sophisticated) posting process – think of all the possible scenarios you can create.  Of course I’m completely aware that my guest posts will not land any successful submissions any time soon – it’s just good to know that it’s available. Not to mention, it was fun to make. </p>
<p>Let’s not forget to donate to the plugin authors!</p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/04/automating-the-guest-post-process/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Looking for Guest Writers!</title>
		<link>http://fearlessflyer.com/2010/04/looking-for-guest-writers/</link>
		<comments>http://fearlessflyer.com/2010/04/looking-for-guest-writers/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 22:33:27 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[guest post]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[write articles]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=1321</guid>
		<description><![CDATA[Content content content. Probably the hardest thing to come up with. My original plan was just to have this website as a personal blog / portfolio but since the popularity of my themes (and some of the articles) &#8211; I&#8217;m getting that itch to take things even further. Maybe Fearlessflyer can come up a notch. ]]></description>
			<content:encoded><![CDATA[<p>Content content content. Probably the hardest thing to come up with. My original plan was just to have this website as a personal blog / portfolio but since the popularity of my themes (and some of the articles) &#8211; I&#8217;m getting that itch to take things even further. Maybe Fearlessflyer can come up a notch. Maybe it can attract more readers. Maybe it can play with the big guys. But one man cannot do it. I need <strong>content</strong> and I&#8217;ve run out. </p>
<p>That&#8217;s why I need your help. </p>
<h3>Why write for me?</h3>
<p>Decent exposure. Below is a screenshot of my analytics page. I do not do any marketing for my blog, nor do I submit it to special web directories. Most of my traffic are organic (from search engines) and word of mouth. My themes are the central source of visits &#8211; and they keep coming.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2010/04/analytics.jpg" alt="analytics Looking for Guest Writers!" title="Google Analytics" width="576" height="323" class="alignnone size-full wp-image-1322" /></p>
<h3>What I&#8217;m Looking For</h3>
<p>Articles related to web design, WordPress, code, plugins, how-to&#8217;s. Basically &#8211; if it&#8217;s interesting and it&#8217;s about web design &#8211; I want it. The articles do not have to be well written. I am pretty good in proof reading and I can polish your articles as needed. </p>
<p>If you&#8217;re interested contact me &#8211; host[at]fearlessflyer.com. Your article will be fully credited to you inside an author box (which I have yet to work on), along with links to your portfolio and Twitter account. I may also work on automating the process so you can have your own account here at Fearlessflyer and create posts anytime. We&#8217;ll see how it goes. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2010/04/looking-for-guest-writers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to Create a Slick jQuery Login Form for WordPress</title>
		<link>http://fearlessflyer.com/2009/06/how-to-create-a-slick-jquery-login-form-for-wordpress/</link>
		<comments>http://fearlessflyer.com/2009/06/how-to-create-a-slick-jquery-login-form-for-wordpress/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 01:57:53 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Login Form]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=624</guid>
		<description><![CDATA[Every WordPress site has its login form in its own page located at: yoursite/wp-admin. But what if you want this form to appear in a more convenient place such as your header template? This will add flexibility to your blog by making your admin pages more accessible. Furthermore, adding a little jQuery makes this form ]]></description>
			<content:encoded><![CDATA[<p>Every WordPress site has its login form in its own page located at: yoursite/wp-admin. But what if you want this form to appear in a more convenient place such as your header template? This will add flexibility to your blog by making your admin pages more accessible. Furthermore, adding a little jQuery  makes this form semi-visible by having a toggle switch.</p>
<h3>The Images</h3>
<p>I only used a couple of images for the form. First is the little tab that extends just right below the edge of our browser that when clicked, shows the entire form. Second is the actual login button. Note that you don’t have to create any images at all for this form – regular CSS styling would look fine. In my case – I used rounded edges for a more stylistic look; hence the need for images:</p>
<p><img class="alignnone size-full wp-image-625" title="Images needed" src="http://fearlessflyer.com/main/wp-content/uploads/2009/06/jquery-login-1.jpg" alt="jquery login 1 How to Create a Slick jQuery Login Form for Wordpress" width="576" height="101" /></p>
<h3>The Form</h3>
<p>This is where the functionality kicks in. This code came from Kriesi’s post: “<a href="http://www.kriesi.at/archives/admin-login-on-your-front-page">Admin login in your front page</a>”.  His code is basically a valid login form that can reside in any page of your WordPress site. An else condition is also included that shows additional options for when the user is logged in. I added a table (that’s correct, I used a TABLE! – so shoot me!) for the input fields and labels to behave and align accordingly. Of course – you can omit the table if you want to. I’ve also added several DIV elements so our form can be housed in a little box.</p>
<p>This part shows when the user isn’t logged in:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;quick-login&quot;&gt;
&lt;div id=&quot;login-form&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>current_user_can<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'level_0'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;form action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-login.php&quot; method=&quot;post&quot;&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;label for=&quot;label&quot;&gt;User&lt;/label&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;label for=&quot;label&quot;&gt;Password&lt;/label&gt;
&lt;em class=&quot;forgot&quot;&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-login.php?action=lostpassword&quot;&gt;Forgot?&lt;/a&gt;&lt;/em&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td&gt;&amp;amp;amp;amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type=&quot;text&quot; name=&quot;log&quot; id=&quot;log&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> wp_specialchars<span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_login</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; size=&quot;20&quot; class=&quot;login-fields&quot; /&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;input type=&quot;password&quot; name=&quot;pwd&quot; id=&quot;pwd&quot; size=&quot;20&quot; class=&quot;login-fields&quot;/&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;&quot; class=&quot;login-button&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;redirect_to&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;</pre></td></tr></table></div>

<p>This code shows when the user IS logged in. I’ve also included my own message for the logged in user. You should adjust this to accommodate your theme.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div id=&quot;logged-in-box&quot;&gt;
&lt;p&gt;You can now quickly edit your posts by clicking the &lt;em&gt;Edit This&lt;/em&gt; &amp;nbsp;buttons after each post&lt;/p&gt;
&lt;ul class=&quot;admin_box&quot;&gt;
&lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/wp-admin/&quot;&gt;Dashboard&lt;/a&gt;&lt;/li&gt; 
&lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> wp_logout_url<span style="color: #009900;">&#40;</span><span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_URI'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;logout&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;!--logged-in-box--&gt; 
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;&lt;!--login-form--&gt;</pre></td></tr></table></div>

<h3>The CSS</h3>
<p>Now that we have all the elements in place, we can proceed with styling them. Note the color for the tab image is the background color for the entire DIV. Another important property is “display:none” &#8211; which hides the form by default. This is what jQuery will toggle to “display:block” when we’re done.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">a<span style="color: #6666ff;">.menu_class</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>images/button-toggle3.png<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">184px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">32px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">-9999px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">outline-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#login-form</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#397846</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#login-form</span> label <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-transform</span><span style="color: #00AA00;">:</span><span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>verdana<span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#login-form</span> em a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#a1dbe6</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">37px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#login-form</span> em a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#999999</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
input<span style="color: #6666ff;">.login-fields</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#444444</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">7px</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
input<span style="color: #6666ff;">.login-button</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">101px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">36px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/login-btn.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#logged-in-box</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">456px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#logged-in-box</span> p <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">238px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#999999</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#logged-in-box</span> p em <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#a1dbe6</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.admin_box</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #933;">20px</span> <span style="color: #933;">20px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.admin_box</span> li<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.admin_box</span> li a<span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFFFF</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-transform</span><span style="color: #00AA00;">:</span><span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span>verdana<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
ul<span style="color: #6666ff;">.admin_box</span> li a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>The jQuery</h3>
<p>Our form is complete, styles and all. The last thing we need is the action. We accomplish this by adding jQuery. First of, don’t forget to reference the library and your custom script in your head section:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/scripts/js/jquery.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/scripts/js/slider.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<p>Then the following few lines of code is what we include in our custom script (“slider.js”).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="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: #009900;">&#40;</span><span style="color: #3366CC;">'a.menu_class'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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: #3366CC;">'div#login-form'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'medium'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And that’s it! You have created a slick jQuery powered login form for your WordPress site. This particular form is designed to be placed in your header file. Note that the form will work from any template in your theme. <strong>Give the <a href="http://blue.fearlessflyer.com/home/jquery-demo/">demo</a> a try</strong> – I’ve designated a test user account so you can see how the form looks when logged in.</p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2009/06/how-to-create-a-slick-jquery-login-form-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Create A Subscribe Bar with CSS Sprites</title>
		<link>http://fearlessflyer.com/2009/05/create-a-subscribe-bar-with-css-sprites/</link>
		<comments>http://fearlessflyer.com/2009/05/create-a-subscribe-bar-with-css-sprites/#comments</comments>
		<pubDate>Fri, 22 May 2009 06:48:37 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[Photoshop]]></category>
		<category><![CDATA[PSD]]></category>
		<category><![CDATA[social buttons]]></category>
		<category><![CDATA[sprites]]></category>
		<category><![CDATA[subscribe]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=511</guid>
		<description><![CDATA[Having a subscribe bar is almost a necessity for modern websites. This organizes your reader&#8217;s options on how to stay informed of your updates and new posts. May it be through Twitter, RSS, Email or even Facebook &#8211; you can display this bar in almost any part of your web pages. This following will teach ]]></description>
			<content:encoded><![CDATA[<p>Having a subscribe bar is almost a necessity for modern websites. This organizes your reader&#8217;s options on how to stay informed of your updates and new posts. May it be through Twitter, RSS, Email or even Facebook &#8211; you can display this bar in almost any part of your web pages. This following will teach you how to create a subscribe bar from scratch using Photoshop and a CSS technique known as sprites.  </p>
<h3>Part 1 &#8211; Creating the Image</h3>
<p>In Photoshop, create a new image 432 pixels by 78 pixels. Add a title for your bar, and four icons of your subscription options. In our case, we&#8217;re using an RSS feed icon, Twitter, Email and Facebook. *Icons are from <a href="http://wefunction.com/2009/05/free-social-icons-app-icons/">WeFunction</a> Collection. Line them up and space them evenly. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-0.jpg" alt="social 0 Create A Subscribe Bar with CSS Sprites" title="start with the active layer in Photoshop" width="576" height="374" class="alignnone size-full wp-image-515" /></p>
<p>Add guides that divide each button. Also be sure to add a guide right on the top of the document. Lock the guides in place – you will need these dimensions when creating the CSS. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-01.jpg" alt="social 01 Create A Subscribe Bar with CSS Sprites" title="shown with guides" width="576" height="375" class="alignnone size-full wp-image-516" /></p>
<p>Multiply the canvas height by two. Make sure you click the button that keeps the canvas flushed to the bottom</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-02.jpg" alt="social 02 Create A Subscribe Bar with CSS Sprites" title="Double the canvas size" width="576" height="338" class="alignnone size-full wp-image-518" /></p>
<p>Select all existing layers and create a duplicate set. Merge all the layers in that set to create a single layer which we’ll use for the hover effect of the links. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-11.jpg" alt="social 11 Create A Subscribe Bar with CSS Sprites" title="Duplicate all the layers" class="alignnone size-full wp-image-517" /></p>
<p>Nudge the new layer upwards – make sure it’s lined up exactly as the bottom layers. To create a hover effect – I desaturate the layer all the way to the max – making it a grayscale layer.</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-03.jpg" alt="social 03 Create A Subscribe Bar with CSS Sprites" title="Convert the buttons to greyscale" width="576" height="370" class="alignnone size-full wp-image-520" /></p>
<p>Make sure you hide the background layer and save the image as a .png.</p>
<h3>Part 2 &#8211; The HTML</h3>
<p>We’re going to need a single div and an unordered list of links to render the sprites. Make sure to add an id for each anchor tag. This is how we’ll match the image through our stylesheet.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;subscribe-div&quot;&gt;
&lt;ul id=&quot;subsc&quot;&gt;
&lt;li class=&quot;title&quot;&gt;Keep Updated&lt;/li&gt;
&lt;li&gt;&lt;a id=&quot;rss&quot; href=&quot;#&quot; title=&quot;Subscribe to RSS&quot;&gt;RSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a id=&quot;twit&quot; href=&quot;#&quot; title=&quot;Follow Us in Twitter&quot;&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a id=&quot;mailrss&quot; href=&quot;#&quot; title=&quot;Get Feeds through Mail&quot;&gt;Subscribe By Email&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a id=&quot;facebook&quot; href=&quot;#&quot; title=&quot;Find us in Facebook&quot;&gt;Facebook&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt; 
&lt;/div&gt;&lt;!--subscribe-div--&gt;</pre></td></tr></table></div>

<p>Of course you have to replace the # with your links. Note that the first list item is not a link. This is just a placeholder for the title “Keep Updated” title. </p>
<h3>Part 3 – The CSS</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#subscribe-div</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/social-sprites.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">78px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The first selector (#subscribe-div) can contain general properties of your bar. This includes overall padding, margins or positioning. The second selector  (#subscribe-div ul#subsc li)  – lets the browser know to display list items horizontally. The third (#subscribe-div ul#subsc li a) – calls our .png image.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li<span style="color: #6666ff;">.bar-title</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/social-sprites.png</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">156px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">78px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">-9999px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-2.jpg" alt="social 2 Create A Subscribe Bar with CSS Sprites" title="the list items after some styling" width="576" height="225" class="alignnone size-full wp-image-519" /></p>
<p>This styles our list item bar-title with the “Keep Updated” leftmost section of our .png image – hence the position of 0 0 (means coordinates of 0 and 0). Next is styling the normal state of the links:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #cc00cc;">#rss</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-156px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">68px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #cc00cc;">#twit</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-224px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">65px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #cc00cc;">#mailrss</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-289px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">65px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #cc00cc;">#facebook</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-354px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">78px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>The above code reflects the normal state of the buttons in our list. The only properties applied are width and background position. To get the width of each button, you have to go back to your .psd (remember applying the guides in the beginning of the tutorial). Note that not all the buttons are identical in size, thus varying in widths. To get the background position, always remember: the first value is the left coordinate and the next value is top. Since we already know that our title is 156 pixels, we know our first button (rss) is going to have a background position of -156px. </p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-3.jpg" alt="social 3 Create A Subscribe Bar with CSS Sprites" title="the list items after more styling!" width="576" height="225" class="alignnone size-full wp-image-514" /></p>
<p>Next is the hover state.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #cc00cc;">#rss</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-156px</span> <span style="color: #933;">78px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">68px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #cc00cc;">#twit</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-224px</span> <span style="color: #933;">78px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">65px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #cc00cc;">#mailrss</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-289px</span> <span style="color: #933;">78px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">65px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#subscribe-div</span> ul<span style="color: #cc00cc;">#subsc</span> li a<span style="color: #3333ff;">:hover</span><span style="color: #cc00cc;">#facebook</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-position</span><span style="color: #00AA00;">:</span><span style="color: #933;">-354px</span> <span style="color: #933;">78px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">78px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Notice I just copied the code for the normal state and re-pasted it. The only difference is the use of anchor pseudo class :hover is appended to the “a” selector, and the top value of background position is now 78 pixels. This is because we want the .png image to shift 78 pixels downward, once the mouse is hovered over each link. </p>
<p>The only thing left to do is to indent the text of the links. This is done in the #subscribe-div ul#subsc li a selector (text-indent:-9999px;). </p>
<p>And that&#8217;s it. We have finished creating a subscribe bar from an image in Photoshop, HTML and finally adding some styles with CSS. You can view the demo from this <a href="http://fearlessflyer.com/main/wp-content/uploads/2009/05/social-sprites.html">link</a>, or <strong>download the source code from <a href="http://fearlessflyer.com/downloads/subscribe-bar.zip">here</a>.</strong> All I ask is for you leave a comment, <a href="http://feeds.feedburner.com/Fearlessflyer">subscribe</a> or follow me in <a href="http://twitter.com/_fearlessflyer">Twitter</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2009/05/create-a-subscribe-bar-with-css-sprites/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How to change the Background Dynamically in your WordPress Theme</title>
		<link>http://fearlessflyer.com/2009/05/how-to-change-the-background-dynamically-in-your-wordpress-theme/</link>
		<comments>http://fearlessflyer.com/2009/05/how-to-change-the-background-dynamically-in-your-wordpress-theme/#comments</comments>
		<pubDate>Sat, 09 May 2009 19:01:44 +0000</pubDate>
		<dc:creator>michael soriano</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Blog]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[WP]]></category>
		<category><![CDATA[WP Themes]]></category>

		<guid isPermaLink="false">http://fearlessflyer.com/?p=486</guid>
		<description><![CDATA[We all have seen WordPress sites with repeating backgrounds that span beautifully across the entire page. This property is usually applied in the body tag of your template. What about those portfolio websites that use a different background image in the front page? Or those magazine styled websites that apply different backgrounds for their category ]]></description>
			<content:encoded><![CDATA[<p>We all have seen WordPress sites with repeating backgrounds that span beautifully across the entire page. This property is usually applied in the body tag of your template.  What about those portfolio websites that use a different background image in the front page? Or those magazine styled websites that apply different backgrounds for their category pages? How’d they do that? </p>
<h3>The problem</h3>
<p>For anyone who’s developed a WordPress theme would know how to break it up in templates: header.php, sidebar.php , footer.php etc. And as I’ve mentioned: you control the background image (if you want it to span the entire page) usually in the body tag of your HTML.  The problem is – the body tag comes BEFORE any other tag in your templates. </p>
<p>For example, take a look at the screenshot of a typical header.php file below. It shows the body tag where you apply a different property value in the CSS file each time you want it unique from another page:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/bg-tut1.jpg" alt="bg tut1 How to change the Background Dynamically in your Wordpress Theme" title="bg-tut1" width="576" height="200" class="alignnone size-full wp-image-488" /></p>
<p>The problem is, in your special template, you’ve already called the get header file:</p>
<p><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/bg-tuts2.jpg" alt="bg tuts2 How to change the Background Dynamically in your Wordpress Theme" title="bg-tuts2" width="576" height="200" class="alignnone size-full wp-image-487" /></p>
<h3>The Answer – Conditional Tags</h3>
<p>WordPress is built is such a way that you can control almost every aspect of your pages. One useful snippet is known as Conditional Tags. Conditional tags can be used in your templates to change what is displayed on a particular page – like the background image. Examples of conditional tags are: is_single(), is_front_page() or is_admin(). For more information on Conditional Tags – see the this <a href="http://codex.wordpress.org/Conditional_Tags">link</a> from WordPress Codex library. In our case – we’re going to use the tag is_page_template().</p>
<h3>Step 1: Insert the PHP</h3>
<p>Open your header.php in your text editor. You’re going to add a conditional statement in inside the opening body id tag. In my case, I’m using three different backround images. Two of them, I want to apply in two individual templates, while the rest of the pages share a default image:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;body id=&quot;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page_template<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template-diff-bg-demo1.php'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;template-diff-bg-demo1&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> 
<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>is_page_template<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template-diff-bg-demo2.php'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;template-diff-bg-demo2&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;default&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; &gt;</pre></td></tr></table></div>

<p><strong>Explanation:</strong> If the template used is named “template-diff-bg-demo1.php”, echo a body id of “template-diff-bg-demo1”, or if template used is named “template-diff-bg-demo2.php” use body id of “template-diff-bg-demo2”, otherwise – just use body id of “default”. </p>
<h3>Step 2: The CSS</h3>
<p>Open your styles.css. We’re going to match the body ids that are going to be called each time you switch page templates. In our case – we need three different ids: </p>
<ul>
<li>body# template-diff-bg-demo1 – a different background</li>
<li>body# template-diff-bg-demo2 – another background</li>
<li>body#default – the default background</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">body<span style="color: #cc00cc;">#default</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/default-bg.jpg</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #993333;">center</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #cc00cc;">#template-diff-bg-demo1</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>images/default-bg2.jpg<span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #993333;">center</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body<span style="color: #cc00cc;">#template-diff-bg-demo2</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>images/default-bg3.jpg<span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #993333;">center</span> <span style="color: #993333;">no-repeat</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>Conclusion </h3>
<p>There you have it. We dynamically changed the body ids of our theme – according to specific page templates. Changing the body ids allowed us style them differently in our stylesheet. This is just one of many possibilities in displaying content (or in our case – style) by using WordPress’ conditional tags. Check out the demo using the code above from this <a href="http://squid.fearlessflyer.com/page-2/">link</a>. Happy Coding!</p>
<p><a href="http://squid.fearlessflyer.com/page-2/"><img src="http://fearlessflyer.com/main/wp-content/uploads/2009/05/bg-tuts3.jpg" alt="bg tuts3 How to change the Background Dynamically in your Wordpress Theme" title="bg-tuts3" width="600" height="200" class="alignnone size-full wp-image-489" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://fearlessflyer.com/2009/05/how-to-change-the-background-dynamically-in-your-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: fearlessflyer.com @ 2012-02-03 19:39:09 by W3 Total Cache -->
