<?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; jQuery</title>
	<atom:link href="http://www.dwightjack.com/diary/tag/jquery/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>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>
