<?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"
	>

<channel>
	<title>unitstep.net &#187; jQuery</title>
	<atom:link href="http://unitstep.net/blog/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://unitstep.net</link>
	<description>the home of peter chng</description>
	<pubDate>Tue, 18 Nov 2008 02:09:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Upgrade jQuery for better Opera support (Or just upgrade Opera)</title>
		<link>http://unitstep.net/blog/2008/06/25/upgrade-jquery-for-better-opera-support-or-just-upgrade-opera/</link>
		<comments>http://unitstep.net/blog/2008/06/25/upgrade-jquery-for-better-opera-support-or-just-upgrade-opera/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 00:45:43 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[browsers]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[opera]]></category>

		<guid isPermaLink="false">http://unitstep.net/?p=336</guid>
		<description><![CDATA[I ran into a weird problem while testing one of my sites that used jQuery with Opera 9.26.  (I happened to be using this older version of Opera because I am lazy to upgrade; I&#8217;m still using Firefox 2 despite the successful launch of FF3)
The issue was with an Ajax request I was sending. [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a weird problem while testing one of my sites that used jQuery with Opera 9.26.  (I happened to be using this older version of Opera because I am lazy to upgrade; I&#8217;m still using Firefox 2 despite the successful launch of FF3)</p>
<p>The issue was with an Ajax request I was sending.  The return value was an array in JSON form.  More specifically, the server was returning something like:</p>
<pre><code>{tag:[{id1:'A',id2:'B'}, {id1:'A',id2:'B'}, {id1:'A',id2:'B'}]}</code></pre>
<p>This was perfectly valid and worked fine in both Firefox and Internet Explorer.  However, in Opera 9.26, I got a JavaScript error indicating that the JSON was not valid.  It was then that I realized I was using an older version of jQuery, v1.2.2.  <a href="http://docs.jquery.com/Downloading_jQuery">Upgrading to the latest</a>, 1.2.6 fixed the problem.  Strangely, I could not find anything on their bug tracker indicating that such a problem (JSON and Opera) had been fixed.</p>
<p>What was even more interesting was that <a href="http://www.opera.com/download/">upgrading to Opera 9.50</a> also solved the problem independently; that is, things worked fine even with the older version of jQuery.  This goes to show the importance of keeping your software up to date and highlights the complicated interactions between different browsers and client-side code in a web application.</p>
<hr/>Copyright &copy; 2008 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2008/06/25/upgrade-jquery-for-better-opera-support-or-just-upgrade-opera/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Share This in jQuery</title>
		<link>http://unitstep.net/blog/2007/08/01/share-this-in-jquery/</link>
		<comments>http://unitstep.net/blog/2007/08/01/share-this-in-jquery/#comments</comments>
		<pubDate>Thu, 02 Aug 2007 04:35:29 +0000</pubDate>
		<dc:creator>Peter Chng</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[plugins]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://unitstep.net/blog/2007/08/01/share-this-in-jquery/</guid>
		<description><![CDATA[
Share This is an excellent WordPress plugin written by Alex King.  The plugin provides a neat and customizable pop-up menu for allowing readers to easily share one of your blog posts using many of the social bookmarking or social websites out there.  It&#8217;s an intelligent solution to the problem of having too many [...]]]></description>
			<content:encoded><![CDATA[<p class="image align-right"><a href="http://alexking.org" title="Share This icon Copyright Alex King"><img src='http://unitstep.net/wordpress/wp-content/uploads/2007/08/share-icon-128x128.png' alt='Share This icon Copyright Alex King (http://alexking.org)' /></a></p>
<p><a href="http://alexking.org/projects/wordpress">Share This</a> is an excellent WordPress plugin written by <a href="http://alexking.org/">Alex King</a>.  The plugin provides a neat and customizable pop-up menu for allowing readers to easily share one of your blog posts using many of the social bookmarking or social websites out there.  It&#8217;s an intelligent solution to the problem of having <a href="http://www.pronetadvertising.com/articles/why-too-many-little-icons-can-easily-distract-your-visitors.html">too many sharing icons</a> that may potentially distract or irritate readers.</p>
<p>Since launching, Share This has become <a href="http://alexking.org/blog/2006/12/27/share-this-catching-on">very popular</a>, with many blogs using it.  I recently began using the plugin for a site of mine, and was impressed by its usefulness. (And the <a href="http://alexking.org/blog/2006/12/11/shareiconscom">icon project it launched</a>)  However, I had also decided to use the <a href="http://jquery.com">jQuery</a> JavaScript framework (and its <a href="http://docs.jquery.com/Plugins">plugins</a>) for this site, and since Share This uses <a href="http://www.prototypejs.org/">Prototype</a> for its JavaScript functionality, there were some conflicts.  </p>
<p>So, I decided to do a minor re-write of Share This, altering only the JavaScript portion to use jQuery instead of Prototype.</p>
<h3>jQuery?</h3>
<p>I wanted to stick with jQuery for a variety of reasons, but mainly because I have more experience with it than with Prototype.  I won&#8217;t get into an argument over which of the frameworks is better, and will instead stick to the &#8220;Unto each his own&#8221; line of thinking.</p>
<p>While jQuery generally works well with existing JavaScript, as it doesn&#8217;t alter the global namespace, and additionally has a &#8220;no-conflict&#8221; mode, some of the plugins that I wanted to use (specifically <a href="http://jquery.com/demo/thickbox/">Thickbox</a>) weren&#8217;t written for the no-conflict mode.  The issue stems from the use of the &#8220;<code>$</code>&#8221; variable name.  In jQuery, it&#8217;s a shortcut for the be-all-end-all function <code>jQuery()</code>, while in Prototype, it&#8217;s a shortcut for <code>document.getElementById()</code>.</p>
<h3>Share This in jQuery</h3>
<p>Before I offer the download, I want to make it clear that this was a <strong>very minor</strong> change - no functionality was added or removed, as just the JavaScript portion was re-written (quickly) to support jQuery instead of Prototype.  Again, it&#8217;s not better than the original <a href="http://alexking.org/projects/wordpress">Share This</a>, only different.  Furthermore, 100% full credit still belongs to <a href="http://alexking.org/">Alex King</a>, as this is barely a derivative work.</p>
<p>In order to use this version, you will need the <a href="http://docs.jquery.com/Downloading_jQuery">jQuery framework</a> as well as the <a href="http://jquery.com/plugins/project/dimensions">Dimensions plugin</a>.  Their cumulative compressed sizes are comparable to the compressed size of the Prototype framework.  You will need to link them to your site in your WordPress theme&#8217;s <code>header.php</code> file by adding lines like these, preferably between the <code>head</code> tags.</p>
<pre><code>&lt;script type="text/javascript" src="/path-to-jquery/jquery.pack.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/path-to-jquery-dimensions/jquery.dimensions.pack.js"&gt;&lt;/script&gt;</code></pre>
<p>You can then replace the original <code>share-this.php</code> with the jQuery version in the <a href='/wordpress/wp-content/uploads/2007/08/share-this-14-jquery.zip' title='Share This in jQuery'>zipped download</a>.  (You may want to backup the original file first, as always)</p>
<h3>Download</h3>
<ul>
<li><a href='/wordpress/wp-content/uploads/2007/08/share-this-14-jquery.zip' title='Share This in jQuery'><img src="/images/icons/silk/folder_go.png" alt="Download" />Share This 1.4 for jQuery</a></li>
</ul>
<h3>Credit and Misc.</h3>
<p>As mentioned before, all credit still belongs to Alex King for writing Share This in the first place.  I haven&#8217;t really changed anything, just adapted it to work with jQuery and thought I&#8217;d like to make it available for everyone to use.  It still works exactly as before, so configuring options and so forth isn&#8217;t any different.</p>
<p>What I changed was just the part of the plugin that outputs the JavaScript necessary to make Share This work.  It&#8217;s just been changed to use jQuery instead of Prototype.  I also commented out the parts of the plugin that link the Prototype framework (from WordPress) into the header.  As mentioned before, you&#8217;ll have to link in the requisite jQuery script files yourself.  Since it looks like <a href="http://trac.wordpress.org/ticket/3824">WordPress will be moving over to jQuery</a>, at least for the admin pages, this might be something worthwhile.</p>
<p>The JavaScript has been written in jQuery&#8217;s compatibility mode (using <code>jQuery()</code> instead of <code>$</code>), so you can continue to use Prototype on your site if you wish.  As mentioned, this was a very quick rewrite, so not much has changed. </p>
<p>Some people have pointed out that Prototype is a lot larger than jQuery in terms of file size.  This may be somewhat true, but when Prototype v 1.5.0 is <a href="http://dean.edwards.name/packer/">packed</a>, it comes in at only around 27 KB.  jQuery packed is about 21 KB, but with the Dimensions plugin needed to make Share This work with jQuery adds another 4-5 KB, bringing the total size close to that of Prototype.  So why use jQuery? Again, it&#8217;s just because I&#8217;m more familiar with it and like how jQuery expressions are formed, particularly with the ability to <a href="http://docs.jquery.com/How_jQuery_Works#Chainability_.28The_Magic_of_jQuery.29">chain function calls</a>.</p>
<h3>Update</h3>
<p><a href="http://www.thunderguy.com/semicolon/">Bennett McElwee</a>, author of many nice WordPress plugins (including some that I use on my own site), has <a href="http://www.thunderguy.com/semicolon/2007/07/30/share-this-jquery-a-wordpress-plugin/">already released a version of Share This in jQuery</a>, seemingly two days before I published this post - what a coincidence!  His appears to be more polished, though, as it doesn&#8217;t use the extra Dimensions plugin and also includes some nice effects.  Definitely give it a try.</p>
<hr/>Copyright &copy; 2008 <strong><a href="http://unitstep.net">unitstep.net</a></strong>. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. Please contact <strong><a href="mailto:webmaster@unitstep.net">webmaster@unitstep.net</a></strong> for more information.<br/><span style="float: right;font-size: 7pt"><a href="http://blog.taragana.com/index.php/archive/wordpress-plugins-provided-by-taraganacom/">Plugin</a> by <a href="http://www.taragana.com/">Taragana</a></span>]]></content:encoded>
			<wfw:commentRss>http://unitstep.net/blog/2007/08/01/share-this-in-jquery/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
