<?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>nooshu &#187; jQuery Archives </title>
	<atom:link href="http://nooshu.com/category/javascript/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://nooshu.com</link>
	<description>Kneeling on the shoulders of giants</description>
	<lastBuildDate>Sun, 15 Apr 2012 13:42:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Auto-spacing input field text</title>
		<link>http://nooshu.com/auto-spacing-input-field-text?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=auto-spacing-input-field-text</link>
		<comments>http://nooshu.com/auto-spacing-input-field-text#comments</comments>
		<pubDate>Sun, 25 Mar 2012 05:00:08 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[UX]]></category>
		<category><![CDATA[field]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=2136</guid>
		<description><![CDATA[I've never seen this functionality in any page I've used. Auto-spacing a credit card number as you type. I must admit I'm not a big fan of the idea, but lets build it anyway!]]></description>
			<content:encoded><![CDATA[<p>On a recent project, a set of wireframes landed on my desk which contained some &#8220;interesting&#8221; ideas, particularly when it came to form fields. One that really stood out was having a credit card number auto-space <strong>as the user types</strong> it into a single input box. This of course would depend completely on what type of card they are entering, as different cards have different layouts. American Express for example have a [4, 6, 5] layout, where as Visa use a [4, 4, 4, 4] number layout.</p>
<p>Thankfully this functionality was eventually removed from the UI specifications after concerns from myself and others were raised. Just to make this perfectly clear; I think this is a <strong>bad idea</strong>, and here is why:</p>
<ul>
<li>Users are very wary when it comes entering their credit card details. Spaces magically appearing in their credit card number could freak a few of them out.</li>
<li>Most e-commerce website I&#8217;ve ever used ask for the credit card number as one long string of numbers with no spaces. Auto-spacing goes against this convention, so a user may actually go back and try to remove the spaces (I know I would).</li>
<li>Validation scripts for credit card numbers usually ask for the input to have no spaces, or will remove any spaces on submit.</li>
<li>If you do want to space out the credit card number, why not use different input boxes for each set of numbers? It looks cleaner and is simpler to implement. Just have your JavaScript automatically jump between boxes as the user types.</li>
</ul>
<p>Even though this functionality was removed, I decided to <a href="http://dl.dropbox.com/u/7851949/input-auto-space/index.html">build a prototype</a> of it in action because&#8230; well because I can and I was bored. :) Please, (please!), whatever you do don&#8217;t use this code in production. I created it as an experiment and should be treated that way. It&#8217;s very simple to get around the auto-spacing and then all hell breaks loose! (not really, but it is easy to break).</p>
<p>The spacing is implemented by counting the length of the string inside the input field, but you could also monitor the current position of the cursor. Anyone wishing to do this see this excellent set of answers on <a href="http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea">Stackoverflow</a>.</p>
<p>You can see the prototype <a href="http://dl.dropbox.com/u/7851949/input-auto-space/index.html">here</a>. Remember, don&#8217;t use it. It&#8217;s not big and it&#8217;s not clever :)</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/auto-spacing-input-field-text/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Remote Loading HTML5 Elements with jQuery</title>
		<link>http://nooshu.com/remote-loading-html5-elements-with-jquery?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=remote-loading-html5-elements-with-jquery</link>
		<comments>http://nooshu.com/remote-loading-html5-elements-with-jquery#comments</comments>
		<pubDate>Fri, 18 Nov 2011 10:31:28 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[ie]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1946</guid>
		<description><![CDATA[Working with Internet Explorer is never easy. jQuery takes some of the pain out of it, but not always!]]></description>
			<content:encoded><![CDATA[<p>I ran into a rather annoying problem a few months ago while developing my <a href="http://solostrightnow.com/">travel blog</a>; the problem of course was involving Internet Explorer. I&#8217;m used to working with WordPress as I use it all the time, but I wanted to get away from the standard pagination you find on a blog. So I decided to use jQuery 1.6.4 to pull in articles from other pages (blogname.com/page/2, blogname.com/page/3 etc). Now this is all fairly simple using the handy jQuery .load() method; point it to a URL, pull in the page, pick the bits you need and reinsert into the page. Simple! Unfortunately once I got a prototype working in &#8216;good&#8217; browsers, IE8 and below was having non of it!</p>
<p>After a little head scratching to work out what was failing, I worked out it was because I was using HTML5 elements such as &#8216;article&#8217;, &#8216;header&#8217; and &#8216;footer&#8217;. There was no problem displaying them on the page, as I&#8217;d used Remy Sharps excellent <a href="http://remysharp.com/2009/01/07/html5-enabling-script/">HTML5 Shiv script</a>. It only failed when trying to pull in these &#8216;new&#8217; elements via Ajax.</p>
<p><strong>Note</strong>: Before you read on you&#8217;ll be happy to hear that this issue no longer occurs in <a href="http://blog.jquery.com/2011/11/03/jquery-1-7-released/">jQuery 1.7.0</a>. Horray! </p>
<p>If you can&#8217;t upgrade, for whatever reason, I hashed together a <a href="http://dl.dropbox.com/u/7851949/html5-load-method/index.html">little work-around</a> for browsers IE8 and below, so read on. I admit the work around isn&#8217;t pretty, but it works. I tried for a few hours to get IE8- to recognise the &#8216;new&#8217; elements after an Ajax request, but to no avail. Eventually I had to wrap the HTML5 tags in a div using conditionals:</p>
<div class="codecolorer-container html4strict default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">&lt;!--[if lt IE 9]&gt;&lt;div id=&quot;ieHackContainer&quot;&gt;&lt;![endif]--&gt;</span><br />
<br />
<span style="color: #009900;">&lt;article <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;html5Content&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;header&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>H2 wrapped in a header element<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>header&gt;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Other HTML here... --&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;footer&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>This is the footer element<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>footer&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>article&gt;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!--[if lt IE 9]&gt;&lt;/div&gt;&lt;![endif]--&gt;</span></div></td></tr></tbody></table></div>
<p>The div is added for browsers IE8 and below, you can then use it as a hook to pull in the elements inside the div. I was hoping that wrapping the HTML5 elements in a standard div would be the end of it, I&#8217;m afraid not. The .load() method still didn&#8217;t work, IE just ignored the elements it didn&#8217;t recognise. I used jQuerys much more customisable .ajax() method to fix the issue in IE6, 7 and 8:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//IE8- work around to load HTML5 elements into a page</span><br />
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#loadHTML5LinkOld&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;page_to_load.html&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cache<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> HTML<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Clear before load</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#html5LoadHolder&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//IE: Look for the hacky wrapper before insertion</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTML <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div#ieHackContainer&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//If HTML var is empty assume using newer browsers</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>HTML<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HTML <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#html5Content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Append to page</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#html5LoadHolder&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>HTML<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>This method works in all browsers I&#8217;ve tested in as I&#8217;ve added a fall back (or should that be forward?) for newer browsers. The solution isn&#8217;t ideal (I really hate the conditional comments), but older versions of IE aren&#8217;t going away any time soon, and it works. Maybe there&#8217;s a more obvious solution that I missed? Leave a comment if there is, I&#8217;d love to know!</p>
<p>You can see a working example <a href="http://dl.dropbox.com/u/7851949/html5-load-method/index.html">here</a>. The page I&#8217;m loading from is <a href="http://dl.dropbox.com/u/7851949/html5-load-method/page_to_load.html">here</a> and the JavaScript in full <a href="http://dl.dropbox.com/u/7851949/html5-load-method/js/html5test.js">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/remote-loading-html5-elements-with-jquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual thesaurus using arbor.js</title>
		<link>http://nooshu.com/visual-thesaurus-using-arbor-js?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-thesaurus-using-arbor-js</link>
		<comments>http://nooshu.com/visual-thesaurus-using-arbor-js#comments</comments>
		<pubDate>Sun, 30 Jan 2011 19:30:40 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Experiments]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[experiment]]></category>
		<category><![CDATA[words]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1587</guid>
		<description><![CDATA[Arbor.js is a very impressive graph visualisation library that takes advantage of jQuery and the Web Workers API. I make my own version of the Visual Thesaurus with it.]]></description>
			<content:encoded><![CDATA[<p>Wow, I can&#8217;t believe we are at the end of January &#8211; one twelfth of the year gone already! I&#8217;ve been so busy this month I&#8217;ve barely had time to sit down and work on any personal projects. Thankfully I had a spare few hours over the weekend to work on  a project I&#8217;ve been meaning to finish for a couple of weeks: <a href="http://nooshu.com/explore/arbor-visual-thesaurus/">a visual thesaurus using JavaScript</a>.</p>
<div id="attachment_1588" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2011/01/visual-thesaurus.gif"><img src="http://nooshu.com/wp-content/uploads/2011/01/visual-thesaurus.gif" alt="Visual Thesaurus using JavaScript" title="visual-thesaurus" width="518" height="350" class="size-full wp-image-1588" /></a><p class="wp-caption-text">Visual thesaurus representation of the word 'clean'.</p></div>
<p>You may (or may not) know of the <a href="http://www.visualthesaurus.com/">Visual Thesaurus by Thinkmap</a>; very useful but it&#8217;s a paid for service, I use it so infrequently I can&#8217;t justify paying for it (there is a free trial though). Recently a very interesting graph visualisation library popped up on <a href="http://www.delicious.com/">delicious</a> called <a href="http://arborjs.org/">arbor.js</a>, so I decided to have a closer look and see if I could use it for the JavaScript version. For the word data I&#8217;ve used the <a href="http://words.bighugelabs.com/api.php">Bighugelabs thesaurus API</a> which I previously used to create my <a href="http://nooshu.com/wordpress-plug-in-post-thesaurus/">Post Thesaurus</a> WordPress plug-in (shameless plug!).</p>
<p>Arbor.js took a little getting used to as it uses a mixture jQuery, canvas and its own methods; but there&#8217;s a fairly extensive set of documentation and a set of usage examples. Once you get your head around adding nodes and edges to the system, arbor takes care of the rest. One thing I did notice is the site examples and my VT experiment run much smoother in Firefox than they do in Chrome, which is quite surprising considering how quick the V8 engine is in Chrome. Maybe this will be improved in future versions.</p>
<p>So to the <a href="http://nooshu.com/explore/arbor-visual-thesaurus/">demo</a>; I&#8217;ve tried to keep it very simple to use. Enter the word you wish to visualise and click search. Once the API returns a result it&#8217;s plotted by arbor. You can drill down into the result by clicking on the sub-particles (and remove them by clicking again). The individual words can be clicked and you&#8217;re given the option to search again using the selected word. I still haven&#8217;t got the perfect system setup as some results can be a little jittery; usually when an even set of words are returned. I&#8217;ll keep playing with system settings to see if I can improve this.</p>
<p>Any suggestions, comments or feature improvements please leave a comment below!</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/visual-thesaurus-using-arbor-js/feed</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>jCarousel missing item width</title>
		<link>http://nooshu.com/jcarousel-missing-item-width?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jcarousel-missing-item-width</link>
		<comments>http://nooshu.com/jcarousel-missing-item-width#comments</comments>
		<pubDate>Tue, 12 Oct 2010 10:04:38 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[carousel]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1409</guid>
		<description><![CDATA[jQuery has a host of carousel plug-ins available to use. jCarousel seems to be the most popular. A small error cause a few issues...]]></description>
			<content:encoded><![CDATA[<p>On a recent project the UX team put together a set of wireframes where the use of <a href="http://developer.yahoo.com/ypatterns/selection/carousel.html">carousels</a> featured heavily. Luckily when you choose a JavaScript library like jQuery you have quite a few carousel plug-ins to choose from. I&#8217;ve used various different ones in the past, but my favorite is called <a href="http://sorgalla.com/jcarousel/">jCarousel</a>. You only have to take a quick look at the jCarousel homepage to see that it will do pretty much anything you ask of it. So in theory it should be a case of copy / paste the code into your site and you&#8217;re away. Unfortunately Web Development doesn&#8217;t always work that way; a small oversight can leave you racking your brains for hours&#8230; arghh!</p>
<p>The design and layout layout had already been created in the usual fashion. All that was left to do was to layer on all the JavaScript goodies (the fun part!). While implementing jCarousel I ran into a curious console error message:</p>
<blockquote><p>&#8220;jCarousel: No width/height set for items. This will cause an infinite loop. Aborting&#8230;&#8221;</p></blockquote>
<p>When I checked the carousel CSS, the item width had been set:</p>
<div class="codecolorer-container css default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.product</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.75em</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">75px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>Strange. The width had been set, so the error message must be from something else. After a few minutes investigation it turned out that the carousel didn&#8217;t have a parent with a set width. When fired the carousel is wrapped with two divs; one wraps the carousel, the other wraps the carousel and the navigation. Neither of these divs have an explicit width set which is what was causing the problem. It was a very quick fix in the end:</p>
<div class="codecolorer-container css default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666ff;">.jcarousel-container</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><span style="color: #808080; font-style: italic;">/* Fixed! */</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>Upon a little more investigation it seems you can fix this issue in other ways too. Instead of using a class of &#8220;product&#8221; to set the item widths I tried using the following:</p>
<div class="codecolorer-container css default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #cc00cc;">#carousel</span> li <span style="color: #00AA00;">&#123;</span><span style="color: #808080; font-style: italic;">/* New selector also fixed it! */</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/*...*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0.75em</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">75px</span><span style="color: #00AA00;">;</span><br />
&nbsp; &nbsp; <span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
<p>Very strange! The CSS in both cases changes the same elements, it just ignored the width in the &#8216;product&#8217; class.</p>
<p>So for anyone else encountering the same &#8220;No width/height set for items&#8221; issue here&#8217;s a quick check list for you to try:</p>
<ol>
<li>Make sure you set a width on the items (duh!). Maybe try different CSS selectors if necessary.</li>
<li>Set a width on the &#8220;jcarousel-container&#8221; class or one of its parents.</li>
<li>If all else fails, adapt one of the skin examples bundled with jCarousel.</li>
</ol>
<p>The last one is very annoying if you have your carousel already styled up, but it is guaranteed to work.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/jcarousel-missing-item-width/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Headspace2 JavaScript error</title>
		<link>http://nooshu.com/headspace2-javascript-error?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=headspace2-javascript-error</link>
		<comments>http://nooshu.com/headspace2-javascript-error#comments</comments>
		<pubDate>Thu, 17 Jun 2010 19:25:35 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1209</guid>
		<description><![CDATA[Post Thesaurus is broken.... oh wait no it isn't. Just a pesky JavaScript error from another plugin!]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: An update of Headspace2 has just been released that seems to solve this issue as well as a few others.</p>
<p>After updating to WordPress 3.0 (yay!) I decided to check the plug-ins that I&#8217;ve written to see if they still worked in version 3.0; to my dismay <a href="http://wordpress.org/extend/plugins/post-thesaurus/">Post Thesaurus</a> had stopped working&#8230; nooooo! Not good! A quick scan using Firebug revealed the issue: the Headspace2 plug-in.</p>
<p><a href="http://wordpress.org/extend/plugins/headspace2/">Headspace2</a> is a superb plug-in that allows you to tweak the SEO potential of your site. There are tonnes of options available; All In One SEO is easier to use, but I prefer the flexibility of Headspace2. The problem was occurring in the headspace-tags.js file:</p>
<div class="codecolorer-container text default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$(get_tag_element()).val() is undefined<br />
/wp-content/plugins/headspace2/js/headspace-tags.js?ver=3.6.32<br />
Line 76</div></td></tr></tbody></table></div>
<p>This error was stopping the rest of the JavaScript on a post page from firing (hence breaking Post Thesaurus). Looking at line 76 of headspace-tags.js you will see:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// Highlights headspace tags using the WordPress tag field as source</span><br />
<span style="color: #003366; font-weight: bold;">function</span> highlight_tags <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> words <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>get_tag_element<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//...</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The code seems to be falling over when there are no tags, so I just added a ternary operator which checks the array length first.</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> words<span style="color: #339933;">;</span><br />
<span style="color: #003366; font-weight: bold;">var</span> wordArray <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>get_tag_element<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#40;</span>wordArray.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> words <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>get_tag_element<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">','</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> words <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>If there are no tags create an empty array, else run the usual code. Adding this code fixed the issue and Post Thesaurus works again. Phew! Panic over. I&#8217;m sure this error will be picked up by the developer straight away and fixed in the next update.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/headspace2-javascript-error/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Recommended books for Front End Web Developers</title>
		<link>http://nooshu.com/recommended-books-for-front-end-web-developers?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=recommended-books-for-front-end-web-developers</link>
		<comments>http://nooshu.com/recommended-books-for-front-end-web-developers#comments</comments>
		<pubDate>Tue, 27 Apr 2010 14:45:23 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=1053</guid>
		<description><![CDATA[Heres a list I recommend for any Front End Web Developer just starting out in the big wild virtual world or web development. ]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve decided to persue a career as a Front End Web Developer (or you already are one and are looking for something new to read); smashing! The life of a Front End Developer is never dull&#8230; (cough) okay sometimes it is but there are certainly some exciting technologies out there to play with, especially at the moment with HTML5 and CSS3 gaining popularity.</p>
<p>Like with anything, you need to have a solid foundation of knowledge to build upon when it comes to new technologies, sometimes it&#8217;s a little dull but it will pay dividends in the future. Once you have the basic knowledge the world is you web browser. So here are a list of five books I&#8217;ve read in the past that I&#8217;ve found particularity helpful.</p>
<p><a href="http://nooshu.com/wp-content/uploads/2010/04/books.jpg"><img src="http://nooshu.com/wp-content/uploads/2010/04/books-518x360.jpg" alt="Looking for new Front End books to read, you could try one of these." title="recommended books" width="518" height="360" class="alignnone size-medium wp-image-1056" /></a></p>
<h3>DOM Scripting</h3>
<p>The reason I&#8217;ve put this book first is simply because it&#8217;s one of the best technical books I&#8217;ve ever read. The way it&#8217;s written is simple to understand and concise. All the way through the book it explains not only what you are doing but also <strong>why</strong> you&#8217;re doing it, and why you should also follow the same methodology.</p>
<p>If you are a complete beginner to JavaScript and the DOM this book will get you up and running and understanding in just a couple of chapters. Now some may say &#8220;oh I don&#8217;t need to know this anymore, that&#8217;s what JavaScript librarys are for&#8221;, but in my opinion that&#8217;s a dangerous road to go down. If ever your chosen library doesn&#8217;t do what you need, or if you can&#8217;t use a library for whatever reason; then you&#8217;re in trouble. </p>
<p>If you know the basics of the DOM and how to manipulate it using JavaScript, you&#8217;re much more likely to solve any issues you encounter and you&#8217;ll have a much better understanding of what the libraries are actually doing.</p>
<p>Author: Jeremy Keith (<a href="http://www.amazon.co.uk/DOM-Scripting-Design-JavaScript-Document/dp/1590595335">Amazon</a>).</p>
<h3>Eric Meyer on CSS</h3>
<p>There simply couldn&#8217;t be a review of front end development books without a book from the wizard of CSS, Eric Meyer. Eric has been a major part of the CSS community for many years; helping to educate developers in the proper usage of CSS and how it can make development so (so!) much easier. I had the pleasure of attending a 2 day workshop of his in London a few years back, and still use what I learnt there on a day to day basis.</p>
<p>&#8216;Eric Meyer on CSS&#8217; will teach you some of the advanced techniques involved in using CSS in a practical manner. You take a plain website built using tables, clean up the mark-up and layer on features and functionality using CSS over the various chapters; so rather than just getting a list of properties and selectors to read about, you actually get to see a live project changing over time.</p>
<p>Be warned, the book isn&#8217;t for absolute beginners, you do really need to know the basics of HTML and CSS to get the most out of it. Not to worry though, all the information you need to learn the basics of many different languages including HTML and CSS is available online at  <a href="http://www.w3schools.com/">w3schools</a>. You don&#8217;t have to stick to HTML and CSS, they also have JavaScript and the DOM if you&#8217;re feeling adventurous.</p>
<p>Author: Eric Meyer (<a href="http://www.amazon.com/Eric-Meyer-CSS-Mastering-Language/dp/073571245X">Amazon</a>) </p>
<h3>JavaScript &#8211; The Definitive Guide</h3>
<p>The very large book you can see in the image above is &#8216;JavaScript &#8211; The Definitive Guide&#8217;, and it really is a definitive guide. It has of 900+ pages of wonderful JavaScript! Now I wouldn&#8217;t expect anyone to read it page by page (although that&#8217;s what I did), but it&#8217;s defiantly a book you should have in your tool kit for reference. It  goes over pretty much all aspects of JavaScript you will ever use and even though it is quite technical it isn&#8217;t hard to follow; with plenty of examples and explanation of the code.</p>
<p>Again there&#8217;s an argument for do you need to know JavaScript if you just intend on using a library. Well I guess that up to you, but I personally don&#8217;t feel comfortable using any sort of framework / abstraction without having at least some understanding of the language it is built on.</p>
<p>Author: David Flanagon (<a href="http://www.amazon.com/JavaScript-Definitive-Guide-Activate-Pages/dp/0596805527/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1272375736&#038;sr=1-1">Amazon</a>) </p>
<h3>Learning jQuery</h3>
<p>So assuming you know about HTML, CSS and JavaScript it&#8217;s time to learn one of the many JavaScript libraries available. Now I agree with Christian Heilmann on a point he made at Full Frontal 2009 (I think it was Christian who made it), it doesn&#8217;t matter what library you use, as long as you use one!</p>
<p>&#8216;Learning jQuery&#8217; is a fantastic book that will take you through all aspects of jQuery, from setting up and writing basic code to Ajax and writing your own jQuery plug-ins. If you know how to use CSS to select parts of the DOM then jQuery will be simple for you to pick up and use. The book is filled with practical examples and applications, all using best practice methods.</p>
<p>I only had one slight gripe with the book while reading it; I found the font for the code blocks was slightly too big, so you tended to get a lot of wrapping on large code blocks. In terms of the content though, it really is one book that is a must read if you use jQuery or want to use jQuery in your projects.</p>
<p>Author: Jonathan Chaffer &#038; Karl Swedberg (<a href="http://www.amazon.com/Learning-jQuery-1-3-Jonathan-Chaffer/dp/1847196705/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1272376954&#038;sr=8-1">Amazon</a>)</p>
<h3>PHP Solutions</h3>
<p>Now I know what you may be thinking, PHP isn&#8217;t a front end language, it&#8217;s a server side language. That is very true, but one thing I can guarantee is one day you will have to integrate the front end templates you&#8217;ve built into a server side language; be that PHP, .Net, JSP, Java etc. As I&#8217;ve mainly worked with open source technologies, PHP is primarily what I integrate into.</p>
<p>&#8216;PHP Solutions&#8217; is another excellent Friends of Ed book that takes you through lots of practical uses of PHP that you can use straight out of the book. It covers subjects such as setting up your server and includes, to online galleries and security.  You may not use any of the functionality it covers since most frameworks and CMS&#8217;s have the functionality built in; but it will give you an understanding of how PHP works as a language which in turn will help you when it comes to integration.</p>
<p>Author: David Powers (<a href="http://www.amazon.co.uk/PHP-Solutions-Dynamic-Design-Made/dp/1590597311">Amazon</a>)</p>
<p>So there you have 5 books I&#8217;d recommend to any Front End Web Developer looking to expand their client-side knowledge. Leave a comment if there are any books you&#8217;d recommend and I&#8217;ll take a look and add it to my Amazon wishlist.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/recommended-books-for-front-end-web-developers/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CodeColorer Auto Expanding Code</title>
		<link>http://nooshu.com/codecolorer-auto-expanding-code?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=codecolorer-auto-expanding-code</link>
		<comments>http://nooshu.com/codecolorer-auto-expanding-code#comments</comments>
		<pubDate>Fri, 16 Apr 2010 15:26:35 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=976</guid>
		<description><![CDATA[Added a little feature to the CodeColourer Wordpress plug-in on my website that I'd thought I'd share with people.]]></description>
			<content:encoded><![CDATA[<p>Just quick post on a small feature I&#8217;ve just added to the site which I thought I&#8217;d share. It&#8217;s a slight addition to the <a href="http://wordpress.org/extend/plugins/codecolorer/">CodeColourer plug-in</a> for WordPress. CodeColourer formats and colourises code blocks in your blog posts for better readability. It comes with several different styles built in, or you can customise it using your own CSS file.</p>
<p>A feature that I saw on another site (although I can&#8217;t remember which) was when a user rolled over a code box it would expand to fit the code, allowing the user to see everything. Cool little addition, so I decided to create my own using jQuery. I&#8217;ve taken some of the code from the plug-in and pasted it below so you can see it in action:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.codecolorer-container&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $code <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.codecolorer-container&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Animation decision object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> decisionObject <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; h<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Original width / height of the displayed code</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> originalWidth <span style="color: #339933;">=</span> $this.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> originalHeight <span style="color: #339933;">=</span> $this.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Width / height of hidden portion of code</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> mainWidth <span style="color: #339933;">=</span> $this.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.codecolorer&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> mainHeight <span style="color: #339933;">=</span> $this.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.codecolorer&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> lineWidth <span style="color: #339933;">=</span> $this.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.line-numbers&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Only attach events if needed (ie has scroll bars)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>mainWidth <span style="color: #339933;">+</span> lineWidth<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> originalWidth <span style="color: #339933;">||</span> mainHeight <span style="color: #339933;">&gt;</span> originalHeight<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009966; font-style: italic;">/* and so on...... */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Since this action is fired on hover, I didn&#8217;t want the code boxes expanding immediately every time a user hovers over a box; as just scrolling down the page would expand the boxes which would become extremely annoying. The boxes should only expand when the cursor is left over the box; lucky there&#8217;s a plug-in for jQuery that already adds this functionality, it&#8217;s called <a href="http://blog.threedubmedia.com/2008/08/eventspecialhover.html">$.event.special.hover</a>. </p>
<p>Special hover simply replaces the standard hover event with one that monitors the speed of the cursor over a set period of time. If the cursor speed drops below the threshold the hover event fires. This is enough to stop random hover events firing when a user navigates over the page, simple!</p>
<p>I&#8217;d be interested to see if the code works for others using <a href="http://wordpress.org/extend/plugins/codecolorer/">CodeColorer</a>, there&#8217;s no reason why it shouldn&#8217;t. <a href="http://nooshu.com/wp-content/uploads/downloads/codecolorer-expander.js">Download the code</a>, give it a try and let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/codecolorer-auto-expanding-code/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress plug-in: Post Thesaurus</title>
		<link>http://nooshu.com/wordpress-plug-in-post-thesaurus?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-plug-in-post-thesaurus</link>
		<comments>http://nooshu.com/wordpress-plug-in-post-thesaurus#comments</comments>
		<pubDate>Wed, 14 Apr 2010 00:09:38 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[thesaurus]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=940</guid>
		<description><![CDATA[I created this plug-in for Wordpress as I have a tendency of using the word 'great' a little to much...]]></description>
			<content:encoded><![CDATA[<p>Over the past few days I&#8217;ve been working on a new WordPress plug-in, one that I personally have desperately needed recently. It&#8217;s called &#8216;Post Thesaurus&#8217; and it does exactly what you&#8217;d expect it to do. It creates a little widget on the side of the &#8216;Add new post&#8217; page which you can use to suggest new words of the same meaning.</p>
<p>After finding I use the  word &#8216;great&#8217; a little too much, I thought it was about time to do something about it. Here are a few screenshots of the plug-in in action:</p>
<div id="attachment_943" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2010/04/screenshot-2.gif"><img src="http://nooshu.com/wp-content/uploads/2010/04/screenshot-2-518x254.gif" alt="Post Thesaurus before I&#039;ve searched for a set of words." title="Post Thesaurus Before Search" width="518" height="254" class="size-medium wp-image-943" /></a><p class="wp-caption-text">Notice the widget in the top right corner.</p></div>
<div id="attachment_944" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2010/04/screenshot-3.gif"><img src="http://nooshu.com/wp-content/uploads/2010/04/screenshot-3-518x254.gif" alt="Post Thesaurus after I&#039;ve completed a word search" title="Post Thesaurus After a Search" width="518" height="254" class="size-medium wp-image-944" /></a><p class="wp-caption-text">The widget has completed a search and populated the results panel.</p></div>
<p>Big thank you to <a href="http://words.bighugelabs.com/">Big Huge Labs</a> for providing the excellent <a href="http://words.bighugelabs.com/api.php">API</a>. I&#8217;ve included an admin page with a few settings (under &#8216;settings&#8217;). One feature to note is the ability to enter your own API key. I&#8217;ve added this just in case the plug-in starts exceeding the 10,000 requests per day a single API key is allowed. <a href="http://words.bighugelabs.com/getkey.php">Sign up is simple</a> and only takes a couple of minutes, then you&#8217;ll have 10,000 requests per day all to yourself.</p>
<p>I&#8217;ve implemented the API using a little jQuery Ajax goodness and some JSONP. Since jQuery is used by the WordPress admin by default, there&#8217;s no additional overhead in having to add it manually.</p>
<p>Grab the plug-in off the WordPress site <a href="http://wordpress.org/extend/plugins/post-thesaurus/">here</a>, or you can download the zip from my site <a href="http://nooshu.com/wp-content/uploads/downloads/post-thesaurus.zip">here</a> <small>(Version 1.0.0.0)</small>.</p>
<p>Hope you find it useful, any feature requests or bugs leave a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/wordpress-plug-in-post-thesaurus/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>jQuery Plug-in: Tab Down</title>
		<link>http://nooshu.com/jquery-plug-in-tab-down?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jquery-plug-in-tab-down</link>
		<comments>http://nooshu.com/jquery-plug-in-tab-down#comments</comments>
		<pubDate>Fri, 02 Apr 2010 22:43:45 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tab]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=534</guid>
		<description><![CDATA[Simple plug-in for hiding content above the page which is shown by clicking a tab.]]></description>
			<content:encoded><![CDATA[<p>This simple plug-in has been on my TODO list for quite a while, as I&#8217;ve seen the effect used on many websites. It seems particularly useful for displaying contact details / social media updates. I&#8217;m sure there are many similar plug-ins around, but where&#8217;s the fun in using someone else&#8217;s version. So I created a jQuery Tab Down.</p>
<p>Tab Down simply hides content above the page which a user can then access via a floating tab. It&#8217;s easier to illustrate using a couple of demos. <a href="http://nooshu.com/explore/jquery-tab-down/">Demo 1</a> pushes the page content down with the tab, where as <a href="http://nooshu.com/explore/jquery-tab-down/index2.html">demo 2</a> tab content floats over the top of the page content. You can easily switch between versions by passing true or false to the &#8220;floating&#8221; option when calling the tabDown method.</p>
<div id="attachment_538" class="wp-caption alignnone" style="width: 528px"><a href="http://nooshu.com/wp-content/uploads/2010/04/tab-down-example.gif"><img src="http://nooshu.com/wp-content/uploads/2010/04/tab-down-example-518x460.gif" alt="jQuery tab down plug-in example" title="tab-down-example" width="518" height="460" class="size-medium wp-image-538" /></a><p class="wp-caption-text">Demo 1 example with floating set to false.</p></div>
<p>The plug-in is simple to use and has a number of options to allow customisation:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#tabContent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tabDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; floating<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; time<span style="color: #339933;">:</span> <span style="color: #CC0000;">900</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; easing<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;easeOutCubic&quot;</span><br />
&nbsp; &nbsp; container<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; downText<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Down&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; upText<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Up&quot;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<ul>
<li><strong>Floating</strong>: Sets if the tab floats over the main content or pushes it down (default: true)</li>
<li><strong>Time</strong>: Time in milliseconds for the slide animation (default: 1000)</li>
<li><strong>Container</strong>: If your tab content is inside a &#8220;wrapper&#8221; div, let the plug-in know the selector for this div, see demo 1 for an example (default: &#8220;body&#8221;)</li>
<li><strong>Downtext</strong>: The text used in the tab before sliding down (default: &#8220;Down&#8221;)</li>
<li><strong>Uptext</strong>: The text used in the tab after sliding down (default: &#8220;Up&#8221;)</li>
<li><strong>Easing</strong>: For smoother animation you can use animation easing, requires the <a href="http://gsgd.co.uk/sandbox/jquery/easing/">jQuery easing plug-in</a> (default: &#8220;swing&#8221;)</li>
</ul>
<p>View <a href="http://nooshu.com/explore/jquery-tab-down/">demo 1</a> and <a href="http://nooshu.com/explore/jquery-tab-down/index2.html">demo 2</a> or <a href="http://nooshu.com/wp-content/uploads/downloads/jquery-tab-down-v0.1.zip">download the code</a> <small>(version 0.1 – updated 2nd Apr 2010)</small>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/jquery-plug-in-tab-down/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coolclock: HTML5 Clock that is Actually Quite Cool*</title>
		<link>http://nooshu.com/coolclock-html5-clock-that-is-actually-quite-cool?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=coolclock-html5-clock-that-is-actually-quite-cool</link>
		<comments>http://nooshu.com/coolclock-html5-clock-that-is-actually-quite-cool#comments</comments>
		<pubDate>Thu, 25 Mar 2010 20:07:20 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Vanilla JavaScript]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://nooshu.com/?p=478</guid>
		<description><![CDATA[Looking for a Canvas based JavaScript clock that also supports Time zones...]]></description>
			<content:encoded><![CDATA[<p><strong>*</strong>: Unless you&#8217;re Internet Explorer, then not so much.</p>
<p>Every so often a designer asks for something a little different, this time it was for an animated clock that sits in the top right corner of a website. Usually that means looking for a Flash based solution, but Canvas is the new Flash&#8230; apparently; luckily <a href="http://randomibis.com/coolclock/">Coolclock</a> is available to plug the no-flash gap.</p>
<p>Coolclock is a fantastic little script that will generate a canvas based clock from the parameters you pass it via the class attribute (I don&#8217;t agree with that, but it works). It&#8217;s fully customisable by way of a little JSON data, allowing you to create your own skins. There are quite a few user submitted skins available to use on the <a href="http://randomibis.com/coolclock/">Coolclock</a> homepage if you don&#8217;t want to create your own.</p>
<p>I needed the clock to be able to change depending on the country that&#8217;s chosen from a dropdown list, here&#8217;s how I achieved it:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//Generate the clock</span><br />
<span style="color: #003366; font-weight: bold;">var</span> generateClock <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Create our dropdown, time difference compared to GMT as a value</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> dropHTML <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&lt;select id='localTime'&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; dropHTML <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;option value='0'&gt;United Kingdom&lt;/option&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; dropHTML <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;option value='+1'&gt;France&lt;/option&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; dropHTML <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;option value='-4'&gt;New York&lt;/option&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; dropHTML <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;/select&gt;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Append to the container</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#time&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>dropHTML<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Initial clock appended to the page (local time)</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> clockHTML <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;canvas id=&quot;clk1&quot; class=&quot;CoolClock:swissRail:27:noSeconds&quot;&gt;&lt;/canvas&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#clock&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>clockHTML<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//When the dropdown changes</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#localTime&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> value <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> localClockHTML <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;canvas id=&quot;clk1&quot; class=&quot;CoolClock:swissRail:27:noSeconds:'</span> <span style="color: #339933;">+</span> value <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;&lt;/canvas&gt;'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Empty the old clock, append the new clock</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#clock&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>localClockHTML<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//Fire the coolclock function to generate the new clock</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CoolClock.<span style="color: #660066;">findAndCreateClocks</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Very simple, the relevant HTML code is generated with JavaScript as to not leave a pointless dropdown on the page when it&#8217;s turned off. The key to the solution was calling the CoolClock.findAndCreateClocks() function from the coolclock.js file, without that the clock isn&#8217;t recreated when the dropdown is changed.</p>
<p>As mentioned above, the script seems to come unstuck when viewed in Internet Explorer, since IE doesn&#8217;t support the canvas tag. You can plug the lack of canvas support using <a href="http://excanvas.sourceforge.net/">ExplorerCanvas</a>, but even then coolclock is a little quirky. I managed to get the clock working with IE6 &#038; IE7 but IE8 wasn&#8217;t having any of it; bit of of shame as it&#8217;s a nice solution. Good news is on the horizon though, IE9 will support canvas by default so no nasty JavaScript hacks. </p>
<p>Eventually I decided to add the clock as a type of &#8216;progressive enhancement&#8217; by wrapping the function in the following:</p>
<div class="codecolorer-container javascript default customCodeColor" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">//IE returns false since it uses 'styleFloat'.</span><br />
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>jQuery.<span style="color: #660066;">support</span>.<span style="color: #660066;">cssFloat</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//IE can't see this code</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>It&#8217;s not great, and I hate having to do it but if users want to see a cool clock they will have to upgrade to a modern browser (that&#8217;s not IE8).</p>
<p>For those who are interested, here&#8217;s a <a href="http://nooshu.com/explore/coolclock-dropdown/">quick demo</a> of the code in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://nooshu.com/coolclock-html5-clock-that-is-actually-quite-cool/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

