<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>User Agent Man &#187; Uncategorized</title>
	<atom:link href="http://www.useragentman.com/blog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.useragentman.com/blog</link>
	<description>A Blog about Client Side Web Technology</description>
	<lastBuildDate>Wed, 08 Sep 2010 14:02:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>visibleIf – Dynamic and Complex Interactive Forms Using HTML5 Custom Data Attributes</title>
		<link>http://www.useragentman.com/blog/2010/06/20/visibleif-html5-custom-data-attributes-with-javascript-make-dynamic-interactive-forms/</link>
		<comments>http://www.useragentman.com/blog/2010/06/20/visibleif-html5-custom-data-attributes-with-javascript-make-dynamic-interactive-forms/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 00:49:36 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=1251</guid>
		<description><![CDATA[One thing HTML5 forms can't do is dynamically show and hide form elements according to the data that the user has already entered.  My new library, <code>visibleIf</code> gives you a very easy way to do this using the HTML5 <code>data-</code> attributes.]]></description>
			<content:encoded><![CDATA[<div class="importantNotes">
<h3>Update (July 28, 2010):</h3>
<p>I have fixed a minor bug in this script to ensure compatibility with webforms2, part of <a href="http://www.useragentman.com/blog/2010/07/27/cross-browser-html5-forms-using-modernizr-webforms2-and-html5widgets/">a suite of scripts that implement cross-browser compatibility with the HTML5 forms specification</a>.</p>
</div>
<p>I have been following the progression of the HTML5 Forms standard with great interest.  It promises a whole slew of new visual and usability goodness to existing HTML forms (e.g. slider and calendar widgets), a client-side validation framework, and so much more.  One of the things I was disappointed with, though, was that <strong>HTML5 cannot hide and show form elements depending on what the user has input into the form so far.</strong>  To give a very simple example of what I am talking about, select a country of origin in the form below:</p>
<form>
<table class="formTable">
<tbody>
<tr>
<th>Country of Origin: </th>
<td>
<select name="country">
<option> Select One&#8230; </option>
<option value="Canada"> Canada </option>
<option value="United States"> United States </option>
</select>
</td>
</tr>
<tr class="visibleIf" data-visibleif-rule=" country == 'Canada'">
<th>Postal Code: </th>
<td>
<input name="postalCode" type="text" /></td>
</tr>
<tr class="visibleIf" data-visibleif-rule=" country == 'United States'">
<th>Zip Code: </th>
<td>
<input name="zipCode" type="text" /></td>
</tr>
</tbody>
</table>
</form>
<p>In HTML5, there is no way for a developer to tell the browser <em>&#8220;only show me this block of HTML if </em><code>country == 'Canada'</code><em>&#8220;</em>.  This is not a criticism of HTML5 or its authors &mdash; HTML5 forms has a lot of awesomeness in it (some of which I will blog about in my next article) and we can&#8217;t expect it to do everything. However, I have been using custom JavaScript to do this kind of stuff all the time, and wouldn&#8217;t it be great if the JavaScript challenged could do so?  In the ideal world graphic designers, J2EE programmers with minimal front-end experience, and even my 75-year-old mom should be able to do this.</p>
<p>As a result, I present a JavaScript library, <code>visibleIf</code>, which allows web developers to use <a href="http://ejohn.org/blog/html-5-data-attributes/">HTML5 custom data attributes</a> to define when blocks of HTML should be visible or invisible.  <strong>Even if you are not a JavaScript genius, you will be able to make cool looking dynamic forms with very simple markup.</strong>  For example, let&#8217;s take a look at the HTML of the example above:</p>
<blockquote class="code">
<pre>&lt;form&gt;
    &lt;table class="formTable"&gt;
        &lt;tr&gt;
            &lt;th&gt;Country of Origin&lt;/th&gt;

            &lt;td&gt;&lt;select name="country"&gt;
                &lt;option value=""&gt;
                    Select One...
                &lt;/option&gt;

                &lt;option value="Canada"&gt;
                    Canada
                &lt;/option&gt;

                &lt;option value="United States"&gt;
                    United States
                &lt;/option&gt;
            &lt;/select&gt; &lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr <span class="hilite">class="visibleIf" data-visibleif-rule="country == 'Canada'"</span>&gt;
            &lt;th&gt;Postal Code&lt;/th&gt;

            &lt;td&gt;&lt;input type="text" name="postalCode"
            value="" /&gt; &lt;/td&gt;
        &lt;/tr&gt;

        &lt;tr <span class="hilite">class="visibleIf" data-visibleif-rule="country == 'United States'"</span>&gt;
            &lt;th&gt;Zip Code&lt;/th&gt;

            &lt;td&gt;&lt;input type="text" name="zipCode"
            value="" /&gt; &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/form&gt;
</pre>
</blockquote>
<p>This example is rather simple: the Postal Code form field is shown when <code>country == 'Canada'</code> and Zip Code is shown when <code>country == 'United States'</code>.  Note that in order to hide and show a block of HTML, you must set two attributes inside the containing tag:</p>
<ul>
<li><strong><code>class="visibleIf"</code>:</strong> which lets the visibleIf.js script know that this block of HTML is to be hidden or shown according to the <code>data-visibleif-rule</code></li>
<li><strong><code>data-visibleif-rule='<em>rule expression'</em></code>:</strong> which contains the visibility rule.  The rule variables are form element names, like <code>country</code> is in the above example. You can do simple equality rules like this, or complex ones like:<br />
<blockquote class="code"><pre>
&lt;div class="visibleIf"
   data-visibleif-rule="country == 'Canada' &#038;&#038; (city == 'Toronto' || city == 'Vancouver')"&gt;
  ...
&lt;/div&gt;
</pre>
</blockquote>
<p>If you know a little bit of JavaScript, you will note that you can use JavaScript functions to do interesting rules like:</p>
<blockquote class="code"><pre>
&lt;div class="visibleIf" data-visibleif-rule="parseInt(total) &gt; 100"&gt;
  ...
&lt;/div&gt;
</pre>
</blockquote>
</li>
</ul>
<p>Note that the above examples have visibleIf rules inside a <code>tr</code> tag, <strong>they can be used in any tag inside an HTML form</strong>. </p>
<p>Although the above example is quite simple, you can use visibleIf to make really complex forms &mdash; you can even put visibleIf blocks inside of visibleIf blocks.  To illustrate this I have created <a href="/tests/visibleIf/example1.html">a more interesting form</a> that shows what can be done using visibleIf.</p>
<p><a href="/tests/visibleIf/example1.html" class="exampleLink">See a more complex visibleIf form example</a></p>
<h2>Hidden Fields &#8211; To Clear Or Not To Clear</h2>
<p>If the user does something that hides some form fields (e.g. clicks on a checkbox) and then reverses that action (in this case clicking on the same checkbox), the fields will reappear with any previously filled-in data erased. Developers can override this default behavior by setting the class of the fields that shouldn&#8217;t be erased to <code>visibleIf-doNotReset</code>.  To illustrate this, I have created a page with two identical forms on it &mdash; one that erases the values inside hidden fields, and one that doesn&#8217;t.  Play with the example and you&#8217;ll see what I mean.</p>
<p><a class="exampleLink" href="/tests/visibleIf/example2-dotNotReset.html">See an example of a form with and without <code>visibleIf-doNotReset</code> fields.</a></p>
<h2>Hidden Fields &#8211; Submit To The Server, Or Not?</h2>
<p>Also note that by default, only the visible form elements are submitted to the server (this is because when a form element is hidden by <code>visibleIf</code>, its <code>disabled</code> attribute is set to <code>true</code> when the form is submitted).  If developers wants to override this behavior, they can simply set the form&#8217;s <code>class</code> to <code>visibleIf-submitInvisibleData</code>.</p>
<p><a  class="exampleLink"  href="/tests/visibleIf/example2-submitInvisibleData.html">See an example of a form with and without <code>visibleIf-submitInvisibleData</code> class set.</a></p>
<h2>The Quick &#8220;How-To&#8221; Guide&#8221;</h2>
<p>Setting up your existing forms to use visibleIf is a quick, three-step process:</p>
<ol>
<li>Download the source from the visibleIf Project Page</li>
<li>Include the visibleIf.css stylesheet, EventHelpers.js and visibleIf.js JavaScript files into your web page:<br />
<blockquote class="code">
<pre>&lt;link rel="stylesheet" href="/path/to/visibleIf.css" type="text/css" /&gt;

&lt;script type="text/javascript" src="/path/to/EventHelpers.js"&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="/path/to/visibleIf.js"&gt;
&lt;/script&gt;
</pre>
</blockquote>
</li>
<li>Use the visibleIf rules as seen in the example above.  Note that <code>&amp;&amp;</code>, <code>||</code> and other logical operators are allowed in the expressions, as are JavaScript functions (e.g. parseInt, parseFloat, etc).</li>
</ol>
<h2>A Note On The Use Of Custom Data Attributes</h2>
<p>Why did I bother with custom data attributes when making <code>visibleIf</code>?  Why did I just use the attribute <code>data-visibleif-rule</code> instead of just <code>visibleif-rule</code> or just <code>rule</code> to place the visibility rule? Wouldn&#8217;t that be simpler?</p>
<ul>
<li><strong><code>data-</code> attributes are HTML compliant: </strong>.  Their use ensure that <code>visibleIf</code> will be compatible with future versions of HTML since <strong><code>data-</code> attributes are reserved to be used for JavaScript libraries</strong>.  As long as you use the <a href="http://dev.w3.org/html5/spec/syntax.html#the-doctype">HTML5 DOCTYPE</a>, your forms should also validate.</li>
<li><strong>The <code>data-visibleif-</code> prefix will not collide with attributes used in other JavaScript libraries. </strong> There is a high chance that <code>data-rule</code> could be used by another library.  Using the name of the library in the attribute significantly reduces that possibility.
</ul>
<h2>Download</h2>
<p><a href="/downloads/visibleIf-2.1.zip" class="exampleLink"><code>visibleIf.js</code> v. 2.1 and example code (zip format)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2010/06/20/visibleif-html5-custom-data-attributes-with-javascript-make-dynamic-interactive-forms/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CSS3 Please &#8211; Another Great Cross Browser CSS3 Solution.</title>
		<link>http://www.useragentman.com/blog/2010/04/06/css3-please-another-great-cross-browser-css3-solution/</link>
		<comments>http://www.useragentman.com/blog/2010/04/06/css3-please-another-great-cross-browser-css3-solution/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 14:47:40 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[ie filters]]></category>
		<category><![CDATA[rotation]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=1033</guid>
		<description><![CDATA[Although I have been doing a lot of work on cssSandpaper  lately (JavaScript API for cross browser CSS3 animation anyone?), I have also spent a little time on an equally worthwhile project CSS3 Please.  While cssSandpaper tries to give developers an all-in-one interface in which to do transforms, gradients and other nifty effects via simple CSS and JavaScript, CSS3 Please gives developers the opportunity to fill in the blanks of a stylesheet and see how CSS3 properties can be coded without the aid of JavaScript so that they work across the browsers that support it.]]></description>
			<content:encoded><![CDATA[<div id="attachment_1035" class="wp-caption alignleft" style="width: 267px"><a href="http://www.useragentman.com/blog/wp-content/uploads/2010/04/css3please.png"><img class="size-full wp-image-1035" title="css3please" src="http://www.useragentman.com/blog/wp-content/uploads/2010/04/css3please.png" alt="" width="257" height="272" /></a><p class="wp-caption-text">Screenshot of the CSS3 Please editor.</p></div>
<p>Although I have been doing a lot of work on <a href="../csssandpaper-a-css3-javascript-library/">cssSandpaper</a> lately (<a href="../2010/04/05/cross-browser-animated-css-transforms-even-in-ie/">JavaScript  API for cross browser CSS3 animation</a> anyone?), I have also spent a  little time on an equally worthwhile project <a href="http://www.css3please.com/">CSS3  Please</a>. While cssSandpaper tries to give developers an all-in-one interface in which to do transforms, gradients and other nifty effects via simple CSS and JavaScript, CSS3 Please gives developers the opportunity to fill in the blanks of a stylesheet and see how CSS3 properties can be coded without the aid of JavaScript so that they work across the browsers that support it (look at the gradient section to see how different the implementations can be).  It also shows how developers can use Microsoft&#8217;s proprietary filter technology to emulate many of the current CSS3 properties (even if the newer CSS3 properties is folded into IE9 along with HTML5, it may be a bit of time before we see it achieve critical mass).  Take a look at the rotate section (the part I worked on), and you&#8217;ll see how very different the filter syntax is from the standard CSS3 declarations.</p>
<p>What tool you want to use depends on what your needs are.  Choice is good, and I thank <a href="http://paulirish.com/">Paul</a> and <a href="http://twitter.com/jon_neal">Jonathan</a> for letting me be part of it.</p>
<p><a class="exampleLink" href="http://www.css3please.com">Check out the official CSS3 Please website.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2010/04/06/css3-please-another-great-cross-browser-css3-solution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cross-Browser Animated CSS Transforms &#8212; Even in IE.</title>
		<link>http://www.useragentman.com/blog/2010/04/05/cross-browser-animated-css-transforms-even-in-ie/</link>
		<comments>http://www.useragentman.com/blog/2010/04/05/cross-browser-animated-css-transforms-even-in-ie/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 03:14:09 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[setTimeout]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=923</guid>
		<description><![CDATA[This is a follow-up article to my original CSS3 Transform article where I extend cssSandpaper to support scripting.  Now you can animate Css3 Transforms (as well as gradients, opacities and box-shadows) in all browsers, including IE, without a lot of issues.  Includes lots of neat examples.]]></description>
			<content:encoded><![CDATA[<div id="attachment_996" class="wp-caption alignright" style="width: 267px"><a href="/tests/cssSandpaper/clock.html"><img class="size-full wp-image-996 " title="Clock Example" src="http://www.useragentman.com/blog/wp-content/uploads/2010/04/clock.png" alt="" width="257" height="252" /></a><p class="wp-caption-text">Cross-Browser Animated CSS Clock Example based on an original WebKit example by Toby Pitman. Click image above to view.</p></div>
<p>In <a href="../2010/03/09/cross-browser-css-transforms-even-in-ie/">my  first article about CSS3</a>, I introduced a new script, <a href="http://www.useragentman.com/blog/csssandpaper-a-css3-javascript-library">cssSandpaper</a>, which allows developers to sidestep the myriad of vendor specific properties and just use one property to implement properties like <code>transform </code>for all browsers, including IE.</p>
<p>After posting the article, I saw many examples of CSS3 Transform using animations.  Toby Pitman&#8217;s <a href="http://css-tricks.com/css3-clock/">Old School Clock</a> is an excellent example of how one can use a Webkit&#8217;s <code>-webkit-transform</code> to make a small but excellent demo.  I wanted to prove that it would be easy to take this example and make it work in all modern browsers, so I did.  It took 15 minutes (okay, I had to change cssSandpaper to offer scripting support, but that didn&#8217;t take too long either).  I then coded a few more examples to show that some really neat things can be done using a small bit of JavaScript.   Here are links to these examples:</p>
<ul>
<li><a href="http://www.useragentman.com/tests/cssSandpaper/clock.html">The Cross-Browser CSS Clock</a> based on code by Toby Pitman</li>
<li><a href="http://www.useragentman.com/tests/cssSandpaper/countdown.html">A remixed movie leader countdown</a> (actually, it uses the <a href="http://en.wikipedia.org/wiki/File:RCA_Indian_Head_test_pattern.JPG">RCA Indian Head Test Pattern</a>, but whatever &#8230;)</li>
<li><a href="http://www.useragentman.com/tests/cssSandpaper/gradient.html">A psychedelic animated gradient</a></li>
</ul>
<h2>How To Do CSS3 Animated Effects?</h2>
<p><strong>If this was the perfect world</strong>, all a developer would need to do is use a DOM element&#8217;s <code>style</code> property and manipulate the appropriate camel-case CSS property.  For example, if a developer wanted to script the rotation of a node, he or she would code the following:</p>
<blockquote class="code">
<pre>    node.style.transform = "rotate(25deg)";</pre>
</blockquote>
<p>However, this is not the perfect world — after all, I am not making millions writing this blog and <strong>the current flavours of IE in use today don&#8217;t support many of the CSS3 properties</strong>.  However, using cssSandpaper, one could use the following method to do the same thing:</p>
<blockquote class="code">
<pre>    cssSandpaper.setTransform(node, "rotate(25deg)");</pre>
</blockquote>
<p>Developers can use cssSandpaper to manipulate <code>opacity</code>, <code>box-shadow</code>,  and <code>background</code> gradients, using <code>cssSandpaper.setOpacity()</code>, <code>cssSandpaper.setBoxShadow()</code> and <code>cssSandpaper.setGradient()</code> respectively.  All these functions take two parameters: a DOM node, and the appropriate CSS property values as described in the <a href="http://www.useragentman.com/downloads/cssSandpaper.1.0-beta2.zip">cssSandpaper documentation</a>.  For example:</p>
<blockquote class="code">
<pre>    cssSandpaper.setTransform(node, "rotate(25deg) scale(2, 2) skew(20deg, 20deg)");
    cssSandpaper.setOpacity(node, 0.3);
    cssSandpaper.setBoxShadow(node, "10px 10px 5px #ffcccc");
    cssSandpaper.setGradient(node, "-sand-gradient(linear, center top, center bottom, from(#0000ff), to(#ff0000));")</pre>
</blockquote>
<p>For more information, please read <a href="/blog/csssandpaper-a-css3-javascript-library">the official documentation of cssSandpaper</a>.</p>
<h2>Caveats</h2>
<ul>
<li>When animating using <code>transform</code>&#8216;s <code>scale()</code> function, make sure you avoid scaling objects too much larger than their original size.  This is due to the fact that IE scales objects as if they were images, and scaling-up an object will make the result quite pixelated.</li>
<li>The <code>-sand-gradient()</code> function does not use Firefox&#8217;s native <code>-moz-gradient</code> function to produce CSS3 gradients, but a solution using Canvas which works in all Canvas enabled versions of Firefox.  I will update cssSandpaper to use <code>-moz-gradient</code> in a future release (if anyone wants to help me get this working, please contact me via the email address at the top of this page, or by leaving a comment below).</li>
</ul>
<p><a class="exampleLink" href="http://www.useragentman.com/blog/csssandpaper-a-css3-javascript-library/">Go to the cssSandpaper documentation to download the latest version.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2010/04/05/cross-browser-animated-css-transforms-even-in-ie/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>My Favourite Third Party JavaScript Libraries</title>
		<link>http://www.useragentman.com/blog/2009/12/22/my-favourite-third-party-javascript-libraries/</link>
		<comments>http://www.useragentman.com/blog/2009/12/22/my-favourite-third-party-javascript-libraries/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 22:15:23 +0000</pubDate>
		<dc:creator>zoltan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.useragentman.com/blog/?p=433</guid>
		<description><![CDATA[Blogging has been a powerful tool for me to publicize code that I have written.  Not only can I announce code that I want to release, I am always complimented by the fact that others like to share what they read here as well. Over the years, however, I have found bits of code others [...]]]></description>
			<content:encoded><![CDATA[<div>
<div id="attachment_453" class="wp-caption alignleft" style="width: 260px"><img class="size-full wp-image-453" title="JavaScript" src="http://www.useragentman.com/blog/wp-content/uploads/2009/12/JavaScript.png" alt="&lt;span&gt;Source: remix of images created by &lt;a href=" width="250" height="188" /><p class="wp-caption-text">Source: remix of images created by Everaldo Coelho and Wikimedia Commons user S.Möller.</p></div>
<p>Blogging has been a powerful tool for me to publicize code that I have written.  Not only can I announce code that I want to release, I am always complimented by the fact that <strong>others like to share what they read here as well. </strong>Over the years, however, I have found bits of code others have written that have found irreplaceable in my web developer toolkit.  Some of them are popular, but others are either obscure or not talked about at all.  In order to give back to those who have unknowingly helped me do my job in the last decade, I am publishing the first in what hope is a series of articles about 3rd party JavaScript libraries.  If anyone else would like to add to this list, please feel free to do so in the comment area below &#8211; I&#8217;d love to hear what others find as useful as what I have listed here.</p>
<h2>Object Oriented Timeouts</h2>
<p>I start off with a script that has been around for a while but to my knowledge is hardly ever talked about.   It concerns <a title="&quot;Tutorial: JavaScript Timers with setTimeout and setInterval&quot; from elated.com" href="http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/">Timeouts</a> &#8211; which are quite important in this             day-and-age of the  			&#8220;nifty-Web-2.0-animated-fade-in-and-out-effect&#8221;. When I             starting coding JavaScript back in the mid-1990&#8242;s, <code>setTimeout()</code> and             <code>setInterval()</code> did what I needed them to do &#8211; pause the application logic for a specified amount of time. However, when I starting to use the object-oriented features of JavaScript,  			I found a few problems:</p>
<ul>
<li><code>setTimeout()</code>and <code>setInterval()</code> both lose track of scope                 when calling a method of an object</li>
<li><code>setTimeout()</code>and <code>setInterval()</code> can only pass strings                 and numbers to methods, <strong>not</strong> an                 arbitrary object.</li>
<li>the function call passed to <code>setTimeout()</code>and <code>setInterval()</code>is passed as a string.   Parameters of the function call must be inserted by using ugly string concatenation:</li>
</ul>
<blockquote class="code">
<pre>setTimeout('fadeInLayer(' + (n+50).toString() +')');</pre>
</blockquote>
<p>However, <strong>back in 2003</strong>, a user named             “algorithm” on <a href="http://www.codingforums.com/">Coding Forums</a> came up             with a great solution for <a href="http://www.codingforums.com/archive/index.php/t-10531.html"> Object Oriented Timeouts</a>. Timeouts can now be done             with objects and with a more elegant syntax:</p>
<blockquote class="code">
<pre>function AjaxDialogue() {
   var me = this;

   // declaration of Timer object.
   me.timer = new Timer(me);

   // a timeout function using the Timer object:
   me.fadeInLayer = function (n, layerOpened, onFadeInEvent){

      ....

      /*
       * This call will set the opacity level of the node layeredOpened to n
       * percent
       */
      CSSHelpers.setOpacity(layerOpened, n);

      if (n &lt; 100) {

         /*
          * setting a timeout of 10 milliseconds on the *public* method fadeInLayer() with the
          * parameters n+50, layerOpened, and onFadeInEvent.  Note only the first parameter
          * is not an object.
          */
         me.timer.setTimeout('fadeInLayer', 10, n+50, layerOpened, onFadeInEvent);

      }
   }
}</pre>
</blockquote>
<p>The question is: <strong>who <em>is</em> this &#8220;algorithm&#8221; person?</strong> This is brilliant code and should be credited             correctly.  It should also have a better home than just a forum  			posting.</p>
<h2>Calendar Widget</h2>
<p><a href="http://en.wikipedia.org/wiki/HTML5">HTML5</a> will have date input tags (i.e. <code>&lt;input type="date"             /&gt;</code>), complete will pop-up calendars, but until it is implemented by all browser vendors,             what is a developer to do when they want users to input             dates in a user friendly way? The best calendar widget I have found is <a href="http://www.dynarch.com/projects/calendar/old/">dynarch.com&#8217;s             Ex-“Coolest” DHTML Calendar</a>. Although             they have a <a href="http://localhost/bin/myTemplate.cgi/%3Cbr%20/%3E%20http://www.dynarch.com/projects/calendar/"> cooler version</a>, I like the former one more because             it was released under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU Lesser             Public License</a>, so it is free as in beer as well as             in freedom.</p>
<h2>Querystring Parsing and Ajax Form Data             Submission</h2>
<p>I always found it odd that there is no built-in method in             JavaScriptto <strong>grab </strong> <strong>form data from the query string from a web page&#8217;s URL.</strong> <a href="http://adamv.com/dev/javascript/querystring">Adam             Vandenberg&#8217;s Querystring Object</a> filled in this gap with a simple 			script that gets this job done.  Suppose your web page had the following 			URL:</p>
<blockquote class="shell">
<pre>http://me.com/mypage.html?page=3&amp;itemsPerPage=10&amp;query=Biker+Babes</pre>
</blockquote>
<p>To tell JavaScript to retrieve the value inside the CGI variable 			<code>query</code>, use the following code:</p>
<blockquote class="code">
<pre>var qs = new Querystring();
var message = qs.get('query');</pre>
</blockquote>
<p>But how about if you have <strong>data in a  			form and you want to  			submit it using Ajax</strong> instead of the traditional  			post-to-the-server-and-retrieve-from-the-server way?  Matthew Eernisse&#8217;s             <a href="http://localhost/bin/myTemplate.cgi/thirdParty.html?templateRoot=useragentman">formData2QueryString()</a> will construct a query string 			from a form so you can use with the XMLHttpRequest Object.</p>
<blockquote class="code">
<pre>var queryString = formData2QueryString(form);

req=new new XMLHttpRequest();

req.onreadystatechange(myFunc);

req.open("GET", "/path/to/ajaxCall?" + queryString, true);</pre>
</blockquote>
<h2>Logging</h2>
<p>In any language, logging and debugging are necessary when it comes to  			discovering what is wrong with your code.  While debuggers like  			<a href="http://localhost/bin/myTemplate.cgi/thirdParty.html?templateRoot=useragentman#">Firebug</a> are great for stepping into code line by 			line and understanding why an algorithm isn&#8217;t working right, it is  			sometimes more desirable to dump variables into a log, especially when trying to debug <a href="http://www.the-art-of-web.com/javascript/ajax-race-condition/">race conditions</a>.  Logging is also useful when you are too lazy to open a debugger but you don&#8217;t want your code bogged down by <code>window.alert()</code>&#8216;s</p>
<p>My favourite 			JavaScript logger is <a href="http://earthcode.com/blog/2005/12/jslog.html">Andre             Lewis&#8217; JSLog</a> . It doesn&#8217;t rely on a specific             JavaScript framework, and it also stays out of the way until I need it  			— it starts off as a             small yellow box in the top left corner of the             application&#8217;s page, and only shows up when I click on it.</p>
<h2>Ajax History and Bookmarking</h2>
<p>After Google Maps came on the scene, a few usability experts pointed out the drawbacks of a lot of &#8220;Ajax&#8221; Applications:</p>
<ul>
<li><strong>Ajax breaks bookmarking: </strong>when users click on a link that results in an Ajax call that changes the content on the screen, users may wish to bookmark the results, and will be disappointed to realize that they didn&#8217;t really bookmark the result of the Ajax call.</li>
<li><strong>Ajax breaks browser history: </strong>when users click on a link that results in an Ajax call that changes the content on the screen, they may intuitively click the back button in order return to the page&#8217;s state, ande will be frustrated when this doesn&#8217;t happen.</li>
</ul>
<p><a href="http://code.google.com/p/reallysimplehistory/">Really             Simple History (RSH): Ajax history and bookmarking             library</a>, developed by <a href="http://codinginparadise.org/">Brad Neuberg</a> and <a href="http://www.briandillard.com/">Brian             Dillard</a>, fixes these issues by storing data inside an JavaScript &#8220;cache&#8221; so that application state can be bookmarked and so that the back button can be used to return your application to an earlier state.  I have used this library on a number of Ajax heavy applications and it works extremely well.</p>
<h2>Fixing IE</h2>
<p>Although <a href="http://dean.edwards.name/IE7/">Dean             Edwards&#8217; /ie7/</a> is not perfect, it does fix a lot of CSS issues with elderly versions of IE.  I use it as one of many utilities in my toolbox when working with Internet Explorer.  It is an awesome piece of work and since Edwards is well known in the JavaScript community, the only thing I can really add that hasn&#8217;t been said before is &#8220;<a href="http://vids.myspace.com/index.cfm?fuseaction=vids.individual&amp;videoid=1276185">Rispek</a>&#8220;.</p>
<h2>sprintf()</h2>
<p>I started off as a C programmer, and when I first started coding in JavaScript, I was happy with it&#8217;s &#8220;C-like&#8221; syntax.  The thing I missed most from the C-world was (and is) JavaScript&#8217;s lack of a <a href="http://en.wikipedia.org/wiki/Printf"><code>sprintf()</code> function</a>, which makes the task of formatting strings quite easy.  <code>sprintf()</code> is more powerful and             produces more human-legable code than using the <code>+</code> JavaScript&#8217;s operator.</p>
<p><a href="http://www.klproductions.com/">K&amp;L             Productions</a> has produced a very good version <a href="http://omino.com/sw/ominoAdobeScriptsSuite/shared/sprintf.jsx"> JavaScript implementation of sprintf</a> that I use             regularly. There are others, but this one is the most complete version 			I have found and works well enough that I haven&#8217;t found a reason to  			change it. Perhaps it would be worthy  			of a future blog post to compare implementations to see which             performs the best.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.useragentman.com/blog/2009/12/22/my-favourite-third-party-javascript-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
