<?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>Jamie Thompson &#187; jQuery</title>
	<atom:link href="http://jamiethompson.co.uk/tags/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamiethompson.co.uk</link>
	<description>Web Developer</description>
	<lastBuildDate>Thu, 09 Sep 2010 12:16:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery Document Meta Plugin</title>
		<link>http://jamiethompson.co.uk/web/2010/04/09/jquery-document-meta-plugin/</link>
		<comments>http://jamiethompson.co.uk/web/2010/04/09/jquery-document-meta-plugin/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 18:30:03 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://jamiethompson.co.uk/?p=247</guid>
		<description><![CDATA[Got some persistent variables you want to pass from the server-side into your jQuery application? If you&#8217;ve got lots of complex data then you probably want to pull it in as JSON data, but for a handful of scalar variables it can be nice to just output them in the document head as meta tags.

&#60;meta [...]]]></description>
			<content:encoded><![CDATA[<p>Got some persistent variables you want to pass from the server-side into your jQuery application? If you&#8217;ve got lots of complex data then you probably want to pull it in as JSON data, but for a handful of scalar variables it can be nice to just output them in the document head as meta tags.</p>
<pre class="brush: html">
&lt;meta name="user_id" content="1337" /&gt;
&lt;meta name="user_name" content="Gary Barlow" /&gt;
</pre>
<p>I&#8217;m thinking core stuff like user ids which never change and get used again and again in ajax calls. Yes, you could achieve the same thing with cookie data, but if like me you like to keep the amount of data stored in cookies to the bare minimum, then this can be a nice little solution.</p>
<p>You can easily access these values like this:</p>
<pre class="brush:js">var user_id = $("meta[name='user_id']").attr('content')</pre>
<p>But eww, it&#8217;s pretty ugly, and ugly code makes Jamie a sad developer.</p>
<p>The following plugin simply provides a neat shorthand for accessing those variables. And I do like to keep things neat. It also caches by means of lazy-loading each meta contents into an internal object, so that the DOM is only traversed once. This is possibly overkill, and probably doesn&#8217;t save a single millisecond in any real-life scenario, but I like to optimise as I go and you can&#8217;t stop me.</p>
<pre class="brush:js">(function($) {
$.meta = function(name) {
    if (typeof($.meta.cache[name])=='undefined'){
        $.meta.cache[name] = $("meta[name='"+name+"']").attr('content');
    }
    return $.meta.cache[name];
};
$.meta.cache = new Object;
})(jQuery);</pre>
<p>You&#8217;re then free to access your variables neatly and concisely throughout your application using your new $.meta function.</p>
<pre class="brush: js">$.post('path/to/someAjaxController', {method: 'doStuff', id: $.meta('user_id')}, function(r){
    alert('Thanks for doing stuff ' + $.meta('user_name'));
})</pre>
<p>This isn&#8217;t to be confused with the existing and widely used <a href="http://docs.jquery.com/Plugins/Metadata">jQuery Metadata Plugin</a> which extracts meta data from DOM Elements. I should perhaps call this plugin something different, but to be honest I can&#8217;t think of a better name.</p>
<p>So to sum up. Ground-breaking? Not really. Useful? Yes.<code></code></p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2010/04/09/jquery-document-meta-plugin/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>An IE7 Bug That Returns MSIE 6.0 User Agent String</title>
		<link>http://jamiethompson.co.uk/web/2008/07/23/an-ie7-bug-that-returns-msie-60-user-agent-string/</link>
		<comments>http://jamiethompson.co.uk/web/2008/07/23/an-ie7-bug-that-returns-msie-60-user-agent-string/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 13:44:15 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[ie7]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/?p=99</guid>
		<description><![CDATA[
IE7, don&#8217;t you just love it? What they gave us with one had in terms of CSS actually sort of working they took away with some of the stupidest niggly little bugs ever. Here&#8217;s another potentially large one i&#8217;m stumbled right into recently.
If your user agent string is more than 260 characters in length then [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://s322999261.websitehome.co.uk/wp-content/uploads/2008/07/header.jpg" alt="Internet Explorer 7 User Agent Bug (MSIE 6.0)" title="Internet Explorer 7 User Agent Bug (MSIE 6.0)" width="530" height="190" /></p>
<p>IE7, don&#8217;t you just love it? What they gave us with one had in terms of CSS actually sort of working they took away with some of the stupidest niggly little bugs ever. Here&#8217;s another potentially large one i&#8217;m stumbled right into recently.</p>
<p><strong>If your user agent string is more than 260 characters in length then your user agent string suddenly and almost magically becomes &#8220;Mozilla/4.0 (compatible; MSIE 6.0)&#8221;</strong></p>
<p>Not what you&#8217;d expect to happen. Now, I know what your thinking. Why on god&#8217;s earth would your user agent string BE that long. The answer is simple. Toolbars and Spyware.</p>
<p><span id="more-99"></span></p>
<h2>Toolbars and Spyware</h2>
<p>The <em>cool</em> thing about Windows is that toolbars, spyware and crapware in general can and do add pointless shit to your Internet Explorer user agent string via the registry. Sounds good doesn&#8217;t it. Now consider the following:</p>
<ol>
<li>Most store bough Windows PCs come pre-installed with tons of stupid toolbars and crapware</li>
<li>IE 7 isn&#8217;t much more secure than IE6 was in terms of spyware</li>
<li>Home users do not know or care about viruses and spyware</li>
</ol>
<p>With me?</p>
<h2>Try it yourself</h2>
<p>You can easily trigger this bug yourself by editing the registry. Fire up regedit and navigate to HKLM/Software/Microsoft/Windows/CurrentVersion/Internet Settings/5./0User Agent/Post Platform. Create a new string key and fill up full of crap (enough to pass the 260 character threshold)</p>
<p><img src="http://s322999261.websitehome.co.uk/wp-content/uploads/2008/07/regedit.jpg" alt="regedit" title="regedit" width="530" height="190" /></p>
<p>Next, close all instances of IE. Fire UP IE again and type the following into the address bar:</p>
<pre class="brush: js">javascript:alert(navigator.userAgent)</pre>
<p>Hit enter and IE7 should now tell you that it&#8217;s IE6. Awesome!</p>
<p>I firmly believe that this is one of the reasons behind problems such as the <a href="/web/2008/03/17/thickbox-31-ie7-positioning-bug/">thickbox positioning bug </a>that many people experience with IE7.</p>
<h2>The workaround?</h2>
<p>This is of course just another argument against relying on the user agent string to determine browser version. It really shouldn&#8217;t be done this way, yet it&#8217;s the method built into many JavaScript libraries including jQuery with it&#8217;s <a href="/web/2008/03/14/jquerybrowserversion-doesnt-recognise-ie7/">unreliable $.browser.version</a> property.</p>
<p>If you really need to know if a browser is IE6 or IE7 then use something more solid like object detection. Simply testing for something like the following would be a better option than extracting unreliable data from the user agent string</p>
<p>A possible patch below redefines the browser version as &#8220;7.0&#8243; only if the browser has already been identified as IE6 and the the presence of the XMLHttpRequest object suggests otherwise.</p>
<pre class="brush: js">if(jQuery.browser.msie &#038;&#038; parseInt(jQuery.browser.version) == 6 &#038;&#038; this.XMLHttpRequest) {
	jQuery.browser.version = "7.0"
}</pre>
<p>I&#8217;m thinking though that maybe this might not be bulletproof. If IE8 presents the same or similar &#8220;Hi i&#8217;m IE6!&#8221; behaviour then the above patch could incorrectly identify IE8 as IE7. This might not be as serious as IE7 vs. IE6 but it&#8217;s still an issue.</p>
<p>I just wish that Microsoft would put a bit more effort into writing good software. It&#8217;s not like they don&#8217;t have the resources.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/07/23/an-ie7-bug-that-returns-msie-60-user-agent-string/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>jQuery ui.tabs, Themeroller and .ui-tabs-nav-item</title>
		<link>http://jamiethompson.co.uk/web/2008/07/22/jquery-uitabs-and-themeroller/</link>
		<comments>http://jamiethompson.co.uk/web/2008/07/22/jquery-uitabs-and-themeroller/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 11:52:36 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/?p=89</guid>
		<description><![CDATA[There currently an inconsistency between the jQuery UI tabs plugin and the CSS generated by Themeroller

The CSS includes rules for &#8220;.ui-tabs-nav-item&#8221; but these classes are never added to the list items by the plugin. Because they are unnecessary.
Simply changing the rules to &#8220;.ui-tabs-nav li&#8221; they way they should be brings it all into line again. [...]]]></description>
			<content:encoded><![CDATA[<p>There currently an inconsistency between the jQuery UI <a href="http://ui.jquery.com/functional_demos/#ui.tabs">tabs plugin</a> and the CSS generated by <a href="http://ui.jquery.com/themeroller">Themeroller</a></p>
<p><img src="http://s322999261.websitehome.co.uk/wp-content/uploads/2008/07/jquery-ui-themeroller.jpg" alt="" title="jquery-ui-themeroller" width="530" height="191" class="alignnone size-full wp-image-90" /></p>
<p>The CSS includes rules for &#8220;.ui-tabs-nav-item&#8221; but these classes are never added to the list items by the plugin. Because they are unnecessary.</p>
<p>Simply changing the rules to &#8220;.ui-tabs-nav li&#8221; they way they should be brings it all into line again. Except the extra specificity overrides the &#8220;.ui-tabs-selected&#8221; rules. These need changing to &#8220;.ui-tabs-nav li.ui-tabs-selected&#8221; and Bob&#8217;s your monkey&#8217;s uncle.</p>
<p>There doesn&#8217;t appear to be a whole lot of consistency (or good CSS) rolling around the JQuery UI project at the moment. Hopefully this will improve. I was of the belief that a theme could be &#8220;dropped onto&#8221; a jQuery UI app to simply re-skin it. This isn&#8217;t the case. Not yet at least.</p>
<p>For the time being I think i&#8217;ll be sticking to good old fashioned hand written CSS</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/07/22/jquery-uitabs-and-themeroller/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery.getScript() does not cache</title>
		<link>http://jamiethompson.co.uk/web/2008/07/21/jquerygetscript-does-not-cache/</link>
		<comments>http://jamiethompson.co.uk/web/2008/07/21/jquerygetscript-does-not-cache/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 12:29:44 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/?p=88</guid>
		<description><![CDATA[It occurred to me today that when using jQuery&#8217;s handy little .getScript method that each script request is appended by a timestamp appended to the querystring. This is great. A lot of the time this is exactly what you want as it ensures that no browser will ever serve up it&#8217;s own cache in preference [...]]]></description>
			<content:encoded><![CDATA[<p>It occurred to me today that when using jQuery&#8217;s handy little .getScript method that each script request is appended by a timestamp appended to the querystring. This is great. A lot of the time this is exactly what you want as it ensures that no browser will ever serve up it&#8217;s own cache in preference of the actual script from the actual server.</p>
<p><img src="http://s322999261.websitehome.co.uk/wp-content/uploads/2008/07/getscript.png" alt="jQuery.getScript" title="jQuery.getScript" width="530" height="190" /></p>
<p>But what if you just want to use .getScript to programatically include parts of your application logic only where necessary (aka <a href="http://en.wikipedia.org/wiki/Lazy_loading">Lazy Loading</a>), or you simply want to defer the execution of a non-essential plugin or two until a couple of seconds after the DOM becomes available. You&#8217;d want those scripts cached as if you&#8217;d hard-coded them into script tags right? I guess.</p>
<h2>Can&#8217;t Cache, Won&#8217;t Cache (with Ainsley Harriott)</h2>
<p>There&#8217;s no way you can send cache control options into getScript. It simply doesn&#8217;t accept any. getScript is merely a wrapper around .get which itself does not provide options for controlling caching. I&#8217;m not sure whether or not this is an oversight on the part of the developers. Feel free to shoot me down in flames if i&#8217;m spectacularly missing some glaringly obvious point here.</p>
<p>It&#8217;s not a problem though. .get is itslef just a simple wrapper around .ajax which publicly exposes all of jQuery&#8217;s AJAXy goodness. As such there&#8217;s absolutely no reason why you can&#8217;t just redefine JQuery.getScript to accept an optional boolean argument for cache control. That&#8217;s the beauty of jQuery.</p>
<h2>jQuery.getScript Redefined</h2>
<pre class="brush: js">$.getScript = function(url, callback, cache){
	$.ajax({
			type: "GET",
			url: url,
			success: callback,
			dataType: "script",
			cache: cache
	});
};
</pre>
<p>This won&#8217;t break any existing code which references the function as omitting the cache argument defaults caching to false as per the original functionality. But if you want to allow caching you now have that option.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/07/21/jquerygetscript-does-not-cache/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Publish / Subscribe With jQuery</title>
		<link>http://jamiethompson.co.uk/web/2008/06/17/publish-subscribe-with-jquery/</link>
		<comments>http://jamiethompson.co.uk/web/2008/06/17/publish-subscribe-with-jquery/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 16:24:27 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/?p=82</guid>
		<description><![CDATA[With a view to writing a jQuery UI integrated with the offline functionality of Google Gears i&#8217;ve been toying with some code to poll for network connection status using jQuery.
The Network Detection Object
The basic premise is very simple. We create an instance of a network detection object which will poll a URL at regular intervals. [...]]]></description>
			<content:encoded><![CDATA[<p>With a view to writing a <a href="http://jquery.com">jQuery</a> UI integrated with the offline functionality of <a href="http://gears.google.com">Google Gears</a> i&#8217;ve been toying with some code to poll for network connection status using jQuery.</p>
<h2>The Network Detection Object</h2>
<p>The basic premise is very simple. We create an instance of a network detection object which will poll a URL at regular intervals. Should these HTTP requests fail we can assume that network connectivity has been lost, or the server is simply unreachable at the current time.</p>
<pre class="brush: js">$.networkDetection = function(url,interval){
	var url = url;
	var interval = interval;
	online = false;
	this.StartPolling = function(){
		this.StopPolling();
		this.timer = setInterval(poll, interval);
	};
	this.StopPolling = function(){
		clearInterval(this.timer);
	};
	this.setPollInterval= function(i) {
		interval = i;
	};
	this.getOnlineStatus = function(){
		return online;
	};
	function poll() {
		$.ajax({
			type: "POST",
			url: url,
			dataType: "text",
			error: function(){
				online = false;
				$(document).trigger('status.networkDetection',[false]);
			},
			success: function(){
				online = true;
				$(document).trigger('status.networkDetection',[true]);
			}
		});
	};
};</pre>
<p>You can view the <a href="/sandbox/nwdetect/">demo here</a>. Set your browser to work offline and see what happens&#8230;. no, it&#8217;s not very exciting.</p>
<h2>Trigger and Bind</h2>
<p>What is exciting though (or at least what is exciting me) is the method by which the status gets relayed through the application. I&#8217;ve stumbled upon a largely un-discussed method of implementing a <a href="http://en.wikipedia.org/wiki/Pub/sub">pub/sub</a> system using jQuery&#8217;s trigger and bind methods.</p>
<p>The demo code is more obtuse than it need to be. The network detection object publishes &#8217;status &#8216;events to the document which actively listens for them and in turn publishes &#8216;notify&#8217; events to all subscribers (more on those later). The reasoning behind this is that in a real world application there would probably be some more logic controlling when and how the &#8216;notify&#8217; events are published.</p>
<pre class="brush: js">$(document).bind("status.networkDetection", function(e, status){
	// subscribers can be namespaced with multiple classes
	subscribers = $('.subscriber.networkDetection');
	// publish notify.networkDetection even to subscribers
	subscribers.trigger("notify.networkDetection", [status])
	/*
	other logic based on network connectivity could go here
	use google gears offline storage etc
	maybe trigger some other events
	*/
});</pre>
<p>Because of jQuery&#8217;s DOM centric approach events are published to (triggered on) DOM elements. This can be the window or document object for general events or you can generate a jQuery object using a selector. The approach i&#8217;ve taken with the demo is to create an almost namespaced approach to defining subscribers.</p>
<p>DOM elements which are to be subscribers are classed simply with &#8220;subscriber&#8221; and &#8220;networkDetection&#8221;. We can then publish events only to these elements (of which there is only one in the demo) by triggering a notify event on <strong>$(&#8220;.subscriber.networkDetection&#8221;)</strong></p>
<p>The <strong>#notifier</strong> div which is part of the .subscriber.networkDetection group of subscribers then has an anonymous function bound to it, effectively acting as a listener.</p>
<pre class="brush: js">$('#notifier').bind("notify.networkDetection",function(e, online){
	// the following simply demonstrates
	notifier = $(this);
	if(online){
		if (!notifier.hasClass("online")){
			$(this)
				.addClass("online")
				.removeClass("offline")
				.text("ONLINE");
		}
	}else{
		if (!notifier.hasClass("offline")){
			$(this)
				.addClass("offline")
				.removeClass("online")
				.text("OFFLINE");
		}
	};
});</pre>
<p>So, there you go. It&#8217;s all pretty verbose and my example isn&#8217;t at all exciting. It also doesn&#8217;t showcase anything interesting you could do with these methods, but if anyone&#8217;s at all interested to dig through the source feel free. All the code is inline in the head of the <a href="/sandbox/nwdetect/">demo page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/06/17/publish-subscribe-with-jquery/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Tips for Using JQuery with ASP.NET Ajax</title>
		<link>http://jamiethompson.co.uk/web/2008/06/09/tips-for-using-jquery-with-aspnet-ajax/</link>
		<comments>http://jamiethompson.co.uk/web/2008/06/09/tips-for-using-jquery-with-aspnet-ajax/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 08:21:20 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/?p=78</guid>
		<description><![CDATA[Dave Ward has put together an excellent and extensive post on his experiences integrating jQuery with ASP.NET
There are the usual number of pitfalls you&#8217;d expect when integrating [insert widely-used microsoft technology here] with [insert useful open source technology here]
Want to consume a JSON Web Service with jQuery? Sounds simple. That&#8217;s kinda the point of JSON [...]]]></description>
			<content:encoded><![CDATA[<p>Dave Ward has put together an <a href="http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax/">excellent and extensive post</a> on his experiences integrating jQuery with ASP.NET</p>
<p>There are the usual number of pitfalls you&#8217;d expect when integrating <em>[insert widely-used microsoft technology here]</em> with <em>[insert useful open source technology here]</em></p>
<p>Want to consume a JSON Web Service with jQuery? Sounds simple. That&#8217;s kinda the point of JSON right? Well yeah, but no. Everything&#8217;s workaroundable and to be fair it isn&#8217;t all Microsoft&#8217;s fault&#8230; ok so most of it is.</p>
<p>I&#8217;m gonna be starting a large scale ASP.NET / jQuery / ExtJS project in the very near future and Dave&#8217;s short guide has probably just saved me several hours if not a whole day of figuring out all the lumps and bumps myself.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/06/09/tips-for-using-jquery-with-aspnet-ajax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Google Analytics Tracking API Integration (ga.js)</title>
		<link>http://jamiethompson.co.uk/web/2008/03/26/jquery-google-analytics-tracking-api-integration-gajs/</link>
		<comments>http://jamiethompson.co.uk/web/2008/03/26/jquery-google-analytics-tracking-api-integration-gajs/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 15:34:54 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/web/2008/03/26/jquery-google-analytics-tracking-api-integration-gajs/</guid>
		<description><![CDATA[Jason Huck&#8217;s gaTracker jQuery plugin allows for unobtrusive integration of the Google Analytics tracker into a page as well as attaching tracking events to each external link, mailto and download. It works seamlessly but it does however currently use the old &#8216;urchin.js&#8217; which has been superceeded by Google&#8217;s new Tracking API (ga.js)
ga.js has all the [...]]]></description>
			<content:encoded><![CDATA[<p>Jason Huck&#8217;s <a href="http://plugins.jquery.com/project/gaTracker">gaTracker</a> jQuery plugin allows for unobtrusive integration of the Google Analytics tracker into a page as well as attaching tracking events to each external link, mailto and download. It works seamlessly but it does however currently use the old &#8216;urchin.js&#8217; which has been superceeded by Google&#8217;s new <a href="http://code.google.com/apis/analytics/docs/">Tracking API</a> (ga.js)</p>
<p>ga.js has all the capabilities of urchin.js but is structured in a fully Object oriented way. The new API has some nice new functionality which among other things allows for tracking of e-commerce transactions, which is pretty exciting. If you like that sorta thing.</p>
<p>I&#8217;ve quickly modified gaTracker to utilise the new API and call it&#8217;s _trackPageview() method rather than using urchinTracker(). The code is available below:</p>
<p><a href="/files/js/jquery.gatracker.js">jquery.gatracker.js</a> (Tracking API version)</p>
<p>It works in exactly the same way as the gaTracker 1.0.1 release, and can be dropped in it&#8217;s place, but utilises the new tracking API. Feel free to grab a copy until support gets built into the official release.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/03/26/jquery-google-analytics-tracking-api-integration-gajs/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jQuery Image Text Replacement: Work In Progress</title>
		<link>http://jamiethompson.co.uk/projects/2008/03/17/jquery-image-text-replacement-work-in-progress/</link>
		<comments>http://jamiethompson.co.uk/projects/2008/03/17/jquery-image-text-replacement-work-in-progress/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 23:19:37 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/projects/2008/03/17/jquery-image-text-replacement-work-in-progress/</guid>
		<description><![CDATA[The JavaScript text replacement on this site is a jQuery Plugin i&#8217;ve written as an adaptation of the techniques detailed in Dynamic Text Replacement by Stewart Rosenberger in A List Apart Issue 183. The current source of the plugin can be found here. I&#8217;m calling it jitr, and you can&#8217;t stop me.
Currently it&#8217;s a work [...]]]></description>
			<content:encoded><![CDATA[<p>The JavaScript text replacement on this site is a jQuery Plugin i&#8217;ve written as an adaptation of the techniques detailed in <a href="http://www.alistapart.com/articles/dynatext">Dynamic Text Replacement</a> by <a href="http://www.alistapart.com/authors/r/stewartrosenberger">Stewart Rosenberger</a> in A List Apart Issue 183. The current source of the plugin can be found <a href="/files/js/jquery.jitr.js">here</a>. I&#8217;m calling it jitr, and you can&#8217;t stop me.</p>
<p>Currently it&#8217;s a work in progress and utilizes an extended version of Stewart&#8217;s <a href="http://www.alistapart.com/d/dynatext/heading.php.txt">Dynamic Heading Generator</a> PHP script. The plugin will attempt to replace the text of an element such as a heading with text generated in a specified font in the same colour and size as specified in the CSS. It will generate one image per word allowing word-wrap to occur.</p>
<p>There is currently a known issue with IE (all versions) when using jitr with em based font sizes. Internet Explorer reports a size which <strong>does not</strong> represent the equivalent font size in pixels.<br />
<span id="more-49"></span></p>
<h2>Syntax:</h2>
<p><code>jitr(String fontfilename, String backgroundColor)</code></p>
<p>jitr returns the jQuery object so that it can be chained.</p>
<p>There is currently however one major part of the process which lies outside of the plugin. To avoid a flicker of unstyled content on document.ready, it is necessary to include a stylesheet (hide.css) which sets the elements which are to be replaced to have &#8216;visibility: hidden&#8217;. As each element is image replaced, it&#8217;s CSS visibility is reset to visible.</p>
<h2>Example hide.css</h2>
<pre class="brush: css">h1, h2, h3 {
	visibility:hidden;
}</pre>
<p>Simply including this stylesheet in the head would have adverse side-effects for visitors without JavaScript though. The CSS above would hide all the headings and the plugin, not being run, would not then reset them to visible. I have decided for the time being that the only solution i can see which will work, although slightly clunky is to use a document.write to include hide.css only when JavaScript is enabled.</p>
<pre class="brush: js">&lt;script type="text/javascript"&gt;
    document.write('&lt;link rel="stylesheet" href="/path/to/hide.css" ' +
    'type="text/css" media="screen" /&gt;');
&lt;/script&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/projects/2008/03/17/jquery-image-text-replacement-work-in-progress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Thickbox 3.1 IE7 Positioning Bug</title>
		<link>http://jamiethompson.co.uk/web/2008/03/17/thickbox-31-ie7-positioning-bug/</link>
		<comments>http://jamiethompson.co.uk/web/2008/03/17/thickbox-31-ie7-positioning-bug/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 13:20:26 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Thickbox]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/web/2008/03/17/thickbox-31-ie7-positioning-bug/</guid>
		<description><![CDATA[
As previously mentioned in this post Thickbox 3.1 is currently broken in many revisions of Internet Explorer 7. Specifically, those revisions who return the substring &#8220;MSIE 6.0&#8243; in the user-agent string.
Update: July 2008
This patch fixes a problem caused when certain installations of IE7 are incorrectly identified as IE6 causing the thickbox window to be positioned [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://s322999261.websitehome.co.uk/wp-content/uploads/2008/07/thickbox.jpg" alt="thickbox" title="thickbox" width="530" height="191" /></p>
<p>As previously mentioned in <a href="http://jamazon.co.uk/web/2008/03/14/jquerybrowserversion-doesnt-recognise-ie7/">this post</a> <a href="http://jquery.com/demo/thickbox/">Thickbox</a> 3.1 is currently broken in many revisions of Internet Explorer 7. Specifically, those revisions who return the substring &#8220;MSIE 6.0&#8243; in the user-agent string.</p>
<h2>Update: July 2008</h2>
<p>This patch fixes a problem caused when certain installations of IE7 are incorrectly identified as IE6 causing the thickbox window to be positioned <strong>partially hidden</strong> in the <strong>top left hand corner</strong> of the viewport . It has become apparent that there are other bugs triggered in other revisions of IE7 which cause another type of miss-positioning with the thickbox window being <strong>centered </strong>correctly but <strong>outside of the viewport</strong>. <strong>This patch doesn&#8217;t fix that</strong></p>
<p>As this is such a widespread problem, and lots of people seem to be having a little difficulty patching their copies of thickbox.js I thought i&#8217;d provide a patched copy here. But first a bit of background for those who are interested in why it&#8217;s broken. The following if statement in the function tb_position is as follows:</p>
<h2>thickbox.js line 284</h2>
<pre class="brush: js">if ( !(jQuery.browser.msie &#038;&#038; jQuery.browser.version < 7)) { // take away IE6
    $("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
}</pre>
<p>The bug is triggered when, in certain revisions of IE7 jQuery.browser.version == 6, resulting in the Thickbox window not receiving the correct CSS positioning. (In IE6, the window receives it position through some clever CSS expressions in thickbox.css)<br />
<span id="more-47"></span><br />
The workaround for all this though is fairly straightforward. You simply need a more accurate way for weeding out IE6... and here it is.</p>
<h2>$.browser.msie6</h2>
<pre class="brush: js">$.browser.msie6 =
    $.browser.msie
    &#038;&#038; /MSIE 6\.0/i.test(window.navigator.userAgent)
    &#038;&#038; !/MSIE 7\.0/i.test(window.navigator.userAgent);</pre>
<p>Once we have this new property defined within the $.browser object we can use it to fix the conditional statement mentioned previously. You can define $.browser.msie6 in thickbox.js (like i have in the patched copies of thickbox below), or patch jQuery itself. Or whatever. It's up to you. After that all that needs to be done is to modify the following line to make use of our new IE6 sniffer:</p>
<h2>thickbox.js line 284</h2>
<pre class="brush: js">if ( !(jQuery.browser.msie6)) { // take away IE6
    $("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
}</pre>
<p>If you don't feel confident patching your own copy of thickbox then feel free to grab a patched copy below. This is thickbox 3.1 with the abovementioned code modifications applied and should simply replace your existing file.</p>
<ul>
<li><a href="/files/js/thickbox.patch.js">thickbox.patch.js</a></li>
<li><a href="/files/js/thickbox.patch.pack.js">thickbox.patch.pack.js</a></li>
</ul>
<p>Let me know if you find this useful</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/03/17/thickbox-31-ie7-positioning-bug/feed/</wfw:commentRss>
		<slash:comments>126</slash:comments>
		</item>
		<item>
		<title>jQuery hide/show Safari Bug</title>
		<link>http://jamiethompson.co.uk/web/2008/03/17/jquery-hideshow-safari-bug/</link>
		<comments>http://jamiethompson.co.uk/web/2008/03/17/jquery-hideshow-safari-bug/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 10:32:50 +0000</pubDate>
		<dc:creator>Jamie Thompson</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jamazon.co.uk/web/2008/03/17/jquery-hideshow-safari-bug/</guid>
		<description><![CDATA[I&#8217;ve noticed problems in Safari with the hide/show methods of jQuery on and off for quite a while now. Basically they don&#8217;t work. Correct me if i&#8217;m wrong. This behaviour also extends to the fadeIn/Out methods.
The problem can be circumvented to applying css rules directly to the element(s) in question.
// This will fail in Safari
$(element).hide()
// [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve noticed problems in Safari with the hide/show methods of jQuery on and off for quite a while now. Basically they don&#8217;t work. Correct me if i&#8217;m wrong. This behaviour also extends to the fadeIn/Out methods.</p>
<p>The problem can be circumvented to applying css rules directly to the element(s) in question.</p>
<pre class="brush: js">// This will fail in Safari
$(element).hide()
// But this will work
$(element).css('display','none')
</pre>
<p>A quick google reveals that lot&#8217;s of people have come across this same issue, but no definitive answers.</p>
<blockquote>
]]></content:encoded>
			<wfw:commentRss>http://jamiethompson.co.uk/web/2008/03/17/jquery-hideshow-safari-bug/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

