<?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>Dwight Jack Diary &#187; JavaScript</title>
	<atom:link href="http://www.dwightjack.com/diary/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dwightjack.com/diary</link>
	<description>Diary of music, design and code</description>
	<lastBuildDate>Tue, 13 Jul 2010 20:46:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Taming Flash Of Unstyled Content without blocking JavaScript loading</title>
		<link>http://www.dwightjack.com/diary/2010/06/10/taming-flash-of-unstyled-content-without-blocking-javascript-loading/</link>
		<comments>http://www.dwightjack.com/diary/2010/06/10/taming-flash-of-unstyled-content-without-blocking-javascript-loading/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 16:23:19 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jajasvcript]]></category>
		<category><![CDATA[labjs]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=293</guid>
		<description><![CDATA[A smart way to overcome FOUC while still using LABjs as JavaScript non-blocking loading techniques.]]></description>
			<content:encoded><![CDATA[<p>One of the best rule in development is <strong>that the less you (as developper) struggle, the more the user will</strong>&#8230; and viceversa.</p>
<p>Lately i&#8217;ve tested some techniques to overcome the blocking nature of <code>script</code> tags to improve page load performance, and i ended up using <a href="http://labjs.com/" target="_blank"><strong>LABjs</strong></a> which seems a really promising project.<br />
 The main drawback of this non blocking  technique is that, since JavaScript parsing is not blocking the interface anymore users may encounter several flash of unstyled (or un-behaviored) content (<strong>FOUC &#8211; FUBC</strong>), which may break the interface (and make your marketing team screams at you).</p>
<p>The solution here is: <strong>struggle a bit more</strong> instead of leaving <code>script</code> tags in the <code>head</code>.</p>
<p>What i&#8217;ve came up by following some suggestions by the LABjs author and the web community is to separate my CSS styles in two separate levels: <strong>one for un-behaviored contents and one for JavaScript enabled browsers</strong>. <br />
 The trick is simple: since the only tag script you need is the one of LABjs, just open it and add this line at the very top of the file:</p>
<pre class="javascript"><code>
document.documentElement.className = 'hasJS';
</code>
</pre>
<p>This way you will add a <code>hasJS</code> class to the <code>html</code> tag that you may target in the CSS rules to overwrite and implement styles to get your interface ready for JavaScript interactions.</p>
<p>The drawback of this technique is that <strong>adding a class attibute to html tag won&#8217;t validate</strong>, but that&#8217;s the only CSS addressable node before DOM ready event.</p>
<p>This way your interface won&#8217;t flash anymore and your users won&#8217;t notice any change while JavaScript is getting loaded in a more efficient way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2010/06/10/taming-flash-of-unstyled-content-without-blocking-javascript-loading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Review: MooTools 1.2 Beginner&#8217;s Guide</title>
		<link>http://www.dwightjack.com/diary/2010/03/27/review-mootools-1-2-beginners-guide/</link>
		<comments>http://www.dwightjack.com/diary/2010/03/27/review-mootools-1-2-beginners-guide/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 14:24:26 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=269</guid>
		<description><![CDATA[One major problem with JavaScript programming is that, differently from other languages, there are little programmers with really good knowledge of it.
 This problem is tightly related to the lack of a solid culture in front-end development, which usually is a gray area between programmers and designers.
Even if a solid knowledge of JavaScript should be [...]]]></description>
			<content:encoded><![CDATA[<p>One major problem with JavaScript programming is that, differently from other languages, there are little programmers with really good knowledge of it.<br />
 This problem is tightly related to the <strong>lack of a solid culture in front-end development</strong>, which usually is a gray area between programmers and designers.</p>
<p>Even if a solid knowledge of JavaScript should be a must, a good way to avoid bad practices and headaches is by <strong>using a JavaScript library</strong>, which will make coding easier and much more beginner friendly.</p>
<p><strong><a href="http://mootools.net/" target="_blank">MooTools</a></strong> is such a library, and offers a lot of methods and patterns for better JavaScript coding.</p>
<h3>Introducing MooTools 1.2 Beginner&#8217;s Guide</h3>
<p><a title="MooTools 1.2 Beginner's Guide" href="http://www.packtpub.com/mootools-1-2-beginners-guide/book?utm_source=dwightjack.com&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002378" target="_blank"><img class="size-medium wp-image-249 right  alignright" style="margin-left: 10px; float: right" title="MooTools 1.2 Beginner's Guide" src="http://www.dwightjack.com/diary/wp-content/uploads/2010/02/MOOTOOLS-243x300.jpg" alt="" width="219" height="270" /></a> Even if I&#8217;m not a MooTools novice, i had the chance to read <strong><a href="http://www.packtpub.com/mootools-1-2-beginners-guide/book?utm_source=dwightjack.com&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002378" target="_blank">MooTools 1.2 Beginners Guide</a></strong> by Jacob Gube and Garrick Cheung (<a href="https://www.packtpub.com/" target="_blank">Packt Publishing</a>), which turned out to be also an interesting reading to better understand all of the improvements made by <strong>MooTools</strong> from the 1.11 version.</p>
<p>From this perspective the book, which aims primarily to beginner MooTools developers, may also be a good reference for users of previous versions willing to update their scripts.</p>
<p>That said, the book doesn&#8217;t cover all of the methods offered by the library, but <strong>is intended by the authors as a step by step introduction to MooTools development</strong> and gives a solid knowledge of its undergoing philosophy.</p>
<p>The approach is strongly examples-oriented to better and clearly show how the library works and to give some starting point for developers willing to practice <em>hands-on</em>.</p>
<h3>The Good Parts</h3>
<p>The guide&#8217;s table of contents spans from the core <code>$</code> function to the plugin&#8217;s usage and factoring, introducing the most relevant and commonly used part of the library. Writing is fluent and familiar keeping it <em>easy</em> while accurate.</p>
<p>First of all, I really appreciated the well done part about <strong>utility functions</strong> which are, in my opinion, one of the library&#8217;s key features since they make possible to save lot of repetitive coding: functions like <code>$type</code>, <code>$each</code> or the <code>Browser</code> object grant a cross-browser and <strong>risk free development with little effort</strong>.</p>
<p>The other aspect which is deeply covered is the <code>Class</code> construction pattern. <br />
 By using this pattern every novice developer is able to code JavaScript classes with syntax similar to other programming languages like PHP, thus filling the lack of real classes in JavaScript and <strong>avoiding global object pollution</strong>.</p>
<p>Also well documented is the animation chapter about <code>FX</code> classes, which still are the best choice for performance and browser rendering (<code>FX</code> has been the first part of the original library).</p>
<p>A full chapter at the end of the book is dedicated to <strong>plug-in development</strong>, featuring not only an explanation on how write a plug-in, but also <strong>teaching how to design a plug-in</strong> starting from existing scripts and reusability requirements. <br />
 This part has been<strong> an unexpected surprise</strong>, since few guides intended for technical audience <em>teach</em> code&#8217;s design process with design sheets and documentation guidelines.</p>
<h3>Beyond Examples</h3>
<p>As of its introduction, the guide is intended as a step by step process in learning the bases in MooTools development; anyway little effort is spent in explaining <em>why</em> using MooTools is not just a smarter way of coding, but also and above all a <em>better</em> approach to JavaScript.</p>
<p>Learning common scripting mistakes is the way to understand that using a library is not just <em>cool</em> and that libraries aren&#8217;t vital, <strong>but still an affordable toolkit for JS scripting</strong>.</p>
<p>Talking about library presentation, it&#8217;d be a good idea to explain more in details some DOM manipulation methods, since many developers are used to circumvent (often too roughly) document and CSS limits by cutting and remixing elements with JavaScript. <br />
 MooTools has a big list of such methods which often are a better choice than native JS both for performance and browsers&#8217; support.</p>
<h3>Conclusions</h3>
<p>As a whole, <strong><a href="http://www.packtpub.com/mootools-1-2-beginners-guide/book?utm_source=dwightjack.com&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002378" target="_blank">MooTools 1.2 Beginners Guide</a></strong> gives a clear and solid basic knowledge of how the library works, making it possible for a novice developer to <em>dive</em> into the official documentation without feeling lost.</p>
<p>Even if some background thoughts about its development patterns would be appreciated,<strong> I&#8217;d definitely suggest the book</strong> to MooTools beginners (but not to JavaScript beginners for the mentioned reason). <br />
 Moreover <strong>it&#8217;s a quick reference for commonly used methods and classes</strong>, therefore a book to keep on your desk.</p>
<p>You may check the publisher website to get the complete <a href="https://www.packtpub.com/node/4850" target="_blank"><strong>table of contents</strong></a> and read a <strong><a href="https://www.packtpub.com/sites/default/files/sample_chapters/4589-mootools-1-2-sample-chapter%20No-working-with-events.pdf" target="_blank">sample chapter</a><span style="font-weight: normal;"> or just jump to the book main page <a href="http://www.packtpub.com/mootools-1-2-beginners-guide/book?utm_source=dwightjack.com&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002378" target="_blank"><strong>here</strong></a>.</span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2010/03/27/review-mootools-1-2-beginners-guide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>On the Bookshelf: MooTools 1.2 Beginner&#8217;s Guide</title>
		<link>http://www.dwightjack.com/diary/2010/02/10/mootools-12-beginners-guide/</link>
		<comments>http://www.dwightjack.com/diary/2010/02/10/mootools-12-beginners-guide/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 20:12:13 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[beginners guide]]></category>
		<category><![CDATA[Mootools]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=250</guid>
		<description><![CDATA[In nowadays frontend development JavaScript spans from rich interactions to animations, however we cannot rely on the native language's methods to implement everything we need in a smart and time-effective way.]]></description>
			<content:encoded><![CDATA[<p>In nowadays frontend development JavaScript spans from rich interactions to animations, however we cannot rely on the native language&#8217;s methods to implement everything we need in a smart and time-effective way.</p>
<p><a href="http://www.packtpub.com/mootools-1-2-beginners-guide/book?utm_source=dwightjack.com&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002378"><img class="size-medium wp-image-252   alignright" style="float: right; margin-left: 10px;" title="MooTools" src="http://www.dwightjack.com/diary/wp-content/uploads/2010/02/MOOTOOLS1-243x300.jpg" alt="" width="146" height="180" /></a>The best solution for our coding needs is to adopt a JS framework as backbone for our scripts. One of the very first framework I&#8217;ve worked with is <strong><a title="Mootools" href="http://mootools.net/" target="_blank">Mootools</a></strong>, since it&#8217;s very developer friendly and fulfils lots of JavaScript&#8217;s &#8220;holes&#8221;.</p>
<p>In the next few days i&#8217;m going to receive a copy of:  <a href="http://www.packtpub.com/mootools-1-2-beginners-guide/book?utm_source=dwightjack.com&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002378" target="_blank"><strong>MooTools 1.2 Beginner&#8217;s Guide</strong></a>, which I&#8217;m going to review for the sake of some of my followers and friends which are in need of a good starting point to learn how to improve their interfaces.</p>
<p>If you are interested you can check the details of the guide at the <a href="http://www.packtpub.com/mootools-1-2-beginners-guide/book?utm_source=dwightjack.com&amp;utm_medium=link&amp;utm_content=blog&amp;utm_campaign=mdb_002378" target="_blank">publisher website</a>.</p>
<p>Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2010/02/10/mootools-12-beginners-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Bicycle 1.2: a lightweight JavaScript library</title>
		<link>http://www.dwightjack.com/diary/2009/06/15/bicycle-12-a-lightweight-javascript-library/</link>
		<comments>http://www.dwightjack.com/diary/2009/06/15/bicycle-12-a-lightweight-javascript-library/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 20:53:05 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[ajax framework]]></category>
		<category><![CDATA[javascript framework]]></category>
		<category><![CDATA[javascript library]]></category>
		<category><![CDATA[javascript shortcuts]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=175</guid>
		<description><![CDATA[Bicycle is a lightweight and efficient small library for JavaScript development featuring basic shortcuts and a full wrapper for events, AJAX and form handling]]></description>
			<content:encoded><![CDATA[<p>When i first stepped into JavaScript i found that one of web developers&#8217; common practice  was collecting  snippets of code (in form of prototypes, functions and shortcuts) to overcome both known JavaScript missing features and language&#8217;s verboseness.</p>
<p>Day by day, i&#8217;ve understood why so many developers use libraries (or frameworks) such as <strong>Mootools</strong> or <strong>jQuery:</strong> It&#8217;s a <em>matter of typing</em>.</p>
<pre><code>document.getElementById("test"); //native Javascript
$("#test"); // with jQuery</code></pre>
<p>At the same time i&#8217;ve learnt that <strong>libraries aren&#8217;t always worth their weight</strong>. Small projects don&#8217;t need them, and just writing a shortcut like:</p>
<pre><code>function id(string) {
   return document.getElementById(string);
}</code></pre>
<p>can make your life better (and more lightweight).</p>
<h3>Introducing Bicycle 1.2</h3>
<p><img class="size-full wp-image-184" align="right" style="margin-left:15px;" title="Bicycle 1.2" src="http://www.dwightjack.com/diary/wp-content/uploads/2009/06/bicyclelogo.png" alt="Bicycle 1.2" width="200" height="108" />That said, here is a new version of <strong>Bicycle</strong>, my little &#8220;JavaScript Collection&#8221;. As from the name, it&#8217;s a lightweight and load-cost-effective library (about <strong>9Kb minified</strong>) with everything is needed to <strong>keep your code simple and cross-browser</strong>. Here is a sample code:</p>
<pre><code>var el = $getEls("test");  // get the element with id "test"
var input = $TN("nametext");  // get the first element with name "nametext"</code></pre>
<h3>Chainability</h3>
<p>Anyway, if you need something more, since this new version Bicycle features a convenient <strong>chainability wrapper</strong>, with even new methods such as <strong>mouse and DOM-ready events</strong> and <strong>AJAX handling</strong>.</p>
<p>The chainable structure is bound to the <code>$b</code> namespace, so that you can use it along with other libraries. Here is a sample code:</p>
<pre><code>$b("#test").css("color","red").txt("New text!");</code></pre>
<p>See the <strong><a href="http://www.dwightjack.com/projects/bicycle/symbols/chain_chain-addons.html" target="_blank">documentation</a></strong> for more methods.</p>
<h3>Form Handling</h3>
<p>Finally, as a bonus, i&#8217;ve added a smart piece of code called <strong>Telegraph</strong>, which is basically a<strong> form handling library</strong> to quickly get and manipulate form inputs:</p>
<pre><code>$b.getForm("myForm").value("testinput"); // get an input value
$b.getForm("myForm").serialize(); // serialize form data in a JavaScript object</code></pre>
<h3>Grab a copy</h3>
<p>At last, <em>more code</em> can&#8217;t mean <em>same weight</em>, but i suppose you won&#8217;t mind it, &#8217;cause  Bicycle core + chainability + new methods + Telegraph is just <strong>22Kb minified</strong>.</p>
<p>Head to the main <a title="Bicycle JavaScript library" href="http://www.dwightjack.com/projects/bicycle/about.html" target="_blank"><strong>project page</strong></a> to get more infos and <a href="http://www.dwightjack.com/projects/bicycle/index.html" target="_blank">documentation</a>, or <strong><a title="Download Bicycle 1.2" href="http://www.dwightjack.com/diary/wp-content/plugins/download-monitor/download.php?id=11" target="_blank">grab a copy</a></strong> of the source code and &#8220;<em>take a ride</em>&#8221; with your brand new Bicycle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2009/06/15/bicycle-12-a-lightweight-javascript-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update: Use MooTools v1.2.x in Joomla! 1.5</title>
		<link>http://www.dwightjack.com/diary/2009/06/07/use-mootools-122-in-joomla-15/</link>
		<comments>http://www.dwightjack.com/diary/2009/06/07/use-mootools-122-in-joomla-15/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 14:39:40 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[Joomla 1.5]]></category>
		<category><![CDATA[Mootools]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=167</guid>
		<description><![CDATA[This is an updated version of the code to switch Mootools from 1.11 to 1.2 in Joomla 1.5]]></description>
			<content:encoded><![CDATA[<p>Since i&#8217;ve fixed some bugs and issues on the files to switch core MooTools v1.11 to v1.2.x and following the release of version <span style="text-decoration: line-through;">1.2.2</span> 1.2.3 of <strong>MooTools Core and More</strong>, i&#8217;m posting here an updated version of<a title="Upgrade Mootools to v1.2.x in Joomla! 1.5" href="http://www.dwightjack.com/diary/2009/02/23/upgrade-mootools-to-v12x-in-joomla-15/"> <strong>this workaround</strong></a> to which you could refer for details on how this code works.</p>
<p>Changes in this new version are:</p>
<ol>
<li>Updated MooTools Core to<span style="text-decoration: line-through;"> <strong>1.2.2</strong></span><strong> 1.2.3</strong> and MooTools More to<span style="text-decoration: line-through;"> </span><strong><span style="text-decoration: line-through;">1.2.2.2</span> 1.2.3.1<br />
 </strong></li>
<li>Added <code>.getValue()</code> to the compatibility file</li>
<li>Added <code>.getSelected()</code> to the compatibility file to fix some issues under IE</li>
<li>Added <code>Json</code> support to the compatibility file</li>
<li>Added <code>window.onDomReady</code> shortcut for DOM ready event</li>
<li>Changed <code class="php">MY_Behavior::mootoolsFix();</code> to handle new MooTools files <code class="php"></code></li>
<li>Changed <code class="php">MY_Behavior::mootoolsFix();</code> to correctly render old tooltips format <code>title::text</code> for items with <code>hasTip</code> class (anyway, remember that classes to style the tooltip <a href="http://mootools.net/docs/more/Interface/Tips#Tips:constructor" target="_blank">have changed</a>!)</li>
<li><span style="text-decoration: line-through;">Added a <strong>validate.js</strong> replacement to fix an issue with <a href="http://www.dwightjack.com/diary/2009/02/23/upgrade-mootools-to-v12x-in-joomla-15/comment-page-1/#comment-167" target="_blank">changed namespaces</a>.</span> ( this replacement is no more needed)<span style="text-decoration: line-through;"><br />
 </span></li>
</ol>
<p>The source code is released in the form of patch: unzip it and upload files in your Joomla root, eventually overwriting files. MooTools library is uncompressed to allow for a quicker debug. Anyway you may minify it with your tool of choice.</p>
<p><span style="text-decoration: line-through;">Here is the code: <a href=http://www.dwightjack.com/diary/wp-content/plugins/download-monitor/download.php?id=10>Mootools 1.11 to 1.2.2 (71.68 kB)</a></span></p>
<p><strong>Update (again):</strong> Sometimes i can&#8217;t get if MooTools team is too vital or library milestones are not well defined&#8230; anyway here is an update to use <strong>latest MooTools</strong><strong> 1.2.3</strong>. No major changes have been made to the fix library, anyway keep reporting compatibility issues. Here is the zipped  file: <span style="text-decoration: line-through;"><a href=http://www.dwightjack.com/diary/wp-content/plugins/download-monitor/download.php?id=13>Mootools 1.11 to 1.2.3 for Joomla 1.5 (72.06 kB)</a></span></p>
<p><strong>Update (09/20/09): </strong>New version available. Corrected some bugs in the compatibility file and added a loop check to replace MooTools 1.11 when called from a component as custom script. Now the validation core script doesn&#8217;t need to be replaced. Get source here (carries the original validate.js as in Joomla 1.5.14:  <a href=http://www.dwightjack.com/diary/wp-content/plugins/download-monitor/download.php?id=15>MooTools 1.11 to 1.2.x (72.88 kB)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2009/06/07/use-mootools-122-in-joomla-15/feed/</wfw:commentRss>
		<slash:comments>62</slash:comments>
		</item>
		<item>
		<title>Google Analytics Outbound Link Tracking with jQuery</title>
		<link>http://www.dwightjack.com/diary/2008/12/30/google-analytics-outbound-link-tracking-with-jquery/</link>
		<comments>http://www.dwightjack.com/diary/2008/12/30/google-analytics-outbound-link-tracking-with-jquery/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 20:27:41 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Google Analytics Outbound Tracking]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery plugin]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=67</guid>
		<description><![CDATA[A simple jQuery plugin to track links with Google Analytics]]></description>
			<content:encoded><![CDATA[<p>A usefull feature of Google Analytics is the ability to track outbound links with a simple call to a JS function, which tracks a click on a link to a specifed URL path. You can read more about this subject <strong><a href="http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&amp;answer=55527" target="_blank">here</a></strong>.</p>
<p>The matter is that the code presented by the help page requires an <strong>onClick</strong> attribute, which is actually  deprecated in XHTML.</p>
<p>To overcome this problem here is a simple jQuery plugin which converts any <strong>rev </strong>(or other given) attribute to a Google Analytics friendly tracking path (for both old and new versions of the app). Here is a sample code:</p>
<pre><code>&lt;a href="http://www.externalwebsite.com" rev="outbounds www.externalwebsite.com"&gt;visit this site&lt;/a&gt;
</code></pre>
<p>Is tracked as <code>/outbounds/www.externalwebsite.com</code></p>
<p>To apply this plugin call it inside a document loaded function, for example:</p>
<pre><code>$("a").colt();</code></pre>
<p>This calls the plugin on all A tags with an attribute <strong>rev</strong>.<br />
Moreover you can use a custom element attribute by just passing it to the function:</p>
<pre><code>$("a").colt("title");
</code><code></code></pre>
<p>And finally here is the source code:<br />
<a href=http://www.dwightjack.com/diary/wp-content/plugins/download-monitor/download.php?id=2>jQuery.colt.js (908 bytes)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2008/12/30/google-analytics-outbound-link-tracking-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Semantic in-field input label with jQuery</title>
		<link>http://www.dwightjack.com/diary/2008/12/24/semantic-in-field-input-label-with-jquery/</link>
		<comments>http://www.dwightjack.com/diary/2008/12/24/semantic-in-field-input-label-with-jquery/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 08:00:43 +0000</pubDate>
		<dc:creator>Dwight Jack</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery plugin]]></category>
		<category><![CDATA[semantic label]]></category>

		<guid isPermaLink="false">http://www.dwightjack.com/diary/?p=25</guid>
		<description><![CDATA[Recent moods on input fields presentation tend to insert as initial value of an empty form field its label value.
An example of this can be found on the Facebook Homepage.
Though this is a space saving way to show labels and a much more focused way to point out the expected field value, addressing it by [...]]]></description>
			<content:encoded><![CDATA[<p>Recent moods on input fields presentation tend to insert as initial value of an empty form field its label value.</p>
<p>An example of this can be found on the <strong>Facebook Homepage</strong>.</p>
<div id="attachment_28" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-28" title="facebook-input-labels" src="http://www.dwightjack.com/diary/wp-content/uploads/2008/12/facebook-input-labels-300x63.png" alt="Facebook Input Label" width="300" height="63" /><p class="wp-caption-text">Facebook Input Label</p></div>
<p>Though this is a space saving way to show labels and a much more focused way to point out the expected field value, addressing it by the <code>value</code> attribute introduces a semantic issue, since that&#8217;s not at all an initial value, not counting that pulling apart the<code> label</code> tag is an accessibility fault.</p>
<p>To overcome this problem we can rely on the powerfull JavaScript framework <strong><a href="http://www.jquery.com/" target="_blank">jQuery</a></strong>, to build an unobtrusive plugin mantaining both accessibility and usability. Let&#8217;s see:</p>
<p>1) Link the script in the head section:</p>
<pre><code>&lt;script src="jquery.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="jquery.inputLabel.js" type="text/javascript"&gt;&lt;/script&gt;</code></pre>
<p>2) Semantically correct XHTML:</p>
<pre><code>&lt;label for="myInput"&gt;Email here&lt;label&gt;&lt;nput type="text" name="myInput" id="myInput" /&gt;</code></pre>
<p>3) Run the plugin on document load (place this in a script tag before the end of head):</p>
<pre class="js"><code>$(function () {
      $("#myInput").inputLabel();
});
</code></pre>
<p>That&#8217;s all. You can pass an options&#8217; object to change, for example, the inserted value, or to prevent the plugin for running on already filled or pre-filled fields:</p>
<ul class="list">
<li><em>color</em>: initial text color (default : &#8220;#666&#8243;)</li>
<li><em>e</em>: event which triggers label text clearing (default: &#8220;focus&#8221;)</li>
<li><em>force</em>: execute this script even if input value is not empty (default: false)</li>
<li><em>keep</em>: if value of field is empty on blur, re-apply label text (default: true)</li>
</ul>
<p>Check the <strong><a href="http://www.dwightjack.com/demos/inputlabel/" target="_blank">demo page</a></strong> to see the script in action or download the source code below:<br />
<a href=http://www.dwightjack.com/diary/wp-content/plugins/download-monitor/download.php?id=1>jQuery inputLabel Plugin (2.18 kB)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwightjack.com/diary/2008/12/24/semantic-in-field-input-label-with-jquery/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
