<?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>buyco.ca</title>
	<atom:link href="http://www.buyco.ca/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.buyco.ca</link>
	<description>because someone stole my name</description>
	<lastBuildDate>Fri, 24 Jun 2011 01:23:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Day 2: On the edge of Canada</title>
		<link>http://www.buyco.ca/2011/06/23/on-the-edge-of-canada/</link>
		<comments>http://www.buyco.ca/2011/06/23/on-the-edge-of-canada/#comments</comments>
		<pubDate>Fri, 24 Jun 2011 01:18:51 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Five Hole For Food]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=261</guid>
		<description><![CDATA[The last 24 hours have been rough&#8230; mainly because I&#8217;ve been stuck in bed sick! Actually that&#8217;s not true, I&#8217;ve had a chance to spend some time working on some new videos. Here&#8217;s the latest&#8230; I only wish I could have joined the fellas on their adventures yesterday: FHFF TV: At the edge of Canada [...]]]></description>
			<content:encoded><![CDATA[<p>The last 24 hours have been rough&#8230; mainly because I&#8217;ve been stuck in bed sick! Actually that&#8217;s not true, I&#8217;ve had a chance to spend some time working on some new videos. Here&#8217;s the latest&#8230; I only wish I could have joined the fellas on their adventures yesterday:</p>
<p><iframe src="http://player.vimeo.com/video/25531955?title=0&amp;byline=0&amp;portrait=0" width="400" height="300" frameborder="0"></iframe>
<p><a href="http://vimeo.com/25531955">FHFF TV: At the edge of Canada</a> from <a href="http://vimeo.com/user7560507">Jonathan Buyco</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Tomorrow is going to be a full day of travel, and lots more to prepare! Keep up with more of our updates here:</p>
<p><a href="http://www.fiveholeforfood.com/snapshots-st-johns-nfld/" target="_blank">http://www.fiveholeforfood.com/snapshots-st-johns-nfld/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2011/06/23/on-the-edge-of-canada/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Day 1 &#8211; Vancouver to St John&#8217;s</title>
		<link>http://www.buyco.ca/2011/06/22/day-1-vancouver-to-st-johns/</link>
		<comments>http://www.buyco.ca/2011/06/22/day-1-vancouver-to-st-johns/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 07:06:55 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Five Hole For Food]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=254</guid>
		<description><![CDATA[This morning our flight left Vancouver at 11am and we arrived in St. John&#8217;s Newfoundland at 12:30am local time. Not much can be said really about today since most of it was spent on a plane. I got a good 8 hours of sleep during the day, but I&#8217;m still tired. Weird saying that since [...]]]></description>
			<content:encoded><![CDATA[<p>This morning our flight left Vancouver at 11am and we arrived in St. John&#8217;s Newfoundland at 12:30am local time. Not much can be said really about today since most of it was spent on a plane. I got a good 8 hours of sleep during the day, but I&#8217;m still tired. Weird saying that since it&#8217;s currently 4:30am here.</p>
<p>The flights over were fantastic, and we have to thank WestJet for flying us out here! I think the other guys may have been a bit jealous because on both flights I think I got <a href="http://ow.ly/i/dhYC" target="_blank">the best seat in the house</a>. Totally makes sense&#8230;since I am the shortest guy out of us all <img src='http://www.buyco.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here&#8217;s a short little video of our first day and just a couple shout outs at the end. </p>
<p><object width="600" height="371"><param name="movie" value="http://www.youtube.com/v/1beSWFwG9gI?version=3&#038;hl=en_US&#038;hd=1&#038;ap=%2526fmt%3D18"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/1beSWFwG9gI?version=3&#038;hl=en_US&#038;hd=1&#038;ap=%2526fmt%3D18" type="application/x-shockwave-flash" width="600" height="371" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>I have to give a HUGE thank-you to London Drugs who provided us with this awesome Panasonic HDC-TM700 camcorder. The quality on this bad boy is insane! It shoots at 1920&#215;1080/60p and you can tell with the video above. Muchos gracias for their support!</p>
<p>I should probably leave it at that, I think I hear the birds chirping outside. Don&#8217;t forget to follow along in our adventure, and to join in at one of the cities closest to you!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2011/06/22/day-1-vancouver-to-st-johns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m leaving on a jet plane!</title>
		<link>http://www.buyco.ca/2011/06/20/im-leaving-on-a-jet-plane/</link>
		<comments>http://www.buyco.ca/2011/06/20/im-leaving-on-a-jet-plane/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 23:38:23 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[fhff]]></category>
		<category><![CDATA[five hole for food]]></category>
		<category><![CDATA[food bank]]></category>
		<category><![CDATA[hockey]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=241</guid>
		<description><![CDATA[Tomorrow&#8217;s the big day &#8212; the day I leave to travel across the country with hopes to make a difference in this world. After the months of planning, the support of our generous sponsors, and the many hands making light of heavy work&#8230; Here&#8217;s our story: That&#8217;s the gist of it. We&#8217;ll be gone for [...]]]></description>
			<content:encoded><![CDATA[<p>Tomorrow&#8217;s the big day &#8212; the day I leave to travel across the country with hopes to make a difference in this world. After the months of planning, the support of our generous sponsors, and the many hands making light of heavy work&#8230; Here&#8217;s our story:</p>
<p><object width="600" height="371"><param name="movie" value="http://www.youtube.com/v/CCaXgl_moH8?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/CCaXgl_moH8?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="600" height="371" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>That&#8217;s the gist of it. We&#8217;ll be gone for a good 3 weeks and to be honest this is the longest I&#8217;ve ever been away from home. My last vacation was years ago, and for about a week (maybe)&#8230;although this isn&#8217;t even a vacation! There is still tons of work left to do, and I&#8217;ve got to be on my toes throughout the entire trip. It&#8217;s hard to say exactly what I&#8217;ll be doing because there is so much to be done. But what I can do is try my best to keep everyone updated with daily videos, tweets, photos, blog entries, and high fives.</p>
<p>All I ask is that if you&#8217;re in one of our cities that we hit, you make an appearance <img src='http://www.buyco.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;ll keep this post short and sweet and leave you with some links you may fancy.</p>
<p>Official Five Hole For Food links:<br />
Website: <a href="http://www.fiveholeforfood.com/" target="_blank">http://www.fiveholeforfood.com/</a><br />
YouTube channel: <a href="http://www.youtube.com/user/FiveHoleForFood" target="_blank">http://www.youtube.com/user/FiveHoleForFood</a><br />
Twitter account: <a href="http://twitter.com/fiveholeforfood" target="_blank">http://twitter.com/fiveholeforfood</a><br />
My twitter account: <a href="http://twitter.com/jonathanbuyco" target="_blank">http://twitter.com/jonathanbuyco</a><br />
My flickr account: <a href="http://www.flickr.com/photos/jonathanbuyco/">http://www.flickr.com/photos/jonathanbuyco/</a></p>
<p>Also, muchos gracias to some of our sponsors:<br />
<a href="http://www.fiveholeforfood.com/sponsors/" target="_blank">http://www.fiveholeforfood.com/sponsors/</a></p>
<p>This trip wouldn&#8217;t happen without them!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2011/06/20/im-leaving-on-a-jet-plane/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Glee Camp Vancouver Experience</title>
		<link>http://www.buyco.ca/2010/12/01/glee-camp-vancouver-experience/</link>
		<comments>http://www.buyco.ca/2010/12/01/glee-camp-vancouver-experience/#comments</comments>
		<pubDate>Wed, 01 Dec 2010 18:09:39 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[glee]]></category>
		<category><![CDATA[glee camp]]></category>
		<category><![CDATA[rocket man]]></category>
		<category><![CDATA[somebody to love]]></category>
		<category><![CDATA[time warp]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=219</guid>
		<description><![CDATA[Last night I was fortunate enough to experience my friends singing and dancing on stage similar to that of Glee! Mind you I&#8217;ve never seen the TV show, but if it&#8217;s anything like what I saw tonight I&#8217;m a new fan. To give a bit of a back-story for this, my friend Mariel mentioned she [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I was fortunate enough to experience my friends singing and dancing on stage similar to that of Glee! Mind you I&#8217;ve never seen the TV show, but if it&#8217;s anything like what I saw tonight I&#8217;m a new fan.</p>
<p><a href="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0744.jpg" rel="shadowbox[Glee Camp Vancouver]"><img src="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0744-150x150.jpg" alt="" title="0_DSC_0744" width="150" height="150" class="alignnone size-thumbnail wp-image-223" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0746.jpg" rel="shadowbox[Glee Camp Vancouver]"><img src="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0746-150x150.jpg" alt="" title="0_DSC_0746" width="150" height="150" class="alignnone size-thumbnail wp-image-224" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0753.jpg" rel="shadowbox[Glee Camp Vancouver]"><img src="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0753-150x150.jpg" alt="" title="0_DSC_0753" width="150" height="150" class="alignnone size-thumbnail wp-image-225" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0760.jpg" rel="shadowbox[Glee Camp Vancouver]"><img src="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0760-150x150.jpg" alt="" title="0_DSC_0760" width="150" height="150" class="alignnone size-thumbnail wp-image-226" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0768.jpg" rel="shadowbox[Glee Camp Vancouver]"><img src="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0768-150x150.jpg" alt="" title="0_DSC_0768" width="150" height="150" class="alignnone size-thumbnail wp-image-227" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0769.jpg" rel="shadowbox[Glee Camp Vancouver]"><img class="alignnone size-thumbnail wp-image-228" title="0_DSC_0769" src="http://www.buyco.ca/wp-content/uploads/2010/12/0_DSC_0769-150x150.jpg" alt="" width="150" height="150" /></a></p>
<p>To give a bit of a back-story for this, my friend Mariel mentioned she joined a Glee club where they practice singing in a group. The first time she mentioned it I thought it was some kind of support group for people who have singing problems lol. Turned out she really enjoyed it and was having a great time with her group. So for the following ten weeks thereafter she and her group worked very hard to put together an amazing night! So without further adieu, here is Mariel, Taal, Shayne and the other members of the Vancouver Glee Camp!</p>
<p>Rocket Man:</p>
<p><object width="600" height="362"><param name="movie" value="http://www.youtube.com/v/VedfVrhBoeE?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/VedfVrhBoeE?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="362"></embed></object></p>
<p>Time Warp:</p>
<p><object width="600" height="362"><param name="movie" value="http://www.youtube.com/v/0ikQPERim-o?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0ikQPERim-o?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="362"></embed></object></p>
<p>Somebody to Love:</p>
<p><object width="600" height="362"><param name="movie" value="http://www.youtube.com/v/bd1nd-JK7jw?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bd1nd-JK7jw?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="362"></embed></object></p>
<p>Like a Prayer:</p>
<p><object width="600" height="362"><param name="movie" value="http://www.youtube.com/v/fd8eV5ZMtKw?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/fd8eV5ZMtKw?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="362"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2010/12/01/glee-camp-vancouver-experience/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JavaScript Essentials: Compatibility</title>
		<link>http://www.buyco.ca/2010/07/23/javascript-compatibility/</link>
		<comments>http://www.buyco.ca/2010/07/23/javascript-compatibility/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 21:30:05 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Weekly JavaScript Workshops]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=200</guid>
		<description><![CDATA[It's one thing to create some amazing interactivity with JavaScript, it's another if you can get it to work with all modern browsers]]></description>
			<content:encoded><![CDATA[<h2>Week 3 &#8211; JavaScript Essentials: Compatibility</h2>
<h3>Compatibility</h3>
<h4>Who are you programming for?</h4>
<p>It&#8217;s one thing to create some amazing interactivity with JavaScript, it&#8217;s another if you can get it to work with all modern browsers, and it&#8217;s above and beyond when you also take into account the needs of browsers with JavaScript disabled.</p>
<p>Creating functionality to work on your site for one particular browser (and version) and for one particular operating system is easy. Getting it to work with other browsers on all operating systems is a more daunting task. Adding functionality to enable elegant error messages for browsers with JavaScript disabled is a work of art!</p>
<p>There are hundreds if not thousands of combinations of browser/operating system combinations. It&#8217;s our duty as web developers to ensure that our sites work with the most common browsers and operating systems, without sacrificing too much of the user&#8217;s experience. For this week&#8217;s session, we&#8217;re going to consider the following groups:</p>
<h5>Modern browsers with JavaScript enabled</h5>
<p>This group is going to be your best friend. These are the browsers which work exactly how you want them to, close to W3C spec and are compatible with almost every bit of modern JavaScript code&#8211;although their reliability can also be a big downfall in your habits. Always remember: Just because it works on Firefox on Windows, doesn&#8217;t mean it works for everything else.</p>
<h5>Older browsers with JavaScript enabled</h5>
<p>Although there are not too many users out there sporting the Internet Explorer 6.0 SP2, they shouldn&#8217;t be forgotten. It&#8217;s not difficult to test code for these types of browsers, you just have to not be lazy. But even if you are, there are alternatives to writing a completely different set of code just for compatibility&#8217;s sake.</p>
<h5>Any browser with JavaScript disabled</h5>
<p>This can include essentially any browser you can think of. This might be the easiest group to speak to because you can&#8217;t with JavaScript!</p>
<h4>Honorable Mentions</h4>
<p>There are some other types of browsers we are not going to consider for this particular week&#8217;s session, but it&#8217;s good to know that they exist.</p>
<h5>Mobile Browsers</h5>
<p>Here we enter the realm of mobile browsing. We are now dealing with even more platforms/operating systems, and types of mobile browsers. Now how many of them actually support JavaScript? This group I rarely worry about because I consider the demographic of my audience and this rarely falls within a project&#8217;s requirements. In the case of you having to build a site compatible with mobile devices, there are several emulators out there you can use on your computer to test the functionality of your site:</p>
<ul>
<li><a href="http://www.winwap.com/desktop_applications/browser_emulator" target="_blank">WinWAP Smartphone Browser Emulator</a></li>
<li><a href="http://www.marketcircle.com/iphoney/" target="_blank">iPhoney iPhone Web Simulator</a></li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=C62D54A5-183A-4A1E-A7E2-CC500ED1F19A&#038;displaylang=en" target="_blank">Device Emulator 1.0 with Windows Mobile OS Images</a></li>
</ul>
<p>These are only a few of many emulators out there which you can use, but this is a good place to start.</p>
<h5>Internet Explorer</h5>
<p>Yes we will go over Internet Explorer, but IE should still be considered as a separate group only because of how easy it is to isolate this subset. Consider the following:</p>
<pre class="brush: xml;">
		&lt;html xmlns="http://www.w3.org/1999/xhtml">
		&lt;head>
		&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		&lt;title>Hello there&lt;/title>
		&lt;!--[if !IE]>-->
		&lt;!--&#038;lt![endif]>-->
		&lt;/head>
		&lt;body>
		&lt;/body>
		&lt;/html>
	</pre>
<p>IE is the only browser you can explicitly call out like this. When writing your code, whether it is JavaScript or even CSS, remember you have this in your arsenal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2010/07/23/javascript-compatibility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript Essentials: Event Handlers</title>
		<link>http://www.buyco.ca/2010/07/08/event-handlers/</link>
		<comments>http://www.buyco.ca/2010/07/08/event-handlers/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 01:11:03 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Weekly JavaScript Workshops]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=189</guid>
		<description><![CDATA[Week 2 &#8211; JavaScript Essentials: Event handlers Events What&#8217;s an event? Exactly what you think it is. They are occurrences of actions happening on a web page. They can be triggered by a user or by the webpage itself. Some of the most commonly known events are ONLOAD, ONCLICK, and ONMOUSEOVER. Certain elements on a [...]]]></description>
			<content:encoded><![CDATA[<h2>Week 2 &#8211; JavaScript Essentials: Event handlers</h2>
<h3>Events</h3>
<h4>What&#8217;s an event?</h4>
<p>Exactly what you think it is. They are occurrences of actions happening on a web page. They can be triggered by a user or by the webpage itself. Some of the most commonly known events are ONLOAD, ONCLICK, and ONMOUSEOVER. Certain elements on a page can trigger any or many of these events. JavaScript has the ability to detect these events and may be utilized to execute functions based on these triggers.</p>
<h4>List of common events</h4>
<p>This is not comprehensive, but I&#8217;ve included several common events based on the element.</p>
<div class="tabs">
<ul>
<li>A
<div class="tabcontent">
<dl>
<dt>onMouseOver</dt>
<dd>Trigger: when you move your mouse over </dd>
<dt>onMouseOut</dt>
<dd>Trigger: user moves mouse off of element</dd>
<dt>onClick</dt>
<dd>Trigger: user clicks on the element</dd>
</dl></div>
</li>
<li>IMG
<div class="tabcontent">
<dl>
<dt>onMouseOver</dt>
<dd>Trigger: when you move your mouse over </dd>
<dt>onMouseOut</dt>
<dd>Trigger: user moves mouse off of element</dd>
<dt>onClick</dt>
<dd>Trigger: user clicks on the element</dd>
<dt>onLoad</dt>
<dd>Trigger: when the element is loaded</dd>
</dl></div>
</li>
<li>INPUT
<div class="tabcontent">
<dl>
<dt>onMouseOver</dt>
<dd>Trigger: when you move your mouse over </dd>
<dt>onMouseOut</dt>
<dd>Trigger: user moves mouse off of element</dd>
<dt>onFocus</dt>
<dd>Trigger: user focuses on an element</dd>
<dt>onBlur</dt>
<dd>Trigger: element loses focus</dd>
<dt>onKeyUp</dt>
<dd>Trigger: user is typing and after a key press</dd>
<dt>onKeyDown</dt>
<dd>Trigger: user is typing and on key press</dd>
</dl></div>
</li>
<li>SELECT
<div class="tabcontent">
<dl>
<dt>onChange</dt>
<dd>Trigger: user changes the selected value</dd>
<dt>onFocus</dt>
<dd>Trigger: user focuses on an element</dd>
<dt>onBlur</dt>
<dd>Trigger: element loses focus</dd>
</dl></div>
</li>
<li>FORM
<div class="tabcontent">
<dl>
<dt>onSubmit</dt>
<dd>Trigger: user attempts to submit a form</dd>
</dl></div>
</li>
<li>BODY
<div class="tabcontent">
<dl>
<dt>onLoad</dt>
<dd>Trigger: when the page is completely loaded</dd>
<dt>onUnLoad</dt>
<dd>Trigger: user leaves the page</dd>
</dl></div>
</li>
</ul></div>
<p>A list of events can be found on the W3C website: <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.htm" target="_blank">http://www.w3.org/TR/DOM-Level-2-Events/events.htm</a>. It is also important to understand that not all browsers handle events the same. An example reference can be found here: <a href="http://www.quirksmode.org/dom/events/index.html" target="_blank">http://www.quirksmode.org/dom/events/index.html</a>.</p>
<h3>Event Handling</h3>
<p>There are several ways to handle these events. Now that you have an understanding of what can trigger these events, we&#8217;re going to attempt to catch them and do something. For the sake of simplicity, we will just execute <em>alert(&#8216;Hello World&#8217;);</em> for the next exercise. Each time an event is triggered, we will pop up a JavaScript dialog box which says &#8220;Hello World.&#8221;</p>
<h4>Example: Anchor Events</h4>
<p>Consider the following markup:</p>
<pre class="brush: xml;">
		&lt;html xmlns="http://www.w3.org/1999/xhtml">
		&lt;head>
		&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		&lt;title>Hello there&lt;/title>
		&lt;/head>
		&lt;body>
		&lt;h1>This is the title&lt;/h1>
		&lt;p>This is a paragraph &lt;a href="#">with a link&lt;/a>&lt;/p>
		&lt;/body>
		&lt;/html>
	</pre>
<p>We are going to change line 8 and add some event handlers:</p>
<pre class="brush: xml; first-line: 8">
		&lt;p>This is a paragraph &lt;a href="#" onclick="alert('Hello World');">with a link&lt;/a>&lt;/p>
	</pre>
<pre class="brush: xml; first-line: 8">
		&lt;p>This is a paragraph &lt;a href="#" onmouseover="alert('Hello World');">with a link&lt;/a>&lt;/p>
	</pre>
<pre class="brush: xml; first-line: 8">
		&lt;p>This is a paragraph &lt;a href="#" onmouseout="alert('Hello World');">with a link&lt;/a>&lt;/p>
	</pre>
<p>Try it for yourself. In the first example, when you click &#8220;with a link,&#8221; the dialog box should pop up. In the next, as soon as you move your mouse over the link, the dialog box should pop up. In the final example, when you move your mouse off the link (after it being over it), the dialog box should pop up.</p>
<p>The same method can be used with other event handlers where we directly input the JavaScript code in a new attribute in the element defined by the event handler name. For the most part this works just fine, but there are several reasons why we don&#8217;t want to do it this way:</p>
<ol>
<li>
<h5>Designers aren&#8217;t developers</h5>
<p>A designer doesn&#8217;t always understand how the functionality of the page works. If he/she makes a change to a link with explicit event handlers defined, unexpected errors may occur.</p>
</li>
<li>
<h5>Content management systems</h5>
<p>Not all CMSs honor inline JavaScript and may remove it from the HTML. </p>
</li>
<li>
<h5>Page overhead</h5>
<p>Adding inline code adds additional overhead to your markup. </p>
</li>
<li>
<h5>Coding standards</h5>
<p>There are no real coding standards for JavaScript, except for the peace of mind knowing your logic is separated from your view. It makes things easier down the road if you need to make updates to your code. (ref: <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" target="_blank">MVC architecture</a>)</p>
</li>
</ol>
<p>With browsers being updated very frequently, and functionality for JavaScript compatibility always on the bend, consolidating your code into one place makes things easier to update and makes your code much more scalable. The MVC concept works well with respect to JavaScript and although not completely necessary, it can make your life a lot easier in the long run.</p>
<h4>Example: Unobtrusive Anchor Events</h4>
<p>When we separate our JavaScript code from our HTML markup, we still need to listen to those event triggers. Unobtrusive JavaScript is centered around the idea of separating functionality and form; behavior and presentation; controller and view; etc. We will continue with our example with anchors, and do the same with unobtrusive JavaScript.</p>
<p>In the previous week&#8217;s topic, <a href="../week-1">we discussed element selection</a>. We are going to use the same ideas and incorporate event listening.</p>
<p>Consider the following markup:</p>
<pre class="brush: xml;">
		&lt;html xmlns="http://www.w3.org/1999/xhtml">
		&lt;head>
		&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		&lt;title>Hello there&lt;/title>
		&lt;/head>
		&lt;body>
		&lt;h1>This is the title&lt;/h1>
		&lt;p>This is a paragraph &lt;a href="#" id="mylink">with a link&lt;/a>&lt;/p>
		&lt;/body>
		&lt;/html>
	</pre>
<p>To simplify this example, we are going to take into consideration the pure JavaScript &#8220;domload&#8221; function which is called on the dom load referred to in <a href="../week-1/#2-4-where-should-the-code-be-">Week 1&#8242;s workshop</a>. For our prototype and jQuery examples, we are going to use their respective &#8220;domload&#8221; functions. We are then assuming this code will be placed in the document&#8217;s HEAD.</p>
<p>We will also be calling the following function when these events are triggered:</p>
<pre class="brush: jscript">

					// our hello world function
					function helloWorld(e) {
						alert('Hello World');
					}
	</pre>
<h5>Example: Listening to &#8220;onClick&#8221;</h5>
<div class="tabs">
<ul>
<li>Pure Javascript
<div class="tabcontent">
<pre class="brush: jscript;">
					// our domload function from Week 1
					initDOMLoad(function() {

						// check what kind of event listener function we need to call
						var m;
						window.addEventListener ? m = true : m = false;

						// select the link
						if (document.getElementById) {
							var objLink = document.getElementById('mylink');

							// use appropriate event listener
							if (m) {
								objLink.addEventListener('click', helloWorld, false);
							}
							else {
								objLink.attachEvent('onclick', helloWorld);
							}
						}
					});
				</pre>
</p></div>
</li>
<li>Prototype
<div class="tabcontent">
<pre class="brush: jscript;">
					// listen on dom load
					document.observe('dom:loaded',function() {

						// select the link and listen on click
						$('mylink').observe('click', helloWorld);
					});
				</pre>
</p></div>
</li>
<li>jQuery
<div class="tabcontent">
<pre class="brush: jscript;">
					// listen on dom load
					$(document).ready(function() {

						// select the link and listen on click
						$('a#mylink').click(helloWorld);
					});
				</pre>
</p></div>
</li>
</ul></div>
<h5>Example: Listening to &#8220;onMouseOver&#8221;</h5>
<div class="tabs">
<ul>
<li>Pure Javascript
<div class="tabcontent">
<pre class="brush: jscript;">
					// our domload function from Week 1
					initDOMLoad(function() {

						// check what kind of event listener function we need to call
						var m;
						window.addEventListener ? m = true : m = false;

						// select the link
						if (document.getElementById) {
							var objLink = document.getElementById('mylink');

							// use appropriate event listener
							if (m) {
								objLink.addEventListener('mouseover', helloWorld, false);
							}
							else {
								objLink.attachEvent('onmouseover', helloWorld);
							}
						}
					});
				</pre>
</p></div>
</li>
<li>Prototype
<div class="tabcontent">
<pre class="brush: jscript;">
					// listen on dom load
					document.observe('dom:loaded',function() {

						// select the link and listen on click
						$('mylink').observe('mouseover', helloWorld);
					});
				</pre>
</p></div>
</li>
<li>jQuery
<div class="tabcontent">
<pre class="brush: jscript;">

					// listen on dom load
					$(document).ready(function() {

						// select the link and listen on click
						$('a#mylink').mouseover(helloWorld);
					});
				</pre>
</p></div>
</li>
</ul></div>
<h5>Example: Listening to &#8220;onMouseOut&#8221;</h5>
<div class="tabs">
<ul>
<li>Pure Javascript
<div class="tabcontent">
<pre class="brush: jscript;">
					// our domload function from Week 1
					initDOMLoad(function() {

						// check what kind of event listener function we need to call
						var m;
						window.addEventListener ? m = true : m = false;

						// select the link
						if (document.getElementById) {
							var objLink = document.getElementById('mylink');

							// use appropriate event listener
							if (m) {
								objLink.addEventListener('mouseout', helloWorld, false);
							}
							else {
								objLink.attachEvent('onmouseout', helloWorld);
							}
						}
					});
				</pre>
</p></div>
</li>
<li>Prototype
<div class="tabcontent">
<pre class="brush: jscript;">
					// listen on dom load
					document.observe('dom:loaded',function() {

						// select the link and listen on click
						$('mylink').observe('mouseout', helloWorld);
					});
				</pre>
</p></div>
</li>
<li>jQuery
<div class="tabcontent">
<pre class="brush: jscript;">
					// listen on dom load
					$(document).ready(function() {

						// select the link and listen on click
						$('a#mylink').mouseout(helloWorld);
					});
				</pre>
</p></div>
</li>
</ul></div>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2010/07/08/event-handlers/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JavaScript Essentials: Execution Order, Selectors, DOM manipulation</title>
		<link>http://www.buyco.ca/2010/07/07/javascript-essentials-execution-order-selectors-dom-manipulation/</link>
		<comments>http://www.buyco.ca/2010/07/07/javascript-essentials-execution-order-selectors-dom-manipulation/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 00:33:47 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Weekly JavaScript Workshops]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=172</guid>
		<description><![CDATA[Execution order When does the script get executed? It&#8217;s important to understand that JavaScript code will be run at different times during the page&#8217;s loading process, or even after. You can place code in a number of areas of a page: within the HEAD tag, the BODY tag or explicitly in elements within the BODY. [...]]]></description>
			<content:encoded><![CDATA[<h3>Execution order</h3>
<h4>When does the script get executed?</h4>
<p>It&#8217;s important to understand that JavaScript code will be run at different times during the page&#8217;s loading process, or even after. You can place code in a number of areas of a page: within the HEAD tag, the BODY tag or explicitly in elements within the BODY. </p>
<p>Consider the following markup:</p>
<pre class="brush: xml;">
		&lt;html xmlns="http://www.w3.org/1999/xhtml">
		&lt;head>
		&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		&lt;title>Hello there&lt;/title>
		&lt;script>
		// you can put your script here in the HEAD
		&lt;/script>
		&lt;/head>
		&lt;body>
		&lt;script>
		// you can put your script here in the BODY
		&lt;/script>
		&lt;p>Or you can put it in an element like this &lt;a href="http://www.buyco.ca" onclick="javascript:void(0);">link&lt;/a>&lt;/p>
		&lt;/body>
		&lt;/html>
	</pre>
<h4>Order of script execution</h4>
<ol>
<li>&lt;HEAD> tag</li>
<li>&lt;BODY> tag</li>
<li>on DOM load</li>
<li>on PAGE load</li>
</ol>
<p>This is most simply the order of script execution on your page. Before we get too deep into the mechanics of event handling, I will explain in the simplest terms what DOM load and PAGE load is. They are not specific areas where you can drop your code, rather they are points in time during the process of a browser loading the page and it&#8217;s contents. You can write scripts in the HEAD and BODY which tells your browser to execute scripts at those two points in time.</p>
<p>The moment at which the document is loaded and ready, but before any external references are even downloaded yet, is DOM load. By external references, I am talking about images, referenced style sheets, etc. After the document is ready, your browser starts to download those external resources (images, stylesheets, etc). When those resources are completely downloaded and displayed, this is the point in time when the PAGE is loaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2010/07/07/javascript-essentials-execution-order-selectors-dom-manipulation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utada In The Flesh Experience</title>
		<link>http://www.buyco.ca/2010/01/26/utada-in-the-flesh-experience/</link>
		<comments>http://www.buyco.ca/2010/01/26/utada-in-the-flesh-experience/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 22:33:29 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[concert]]></category>
		<category><![CDATA[Hikaru]]></category>
		<category><![CDATA[Hikki]]></category>
		<category><![CDATA[In the Flesh]]></category>
		<category><![CDATA[Kuma]]></category>
		<category><![CDATA[Seattle]]></category>
		<category><![CDATA[Utada]]></category>
		<category><![CDATA[Utada Hikaru]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=144</guid>
		<description><![CDATA[My feet were so sore, my legs were numb, and I was tired as hell. The trip started off with a drive to Seattle, WA leaving from Vancouver, BC at around 9:30am. Seems pretty early to me especially if we wanted to be at the Showbox by 4, but it gave us a chance to [...]]]></description>
			<content:encoded><![CDATA[<p>My feet were so sore, my legs were numb, and I was tired as hell. The trip started off with a drive to Seattle, WA leaving from Vancouver, BC at around 9:30am. Seems pretty early to me especially if we wanted to be at the Showbox by 4, but it gave us a chance to stop by the outlets on the way—where I got an awesome Burberry sweater for the low discounted price of $200. After explaining to Will we’d be late, and laughing at the picture of his reaction when we told him, we made our way downtown.</p>
<p><a href="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940616774_507796774_3426743_7230388_n.jpg" rel="shadowbox[En-Route]" title="On our way!"><img src="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940616774_507796774_3426743_7230388_n-150x150.jpg" alt="toad" title="toad" width="150" height="150" class="alignnone size-thumbnail wp-image-146" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/01/m1_414426.jpg" rel="shadowbox[En-Route]" title="New Cardigan"><img src="http://www.buyco.ca/wp-content/uploads/2010/01/m1_414426-150x150.jpg" alt="New Sweater" title="New Sweater" width="150" height="150" class="alignnone size-thumbnail wp-image-149" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/01/photo.jpg" rel="shadowbox[En-Route]" title="Will's reaction"><img src="http://www.buyco.ca/wp-content/uploads/2010/01/photo-150x150.jpg" alt="will" title="will" width="150" height="150" class="alignnone size-thumbnail wp-image-157" /></a></p>
<p>It was only 2:30pm when we circled 1st and Union, so we thought we were doing fairly well in terms of timing for the show. 10 mins of debating on parking was followed by a stroll by the Showbox just to check out the scenery. Unfortunately the scenery included a lineup on the street for the show. There were only about 10 people there, but we didn’t want to take any chances and waited in line anyways.</p>
<p><a href="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940631774_507796774_3426744_7623039_n.jpg" rel="shadowbox[Lineup]"><img src="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940631774_507796774_3426744_7623039_n-150x150.jpg" alt="Lineup at 3" title="Lineup at 3" width="150" height="150" class="alignnone size-thumbnail wp-image-151" /></a></p>
<p>While standing in line with Will, hours before the show even started, I saw one of my old coworkers lining up to go to the same show. What a coincidence! Later on in the evening I ended up seeing another coworker there too. After a quick exchange of our expectations on how awesome the show was going to be, we went back to our spots in line.</p>
<p>At around 4:30pm we got the option to go into the bar (Green Room) beside the venue where we’d get even better priority over those in line. Interesting way of doing things actually—instead of waiting in the line, they offer you a seat in the bar and give you a number (1-5 based on priority). When they start letting people in for the show, they first allow those at the bar in based on their number. It’s a nice way to keep those, who show up early, nice and comfortable before the show. So, for the next 2 and a half hours we had some drinks, talked about how awesome the night is going to be, and played a bastardized version of Chai Mui.</p>
<p><a href="http://www.buyco.ca/wp-content/uploads/2010/01/green_room.jpg" rel="shadowbox[Drinking]" title="The Green Room"><img src="http://www.buyco.ca/wp-content/uploads/2010/01/green_room-150x150.jpg" alt="Green Room" title="Green Room" width="150" height="150" class="alignnone size-thumbnail wp-image-152" /></a></p>
<p>They finally started letting people in at around 7pm, starting with us in the Green Room. After the quick frisk, and ticket check, there was a mad rush to the front of the stage to get the best spots. Lucky us, we found spots just off center and behind a couple midgets (not literally, but rather—hilariously). The four of us had a strategy of creating empty space in the middle of us, allowing room for crumple during the concert—which eventually worked well! After the first hour of waiting, we started getting impatient.</p>
<p>My feet were so sore, my legs were numb, and I was tired as hell.</p>
<p>DJ Mike Rizzo jumped on stage and started amping up the crowd. Unfortunately, it didn’t work on me because I don’t listen to the radio and reason being: top 40 doesn’t entertain me. An hour later I could feel the tension in the crowd and within me. We were already waiting for 5 hours and still no sign of her. At about 9:15pm, Mike blurts out—she’ll be out in 15 minutes! The whole venue goes crazy!</p>
<p>15 minutes later he says: “She’ll be here in 15 minutes!”</p>
<p>Another uproar, but I stood there pouting. At this point in my head I’m thinking, holy crap we’re going through a lot for this show. After 15 minutes of an internal debacle with myself, Mike leaves the stage and the roadies start setting up! My resting heart rate just jumped from 75 to 100!</p>
<p>For about 15 minutes, I worry that I’m going to pass out from all the excitement—then the music starts, and then Utada Hikaru kicks off with On and on! I can’t even explain how I felt, how it was like to be arms length away from her, to look in her eyes and receive the most beautiful smile back!</p>
<p>The show only got better and better. After a few English songs, she starts some dialogue and even at the introduction to her Japanese songs, the crowd went nuts! I went nuts! She did a few songs while on the keyboard as well. And I quote, “This is a keyboard!” When she started singing First Love I was afraid I wouldn’t hear her because of all the crowd singing along, but her voice of course broke through and was amazing! Every song she sang brought chills down my spine. Hikki’s voice was perfect all night, and every song sounded as beautiful as the first time I heard them.</p>
<p>Throughout the concert, cameras were disallowed, and I’m okay with that. There’s no way I’d forget those memories! There was, although, someone between us and the stage beside the bouncer taking photos. In between songs I looked… and it was Keiko Fuji aka Utada Junko, Hikki’s mom! I was in the presence of greatness! Being in such an intimate setting is beyond words. The venue was not very big, but it was packed! I’d compare it to about double the size of the venue stages during her United tour. We were up at the front with our eyes glued to Hikki, but I did get a chance to take a glance behind us and there wasn’t an inch of unmanned/unwomaned floor!</p>
<p>As the concert was coming to a close, she said her goodbyes and left the stage. Then we kept screaming for an encore. After about 2 minutes of screaming her name they came back on stage! Hikki ended off with Simple and Clean (with the awesome la da da da da da da ending). It looked like she grabbed her bag to leave, but it was actually a bag of 6-8 signed kumabucks balls! She began throwing them into the crowd and I was afraid I’d get trampled by other frantic fans.</p>
<p>So, you can think otherwise, but this is how it played out: she had a few left, and came back to the mid-left side of the stage (where we were). As she was grabbing a ball I was looking directly at her and she looked up, saw me and smiled, then tossed me the ball. It was all in slow motion in my brain and I’ll never forget those 5 seconds of my life (I sound like a creep right now lol). I couldn’t believe it, but it happened… and now my friends and gbones beside me at the concert hate me forever.</p>
<p><a href="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940651774_507796774_3426746_4188476_n.jpg" rel="shadowbox[Ball]" title="Boku wa kuma!"><img src="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940651774_507796774_3426746_4188476_n-150x150.jpg" alt="kumabucks" title="kumabucks" width="150" height="150" class="alignnone size-thumbnail wp-image-153" /></a> <a href="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940661774_507796774_3426747_4401024_n.jpg" rel="shadowbox[Ball]" title="EEEE!!!!"><img src="http://www.buyco.ca/wp-content/uploads/2010/01/20655_265940661774_507796774_3426747_4401024_n-150x150.jpg" alt="utadaball" title="utadaball" width="150" height="150" class="alignnone size-thumbnail wp-image-154" /></a></p>
<p>It was the most amazing night ever! I had so much fun, and couldn’t have asked for more (well, I could but that’d just be greedy). I don’t think I could ever go to another concert and have the same connection or feeling of bliss like I did at this one.</p>
<p>My feet were so sore, my legs were numb, and I was tired as hell.</p>
<p>…3 hours with Utada’s voice was well worth it</p>
<hr noshade size="1" color="#cccccc" />
<p>Links:<br />
<a href="http://www.utada.com/photos/default.aspx?fid=6385" target="_blank">Official Tour Photos</a><br />
Video clips and audio (removed these links, I guess you had to be there)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2010/01/26/utada-in-the-flesh-experience/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Leveraging JavaScript Frameworks to Make Your Life Easier</title>
		<link>http://www.buyco.ca/2009/08/28/leveraging-javascript-frameworks-to-make-your-life-easier/</link>
		<comments>http://www.buyco.ca/2009/08/28/leveraging-javascript-frameworks-to-make-your-life-easier/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 09:51:44 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Dev Tips and Tricks]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=132</guid>
		<description><![CDATA[Are you all about programming in JavaScript? Save yourself some time and try implementing a scripting framework. ]]></description>
			<content:encoded><![CDATA[<h4>Framework Preface</h4>
<p>Are you a hardcore JavaScript/AJAX programmer who knows no bounds? Do you spend meticulous hours perfecting your code so it works on all browsers? I used to be like that. I still am, but the only difference is that I now don&#8217;t spend hours testing my code. This is mostly attributed to the Prototype framework. Today I&#8217;m going to go through a few features and benefits of using a JavaScript framework over writing custom code yourself which may require testing and re-testing. Of course there is still the need for testing even when using a framework, but the difference is that there will be a lot of cross-browser compliance which is no longer needed.
<p>There are other frameworks out there like jQuery and MooTools, but today we&#8217;ll start with what I&#8217;m more familiar with and with what I first started with. The documentation for Prototype is very thorough and I don&#8217;t want to explain everything, so I&#8217;ll start off with the major items which will change your JavaScript programming life!</p>
<h4>JavaScript Framework? Double you tee eff?</h4>
<p>You&#8217;re asking the right question. For the longest time I was always stuck in my own little JavaScript world where everything I coded was job-specific, customized, and with my own techniques. There were also little quirks which JavaScript had when rendering/running under different browsers/operating systems&#8211;these too were also solved using my own super secret techniques. What Prototype does, as well as other JavaScript frameworks, is give you the simple building-blocks which solve those quirks without you even needing to address them specifically. For example, if you want a <em>div</em> element to show or hide, you simply select the element and program the action. Sounds simple, but selecting that element requires some browser detection and compatibility verification. Let&#8217;s make a couple comparisons..</p>
<h4>Make your life easier</h4>
<p>Continuing on with the previous example, let&#8217;s select that <em>div</em> element given the following markup:</p>
<pre class="brush: xml">
&lt;div id="copy">
	&lt;p>Lorem ipsom dolor sit amet&lt;/p>
&lt;/div>
</pre>
<p>We&#8217;re not going to think of any invokers right now, let&#8217;s just try to hide the <em>div</em>. Here is what the JavaScript may have looked like prior to using Prototype:</p>
<pre class="brush: jscript;">
var objDivId = 'copy';
objDiv = document.layers ? document.layers[objDivId] : document.all ? document.all[objDivId] : document.getElementById ? document.getElementById(objDivId) : null;
objDiv != null ? objDiv.style.display = 'none' : '';
</pre>
<p>Obviously this isn&#8217;t the most efficient way of doing this, ideally I would create a function, but this is the shortest of shorthands to select and hide the <em>div</em> element while respecting all web browsers. Now let&#8217;s have a look at how this would look using the Prototype framework:</p>
<pre class="brush: jscript;">
var objDivId = 'copy';
objDiv = $(objDivId);
$(objDivId) ? $(objDivId).style.display = 'none' : '';
</pre>
<p>For this example, the difference is quite apparent. By using the $() utility method we can quickly select that <em>div</em> element without the worry of what browser is being used. Now, let&#8217;s see what happens when we try to hide more than one element. First here&#8217;s the HTML markup:</p>
<pre class="brush: xml">
&lt;div id="copy">
	&lt;p>Lorem ipsom dolor sit amet&lt;/p>
&lt;/div>
&lt;div id="button">
	&lt;p>This is a button&lt;/p>
&lt;/div>
&lt;div id="preview">
	&lt;p>This is a preview section&lt;/p>
&lt;/div>
</pre>
<p>I&#8217;m going to create a function to hopefully help the cause of the traditional JavaScript code and see how it compares to using Prototype. First the oldschool method:</p>
<pre class="brush: jscript;">
function getObject(id) {
	return document.layers ? document.layers[id] : document.all ? document.all[id] : document.getElementById ? document.getElementById(id) : null;
}
var objDivIds = new Array('copy','button','preview');
for (var i=0; i&lt;objDivIds.length; i++) {
	objDiv = getObject(objDivIds[i]);
	objDiv.style.display = 'none';
}
</pre>
<p>And now the code for doing the same thing using Prototype:</p>
<pre class="brush: jscript;">
$('copy','button','preview').invoke('hide');
</pre>
<p>Say what!? Yeah, it&#8217;s that easy. The traditional method utilizes a function which will return the object instance. We then iterate through the three <em>div</em> elements and update each one individually.</p>
<p>In the Prototype version, we&#8217;re using a couple of included extensions. First, the selector $() utility method returns an Enumerable list of objects, and the <em>hide</em> function is invoked across all of those objects. Easy fo-sheezy.</p>
<p>There are also other ways of selecting multiple elements within a page. You can do this by applying some CSS knowledge. For example, let&#8217;s attach a tracking script to all of the links within a page. We want to first select all of the <em>A</em> elements, then iterate through them by adding a short querystring tag to it&#8217;s <em>href</em> attribute.</p>
<pre class="brush: jscript;">
var _TAG = '?source=buyco.ca';
$$('a').each(function(objA) {
	var url = objA.getAttribute('href');
	objA.setAttribute('href',url+_TAG);
});
</pre>
<p>This time I&#8217;m using the $$() utility method which will select a collection of elements. It takes in CSS-style selectors, such as: &#8216;a.external&#8217; (select all a elements with the classname external), or &#8216;div#nav ul li&#8217; (select all list items in the div with the id of &#8216;nav&#8217;). The full documentation on this can be found on the <a href="http://www.prototypejs.org/api/utility" title="Prototype API" target="_blank">Prototype API documentation website</a>.</p>
<h4>Post face?</h4>
<p>These are two short examples of a few things you can do (quicker) by utilizing a JavaScript framework. You will spend less time focused on browser compliance and more on the functionality and interactivity of your websites. It&#8217;s not a quick transition, but practice does make perfect! The documentation on the <a href="http://www.prototypejs.org/" target="_blank" title="Prototype JS">Prototype website</a> is awesome, and I still find myself going back to learn new things. The main point I&#8217;m trying to get across here is that there are tools out there to make our lives (as web developers) a whole lot easier. Don&#8217;t get stuck in a place where you&#8217;re too comfortable or you&#8217;ll end up writing IE6-compliant code forever. Spend your time on more important things like user-experience, and wicked-awesome-flashy-effects. Your site visitors will thank you:)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2009/08/28/leveraging-javascript-frameworks-to-make-your-life-easier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing with Image Sprites and CSS for Beginners (Part 2)</title>
		<link>http://www.buyco.ca/2009/08/27/optimizing-with-image-sprites-and-css-for-beginners-part-2/</link>
		<comments>http://www.buyco.ca/2009/08/27/optimizing-with-image-sprites-and-css-for-beginners-part-2/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 09:34:02 +0000</pubDate>
		<dc:creator>Buyco</dc:creator>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[How to]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[sprites]]></category>

		<guid isPermaLink="false">http://www.buyco.ca/?p=118</guid>
		<description><![CDATA[I know what a sprite is. Now what do I do?!]]></description>
			<content:encoded><![CDATA[<h4>I know what a sprite is, now what?</h4>
<p>In Part 1 of <a title="Optimizing with Image Sprites and CSS for Beginners" href="http://www.buyco.ca/2009/06/30/optimizing-with-image-sprites-and-css-for-beginners-part-1/">Optimizing with Image Sprites and CSS for Beginners</a> I went through an explanation of what sprites are, how they work, and why to even bother. This time around we&#8217;re going to jump into some implementation of these sprites. I am still calling this Beginner stuff (only so that I can hit everyone with some hardcore code in the future), but if you happen to get confused follow me on <a title="Follow Jonathan Buyco on Twitter" href="http://twitter.com/jonathanbuyco" target="_blank">Twitter</a> and ask away!</p>
<h4>What am I going to use the sprite for?</h4>
<p>First let&#8217;s figure out what we&#8217;re even going to use the sprite for. When you&#8217;re ready to start slicing up your design, use your intuition and think of the graphical elements which will be used and reused on your site; this usually includes your navigation and maybe some buttons. In this example I&#8217;m going to use a sprite to create a &#8220;close&#8221; button and a textual navigation bar (SEO FTW). Here&#8217;s what I&#8217;ll be working with:</p>
<p><img src="/images/sprites.gif" alt="sprites" /></p>
<h4>Let&#8217;s open with a close</h4>
<p>This is the close button which I want sprite-ized:</p>
<p><a id="close" title="Close this badboy" href="#">Close</a></p>
<p>Your processes may be different, but I always start off with the HTML markup. The reason is because I want it as clean as possible and easily accessible for our search crawler friends. With a few quick keystrokes and a little touch of magic, this is what my markup for the close button looks like:</p>
<pre class="brush: xml;">&lt;a href="/close" title="Close this badboy" id="close"&gt;Close&lt;/a&gt;</pre>
<p>That was easy! Now let&#8217;s fancy this up with a bit of CSS magic and add the graphical close icon:</p>
<pre class="brush: css;">a#close {
	display: block;
	height: 14px;
	line-height: 14px;
	font: 11px 'Verdana','Arial',sans-serif;
	padding-left: 20px;
	background: url(sprites.gif) -32px -100px no-repeat;
}
a#close:hover {
	background-position: -32px -114px;
}
a#close:active {
	background-position: -32px -128px;
}</pre>
<h4>Wait.. what?</h4>
<p>I skipped about 20 steps there, so let&#8217;s go through this line by line:</p>
<pre class="brush: css; first-line: 2">	display: block;</pre>
<p>We need to give our link element layout so the graphic doesn&#8217;t get cropped. Display as <em>block</em>, kablammo problem solved! Almost..</p>
<pre class="brush: css; first-line: 3">	height: 14px;</pre>
<p>The close button consists of a 14&#215;14 area on our sprite map. We need to set the <em>height</em> so we don&#8217;t get any cropping.</p>
<pre class="brush: css;first-line: 4">	line-height: 14px;
	font: 11px 'Verdana','Arial',sans-serif;</pre>
<p>This part is a bit arbitrary. I set the <em>line-height</em> just so the text is vertically positioned evenly, and the font is a tribute to <a title="Ikea says Goodbye to Futurea" href="http://www.idsgn.org/posts/ikea-says-goodbye-to-futura/" target="_blank">Ikea</a> (don&#8217;t hurt me <img src='http://www.buyco.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ).</p>
<pre class="brush: css;first-line: 6">	padding-left: 20px;
	background: url(sprites.gif) -32px -100px no-repeat;</pre>
<p>The fun part! The <em>padding</em> is there so that the text for &#8220;close&#8221; is shifted to the right and not disturbing the space for the graphic. But where the hell did I get the -32px -100px from? It&#8217;s the sprite&#8217;s position! 32 pixels from the left, and 100 pixels from the top. An easy way of finding your graphic positions in your sprite map is to open up the file in Photoshop, use the rectangular marquee tool (M), then start a selection from the top left of the document and end at the topmost and leftmost of the graphic. Check your Info window (F8) and take note of the width and height of your selection&#8211; and there are your positioning coordinates!</p>
<pre class="brush: css;first-line: 9">a#close:hover {
	background-position: -32px -114px;
}
a#close:active {
	background-position: -32px -128px;
}</pre>
<p>These modifiers are just added to give a hover and click effect to the button. The only style changing here is the position of the background which then points to the coordinates of the hover and active states. Put this all together and you have yourself a close button!</p>
<p>I obviously geared the markup for this single example, not taking into account that you may want to reuse the code. With just a small change to select the class of the elements instead of styling based on ID, you can have multiple instances of this button:</p>
<pre class="brush: css;">a.close {
	display: block;
	height: 14px;
	line-height: 14px;
	font: 11px 'Verdana','Arial',sans-serif;
	padding-left: 20px;
	background: url(sprites.gif) -32px -100px no-repeat;
}
a.close:hover {
	background-position: -32px -114px;
}
a.close:active {
	background-position: -32px -128px;
}</pre>
<p>For you newbies: it&#8217;s the dot.</p>
<h4>Navigation Sprite&#8217;ing</h4>
<div id="navigation">
<ul>
<li><a href="#1"><span id="nav-first"> </span><span>Link 1</span></a></li>
<li class="splitter"></li>
<li><a href="#2"><span>Link 2</span></a></li>
<li class="splitter"></li>
<li><a href="#3"><span>Link 3</span></a></li>
<li class="splitter"></li>
<li><a href="#4"><span>Link 4</span></a></li>
<li class="splitter"></li>
<li><a href="#5"><span id="nav-last"> </span><span>Link 5</span></a></li>
</ul>
</div>
<p><br style="clear: both;" /></p>
<p>This may seem a bit more advanced, but I am using very similar techniques as the example above. Once again, I&#8217;ll start off with the markup:</p>
<pre class="brush: xml;">
&lt;div id="navigation"&gt;
	&lt;ul title="Jon's awesome navigation"&gt;
		&lt;li&gt;&lt;a href="link1" title="link 1"&gt;&lt;span id="nav-first"&gt;&lt;/span&gt;&lt;span&gt;Link 1&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li class="splitter"&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="link2" title="link 1"&gt;&lt;span&gt;Link 2&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li class="splitter"&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="link3" title="link 1"&gt;&lt;span&gt;Link 3&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li class="splitter"&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="link4" title="link 1"&gt;&lt;span&gt;Link 4&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li class="splitter"&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="link5" title="link 1"&gt;&lt;span id="nav-last"&gt;&lt;/span&gt;&lt;span&gt;Link 5&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;</pre>
<p>Wow that looks like some dirty code. Forgive me for the empty <em>span</em> tags, it&#8217;s getting late. I&#8217;m assuming everyone&#8217;s navigation markup looks pretty similar to this, so it shouldn&#8217;t be much of a stretch to update your style sheets. Speaking of which, here they are for this example:</p>
<pre class="brush: css;">div#navigation {
	font: 11px 'Verdana','Arial',sans-serif;
}
div#navigation ul {
	margin: 0;
	padding: 0;
	height: 50px;
	background: url(sprites.gif) 0 0 repeat-x;
	float: left;
	list-style-type: none;
}
div#navigation ul li {
	float: left;
	display: block;
	width: 50px;
}
div#navigation ul li.splitter {
	width: 2px;
	height: 50px;
	background: url(sprites.gif) -7px -100px no-repeat;
	float: left;
}
div#navigation ul li a {
	display: block;
	height: 50px;
	line-height: 50px;
	color: #606;
	text-decoration: none;
}
div#navigation ul li a:hover {
	background: url(sprites.gif) 0 -50px repeat-x;
	color: #404
}
div#navigation ul li a span	{
	display: block;
	padding: 0 5px;
}
div#navigation ul li a span#nav-first {
	display: block;
	position: absolute;
	padding: 0 !important;
	width: 6px;
	height: 50px;
	background: url(sprites.gif) 0 -100px no-repeat;
}
div#navigation ul li a:hover span#nav-first {
	background: url(sprites.gif) -16px -100px
}
div#navigation ul li a span#nav-last {
	display: block;
	position: absolute;
	margin: 0 0 0 44px;
	padding: 0 !important;
	width: 6px;
	height: 50px;
	background: url(sprites.gif) -10px -100px no-repeat;
}
div#navigation ul li a:hover span#nav-last {
	background: url(sprites.gif) -26px -100px;
}</pre>
<p>Quite a bit of styles. It&#8217;s okay though, you&#8217;ve obviously gone through the first example a million times already, so this should be a breeze.</p>
<p>Now, a lot of the styling is there just for aesthetics so we&#8217;ll skip all of that. Let&#8217;s just jump to the areas where we&#8217;re using sprites:</p>
<pre class="brush: css;first-line: 4">div#navigation ul {
	margin: 0;
	padding: 0;
	height: 50px;
	background: url(sprites.gif) 0 0 repeat-x;
	float: left;
	list-style-type: none;
}</pre>
<p>Here we are actually going to be repeating the sprite as the background in the x direction because I want this navigation bar to expand in the event of new sections. When creating a sprite with the intention of repeating it as a background, keep in mind that they can only be repeated in one direction: x or y. You cannot repeat a slice of a sprite in both directions, otherwise you may have other graphics in the sprite included in the repetition. Looking back at the original sprite, this background can be repeated in the x direction since there are no other slices to the left or right of that area.</p>
<pre class="brush: css;first-line: 30">div#navigation ul li a:hover {
	background: url(sprites.gif) 0 -50px repeat-x;
	color: #404
}</pre>
<p>Skipping all the positioning and font styles, I want to add a hover effect. Once again I&#8217;m utilizing a repeating background in the x-direction. The position is found using my marquee technique above.</p>
<pre class="brush: css;first-line: 17">div#navigation ul li.splitter {
	width: 2px;
	height: 50px;
	background: url(sprites.gif) -7px -100px no-repeat;
	float: left;
}</pre>
<p>I thought the navigation bar would look a little weird without having some kind of splitter between each option, so the styles above should take care of that. Here I am actually specifying the width because I do not want the background to repeat.</p>
<pre class="brush: css;first-line: 38">div#navigation ul li a span#nav-first {
	display: block;
	position: absolute;
	padding: 0 !important;
	width: 6px;
	height: 50px;
	background: url(sprites.gif) 0 -100px no-repeat;
}
div#navigation ul li a:hover span#nav-first {
	background: url(sprites.gif) -16px -100px
}
div#navigation ul li a span#nav-last {
	display: block;
	position: absolute;
	margin: 0 0 0 44px;
	padding: 0 !important;
	width: 6px;
	height: 50px;
	background: url(sprites.gif) -10px -100px no-repeat;
}
div#navigation ul li a:hover span#nav-last {
	background: url(sprites.gif) -26px -100px;
}</pre>
<p>Here I&#8217;m just being a little fancy and adding the smooth bits at each end of the navigation bar. Essentially the same techniques used above.</p>
<h4>Holy Crap!</h4>
<p>Yeah, it&#8217;s a lot to take in but I didn&#8217;t lie when I said this was a beginner guide because I assume everyone reading this is an expert with CSS.</p>
<p>The examples above are merely examples. I hope no one copy-and-pastes the markup because it won&#8217;t work for your site (figuratively speaking). I hope you learn from what was presented above, test out your own techniques, and apply it in your daily web development ventures. The best way of learning is to do it yourself, this guide is only here as a guide and also because I have nothing better to do at 2:00AM on a Wednesday morning <img src='http://www.buyco.ca/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.buyco.ca/2009/08/27/optimizing-with-image-sprites-and-css-for-beginners-part-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

