<?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:atom="http://www.w3.org/2005/Atom"
				  >
<channel>
<title></title>
<link>http://mattsnider.com/</link>
<description><![CDATA[Understanding Web Development]]></description>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://mattsnider.com/feed" type="application/rss+xml" />
<item>
<title>Web Development News March 2010 A</title>
<link>http://mattsnider.com/news/web-development-news-032010-a/</link>
<guid isPermaLink="true" >http://mattsnider.com/news/web-development-news-032010-a/</guid>
<pubDate>Tue, 16 Mar 2010 21:36:30 -0700</pubDate>
<description><![CDATA[<p>Here is a collection of interesting news from the first half of March.</p>

<p><h3>YUI 3 Gallery Competition</h3></p>
<p>In case you missed the announcement, YUI 3 is hosting a gallery widget competition. You still have a few days to get your submission ready. <a href="http://yuiblog.com/yui3gallerycontest2010/">Check out the details</a>.</p>

<p><h3>YUI 3 Alloy</h3></p>
<p><a href="http://www.liferay.com/web/nathan.cavanaugh/blog/">Nate Cavanaugh</a> and <a href="http://www.liferay.com/web/eduardo.lundgren/blog/">Eduardo Lundgren</a>, of <a href="http://www.liferay.com/">Liferay</a>, have spent the last six months building a YUI3-based widget library. Not only did these guys write great widgets, but this library also helps fills in the gaps while we wait for YUI 3 to port all their YUI 2 widgets.</p>
<p><a href="http://www.yuiblog.com/blog/2010/03/15/previewing-alloyui/">http://www.yuiblog.com/blog/2010/03/15/previewing-alloyui/</a></p>

<p><h3>The Web Standards Cold War</h3></p>
<p>The <a href="http://www.alistapart.com/articles/flashstandards/">Flash and Standards: The Cold War of the Web</a> is a good article by <a href="http://www.alistapart.com/authors/m/dmall">Dan Mall</a>, proposing that developers get behind the standardization and improvement of one or more web-technology, instead of spending their time bashing the technologies they don't like. Worth a quick read.</p>

<p><h3>IE 8 Document Mode Demystified</h3></p>
<p>IE developers have finally written an article explaining how the browser chooses the document mode. If you use document mode in IE, this is a must read.</p>

<p><a href="http://blogs.msdn.com/ie/archive/2010/03/02/how-ie8-determines-document-mode.aspx">How IE 8 Determines Document Mode</a></p>

<p><h3>JQuery Workshop Videos</h3></p>
<p><a href="http://www.google.com/reader/view/feed/http%3A%2F%2Ffeeds.feedburner.com%2FJohnResig">John Resig</a> has a series of talks on jQuery ranging from an introduction to the framework, to things you might not know, and ways to improve your application. If you use jQuery, then these are for you.</p>

<p><a href="http://ejohn.org/blog/spring-2010-jquery-talks/">Spring 2010 jQuery Talks</a></p>

<p><h3>MattSnider-Related News</h3></p>
<p>I have been working diligently on integrating the RadialMenu with the YUI 3 overlay framework. I am pretty far along, and hope to have something to share by the end of this week. I will be submitting it to the YUI competition as well, so it will be available on the gallery.</p>

<p>Starting next month, I will begin working on the YUI Storage system again. There has been lots of feedback to incorporate and we need to port it to YUI 3. Look forward to an announcement in the next few months.</p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=508</wfw:commentRss>
</item>
<item>
<title>YUI 3 Number Gallery Component</title>
<link>http://mattsnider.com/javascript/yui-3-number-gallery-component/</link>
<guid isPermaLink="true" >http://mattsnider.com/javascript/yui-3-number-gallery-component/</guid>
<pubDate>Fri, 05 Mar 2010 10:41:00 -0800</pubDate>
<description><![CDATA[<p>A while back I threw together a quick API port of the <a href="http://yui-ext-mvc.googlecode.com/svn/trunk/assets/js/native-ext/number.js">number.js</a> from the YUI-Ext-MVC framework into the YUI 3 gallery. However, I did not give the API enough attention in my first pass, nor have I revisited it since. Today, I finally revisited the API to clean it up and add some sorely needed functions.</p>

<p><h3>Getting started</h3></p>
<p>You will need to include the module in your code:</p>
<p><pre class="brush:js">YUI({
	filter: 'raw',
	combine: true,
	timeout: 10000,
	modules: {
		'gallery-number': {
			fullpath: 'http://github.com/mattsnider/yui3-gallery/blob/master/src/gallery-number/js/number.js',
			requires: [],
			optional: [],
			supersedes: []
		}
	}
}).use('gallery-number', function(Y) {
	/* ... */
});</pre></p>

<p><h3>How to do it...</h3></p>

<p>Convert radians to degrees and vice-versa:</p>
<p><pre class="brush:js">var degreeValue = Y.Number.degrees(radianValue);
var radianValue = Y.Number.radians(degreeValue);</pre></p>

<p>Evaluate if a number is between or not two other numbers:</p>
<p><pre class="brush:js">var bool = Y.Number.isBetween(number, lowerBound, upperBound);
var bool = Y.Number.isNotBetween(number, lowerBound, upperBound);</pre></p>

<p>Evaluate if a number is even or odd:</p>
<p><pre class="brush:js">var bool = Y.Number.isEven(number);
var bool = Y.Number.isOdd(number);</pre></p>

<p>Evaluate is a number is prime:</p>
<p><pre class="brush:js">var bool = Y.Number.isPrime(number);</pre></p>

<p>Find the precision of a number (number of decimal places):</p>
<p><pre class="brush:js">var precision = Y.Number.getPrecision(number);</pre></p>

<p>Generate a random integer:</p>
<p><pre class="brush:js">var number = Y.Number.random(number);</pre></p>

<p>Round to the nearest digit:</p>
<p><pre class="brush:js">var number = Y.Number.roundToDigit(number, 100);</pre></p>

<p>Format a number into a US number string:</p>
<p><pre class="brush:js">var string = Y.Number.format(number, "0,000.00");</pre></p>

<p><h3>How it works...</h3></p>
<p>The <code>radians</code>/<code>degrees</code> conversion functions uses the math equation, where "degree = radian * 180 / PI" to convert the values.</p>

<p>The <code>isBetween</code>/<code>isNotBetween</code> evaluation functions use the less than and greater than operators to evaluate where the first argument lies.</p>

<p>The <code>isEven</code>/<code>isOdd</code> evaluation functions use the modulus operator to see if the result equals ZERO or not.</p>

<p>The <code>isPrime</code> uses a series of rules to determine if the number is prime or not. First, it checks if the number is 2 or 5, as these are special primes. Then it checks if the number is not event. If the number is less than 200 it evaluates if the number is any of the primes less than 200 (these values are hardcoded). If the number is greater than 200, it checks if it is divisible by any of the prime less than 200.</p>

<p>The <code>getPrecision</code> function converts the number to an a string and splits around the decimal point. The length of the second parameter in the resulting array is the precision.</p>

<p>The <code>random</code> function uses a well-known equation to convert the decimal produced by <code>Math.random</code> into an integer value between ZERO and the number provided as the first argument.</p>

<p>The <code>roundToDigit</code> attempts to convert the provided value to the nearest digit, as determined by the second argument. This means if you have the number 799 and desire hundreds place rounding (pass in 100 as the second parameter) and the number will be rounded to 800, but if you round to the thousands place, the number will be rounded to 1000. This function works by converting the number to a string, moving the decimal place to desired precision, executing <code>Math.round()</code> and then converting the number back to the correct precision.</p>

<p>The <code>format</code> function uses a regular expression to find the textual number inside of the format string. It then applies logic to convert the number into the desired format; generally this means do you want commas and/or decimal places shown. And finally it inserts the formatted number back into the string. Therefore, you can pass in a complete sentence or a string of symbols, and this method surgically replace the number format string with the formatted number.</p>

<p><h3>There's more...</h3></p>
<p>The <code>isBetween</code>/<code>isNotBetween</code> evaluation functions can accept an optional boolean value as there fourth parameter. When true, they will perform inclusive comparisons, evaluating with the greater/less than or equal to operators, instead of greater/less than operators.</p>

<p>The <code>random</code> function accepts an optional second argument, which is the starting point of the random range. This way you can find random numbers between two numbers, instead of just between ZERO and the desired number.</p>

<p>Previously, this component wrapped some of the native Math functions, but this only added bloat, making the component larger than it needed to be, so I removed them.</p>

<p><h3>See also</h3></p>
<p><ul><li>The <a href="http://yuilibrary.com/gallery/show/number">Number  Component page</a> on <a href="http://www.yuilibrary.com">YUILibrary.com</a></li></ul></p>

<p><h3>More to come</h3></p>
<p>The functions included here are all derived from the math functions that I have needed for work on <a href="http://www.mint.com">Mint.com</a>, a financial site. However, there are probably other functions that are commonly used by developers, which I would like to include in this API. If you have a math function that you commonly use, please include it in the comments section.</p>

<p>Additionally, I think the format function should work more like a <code>print</code> function in C-style languages, so I will be improving this function eventually.</p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=507</wfw:commentRss>
</item>
<item>
<title>Web Development News February 2010 B</title>
<link>http://mattsnider.com/news/web-development-news-022010-b/</link>
<guid isPermaLink="true" >http://mattsnider.com/news/web-development-news-022010-b/</guid>
<pubDate>Tue, 02 Mar 2010 10:01:45 -0800</pubDate>
<description><![CDATA[<p>Let's take a moment and look back on the life and death of IE6. For those of you who missed the Mountain View funeral, there will be another one held in Colorado on the 4th. For details see <a href="http://ie6funeral.com/">http://ie6funeral.com/</a>. May it rest in peace forever, and never, ever be used again.</p>

<p>Now to move onto other recent news.</p>

<p><h3>Best Practices Article by Smashing Magazine</h3></p>
<p>Hopefully, you know most of this already, but it is a good read.</p>
<p><a href="http://www.smashingmagazine.com/2010/02/22/the-seven-deadly-sins-of-javascript-implementation/">http://www.smashingmagazine.com/2010/02/22/the-seven-deadly-sins-of-javascript-implementation/</a></p>

<p><h3>Storage-Lite in YUI3</h3></p>
<p><a href="http://wonko.com/">Ryan Grove</a> has written a <a href="http://yuilibrary.com/gallery/show/storage-lite">Storage Lite</a> package for YUI 3. It isn't a port of <a href="http://developer.yahoo.com/yui/storage/">YUI 2 Storage Utility</a>, but instead focuses only on the various native methods that existed pre HTML 5. It is a great package and some of these techniques will probably work their way into YUI Storage Utility. Read more about it at <a href="http://feeds.yuiblog.com/~r/YahooUserInterfaceBlog/~3/19tp3D3ag7Y/">http://feeds.yuiblog.com/~r/YahooUserInterfaceBlog/~3/19tp3D3ag7Y/</a></p>

<p><h3>Need a Job? Work for YUI</h3></p>
<p>The YUI team is hiring. Find out more at <a href="http://feeds.yuiblog.com/~r/YahooUserInterfaceBlog/~3/myJCx4R3CMw/">http://feeds.yuiblog.com/~r/YahooUserInterfaceBlog/~3/myJCx4R3CMw/</a>.</p>

<p><h3>JQuery 1.4.2 Release</h3></p>
<p>The jQuery team has outdone themselves this time, claiming that they have made jQuery almost twice as fast as before. And it is noticeably faster. Additionally, they have added two functions <code>.delegate()</code> and <code>.undelegate()</code> to compliment the <code>.live()</code> and <code>.die()</code> functions. Read more about it at <a href="http://blog.jquery.com/2010/02/19/jquery-142-released/">http://blog.jquery.com/2010/02/19/jquery-142-released/</a>.</p>

<p><h3>Handle Accent Characters in Your AutoComplete</h3></p>
<p>Want to support more characters in your autocomplete system, check out this post, <a href="http://www.alistapart.com/articles/accent-folding-for-auto-complete/">http://www.alistapart.com/articles/accent-folding-for-auto-complete/</a>, which discusses how.</p>

<p><h3>A JavaScript Solution to the Password Problem</h3></p>
<p>The password problem, is that many people feel that <code>input</code> elements of type <code>password</code> are inaccessible (for a variety of reasons). This article, <a href="http://www.alistapart.com/articles/the-problem-with-passwords/">http://www.alistapart.com/articles/the-problem-with-passwords/</a>, describes a couple of JavaScript based solutions to the problem, including one that mimics the iPhone behavior of showing the last character.</p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=506</wfw:commentRss>
</item>
<item>
<title>IE 8 Compatibility Issue with YUI 2 Selector Component</title>
<link>http://mattsnider.com/javascript/ie-8-compatibility-issue-with-yahoo-2-selector-component/</link>
<guid isPermaLink="true" >http://mattsnider.com/javascript/ie-8-compatibility-issue-with-yahoo-2-selector-component/</guid>
<pubDate>Wed, 24 Feb 2010 11:11:42 -0800</pubDate>
<description><![CDATA[<p>I realized recently, in my work on <a href="http://www.mint.com">Mint.com</a>, that the <code>YAHOO.util.Selector.query</code> function does not work properly in IE 8 compatibility mode when performing a search against the <code>class</code> and <code>for</code> attributes. The issue is that previous versions of IE defined these attributes names as <q>className</q> and <q>htmlFor</q>, while IE 8 changed them to follow the standard. And a faulty <code>if</code> statement in the selector component does not properly use the legacy names when developers apply the X-UA-Compatible META tag to set compatibility modes.</p>

<p><h3>The Problem...</h3></p>
<p>The selector utility is using the following code:</p>

<p><pre class="brush:js">if (YAHOO.env.ua.ie && YAHOO.env.ua.ie < 8) { // rewrite class for IE < 8</pre></p>

<p>However, according to the IE blog, this won't work:</p>

<p><a href="http://blogs.msdn.com/ie/archive/2009/02/16/just-the-facts-recap-of-compatibility-view.aspx">http://blogs.msdn.com/ie/archive/2009/02/16/just-the-facts-recap-of-compatibility-view.aspx</a></p>

<p>When using the server-driven X-UA-Compatible META tag, due to technical reasons, the user-agent string is not changed. This means that the <code>if</code> statement will evaluate to false, thinking that the browser is IE 8, even though the server has indicated the use of another version of IE. However, IE 8 has introduced a new property <code>document.documentMode</code>, which can be used to handle this situation. The <code>document.documentMode</code> will be the version of IE specified via the X-UA-Compatible META tag.</p>

<p><h3>The Solution...</h3></p>
<p>Change the code in <q>selector.js</q> to:</p>

<p><pre class="brush:js">if(YAHOO.env.ua.ie && ((!document.documentMode && YAHOO.env.ua.ie<8) || document.documentMode < 8)){// rewrite class for IE < 8</pre></p>

<p>If the <code>document.documentMode</code> does not exist, default to the user-agent string, otherwise, use the <code>document.documentMode</code> to evaluate the version of IE.</p>

<p><h3>There's More...</h3></p>
<p>Perhaps future versions of YUI will take the <code>document.documentMode</code> into consideration when evaluating the user-agent, but for now we must apply this patch to fix the selector component in IE 8.</p>

<p>A big thanks goes out to <a href="http://yuilibrary.com/forum/memberlist.php?mode=viewprofile&u=242">Kaven Yan</a> who first fixed this issue.</p>

<p><h3>See Also</h3></p>
<p><ul>
<li>The open ticket on this issue, <a href="http://yuilibrary.com/projects/yui2/ticket/2528006">http://yuilibrary.com/projects/yui2/ticket/2528006</a></li>
</ul></p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=505</wfw:commentRss>
</item>
<item>
<title>Web Development News February 2010 A</title>
<link>http://mattsnider.com/news/web-development-news-022010-a/</link>
<guid isPermaLink="true" >http://mattsnider.com/news/web-development-news-022010-a/</guid>
<pubDate>Thu, 18 Feb 2010 08:52:31 -0800</pubDate>
<description><![CDATA[<p>Here is some news from the first half of Febraury that I found interesting:</p>

<p><h3>Touch Events (JavaScript for Touchscreen Devices)</h3></p>
<p>PPK has done a lot of research on touch events, and posted a compatibility table and his thoughts:</p>

<p><a href="http://www.quirksmode.org/blog/archives/2010/02/the_touch_actio.html">The Touch Action</a></p>
<p><a href="http://www.quirksmode.org/blog/archives/2010/02/persistent_touc.html">Persistent Touch Event Objects</a></p>

<p><h3>New MooTools Released</h3></p>
<p>A new version (1.2.4.4) of the MooTools JavaScript framework has been released.</p>

<p><a href="http://feedproxy.google.com/~r/mootools-blog/~3/W04EFx06I9Y/">MooTools 1.2.4.4</a></p>

<p>Additionally, developers describe how to use MooTools as a <a href="http://feedproxy.google.com/~r/mootools-blog/~3/zDMDreepYWM/">General Purpose Application Framework</a>.</p>

<p><h3>IE 6 Comic Strip</h3></p>
<p>And this was just awesome.</p>

<p><a href="http://media.smashingmagazine.com/cdn_smash/wp-content/uploads/2010/02/ie6-comic-strip.jpg">The Life and Times (and Death?) of Internet Explorer 6</a></p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=504</wfw:commentRss>
</item>
<item>
<title>Radial Menu Key Events</title>
<link>http://mattsnider.com/widget/radial-menu-key-events/</link>
<guid isPermaLink="true" >http://mattsnider.com/widget/radial-menu-key-events/</guid>
<pubDate>Wed, 17 Feb 2010 11:54:01 -0800</pubDate>
<description><![CDATA[<p>In this article, we add key events into the <a href="http://www.mattsnider.com/widget/radial-menu/">Radial Menu</a>. The goal is to allow end-users to navigate the menu with the keyboard, once it has been opened, using the arrow keys. Additionally, end-users will be able to select panels with the <q>enter</q> key and close the menu with the <q>escape</q> key.</p>

<p><h3>Setup</h3></p>
<p>Instead of adding keyboard support as a plugin, I decided to incorporate it directly into the menu, as widgets should be navigable via the keyboard, as well as the mouse. Thus, there is no additional setup required.</p>

<p><h3>How It's Done...</h3></p>
<p>When the Radial Menu is opened, a <code>keydown</code> and <code>keyup</code> listener is attached to the document. The callback for the <code>keydown</code> event is:</p>

<p><pre class="brush:js">_handleKeyDown: function(e) {
	var panels = this.get('panels'),
		lastPanel = this._lastPanel,
		i = lastPanel ? lastPanel.getRadialIndex() : 0,
		n = panels.length,
		isValid = false,
		hoverClass = this.get('hoverClass'),
		m, l=n%2;
	
	switch (e.keyCode) {
		case 38: // up
			if (0 != i) {
				isValid = true;
				if (n / 2 > i) {
					i -= 1;
				}
				else {
					i += 1;
				}
			}
		break;

		case 39: // right
			m = n / 4;

			if (m != i && ! (l && _isBetween(i, m-1, m+1))) {
				isValid = true;
				if (m >= i + 1 || n - m <= i) {
					i += 1;
				}
				else if (m <= i - 1) {
					i -= 1;
				}
			}
		break;

		case 40: // down
			m = n / 2;
				
			if (m != i && ! (l && _isBetween(i, m-1, m+1))) {
				isValid = true;
				if (m >= i + 1) {
					i += 1;
				}
				else if (m <= i - 1) {
					i -= 1;
				}
			}
		break;

		case 37: // left
			m = n / 4;

			if (n - m != i && ! (l && _isBetween(i, n-m-1, n-m+1))) {
				isValid = true;
				if (m < i && n - m >= i + 1) {
					i += 1;
				}
				else if (n - m <= i - 1 || i <= m) {
					i -= 1;
				}
			}
		break;

		case 13: // enter
			if (lastPanel) {
				e.target = lastPanel._node;
				this._handleClick(e);
			}
		break;

		case 27: // escape
			this.hide();
		break;
	}

	if (isValid) {
		if (this._timerKeyDown) {this._timerKeyDown.cancel();}

		if (0 > i){
			i = n - 1;
		}
		else if (n - 1 < i) {
			i = 0;
		}

		n = this.get('keyHoldTimeout');
		if (0 < n) {
			this._timerKeyDown = Y.later(n, this, this._handleKeyDown, e);
		}
		
		if (lastPanel) {lastPanel._node.removeClass(hoverClass);}
		lastPanel = panels[i];
		this._lastPanel = lastPanel;
		lastPanel._node.addClass(hoverClass);
		this._isKeyPressed = true;
	}
},</pre></p>

<p>The <code>keyup</code> event listener simply stops the event timer started at the end of the <code>keydown</code> function:</p>

<p><pre class="brush:js">_handleKeyUp: function(e) {
	if (this._timerKeyDown) {this._timerKeyDown.cancel();}
	this._isKeyPressed = false;
},</pre></p>

<p><h3>How It Works...</h3></p>

<p>When an arrow key is detected, the position of the currently selected panel is fetched (or ZERO is used), and a calculation is made to determine whether the menu has additional panels in the desired direction available for selection. If there are additional panels, then the position is changed by one. </p>

<p>If there is a value for the new property <code>keyHoldTimeout</code>, then a timer is set to call the <code>_handleKeyDown</code> function again. This facilitates instances where end-users hold down an arrow key. The rest of the function handles caching the current panel and applying the hover class.</p>

<p>The <q>enter</q> key calls the click handler, and the <q>escape</q> key calls the <code>hide</code> function></p>

<p><h3>There's More...</h3></p>

<p>All events and pointers are attached when the menu is opened, and removed when the menu is closed, to remove impact on the page performance.</p>

<p>You may notice minor issues with the arrow navigation when using a small number of panels. You can use the arrow keys to reach all positions, but sometimes a position isn't reachable by all arrows that you think it should be (ie., you expect down and right arrows will get you to a position, but only the down arrow does). It did not seem to be a blocking issue, but if you have a solution, feel free to post it in the comments.</p>

<p><h3>See also</h3></p>
<p>The article, <a href="http://www.mattsnider.com/widget/radial-menu/">Radial Menu</a>, where this widget was first introduced.</p>
<p>The test page, <a href="http://www.mattsnider.com/tests/test_radialMenu.html">Radial Menu Test</a>, where you can play with the animations yourself.</p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=503</wfw:commentRss>
</item>
<item>
<title>Sorry, No Article This Week</title>
<link>http://mattsnider.com//news/sorry-no-article-this-week/</link>
<guid isPermaLink="true" >http://mattsnider.com//news/sorry-no-article-this-week/</guid>
<pubDate>Thu, 11 Feb 2010 10:10:08 -0800</pubDate>
<description><![CDATA[<p>I was not able to complete the Radial Menu widget keyboard events improvement. I have been blocked on an issue with the YUI 3 event detach function not working properly with events created using <code>Y.on()</code>, instead of <code>nodeInstance.on()</code>. I expect I will resolve it over the weekend and have an article for you by Tuesday. Thanks for you patience.</p>

<p>-matt</p>

<p>In the meantime, here is a video of Douglas Crockford's Talk: And Then There Was JavaScript</p>
<p><div><object width="576" height="324"><param name="movie" value="http://d.yimg.com/m/up/ypp/default/player.swf"></param><param name="flashVars" value="vid=18051724&"></param><param name="allowfullscreen" value="true"></param><param name="wmode" value="transparent"></param><embed width="576" height="324" allowFullScreen="true" src="http://d.yimg.com/m/up/ypp/default/player.swf" type="application/x-shockwave-flash" flashvars="vid=18051724&"></embed></object></div></p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=502</wfw:commentRss>
</item>
<item>
<title>Radial Menu Animation</title>
<link>http://mattsnider.com/widget/radial-menu-animation/</link>
<guid isPermaLink="true" >http://mattsnider.com/widget/radial-menu-animation/</guid>
<pubDate>Fri, 05 Feb 2010 11:13:10 -0800</pubDate>
<description><![CDATA[<p>This article will discuss an animation plugin for the <a href="http://www.mattsnider.com/widget/radial-menu/">Radial Menu</a> widget. It was written as a plugin, both to better understand the plugin infrastructure of YUI 3, and because not all developers will want animation in all cases. There are two animations, one that radiates and the another that rotates out (and in) from (and to) the center.</p>

<p><h3>Setup...</h3></p>

<p>First add the animation plugin to your YUI 3 modules list:</p>

<p><pre class="brush:js">YUI({
	/* ... */
	modules: {
		/* ... */
		
		'gallery-radial-menu-anim': {
			fullpath: 'http://yui-ext-mvc.googlecode.com/svn/trunk/assets/js/yahoo-3-ext/RadialMenuAnim.js',
			requires: ['plugin', 'anim', 'gallery-radial-menu'],
			optional: [],
			supersedes: []
		},
	}
});</pre></p>

<p><h3>How It's Done...</h3></p>

<p><h4>Plugin default animation:</h4></p>

<p><pre class="brush:js">radioMenuInstance.plugin(Y.RadialMenuAnim, {});</pre></p>

<p><h4>Plugin a configured animation:</h4></p>

<p><pre class="brush:js">radioMenuInstance.plugin(Y.RadialMenuAnim, {
	animType: 'rotate', 
	easingOut: Y.Easing.easeOut, 
	easingIn: Y.Easing.easeIn
});</pre></p>

<p><h4>Change plugin variables on the fly:</h4></p>

<p><pre class="brush:js">radioMenuInstance.radialMenuAnim.set('animType', 'radiate');</pre></p>

<p><h3>How It Works...</h3></p>

<p>The YUI 3 widget plugin system, augments the <code>radialMenuInstance</code> by listening for the execution of the <code>hide</code>, <code>show</code>, and <code>syncUI</code> functions. When this happens, <code>RadialMenuAnim</code> prevents the default behavior of those functions, and implements its own version. </p>

<p>To animate, the hijacked <code>hide</code> and <code>show</code> functions either move along a straight line (radiate animation) or they follow a 90 degree rotating path while moving along the radius (rotate animation), from the center to the panel's position on the circle (or the reverse). The YUI <q>curve</q> animation is use for the rotation animation, see the <a href="http://developer.yahoo.com/yui/3/examples/anim/curve.html">Curve Animation Example</a> for more information.</p>

<p>There are 5 properties that can be defined on the RadialMenuAnim plugin:</p>

<p><table class="properties"></p>
<p><thead><tr></p>
<p>	<th>Name:</th></p>
<p>	<th>Description:</th></p>
<p></tr><thead></p>
<p><tbody></p>
<p><tr></p>
<p>	<td class="label">animType:</td></p>
<p>	<td>A string value that is the type of animation to use, either <q>radiate</q> or <q>rotate</q>; defaults to <q>radiate</q></td></p>
<p></tr></p>
<p><tr></p>
<p>	<td class="label">duration:</td></p>
<p>	<td>An integer value that is the duration for the animation; defaults to 1 second</td></p>
<p></tr></p>
<p><tr></p>
<p>	<td class="label">easingIn:</td></p>
<p>	<td>A <code>Y.Easing</code> function for the hide animation; defaults to <code>Y.Easing.elasticIn</code></td></p>
<p></tr></p>
<p><tr></p>
<p>	<td class="label">easingOut:</td></p>
<p>	<td>A <code>Y.Easing</code> function for the show animation; defaults to <code>Y.Easing.elasticOut</code></td></p>
<p></tr></p>
<p><tr></p>
<p>	<td class="label">rotation:</td></p>
<p>	<td>An integer value that is the number of degrees to rotate by when using the <q>rotate</q> <q>animType</q>; defaults to 90</td></p>
<p></tr></p>
<p></tbody></p>
<p></table></p>

<p><h3>There's More...</h3></p>
<p>Because some browsers suck (ahem... IE), and I needed the capability for my testing page, there are two functions that can be used to turn the animation plugin on and off:</p>

<p><pre class="brush:js">// turn plugin on
radioMenuInstance.enable();

// turn plugin off
radioMenuInstance.disable();</pre></p>

<p>The plugin is enabled by default.</p>

<p><h3>See also</h3></p>
<p>The article, <a href="http://www.mattsnider.com/widget/radial-menu/">Radial Menu</a>, where this widget was first introduced.</p>
<p>The test page, <a href="http://www.mattsnider.com/tests/test_radialMenu.html">Radial Menu Test</a>, where you can play with the animations yourself.</p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=501</wfw:commentRss>
</item>
<item>
<title>Web Development News January 2009 B</title>
<link>http://mattsnider.com/news/web-development-news-012010-b/</link>
<guid isPermaLink="true" >http://mattsnider.com/news/web-development-news-012010-b/</guid>
<pubDate>Tue, 02 Feb 2010 09:16:32 -0800</pubDate>
<description><![CDATA[<p>There has been a lot of interesting news from the second half of January. Here are some of the stories that resonated with me:</p>

<p><h3>Dojo 1.4.1 Release Candidate 1</h3></p>
<p>If you use the Dojo framework, then you'll be excited about there new release candidate. I have not seen the spec document yet, but the developers mention FireFox 3.6 support.</p>

<p><a href="http://o.dojotoolkit.org/2010/01/21/1-4-1-release-candidate-1-ready">http://o.dojotoolkit.org/2010/01/21/1-4-1-release-candidate-1-ready</a></p>

<p><h3>Google Reader For Any Website</h3></p>
<p>Google reader now has the ability to follow changes on any website, not just RSS feeds. </p>

<p><a href="http://googlereader.blogspot.com/2010/01/follow-changes-to-any-website.html">http://googlereader.blogspot.com/2010/01/follow-changes-to-any-website.html</a></p>

<p><h3>JavaScript Unpacker</h3></p>
<p>JSBeautifer attempts to revert JavaScript compression and obfuscation, so that you can read code snippets from the web.</p>

<p><a href="http://jsbeautifier.org/">http://jsbeautifier.org/</a></p>

<p><h3>HTML 5 Audio Player Demo</h3></p>
<p>To teach himself a little about HTML 5, <a href="http://jszen.blogspot.com/">Scott Andrew LePera</a> wrote a proof of concept audio player.</p>

<p><a href="http://jszen.blogspot.com/2010/01/html-5-audio-player-demo.html">http://jszen.blogspot.com/2010/01/html-5-audio-player-demo.html</a></p>

<p><h3>HTC Performance</h3></p>
<p>This article highlights the performance cons of using an HTC file to fix IE 6. I recommend progressive enhancement over attempting to make IE behave like other browsers, but if you insist on it, then you should read this:</p>

<p><a href="http://www.codingforums.com/archive/index.php/t-63384.html">http://www.codingforums.com/archive/index.php/t-63384.html</a></p>

<p><h3>SVG</h3></p>
<p>I have been seeing a lot of SVG work lately. Here are a few highlights:</p>

<p><a href="http://www.sitepoint.com/blogs/2010/01/25/what-everybody-ought-to-know-about-using-svg-right-now/">http://www.sitepoint.com/blogs/2010/01/25/what-everybody-ought-to-know-about-using-svg-right-now/</a></p>

<p><a href="http://www.alistapart.com/articles/using-svg-for-flexible-scalable-and-fun-backgrounds-part-i/">http://www.alistapart.com/articles/using-svg-for-flexible-scalable-and-fun-backgrounds-part-i/</a></p>

<p><a href="http://www.alistapart.com/articles/using-svg-for-flexible-scalable-and-fun-backgrounds-part-ii/">http://www.alistapart.com/articles/using-svg-for-flexible-scalable-and-fun-backgrounds-part-ii/</a></p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=500</wfw:commentRss>
</item>
<item>
<title>Running JSLint With Your Ant Build</title>
<link>http://mattsnider.com/build/running-jslint-with-your-ant-build/</link>
<guid isPermaLink="true" >http://mattsnider.com/build/running-jslint-with-your-ant-build/</guid>
<pubDate>Thu, 28 Jan 2010 09:58:36 -0800</pubDate>
<description><![CDATA[<p>In the article, <a href="http://mattsnider.com/build/using-ant-to-consolidate-css-and-javascript/">Using Ant to Consolidate CSS and JavaScript</a>, we discussed how to use Ant for consolidating and compressing JavaScript and CSS. Today we will take that a step further by adding JSLint JavaScript validation to the process. JSLint is a code quality tool that checks your code for common JavaScript errors, best practices, and optimizations.</p>

<p><blockquote>Keep in mind that using JSLint will hurt your feelings, so only read on if you are either brave or foolhardy.</blockquote></p>

<p><h3>How It's Done...</h3></p>

<p>We will be modifying the ant build script from YUI-EXT-MVC at <a href="http://yui-ext-mvc.googlecode.com/svn/trunk/build.xml">http://yui-ext-mvc.googlecode.com/svn/trunk/build.xml</a>.</p>

<p><h4>First you need two files:</h4></p>

<p><ul>
<li>Get the latest version of Rhino at <a href="http://www.mozilla.org/rhino/">http://www.mozilla.org/rhino/</a></li>
<li>Get the latest version of JSLint for Rhino at <a href="http://www.jslint.com/rhino/">http://www.jslint.com/rhino/</a></li>
</ul></p>

<p>Extract the JAR from the Rhino download (it was named <q>js-14.jar</q> for me, so I renamed it to the more useful <q>rhino-1.7R2.jar</q>) and the JSLint JavaScript file. Move them both to a folder accessible by your build.</p>

<p><h4>Setup build properties pointing to the two files you downloaded:</h4></p>

<p><pre class="brush:xml">
&lt;property name="rhino.jar" value="${basedir}/bin/rhino-1.7R2.jar"/&gt;
&lt;property name="jslint.js" value="${basedir}/bin/jslint.js"/&gt;
</pre></p>

<p><h4>Execute JSLint on the consolidated JavaScript files:</h4></p>

<p><pre class="brush:xml">
&lt;echo message="JSLinting consolidatedFile.js"/&gt;
&lt;apply executable="java" parallel="false"&gt;
	&lt;filelist dir="${builddir}/js"&gt;
		&lt;file name="consolidatedFile.js"/&gt;
	&lt;/filelist&gt;
	&lt;arg line="-jar"/&gt;
	&lt;arg path="${rhino.jar}"/&gt;
	&lt;arg path="${jslint.js}"/&gt;
&lt;/apply&gt;</pre></p>

<p>Now when the script consolidates your JavaScript files, it also executes JSLint. JSLint will output the errors and warnings it finds, but will only stop the build if it finds a critical error.</p>

<p><h4>Configuring JSLint:</h4></p>

<p>The off the shelf version of JSLint is very strict and may not suit your needs. For work on <a href="http://www.mint.com">Mint.com</a> I had to register a bunch of globals and change the default configuration. To change your default configuration, look in the <q>jslint.js</q> file for the line:</p>

<p><pre class="brush:js">if(!JSLINT(input,{...}</pre></p>

<p>The properties defined inside the object can be activated by setting them to <q>true</q>. A full list of properties is available at <a href="http://www.jslint.com/lint.html#options">http://www.jslint.com/lint.html#options</a>. You will most likely want to set the property <code>browser</code> and <code>widget</code> to true, which will allow browser and YUI globals.</p>

<p>If you have additional globals, then you need to find the <code>browser={...}</code> object in <q>jslint.js</q>. Add any global variables to this object where the variable name is the key and set its value to <code>false</code>. For example, if you use JQuery you might want to add the following two globals:</p>

<p><pre class="brush:js">browser={/* already defined properties */
jquery: false,
'$': false
}</pre></p>

<p><h3>How It Works...</h3></p>

<p>JSLint uses a variety of techniques to scan JavaScript files against a collection of validations. The validations are customizable and can be turned on or off by modifying <q>jslint.js</q>. Since <q>jslint.js</q> is a JavaScript file, Rhino is needed to run JavaScript from the command line. You can execute this Rhino command directly on the command line, but today's article show how to use Ant to automate the build process.</p>

<p><h3>There's More...</h3></p>

<p>JSLint can take a while to execute, especially on large, consolidated files. Advanced users of Ant may want to define a property to make JSLint an optional part of their build:</p>

<p><pre class="brush:xml">&lt;if&gt;
	&lt;isset property="enable.jslint"/&gt;
	&lt;then&gt;
		&lt;echo message="validating consolidatedFile"/&gt;
		&lt;apply executable="java" parallel="false"&gt;
			&lt;filelist dir="${builddir}/js"&gt;
				&lt;file name="consolidatedFile"/&gt;
			&lt;/filelist&gt;
			&lt;arg line="-jar"/&gt;
			&lt;arg path="${rhino.jar}"/&gt;
			&lt;arg path="${jslint.js}"/&gt;
		&lt;/apply&gt;
	&lt;/then&gt;
&lt;/if&gt;</pre></p>

<p>By default this code block will not execute. You will need to call Ant in the following way to execute JSLint:</p>

<p><pre class="brush:cpp">ant -Denable.jslint=true package</pre></p>

<p><h3>More to Come...</h3></p>

<p>I am fairly happy with the current <q>build.xml</q>, but there is a lot of repeated patterns (consolidate, jslint, compress). At <a href="http://www.mint.com">Mint.com</a> we have changed our consolidation script to use macros, making our <q>build.xml</q> simpler. However, macros are finicky and more complicated than calling simple ant commands. I anticipate that in the next couple months I will improve the build script to use macros and write an article explaining how.</p>

<p><h3>See Also...</h3></p>

<p><ul>
<li>The article, <a href="http://mattsnider.com/build/using-ant-to-consolidate-css-and-javascript/">Using Ant to Consolidate CSS and JavaScript</a>, to better understand <q>build.xml</q></li>
<li>The website, <a href="http://ant.apache.org/">http://ant.apache.org/</a>, for more about Apache Ant</li>
<li>And the website, <a href="http://www.jslint.com/lint.html">http://www.jslint.com/lint.html</a>, for more about JSLint</li>
</ul></p>

<p><h3>Note From Matt...</h3></p>
<p>I know some of you are anticipating improvements to the <a href="http://www.mattsnider.com/widget/radial-menu/">Radial Menu</a> that I introduced last week. I am working on it, but I do not have anything production ready yet. I hope to deliver a more complete version sometime next week. Who knows, if I feel it is good enough, I might submit it to the YUI gallery. ^_^</p>]]></description>
<wfw:commentRss>http://js-kit.com/rss/mattsnider.com/p=499</wfw:commentRss>
</item>
</channel>
</rss>