<?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>Diego Lago</title>
	<atom:link href="http://www.diegolago.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.diegolago.co.uk</link>
	<description>Diego Lago&#039;s Web Portfolio and Technology Lab</description>
	<lastBuildDate>Tue, 22 Nov 2011 10:24:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Organise your JavaScript and make your life easier</title>
		<link>http://www.diegolago.co.uk/development/organise-your-javascript-and-make-your-life-easier/</link>
		<comments>http://www.diegolago.co.uk/development/organise-your-javascript-and-make-your-life-easier/#comments</comments>
		<pubDate>Fri, 13 May 2011 15:31:58 +0000</pubDate>
		<dc:creator>Diego</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[optimisation]]></category>

		<guid isPermaLink="false">http://www.diegolago.co.uk/?p=330</guid>
		<description><![CDATA[Intro It is well known that the use of JavaScript has increased notoriously in the last five years or so. We now certainly have heavy JavaScript applications like Gmail but even content-based websites have been adding some serious behaviour to &#8230; <a href="http://www.diegolago.co.uk/development/organise-your-javascript-and-make-your-life-easier/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>Intro</h2>
<p>It is well known that the use of JavaScript has increased notoriously in the last five years or so.  We now certainly have heavy JavaScript applications like Gmail but even content-based websites have been adding some serious behaviour to their pages.</p>
<p>Libraries like jQuery have allowed developers and designers that might have avoided JavaScript in the past to start using it substantially in their projects.</p>
<p>But, as requirements for interactive components rise, the management of all that code might become overwhelming.</p>
<h2>A common scenario</h2>
<p>Let’s take a site with two types of pages: a product catalogue page and a product detail page. On top of that, some detail pages will have a “Related Products” section at the bottom of the page.</p>
<ol>
<li>We want that when a user clicks on a product thumbnail image to launch a modal view window with a zoomed version. This functionality would apply on thumbnails on the catalogue page, secondary images in the detail page and related products thumbnails. We could argue this is a common functionality across all page types.</li>
<li>We also want to do some DOM manipulation on the details page.</li>
<li>Finally, we want the related products listed and displayed as a carousel.</li>
</ol>
<h2>Did you think jQuery?</h2>
<p>So the first thought might be to get some jQuery plugins to do all the magic. The bottom of all your html pages might look like this:</p>
<pre class="brush: xml; title: ;">
&lt;script src=&quot;js/jquery.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/modal-view-plugin.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/carousel-plugin.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;js/my-scripts.js&quot;&gt;&lt;/script&gt;
</pre>
<p>my-scripts.js might look like the one below:</p>
<pre class="brush: jscript; title: ;">
$(document).ready(function() {

  // code to call modal view in all pages

  // code to manipulate some DOM elements in detail page

  // code to call related products carousel

});
</pre>
<p>Should we call the carousel functionality when the user lands on a catalogue page? Nope. The issue gets bigger as we start to add more page specific functionality on our main js file and more page types across the site.</p>
<h2>Solution 1.0</h2>
<p>There is a technique that allows you to organise and execute the code for a given page only when is needed. It&#8217;s called the <a href="http://www.viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution/">Garber-Irish implementation</a>.</p>
<p>I won’t go into detail on this technique as the authors’ sites do a very good job on that.</p>
<p>In a nutshell, your JS code will read what type of page it is currently loaded from attributes in the html’s body tag.  Based on that, it will execute shared code across pages and then it will start moving on to more page specific code.</p>
<p>A snippet of how our problem might be implemented with this technique in my-scripts.js is below:</p>
<pre class="brush: jscript; title: ;">
SITENAME = {
  allpages: {
    init: function() {
      // application-wide code:
      // code to call modal view in all pages
    }
  },

  detailpage: {
    init: function() {
      // controller-wide code:
      // code to manipulate some DOM elements in detail page
    },

    relatedproducts: function() {
      // action-specific code:
      // code to call carousel in related products when they exist
    }
  }
};
</pre>
<h2>Solution 2.0</h2>
<p>This technique is great for organising code but, on top of that, we want to improve on the optimisation department:  welcome to the world of dependency management.</p>
<p>There are a few libraries that let you call files only when you need to. Until now we would either call all files in all pages or just list the ones needed in the html – which is hard to maintain.</p>
<p>These JavaScript loaders, as they are commonly referred, can play nicely with the Garber-Irish technique mentioned above. I particularly use <a href="http://requirejs.org/">require.js</a> but there are many more out there.</p>
<p>The approach here is to still use the sections from the Garber-Irish example but we also adding in my-scripts.js which files we want to load for each type of page:</p>
<pre class="brush: jscript; title: ;">

SITENAME = {
  allpages: {
    init: function() {
      require([&quot;jquery&quot;, &quot;modal-view-plugin&quot;], function($) {
        // jquery.js and modal-view-plugin.js plugin have been loaded.
        $(function() {
          // application-wide code:
          // code to call modal view in all pages
        });
      });
    }
  },

  detailpage: {
    init: function() {
      // controller-wide code:
      // code to manipulate some DOM elements in detail page
    },

    relatedproducts: function() {
      require([&quot;carousel-plugin&quot;], function($) {
        // carousel-plugin.js plugin have been loaded.
        $(function() {
          // action-specific code:
          // code to call carousel in related products when they exist
        });
      });
    }
  }
};
</pre>
<p>Organising JavaScript code is an evolving topic. If you are building web applications instead, this might not be the best solution.</p>
<p>But for sites with lots of JavaScript and, more specifically, DOM eye-candy the combination of these techniques might help you keep your code more manageable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/development/organise-your-javascript-and-make-your-life-easier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My very own dark theme for Aptana Studio 3</title>
		<link>http://www.diegolago.co.uk/development/my-very-own-dark-theme-for-aptana-studio-3/</link>
		<comments>http://www.diegolago.co.uk/development/my-very-own-dark-theme-for-aptana-studio-3/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 15:17:19 +0000</pubDate>
		<dc:creator>Diego</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[aptana editors]]></category>

		<guid isPermaLink="false">http://www.diegolago.co.uk/?p=305</guid>
		<description><![CDATA[Aptana Studio 3 (beta) has been out for a little while. I&#8217;ve tried previous versions of it but never felt comfortable about switching entirely. There are plenty of great features that this IDE brings in but from the moment I &#8230; <a href="http://www.diegolago.co.uk/development/my-very-own-dark-theme-for-aptana-studio-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.aptana.com/products/studio3/" rel="nofollow">Aptana Studio 3 (beta)</a> has been out for a little while. I&#8217;ve tried previous versions of it but never felt comfortable about switching entirely.</p>
<p>There are plenty of great features that this IDE brings in but from the moment I installed it I wasn&#8217;t impressed with the available text editor themes.</p>
<p>Aptana comes with many editor themes for you to choose. However, these default ones aren&#8217;t that great for front-end coding. The html defaults were a bit too simple and didn&#8217;t feel any better than the mighty <a href="http://notepad-plus-plus.org/" rel="nofollow">notepad++</a>.</p>
<p>So I started looking how to get my own theme rolling and it wasn&#8217;t easy to find out the right way to do it at first. </p>
<p>Firstly, it took me a while to get to the right <a href="https://aptanastudio.tenderapp.com/kb/aptana-studio-preferences/aptana-studio-3-themes">documentation in Aptana to style the different components of code in html, css, and javaScript</a>. Once I got that, I re-styled a default theme and once happy, I exported it. All that from clicking Windows/Preferences/Aptana/Themes.</p>
<p>The exported file is a ruby ruble. In there you can see all the different colours you just set in a hash array. But how do you get that back into your installation?</p>
<p>Ruby bundles are not to be imported back into Aptana by clicking the import button next to the export one I previously mentioned &#8211; somehow. Instead, create a folder and name it &#8220;theme.ruble&#8221; and drop it in the &#8220;Aptana Rubles&#8221; folder in your user&#8217;s folder. In my case it all ended up looking like was C:\Documents and Settings\diego\Aptana Rubles\theme.ruble\my-bundle.rb</p>
<p>One of the values listed in bundle.rb is &#8220;name&#8221;. That&#8217;s the name of the theme. Once you restart Aptana, you&#8217;ll see your new theme listed in there.</p>
<p>If you want to try mine one. Here you have &#8220;Spring&#8221;:</p>
<pre class="brush: ruby; title: ;">
require 'ruble/theme'

Ruble::Theme.add({
  'punctuation' =&gt; '#c0c0c0ff',
  'keyword' =&gt; '#ffb18cff',
  'meta.brace.square.js' =&gt; '#ffb18cff',
  'meta.diff.header' =&gt; '#ffffffff,#5685e3ff',
  'meta.diff.index' =&gt; '#ffffffff,#3467d1ff,italic',
  'markup.deleted' =&gt; '#ffffffff,#ff3d3dff',
  'entity.other.attribute-name.class.html' =&gt; '#fcfdc6ff',
  'hyperlink' =&gt; '#1daabaff',
  'meta.brace.curly.js' =&gt; '#a3e2f8ff',
  'upport.constant.property-value.css' =&gt; '#ff80ffff',
  'string' =&gt; '#b0edc4ff',
  'markup.bold' =&gt; 'bold',
  'name' =&gt; 'Spring',
  'selection' =&gt; '#c6dffeff',
  'console.warning' =&gt; '#fcfdc6ff',
  'comment.block' =&gt; '#818fa0ff',
  'caret' =&gt; '#000000',
  'entity.other.attribute-name.class.css' =&gt; '#fcfdc6ff',
  'console.prompt' =&gt; '#a3e2f8ff',
  'entity.name.tag.structure.any.html' =&gt; '#9ce1f8ff',
  'constant.other.placeholder.py' =&gt; '#ff4a46ff',
  'console.error' =&gt; '#ff4a46ff',
  'entity.other.attribute-name.html' =&gt; '#fcfdc6ff',
  'entity.name.tag.inline.any.html' =&gt; '#9ee1f8ff',
  'entity.name.function' =&gt; '#1daabaff',
  'meta.separator.diff' =&gt; '#81d9f5ff,#3467d1ff,italic',
  'constant.numeric.js' =&gt; '#ffb18cff',
  'markup.inserted' =&gt; '#000000ff,#73ff65ff',
  'punctuation.definition.tag.end.html' =&gt; '#81d9f5ff',
  'text' =&gt; '#c5c5c5ff',
  'lineHighlight' =&gt; '#00000012',
  'markup.underline' =&gt; 'underline',
  'constant.language' =&gt; '#a3e2f8ff',
  'entity.other.attribute-name.id.html' =&gt; '#fcfdc6ff',
  'comment' =&gt; '#7c8b9eff',
  'entity.name.tag.block.any.html' =&gt; '#9ce1f8ff',
  'foreground' =&gt; '#c0c0c0',
  'storage' =&gt; '#ffb18cff',
  'meta.diff.range' =&gt; '#ffffffff,#3467d1ff,italic',
  'entity.name.type' =&gt; '#1daabaff',
  'meta.separator' =&gt; '#ffffffff,#3467d1ff',
  'invalid' =&gt; '#ffffffff,#ff4a46ff',
  'background' =&gt; '#323e43',
  'support' =&gt; '#a3e2f8ff',
  'variable' =&gt; '#ffb08aff',
  'source.css' =&gt; '#ffb18cff',
  'meta.brace.round.js' =&gt; '#fcfdc6ff',
  'support.type.property-name.css' =&gt; '#c5c5c5ff',
  'markup.italic' =&gt; '#bef58bff',
  'punctuation.definition.tag.begin.html' =&gt; '#81d9f5ff',
  'markup.changed' =&gt; '#ffffffff,#f5c411ff',
  'entity.other.attribute-name.id.css' =&gt; '#b0edc4ff',
  'console.input' =&gt; '#b0edc4ff',
  'entity.name.tag.css' =&gt; '#9ce1f8ff'})
</pre>
<p>An screenshot of how cool it looks is also below:</p>
<p><a href="http://www.diegolago.co.uk/wp-content/uploads/2011/02/aptana-theme.png"><img class="aligncenter size-full wp-image-308" title="aptana-theme" src="http://www.diegolago.co.uk/wp-content/uploads/2011/02/aptana-theme.png" alt="example of aptana text editor theme" width="460" height="671" /></a></p>
<p>The font I use is Droid Android Monospace 11pt. Get yours from this excellent post at <a href="http://hivelogic.com/articles/top-10-programming-fonts">hivelogic.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/development/my-very-own-dark-theme-for-aptana-studio-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML5, WebGL, web audio, and faster JavaScript &#8211; Firefox 4 Demo</title>
		<link>http://www.diegolago.co.uk/development/html5-webgl-web-audio-and-faster-javascript-firefox-4-demo/</link>
		<comments>http://www.diegolago.co.uk/development/html5-webgl-web-audio-and-faster-javascript-firefox-4-demo/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 10:01:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Firefox browsers html5]]></category>

		<guid isPermaLink="false">http://www.diegolago.co.uk/?p=296</guid>
		<description><![CDATA[Christian Heilmann&#8216;s presentation on HTML5 yesterday was excellent. He always manage to convey his ideas in a very clear way and the outcome is always thought-provoking. This time he also put questions back to us the developers about what the &#8230; <a href="http://www.diegolago.co.uk/development/html5-webgl-web-audio-and-faster-javascript-firefox-4-demo/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://icant.co.uk/">Christian Heilmann</a>&#8216;s <a href="http://www.wait-till-i.com/2011/02/09/using-html5-sensibly-and-multimedia-on-the-web-speaking-at-the-london-ajax-meetup/">presentation on HTML5</a> yesterday was excellent. He always manage to convey his ideas in a very clear way and the outcome is always thought-provoking. This time he also put questions back to us the developers about what the right way for using HTML5 might be.</p>
<p>He also talked about multimedia and HTML5. What I liked the most from that was a demo from Mozilla: <a href="http://videos.mozilla.org/serv/mozhacks/flight-of-the-navigator/">http://videos.mozilla.org/serv/mozhacks/flight-of-the-navigator/</a> is really interesting because of what it actually is and does – more of that here <a href="http://vocamus.net/dave/?p=1233">http://vocamus.net/dave/?p=1233</a></p>
<p>You’ll need Firefox 4 or Chrome to run it.</p>
<p>There are a few more demos at <a href="http://hacks.mozilla.org/demos/">http://hacks.mozilla.org/demos/</a> if you want to try.</p>
<p>I got really excited when I saw all this because they are built on open technologies and the premise is simple: the resources (music, videos, photos, tweets) are pulled from somewhere else unlike flash where everything is embedded inside the movie.</p>
<p>Christian presentation was held at <a rel="nofollow" href="http://skillsmatter.com/">skillsmatter</a>. I found the place to be one of the best for training and free events on the latest stuff. Their staff is very friendly and if you&#8217;re looking for training given by experts in London you should check them out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/development/html5-webgl-web-audio-and-faster-javascript-firefox-4-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The User Experience wheel</title>
		<link>http://www.diegolago.co.uk/user-experience/the-user-experience-wheel/</link>
		<comments>http://www.diegolago.co.uk/user-experience/the-user-experience-wheel/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 16:43:57 +0000</pubDate>
		<dc:creator>Diego</dc:creator>
				<category><![CDATA[User Experience]]></category>
		<category><![CDATA[infographics]]></category>
		<category><![CDATA[ux]]></category>

		<guid isPermaLink="false">http://www.diegolago.co.uk/?p=271</guid>
		<description><![CDATA[Although the credit to the concept goes to IBM Customer Facing Solutions I thought to create my own &#8220;flavour&#8221; of it (above). What I find interesting in this User Experience wheel of skills is that, at different levels of expertise &#8230; <a href="http://www.diegolago.co.uk/user-experience/the-user-experience-wheel/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a class="fancybox" href="http://www.diegolago.co.uk/wp-content/uploads/2011/01/ux-wheel.png"><img class="aligncenter size-full wp-image-272" title="ux-wheel" src="http://www.diegolago.co.uk/wp-content/uploads/2011/01/ux-wheel.png" alt="User Experience skills wheel" width="460" /></a>Although the credit to the concept goes to <a rel="nofollow" href="http://www.customerfacingsolutions.com/">IBM Customer Facing Solutions</a> I thought to create my own &#8220;flavour&#8221; of it (above).</p>
<p>What I find interesting in this User Experience wheel of skills is that, at different levels of expertise and except for Content Strategy, my experience spans across five of these segments:</p>
<ul>
<li>User Interface: Design, Semantics, HTML5, CSS</li>
<li>Platform: desktop and mobile devices, browsers</li>
<li>Functionality: JavaScript programming, AJAX, JSON/XML</li>
<li>Usability &amp; Accessibility</li>
<li>Information Architecture</li>
</ul>
<p>Recently, I&#8217;ve also noticed that many recruitment agents tend to see IA&#8217;s as the only UX professionals.</p>
<p>While it may be true that UX job descriptions tend to lean towards Information Architecture, I think it&#8217;s important to differentiate between these two and secondly, and perhaps more importantly, understand the other components of the discipline and how they complement each other.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/user-experience/the-user-experience-wheel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding art deco typography in Istria</title>
		<link>http://www.diegolago.co.uk/travel/finding-art-deco-typography-in-istria/</link>
		<comments>http://www.diegolago.co.uk/travel/finding-art-deco-typography-in-istria/#comments</comments>
		<pubDate>Sat, 29 Jan 2011 14:28:37 +0000</pubDate>
		<dc:creator>Diego</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Travel]]></category>
		<category><![CDATA[Typography]]></category>

		<guid isPermaLink="false">http://www.diegolago.co.uk/?p=258</guid>
		<description><![CDATA[I have taken this picture a little while back and thought to post it. Istria, on the North West of Croatia, is a land with a very mixed heritage. Having been under Venecian, Astro-Hungarian, Fascist Italian and Communist Yugoslavian rulers &#8230; <a href="http://www.diegolago.co.uk/travel/finding-art-deco-typography-in-istria/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have taken this picture a little while back and thought to post it.</p>
<div id="attachment_259" class="wp-caption aligncenter" style="width: 470px"><a class="fancybox" href="http://www.diegolago.co.uk/wp-content/uploads/2011/01/istria-type.jpg"><img class="size-full wp-image-259" title="istria-type" src="http://www.diegolago.co.uk/wp-content/uploads/2011/01/istria-type.jpg" alt="Art deco type in Istrian wall" width="460" height="345" /></a><p class="wp-caption-text">Istrian aqueduct</p></div>
<p style="text-align: center;">
<p>Istria, on the North West of Croatia, is a land with a very mixed heritage. Having been under Venecian, Astro-Hungarian, Fascist Italian and Communist Yugoslavian rulers you could imagine that.</p>
<p>The country side, or the inner-Istria, has kept its Italian feel to this day. This picture was taken in Motovun, and it clearly comes from the time the Italian rulers were imposing everyone to speak Italian or else. Nice..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/travel/finding-art-deco-typography-in-istria/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Navigating the Paris Metro</title>
		<link>http://www.diegolago.co.uk/travel/navigating-the-paris-metro/</link>
		<comments>http://www.diegolago.co.uk/travel/navigating-the-paris-metro/#comments</comments>
		<pubDate>Thu, 27 Jan 2011 17:02:18 +0000</pubDate>
		<dc:creator>Diego</dc:creator>
				<category><![CDATA[Travel]]></category>
		<category><![CDATA[urban design]]></category>

		<guid isPermaLink="false">http://www.diegolago.co.uk/?p=216</guid>
		<description><![CDATA[The underground system in Paris, the Metro, is so different in so many aspects to the more familiar tube from London. My first impression was capitalism doesn’t strike as hard there as in London. There are not as many ads &#8230; <a href="http://www.diegolago.co.uk/travel/navigating-the-paris-metro/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The underground system in Paris, the Metro, is so different in so many aspects to the more familiar tube from London.</p>
<p style="text-align: center;"><a class="fancybox" href="http://www.diegolago.co.uk/wp-content/uploads/2011/01/paris-metro.gif"><img class="aligncenter size-large wp-image-250" title="paris-metro" src="http://www.diegolago.co.uk/wp-content/uploads/2011/01/paris-metro-1015x1024.gif" alt="Map of Paris Metro" width="460" height="464" /></a></p>
<p>My first impression was capitalism doesn’t strike as hard there as in London. There are not as many ads neither inside the carriages nor on the platforms as in London, where every single inch of space is used to promote the latest musicals or the new cool <a href="http://www.t6water.co.uk/" rel="nofollow">home water purifying system</a>.</p>
<p>To my polluted eye it results in a bit of desolation in some parts. You can easily find yourself walking through corridors that are totally empty which could be exploited in creative ways.</p>
<p>But there are also some great pluses with the Paris Metro that I&#8217;m sure the daily commuter over there might appreciate &#8211; I do &#8211; the ticket price is way cheaper that London fares.</p>
<p>I haven’t used the Navigo card, Paris version of the Oyster, but the old school tiny &#8220;billet&#8221; is cheaper that a single journey on a lovely London bus.</p>
<p>And I had no problem to follow indications while interchanging lines in Paris either. I’ve found most of the stations having easy-to-follow signs. The fact that the lines are known by numbers rather than <a href="http://en.wikipedia.org/wiki/Bakerloo_line">merged locations</a> is something I appreciate too.</p>
<p>Now an incredible plus is that you can actually use your phone while being underground. Yes, really! How can that be? The French found a way before the British? Well, maybe they just care enough to invest in something that for sure might improve the commuter&#8217;s journey and even the economy if you&#8217;re optimistic.</p>
<p>And no, I haven&#8217;t heard anyone talking loud on the phone while in the train.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/travel/navigating-the-paris-metro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX loader object with jQuery</title>
		<link>http://www.diegolago.co.uk/development/ajax-loader-object-with-jquery/</link>
		<comments>http://www.diegolago.co.uk/development/ajax-loader-object-with-jquery/#comments</comments>
		<pubDate>Fri, 14 Jan 2011 15:08:54 +0000</pubDate>
		<dc:creator>Diego</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://www.diegolago.co.uk/?p=174</guid>
		<description><![CDATA[See Demo in Fiddle or Play with the code This is a tiny snippet I came up with to inform an user that something is going on while an AJAX request is taking place. There are many examples of this &#8230; <a href="http://www.diegolago.co.uk/development/ajax-loader-object-with-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a class="btn" href="http://jsfiddle.net/springmile/2VxA2/18/embedded/result/">See Demo in Fiddle</a> or <a class="btn" href="http://jsfiddle.net/springmile/2VxA2/18/">Play with the code</a></p>
<p>This is a tiny snippet I came up with to inform an user that something is going on while an AJAX request is taking place.</p>
<p>There are many examples of this already. I just needed a compact object that could be called from anywhere so here&#8217;s the start:</p>
<h2>JavaScript</h2>
<pre class="brush: jscript; title: ;">
var ajaxLoader = function () {
  var start = function() {
   };

   var stop = function() {
   };

   return {
   // declare which properties and methods are supposed to be public
     start: start,
     stop: stop
   }
}();
</pre>
<p>I&#8217;m using the <a href="http://www.wait-till-i.com/2007/08/22/again-with-the-module-pattern-reveal-something-to-the-world/">revealing module pattern</a> here as it keeps things tidy and it&#8217;s almost self explanatory.</p>
<p>When you need to show the &#8220;Loading.. Please wait.&#8221; message you call ajaxLoader.start(). Then hide it with ajaxLoader.stop().</p>
<p>The start method is as follows:</p>
<pre class="brush: jscript; title: ;">
var start = function() {
  var pageHeight = $(document).height();

  // if loader already exists, just show it
  // otherwise add markup to DOM
  if ($('#load-overlay').length) {
    // assign height again as it might have increased due to DOM additions
    $('#load-overlay').css({
      'height' : pageHeight
    });
    $('#load-overlay, #load-indicator').show();
  }
  else {
    $('body').append('&lt;div id=&quot;load-overlay&quot;&gt;&lt;/div&gt;&lt;div id=&quot;load-indicator&quot;&gt;&lt;p&gt;Loading...&lt;/p&gt;&lt;/div&gt;');
    $('#load-overlay').css({
      'height' : pageHeight
    });
  }
};
</pre>
<p>We add the needed html, the loading div and an overlay behind, just once. Then we show or hide them when needed.</p>
<p>If you need to support IE6 be aware of <a href="http://www.throbs.net/web/articles/IE-SELECT-bugs/#ieZIndex">select elements ignoring z-index</a>. You might want to add this bit below just after the previous snippet:</p>
<pre class="brush: jscript; title: ;">
// for ie6 only (feature detection used)
if (typeof document.body.style.maxHeight === 'undefined') {
  // hide visible selects for proper overlay implementation
  $('select').hide();
}
</pre>
<p>The stop method couldn&#8217;t be easier:</p>
<pre class="brush: jscript; title: ;">
var stop = function() {
  $('#load-overlay, #load-indicator').hide();

  // for ie6 only (feature detection used)
  if (typeof document.body.style.maxHeight === 'undefined') {
    //show hidden selects for proper overlay implementation
    $('select').show();
  }
};
</pre>
<p>Just hide both, the loading div and the semitransparent overlay. Show the selects as well if you&#8217;re supporting IE6.</p>
<p>The whole object is below:</p>
<pre class="brush: jscript; title: ;">
/**
 * AJAX Loader Object
 * uses the revealing module pattern
 * start it by calling ajaxLoader.start();
 * stop it by calling ajaxLoader.stop();
 */
var ajaxLoader = function () {

  var start = function() {
    var pageHeight = $(document).height();

    // if loader already exists, just show it
    // otherwise add markup to DOM
    if ($('#load-overlay').length) {
      // assign height again as it might have increased due to DOM additions
      $('#load-overlay').css({
        'height' : pageHeight
      });
      $('#load-overlay, #load-indicator').show();
    }
    else {
      $('body').append('&lt;div id=&quot;load-overlay&quot;&gt;&lt;/div&gt;&lt;div id=&quot;load-indicator&quot;&gt;&lt;p&gt;Loading...&lt;/p&gt;&lt;/div&gt;');
      $('#load-overlay').css({
        'height' : pageHeight
      });
    }

    // for ie6 only (feature detection used)
    if (typeof document.body.style.maxHeight === 'undefined') {
      // hide visible selects for proper overlay implementation
      $('select').hide();
    }
  };

  var stop = function() {
    $('#load-overlay, #load-indicator').hide();

    // for ie6 only (feature detection used)
    if (typeof document.body.style.maxHeight === 'undefined') {
      //show hidden selects for proper overlay implementation
      $('select').show();
    }
  };

  return {
    // declare which properties and methods are supposed to be public
    start: start,
    stop: stop
  }
}();
</pre>
<h2>CSS</h2>
<pre class="brush: css; title: ;">
#load-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 20px;
  margin-top: -10px; /* set to a negative number 1/2 of height */
  margin-left: -50px; /* set to a negative number 1/2 of width */
  border: 4px solid #888;
  z-index: 1001;
  background: #fff;
  padding: 10px;
}
* html #load-indicator {
  position: absolute;
}
#load-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: #666 none 50% 50% repeat;
  opacity: .50;
  filter:Alpha(Opacity=50);
}
</pre>
<p>#load-indicator gets its way to be centred in the middle of the page, both in height and width.</p>
<p>#load-overlay expands to fill the full width and height of the page.</p>
<h2>What&#8217;s next?</h2>
<p>I leave it to the avid coder to take this further as needed. Particularly the CSS section where some might like to add <a href="http://www.ajaxload.info/">spinning wheels</a> and other much needed eye candy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/development/ajax-loader-object-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Flowplayer a bit more accessible</title>
		<link>http://www.diegolago.co.uk/development/making-flowplayer-a-bit-more-accessible/</link>
		<comments>http://www.diegolago.co.uk/development/making-flowplayer-a-bit-more-accessible/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 17:13:14 +0000</pubDate>
		<dc:creator>Diego</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Snippets]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://127.0.0.1:4001/wordpress/?p=98</guid>
		<description><![CDATA[See Demo in Fiddle or Play with the code Flowplayer is a great Flash video player for embedding video streams into your web pages. It&#8217;s free, open source and well documented. The Flowplayer website has plenty of examples. However, I &#8230; <a href="http://www.diegolago.co.uk/development/making-flowplayer-a-bit-more-accessible/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a class="btn" href="http://jsfiddle.net/springmile/tKa7Z/8/embedded/result/">See Demo in Fiddle</a> or <a class="btn" href="http://jsfiddle.net/springmile/tKa7Z/8/">Play with the code</a></p>
<p><a href="http://flowplayer.org/">Flowplayer</a> is a great Flash video player for embedding video streams into your web pages. It&#8217;s free, open source and well documented.</p>
<p>The Flowplayer website has plenty of examples. However, I had to add a bit of bespoke code on a project that required a solid accessibility implementation.</p>
<p>The issue I&#8217;ve found was around keyboard navigation. The default controls (Play, Pause, Mute, etc) are done in Flash, which I didn&#8217;t feel was the right approach in this case. The good thing is that there is also a <a href="http://flowplayer.org/demos/plugins/javascript/index.html">HTML based control bar available</a>.</p>
<p>But even the HTML based controls didn&#8217;t play well with keyboard navigation.</p>
<p>With a bit of JavaScript code I was able to add keyboard navigation to a page with several players.</p>
<p>The code to look at is mainly the html snippet and the JS magic:</p>
<h2>HTML</h2>
<p>Just container div&#8217;s for the videos and their controls. &#8220;hulu&#8221; is the Flowplayer class that styles the controls.</p>
<p>You can add as many video players as you need providing you assign unique id&#8217;s to both, the player placeholder and the controls&#8217; container.</p>
<pre class="brush: xml; title: ;">
&lt;div class=&quot;video&quot;&gt;
 &lt;!-- player #1 --&gt;
 &lt;a id=&quot;player-1&quot; class=&quot;player&quot; href=&quot;http://blip.tv/file/get/KimAronson-TwentySeconds58192.m4v&quot;&gt;&lt;/a&gt;
 &lt;!-- controlbar container --&gt;
 &lt;div id=&quot;controlbar-1&quot; class=&quot;controlbar hulu&quot;&gt;&lt;/div&gt;
 &lt;/div&gt;

 &lt;div class=&quot;video&quot;&gt;
 &lt;!-- player #2 --&gt;
 &lt;a id=&quot;player-2&quot; class=&quot;player&quot; href=&quot;http://blip.tv/file/get/KimAronson-TwentySeconds63617.m4v&quot;&gt;&lt;/a&gt;
 &lt;!-- controlbar container --&gt;
 &lt;div id=&quot;controlbar-2&quot; class=&quot;controlbar hulu&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<h2>JavaScript</h2>
<p>In this JS snippet we loop through the videos&#8217; containers and gather some info from them. Then call Flowplayer as its site advises.</p>
<p>Finally we add tabindex=-1 to the link on the movie so doesn&#8217;t get focus from the keyboard and add href attributes to the play and mute controls to gain focus.</p>
<p>By the power of jQuery&#8217;s delegate we modify the values of these href so the user gets a little clue on the state of the video (playing, paused, muted, and unmuted) from the browser address bar.</p>
<pre class="brush: jscript; title: ;">
$(document).ready(function() {

  $('.video').each(function(){
    var $video= $(this),
         playerId = $video.find('.player').attr('id'),
         controlbarId = $video.find('.controlbar').attr('id');

    $f(playerId, &quot;http://releases.flowplayer.org/swf/flowplayer-3.2.5.swf&quot;, {
    // don't start automatically
      clip: {
        autoPlay: false,
        autoBuffering: true
      },

      // disable default controls
      plugins: {controls: null}

    // install HTML controls inside element whose id is &quot;hulu&quot;
    }).controls(controlbarId, {duration: 25});

    // keyboard navigation adjustments
    // set which controls to receive focus
    $video.find('.player').attr('tabindex','-1');
    $video.find('.controlbar a.play').attr('href','#play');
    $video.find('.controlbar a.mute').attr('href','#mute');

    // modify href to show state of video
    // avoid href=&quot;#&quot; or href=&quot;javascript:void(0);
    $pane.find('.controlbar').delegate('a', 'click', function(){
    if ($(this).hasClass('pause')) {
      $(this).attr('href','#play');
    }
    else if ($(this).hasClass('play')) {
      $(this).attr('href','#pause');
    }
    else if ($(this).hasClass('mute')) {
      $(this).attr('href','#unmute');
    }
    if ($(this).hasClass('unmute')) {
      $(this).attr('href','#mute');
    }
  });

});
</pre>
<p><strong>Note:</strong> If you&#8217;re trying this at home make sure to download all the resources &#8211; see &#8220;Manage Resources&#8221; on the left hand side nav in Fiddle.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.diegolago.co.uk/development/making-flowplayer-a-bit-more-accessible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.338 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-20 23:56:21 -->

