<?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>James Macfie</title>
	<atom:link href="http://www.jamesmacfie.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jamesmacfie.com</link>
	<description>Welcome to my blog and online portfolio</description>
	<lastBuildDate>Fri, 15 Jun 2012 04:19:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>8-bit images using only CSS3 and one HTML element</title>
		<link>http://www.jamesmacfie.com/2012/06/8-bit-images-using-only-css3-and-one-html-element/</link>
		<comments>http://www.jamesmacfie.com/2012/06/8-bit-images-using-only-css3-and-one-html-element/#comments</comments>
		<pubDate>Fri, 15 Jun 2012 04:19:40 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=270</guid>
		<description><![CDATA[Combining a block element and the CSS3 attribute box-shadow, we can pretty easily create sudo-pixelated / 8-bit style images with only one line of HTML (and many lines of CSS). Whilst I&#8217;m undecided on the real-world merits of this technique, it&#8217;s pretty cool nonetheless. This is what we&#8217;re going to be creating: To start with, [...]]]></description>
			<content:encoded><![CDATA[<p>Combining a block element and the CSS3 attribute <code>box-shadow</code>, we can pretty easily create sudo-pixelated / 8-bit style images with only one line of HTML (and many lines of CSS). Whilst I&#8217;m undecided on the real-world merits of this technique, it&#8217;s pretty cool nonetheless.</p>
<p>This is what we&#8217;re going to be creating:</p>
<p><img class="alignnone size-full wp-image-271" title="space_invader_full" src="http://www.jamesmacfie.com/wp-content/uploads/2012/06/space_invader_full.png" alt="" width="202" height="150" /></p>
<p>To start with, lets create an HTML div element that will be the original pixel that we will work off:</p>
<pre class="html">
<span class="htmlOtherTag">&lt;div id=<span class="htmlAttributeValue">&quot;pixel&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p>And give it this CSS:</p>
<pre class="css">
<span class="cssSelector">#pixel {</span>
<span class="cssProperty">background</span><span class="cssRest">:</span><span class="cssValue"> black</span><span class="cssRest">;</span>
<span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue"> 1em</span><span class="cssRest">;</span>
<span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue"> 1em</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
</pre>
<p>That gives us:</p>
<p><img class="alignnone size-full wp-image-274" title="black_square" src="http://www.jamesmacfie.com/wp-content/uploads/2012/06/black_square.png" alt="" width="86" height="71" /></p>
<p>The entire shape is going to be achieved using the CSS3 <code>box-shadow</code> attribute. To explain how this is done, I&#8217;ll just give a quick run through of how multiple box shadows can achieve this in relation to the code we have above.</p>
<p>If you take a look at the CSS code we have above, all we have is a black square &#8211; think of it as a big pixel &#8211; that&#8217;s 1em by 1em. Pretty simple, but that&#8217;s all we need to start with. A space invaders character (or any old-school 8-bit character, for that matter) is just a collection of pixels, and in this space invaders example the pixels aren&#8217;t even different colors making this particular exercise even easier.</p>
<p>What we can do with this &#8216;pixel&#8217; is add a large number of box shadows to it. Each shadow will be the same height and width as our original square and by not giving the shadow any blur or spread, we can create more sudo-pixels which are replicas of the original (as a side note, each time I reference the word &#8216;pixel&#8217; I&#8217;m referring to the black square as a single sudo-pixel, not actual screen pixels. When talking about 8-bit characters and the such, talking in pixels just makes sense). Combine that with the horizontal and vertical offset (equal to the width and height of the element), we can move these replica pixels around in relation to original to create a picture. Confused? Maybe this picture can explain it better:</p>
<p><img class="alignnone size-full wp-image-275" title="box-shadow_example" src="http://www.jamesmacfie.com/wp-content/uploads/2012/06/box-shadow_example.jpg" alt="" width="260" height="260" /></p>
<p>There we have the original black &#8216;pixel&#8217;. By adding <code>box-shadow</code>, we have created another &#8216;pixel&#8217;. The cool thing is, we can create as many shadows as we like. That means we can create as many extra &#8216;pixels&#8217; as we like.</p>
<p>The first line of our space invader&#8217;s boxshadow CSS would look like this:</p>
<pre class="css">
box-shadow: -1em 0 0 0 black,
-3em 0 0 0 black,
-4em 0 0 0 black,
1em 0 0 0 black,
3em 0 0 0 black,
4em 0 0 0 black;
</pre>
<p>That CSS is just for the first line of the space invader (the line with the eyes). You&#8217;ll get something like this:</p>
<p><img class="alignnone size-full wp-image-276" title="first_line_no_margin" src="http://www.jamesmacfie.com/wp-content/uploads/2012/06/first_line_no_margin.png" alt="" width="128" height="69" /></p>
<p>Hmmm. That looks a little off. The problem here is that as we create those shadows on the negative (both horizontal and vertical negative), the shadows are going to appear outside the browser window. To combat this we need to put a margin on the div so that this margin offsets the distance the shadows are going to appear in. If you look at an image of a space invader, from the middle pixel to the top left we need a margin of 3em up and 5 em left. So put in a margin into the CSS like this:</p>
<pre class="css">
<span class="cssProperty">margin</span><span class="cssRest">:</span><span class="cssValue"> 3em 0 0 5em</span><span class="cssRest">;</span>
</pre>
<p>Now your screen will look something like this:</p>
<p><img class="alignnone size-full wp-image-277" title="first_line_margin" src="http://www.jamesmacfie.com/wp-content/uploads/2012/06/first_line_margin.png" alt="" width="195" height="108" /></p>
<p>Now all you have to do is put in the rest of the <code>box-shadow</code></p>
<pre class="css">
box-shadow:
-1em 0 0 0 black,
-3em 0 0 0 black,
-4em 0 0 0 black,
1em 0 0 0 black,
3em 0 0 0 black,
4em 0 0 0 black,
-3em -1em 0 0 black,
-2em -1em 0 0 black,
-1em -1em 0 0 black,
0 -1em 0 0 black,
1em -1em 0 0 black,
2em -1em 0 0 black,
3em -1em 0 0 black,
-2em -2em 0 0 black,
-3em -3em 0 0 black,
2em -2em 0 0 black,
3em -3em 0 0 black,
-5em 1em 0 0 black,
-4em 1em 0 0 black,
-3em 1em 0 0 black,
-2em 1em 0 0 black,
-1em 1em 0 0 black,
0 1em 0 0 black,
1em 1em 0 0 black,
2em 1em 0 0 black,
3em 1em 0 0 black,
4em 1em 0 0 black,
5em 1em 0 0 black,
-5em 2em 0 0 black,
-5em 3em 0 0 black,
5em 2em 0 0 black,
5em 3em 0 0 black,
-3em 2em 0 0 black,
-2em 2em 0 0 black,
-1em 2em 0 0 black,
0 2em 0 0 black,
1em 2em 0 0 black,
2em 2em 0 0 black,
3em 2em 0 0 black,
-3em 3em 0 0 black,
3em 3em 0 0 black,
-2em 4em 0 0 black,
-1em 4em 0 0 black,
2em 4em 0 0 black,
1em 4em 0 0 black;
</pre>
<p>And that&#8217;ll give you this:</p>
<p><img class="alignnone size-full wp-image-278" title="space_invader_full" src="http://www.jamesmacfie.com/wp-content/uploads/2012/06/space_invader_full1.png" alt="" width="202" height="150" /></p>
<p>So hopefully you can see how this technique can be used to create any pixelated 8-bit character using only the CSS <code>box-shadow</code> attribute.</p>
<p>As I mentioned, probably not the most practical way of creating a space invader, but still rather cool.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2012/06/8-bit-images-using-only-css3-and-one-html-element/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Displaying WordPress posts that have a future scheduled date</title>
		<link>http://www.jamesmacfie.com/2012/04/displaying-wordpress-posts-that-have-a-future-scheduled-date/</link>
		<comments>http://www.jamesmacfie.com/2012/04/displaying-wordpress-posts-that-have-a-future-scheduled-date/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 04:43:32 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=265</guid>
		<description><![CDATA[On one of the sites I work on I have a custom post type of &#8216;event&#8217;. All was well and good with these event posts until I had to make a change which involved changing the publish date to the date of the event. In WordPress, if you create a post and set the publish [...]]]></description>
			<content:encoded><![CDATA[<p>On one of the sites I work on I have a custom post type of &#8216;event&#8217;. All was well and good with these event posts until I had to make a change which involved changing the publish date to the date of the event.</p>
<p>In WordPress, if you create a post and set the publish date to anything in the future it will automagically schedule the post for that date and time. Most of the time I&#8217;m sure that&#8217;s nice and convenient but in my case I didn&#8217;t want that. I wanted the post to be viewable immediately but show the &#8216;published date&#8217; as the future date I selected.</p>
<p>Luckily there&#8217;s a simple fix for this. There&#8217;s an option called &#8216;post_status&#8217; that you can modify when specifying the details of the loop you are using to grab your posts. You can read more about that on the <a title="WP_Query" href="http://codex.wordpress.org/Class_Reference/WP_Query#Type_.26_Status_Parameters" target="_blank">WP_Query </a>page, but if you&#8217;re just looking for some code to cop and paste then this will do the trick:</p>
<pre class="php">
$loop <span class="phpOperator">=</span><span class="phpKeyword"> new </span>WP_Query<span class="phpOperator">(</span><span class="phpString">'post_status'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">'future'</span>, <span class="phpString">'publish'</span><span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span>have_posts<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">:</span><span class="phpKeyword"> while </span><span class="phpOperator">(</span> $loop<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>have_posts<span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">)</span> <span class="phpOperator">:</span> $loop<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>the_post<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Do something here
</span>>endwhile<span class="phpText">;</span>
<span class="phpKeyword">
endif<span class="phpText">;</span></span>
</pre>
<p>What that&#8217;s doing is grabbing all your posts that are either published or are set to be published at some point in the future.</p>
<p>In my case I also added the custom post type details into the arguments and my problem was solved!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2012/04/displaying-wordpress-posts-that-have-a-future-scheduled-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debug your HTML &amp; CSS on the iPad/iPhone</title>
		<link>http://www.jamesmacfie.com/2012/03/debug-your-html-css-on-the-ipadiphone/</link>
		<comments>http://www.jamesmacfie.com/2012/03/debug-your-html-css-on-the-ipadiphone/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 01:56:38 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Analysis]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=258</guid>
		<description><![CDATA[For all their bells and whistles, debugging a website or web app on either an iPad or iPhone is a huge pain in the ass. Personally, I see it as rather irresponsible for Apple not to provide webdev tools on their devices (and their &#8216;Debug mode&#8217; doesn&#8217;t count &#8211; that&#8217;s just a console log). You [...]]]></description>
			<content:encoded><![CDATA[<p>For all their bells and whistles, debugging a website or web app on either an iPad or iPhone is a huge pain in the ass. Personally, I see it as rather irresponsible for Apple not to provide webdev tools on their devices (and their &#8216;Debug mode&#8217; doesn&#8217;t count &#8211; that&#8217;s just a console log). You know, considering the millions upon millions of devices they have in circulation and the fact that mobiles are <a href="http://www.bbc.co.uk/news/technology-14731757" target="_blank">increasingly </a>becoming the device people use to access the interwebs.</p>
<p>Until such time as iOS gets an update with some nice dev tools, we can rely on <a href="http://getfirebug.com/firebuglite" target="_blank">Firebug Lite</a> to provide some dev functionality. Unfortunately it doesn&#8217;t go as far as being able to debug the page&#8217;s JavaScript, but it&#8217;s HTML and CSS inspector is fantastic. iPads and iPhones don&#8217;t play nice with bookmarklets so there&#8217;s a few steps you have to take to get it going:</p>
<ul>
<li>Bookmark this page (or any other page for that matter. We&#8217;re going to be modifying it anyway)</li>
<li>Name the bookmark something useful like &#8216;Firebug Lite&#8217;</li>
<li>Copy this text here:</li>
</ul>
<pre class="javascript">
<div>javascript:(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&amp;&amp;F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','firebug-lite.js','releases/lite/latest/skin/xp/sprite.png','https://getfirebug.com/','#startOpened');</div>
</pre>
<ul>
<li>
<div>Edit the bookmark you created before and paste in the code you copied over the current URL.</div>
</li>
<li>Done!</li>
</ul>
<p>Now when you&#8217;re viewing a page you want to inspect, click on the bookmark that you just created.You&#8217;ll see Firebug Lite at the bottom of the browser window.</p>
<p><img class="alignnone size-medium wp-image-259" title="photo" src="http://www.jamesmacfie.com/wp-content/uploads/2012/03/photo-326x244.png" alt="" width="326" height="244" /></p>
<p>Another scenario where I&#8217;ve found this useful is trying to inspect dynamic content in Internet Explorer. The IE9 (or IE8) dev tools currently only allow you to inspect the content that hasn&#8217;t been altered by JavaScript &#8211; Firebug Lite helps get around this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2012/03/debug-your-html-css-on-the-ipadiphone/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IE7 &#8211; Absolutely positioned element hidden when put alongside a floated element</title>
		<link>http://www.jamesmacfie.com/2012/01/ie7-absolutely-positioned-element-hidden-when-put-alongside-a-floated-element/</link>
		<comments>http://www.jamesmacfie.com/2012/01/ie7-absolutely-positioned-element-hidden-when-put-alongside-a-floated-element/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 01:45:32 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE sucks]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=255</guid>
		<description><![CDATA[I&#8217;m really happy that on my current project I don&#8217;t have to develop for IE6. But f*ck it, IE7 still gives me grief on a day to day basis. What follows it an inconsitant and irritating bug that took me the better part of an hour to fix (and when I say fix, I really [...]]]></description>
			<content:encoded><![CDATA[<div>I&#8217;m really happy that on my current project I don&#8217;t have to develop for IE6. But f*ck it, IE7 still gives me grief on a day to day basis. What follows it an inconsitant and irritating bug that took me the better part of an hour to fix (and when I say fix, I really mean hack).</p>
<p>The problem I ran into was when I had a parent container (with CSS position set to relative) which contained four elements. Three of these were absolutely positoned and one was floated to the left (with a set % width). Without getting into specifics, all this achieved was a nice row of information that expanded nicely when the page was resized.</p>
<p>All was well on every browser I tested on&#8230; except IE7. The issue seems to be that IE likes to hide absolutely positioned elements when it&#8217;s coded alongside a sibling floated element. I&#8217;m talking about disappearing from the entire page here. And, according to some quick Googling, it seems as if this bug isn&#8217;t consistant. Sometimes the elements are hidden, sometimes they aren&#8217;t. Sometimes the elements are hidden on one PC, while being fine on another. * sigh *</p>
<p>But there is a solution. A quick, dirty hack of a HTML solution. By chucking in an empty div element straight after the disappearing element the element always stays visible. So in my issue that I brielfy explained above I had to put three empty div elements onto the page &#8211; one after every missing element.</p>
<p>Maybe there&#8217;s a better option &#8211; it doesn&#8217;t look like there is a CSS only fix (which would be nice).</p>
<p>Goodbye semantic HTML&#8230;</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2012/01/ie7-absolutely-positioned-element-hidden-when-put-alongside-a-floated-element/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data tables – some incremental improvements</title>
		<link>http://www.jamesmacfie.com/2011/09/data-tables-%e2%80%93-some-incremental-improvements/</link>
		<comments>http://www.jamesmacfie.com/2011/09/data-tables-%e2%80%93-some-incremental-improvements/#comments</comments>
		<pubDate>Mon, 05 Sep 2011 09:27:54 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=240</guid>
		<description><![CDATA[Tables are boring, but in most cases they’re meant to be that way. The purpose of a table of data is to display the appropriate information to a user in a concise, logical, easy to understand manner. The reason tables tend to be boring is the focus is meant to be on the information contained [...]]]></description>
			<content:encoded><![CDATA[<p>Tables are boring, but in most cases they’re meant to be that way. The purpose of a table of data is to display the appropriate information to a user in a concise, logical, easy to understand manner. The reason tables tend to be boring is the focus is meant to be on the information contained in them. Making a super-pretty table can really remove the focus from the table’s data. However, in saying that, there are a few things that you can do that doesn’t take the focus away from the data but can actually increase readability.</p>
<p>For this exercise I’m going to take a part of the 2006 NZ census data (specifically the ‘Highest Qualification and Sex by Age Group’ info) and slowly improve on it. Disclaimer: this was never actually a web table. I’m not taking this table from the web and making it any better – I’m taking a table from an excel spreadsheet and using it as a base to improve from.  On a related note, if you ever want to tab a table from excel and publish it with HTML, use the tool Tablizer (<a href="http://tableizer.journalistopia.com/">http://tableizer.journalistopia.com/</a>). It makes it all pretty simple (but I do recommend checking the code to get it to a state that you want to work with).</p>
<p>Here’s<a title="Table 1" href="http://www.jamesmacfie.com/wp-content/uploads/2011/09/table1.html" target="_blank"> the table without any styling [table1]</a>. Looks a bit rubbish, really. On a lot of financial and government sites, these types of tables (maybe a wee bit prettier than ours) are surprisingly common. So how about for the first part of this exercise we add a little bit of colour to aid the user’s scanning of the table. We’ll add a color to the header to make that obvious, and maybe we’ll also make the totals at the right of the table  stand out more.</p>
<p>Check out our <a title="Table 2" href="http://www.jamesmacfie.com/wp-content/uploads/2011/09/table2.html" target="_blank">sample table [table 2]</a> with a little bit of color. Looks better, doesn’t it? You’re probably going to want to investigate a better colour choice than what I’ve done.</p>
<p>Now that’s certainly better than the plain version we first implemented. We should also go one step further with the colour styling and throw in some zebra or alternate row styling. If you’ve got jQuery running on the page then one line of Javascript and one CSS class will do the trick.</p>
<pre class="css">
<span class="cssSelector">.even {</span> <span class="cssProperty">Background-color</span><span class="cssRest">:</span><span class="cssValue">  #000</span><span class="cssRest">;</span> <span class="cssSelector">}</span>
</pre>
<pre class="php">
$<span class="phpOperator">(</span><span class="phpString">'tr<span class="phpOperator">:</span>even'</span><span class="phpOperator">)</span>.addClass<span class="phpOperator">(</span><span class="phpString">'even'</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>With that running on <a title="Table 3" href="http://www.jamesmacfie.com/wp-content/uploads/2011/09/table3.html" target="_blank">the table [table 3]</a>, we can now scan our eyes over the data and can easily refer back to the information contained in the row by following that coloured row over to the left. In our table this also has the bonus of highlighting not only every second row but, coincidentally, also differentiates the sub-headers of the table (the types of qualifications) and helps distinguish between the three values underneath it.</p>
<p>Speaking of subheadings, there’s a better way that we  could deal with them too. How about we allow the users to open and close these  groups (groups defined by the sub-heading). This cleans up the table &#8211; if you were only wanting to look at one section, for example, then closing all the other ones would help you to focus only on what you want. Note in the code below that I’ve included the jquery plugin livequery.</p>
<pre class="php">
<span class="phpComment">//Click event<span class="phpKeyword"> for </span>making an open group closed
</span>$<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">.</span>activeGroup'</span><span class="phpOperator">)</span>.livequery<span class="phpOperator">(</span><span class="phpString">'click'</span>, <span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span>event<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.addClass<span class="phpOperator">(</span><span class="phpString">'inactiveGroup'</span><span class="phpOperator">)</span>.removeClass<span class="phpOperator">(</span><span class="phpString">'activeGroup'</span><span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.parent<span class="phpOperator">(</span><span class="phpOperator">)</span>.nextAll<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">:</span>lt<span class="phpOperator">(</span><span class="phpNumber">3</span><span class="phpOperator">)</span>'</span><span class="phpOperator">)</span>.hide<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Click event<span class="phpKeyword"> for </span>making a closed group open
</span>$<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">.</span>inactiveGroup'</span><span class="phpOperator">)</span>.livequery<span class="phpOperator">(</span><span class="phpString">'click'</span>, <span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span>event<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.addClass<span class="phpOperator">(</span><span class="phpString">'activeGroup'</span><span class="phpOperator">)</span>.removeClass<span class="phpOperator">(</span><span class="phpString">'inactiveGroup'</span><span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.parent<span class="phpOperator">(</span><span class="phpOperator">)</span>.nextAll<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">:</span>lt<span class="phpOperator">(</span><span class="phpNumber">3</span><span class="phpOperator">)</span>'</span><span class="phpOperator">)</span>.show<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>Check out <a title="Table 4" href="http://www.jamesmacfie.com/wp-content/uploads/2011/09/table4.html" target="_blank">the grouping action [table 4]</a></p>
<p>A further improvement on this would be to make the empty rows by the qualification names the totals until that group is expanded. With a little bit more jQuery magic we can achieve that.</p>
<pre class="php">
<span class="phpComment">//Click event<span class="phpKeyword"> for </span>making an open group closed
</span>$<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">.</span>activeGroup'</span><span class="phpOperator">)</span>.livequery<span class="phpOperator">(</span><span class="phpString">'click'</span>, <span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span>event<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.addClass<span class="phpOperator">(</span><span class="phpString">'inactiveGroup'</span><span class="phpOperator">)</span>.removeClass<span class="phpOperator">(</span><span class="phpString">'activeGroup'</span><span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.parent<span class="phpOperator">(</span><span class="phpOperator">)</span>.nextAll<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">:</span>lt<span class="phpOperator">(</span><span class="phpNumber">3</span><span class="phpOperator">)</span>'</span><span class="phpOperator">)</span>.hide<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Replace blank cells with totals
</span>>var toBeReplaced <span class="phpOperator">=</span> $<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.siblings<span class="phpOperator">(</span><span class="phpOperator">)</span>.slice<span class="phpOperator">(</span><span class="phpNumber">0</span>, 16<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
var </span>toReplaceWith <span class="phpOperator">=</span> $<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.parent<span class="phpOperator">(</span><span class="phpOperator">)</span>.nextAll<span class="phpOperator">(</span><span class="phpOperator">)</span>.eq<span class="phpOperator">(</span><span class="phpNumber">2</span><span class="phpOperator">)</span>.children<span class="phpOperator">(</span><span class="phpOperator">)</span>.slice<span class="phpOperator">(</span><span class="phpNumber">1</span>, 17<span class="phpOperator">)</span><span class="phpKeyword">.clone<span class="phpOperator">(</span></span><span class="phpOperator">)</span><span class="phpText">;</span>
toBeReplaced<span class="phpOperator">.</span>replaceWith<span class="phpOperator">(</span>toReplaceWith<span class="phpKeyword">.clone<span class="phpOperator">(</span></span><span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Click event<span class="phpKeyword"> for </span>making a closed group open
</span>$<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">.</span>inactiveGroup'</span><span class="phpOperator">)</span>.livequery<span class="phpOperator">(</span><span class="phpString">'click'</span>, <span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span>event<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.addClass<span class="phpOperator">(</span><span class="phpString">'activeGroup'</span><span class="phpOperator">)</span>.removeClass<span class="phpOperator">(</span><span class="phpString">'inactiveGroup'</span><span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.parent<span class="phpOperator">(</span><span class="phpOperator">)</span>.nextAll<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">:</span>lt<span class="phpOperator">(</span><span class="phpNumber">3</span><span class="phpOperator">)</span>'</span><span class="phpOperator">)</span>.show<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Blank the cells
</span>$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.siblings<span class="phpOperator">(</span><span class="phpOperator">)</span>.slice<span class="phpOperator">(</span><span class="phpNumber">0</span>, 16<span class="phpOperator">)</span>.<span class="phpFunction">empty</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>Now <a title="Table 5" href="http://www.jamesmacfie.com/wp-content/uploads/2011/09/table5.html" target="_blank">that’s looking pretty swanky [table 5]</a>. But what happens if the user scrolls down the page? If the headers disappear above the top of the screen then the user isn’t going to know what column they are looking at. There’s a helpful jQuery plugin called &lt;fixed table header&gt; that keeps the header of your table at the top of the screen if you scroll to a point where it normally wouldn’t be visible. The JavaScript code to do this is:</p>
<pre class="php">
$<span class="phpOperator">(</span><span class="phpString">'table'</span><span class="phpOperator">)</span>.fixedtableheader<span class="phpOperator">(</span><span class="phpOperator">{</span>headerrowsize<span class="phpOperator">:</span><span class="phpNumber">2</span><span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p><a title="Table 6" href="http://www.jamesmacfie.com/wp-content/uploads/2011/09/table6.html" target="_blank">Check out that stationary header! [table 6]</a></p>
<p>How about we also add some hover events to the row. What this will do is when the user has their mouse over a row, the roll will get that little bit darker. This simply helps them to scan across the row more quickly as this slight colour difference will show off the current bit of data a little more easily.</p>
<pre class="css">
<span class="cssSelector">td.hoverCell, th.hoverCell {</span>
<span class="cssProperty">background-color</span><span class="cssRest">:</span><span class="cssValue"> #e0e6f6</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">td.hoverTotal {</span>
<span class="cssProperty">background-color</span><span class="cssRest">:</span><span class="cssValue"> #fa9090<span class="cssImportant">!important</span></span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
</pre>
<pre class="php">
$<span class="phpOperator">(</span><span class="phpString">'tr'</span><span class="phpOperator">)</span>.hover<span class="phpOperator">(</span><span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.children<span class="phpOperator">(</span><span class="phpString">'td, th'</span><span class="phpOperator">)</span>.addClass<span class="phpOperator">(</span><span class="phpString">'hoverCell'</span><span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.children<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">.</span>totalCol'</span><span class="phpOperator">)</span>.addClass<span class="phpOperator">(</span><span class="phpString">'hoverTotal'</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>, <span class="phpFunctionKeyword">function</span> <span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.children<span class="phpOperator">(</span><span class="phpString">'td, th'</span><span class="phpOperator">)</span>.removeClass<span class="phpOperator">(</span><span class="phpString">'hoverCell'</span><span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpOperator">(</span>this<span class="phpOperator">)</span>.children<span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">.</span>totalCol'</span><span class="phpOperator">)</span>.removeClass<span class="phpOperator">(</span><span class="phpString">'hoverTotal'</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>Now that’s a<a title="Table 7" href="http://www.jamesmacfie.com/wp-content/uploads/2011/09/table7.html" target="_blank"> fancy looking (and usable) table [table 7]</a>.</p>
<p>That’s all the table enhancements I’m  going to do. There are a couple more things you may want to consider for your table. The first could be the abbreviation of large numbers.  You could make $1,400,000 into $1.4m, for example (or even just 1.4 if all your info is in the millions).  Sometimes it’s just not necessary to display all this information. This also helps if you have lots of columns – the shorter the info in the cells, the more columns you will be able to display on the screen (not saying you should cram as much as you can on there – you don’t want to overwhelm users).</p>
<p>Something to combine with these abbreviations could be to put tool-tips on your cells that have abbreviated content in them.  These tool-tips would provide the exact values to your abbreviated content.</p>
<p>And finally, consider making your table accessible to those that use screen readers. Tables are difficult to read as it is. Imagine how difficult it is for people­­ with disabilities to get through all the data you are displaying. There’s a few things that you can (and, indeed, should) do to make sure disabled users can get the information from your table.</p>
<p>Firstly, start off your table with the ‘summary’ attribute.  This might not be needed for really simple tables, but it can increase the comprehension of more complex tables for those that use screen readers. The ‘summary’ attribute should be a description that highlights the most important elements of a table.]</p>
<p>&nbsp;</p>
<p>The &lt;caption&gt; tag should also be used on your table to not give a description like the ‘summary’ attribute but to give the title of the table.</p>
<p>The ‘summary’ attribute and &lt;caption&gt; tag should be used in conjunction with the ‘scope’ attribute and &lt;th&gt; tag. While the first two elements mentioned explain the table as a whole, the next two are used to explain the data within the table. The &lt;th&gt; tag is used to define whether the header is a column or a row. Combining this with the ‘scope’ attribute changes the order in which the cells are read out by a screen reader. Here’s an actual example of all of this in practice.</p>
<pre class="html">
<span class="htmlTableTag">&lt;table summary=<span class="htmlAttributeValue">&quot;”Internet&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;caption&gt;</span>CSS Selectors in IE6 to IE9<span class="htmlOtherTag">&lt;/caption&gt;</span>
<span class="htmlTableTag">&lt;tbody&gt;</span>
<span class="htmlTableTag">&lt;tr&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”col”&quot;</span>&gt;</span>Selector<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”col”&quot;</span>&gt;</span>&gt;IE6<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”col”&quot;</span>&gt;</span>&gt;IE7<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”col”&quot;</span>&gt;</span>&gt;IE8<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”col”&quot;</span>&gt;</span>&gt;IE9<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;/tr&gt;</span>
<span class="htmlTableTag">&lt;tr&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”row”&quot;</span>&gt;</span>* selector<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;/tr&gt;</span>
<span class="htmlTableTag">&lt;tr&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”row”&quot;</span>&gt;</span>* &gt;&gt; selector<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>No<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;/tr&gt;</span>
<span class="htmlTableTag">&lt;tr&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”row”&quot;</span>&gt;</span>* &gt;+ selector<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>No<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Static<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Almost<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;/tr&gt;</span>
<span class="htmlTableTag">&lt;tr&gt;</span>
<span class="htmlTableTag">&lt;th scope=<span class="htmlAttributeValue">&quot;”row”&quot;</span>&gt;</span>* &gt;:before and :after<span class="htmlTableTag">&lt;/th&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>No<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>No<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;td&gt;</span>Yes<span class="htmlTableTag">&lt;/td&gt;</span>
<span class="htmlTableTag">&lt;/tr&gt;</span>
<span class="htmlTableTag">&lt;/tbody&gt;</span>
<span class="htmlTableTag">&lt;/table&gt;</span>
</pre>
<p>Think I’ve missed anything (or am totally wrong about something else)? Let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2011/09/data-tables-%e2%80%93-some-incremental-improvements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Equal height columns with jQuery</title>
		<link>http://www.jamesmacfie.com/2011/08/equal-height-columns-with-jquery/</link>
		<comments>http://www.jamesmacfie.com/2011/08/equal-height-columns-with-jquery/#comments</comments>
		<pubDate>Tue, 09 Aug 2011 08:38:17 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=220</guid>
		<description><![CDATA[Funnily enough, creating two columns side by side with the same height isn&#8217;t that simple with plain CSS. There&#8217;s a few tricks to get it to work but sometimes I just can&#8217;t be bothered dealing with all the extra code. With jQuery, you can write two lines of code and get it sorted quick smart. [...]]]></description>
			<content:encoded><![CDATA[<p>Funnily enough, creating two columns side by side with the same height isn&#8217;t that simple with plain CSS. There&#8217;s a few tricks to get it to work but sometimes I just can&#8217;t be bothered dealing with all the extra code.<br />
With jQuery, you can write two lines of code and get it sorted quick smart. Sure, this method doesn&#8217;t cater for people who have javascript enabled, but these users are probably used to sites looking below average anyway <img src='http://www.jamesmacfie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Let&#8217;s say you&#8217;ve got a main column with an ID of &#8216;main&#8217;, and a sidebar with an ID of &#8216;sidebar&#8217;. Nice and original. Firstly we&#8217;ll grab the highest element of the two. Then we&#8217;ll set the height of both of these elements to that height. </p>
<pre class="javascript">
var colHeight = Math.max($('#main').height(), $('#sidebar').height());
$('#main, #sidebar').height(colHeight);
</pre>
<p>Damn. That was easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2011/08/equal-height-columns-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS tip: Word-wrap</title>
		<link>http://www.jamesmacfie.com/2011/06/css-tip-word-wrap/</link>
		<comments>http://www.jamesmacfie.com/2011/06/css-tip-word-wrap/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 03:28:06 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=199</guid>
		<description><![CDATA[I had a case today where any super long words in a container would not wrap when the word reached the end of the containing element. The text does this automatically if you have dashes or spaces in the text, but in the instance of one long word, the browser doesn&#8217;t automatically break the text [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>I had a case today where any super long words in a container would not wrap when the word reached the end of the containing element. The text does this automatically if you have dashes or spaces in the text, but in the instance of one long word, the browser doesn&#8217;t automatically break the text in parts.<br />
Then I discovered the little gem of <code>word-wrap</code>. This CSS property has two possible values: <code>normal</code> which is the default behaviour (breaks only allowed at designated breakpoints -i.e. dashes and spaces) and <code>break-word</code> which breaks the long word at the right edge of the parent container. Take the code below. The first example has no word-wrap. The second has the property word-wrap with a value of <code>break-word</code>.<br />
CSS:</p>
<pre class="css">
<span class="cssSelector">div {</span>
<span class="cssProperty">background</span><span class="cssRest">:</span><span class="cssValue"> #F1EFE0</span><span class="cssRest">;</span>
<span class="cssProperty">border</span><span class="cssRest">:</span><span class="cssValue"> solid 1px #AAA</span><span class="cssRest">;</span>
<span class="cssProperty">padding</span><span class="cssRest">:</span><span class="cssValue"> 5px</span><span class="cssRest">;</span>
<span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue"> 160px</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">div.wrap {</span>
<span class="cssProperty">word-wrap</span><span class="cssRest">:</span><span class="cssValue"> break-word</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
</pre>
<p>Code for non-wrapping element:</p>
<pre class="html">
<span class="htmlOtherTag">&lt;div&gt;</span><span class="htmlOtherTag">&lt;p&gt;</span>HereIsAnExampleOfASuperDuperLongWord<span class="htmlOtherTag">&lt;/p&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p><img class="alignnone size-full wp-image-206" title="word-wrap:normal" src="http://www.jamesmacfie.com/wp-content/uploads/2011/06/nowrap.jpg" alt="" width="297" height="42" /><br />
</br><br />
Code for wrapping element:</p>
<pre class="html">
<span class="htmlOtherTag">&lt;div class=<span class="htmlAttributeValue">&quot;wrap&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;p&gt;</span>HereIsAnExampleOfASuperDuperLongWord<span class="htmlOtherTag">&lt;/p&gt;</span><span class="htmlOtherTag">&lt;/div&gt;</span>
</pre>
<p><img class="alignnone size-full wp-image-208" title="word-wrap:break-word" src="http://www.jamesmacfie.com/wp-content/uploads/2011/06/wrap.jpg" alt="" width="181" height="64" /><br />
</br><br />
Too cool.</p>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2011/06/css-tip-word-wrap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using text-overflow across browsers</title>
		<link>http://www.jamesmacfie.com/2011/05/using-text-overflow-across-browsers/</link>
		<comments>http://www.jamesmacfie.com/2011/05/using-text-overflow-across-browsers/#comments</comments>
		<pubDate>Fri, 27 May 2011 04:19:26 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=186</guid>
		<description><![CDATA[Having only discovered the virtues of CSS&#8217;s text-overflow:ellipsis rule recently (and therefore not having to rely on determining character lengths via server side or javascript code), I was disappointed to find that Firefox doesn&#8217;t support this CSS rule (and in fact never has). If you&#8217;ve never seen this rule, what it accomplishes is adding &#8216;&#8230;&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>Having only discovered the virtues of CSS&#8217;s <code>text-overflow:ellipsis</code> rule recently (and therefore not having to rely on determining character lengths via server side or javascript code), I was disappointed to find that Firefox doesn&#8217;t support this CSS rule (and in fact never has).</p>
<p>If you&#8217;ve never seen this rule, what it accomplishes is adding &#8216;&#8230;&#8217; to the end of a text field (<code>p</code> or <code>span</code>)if the length of said field is longer than that of it&#8217;s container. For example, if you use the code below:</p>
<pre class="css">
<span class="cssSelector">p.example {</span>
<span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue"> 100px</span><span class="cssRest">;</span>
<span class="cssProperty">border</span><span class="cssRest">:</span><span class="cssValue"> 1px solid #000</span><span class="cssRest">;</span>
<span class="cssProperty">white-space</span><span class="cssRest">:</span><span class="cssValue"> nowrap</span><span class="cssRest">;</span>
<span class="cssProperty">overflow</span><span class="cssRest">:</span><span class="cssValue"> hidden</span><span class="cssRest">;</span>
<span class="cssProperty">text-overflow</span><span class="cssRest">:</span><span class="cssValue"> ellipsis</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
</pre>
<pre class="html">
<span class="htmlOtherTag">&lt;p class=<span class="htmlAttributeValue">&quot;example&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;span&gt;</span>Hello - here&#039;s some text that&#039;s obviously longer that 100px<span class="htmlOtherTag">&lt;/span&gt;</span><span class="htmlOtherTag">&lt;/p&gt;</span>
</pre>
<p>You&#8217;ll end up with a final result that looks like this:</p>
<a href="http://www.jamesmacfie.com/2011/05/using-text-overflow-across-browsers/ellipsis_eg/" rel="attachment wp-att-187"><img src="http://www.jamesmacfie.com/wp-content/uploads/2011/05/ellipsis_eg.jpg" alt="Example of CSS text-overflow: ellipsis;" title="Example of CSS text-overflow: ellipsis;" width="121" height="34" class="size-full wp-image-187" /></a>
<p>I think that&#8217;s pretty neat. Now I don&#8217;t have to rely on some javascript or server side hack that truncates text based on the number of characters in a string (obviously not as nice as, for example, the string &#8220;WWWWWWWWWW&#8221; is longer than &#8220;llllllllll&#8221; even though they have the same number of characters). This CSS rule doesn&#8217;t rely on the number of characters in a string, but rather the width of the parent container! Gold, absolute gold.</p>
<p>But firefox doesn&#8217;t support this. I was quite surprised to learn firstly that it was IE6 that introduced this feature, and secondly that there was actually a feature that I wanted to use that IE had and firefox didn&#8217;t. Go figure. The way I ended up remedying this is in firefox was by using a <a href="http://devongovett.wordpress.com/2009/04/06/text-overflow-ellipsis-for-firefox-via-jquery/" target="_blank">jQuery script written by Decon Govett</a> that dynamically figures out the width of the parent container and systematically reduces the text string of the child container until its width fits inside the parent. Then the &#8216;&#8230;&#8217; is added to the end.</p>
<p>Developers can vote for this feature to be added to firefox via the link below:<br />
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=312156" target="_blank">https://bugzilla.mozilla.org/show_bug.cgi?id=312156</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2011/05/using-text-overflow-across-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Function Declarations vs. Function Expressions</title>
		<link>http://www.jamesmacfie.com/2011/05/javascript-function-declarations-vs-function-expressions/</link>
		<comments>http://www.jamesmacfie.com/2011/05/javascript-function-declarations-vs-function-expressions/#comments</comments>
		<pubDate>Tue, 24 May 2011 08:52:08 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.jamesmacfie.com/?p=181</guid>
		<description><![CDATA[A word about how these two concepts differ in JavaScript. In case you don&#8217;t know what I mean, take these two example bits of code below. First we have a function declaration: function myFunction() { return "result"; } And here we have a function expression: var myFunction = function() { return "result"; } Both of [...]]]></description>
			<content:encoded><![CDATA[<p>A word about how these two concepts differ in JavaScript.<br />
In case you don&#8217;t know what I mean, take these two example bits of code below.</p>
<p>First we have a function declaration:</p>
<pre class="javascript">
function myFunction() { return "result"; }
</pre>
<p>And here we have a function expression:</p>
<pre class="javascript">
var myFunction = function() { return "result"; }
</pre>
<p>Both of these functions, if referenced further on in your code, are for all intents and purposes the same. Both are going to return a string with a value of &#8220;result&#8221;. The difference lies in how (and when) the browser loads them into the execution context. With a function declaration, these functions are loaded before the interpreter has run through any code at all. With a function expression, the function will only be loaded once the interpreter has run it&#8217;s way down and past the particular line of code that it sits in.</p>
<p>Function declarations will always run &#8211; the browser will always be able to find myFunction() because it has been loaded before any code has run. Even if you refer to myFunction() on your first line of code, you&#8217;re going to be ok. Take the example below &#8211; the function has been read and added to the execution context already so when it&#8217;s called, the function will return out the desired result.</p>
<pre class="javascript">
alert(myFunction());		//result
function myFunction() { return "result"; }
</pre>
<p>But any function written as a function expression will only run if the function is called <em>after</em> the function expression has been initialised. In the example below, myFunction() will never run because it is called before the code has had a chance to initialise it and hence will cause an &#8220;unexpected identifier&#8221; error.</p>
<pre class="javascript">
alert(myFunction());		//Oh no - error!
var myFunction = function() { return "result"; }
</pre>
<p>That&#8217;s probably all you need to know on the subject. But if, like me, you need to know more about stuff like this then check out <a target="_blank" href="http://kangax.github.com/nfe/#expr-vs-decl">this article</a> by Juriy Zaytsev.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2011/05/javascript-function-declarations-vs-function-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Note on URL Design</title>
		<link>http://www.jamesmacfie.com/2010/11/a-quick-note-on-url-design/</link>
		<comments>http://www.jamesmacfie.com/2010/11/a-quick-note-on-url-design/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 14:31:33 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[URLs]]></category>

		<guid isPermaLink="false">http://underconstruction.jamesmacfie.com/?p=63</guid>
		<description><![CDATA[Clean URLs are an important consideration of website design. The URL is a fundamental part of the internet - they repersent a page uniquely and permanently. They should be human-readable, consitant, and contain any important keywords.]]></description>
			<content:encoded><![CDATA[<p>Clean URLs are an important consideration of website design. The URL is a fundamental part of the internet &#8211; they repersent a page uniquely and permanently. They should be human-readable, consitant, and contain any important keywords.</p>
<p>Because a URL should always be considered permanent, having a good structure in place will aid you when the time comes to update your site. Having a incomprehensible URL that only a computer can understand is not going to be shifted across to a newly designed site easily. Also, if you change the structure after any amount of time, then if anyone on the web has already linked to your old URL then no one is going to be able to navigate from there to your site as the URL won&#8217;t exist anymore. Having 301 redirects will fix this, but it&#8217;s more work for a developer; work that shouldn&#8217;t have to be done in the first place.</p>
<p>Having a URL that is user-friendly (or at least human readable) has one huge benefit &#8211; it makes your page more SEO friendly. If you have keywords in your URL (not stuffed with keywords, of course. It still has to be user friendly), then these will be picked up by Google etc as being an important part of your page.</p>
<p>A good designer or developer will consider this when making a site. It&#8217;s a small job to make a consistant, readable structure from the start &#8211; don&#8217;t make the mistake of having to tackle this later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jamesmacfie.com/2010/11/a-quick-note-on-url-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.jamesmacfie.com @ 2013-05-24 10:48:12 -->