<?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>Fuel Your Coding &#187; Javascript</title>
	<atom:link href="http://fuelyourcoding.com/category/languages/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://fuelyourcoding.com</link>
	<description></description>
	<lastBuildDate>Mon, 09 Aug 2010 14:40:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Open-Source Spotlight: Underscore.js</title>
		<link>http://fuelyourcoding.com/open-source-spotlight-underscorejs/</link>
		<comments>http://fuelyourcoding.com/open-source-spotlight-underscorejs/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 16:20:36 +0000</pubDate>
		<dc:creator>Jerod Santo</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=856</guid>
		<description><![CDATA[JavaScript is a powerful language, but it lacks some of the handy utilities that developers of other languages like Ruby &#38; Python have come to know and love. Underscore.js is your utility belt. In the author&#8217;s own words:
Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/open-source-spotlight-underscorejs/">Open-Source Spotlight: Underscore.js</a></p>
]]></description>
			<content:encoded><![CDATA[<p>JavaScript is a powerful language, but it lacks some of the handy utilities that developers of other languages like Ruby &amp; Python have come to know and love. <a href="http://documentcloud.github.com/underscore/">Underscore.js</a> is your utility belt. In the author&#8217;s own words:</p>
<blockquote><p>Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. It&#8217;s the tie to go along with jQuery&#8217;s tux.</p></blockquote>
<p><a href="http://documentcloud.github.com/underscore/">Underscore.js</a> provides collection functions like <tt>each</tt>, <tt>map</tt>, <tt>include</tt>, and <tt>reduce</tt>. It makes arrays more powerful by adding <tt>flatten</tt>, <tt>uniq</tt>, and <tt>intersect</tt>. It extends objects with many useful functions like <tt>keys</tt>, <tt>values</tt>, <tt>functions</tt>, <tt>isNaN</tt>, and many more.</p>
<p>A few examples to whet your appetite:</p>
<p>Using the <tt>each</tt> function to write each array value to the console:</p>
<pre class="brush: jscript;">
// object-oriented way
_(['John', 'Paul', 'George', 'Ringo']).each(function(beatle) {
    console.log(beatle);
});
// functional way
_.each(['John', 'Paul', 'George', 'Ringo'], function(beatle) {
    console.log(beatle);
});
</pre>
<p>Using the <tt>reduce</tt> method to round three numbers down and sum the results:</p>
<pre class="brush: jscript;">
_.reduce([1.5,2,3.7], 0, function(memo, num) { return memo + Math.floor(num) });
// =&gt; 6
</pre>
<p>Using the <tt>pluck</tt> method to to extract just the names from an array of objects:</p>
<pre class="brush: jscript;">
var beatles = [
  {name: 'John', dead: true},
  {name: 'Paul', dead: false},
  {name: 'Ringo', dead: false},
  {name: 'George', dead: true}
]

_.pluck(beatles, 'name');
// =&gt; [&quot;John&quot;, &quot;Paul&quot;, &quot;Ringo&quot;, &quot;George&quot;]
</pre>
<p>The library weighs in at just <strong>2.5kb</strong> once packed and gzipped, so there is little excuse not to take advantage of its offerings. There are over 60 functions included, the documentation on how to use each function is great, the source code is freely available <a href="http://github.com/documentcloud/underscore/">on GitHub</a>, and the library is completely DOM-free which means you can use it server-side as well.</p>
<p>Thanks to <a href="http://github.com/jashkenas">Jeremy Ashkenas</a> and the folks at <a href="http://www.documentcloud.org/home">DocumentCloud</a> for a great open-source library that we can all benefit from!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/open-source-spotlight-underscorejs/">Open-Source Spotlight: Underscore.js</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/open-source-spotlight-underscorejs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Plugin Design Patterns: Part I</title>
		<link>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/</link>
		<comments>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 18:21:06 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Plugins / Add-Ons]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798</guid>
		<description><![CDATA[jQuery plugins come in all shapes and sizes. They perform very simple or very complex tasks depending on their intended use. When it comes time for you to design your own plugin, its really important to understand what patterns other developers use and what will best suits your needs.
As a side note, I have built [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/">jQuery Plugin Design Patterns: Part I</a></p>
]]></description>
			<content:encoded><![CDATA[<p>jQuery plugins come in all shapes and sizes. They perform very simple or very complex tasks depending on their intended use. When it comes time for you to design your own plugin, its really important to understand what patterns other developers use and what will best suits your needs.</p>
<p>As a side note, I have built a number of plugins for my own projects and client work that will <em>never be released</em>. The jQuery community needs to stop thinking of plugins only as releasable, open-source projects, and start thinking of them instead as a reusable pieces of code that can help optimize and <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a> up a complex website. Take this little plugin as an example:</p>
<pre class="brush: jscript;">
$.fn.notice = function(){
    return this.slideDown(500).delay(4000).slideUp(500);
}
</pre>
<p>It simply abstracts the animation for displaying a notice (using jQuery 1.4). Would I ever release this on an open source site? Of course not! But it is still a fully functioning jQuery plugin that can be used over and over throughout a website.</p>
<h2>Design Pattern Series Overview</h2>
<ul>
<li>Basics &amp; Structure (this article)</li>
<li>Options &amp; Updating</li>
<li>Callbacks &amp; Custom Events</li>
<li>Misc. General Practices</li>
</ul>
<h2>Basics</h2>
<h3>Filename</h3>
<p>Every jQuery plugin sits in its own JS file, and is normally named using the following pattern:</p>
<pre class="brush: plain;">
jquery.pluginname.js
jquery.pluginname.min.js
</pre>
<p>Released plugins often also have a version number:</p>
<pre class="brush: plain;">
jquery.pluginname-1.3.js
jquery.pluginname-1.3.min.js
</pre>
<p>If you end up building a lot of plugins for your website, consider also including a namespace to keep all your files together (And of course you would combine and minify them for production, right?):</p>
<pre class="brush: plain;">
jquery.mysite.pluginname.js
jquery.mysite.pluginname.js
</pre>
<h3>Basic File Layout</h3>
<p>After any comments you choose to put at the top of your file, the very next thing you should have is a self executing anonymous function that will actually wrap your entire plugin. Say what!? Don&#8217;t worry, you have seen it before, and it looks like this:</p>
<pre class="brush: jscript;">
(function($){

   ... code here ...

})(jQuery);
</pre>
<p>This gives your plugin a private scope to work in, and also allows your plugin to be used with <code>$.noConflict</code> mode without creating a problem. By passing <tt>jQuery</tt> into the function, the <tt>$</tt> will equal jQuery <em>inside</em> the function even if <code>$</code> means something different outside your plugin.</p>
<h2>Structure</h2>
<p>There are three basic structures you will see when you look at released plugins:</p>
<h3>Contained Function</h3>
<p>In this structure, (almost) all the code to run your plugin is contained within the function used to call your plugin. This is the most common format:</p>
<pre class="brush: jscript;">
(function($){

   $.fn.myPlugin = function(){
      return this.each(function(){
         // do something
      });
   }

})(jQuery);
</pre>
<p>You <strong>should</strong> use this this structure when you are writing a simple plugin that acts once upon the jQuery result set on each execution. For complex plugins that need to maintain an adjustable state, you should consider the &#8220;Class and Function&#8221; structure.</p>
<h3>Class and Function</h3>
<p>In this structure, a class is used and an instance is created for each DOM element in the result set. You may see these objects attached in some way to the DOM elements they modify:</p>
<pre class="brush: jscript;">
(function($){
   var MyClass = function(el){
       var $el = $(el);

       // Attach the instance of this object
       // to the jQuery wrapped DOM node
       $el.data('MyClass', this);
   }

   $.fn.myPlugin = function(){
      return this.each(function(){
         (new MyClass(this));
      });
   }

})(jQuery);
</pre>
<p>You <strong>should</strong> use this structure if you need to be able to access the object later that is associated with a DOM element. It is far easier to attach a single object vs several key/value pairs using the <tt>data()</tt> method. In this approach, you can access the object by calling <tt>$('selector').data('MyClass')</tt>. This functions more like a widget and is a plugin that maintains state and can adjust its state on the fly (Learn how in the next article.).</p>
<p><em><strong>Note: </strong> Widget Factory: The next release of jQuery UI is going to see the addition of a Widget Factory that will be designed to specially assist in developing widget-like plugins. </em></p>
<h3>Extend</h3>
<p>In my opinion, this is the least idiomatic way to create a jQuery plugin. It uses the <tt>jQuery.fn.extend</tt> method instead of <tt>jQuery.fn.pluginName</tt>:</p>
<pre class="brush: jscript;">
(function($){

   $.fn.extend({
     myPlugin: function(){
      return this.each(function(){
         // do something
     },
     myOtherPlugin: function(){
      return this.each(function(){
         // do something
     }
   });

})(jQuery);
</pre>
<p>You will find this structure helpful if you need to add a <em>large number</em> of plugin methods to jQuery. I would contend, however, that if your plugin needs to add that many methods, there may be a better way to structure its implementation.</p>
<p>I feel the extend method is used more by programmers transitioning from other JS libraries. I personally find the simple <tt>$.fn.pluginName =</tt> structure to be easier to read, and more in line with what you will normally see in jQuery plugins.</p>
<h2>Up Next</h2>
<p>In the next part of this series, we will look at passing options and providing methods for updating settings and functionality after a plugin has been called.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/">jQuery Plugin Design Patterns: Part I</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>jQuery Enlightenment: Book Review and Giveaway (Winners Announced!)</title>
		<link>http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/</link>
		<comments>http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 20:04:58 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Books / Magazines]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=782</guid>
		<description><![CDATA[Winners Announced
I was really happy to see so much participation in this giveaway! After seeing how many people entered, I was feeling really bad that only one of them would leave with a copy of the book. I talked to Cody, and he graciously provided two more free copies so we can award a total [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/">jQuery Enlightenment: Book Review and Giveaway (Winners Announced!)</a></p>
]]></description>
			<content:encoded><![CDATA[<h2>Winners Announced</h2>
<p>I was really happy to see so much participation in this giveaway! After seeing how many people entered, I was feeling really bad that only one of them would leave with a copy of the book. I talked to Cody, and he graciously provided two more free copies so we can award a total of three books! I randomly picked three winners (using <a href="http://random.org">Random.org</a>) and am happy to announce the following winners:</p>
<ul>
<li>Brad Rhine (<a href="http://truetech.org">truetech.org</a>)</li>
<li>Mila</li>
<li>Geoff Woodburn (<a href="http://woodburndesigns.com">woodburndesigns.com</a>)</li>
</ul>
<h2>Book Review</h2>
<p>Late in 2009, <a href="http://www.codylindley.com">Cody Lindley</a> published a PDF book on jQuery titled <a href="http://jqueryenlightenment.com">jQuery Enlightenment</a>. Today we are presenting our view of the book as well as offering a free copy to one lucky reader.</p>
<p><img class="alignnone size-full wp-image-792" title="jqueryen" src="http://fuelyourcoding.com/files/jqueryen.jpg" alt="jqueryen" width="600" height="300" /></p>
<h2>About The Author</h2>
<p>Cody Lindley is a core team member of the <a href="http://jquery.com">jQuery</a> project, and the original developer of the well known Thickbox plugin for jQuery. I had the pleasure of meeting and listening to Cody present at the jQuery Conference last year in Boston. He describes himself on his website:</p>
<blockquote><p>Today I am a Christian, husband, son, brother, professional Web developer, and outdoor enthusiast. I spend a majority of my time sleeping and working, but who doesn’t? In between the daily routines of the average American, I desire an existence that entails a relationship with God, my family, and nature. I would like to consider myself a bookworm (a novice theologian at best), but truth be told, I simply enjoy watching movies and playing xBox way too much. I guess I also have the luxury of pursuing my profession as a personal passion. Yes, I often work even when I am not at work.</p></blockquote>
<h2>Overview</h2>
<p>jQuery Enlightenment is a different type of book than I am used to seeing in the tech field. A list of what it is <em>not</em> might help shed light on what I mean. It is not documentation, a tutorial/walkthrough, or just conceptual material. jQuery Enlightenment is an amazingly clear montage of principals and code samples every jQuery developer needs to know grouped by topic. Cody covered topics both basic and profound throughout the pages of the book.</p>
<p>I consider myself quite adept at using jQuery, but found myself constantly amazed at the things I was learning while reading this book.  Cody says it picks up where the jQuery documentation leaves off. I can see his point, but I think this book would be a better starting place for a new jQuery developer than even reading through the jQuery API site.</p>
<h2>Pros</h2>
<h3>Code Samples</h3>
<p><img class="alignnone size-full wp-image-783" title="code" src="http://fuelyourcoding.com/files/code.jpg" alt="code" width="568" height="104" /></p>
<p>Code samples make up over 70% of the book (rough estimation). The book is not written in an editorial way at all. It is about presenting what you need to know, demonstrating it with an example, and moving on. For this reason the book is an extremely fast read and perfect for reference on a day to day basis.</p>
<p>Possibly one of the neatest features of the book itself is that (almost) every code sample provided in the book has a link to the same code on JSBin.com. JSBin is an online playground for testing and demonstrating JavaScript, HTML, and CSS technologies. jQuery Enlightenment isn&#8217;t a flat reading experience, it allows you to immediately jump in and play with the code samples until everything makes sense.</p>
<h3>Additional Notes</h3>
<p><img class="alignnone size-full wp-image-784" title="notes" src="http://fuelyourcoding.com/files/notes.jpg" alt="notes" width="568" height="104" /></p>
<p>Many of the topics are followed by a little box titled &#8216;Notes&#8217;. I am glad Cody didn&#8217;t choose some cheesy title for these boxes, but &#8216;Notes&#8217; really does not sum up what they provide. You will find many undocumented (or hard to find) tips and tricks about the finer points of jQuery in these boxes. Skip over them at your own peril!</p>
<h3>No Fluff Quality</h3>
<p>Cody doesn&#8217;t waste any time on any of the topics presented in the book. The pattern used is simple: explain, demonstrate, move on. I personally will be using this book not just for reference, but for a quick read-through every few weeks to keep my jQuery senses sharp.</p>
<h2>Cons</h2>
<p>You will be hard pressed to find something negative to say about this book, and it wasn&#8217;t until I reached the end that I had one complaint about the content. The chapter on Ajax (Chapter 11) was far too short. Perhaps this is because the documentation is very clear, but I still wanted to learn more and have more examples to glean from. Perhaps the second edition of the book (which will cover jQuery 1.4) will provide more detail on jQuery&#8217;s AJAX implementation and associated methods.</p>
<h2>Conclusion</h2>
<p>I am confident new users and seasoned users alike will find much to learn in jQuery Enlightenment. After reading the book, my only concern is that I won&#8217;t remember all of the cool things I learned while reading it!</p>
<h2>Win a FREE Copy!</h2>
<p>Next Wednesday we will be selecting a winner to receive a free copy of jQuery Enlightenment. Entering the competition is easy!</p>
<p>Head over to <a href="http://jqueryenlightenment.com">jQuery Enlightenment</a> and quickly look through table of contents. Then, leave a comment below telling us what chapter you think you would learn the most from if you were to win the book. Only comments referencing one of the actual chapters in the book will be eligible to win. <strike>We will randomly select a winner next Wednesday and announce it here on the site.</strike>. <strong>Sorry, but the contest is over!</strong></p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/">jQuery Enlightenment: Book Review and Giveaway (Winners Announced!)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>JavaScript Can Learn: Now Teach It Tricks!</title>
		<link>http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/</link>
		<comments>http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 07:00:34 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[extending]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=672</guid>
		<description><![CDATA[When you do a lot of development with backend technologies, it can be frustrating to then move to the front end and feel like you are using a completely different syntax. One thing I really miss is the helper methods, especially when using Ruby on Rails on the server. Little helpers like titleize() or downcase() [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/">JavaScript Can Learn: Now Teach It Tricks!</a></p>
]]></description>
			<content:encoded><![CDATA[<p>When you do a lot of development with backend technologies, it can be frustrating to then move to the front end and feel like you are using a completely different syntax. One thing I really miss is the helper methods, especially when using Ruby on Rails on the server. Little helpers like <tt>titleize()</tt> or <tt>downcase()</tt> get replaced in javascript by a custom function and <tt>toLowerCase()</tt> respectively. You don&#8217;t have to feel lost anymore! There is a way you can extend the native objects found in JavaScript to make your environment feel a little more like &#8220;home.&#8221;</p>
<p>This is accomplished by using the prototype object. Each native object in JavaScript includes a prototype object. Don&#8217;t get this confused with the PrototypeJS framework&#8230; the prototype object is a way to extend <em>all</em> objects that have inherited from the base object you extended. You can easily extend the prototype object by adding functions to it like this:</p>
<pre class="brush: jscript;">
Object.prototype.functionName = function(){

}
</pre>
<p>You can then call them directly:</p>
<pre class="brush: jscript;">
var obj = new Object();
obj.functionName();
</pre>
<p>There are a number of advanced uses of the prototype object, but this is the important thing to remember: any function added to the prototype of an object is available on any object that inherits from it. So if you extend the prototype on the Number object, all numbers will have access to the new function; if you extend the Array object, all arrays can access your custom function. You only use the <tt>prototype.functionName</tt> syntax when declaring the new function, not when calling it.</p>
<p>Enough theory, lets see some (somewhat) practical uses:</p>
<p>Do you find yourself capitalizing a lot of words in a particular JavaScript app? Just add a <tt>capitalize</tt> method to the String object.</p>
<pre class="brush: jscript;">
String.prototype.capitalize = function(){
  if(this.length == 0) return this;
  return this[0].toUpperCase() + this.substr(1);
}
</pre>
<p>Now you can capitalize any string in your application by calling <tt>"lower".capitalize()</tt> and get <tt>"Lower"</tt> in return. Since it returns a string, you could chain it with any other function you can execute on a string.</p>
<p>Do you always find yourself forgetting you can call Number(&#8221;25&#8243;) to turn a string into a number? Just add a <tt>toNumber()</tt> function to the String prototype:</p>
<pre class="brush: jscript;">
String.prototype.toNumber = function(){
  return Number(this);
}

If you need to split large JSON arrays into groups of two or three each, you could extend the Array object like this:

[js]
Array.prototype.inGroupsOf = function(num){
	var ret = [],
		length = this.length,
		groups = Math.ceil(length / num);

	for(var i = 0; i &lt; groups; i++){
		var start = i * num,
			end   = start + num;

		ret.push(this.slice(start, end))
	}
	return ret;
}
</pre>
<p>Now calling <tt>inGroupsOf(3)</tt> on any Array would return that same array split into as many parts as needed to ensure no group has more than three items in it.</p>
<p>There are a number of objects you can extend, but the ones you will use the most are <tt>String</tt>, <tt>Array</tt>, <tt>Object</tt>, <tt>Number</tt>, <tt>Date</tt>. One trouble area you might face is calling methods on numbers. The following example will fail:</p>
<pre class="brush: jscript;">
Number.prototype.to_s = function(){
  return this + &quot;&quot;;
}

25.to_s();
</pre>
<p>The prototype function is correct, but the way we called it is wrong. There are two ways to call our custom functions on numbers:</p>
<pre class="brush: jscript;">
var n = 25;
n.to_s(); // Returns &quot;25&quot;

(25).to_s(); // Also returns &quot;25&quot;
</pre>
<h2>Think Start, Not End</h2>
<p>Its important when deciding what object to extend that you focus on what object type you are starting with, not so much which type you plan on ending with. For instance, if you wanted to extend an object to easily parse Twitter date strings you would not extend the <tt>Date</tt> object. You would extend the <tt>String</tt> object, and your function would return a <tt>Date</tt> object.</p>
<h2>Load Your Extensions First</h2>
<p>It is normally a good idea to load these extensions prior to any other library, including jQuery. Anytime you extend the prototype object, the new method is instantly available to all objects of the same type or any object that has inherited from that type. However, since you want to be sure your methods are always available, you guarantee their availability by loading them first.</p>
<h2>How to Group The Extensions</h2>
<p>Naming your files <tt>Prototype.Date.js</tt> and <tt>Prototype.Array.js</tt> is an easy way to keep all your extensions in one part of your JS folder, and easy to access during development. If you follow this method, you would simply put Date.prototype methods in the <tt>Prototype.Date.js</tt> file, etc. This starts to break down when you have parallel functions. You might have a <tt>toDateFromTwitter()</tt> method on the String object and a <tt>toTwitterFromDate()</tt> method on the Date object. Putting these in separate files might not make sense. At that point, you should put both these extensions in a file named TwitterHelpers.js or something similar. Obviously use what makes sense to you and works with your flow.</p>
<h2>Don&#8217;t Bloat</h2>
<p>Just because you write 500+ awesome Array extensions in the next 2 years, does not mean you need to include them on every project. Be sure to only use this technique when it makes sense for the project and when it helps clean up your code.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/">JavaScript Can Learn: Now Teach It Tricks!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery Custom Events: They Will Rock Your World!</title>
		<link>http://fuelyourcoding.com/jquery-custom-events-they-will-rock-your-world/</link>
		<comments>http://fuelyourcoding.com/jquery-custom-events-they-will-rock-your-world/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 00:12:50 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=418</guid>
		<description><![CDATA[Ok, maybe they won&#8217;t exactly “Rock Your World” but they might completely change the way you look at your jQuery development. At the very least, I hope this simple technique will help you build clean, reusable and extendable front-end code.

A Quick &#8216;n&#8217; Dirty Overview
If you are the “just the facts” type of person, here is [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-custom-events-they-will-rock-your-world/">jQuery Custom Events: They Will Rock Your World!</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Ok, maybe they won&#8217;t exactly “Rock Your World” but they might completely change the way you look at your jQuery development. At the very least, I hope this simple technique will help you build clean, reusable and extendable front-end code.</p>
<div class="post_buttons"><a href="http://fuelyourcoding.com/files/jqueryeventssource.zip"><img class="size-full wp-image-24 alignnone" title="Download zipped archive" src="http://fuelyourcoding.com/files/download-button.gif" alt="Download zipped archive" width="229" height="68" style="margin-left: 30px" /></a><a href="http://fuelyourcoding.com/samples/jquery_custom_events/"><img class="size-full wp-image-25 alignnone" title="View the example" src="http://fuelyourcoding.com/files/example-button.gif" alt="View the example" width="229" height="68"  style="margin-left: 30px" /></a></div>
<h2>A Quick &#8216;n&#8217; Dirty Overview</h2>
<p>If you are the “just the facts” type of person, here is the 20 second overview. You can trigger custom events on any DOM object of your choosing using jQuery. Just trigger it using the following code:</p>
<pre class="brush: jscript;">
$(&quot;#myelement&quot;).trigger('fuelified');
</pre>
<p>You can subscribe to that event using either <tt>bind</tt> or <tt>live</tt> functions in jQuery:</p>
<pre class="brush: jscript;">
$(&quot;#myelement&quot;).bind('fuelified',function(e){ ... });
$(&quot;.cool_elements&quot;).live('fuelified',function(e){ ... });
</pre>
<p>You can even pass additional data about the event when triggering it and reference it on the listeners end:</p>
<pre class="brush: jscript;">
$(&quot;#myelement&quot;).trigger('fuelified',{ custom: false });
$(&quot;#myelement&quot;).bind('fuelified',function(e,data){ if(data.custom) ... });
</pre>
<p>The element the trigger has been called on, is available to listener&#8217;s callback function as the variable this.</p>
<h2>A Little Philosophy</h2>
<p>I encourage you to view your front end code in parts and pieces instead of one huge piece of front-end code. If you look at each part separately, you can build better, reusable pieces of code. You won&#8217; t have a lot of duplicated code in your web-site, and you will be able to extend what you have built later on. A rating site might have widgets that are used to take in the ratings. You may have another widget that monitors the rating widgets and tallies the scores. Making the pieces as independent as possible makes reuse and extension a breeze.</p>
<h2>A Fun Example</h2>
<p>For those who like tutorials or walkthroughs, this should be a fun demonstration of the power of jQuery custom events.</p>
<h3>Preparation</h3>
<p>To get started, <a href="http://fuelyourcoding.com/files/blankwebsitetemplate.zip">download my blank website template</a>. Then head over to <a href="http://starter.pixelgraphics.us" target="_blank">Starter for jQuery</a> and create two jQuery plugins using the following settings:</p>
<ol>
<li>Class Name: <strong>ColorBlock<br />
<span style="font-weight: normal;">Include: </span>Options, Getter </strong>(Not Comments)</li>
<li>Class Name: <strong>ColorObserver<br />
<span style="font-weight: normal;">Include: </span>Options, Getter <span style="font-weight: normal;">(Not Comments)<br />
Default Options: <strong>colorObjs|div.color_block</strong><strong> </strong></span></strong></li>
</ol>
<p>After you enter each item, click <strong>Create</strong> then <strong>Download</strong>. Save each file to the <strong>js/</strong> directory of our Blank Website Template. Then add &lt;script&gt; tags linking both files into the index.html file. Finally, put a blank jQuery document.ready block into the head, just below the scripts. When you are finished, the scripts in &lt;head&gt; area should look like this:</p>
<pre class="brush: xml;">
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/jquery.colorblock.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/jquery.colorobserver.js&quot; type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
 	$(document).ready(function(){

  	});
 &lt;/script&gt;
</pre>
<h3>HTML</h3>
<p>Copy and paste the following HTML markup into the &lt;body&gt; tag of the <strong>index.html</strong> file:</p>
<pre class="brush: xml;">
&lt;div id=&quot;color_blocks&quot;&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
  	&lt;div class=&quot;color_block&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;div id=&quot;observer-one&quot; class=&quot;observer&quot;&gt; &lt;/div&gt;
&lt;div id=&quot;observer-two&quot; class=&quot;observer&quot;&gt; &lt;/div&gt;
</pre>
<p>Normally I might delegate the creation of the div.color_block elements to a script as well, but that is not the point of this exercise!</p>
<h3>CSS</h3>
<p>Copy and paste the following CSS into the layout.css file. Basically it sets simple styling for our elements. The important part is that it sets a width and height of 50px for our .color_block elements, and floats them to the left. If you were to load <strong>index.html</strong> in a browser right now, you wouldn&#8217;t see too much.</p>
<pre>
<pre class="brush: css;">
.color_block {
	width: 50px;
	height: 50px;
	cursor: pointer;
	float: left;
	margin: 0 5px 5px 0;
}

.observer {
	clear: left;
	margin: 10px 0;
	padding: 10px;
	float: left;
	background: #eee;
	font-family: Helvetica, Arial;
}

#observer-one { border-top: solid 2px red; }
#observer-two { border-top: solid 2px blue; }</pre>
</pre>
<h3>JS</h3>
<p>The plugins you created using Starter for jQuery have added two new functions to our jQuery objects. We are going to call both of them in our &lt;head&gt; script area. Paste the following code between the opening and closing braces of the <tt>document.ready</tt> function:</p>
<pre>
<pre class="brush: jscript;">
$(&quot;.color_block&quot;).colorBlock();
$(&quot;#observer-one&quot;).colorObserver();
</pre>
</pre>
<p>The first line calls our <tt>colorBlock</tt> plugin on all the blocks. The second, calls our <tt>colorObserver</tt> method on one of our observer divs. If you load the page now, you should not get any errors, but nothing should do anything yet either.</p>
<h3>ColorBlock</h3>
<p>We want to give our ColorBlocks an array of colors. They will all start on color 1 (index position 0) and every time you click on them, they will change to the next color. To do this, we will add code to our <tt>jquery.colorblock.js</tt> file.</p>
<p><strong>Note: Most of you are probably not familiar with Starter for jQuery, or the code it puts out. I plan on writing an article about it sometime, but for this article remember these important principles. Anywhere in the plugin class itself ($.ColorBlock for example) <tt>base</tt> refers to base object. And <tt>base.el</tt> and <tt>base.$el</tt> refer to the DOM element and the jQuery wrapped DOM element the base object is connected to.</strong></p>
<p>The plugin supports override-able options. We need to use this for our plugin, so find the <tt>$.ColorBlock.defaultOptions</tt> and paste this between the curly braces:</p>
<pre>
<pre class="brush: jscript;">colors: [&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;,&quot;yellow&quot;]</pre>
</pre>
<p>Now, we need to give our object the ability to change colors. Paste the following code after the <tt>base.init</tt> function definition (but before the base.init() call. That should always come last in the plugin) :</p>
<pre>
<pre class="brush: jscript;">
base.setColor = function(new_color_index){
	if( new_color_index != base.current_color_index ){
		base.current_color_index = new_color_index;
		base.$el.css({backgroundColor: base.options.colors[base.current_color_index]});
	}
}

base.nextColor = function(){
	var new_color_index = base.current_color_index + 1;
	if ( new_color_index &gt; ( base.options.colors.length - 1 ) )
		new_color_index = 0;
	base.setColor( new_color_index );
}

base.getColor = function(){
	return base.options.colors[base.current_color_index];
}
</pre>
</pre>
<p>This gives our object three methods. A method to set the color using an arbitrary index. A method to trigger the next color in the cycle. And finally a way to retrieve which color is currently in use. Nothing so far is rocket science.</p>
<p>Finally to enable our little widget, we add two lines of code to the base.init function after the line that initializes the options.</p>
<pre>
<pre class="brush: jscript;">
base.$el.click(function(){ base.nextColor(); });
base.setColor(0);</pre>
</pre>
<p>The first line triggers base.nextColor() every time our object is clicked. And the second line just initializes our object using the first color in the array (index position 0).</p>
<p>Now, if we load index.html in our browser, you will be able to cycle through the colors on each block simply by clicking on them.</p>
<p>In our make believe world, we can be happy that we made a working jQuery plugin. YAY! However, bad news also occurs in our world, and our client requests a way to monitor which colors are currently showing. So, along comes our ColorObserver widget. </p>
<p>Already we are making educational progress, because we realize the functionality to monitor all color_blocks is <strong>not</strong> the function of the ColorBlock widget (You <strong>do</strong> realize that right?).</p>
<h3>ColorObserver</h3>
<p>Our observer needs a method to find all ColorBlocks and find out which colors are showing. The following code should do the trick. Paste the following code into the <tt>jquery.colorobserver.js</tt> file, after the <tt>base.init</tt> definition, but before the <tt>base.init();</tt> call.</p>
<pre>
<pre class="brush: jscript;">
base.discoverColors = function(){
	var colors_count = {};
	$(base.options.colorObjs).each(function(){
		var color = $(this).data('ColorBlock').getColor();

		if(!colors_count[color])
			colors_count[color] = 1;
		else
			colors_count[color] += 1;
	});

	var output = &quot;&quot;;
	$.each(colors_count, function(key,value){
		output += key + &quot;=&quot; + value + &quot;&lt;br /&gt;&quot;;
	})
	base.$el.html(output);
}</pre>
</pre>
<p>In a nutshell, this code uses the selector from our <tt>defaultOptions</tt> or an overridden option to find which objects are ColorBlocks. It then gets the color, and either adds it to the <tt>colors_count</tt> array, or increases its count by one if it already exists. It then puts together a HTML snippet, and updates its <tt>base.$el</tt> content with our snippet. (Remember that <tt>base.$el</tt> refers to the jQuery wrapped DOM element we originally tied the widget to. In this case, <tt>#observer-one</tt>)</p>
<h2>The Most Important Part</h2>
<p>Now we need to tie to two objects together. You might be tempted to hardwire some <tt>$("#observer-one").getColorObserver().discoverColors()</tt> call into your <tt>setColor</tt> function over on the ColorBlocks. It would work for sure, but it makes your code more and more dependent on each other&#8230; making future changes more likely to break your code.</p>
<p>Instead we will use custom events to solve our problem. Put the following line inside the <tt>base.setColor</tt> function on the ColorBlock, inside the <tt>if</tt> statement as the last line:</p>
<pre>
<pre class="brush: jscript;">base.$el.trigger('color_changed');</pre>
</pre>
<p>Now, any time the color changes on a single block, a &#8216;color_changed&#8217; event fires. Now, put the following two lines in the <tt>base.init</tt> function of the ColorObserver class (After the options setup code):</p>
<pre>
<pre class="brush: jscript;">
$(base.options.colorObjs).live('color_changed', function(){ base.discoverColors(); });
base.discoverColors();
</pre>
</pre>
<p>The first line binds to our custom event and tells the ColorObserver class to rediscover the visible colors. The second line is just the initial call to find out the starting state of the colors.</p>
<p>At this point our job is done, and our two widgets are correctly wired together. Load <tt>index.html</tt> up in your browser and see for yourself. Every time you change a block color, the observer knows about it and changes its data to match.</p>
<p>The best part is that you could delete the &lt;script&gt; tag that links the ColorObserver to our document, and remove the line that initializes it, and the ColorBlock&#8217;s would continue to work just fine!</p>
<h2>Even More Coolness</h2>
<p>You might not have even noticed, but even more flexibility was baked into our project. Add the following line to our &lt;head&gt; script block:</p>
<pre>
<pre class="brush: jscript;">$(&quot;#observer-two&quot;).colorObserver({colorObjs:$(&quot;.color_block:lt(3)&quot;)});</pre>
</pre>
<p>Now our second observer only observes the first 3 color blocks. We over-rode the colorObjs default selector with our own.</p>
<h2>Conclusion</h2>
<p>I hope this opens new doors to you when using jQuery for development. Its a great way of compartmentalizing and easily extending your code. If you still have trouble understanding its practicality, consider an advanced jQuery rich internet application. It could trigger events for every major interactions, and you could build a GoogleAnalyticsObserver class to listen for those actions and send them on to Google to track. </p>
<p>Let me know if this helps you out, or how you think you could use Custom jQuery Events.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-custom-events-they-will-rock-your-world/">jQuery Custom Events: They Will Rock Your World!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/jquery-custom-events-they-will-rock-your-world/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Steps to becoming a front-end web developer</title>
		<link>http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/</link>
		<comments>http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/#comments</comments>
		<pubDate>Mon, 18 May 2009 23:40:05 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[xhtml / css]]></category>
		<category><![CDATA[become]]></category>
		<category><![CDATA[becoming]]></category>
		<category><![CDATA[front-end]]></category>
		<category><![CDATA[web developer]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=121</guid>
		<description><![CDATA[There are a few things you have to know in order to be a front-end web developer. Where to start and what to learn. This guide will take you through the steps of becoming a front-end web developer.
First things first
Before we start seeing stuff on the screen, we have to make something out of nothing. [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/">Steps to becoming a front-end web developer</a></p>
]]></description>
			<content:encoded><![CDATA[<p>There are a few things you have to know in order to be a front-end web developer. Where to start and what to learn. This guide will take you through the steps of becoming a front-end web developer.</p>
<h2>First things first</h2>
<p>Before we start seeing stuff on the screen, we have to make something out of nothing. We start at the basics of web developing: <a href="http://en.wikipedia.org/wiki/HTML">HTML</a>. This markup language will draw shapes on the web page and display text.</p>
<p>HTML is not only very important, your whole markup will depend on it. Don&#8217;t touch CSS yet! We&#8217;ll come to that later.<br />
CSS is worthless with a bad markup supporting it.</p>
<h2>1. Learn HTML</h2>
<ol>
<li><a href="http://www.w3schools.com/html/html_intro.asp">Learn basic HTML</a></li>
<li><a href="http://www.w3schools.com/Xhtml/">Learn about xhtml and validation</a></li>
<li><a href="http://validator.w3.org/">Make valid xhtml and validate</a></li>
</ol>
<p>Learning perfect HTML will take some time but it will really pay off later. It&#8217;s way easier to prevent mistakes and track down bugs when the markup is perfect.</p>
<p>Next step is what you&#8217;ve been waiting for; applying CSS.</p>
<h2>2. Know CSS</h2>
<ol>
<li><a href="http://www.w3.org/Style/Examples/011/firstcss">How to apply CSS</a></li>
<li><a href="http://www.w3schools.com/css/css_background.asp">Know all the important aspects of styling</a></li>
<li><a href="http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/">Learn about positioning</a></li>
<li><a href="http://www.w3schools.com/css/css_dimension.asp">Get to advanced CSS</a></li>
</ol>
<p>You don&#8217;t have to be perfect at CSS. But being good at it will save a lot of time for your designer.</p>
<p>If you plan on becoming a server side programmer you are best off learning a server side language to generate HTML pages now. Take a look at <a href="http://www.php.net/">PHP</a>, <a href="http://www.asp.net/">ASP.NET</a>, <a href="http://java.sun.com/products/jsp/">JSP</a> etc. if you want to know more.</p>
<p>Now that you know good HTML and CSS it&#8217;s time to put in a little <a href="http://en.wikipedia.org/wiki/JavaScript">Javascript</a>.<br />
Don&#8217;t start by using a framework now, you first need to understand what Javascript is and what it can do to alter the layout of the web page.</p>
<h2>3. Rock Javascript!</h2>
<ol>
<li><a href="http://www.amazon.com/s/ref=nb_ss_b?url=search-alias%3Dstripbooks&amp;field-keywords=javascript&amp;x=0&amp;y=0">Read a good book about Javascript.</a></li>
<li><a href="http://net.tutsplus.com/articles/web-roundups/best-of-the-web-january/">Get to know some funny Javascript effects and concepts.</a> (There are a lot on the Internet)</li>
</ol>
<p>After I read a good book and experimented with Javascript on some projects a bit, I wanted to get everything out of Javascript by making nice effects like the other guys do. For this there are a lot of frameworks available, which also happen to make your Javascript coding a lot easier!</p>
<h2>4. Pick your framework</h2>
<p> </p>
<p>There are a few great Javascript frameworks out there. The biggest players in the game are: <a href="http://mootools.net/">MooTools</a>, <a href="http://jquery.com/">jQuery</a> and <a href="http://script.aculo.us/">script.aculo.us</a>.</p>
<p><a href="http://mootools.net/">MooTools</a> is a lightweight Javascript framework which can be used to utilize simple effects on the elements on your page. It doesn&#8217;t have a lot of fancy features, but it does the job. Good choice for beginners.</p>
<p><a href="http://jquery.com/">jQuery</a> might be the most popular one out there. Not without a reason! It&#8217;s easy to apply, it has great docs, maybe even easier to learn and does a wonderful job. Does require some plugins for extra functionality but it&#8217;s a really nice framework. Also has a large community.</p>
<p><a href="http://script.aculo.us/">script.aculo.us</a> is the mother ship of the Javascript frameworks. It&#8217;s big and weights a ton. It might be a bit slower and requires a bit more programming than its competitors, but it is powerful in what it does. The capabilities of script.aculo.us take a lot up in speed, but for that you get complete control. You can create excellent Rich Internet Applications with this framework.</p>
<p> </p>
<h2>Conclusion</h2>
<p>In just a few step you can become a front-end web developer. This might take a while and it might take some time to get used to a language, but it will pay-off in the end.<br />
There is a lot to be learned on the Internet and it is never too late to try out web development and make the web a little more exciting.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/">Steps to becoming a front-end web developer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Panoramic Photoviewer in Javascript</title>
		<link>http://fuelyourcoding.com/panoramic-photoviewer-in-javascript/</link>
		<comments>http://fuelyourcoding.com/panoramic-photoviewer-in-javascript/#comments</comments>
		<pubDate>Mon, 04 May 2009 12:44:20 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[panorama]]></category>
		<category><![CDATA[panoramic]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=53</guid>
		<description><![CDATA[As a webdesigner you might have had this problem: “I’ve got a nice looking wide image, but I don’t want my visitors to scroll horizontally.”
A colleague showed me a new project he was working on. A large image appeared and I had the ability to drag and move the image around in a container. Not [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/panoramic-photoviewer-in-javascript/">Panoramic Photoviewer in Javascript</a></p>
]]></description>
			<content:encoded><![CDATA[<p>As a webdesigner you might have had this problem: “I’ve got a nice looking wide image, but I don’t want my visitors to scroll horizontally.”</p>
<p>A colleague showed me a new project he was working on. A large image appeared and I had the ability to drag and move the image around in a container. Not super efficient if you ask me, I still had to grab the image and move it around holding my mouse button. Can’t there be an easier way?</p>
<p>This article will show you my solution to the problem and maybe even a different approach on navigation.</p>
<p><img class="alignnone size-full wp-image-56" title="Panoramic Photoviewer in Javascript" src="http://fuelyourcoding.com/files/panoramicphotoviewerimg.jpg" alt="Panoramic Photoviewer in Javascript" width="606" height="132" /></p>
<div class="post_buttons"><a href="http://www.fuelyourcoding.com/scripts/photonav/jqueryphotonav.zip"><img class="size-full wp-image-24 alignnone" title="Download zipped archive" src="http://fuelyourcoding.com/files/download-button.gif" alt="Download zipped archive" width="229" height="68" /></a><a href="http://www.fuelyourcoding.com/scripts/photonav/"><img class="size-full wp-image-25 alignnone" title="View the example" src="http://fuelyourcoding.com/files/example-button.gif" alt="View the example" width="229" height="68" /></a></div>
<p>The <em>example page</em> is located here:<br />
<a href="http://fuelyourcoding.com/scripts/photonav/">http://www.fuelyourcoding.com/scripts/photonav/</a></p>
<p>And the <em>archive is downloadable</em> here:<br />
<a onclick="javascript:pageTracker._trackPageview('/scripts/photonav/jqueryphotonav.zip');" href="http://fuelyourcoding.com/scripts/photonav/jqueryphotonav.zip">http://fuelyourcoding.com/scripts/photonav/jqueryphotonav.zip</a></p>
<h2>What is it?</h2>
<p>This photo container has been adjusted to “move” with the cursor. To achieve this I used Javascript and a library called <a onclick="javascript:pageTracker._trackPageview('/outbound/article/jQuery.com');" href="http://jquery.com/">jQuery</a>.</p>
<h2>What do we have and what do we need to do?</h2>
<ol>
<li>Create a HTML layout for the picture to get in.</li>
<li>Adjust the CSS.</li>
<li>Make a call to PhotoNav in Javascript.</li>
</ol>
<h2>1. Create a HTML layout</h2>
<p>This is the easiest step. It might just as well be a copy paste of the code below. But be aware of three things.<br />
First give the overall container an id (so Javascript can grab the object).<br />
Then make sure the div with classname <em>fixed</em> gets a second classname to correspond with the CSS (I used <em>opt1</em> and <em>opt2</em>).<br />
Determine if you want to have links inside of the container, if not; you can leave the container empty.</p>
<p>Take a look at the code below:</p>
<pre class="brush: xml;">
&lt;div class='photo' style='display: none;' id='navigate'&gt;
	&lt;div class='fixed opt1'&gt;
		&lt;!-- this is optional --!&gt;
		&lt;a href='http://gayadesign.com/post/' class='button1'&gt;

		&lt;/a&gt;
		&lt;a href='http://gayadesign.com/portfolio/' class='button2'&gt;

		&lt;/a&gt;
		&lt;a href='http://gayadesign.com/about/' class='button3'&gt;

		&lt;/a&gt;
		&lt;a href='http://gayadesign.com/partners/' class='button4'&gt;

		&lt;/a&gt;
		&lt;a href='http://gayadesign.com/contact/' class='button5'&gt;

		&lt;/a&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>The overall container “navigate” will always be hidden prior to the actual Javascript call. I also gave the <em>fixed</em> div a second class. This classname will point to the options of the container; the height and the background image (the actual image that needs scrolling).<br />
You can add <em>&lt;a&gt; tags</em> to the <em>fixed</em> container. I gave them all classnames so they can be positioned in the CSS. This part is optional.</p>
<p>Remember to include the jQuery library and the PhotoNav Javascript files in the header. Also include the CSS file <em>photonav.css</em>.</p>
<pre class="brush: xml;">
&lt;script src=&quot;js/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;js/photonavjQuery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;link href='css/photonav.css' rel='stylesheet' type='text/css' /&gt;
</pre>
<h2>2. Adjust the CSS<br />
</h2>
<p>The top part of the CSS has to stay the way it is, do not adjust it if you don’t know what you are doing. I put a comment at the spot where you can start to edit the CSS.<br />
I’ll describe what to do at each part of the CSS.</p>
<p><strong>.photonav .photo: </strong></p>
<pre class="brush: css;">
.photonav .photo {
	width: 400px;
	margin: 10px;
	border: 1px solid gray;
}
</pre>
<p>Adjust the width of the total container. This has to be a fixed width in order for it to work in IE6. I have no idea why, but if the <em>width</em> was set to <em>100%</em>, the height was 0px. You can do <em>100%</em> in other browser with the <em>!important</em> trick.<br />
The margin and border are optional, just make it as you’d like.</p>
<p><strong>.photonav .photo .opt1:</strong></p>
<pre class="brush: css;">
.photonav .photo .opt1 {
	height: 100px;
	background-image: url();
}
</pre>
<p>This is the height of the photo container, at least, the <em>fixed</em> container. But notice the <em>.opt1</em>, it is the second classname we added to the <em>fixed</em> container in the HTML part.<br />
The background image is the image that has to be viewed inside the container.</p>
<p><em>The next part is optional and only if you want buttons inside the container.</em></p>
<p><strong>a.button*:</strong></p>
<pre class="brush: css;">
a.button1 {
	margin-left: 20px;
	margin-top: 30px;
	width: 100px;
	height: 90px;
	background-image: url();
}

a.button1:hover {
	background-image: url();
}
</pre>
<p>In order to create a menu navigation like I did on the preview page, you need to add <em>a tags</em> with different classnames. Define the pixels from the left side and the top of the container in the margin values. State the width and height of the button and the background image (if needed).<br />
To create an <em>onhover</em> effect you can add an other image in the <em>:hover</em> part.<br />
If you want a second <em>a tag</em> next to the other, subtract the <em>height </em>of the previous button from the margin-top.</p>
<h2>3. Make a call to PhotoNav in Javascript</h2>
<p>Now that you’ve got all the necessary HTML and CSS set, you can call the PhotoNav functionality. The following code can be put in a js file or in a <em>script</em> tag.</p>
<pre class="brush: jscript;">
document.getElementById('navigate').style.display = 'block';
PhotoNav.init('navigate', 758, 1412, false);
</pre>
<p>The specification is:<br />
<strong>function </strong>init(<strong>String </strong><em>id_of_container</em>, <strong>int </strong><em>width_of_container</em>, <strong>int </strong><em>width_of_panorama_picture</em>, <strong>bool</strong> <em>debugMode</em>);</p>
<p><strong>String </strong><em>id_of_container</em>:<br />
The id of the container.</p>
<p><strong>int </strong><em>width_of_container</em>:<br />
Give the width in pixels of the <em>fixed</em> container. For calculating reasons.</p>
<p><strong>int </strong><em>width_of_panorama_picture</em>:<br />
Give the width in pixels of the <span style="font-style: italic;">panoramic </span><em>picture</em>. For calculating reasons.</p>
<p><strong>bool</strong> <em>debugMode</em>:<br />
Enable debug mode. Outputting value to the HTML element with id <em>’status’</em>. (default: false)</p>
<p>If you want to enable debug mode, you have to insert the following code somewhere in your HTML:</p>
<pre class="brush: xml;">
&lt;div id='status'&gt;
	&amp;nbsp;
&lt;/div&gt;
</pre>
<h2>Conclusion</h2>
<p>Now that everything is set, you can fire the thing up! Enable the navigation on loading a page or by triggering an event in Javascript. If you have implementations of this script, post your examples in the comment section, I’d like to see them.</p>
<p>Good luck!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/panoramic-photoviewer-in-javascript/">Panoramic Photoviewer in Javascript</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/panoramic-photoviewer-in-javascript/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Dos and don&#8217;ts of AJAX</title>
		<link>http://fuelyourcoding.com/dos-and-donts-of-ajax/</link>
		<comments>http://fuelyourcoding.com/dos-and-donts-of-ajax/#comments</comments>
		<pubDate>Mon, 04 May 2009 12:05:17 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[backbase]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=46</guid>
		<description><![CDATA[AJAX is one the nicest concept I’ve seen in web development. The basics are simple and quite easy to use.
There are a lot of AJAX frameworks around like jQuery, Prototype and backbase. These frameworks help you create an AJAX application with ease.
But is AJAX really that good? No, but if you use it correctly, it [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/dos-and-donts-of-ajax/">Dos and don&#8217;ts of AJAX</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');" href="http://en.wikipedia.org/wiki/Ajax_%28programming%29">AJAX</a> is one the nicest concept I’ve seen in web development. The basics are simple and quite easy to use.<br />
There are a lot of <a onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');" href="http://en.wikipedia.org/wiki/List_of_Ajax_frameworks">AJAX frameworks</a> around like <a onclick="javascript:pageTracker._trackPageview('/outbound/article/jquery.com');" href="http://jquery.com/">jQuery</a>, <a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.prototypejs.org');" href="http://www.prototypejs.org/">Prototype</a> and <a onclick="javascript:pageTracker._trackPageview('/outbound/article/bdn.backbase.com');" href="http://bdn.backbase.com/">backbase</a>. These frameworks help you create an AJAX application with ease.<br />
But is AJAX really that good? No, but if you use it correctly, it is!</p>
<p>In this article I wish to share my view on AJAX and the possibilities it gives to web developers and designers, and why AJAX is wrong in several situations.</p>
<p><img class="alignnone size-full wp-image-49" title="Dos and don'ts of AJAX" src="http://fuelyourcoding.com/files/dodontsajaximg.jpg" alt="Dos and don'ts of AJAX" width="606" height="112" /></p>
<h2>Case 1: Page loading</h2>
<p>What’s up with websites and dynamically loading pages through AJAX? Isn’t it a bit strange that when you want to switch to another page, there is no real page switch?<br />
Sure, I like it when content is loaded into the website dynamically, saving me bandwidth, time and irritation. But a whole page? Isn’t that kind of missing the point?</p>
<ul>
<li>First of all: What about the back and forward buttons of your browser? No use for them if you load a whole page in AJAX.</li>
<li>Second: Funny when a user tries to copy the URL and send it to a friend. Oops, the page is loaded without the content the user expected.</li>
<li>Third: Search Engines can’t pick it up since it is not really a new page.</li>
</ul>
<p>A better way to load content through AJAX is to load only small parts of information on the page. If the users wishes to visit another page, let the browser go to another page.<br />
Loading content in a small part of the page isn’t a bad thing. If you have a container with tabbed content, it’s easy to load the content of other tabs with AJAX, not a problem.</p>
<p>Loading a whole page in AJAX is just overusing the functionality and really missing the point of web browsing.</p>
<h2>Case 2: The content manager</h2>
<p>Being able to adjust the information of your web profile on a web page with the use of AJAX is cool. Fast feedback, fast loading times and convenient. But is it really secure?<br />
I’ve seen sites where the HTTP calls to the server contained the key and value of the part they wanted to configure. Which means the record which will be adjusted is defined. This means you could also change information of other rows in the database. Why? You need to wonder what parts of the profile can be adjusted, and if it applies only to the user who is trying to configure their information, why do you need a key to tell the server which record to adjust?<br />
In PHP, for example, it only takes little effort to remember a value in a session. With this, you know which user is using the website and if you open the session in the AJAX server side pages, you can still read that session. Makes it easy to tell which record to update and doesn’t give a user the opportunity to mess around in your system.</p>
<p>If you do want to send along a key + value, which could be needed in some situations (like inserting a comment), be sure to check the given values in the server side scripts. Can’t say this enough to people, but please be sure the user that is trying to insert / update data has access to that data. This also applies to normal usage of forms, but adjusting an AJAX request is harder for most users. Still it is possible! So be on your guard.</p>
<h2>Case 3: One click update</h2>
<p>This one is something I love about AJAX. The vote buttons on sites, the follow button on Twitter, delete entry buttons and many more of those. The convenience of just clicking once without having to refresh the page is awesome. It’s so simple, yet so powerful.<br />
If you are using such a thing, keep <em>case 2</em> in mind.</p>
<h2>Case 4: Content loading</h2>
<p>One of the most important things of dynamic loading: it has to be quick. Sending a request to a server doesn’t always have to take up most of the time, but loading the response can be a real pain.<br />
Keep the response clean and small. I’ve seen examples (I’ve been guilty in the past) of people giving HTML back in the response. With this they’ll adjust the innerHTML of a container. In the worst case they’ll load a whole new page (like in <em>case 1</em>).</p>
<p>To solve this, please use <a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.php.net');" href="http://www.php.net/json_encode">JSON</a> or anything of that kind. JSON helps you convert server side variables to Javascript variables. The response the server will give are Javascript variables for Javascript to read. JSON has been implemented in PHP since version 5.2.0 and is easy to use.</p>
<p>Don’t give HTML back to your web page, but arrays of information. This helps keeping the presentation of your site and the calculation apart from each other. Do the adjusting of the DOM in Javascript.</p>
<h2>Case 5: External Services</h2>
<p>When you use external services and feeds to build a web page in server side scripting, you rely on an external service. This can also result is pages loading slower than needed. The is why AJAX is ideal for loading external services.</p>
<p>Load information from an external source after loading the page. This will prevent slow loading of the rest of the page and let’s the information just easily slip in the page when it’s ready.</p>
<h2>Conclusion</h2>
<p>I hope I’ve given my point of view on AJAX and how to use it. If you wish to discuss the things that I’ve said; please do so!</p>
<p>Share your AJAX stories with me =)</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/dos-and-donts-of-ajax/">Dos and don&#8217;ts of AJAX</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/dos-and-donts-of-ajax/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Garagedoor effect using Javascript</title>
		<link>http://fuelyourcoding.com/garagedoor-effect-using-javascript/</link>
		<comments>http://fuelyourcoding.com/garagedoor-effect-using-javascript/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 23:35:33 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[scriptaculous]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=3</guid>
		<description><![CDATA[The GarageDoor effect &#8211; creating one has now been made easy! This tutorial explains everything you need to know on how to create the same effect yourself.


An example of the GarageDoor effect in work is found here: http://www.fuelyourcoding.com/scripts/garagedoor/
Download the following archive containing everything you need: http://www.fuelyourcoding.com/scripts/garagedoor/garagedoor.zip
Unzip the contents of the archive and upload the contents [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/garagedoor-effect-using-javascript/">Garagedoor effect using Javascript</a></p>
]]></description>
			<content:encoded><![CDATA[<p>The GarageDoor effect &#8211; creating one has now been made easy! This tutorial explains everything you need to know on how to create the same effect yourself.</p>
<p><img class="alignnone size-full wp-image-17" title="Garagedoor effect using Javascript" src="http://fuelyourcoding.com/files/garagedoorpostimg.jpg" alt="Garagedoor effect using Javascript" width="606" height="162" /></p>
<div class="post_buttons"><a href="http://fuelyourcoding.com/scripts/garagedoor/garagedoor.zip"><img class="size-full wp-image-24 alignnone" title="Download zipped archive" src="http://fuelyourcoding.com/files/download-button.gif" alt="Download zipped archive" width="229" height="68" /></a><a href="http://fuelyourcoding.com/scripts/garagedoor/"><img class="size-full wp-image-25 alignnone" title="View the example" src="http://fuelyourcoding.com/files/example-button.gif" alt="View the example" width="229" height="68" /></a></div>
<p>An example of the GarageDoor effect in work is found here: <a href="http://fuelyourcoding.com/scripts/garagedoor/">http://www.fuelyourcoding.com/scripts/garagedoor/</a><br />
<em>Download</em> the following archive containing everything you need: <a onclick="javascript:pageTracker._trackPageview('/scripts/garagedoor/garagedoor.zip');" href="http://fuelyourcoding.com/scripts/garagedoor/garagedoor.zip">http://www.fuelyourcoding.com/scripts/garagedoor/garagedoor.zip</a></p>
<p><em>Unzip </em>the contents of the archive and upload the contents to your server, the set folders can be adjusted to your needs.</p>
<p>First we need to make the script ans style of the GarageDoor work. To make that happen, you’ll need Scriptaculous. This library enables interface effects, so you don’t have to create it yourself. So <a onclick="javascript:pageTracker._trackPageview('/outbound/article/script.aculo.us');" href="http://script.aculo.us/downloads">grab Scriptaculous</a> and upload it to your server. Make sure you also upload the <strong>prototype.js </strong>file (in the lib folder).</p>
<p>Add the following code in the <strong>&lt;head&gt;</strong> tag of your page:</p>
<pre class="brush: xml;">
&lt;script src=&quot;js/prototype.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/scriptaculous.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;script src=&quot;js/garagedoor.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;link href='css/garagedoor.css' rel='stylesheet' type='text/css' /&gt;
</pre>
<p>This will load the scripts and styles needed for the GarageDoor to work. <em>Adjust the paths where needed.<br />
</em></p>
<p>The next thing you want to do is to create the HTML layout for the garagedoors. The following code shows the structure you need to create for your document:</p>
<pre class="brush: xml;">
&lt;div class='garagedoor' id='garagedoor'&gt;
	&lt;div title='linktofile' class='item'&gt;
		&lt;div class='underlay'&gt;
			Caption text
		&lt;/div&gt;
		&lt;img src='uritooverlayimage' class='overlay' /&gt;
		&lt;div class='mouse'&gt;&lt;img src='images/nothing.gif' /&gt;&amp;nbsp;&lt;/div&gt;
	&lt;/div&gt;
	&lt;div title='linktofile' class='item'&gt;
		&lt;div class='underlay'&gt;
			Caption text
		&lt;/div&gt;
		&lt;img src='uritooverlayimage' class='overlay' /&gt;
		&lt;div class='mouse'&gt;&lt;img src='images/nothing.gif' /&gt;&amp;nbsp;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>This contains two items that will be the garagedoor. The keywords <strong>linktofile</strong> and<strong> uritooverlayimage</strong> have to be adjusted in order to make it work. <strong>Linktofile</strong> is the URL of the page the button has to link to, might be confusing because it’s not an <em>a tag</em>, but Javascript fixes it for you.</p>
<p>The items have a default size of: <strong>100px width </strong>and <strong>80px height</strong>. <em>Create overlay images</em> according to these dimensions. In order to change the size, take a look in the <strong>garagedoor.css</strong> file and<em>adjust</em> the <strong>width</strong> and <strong>height</strong> of several elements.</p>
<p>All there is left to do is call the GarageDoor to enable the effect!</p>
<pre class="brush: xml;">
&lt;script&gt;
	GarageDoor.scrollY = -55;
	GarageDoor.scrollX = 0;
	GarageDoor.setBindings('garagedoor');
&lt;/script&gt;
</pre>
<p>The first line in the <strong>&lt;script&gt;</strong> tag sets the amount of scrolling the overlay has to do when the cursor is floating over an item. In this example the overlay has to go 55 up, which means move -55px on the Y-axis.<br />
You can also make it scroll horizontal.</p>
<p>Give the <strong>id</strong> of the <strong>garagedoor container</strong> to the <strong>setBindings</strong> method and the GarageDoor effect will be initialized! Be sure to make the call <strong>after</strong> creating the <strong>html</strong>.</p>
<p>You are now set to use the GarageDoor Effect. Good luck!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/garagedoor-effect-using-javascript/">Garagedoor effect using Javascript</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/garagedoor-effect-using-javascript/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
