<?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>Call Me Goon &#187; Javascript</title>
	<atom:link href="http://callmegoon.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://callmegoon.com</link>
	<description></description>
	<lastBuildDate>Wed, 12 Oct 2011 22:50:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Create a fun, clean, easy to use FAQ list with jQuery!</title>
		<link>http://callmegoon.com/create-a-fun-clean-easy-to-use-faq-list/</link>
		<comments>http://callmegoon.com/create-a-fun-clean-easy-to-use-faq-list/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 04:01:14 +0000</pubDate>
		<dc:creator>Goon</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://callmegoon.com/?p=906</guid>
		<description><![CDATA[This tutorial demonstrates how to create a jQuery FAQ list that is both easy to use and easy to create. View a real life example. FAQ pages are often a long list of questions followed by answers, or a list of questions that anchor link to an answer further down the page. Neither one creates [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft size-full wp-image-908" title="jQuery FAQ List" src="http://callmegoon.com/wp-content/uploads/2009/09/Featured-List.jpg" alt="jQuery FAQ List" width="143" height="125" />
<p>This tutorial demonstrates how to create a jQuery FAQ list that is both easy to use and easy to create.  <a class="newwindow" href="http://www.gatewaygi.com/faqs">View a real life example.</a></p>
<p>FAQ pages are often a long list of questions followed by answers, or a list of questions that anchor link to an answer further down the page.  Neither one creates a very usable way for users to easily find the information they are looking for.</p>
<p>The following script fixes all of that by creating a clean page that puts the user in control of what information to display.</p>

<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0' width='560' height='345'><param name='movie' value='http://screenr.com/Content/assets/screenr_0817090731.swf' ></param><param name='flashvars' value='i=15231' ></param><param name='allowFullScreen' value='true' ></param><embed src='http://screenr.com/Content/assets/screenr_0817090731.swf' flashvars='i=15231' allowFullScreen='true' width='560' height='345' pluginspage='http://www.macromedia.com/go/getflashplayer' ></embed></object>

<h3>The HTML</h3>
<p>First we wrap everything in a wrapper div and give it a class name.  Within this div is an h5.  This h5 is actually our question.  It doesn't have to be an h5, but if you use a different element, you will have to edit the jQuery accordingly to target the element you have chosen to use.  Next, we have a div with a class of answer.  We will be targeting this div in order for the user to be able to show and hide the answer.  Within this div is a paragraph tag with some filler lorem ipsum text.</p>
<p>That is all you need to create the HTML for one question, however, to get the full effect, you will want to copy and past this code a few times so that  you have a few questions.</p>
<pre class="brush: xml; title: ; notranslate">
&amp;amp;lt;div class=&amp;amp;quot;FAQWrap&amp;amp;quot;&amp;amp;gt;
  &amp;amp;lt;h5&amp;amp;gt;This is my question?&amp;amp;lt;/h5&amp;amp;gt;
  &amp;amp;lt;div class=&amp;amp;quot;answer&amp;amp;quot;&amp;amp;gt;
    &amp;amp;lt;p&amp;amp;gt;Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in.  Equitur mutationem consuetudium lectorum mirum est formas humanitatis.&amp;amp;lt;/p&amp;amp;gt;
    &amp;amp;lt;/div&amp;amp;gt;
  &amp;amp;lt;/div&amp;amp;gt;
</pre>

<h3>The CSS</h3>
<p>The styles are essentially unimportant.  You can styles the layout any way you want, but I will give some insight into some of the styles I often choose when creating an FAQ page.</p>
<p>The first thing to note is that I give my h5 a cursor: pointer style.  This creates the hand pointer when the user hovers on the question.  That gives the user a clear indication that something will happen if they click on this question.</p>
<p>You will also see that I have different background images for the h5 depending on whether it has a class of inactive or active.  We will change this class with jQuery when the user clicks the question and the class, along with the background image arrow, will toggle, again creating visual interactivity between the user and the page.</p>
<pre class="brush: css; title: ; notranslate">
#content {width: 960px; margin: 0 auto;}
.FAQWrap h5 {color: #555; margin: 10px 0 0 0; padding: 0 0 0 20px; font-size: 14px; font-weight: normal; cursor: pointer;}
.FAQWrap h5.inactive {background: url(../images/bg-faq-inactive.png) no-repeat 0 3px;}
.FAQWrap h5.active {background: url(../images/bg-faq-active.png) no-repeat 0 3px;}
.FAQWrap .answer {background: #EEE; margin: 10px 10px 20px 30px; padding: 10px;}
</pre>

<h3>The jQuery</h3>
<p>And finally, the most important part, the jQuery.  Remember of course to first link to the jQuery framework.</p>
<p>The first thing we do is hide all answer divs when the page loads.  That creates the nice clean layout we are looking for and puts the control in the hands of the user as which information they want displayed on the page.</p>
<p>Next, we target all h5's within the FAQWrap div and assign a class of inactive.  This, along with our CSS on the h5, will create a background image of an arrow pointing to the right, denoting that the answer is hidden, but can be displayed if you click the question.</p>
<p>The next thing we want to do is run a function when we click on an h5 within FAQWrap.  The first thing we do is use this toggleClass method to switch the class of the actual h5 we clicked.  toggleClass simply toggles the class name on the targeted element.  If it has a class of 'inactive', it will switch the class to 'active', and if it is 'active', it will switch the class to 'inactive'.   So, hopefully you are now beginning to see that each time we click on an h5, we are switching the class name between 'inactive' and 'active', and that, in combination with our CSS, is what is changing our background image arrow on the h5.</p>
<p>The last thing we do, which is most important, is slideToggle the answer div.  The way we do that is first find the parent of 'this' (the h5 we are clicking on), then we are finding the div with a class of answer within that parent element, and slideToggling it.  This means that if the answer is showing, it will slideUp and and be hidden, and if it is hidden, it will slideDown and show.</p>
<pre class="brush: jscript; title: ; notranslate">
$(function() {
      $('.answer').hide();
      $('.FAQWrap h5').addClass('inactive');
      $('.FAQWrap h5').click(function() {
        $(this).toggleClass('active');
        $(this).toggleClass('inactive');
        $(this).parent().find('.answer').slideToggle();        
      });
    });
</pre>

<h3>The Demo</h3>
<p>And so when you put all of that together, you get a nice, clean, easy to use FAQ page that any user will enjoy using!</p>
<style type="text/css" media="screen">
.FAQWrap h5 {color: #555; margin: 10px 0 0 0; padding: 0 0 0 20px; font-size: 14px; font-weight: normal; cursor: pointer;}
.FAQWrap h5.inactive {background: url(/wp-content/themes/simplebeginnings/images/bg-faq-inactive.png) no-repeat 0 3px;}
.FAQWrap h5.active {background: url(/wp-content/themes/simplebeginnings/images/bg-faq-active.png) no-repeat 0 3px;}
.FAQWrap .answer {background: #EEE; margin: 10px 10px 20px 30px; padding: 10px;}
</style>
<script type="text/javascript" charset="utf-8">
    $(function() {
      $('.answer').hide();
      $('.FAQWrap h5').addClass('inactive');
      $('.FAQWrap h5').click(function() {
        $(this).toggleClass('active');
        $(this).toggleClass('inactive');
        $(this).parent().find('.answer').slideToggle();        
      });
    });
  </script>
<div class="FAQWrap">
      <h5>This is my question?</h5>
      <div class="answer">
        <p>Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in. Sequitur mutationem consuetudium lectorum mirum est formas humanitatis.</p>
      </div>
    </div>
    <div class="FAQWrap">
      <h5>This is my question?</h5>
      <div class="answer">
        <p>Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in. Sequitur mutationem consuetudium lectorum mirum est formas humanitatis.</p>
      </div>
    </div>
    <div class="FAQWrap">
      <h5>This is my question?</h5>
      <div class="answer">
        <p>Notare quam littera gothica quam, nunc putamus parum claram anteposuerit litterarum. Et quinta decima eodem modo typi qui nunc. Per seacula quarta decima nobis videntur parum clari: fiant sollemnes in. Sequitur mutationem consuetudium lectorum mirum est formas humanitatis.</p>
      </div>
    </div>

<p class="source"><a href="/sourcefiles/FAQExample.zip">Download the source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://callmegoon.com/create-a-fun-clean-easy-to-use-faq-list/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple jQuery Image Fade Slideshow</title>
		<link>http://callmegoon.com/jquery-image-fader/</link>
		<comments>http://callmegoon.com/jquery-image-fader/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 05:10:06 +0000</pubDate>
		<dc:creator>Goon</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://callmegoon.com/?p=855</guid>
		<description><![CDATA[This tutorial demonstrates how to create a simple image fade slideshow using jquery. We will use a plugin called the jQuery Cycle Plugin to make achieving this effect easier. "The plugin provides a method called cycle which is invoked on a container element. Each child element of the container becomes a "slide". Options control how [...]]]></description>
			<content:encoded><![CDATA[<img class="alignleft size-full wp-image-856" title="jQuery Image Fader" src="http://callmegoon.com/wp-content/uploads/2009/09/jquery.jpg" alt="jQuery Image Fader" width="143" height="125" />

This tutorial demonstrates how to create a simple image fade slideshow using jquery.  We will use a plugin called the <a class="newwindow" href="http://malsup.com/jquery/cycle/">jQuery Cycle Plugin</a> to make achieving this effect easier.  "The plugin provides a method called cycle which is invoked on a container element. Each child element of the container becomes a "slide". Options control how and when the slides are transitioned."

There are numerous transitions besides just fade that can easily be implemented as well, including zoom, shuffle, turn down, etc.  It is actually quite simple to implement, just follow the steps below and you'll quickly be on your way.  You can also download the <a href="/sourcefiles/Image_Fader.zip">source files</a> as a quick an easy to dig into the code.
<h3>Demo:</h3>
<script src="http://callmegoon.com/wp-content/themes/simplebeginnings/js/imageCycle.js"></script>
 <script type="text/javascript">// <![CDATA[
$(function() {
if (!$('.pics').length > 0) return false;
$('.pics').cycle('fade');
});
// ]]&gt;</script>

<!-- .picsWrap {background: #eee; width: 230px; border: 1px solid #ddd;} img {border-bottom: 1px solid #fff;} .picsWrap p {padding: 10px; margin: 0;} -->
<div class="pics"><img src="/wp-content/themes/simplebeginnings/images/imagefader/1.png" alt="" width="205" height="147" />
<img src="/wp-content/themes/simplebeginnings/images/imagefader/2.jpg" alt="" width="205" height="147" />
<img src="/wp-content/themes/simplebeginnings/images/imagefader/3.jpg" alt="" width="205" height="147" />
<img src="/wp-content/themes/simplebeginnings/images/imagefader/4.jpg" alt="" width="205" height="147" /></div>
<!--end .pics-->
<h3>Code:</h3>
First, download the jquery framework.  You can grab that <a class="newwindow" href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.1.min.js">here</a>.  Next, head over to the <a class="newwindow" href="http://malsup.com/jquery/cycle/">jQuery Cycle Plugin</a> page and download the image cycle javascript file.  Or you can download it directly <a class="newwindow" href="http://malsup.com/jquery/cycle/jquery.cycle.all.min.js?v2.71">here</a>.  You may have to copy the code from this page and save into a file, I called mine imageCycle.js.

Next, create a new file called index.html.  Within index.html, you need to call a couple javascript files, both jquery.js and the imageCycle.js we just downloaded.  We also need to create a function to initiate the cycle plugin on a specific html element.

<pre class="brush: jscript; title: ; notranslate">
&lt;script src=&quot;/js/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;/js/imageCycle.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function() {
if (!$('.pics').length &gt; 0) return false;
$('.pics').cycle('fade');
});
&lt;/script&gt;
</pre>

For the HTML, I will create a div with a class of 'pics'.  Within that div are simple img elements.  The class of pics on our div is the trigger from our jquery function that creates that image rotation on all the img elements within our div.

<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;pics&quot;&gt;
  	&lt;img src=&quot;images/1.png&quot; width=&quot;205&quot; height=&quot;147&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;
  	&lt;img src=&quot;images/2.jpg&quot; width=&quot;205&quot; height=&quot;147&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;
  	&lt;img src=&quot;images/3.jpg&quot; width=&quot;205&quot; height=&quot;147&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;
  	&lt;img src=&quot;images/4.jpg&quot; width=&quot;205&quot; height=&quot;147&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;
  &lt;/div&gt;&lt;!--end .pics--&gt;
</pre>

It's really as simple as that.
<ol>
	<li>link to the jquery framework</li>
	<li>link to the image cycle jquery plugin</li>
	<li>create a function that links to a specific class to trigger the rotation (just copy the exact function I have included)</li>
	<li>create a div with a class of 'pics' (or whatever trigger you chose to use in your function.  If you just copied mine, it will be 'pics').</li>
	<li>include the images with your div that you would like to fade in and out</li>
</ol>
You can always add your own custom styles to spice things up a bit if necessary, but I tried to keep this as simple as possible.  Be sure to head over the <a class="newwindow" href="http://malsup.com/jquery/cycle/">jQuery Cycle Plugin</a> page for even more features and image fade possibilities.
<p class="source"><a href="/sourcefiles/Image_Fader.zip">Download Source</a></p>]]></content:encoded>
			<wfw:commentRss>http://callmegoon.com/jquery-image-fader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

