<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>thyncology</title>
	
	<link>http://www.thynctank.com</link>
	<description>The Science of Thynctank.</description>
	<lastBuildDate>Fri, 03 Apr 2009 03:51:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/thyncology" /><feedburner:info uri="thyncology" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>All That Jazz</title>
		<link>http://feedproxy.google.com/~r/thyncology/~3/UxhJ1__a4g0/</link>
		<comments>http://www.thynctank.com/javascript/2009/03/all-that-jazz/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 21:41:29 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jazzrecord]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/?p=169</guid>
		<description><![CDATA[I&#8217;d been toying with the idea of expanding JazzRecord into a full MVC stack for building Javascript apps, and I finally spent enough time thinking and obsessing about it to get some work done.

I&#8217;m calling it JazzFusion.

It&#8217;s not well-organized yet, but the ideas are there, and it&#8217;s going to be very modular. You&#8217;ll be able [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d been toying with the idea of expanding <a href="http://www.jazzrecord.org">JazzRecord</a> into a full <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">MVC</a> stack for building Javascript apps, and I finally spent enough time thinking and obsessing about it to get some work done.</p>

<p>I&#8217;m calling it <strong>JazzFusion</strong>.</p>

<p>It&#8217;s <em>not</em> well-organized yet, but the ideas are there, and it&#8217;s going to be <strong>very modular</strong>. You&#8217;ll be able to use JazzRecord <em>or any other data component</em> for handling the database, and <strong>view templating will also be easily extensible</strong>. The goal for views is to allow simple string-replacement templating with a few macros out of the gate (for calling helper methods, etc), as well as supporting Markdown through <a href="http://attacklab.net/showdown/">Showdown</a>, which I discovered thanks to <a href="http://funkatron.com">Ed Finkler</a>, author of Spaz.</p>

<p>The controller methodology is very much inspired by Rails (like JazzRecord&#8217;s models), so anyone coming from a Rails background will feel right at home. It supports lazy loading of views and eager loading of controllers out of the gate, with minimal configuration hassle. Control routing will be handled by another modular piece, and documentation will be available on how to easily override the router and view renderer, and detailed docs on writing DRY controllers with features like <strong>before/after filters</strong> and the ability to <strong>render/redirect</strong> from one controller/action to other controllers and actions.</p>

<p>I&#8217;m playing with the idea now of building a Ruby-based set of <strong>generator tools</strong> for JazzFusion modeled after Rails&#8217; script/generator tools.</p>

<p>More details to follow, and as soon as the library is in somewhat of a ready state the website/Google Group/Twitter/Github for it will be made available.</p>
<img src="http://feeds.feedburner.com/~r/thyncology/~4/UxhJ1__a4g0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/javascript/2009/03/all-that-jazz/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.thynctank.com/javascript/2009/03/all-that-jazz/</feedburner:origLink></item>
		<item>
		<title>Gracefully Degrading Widgets, Part 2: Navbars &amp; jQuery Plugins</title>
		<link>http://feedproxy.google.com/~r/thyncology/~3/9TwZORNebfE/</link>
		<comments>http://www.thynctank.com/javascript/2009/03/gracefully-degrading-widgets-part-2-navbars-jquery-plugins/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 10:42:14 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[graceful degradation]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[progressive enhancement]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/?p=145</guid>
		<description><![CDATA[I recently met up with a friend and former coworker to help him ramp up his jQuery skills quickly. In the process I got to play with a few things I hadn&#8217;t bothered to pick up previously myself!

First of these was Google&#8217;s Ajax Libraries API. While worthless for when you need to be offline (as [...]]]></description>
			<content:encoded><![CDATA[<p>I recently met up with a friend and former coworker to help him ramp up his jQuery skills quickly. In the process I got to play with a few things I hadn&#8217;t bothered to pick up previously myself!</p>

<p>First of these was <a href="http://code.google.com/apis/ajaxlibs/">Google&#8217;s Ajax Libraries API</a>. While worthless for when you need to be offline (as I ended up being, since the Borders where we met has no free wifi, and <strong>I am cheap/skint</strong>), it&#8217;s nice and easy to include scripts on your pages without needing to maintain the files yourself. Luckily I thought to download local copies and installed Google Docs offline shortly before leaving to meet with the dude.</p>

<p>The second interesting thing I picked up, I actually picked up <em>after</em> the meeting, as I both wanted to learn it and wanted to share with my friend. That something is <em>How to Author a jQuery Plugin</em>, which is what we&#8217;re going to look at today. We&#8217;ll be building a flexible drop-down navigation menu which will work <em>with or without</em> JavaScript thanks to CSS.</p>

<p>Here&#8217;s the working example: <a href="http://www.thynctank.com/nav.html">MultiNav</a></p>

<p><a href="http://www.thynctank.com/javascript/2008/02/gracefully-degrading-widgets-part-1-tabs/">Previously</a>, I discussed some of the fundamental ideas behind <strong>Gracefully Degrading Widgets</strong>, but let&#8217;s quickly delineate them again here:</p>

<ul>
<li>Focus on content above interactivity &#8211; if that means sacrificing the latter for the former, so be it</li>
<li>Present most important content first &#8211; sometimes it is necessary to hide some content to maintain page layout, the most important still shows</li>
<li>Write minimalist markup &#8211; this leads to fewer chances of screwing up and makes it easier on any consumers of your code</li>
<li>Write stylesheets to hide interactive content by default, and override in your JavaScript</li>
</ul>

<p>We&#8217;ll also be focusing on <strong>reusability</strong> and <strong>flexibility</strong>, and we&#8217;ll discover that part of this is covered by virtue of the fact we&#8217;re creating our widget as a jQuery plugin. jQuery plugins are automatically applicable to any selector style available in jQuery, and so our widget will immediately be available to instantiate among common classes of a page, or to elements with individually unique IDs. You can even apply multiple instances on the page at simultaneously. In addition to these flexible instantiation capabilities, we&#8217;ll be building the widget to take a number of options to use different effects, use different classes if the default class names are not appropriate or would conflict with existing names on the page, and so on.</p>

<p>On with the show already! First off let&#8217;s create some simple markup for our drop down menu and style it w/ CSS:</p>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nav&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Top Level<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Submenus<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Are Much<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Less Prominent<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Menus Are<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Most Noticeable<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>But Still<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Quite Useful<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>


<p>Nice and simple!</p>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">  <span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.nav</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.nav</span> li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#ccccee</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2em</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.nav</span> li ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #933;">50px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.nav</span> li a <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.nav</span> li a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.nav</span> li<span style="color: #3333ff;">:hover </span>ul <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
  <span style="color: #6666ff;">.nav</span> li ul li <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">130px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>


<p><em>Still</em> simple!</p>

<p>Even with this alone, the example code will show simple hover-over submenus via CSS, in browsers that support it (all but IE6, I believe). This is where degradation comes into play. We want things to fail gracefully, so each of those top-level menus should be a link in and of itself, rather than slamming all the links into the submenus. This is a good failover.</p>

<p>So now that we&#8217;ve got simple menus, let&#8217;s add some action!</p>

<p>To animate a single submenu&#8217;s intro into the page, we might use code similar to the following:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.nav:first &gt; ul &gt; li:first &gt; ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<p>Which uses an advanced CSS3 selector to grab the very first submenu (a <em>ul</em> element) of the first top-level menu item of the first nav. <code>fadeIn()</code> is a call to a nice pre-defined function of any element(s) returned by jQuery.</p>

<p>That&#8217;s all well and good, but what we really need to do is setup a hover effect to fade this menu in and out given the user&#8217;s interaction with it.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.nav:first &gt; li:first&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<p>This sets up two anonymous functions to be triggered on <em>mouseOver</em> and on <em>mouseOut</em>. jQuery takes care of all of this. What&#8217;s important is understanding the selectors and the event assignment. We won&#8217;t go into detail about the selectors here, but definitely read the <a href="http://docs.jquery.com/Selectors">documentation</a> and play with it. The <em>hover</em> function takes two parameters, each a function. The first will be run on mouseOver, and the second will be run on mouseOut.</p>

<p>So that&#8217;s a start. Our submenu is fading in and out. But what if you accidentally mouse off the submenu? The damned thing fades away instantly! To get around this limitation, we&#8217;ll use a handy built-in feature of JavaScript, <code>setTimeout</code>. This function takes as its parameters a function literal to be called after a specified number of milliseconds, followed by a timeout value in milliseconds. On mouseOver, we&#8217;ll set a class on the element, let&#8217;s call it &#8220;over&#8221;. On mouseOut, we&#8217;ll remove the class, and call <code>setTimeout</code>. After a specified amount of time, let&#8217;s say 500ms, we&#8217;ll check whether the class &#8220;over&#8221; is present on the top-level nav, and if it isn&#8217;t, we&#8217;ll fade it out. If it is (indicating the nav item has been hovered over again), we do nothing.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.nav:first &gt; li:first&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;over&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> li <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>li.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;over&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
          li.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<p>This new code sets it up exactly as we&#8217;d like it for the first submenu content alone.</p>

<p>What we want to do is make this reusable, as much as possible, and also make it versatile. That&#8217;s where jQuery&#8217;s plugin system comes in.</p>

<p>jQuery plugins are like any other widget initializer code, only they automatically get to take advantage of jQuery&#8217;s fancy schmancy selector system. They should also be written using the function name <em>jQuery</em> rather than <em>$</em>, because jQuery optionally allows itself to be alternately aliased so that it can sit along side other libraries, which might also define a global function <em>$</em>. Both <a href="http://www.prototypejs.org">Prototype</a> and <a href="http://www.mootools.net/">MooTools</a> do this, and still jQuery can run in combination with these libraries. If you were to use the $ function, you could likely be unintentionally calling the Prototype or MooTools selector function rather than jQuery&#8217;s.</p>

<p>Instructions on authoring jQuery plugins can be found <a href="http://docs.jquery.com/Plugins/Authoring">on jQuery&#8217;s Web site</a>. It all boils down to:</p>

<ol>
<li>Respecting the &#8220;jQuery&#8221; function name over &#8220;$&#8221;</li>
<li>Defining your function as a property of <code>jQuery.fn</code>, and</li>
<li>Returning the jQuery object that it is called on. (this allows chaining calls, something near and dear to jQuery developers&#8217; hearts)</li>
<li>To be incorporated as an official plugin, the plugin should be defined in a standalone file, named &#8220;jquery.[plugin name].js&#8221; where &#8220;[plugin name]&#8221; is your plugin&#8217;s name.</li>
</ol>

<p>Let&#8217;s take a look at the next version of our code, the first as a plugin:</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">nav</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> nav <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      nav.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &gt; li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> li <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>li.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;over&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            li.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">500</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>


<p>This is a very suitable, fine piece of code, and it&#8217;s even a plugin now. It&#8217;s even reusable, because it&#8217;s no longer tied to the &#8220;.nav&#8221; class. You can actually call it multiple times on a page, and using multiple selectors, and all will work just fine, independently:</p>

<ul>
<li><code>$(".nav").nav()</code> works just like our old code, only now it&#8217;s a <em>lot</em> shorter.</li>
<li><code>$("#topNav").nav()</code> also works, only this is for a single unique element</li>
</ul>

<p>However, it&#8217;s not very versatile beyond the selector bit. For that, we&#8217;ll need to introduce the concept of <em>default options</em> and overrides. jQuery provides a simple means of setting up default settings for a plugin that can be overridden in any call to it by passing in an options object. The options object concept is an echo of similar functionality in other programming languages: Ruby (via Hashes), Python (via named arguments) and other languages via similar constructs such as associative arrays. The idea behind it is that no one wants to have to memorize the order of parameters for a function, so don&#8217;t make them! Object literals allow you to specify their component properties in any order.</p>

<p>To obtain this functionality in jQuery, simply call <code>jQuery.extend()</code>, passing in an object literal for the default values, and the options object parameter from the plugin&#8217;s function. Through this, we can specify faster or slower fade effects, as well as change the actual effects called. This is the final version of our plugin, and the code is quite a bit longer.</p>


<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">  jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">multinav</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>options<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> settings <span style="color: #339933;">=</span> jQuery.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      effect<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;fade&quot;</span><span style="color: #339933;">,</span>
      duration<span style="color: #339933;">:</span> <span style="color: #CC0000;">250</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> fade <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
      over<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;">&#40;</span>settings.<span style="color: #660066;">duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      out<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span>settings.<span style="color: #660066;">duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> slide <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
      over<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span>settings.<span style="color: #660066;">duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      out<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span>settings.<span style="color: #660066;">duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> size <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
      over<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span>settings.<span style="color: #660066;">duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      out<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span>settings.<span style="color: #660066;">duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> effect <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span>settings.<span style="color: #660066;">effect</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;slide&quot;</span><span style="color: #339933;">:</span>
        effect <span style="color: #339933;">=</span> slide<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;size&quot;</span><span style="color: #339933;">:</span>
        effect <span style="color: #339933;">=</span> size<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;fade&quot;</span><span style="color: #339933;">:</span>
      <span style="color: #003366; font-weight: bold;">default</span><span style="color: #339933;">:</span>
        effect <span style="color: #339933;">=</span> fade<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// iterate over the elements obtained from the selector</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> nav <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      nav.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &gt; li &gt; ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      nav.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &gt; li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;over&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        effect.<span style="color: #660066;">over</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> li <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;over&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>li.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;over&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            effect.<span style="color: #660066;">out</span><span style="color: #009900;">&#40;</span>li<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>


<p>Though this code is longer, it&#8217;s still quite legible. We&#8217;ve changed the plugin&#8217;s name to <em>multinav</em> to reflect it&#8217;s new, multi-functional nature The new benefit is that we are able to call on the plugin with alternate effects and timing, simply by passing in an object literal with alternate values from the defaults. Here are a few examples:</p>

<ul>
<li><code>$(".nav:first").multinav();</code> &#8211; this is the default behavior</li>
<li><code>$(".nav:nth(1)").multinav({effect: "slide", duration: 100});</code> &#8211; this selects the second nav-classed element and performs a fast slideIn on hover</li>
<li><code>$(".nav:last").multinav({effect: "size", duration: 1000});</code> &#8211; this selects the last nav-classed element and performs a slow size-in on hover</li>
</ul>

<p>Using these ideas, you can build any number of plugins which, when handled correctly, can <em>work alongside other libraries</em>, can <em>work under a variety of conditions</em> and <em>present different functionality based on the needs of the job at hand</em>. Calling on a plugin is <strong>typically only one line of code</strong>. That&#8217;s a lot of power in one line. Not only that, but when using the practices of graceful degradation, your page will look and behave appropriately when interactivity is not possible in the browser.</p>

<p>Remember that any widget with interactive elements (form controls, ajax links, tabs, content which moves around or hides/reveals&#8230;) should either hide those interactive elements in the CSS and reveal in the JavaScript, or find a way to make use of the elements using the backend. This ensures the page does not contain any confusing, ineffectual controls which look as though they&#8217;ll bring about change on the page. In the case of ajax tabs, for instance, you have two choices: Hide the tabs altogether (certainly the easier route), or organize your content and backend technology so that the tabs work as static links to reload the page showing the appropriate (newly-clicked) tab content and hiding the other tabs. This is a bit more trouble, and if you can get away with showing only the most-important content in the first tab, I suggest taking that route.</p>

<p>Have fun writing gracefully-degrading jQuery plugins!</p>
<img src="http://feeds.feedburner.com/~r/thyncology/~4/9TwZORNebfE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/javascript/2009/03/gracefully-degrading-widgets-part-2-navbars-jquery-plugins/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.thynctank.com/javascript/2009/03/gracefully-degrading-widgets-part-2-navbars-jquery-plugins/</feedburner:origLink></item>
		<item>
		<title>SafariWatir Nuisances</title>
		<link>http://feedproxy.google.com/~r/thyncology/~3/iUBoWPwc1yA/</link>
		<comments>http://www.thynctank.com/ruby-rails/2009/03/safariwatir-nuisances/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 06:04:34 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[front end]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[watir]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/?p=157</guid>
		<description><![CDATA[The place where I work (RideCharge) is a Rails shop. As such, we&#8217;ve embraced numerous Ruby technologies, including several ActiveRecord plugins, test frameworks, and other components used at various points in the stack. I deal with a lot of view-side and presentational stuff, including having embraced Sass for stylesheets (I even use them in some [...]]]></description>
			<content:encoded><![CDATA[<p>The place where I work (<a href="http://www.ridecharge.com">RideCharge</a>) is a Rails shop. As such, we&#8217;ve embraced numerous Ruby technologies, including several ActiveRecord plugins, test frameworks, and other components used at various points in the stack. I deal with a lot of view-side and presentational stuff, including having embraced Sass for stylesheets (I even use them in some non-Rails/Ruby projects via CLI), making use of AssetPackager and so on.</p>

<p>One thing RideCharge has used, but which I&#8217;ve only recently expressed interest in, is Watir. Watir is a cool testing toolkit that allows you to control and get feedback from various Web browsers using Ruby. You can use it, or variations of it, with IE (the original Watir was IE-only) Firefox, Safari, or even Flash using the various <a href="http://wtr.rubyforge.org/platforms.html">variations</a>. I&#8217;ve only spent enough time with it to get it installed and tinker a bit, so this post only deals with real in-the-field experience. As such, I&#8217;ve only played with the FireWatir and SafariWatir variations.</p>

<p>One thing I&#8217;ve noticed already are some nuisances in SafariWatir and FireWatir, and perhaps Watir in general in some cases:</p>

<ul>
<li>SafariWatir&#8217;s <code>goto</code> method requires the protocol as part of the URL whereas FireWatir does not. This is a minor complaint.</li>
<li>Links in SafariWatir appear to have no href or url property (among others), despite <a href="http://wiki.openqa.org/display/WTR/Methods+supported+by+Element">this table</a> showing that they should.</li>
<li>SafariWatir has no url to determine the current page.</li>
<li>No support for CSS selectors that I&#8217;m aware. This could be brought in from one of at least two Ruby projects (<a href="http://wiki.github.com/why/hpricot">Hpricot</a> or <a href="http://github.com/tenderlove/nokogiri/tree/master">Nokogiri</a>). XPath is a bore.</li>
<li>Confusingly it only selects the first matching element if multiple elements match. There&#8217;s no way to verify the # of elements, etc. Selecting a different matching element is accomplished through the <code>:index</code> parameter.</li>
<li>Having a different &#8220;selector&#8221; method for almost every element type seems strange, but perhaps this is just bias from having used JavaScript selector engines so much.</li>
<li>Having the browser &#8220;click&#8221; a link where JavaScript is supposed to intercept the click fails to trigger the JavaScript, or may simply have no effect (in one case in SafariWatir).</li>
<li>No convenient &#8220;click the back button&#8221; method. This would be useful for testing state-saving in Ajax-focused applications where browser history is an issue.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/thyncology/~4/iUBoWPwc1yA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/ruby-rails/2009/03/safariwatir-nuisances/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.thynctank.com/ruby-rails/2009/03/safariwatir-nuisances/</feedburner:origLink></item>
		<item>
		<title>JazzRecord changes</title>
		<link>http://feedproxy.google.com/~r/thyncology/~3/ncJH_l-WYf0/</link>
		<comments>http://www.thynctank.com/javascript/2009/01/jazzrecord-changes/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 15:27:25 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jazzrecord]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/?p=143</guid>
		<description><![CDATA[So, the git repo has seen a lot of activity since it went up in November. We&#8217;ve added support for Appcelerator Titanium PR1, and most recently I completely gutted MooTools out of JazzRecord, making it compatible with any library you like, not just MooTools. We&#8217;ve also souped up the validation methods (all should be working [...]]]></description>
			<content:encoded><![CDATA[<p>So, the git repo has seen a lot of activity since it went up in November. We&#8217;ve added support for Appcelerator Titanium PR1, and most recently I completely gutted MooTools out of JazzRecord, making it compatible with any library you like, not just MooTools. We&#8217;ve also souped up the validation methods (all should be working now) and worked on expanding the automated testing we use to ensure the product is stable and working as expected. Around the corner, we&#8217;ll be adding support for new runtime environments as well as asynchronous support and additional testing.</p>

<p>Details to follow elsewhere, as we&#8217;ve also added a <a href="http://blog.jazzrecord.org">JazzRecord Blog</a>.</p>
<img src="http://feeds.feedburner.com/~r/thyncology/~4/ncJH_l-WYf0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/javascript/2009/01/jazzrecord-changes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.thynctank.com/javascript/2009/01/jazzrecord-changes/</feedburner:origLink></item>
		<item>
		<title>JazzRecord on Github, Plans to Nativize</title>
		<link>http://feedproxy.google.com/~r/thyncology/~3/ab3gN1XAN9Q/</link>
		<comments>http://www.thynctank.com/javascript/2008/11/jazzrecord-on-github-plans-to-nativize/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 10:26:35 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[change]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[jazzrecord]]></category>
		<category><![CDATA[jstorm]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[scm]]></category>
		<category><![CDATA[version control]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/?p=137</guid>
		<description><![CDATA[JazzRecord master repo is now officially hosted at Github. It&#8217;s available here.

Jesse and I have started to play with git and will be resuming moving forward with testing and refactoring things for the time being.

A short ways down the road, however, there will be a somewhat large change where I&#8217;ll be converting JazzRecord to be [...]]]></description>
			<content:encoded><![CDATA[<p>JazzRecord master repo is now officially hosted at Github. It&#8217;s <a href="http://github.com/thynctank/jazzrecord/tree/master">available here</a>.</p>

<p>Jesse and I have started to play with git and will be resuming moving forward with testing and refactoring things for the time being.</p>

<p>A short ways down the road, however, there will be a somewhat large change where I&#8217;ll be converting JazzRecord to be an independent library not based in MooTools. The reasoning is basically that with no dependency, more users will be inclined to accept it and move on with their app creation.</p>

<p>I&#8217;ve been in contact today with Uriel Kats, developer of another JavaScript ORM, <a href="http://www.urielkatz.com/archive/detail/introducing-jstorm/">JStORM</a>. JStORM has similar syntax for some of it, but he tells me his is rooted in Django whereas my library is rooted in ActiveRecord. We&#8217;ve both expressed interest in learning from one another. I&#8217;m <em>certain</em> to borrow some ideas from his code! He&#8217;s got JOINs implemented already, for one, a major stumbling block for me! His code is also pretty terse and easy to read.</p>

<p>If you come from Django and are looking for ORM in JS, perhaps you&#8217;d better take a look at JStORM!</p>

<p>If you&#8217;re down with ActiveRecord, hang around. We&#8217;ve got some cool stuff coming still.</p>
<img src="http://feeds.feedburner.com/~r/thyncology/~4/ab3gN1XAN9Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/javascript/2008/11/jazzrecord-on-github-plans-to-nativize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.thynctank.com/javascript/2008/11/jazzrecord-on-github-plans-to-nativize/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 5.244 seconds -->
