<?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>Toddish.co.uk - Web Developer Portfolio - Leeds &#187; Blog</title>
	<atom:link href="http://toddish.co.uk/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://toddish.co.uk</link>
	<description></description>
	<lastBuildDate>Sun, 29 Jan 2012 11:12:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>My Top Sublime Text 2 Packages</title>
		<link>http://toddish.co.uk/2012/my-top-sublime-text-2-packages/</link>
		<comments>http://toddish.co.uk/2012/my-top-sublime-text-2-packages/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 23:13:48 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[Sublime Text 2]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=592</guid>
		<description><![CDATA[I know, I've <a href="http://toddish.co.uk/2011/sublime-text-2-review/">raved about Sublime Text 2 before</a>, but now that it's fully integrated into my workflow (and I even own a license for it!), I thought I'd share my most used packages for it.]]></description>
			<content:encoded><![CDATA[<p><img src="http://toddish.co.uk/wordpress/assets/sublime_packages.jpg" alt="" title="sublime_packages" width="630" height="340" class="alignnone size-full wp-image-600" /></p>
<p>I know, I&#8217;ve <a href="http://toddish.co.uk/2011/sublime-text-2-review/">raved about Sublime Text 2 before</a>, but now that it&#8217;s fully integrated into my workflow (and I even own a license for it!), I thought I&#8217;d share my most used packages for it.</p>
<p><span id="more-592"></span></p>
<p>Before I delve into this, if you&#8217;re new to packages, they&#8217;re basically plugins that extend the functionality of the main program. The best way to install them is to follow the instructions in this <a href="http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/">post from Nettuts</a> (look for point 7), which basically boils down to:</p>
<ul>
<li>Open the console with CTRL/CMD + &#8216;</li>
<li>Paste this into it:
<div class="codesnip-container" >import urllib2,os;pf=&#8217;Package Control.sublime-package&#8217;;ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),&#8217;wb&#8217;).write(urllib2.urlopen(&#8216;http://sublime.wbond.net/&#8217;+pf.replace(&#8216; &#8216;,&#8217;%20&#8242;)).read())</div>
</li>
</ul>
<p>Restart Sublime text 2 and you should now have the package manager installed. Press CTRL/CMD + SHIFT + P, type install, and hit enter.</p>
<p>You should be presented with a list of all the current packages available. Simply scroll through and press enter to install, it&#8217;s that easy!</p>
<p>You can also <a href="http://wbond.net/sublime_packages/community">head here to browse through them</a> if you don&#8217;t have Sublime text 2 installed;</p>
<h3>The List</h3>
<p>These are just a fraction of the packages available, but they seem to be the ones that I&#8217;m using the most at the moment.</p>
<h4><a href="http://wbond.net/sublime_packages/alignment">Alignment</a></h4>
<p>Lines up arrays/objects. I used to hate inheriting code that wasn&#8217;t lined up, now with two simple keyboard shortcuts I don&#8217;t have to spend time sorting it out!</p>
<h4><a href="https://github.com/Kronuz/SublimeCodeIntel">Code Intel</a></h4>
<p>I&#8217;m still not sure if I love this plugin, or hate it. Code Intel is Komodo&#8217;s autocompletion engine; it supports lots of languages and actually learns what you use the most and (supposedly) intelligently suggests what you mean.</p>
<p>I think at first you need to be patient as it learns what you use, because I find it completing the wrong word a lot. When pressing &#8216;-&#8217; it assumes it&#8217;s the end of the word and auto completes with what ever is at the top of the list, which is a nightmare when writing CSS.</p>
<h4><a href="https://github.com/spadgos/sublime-jsdocs">DocBlockr</a></h4>
<p>One thing I missed when moving away from NetBeans was the autocompletion of doc blocks, including variable hinting and auto indentation once inside the block. This solves that.</p>
<h4><a href="https://github.com/kemayo/sublime-text-2-git">Git</a></h4>
<p>Simply integrates Git straight into the IDE. I use it sparingly (like if I need to change just one file and commit it), but it does come in useful. There is also an <a href="http://wbond.net/sublime_packages/tortoise">Tortoise alternative available</a> for people that use SVN. </p>
<h4><a href="https://github.com/robcowie/SublimeTODO">TODO</a></h4>
<p>Extracts TODOs (and FIXME, CHANGED and another others you might want to add) so you can keep on track with what you have left to complete.</p>
<h4><a href="https://github.com/SublimeText/TrailingSpaces">Trailing Spaces</a></h4>
<p>I&#8217;m a bit of a layout perfectionist, and it annoys me when there are trailing spaces at the end of lines. This highlights them and lets you delete them all in one shortcut.</p>
<h4><a href="https://bitbucket.org/wbond/sublime-2-zencoding">Zen Coding</a></h4>
<p>I&#8217;d never come across Zen Coding until recently, and I still need to remember to use it half the time, but when I do I really like it. This makes writing HTML quick and pain free.</p>
<h3>There are so many more&hellip;</h3>
<p>There are so many more I could have mentioned, but those are the ones I&#8217;m using most frequently. More are added all the time, so the repository definitely active.</p>
<p>Whatever you need/language you program in, there is probably a package for you!</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2012/my-top-sublime-text-2-packages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Twittoh Launch</title>
		<link>http://toddish.co.uk/2011/twittoh-launch/</link>
		<comments>http://toddish.co.uk/2011/twittoh-launch/#comments</comments>
		<pubDate>Wed, 28 Sep 2011 14:37:30 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Launch]]></category>
		<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[Fuel]]></category>
		<category><![CDATA[Phirehose]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=553</guid>
		<description><![CDATA[<a href="http://twittoh.com">Twittoh</a> is a small mini project I created with <a href="http://chriswillerton.com">Chris Willerton</a>. He took the lead on the design and HTML/CSS, and I coded the twitter bits.]]></description>
			<content:encoded><![CDATA[<p><img src="http://toddish.co.uk/wordpress/assets/twittoh1.png" alt="Twittoh site" title="Twittoh" width="630" height="340" class="alignnone size-full wp-image-574" /></p>
<p><a href="http://twittoh.com">Twittoh</a> is a mini project I created with <a href="http://chriswillerton.com">Chris Willerton</a>. He took the lead on the design and HTML/CSS, and I coded the twitter bits.</p>
<p><span id="more-553"></span></p>
<p>It&#8217;s a collection of &#8220;overhead&#8221; tweets; tweets that are prefixed with &#8220;OH:&#8221;, and generally contain a funny sentence someone has overheard.</p>
<h2>The Tech</h2>
<p>The site uses <a href="http://fuelphp.com">Fuel</a> as its base. I&#8217;d not used Fuel before, I usually stick with CodeIgniter, so it was interesting to see how it differed. I think I prefer it, and I&#8217;ll be using it again.</p>
<p>I used <a href="https://github.com/fennb/phirehose">Phirehose</a> to connect to the Twitter streaming API, which was very easy to use and definitely made the job easier.</p>
<p>Once I was collecting tweets, I had to filter them. I only saved tweets that had &#8220;OH: &#8221; at the start and didn&#8217;t contain any links. To filter out all the non english ones (although some do slip through), I check the language using <a href="http://msdn.microsoft.com/en-us/library/ff512419.aspx">Microsoft Translator API</a>.</p>
<p>And off it goes, collecting tweets and displaying them. <a href="http://twittoh.com">Check them out!</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/twittoh-launch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sublime Text 2 Review</title>
		<link>http://toddish.co.uk/2011/sublime-text-2-review/</link>
		<comments>http://toddish.co.uk/2011/sublime-text-2-review/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 18:42:28 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Review]]></category>
		<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Sublime Text 2]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=500</guid>
		<description><![CDATA[I'm a <a href="http://netbeans.org/">NetBeans</a> user, but recently I've found it to be too bloated and slow. Then I heard about <a href="http://www.sublimetext.com/">Sublime Text 2</a>, and I thought it'd give it a test run.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a <a href="http://netbeans.org/">NetBeans</a> user, but recently I&#8217;ve found it to be too bloated and slow. Then I heard about <a href="http://www.sublimetext.com/">Sublime Text 2</a>, which promised to be a</p>
<blockquote><p>&#8220;sophisticated text editor for code, html and prose. You&#8217;ll love the slick user interface and extraordinary features&#8221;</p></blockquote>
<p>Well, I thought, it doesn&#8217;t hurt to give it a go, and I&#8217;m glad I did. Here are my pros and cons so far.<br />
<span id="more-500"></span></p>
<h2>Cons</h2>
<p class="quiet">Please bear in mind that most of the cons are comparing Sublime Text 2 to NetBeans, and so may not apply to everyone.</p>
<ul>
<li><strong>No code auto formatting</strong>. It&#8217;s one of the main features NetBeans has that I love. Pasting someone else&#8217;s horribly formatted code into your editor and instantly prettifying it was great. It does have a plugin for this, but not for PHP as far as I can see.</li>
<li><strong>No PHP validation</strong>. Again, I&#8217;m probably being spoiled by NetBeans, but I did like it telling me if I had any errors <em>before</em> I viewed the file in the browser.</li>
<li><strong>Average auto complete</strong>. NetBeans used to read all the files in the project, and enable auto complete for each php class, function and css class it could find, which was great. From what I can see, Sublime Text 2 only auto completes the variables in the current page, with no hints available. This does mean more visits to php.net, which is never good on the eyes.</li>
<li><strong>No navigator</strong>. While the mini map is cool, and fairly useful, I liked the navigator in NetBeans better. Having a list of my class methods in alphabetical order (all with private/protected/public indicators) that I can quickly jump to was a very handy feature. Sublime Text 2 does have this sort of, by pressing cmd/ctl R, then you can go through each function available, but they aren&#8217;t in alphabetical order.</li>
<li><strong>Some unintuitive UI elements</strong>. This last point is made up of two very, <em>very</em> picky points. When you double click in the folders view, it doesn&#8217;t open the folder; instead, you have to click the small arrow next to the folder. Also, when I highlight a word, then open the replace dialog, I want the word to be automatically placed into the find box.</li>
</ul>
<h2>Pros</h2>
<ul>
<li><strong>It&#8217;s fast</strong>, like <em>really</em> fast. Opening takes a few seconds at most, and adding folders/files and navigating through code is lightning quick. Makes a refreshing change from waiting 15 seconds for NetBeans to open, then another minute for it to scan the curent projects and become usable.</li>
<li><strong>Project management is very flexible</strong>. A project is simply a collection of folders, much like in TextMate, so you can add and remove them at any time. This is great if I want to easily reference some old code; I just add in the folder, do I what I need to do, and remove it once I&#8217;m done. However, it would be nice if we could add files as well as folders like TextMate does.</li>
<li><strong>It has a nice dark colour scheme</strong>. I usually code on a white background, and I&#8217;d yet to find a colour scheme that&#8217;d change my mind. After looking at the Blackboard colour scheme in Sublime Text 2, I&#8217;m now converted.</li>
<li><strong>Find and replace has an option to KEEP the current capitalisation</strong>. I don&#8217;t know if any other programmes have this, but it&#8217;s a great feature. Basically, if you do a find for &#8220;var&#8221; to be replaced with &#8220;diff_var&#8221;, you can keep the initial capitalisation, so VAR will become DIFF_VAR, or Var will become Dif_var. This is great if you have a mix of constants, variables and text, and you need all instances of a word changing.</li>
<li><strong>Distraction free mode</strong>. Much like WordPress has, Sublime Text 2 offers a distraction free editing mode. It&#8217;s a fullscreen mode, but with no menu/sidebars; all the focus is on the code. (It also has a normal fullscreen mode.) This is great if you get distracted easily.</li>
<li><strong>Easy to tell files apart</strong>. When using CodeIgniter, I often find I have various files open, all with the same name, which can be confusing when the tab for that file in my editor only has the filename on it. Sublime Text 2 gets around this by detecting when you&#8217;ve got files with the same name open, and putting the folder it&#8217;s in next to it.</li>
<li><strong>Pretty folder view</strong>. To counteract the last con above, I&#8217;d like to mention the nice effect of the folders and files sliding in as you expand each folder in the project pane. Small, but a very nice touch.</li>
</ul>
<h2>Final Thoughts</h2>
<p>Overall, I&#8217;ve got to say I really like Sublime Text 2, and it&#8217;s now my go to editor. I&#8217;ve only been using it for a few days, but I feel comfortable using it for my main projects.</p>
<p>I&#8217;m willing to overlook the cons (hopefully they&#8217;ll be added in later as core updates/plugins anyway), and I&#8217;ll probably pay for the license after a little more playing around with its features.</p>
<p>Has anyone else used it? Do you like it, or still use something over it?</p>
<p class="notice">If you&#8217;re interested, I&#8217;ve also done a write up on my <a href="http://toddish.co.uk/2012/my-top-sublime-text-2-packages/">favourite packages</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/sublime-text-2-review/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>First Published Nettuts Tutorial!</title>
		<link>http://toddish.co.uk/2011/first-published-nettuts-tutorial/</link>
		<comments>http://toddish.co.uk/2011/first-published-nettuts-tutorial/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 16:38:21 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=582</guid>
		<description><![CDATA[I recently submitted a tutorial to Nettuts, and it was accepted and published!]]></description>
			<content:encoded><![CDATA[<p><img src="http://toddish.co.uk/wordpress/assets/nettuts.png" alt="" title="nettuts" width="630" height="340" class="alignnone size-full wp-image-585" /></p>
<p>I recently submitted a tutorial to Nettuts, and it was accepted and published!</p>
<p><span id="more-582"></span></p>
<p>I wrote a quick blog post on <a href="http://toddish.co.uk/2011/ajax-file-upload-in-codeigniter-mvc">how to upload a file using AJAX</a> (or some AJAXy techniques), and I thought it might make a decent tutorial.</p>
<p>I submitted it to Nettuts, and low and behold, it was published! I&#8217;m quite happy with it, but there are definitely some improvements I could make.</p>
<p>I, however, did learn a lot writing it, and hopefully I&#8217;ll be writing some more soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/first-published-nettuts-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX File upload in CodeIgniter and MVC</title>
		<link>http://toddish.co.uk/2011/ajax-file-upload-in-codeigniter-mvc/</link>
		<comments>http://toddish.co.uk/2011/ajax-file-upload-in-codeigniter-mvc/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 18:52:50 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[CodeIgniter]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=479</guid>
		<description><![CDATA[Trying to set up AJAX file uploading within CodeIgniter can be a serious pain. I tried multiple scripts before settling on one that actually worked, so if you're having trouble, keep on reading.]]></description>
			<content:encoded><![CDATA[<p class="notice">I&#8217;ve actually written up a more complete tutorial, which has been <a href="http://net.tutsplus.com/tutorials/javascript-ajax/how-to-upload-files-with-codeigniter-and-ajax/">published on Nettuts+</a>. You should go and read that instead!</p>
<p>Trying to set up AJAX file uploading within CodeIgniter can be a serious pain. I tried multiple scripts before settling on one that actually worked, so if you&#8217;re having trouble, keep on reading.<br />
<span id="more-479"></span></p>
<h2>The Failed Attempts</h2>
<p>First, I tried <a href="http://www.uploadify.com/">Uploadify</a>, which came highly recommended. Stupidly, I tried the new beta (the newest version is always better, right?) which comes with incomplete documentation and lots of bugs. After an hour of fiddling, and finally getting it to sort of work, I decided it didn&#8217;t really suit my needs. I couldn&#8217;t point the upload script path to a controller in CodeIgniter, I had to point it to a specific script (i.e., upload.php).</p>
<p>Secondly, I tried <a href="http://valums.com/ajax-upload/">Vaulms</a>, which looked promising; it even sort of worked on the first try! However, again, I couldn&#8217;t get it to point to a controller. CodeIgniter seemed to be stripping out the $_GET stuff. (I&#8217;m using the latest reactor release.) I could probably have forced the script to only use the IFRAME $_FILES method, but I thought it might be too much faff.</p>
<h2>And The Winner Is&#8230;</h2>
<p>Finally, I tried <a href="http://www.phpletter.com/Demo/AjaxFileUpload-Demo/">PHP Letter AjaxFileUpload</a>. Initially, I was put off by the site, but as they say, don&#8217;t judge a book by its cover!</p>
<p>The script is a nice simple one; it works off of a native form field, and can be called from anywhere. It does lack some of the bells and whistles of the previous scripts, such as loading progress and multiple uploads (without tinkering), but it suited my needs perfectly.</p>
<h2>The Code</h2>
<p>So, here&#8217;s how to implement it. <a href="http://www.phpletter.com/DOWNLOAD/">Download the script</a>, and include it in your page. (Obviously including jQuery before it!) Create your form, making sure to place in a form input field. </p>
<p>Now, add in your JS:</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;">$<span class="br0">&#40;</span><span class="st0">&#8216;#form&#8217;</span><span class="br0">&#41;</span>.<span class="me1">submit</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; e.<span class="me1">preventDefault</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; $.<span class="me1">ajaxFileUpload</span><span class="br0">&#40;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; url<span class="sy0">:</span><span class="st0">&#8216;/image/upload&#8217;</span><span class="sy0">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; secureuri<span class="sy0">:</span><span class="kw2">false</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; fileElementId<span class="sy0">:</span><span class="st0">&#8216;image&#8217;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dataType<span class="sy0">:</span> <span class="st0">&#8216;json&#8217;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; data&nbsp; &nbsp; <span class="sy0">:</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;title&#8217;</span> <span class="sy0">:</span> $<span class="br0">&#40;</span><span class="st0">&#8216;#title&#8217;</span><span class="br0">&#41;</span>.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; success<span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">&#40;</span>data<span class="sy0">,</span> <span class="kw3">status</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>data.<span class="me1">error</span> <span class="sy0">!=</span> <span class="st0">&#8221;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">alert</span><span class="br0">&#40;</span>data.<span class="me1">error</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">alert</span><span class="br0">&#40;</span>data.<span class="me1">msg</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Refresh image list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; error<span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">&#40;</span>data<span class="sy0">,</span> <span class="kw3">status</span><span class="sy0">,</span> e<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span class="me1">log</span><span class="br0">&#40;</span>e<span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>As you can see, we&#8217;re hijacking the form submit. The params are the same as a normal $.ajax, as all we&#8217;re doing really is creating an iframe and submitting the form through that. Note that I&#8217;m sending extra data through (the other field on the form). This means you can submit the entire form at the same time.</p>
<p>Now for the PHP side. Create a controller called image and add a public function called upload. Within that function, place this code:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$error</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span><br />
<span class="re0">$msg</span> <span class="sy0">=</span> <span class="st0">&quot;&quot;</span><span class="sy0">;</span><br />
<span class="re0">$file_element_name</span> <span class="sy0">=</span> <span class="st_h">&#8216;image&#8217;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st_h">&#8216;title&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$error</span> <span class="sy0">=</span> <span class="st0">&quot;Please enter a title&quot;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="re0">$error</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$config</span><span class="br0">&#91;</span><span class="st_h">&#8216;upload_path&#8217;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">&#8216;./images/&#8217;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$config</span><span class="br0">&#91;</span><span class="st_h">&#8216;allowed_types&#8217;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st_h">&#8216;gif|jpg|png&#8217;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$config</span><span class="br0">&#91;</span><span class="st_h">&#8216;max_size&#8217;</span><span class="br0">&#93;</span> <span class="sy0">=</span> 1024 <span class="sy0">*</span> <span class="nu0">3</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$config</span><span class="br0">&#91;</span><span class="st_h">&#8216;max_width&#8217;</span><span class="br0">&#93;</span> &nbsp;<span class="sy0">=</span> <span class="st_h">&#8217;1280&#8242;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="re0">$config</span><span class="br0">&#91;</span><span class="st_h">&#8216;max_height&#8217;</span><span class="br0">&#93;</span> &nbsp;<span class="sy0">=</span> <span class="st_h">&#8217;1024&#8242;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">load</span><span class="sy0">-&gt;</span><span class="me1">library</span><span class="br0">&#40;</span><span class="st_h">&#8216;upload&#8217;</span><span class="sy0">,</span> <span class="re0">$config</span><span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">upload</span><span class="sy0">-&gt;</span><span class="me1">do_upload</span><span class="br0">&#40;</span><span class="re0">$file_element_name</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$error</span> <span class="sy0">=</span> <span class="re0">$this</span><span class="sy0">-&gt;</span><span class="me1">upload</span><span class="sy0">-&gt;</span><span class="me1">display_errors</span><span class="br0">&#40;</span><span class="st_h">&#8221;</span><span class="sy0">,</span> <span class="st_h">&#8221;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Update your DB here</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$msg</span> <span class="sy0">.=</span> <span class="st0">&quot;success&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="co1">//for security reason, we force to remove all uploaded file</span><br />
&nbsp; &nbsp; <span class="sy0">@</span><a href="http://www.php.net/unlink"><span class="kw3">unlink</span></a><span class="br0">&#40;</span><span class="re0">$_FILES</span><span class="br0">&#91;</span><span class="re0">$file_element_name</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="kw1">echo</span> <span class="st0">&quot;{&quot;</span><span class="sy0">;</span><br />
<span class="kw1">echo</span> <span class="st0">&quot;error: &#8216;&quot;</span> <span class="sy0">.</span> <span class="re0">$error</span> <span class="sy0">.</span> <span class="st0">&quot;&#8217;,<span class="es1">\n</span>&quot;</span><span class="sy0">;</span><br />
<span class="kw1">echo</span> <span class="st0">&quot;msg: &#8216;&quot;</span> <span class="sy0">.</span> <span class="re0">$msg</span> <span class="sy0">.</span> <span class="st0">&quot;&#8217;<span class="es1">\n</span>&quot;</span><span class="sy0">;</span><br />
<span class="kw1">echo</span> <span class="st0">&quot;}&quot;</span><span class="sy0">;</span></div>
</div>
<p>In this code we do some simple validation on the title, then initialize the upload library and try to upload the file. Note how the input name is passed into the do_upload() method, this is because by default CodeIgniter looks for a field called &#8216;userfile&#8217;. (For more on the CodeIgniter Upload class, see the <a href="http://codeigniter.com/user_guide/libraries/file_uploading.html">documentation</a>.)</p>
<p>At the end of the controller, we echo out a response in JSON. <em>Technically</em>, we should pass it to a view and do it properly, but for the sake of the tutorial, this is fine.</p>
<p>And there you go, AJAX File Uploading in CodeIgniter!</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/ajax-file-upload-in-codeigniter-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TF Popup Launch</title>
		<link>http://toddish.co.uk/2011/tf-popup-jquery-lightbox-launch/</link>
		<comments>http://toddish.co.uk/2011/tf-popup-jquery-lightbox-launch/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 22:03:56 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Launch]]></category>
		<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=450</guid>
		<description><![CDATA[<p>I've done a silly thing; I've created another popup script. I'm not usually one to reinvent the wheel; I'd much rather use someone else's probably superior code, but this time I needed something a little different (much like with <a href="http://toddish.co.uk/blog/2011/05/17/tf-assets-a-new-codeigniter-assetlayout-library/">TF Assets</a>).</p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve done a silly thing; I&#8217;ve created another jQuery popup/lightbox script. I&#8217;m not usually one to reinvent the wheel, I&#8217;d much rather use someone else&#8217;s probably superior code, but this time I needed something a little different (much like with <a href="http://toddish.co.uk/blog/2011/05/17/tf-assets-a-new-codeigniter-assetlayout-library/">TF Assets</a>).</p>
<p><a href="http://toddish.co.uk/wordpress/assets/uploads/2011/07/tf-popup-example.png"><img src="http://toddish.co.uk/wordpress/assets/uploads/2011/07/tf-popup-example-300x188.png" alt="" title="tf-popup-example" width="300" height="188" class="alignright size-medium wp-image-454" style="float:right;margin:0 0 20px 20px" /></a></p>
<p><strong>TF Popup</strong> is a <a href="http://jquery.com">jQuery</a> plugin aimed at developers. It gives you full theming control and is really flexible; it can be used for simple information modal popups, to full login/registration forms complete with validation.</p>
<p>It includes a small API to help when validating your form, doing a lot of the display leg work for you.</p>
<p><span id="more-450"></span></p>
<p>You can <strong><a href="https://github.com/Toddish/TF-Popup">download it over at github</a></strong>!</a></p>
<h2>See it in action</h2>
<p>You can see it in action on the <a href="http://scripts.toddish.co.uk/tf-popup/demos">demos page</a> without code, or on the <a href="http://scripts.toddish.co.uk/tf-popup/examples">examples page</a> with code.</p>
<p>Overtime I may add more examples and demos if anyone can think of any that would be particularly useful.</p>
<h2>Documentation</h2>
<p>Like <a href="http://toddish.co.uk/blog/2011/05/17/tf-assets-a-new-codeigniter-assetlayout-library/">TF Assets</a>, <strong>TF Popup</strong> is fully documented over at my <a href="http://scripts.toddish.co.uk/tf-popup">scripts mini site</a>. Additionally, you can email or post questions here.</p>
<p>If anyone has any suggestions, or find any bugs, please let me know! It is still in beta, so there may be a few kinks, but it should be usable on sites now.</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/tf-popup-jquery-lightbox-launch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TF Assets Launch</title>
		<link>http://toddish.co.uk/2011/tf-assets-a-new-codeigniter-assetlayout-library/</link>
		<comments>http://toddish.co.uk/2011/tf-assets-a-new-codeigniter-assetlayout-library/#comments</comments>
		<pubDate>Tue, 17 May 2011 22:26:53 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[CodeIgniter]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=412</guid>
		<description><![CDATA[One thing I dislike about <a href="http://codeigniter.com/">CodeIgniter</a> is the way it handles views and assets; it can get very messy as your site grows. Enter TF Assets!]]></description>
			<content:encoded><![CDATA[<p>One thing I dislike about <a href="http://codeigniter.com/">CodeIgniter</a> is the way it handles views and assets; it can get very messy as your site grows. I did used to use <a href="http://backstack.ca/projects/bucket/">Bucket</a>, which I&#8217;ve <a href="http://toddish.co.uk/blog/2010/11/23/codeigniter-2-and-bucket/">blogged about before</a>, but I found the overhead for some features I didn&#8217;t use (and couldn&#8217;t seem to get to work) too much.<br />
<span id="more-412"></span><br />
Enter <a href="https://github.com/Toddish/TF-Assets/"><strong>TF Assets</strong></a>! A simple way to handle partial views, layouts and css/js files. It may not be as feature rich as Bucket, but it&#8217;s a lot more lightweight.</p>
<p>I&#8217;ve tried to make it really easy to use and as flexible as possible. The library ships with just 2 files, config.php and tf_assets.php.</p>
<p class="important">You can download the library from <a href="https://github.com/Toddish/TF-Assets/">Github</a></p>
<p>You can find complete examples and documentation at my new mini documentation site,  where I&#8217;ll be putting all the docs for any plugins/scripts I create. I&#8217;ve imaginatively named it <strong>Toddish&#8217;s Scripts</strong>, and you can find it at <a href="http://scripts.toddish.co.uk">http://scripts.toddish.co.uk</a>.</p>
<p>Please comment here or even better use the <a href="https://github.com/Toddish/TF-Assets/issues">GitHub Issue Tracker</a> if you have any suggestions or bugs to report.</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/tf-assets-a-new-codeigniter-assetlayout-library/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>API Pet Peeves</title>
		<link>http://toddish.co.uk/2011/api-pet-peeves/</link>
		<comments>http://toddish.co.uk/2011/api-pet-peeves/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 21:33:25 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[APIs]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=398</guid>
		<description><![CDATA[<p>I've been doing a lot of work recently using various APIs, including creating some myself, and I've noticed quite a few seem to have annoying traits.</p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of work recently using various APIs, including creating some myself, and I&#8217;ve noticed quite a few seem to have annoying traits.</p>
<p>I mainly work with REST APIs, so this post will focus on them; although most of the points can be transferred across to others.</p>
<p><span id="more-398"></span></p>
<p>I don&#8217;t claim to be an expert in REST APIs, far from it, but here are some things that really annoy me. As usual, if I&#8217;ve got anything wrong, or if there is a better way to go about it, let me know in the comments!</p>
<h2>The Gripes</h2>
<h3>Lack of Documentation</h3>
<p>The whole point of exposing your site to developers is to allow them to create applications using your data/services. Not telling them how to do that is a massive drawback.</p>
<p>We shouldn&#8217;t have to guess what a method returns, or what parameters it takes.</p>
<h3>Consistency</h3>
<p>All of your methods and variables should follow a convention, and should stick to that convention no matter what.</p>
<p>If, a few months down the line, you decide you prefer camelCase to underscores, don&#8217;t start writing new methods in camelCase, stick to underscores. There&#8217;s nothing worse than calling /example_method then calling /anotherExampleMethod.</p>
<p>Only change the convention for a new major version of the API, and even then keep the old version for a while.</p>
<h3>Return Something Sensible</h3>
<p>If I make a request in JSON, I&#8217;d probably like it back in JSON (unless specified in the request). Don&#8217;t just automatically return XML; either give me a choice or return in the same format I initially used.</p>
<p>If returning an error, return a machine readable error, not an an error for a human. Don&#8217;t return a nice html page with the error explained, give me a JSON packet with an error code and description. Also, please return a header code. Don&#8217;t return every request with a 200!</p>
<h3>Use HTTP Verbs</h3>
<p>Use the HTTP verbs to keep your URLs clean and logical, don&#8217;t prefix your methods (e.g., post_user/delete_user). This allows the url <em>/user/44</em> to be used for multiple things. Sending a GET request will retrieve the user whereas sending a DELETE request will delete the user for example.</p>
<h3>Standardise Your Returns</h3>
<p>One API I&#8217;m currently working with does this, and it creates a lot of extra code. When returning a list of items (users for example), return the same format list even if you&#8217;re returning 0, 1 or 100. Don&#8217;t return a single object for 1, and an array of objects for 100; return an array for any amount. That way, all I have to do it count the items in the array, and I can loop through it no matter what.</p>
<h2>I&#8217;ve probably missed some&#8230;</h2>
<p>I&#8217;ve probably missed some obvious gripes, but they are the ones that have been bugging me lately.</p>
<p>If you can think of any I have missed, let me know!</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/api-pet-peeves/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Games that Deserve a Sequel</title>
		<link>http://toddish.co.uk/2011/games-that-deserve-a-sequel/</link>
		<comments>http://toddish.co.uk/2011/games-that-deserve-a-sequel/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 12:30:47 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[list]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/blog/?p=143</guid>
		<description><![CDATA[<p>Thinking about all the sequels currently being released (Killzone 3, MvC3, Deus Ex Human Revolution, Crysis 2 etc), I got to wondering about the forgotten games that would be amazing if recreated using current gen tech.</p>]]></description>
			<content:encoded><![CDATA[<p>Thinking about all the sequels currently being released (Killzone 3, MvC3, Deus Ex Human Revolution, Crysis 2 etc), I got to wondering about the forgotten games that would be amazing if recreated using current gen tech.</p>
<p><span id="more-143"></span></p>
<p><small>Please note that this is very biased because the list is comprised of games I&#8217;d like to see remade, mainly due to the fact I used to play them and have fond memories of them, and as such isn&#8217;t a complete list by any means. It also only features PlayStation games, because that&#8217;s what I had growing up. If you have any more suggestions, please leave them in the comments!</small></p>
<h2>5. Rollcage</h2>
<p><strong>What is it?</strong> A futuristic racing game with weapons.</p>
<p><strong>Why should it get a sequel?</strong> Rollcage Stage II was a great game when it came out in 2000; I&#8217;ve never really been into racing games, but for some reason I really took to it.  I loved the speed, the fact you could go on the ceiling, and the great use of the weapons. I think my favourite mode, however, was Scramble. It&#8217;s basically the puzzle mode; an infuriating puzzle mode.</p>
<p><strong>Chances of a sequel being made:</strong> None. The developers, Attention To Detail, liquidated in 2003, and Midway, one of the publishers, recently became bankrupt.  Only the second publisher, Psygnosis, exists, albeit now as part of Sony Computer Entertainment Liverpool.</p>
<h2>4. Timesplitters</h2>
<p><strong>What is it?</strong> A comedy FPS with a strong focus on multiplayer.</p>
<p><strong>Why should it get a sequel?</strong> Because it was amazing! Each one in the series was fantastic, with great characters, interesting challenges, and great multiplayer. It&#8217;d definitely benefit from todays better online tech, I just hope they don&#8217;t go all Call of Duty and start implementing classes and XP.</p>
<p><strong>Chances of a sequel being made:</strong> Publishers Eidos are now part of Square Enix Europe, and Developers Free Radical have been acquired by Crytek, becoming Crytek UK. Before their acquisition, it was revealed they were working on Timesplitters 4; going as far as releasing some concept art. Crytek UK will be announcing some big news around E3 (June 7-9), let&#8217;s hope it&#8217;s Timesplitters 4 related!</p>
<h2>3. Bloody Roar</h2>
<p><strong>What is it?</strong> A fighting game where your character could turn into an Zoanthrope.</p>
<p><strong>Why should it get a sequel?</strong> This year is the year for fighters. With MvC3 finally out, MK9 and SFIV:AE round the corner and newcomer Skull Girls out in the summer, fighting games are bigger than ever. Bloody roar and it&#8217;s sequels were great fun when they originally came out, and I&#8217;m sure with some gameplay tweaks and an updated engine, it&#8217;d fit right in with today&#8217;s modern fighters.</p>
<p><strong>Chances of a sequel being made:</strong> None. Bloody Roar 5 was confirmed as being in production, but when Konami closed Hudson Entertainment in February it was cancelled.</p>
<h2>2. Legacy of Kain: Soul Reaver</h2>
<p><strong>What is it?</strong> A third-person action adventure with a dark twist.</p>
<p><strong>Why should it get a sequel?</strong> Soul Reaver and its sequel were amazing games; combining decent puzzles with combat that didn&#8217;t get boring. After seeing what God of War III can do, I think a Soul Reaver 3 is work making, especially as there was no conclusive ending to the story in Soul Reaver 2!</p>
<p><strong>Chances of a sequel being made:</strong> I&#8217;m not sure really. Developers Crystal Dynamic were acquired by publishers Eidos, who in turn have been acquired by Square Enix Europe. However, Kain and Raziel were both playable characters (via DLC) for 2010s Tomb Raider and the Guardian of Light. Maybe they were trying to gauge how much interest people had in the characters?</p>
<h2>1. Zone of the Enders</h2>
<p><strong>What is it?</strong> A third person action adventure where you pilot a giant mech.</p>
<p><strong>Why should it get a sequel?</strong> Because the first two were amazing. Great graphics, amazing story and fluid combat. Z.O.E. 3 would look amazing on the PS3, and it may even be able to incorporate the move without it being too gimicky.</p>
<p><strong>Chances of a sequel being made:</strong> Pretty good actually. Hideo Kojima promised in 2009 a sequel would be made, and while it has been a fair while, we can still hope!</p>
<h3 style="margin:20px 0 0;">Honourable Mentions</h3>
<ul style="margin:0 0 20px;">
<li>Spyro</li>
<li>Urban Chaos</li>
<li>Bushido Blade</li>
<li>Crash Team Racing</li>
</ul>
<p>If I&#8217;ve missed any, or if you want to add your own, please leave the game in the comments below and I&#8217;ll probably add it to the honourable mentions.</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/games-that-deserve-a-sequel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Recreating Dabble.in&#8217;s Homepage in CSS3</title>
		<link>http://toddish.co.uk/2011/recreating-dabble-ins-homepage-in-css3/</link>
		<comments>http://toddish.co.uk/2011/recreating-dabble-ins-homepage-in-css3/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 16:20:38 +0000</pubDate>
		<dc:creator>Toddish</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Web Tech]]></category>
		<category><![CDATA[CSS3]]></category>

		<guid isPermaLink="false">http://toddish.co.uk/?p=361</guid>
		<description><![CDATA[<p>I was recently pointed towards <a href="http://dabble.in">Dabble.in</a>, where I, like many others it seems, instantly loved the cool rollover effect.</p>
<p>Here's how to replicate it, and why (I think) they used jQuery when it isn't actually needed.</p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://dabble.in"><img src="http://toddish.co.uk/wordpress/assets/uploads/2011/03/dabble-300x161.png" alt="" title="dabble" width="300" height="161" class="size-medium wp-image-364" style="float:right;margin:0 0 10px 10px;" /></a>I was recently pointed towards <a href="http://dabble.in">Dabble.in</a> where I, like many others it seems, instantly loved the cool rollover effect.</p>
<p>The first thing I did was inspect element to see how it was done (like pretty much every web developer I know did), and it turns out the effect is incredibly simple. It&#8217;s mainly CSS3 with a sprinkling of jQuery. Here&#8217;s how to replicate it, and why (I think) they used jQuery when it isn&#8217;t actually needed.</p>
<p><span id="more-361"></span></p>
<h2>The Code</h2>
<p>Quite simply, each block is a div; the colour changes instantly when you rollover, and fades out when you rollout. To get this effect, you need to use the CSS3 property <strong>transition</strong> and it&#8217;s vendor implementations.</p>
<div class="fader_cont">
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader green"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader red"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader red"></div>
<div class="fader green"></div>
<div class="fader green"></div>
<div class="fader green"></div>
<div class="fader green"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader light_grey"></div>
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader green"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader red"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader red"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader green"></div>
<div class="fader light_grey"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
<div class="fader blue"></div>
<div class="fader green"></div>
<div class="fader green"></div>
<div class="fader blue"></div>
<div class="fader red"></div>
<div class="fader blue"></div>
<div class="fader red"></div>
<div class="fader light_grey"></div>
<div class="fader blue"></div>
</div>
<p style="text-align:center"><em>Rollover the blocks above to see the effect in action.</em></p>
<p>First, you set up your divs:</p>
<div class="codesnip-container" >
<div class="css codesnip" style="font-family:monospace;"><span class="re1">.fader</span>.<span class="kw2">red</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">background-color</span><span class="sy0">:</span><span class="re0">#ed4e4e</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="re1">.fader</span>.<span class="kw1">blue</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">background-color</span><span class="sy0">:</span><span class="re0">#7077f9</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="re1">.fader</span><span class="re1">.light_grey</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">background-color</span><span class="sy0">:</span><span class="re0">#a8a8a8</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="re1">.fader</span>.<span class="kw2">green</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">background-color</span><span class="sy0">:</span><span class="re0">#ddb12c</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span> &nbsp; &nbsp; &nbsp; <br />
<span class="re1">.fader</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">height</span><span class="sy0">:</span><span class="re3">40px</span><span class="sy0">;</span> <br />
&nbsp; &nbsp; <span class="kw1">width</span><span class="sy0">:</span><span class="re3">40px</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">float</span><span class="sy0">:</span><span class="kw1">left</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="re1">.fader</span><span class="re2">:hover </span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#606060</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>These are simply 40&#215;40 divs that float next to each other. I&#8217;ve given them another class to denote what default colour they should have.</p>
<p>Now, to add in the fade when we change the background colour, we need to add the following CSS3 properties to our .fader class:</p>
<div class="codesnip-container" >
<div class="css codesnip" style="font-family:monospace;"><span class="re1">.fader</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; -webkit-transition<span class="sy0">:</span><span class="kw1">background-color</span> 2s 0.4s ease-out<span class="sy0">;</span><br />
&nbsp; &nbsp; -moz-transition<span class="sy0">:</span><span class="kw1">background-color</span> 2s 0.4s ease-out<span class="sy0">;</span><br />
&nbsp; &nbsp; -o-transition<span class="sy0">:</span><span class="kw1">background-color</span> 2s 0.4s linear<span class="sy0">;</span><br />
&nbsp; &nbsp; transition<span class="sy0">:</span><span class="kw1">background-color</span> 2s 0.4s ease-out<span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">height</span><span class="sy0">:</span><span class="re3">40px</span><span class="sy0">;</span> <br />
&nbsp; &nbsp; <span class="kw1">width</span><span class="sy0">:</span><span class="re3">40px</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">float</span><span class="sy0">:</span><span class="kw1">left</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>The syntax for the transition property is:</p>
<p><strong>property</strong>: property to animate (use &#8220;all&#8221; for any property that changes)</p>
<p><strong>time</strong>: length of time the animation lasts</p>
<p><strong>delay</strong>: delay before the animation begins</p>
<p><strong>easing</strong>: easing type, defaults to linear</p>
<p>The actual command is just <em>transition</em>, but due to the different vendor implementations we need to add the -webkit (Chrome), -moz (Firefox) and -o (Opera) versions for it to work consistently in other browsers. Our divs should now fade when we roll over them!</p>
<p>However, they don&#8217;t change instantly when we initially rollover, instead we have to wait for the delay and watch them fade in. This isn&#8217;t what we want!</p>
<p>Luckily, all we have to do is remove the transition property in our :hover statement, like so:</p>
<div class="codesnip-container" >
<div class="css codesnip" style="font-family:monospace;"><span class="re1">.fader</span><span class="re2">:hover </span><span class="br0">&#123;</span><br />
&nbsp; &nbsp; -webkit-transition<span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span><br />
&nbsp; &nbsp; -moz-transition<span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span><br />
&nbsp; &nbsp; -o-transition<span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span><br />
&nbsp; &nbsp; transition<span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#606060</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div>
</div>
<div class="bob_cont">
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader light_grey"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader light_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader light_grey"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader light_grey"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader dark_grey"></div>
<div class="fader light_grey"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader light_grey"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader light_grey"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader black"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
<div class="fader white"></div>
</div>
<p>Our divs should now change instantly to our new colour, and fade out slowly when we rollout.</p>
<p>You should note that we are only animating the background-color property here. The transition property can animate most CSS properties, including width, height and opacity.</p>
<p>Using these techniques, you can make some quite interesting things. I used it to create this bob. Rollover him to see the effect.</p>
<h2>Known Issues</h2>
<p>This won&#8217;t work properly in Opera, which doesn&#8217;t seem to honour the change in the transition property, so the div will fade on rollover and rollout. And you may have already guessed, but it doesn&#8217;t work in IE (even in 9).</p>
<h3>The use of jQuery</h3>
<p>Seeing as you can do all of this in CSS3, why did Dabble use jQuery?</p>
<p>I&#8217;m only guessing here, but whilst I was playing around with this it seemed fairly obvious. Unless you like creating hundreds of divs, the only sane way to create them is via a loop in whatever language you prefer, and unless you want to make hundreds of CSS statements with each colour in as a class, it&#8217;d be easier to simple add the colour in a style property per div.</p>
<p>However, as soon as you do this, the transition no longer works. The only way to get it to work again is to add the transition properties in the style property as well. Switching them out when rolling over/out via jQuery is the easiest way to duplicate the effect, storing the original colour in an attribute.</p>
<p>Well, this ended up a lot longer than I expected, and I still left out a lot of things. If there is anything you don&#8217;t get or I&#8217;ve got wrong, please let me know. Likewise, if you found this useful, please leave a comment!</p>
<p>If you want to read more about the transition property, see <a href="http://www.css3files.com/transition/">CSS3 Files</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://toddish.co.uk/2011/recreating-dabble-ins-homepage-in-css3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

