<?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>David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞. &#187; Usability / Accessibility</title> <atom:link href="http://davidwalsh.name/tutorials/usability-accessibility/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 02 Sep 2010 03:13:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>Smooth Scrolling with MooTools&#160;Fx.SmoothScroll</title><link>http://davidwalsh.name/mootools-fx-smoothscroll</link> <comments>http://davidwalsh.name/mootools-fx-smoothscroll#comments</comments> <pubDate>Mon, 05 Apr 2010 12:36:33 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[MooTools]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4942</guid> <description><![CDATA[I get quite a few support requests for my previous MooTools SmoothScroll article and the issue usually boils down to the fact that SmoothScroll has become Fx.SmoothScroll. Here&#8217;s a simple usage of Fx.SmoothScroll. View Demo The&#160;HTML &#60;a href=&#34;#contact&#34;&#62;Contact Us&#60;/a&#62; &#60;!-- goes down to the contact area --&#62; &#60;!-- more stuff here --&#62; &#60;a name=&#34;contact&#34; id=&#34;contact&#34;&#62;&#60;/a&#62; [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-fx-smoothscroll">Smooth Scrolling with MooTools&nbsp;Fx.SmoothScroll</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/smooth-scroll-mootools' rel='bookmark' title='Permanent Link: SmoothScroll Using MooTools&nbsp;1.2'>SmoothScroll Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/mootools-onload-smoothscroll' rel='bookmark' title='Permanent Link: MooTools onLoad&nbsp;SmoothScrolling'>MooTools onLoad&nbsp;SmoothScrolling</a></li><li><a
href='http://davidwalsh.name/smooth-scroll' rel='bookmark' title='Permanent Link: Fluid Anchors &#8211; Smooth Anchors Using&nbsp;MooTools'>Fluid Anchors &#8211; Smooth Anchors Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/scrollspy-terms' rel='bookmark' title='Permanent Link: Scrolling &#8220;Agree to Terms&#8221; Component with MooTools&nbsp;ScrollSpy'>Scrolling &#8220;Agree to Terms&#8221; Component with MooTools&nbsp;ScrollSpy</a></li><li><a
href='http://davidwalsh.name/mootools-watermark' rel='bookmark' title='Permanent Link: &#8220;Top&#8221; Watermark Using&nbsp;MooTools'>&#8220;Top&#8221; Watermark Using&nbsp;MooTools</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I get quite a few support requests for my previous MooTools SmoothScroll article and the issue usually boils down to the fact that SmoothScroll has become <a
href="http://mootools.net/docs/more/Fx/Fx.SmoothScroll" rel="nofollow">Fx.SmoothScroll</a>.  Here&#8217;s a simple usage of Fx.SmoothScroll.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/fx-smoothscroll.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;HTML</h2><pre class="html">
&lt;a href=&quot;#contact&quot;&gt;Contact Us&lt;/a&gt; &lt;!-- goes down to the contact area --&gt;

&lt;!-- more stuff here --&gt;

&lt;a name=&quot;contact&quot; id=&quot;contact&quot;&gt;&lt;/a&gt;
&lt;h2&gt;Contact Us&lt;/h2&gt;

&lt;-- more stuff here --&gt;
</pre><p>The only HTML requirement for Fx.SmoothScroll is that all named anchors be given an identical id attribute.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
new Fx.SmoothScroll({
	duration: 200
},window);
</pre><p>Fx.SmoothScroll accepts two arguments:  the area to scroll (defaults to the window) and options for the class.  The default options are usually sufficient.  One recommendation I do have is to make the duration quick &#8212; no one wants to wait for the animation to finish.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/fx-smoothscroll.php" class="demo">View Demo</a><div
class="clear"></div></div><p>Happy scrolling!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-fx-smoothscroll">Smooth Scrolling with MooTools&nbsp;Fx.SmoothScroll</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/smooth-scroll-mootools' rel='bookmark' title='Permanent Link: SmoothScroll Using MooTools&nbsp;1.2'>SmoothScroll Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/mootools-onload-smoothscroll' rel='bookmark' title='Permanent Link: MooTools onLoad&nbsp;SmoothScrolling'>MooTools onLoad&nbsp;SmoothScrolling</a></li><li><a
href='http://davidwalsh.name/smooth-scroll' rel='bookmark' title='Permanent Link: Fluid Anchors &#8211; Smooth Anchors Using&nbsp;MooTools'>Fluid Anchors &#8211; Smooth Anchors Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/scrollspy-terms' rel='bookmark' title='Permanent Link: Scrolling &#8220;Agree to Terms&#8221; Component with MooTools&nbsp;ScrollSpy'>Scrolling &#8220;Agree to Terms&#8221; Component with MooTools&nbsp;ScrollSpy</a></li><li><a
href='http://davidwalsh.name/mootools-watermark' rel='bookmark' title='Permanent Link: &#8220;Top&#8221; Watermark Using&nbsp;MooTools'>&#8220;Top&#8221; Watermark Using&nbsp;MooTools</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-fx-smoothscroll/feed</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>Checkbox Filtering Using MooTools&#160;ElementFilter</title><link>http://davidwalsh.name/checkbox-filter</link> <comments>http://davidwalsh.name/checkbox-filter#comments</comments> <pubDate>Thu, 04 Feb 2010 14:18:29 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4781</guid> <description><![CDATA[When I first wrote MooTools ElementFilter, I didn&#8217;t think much of it. Fast forward eight months later and I&#8217;ve realized I&#8217;ve used the plugin a billion times. Hell, even one of the &#8220;big 3&#8243; search engines is using it for their maps application. There&#8217;s one more place I&#8217;d like to use it. My employer uses [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/checkbox-filter">Checkbox Filtering Using MooTools&nbsp;ElementFilter</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/plugin-element-filter' rel='bookmark' title='Permanent Link: New MooTools Plugin:&nbsp;ElementFilter'>New MooTools Plugin:&nbsp;ElementFilter</a></li><li><a
href='http://davidwalsh.name/mootools-checkboxes-plugin' rel='bookmark' title='Permanent Link: MooTools dwCheckboxes&nbsp;Plugin'>MooTools dwCheckboxes&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/checkbox-form-input-arrays' rel='bookmark' title='Permanent Link: Using Form Input Arrays For&nbsp;Checkboxes'>Using Form Input Arrays For&nbsp;Checkboxes</a></li><li><a
href='http://davidwalsh.name/check-all-none-checkboxes-using-mootools' rel='bookmark' title='Permanent Link: Check All/None Checkboxes Using&nbsp;MooTools'>Check All/None Checkboxes Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/checked-pseudo-selector-mootools' rel='bookmark' title='Permanent Link: Create a Custom &#8220;:checked&#8221; Pseudo Selector for MooTools&nbsp;1.2'>Create a Custom &#8220;:checked&#8221; Pseudo Selector for MooTools&nbsp;1.2</a></li></ol>]]></description> <content:encoded><![CDATA[<p>When I first wrote <a
href="http://davidwalsh.name/plugin-element-filter">MooTools ElementFilter</a>, I didn&#8217;t think much of it.  Fast forward eight months later and I&#8217;ve realized I&#8217;ve used the plugin a billion times.  Hell, even one of the &#8220;big 3&#8243; search engines is using it for their maps application.  There&#8217;s one more place I&#8217;d like to use it.  My employer uses a basic SPAM filtering system which allows me to see emails that were incorrectly (or correctly) caught in SPAM, click a checkbox, and click a &#8220;Deliver&#8221; button.  The problem is that it will catch a bunch of valid emails with very similar subject lines, so I have to hunt down all of the emails, check the email&#8217;s checkbox, and keep searching.  Inefficient to say the least.  That&#8217;s why I&#8217;ve used ElementFilter to find LABEL elements with the given search text and automatically check their checkboxes.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/filter-checkboxes.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The Sample&nbsp;HTML</h2><pre class="html">
&lt;ul id=&quot;my-list&quot;&gt;
&lt;li&gt;&lt;input type=&quot;checkbox&quot; id=&quot;chkADDRESS&quot; /&gt; &lt;label for=&quot;chkADDRESS&quot;&gt;ADDRESS&lt;/label&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;checkbox&quot; id=&quot;chkAPPLET&quot; /&gt; &lt;label for=&quot;chkAPPLET&quot;&gt;APPLET&lt;/label&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;checkbox&quot; id=&quot;chkAREA&quot; /&gt; &lt;label for=&quot;chkAREA&quot;&gt;AREA&lt;/label&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;checkbox&quot; id=&quot;chkA&quot; /&gt; &lt;label for=&quot;chkA&quot;&gt;A&lt;/label&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;checkbox&quot; id=&quot;chkBASE&quot; /&gt; &lt;label for=&quot;chkBASE&quot;&gt;BASE&lt;/label&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;checkbox&quot; id=&quot;chkBASEFONT&quot; /&gt; &lt;label for=&quot;chkBASEFONT&quot;&gt;BASEFONT&lt;/label&gt;&lt;/li&gt;
&lt;li&gt;&lt;input type=&quot;checkbox&quot; id=&quot;chkBIG&quot; /&gt; &lt;label for=&quot;chkBIG&quot;&gt;BIG&lt;/label&gt;&lt;/li&gt;
&lt;!-- ... more ... --&gt;
&lt;/ul&gt;
</pre><p>I&#8217;ve used a simple list of HTML elements for my example.  Having 100 &#8220;VIAGRA!!!&#8221; labels really wouldn&#8217;t be helpful.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
/* usage */
window.addEvent('domready',function() {
	var myFilter = new ElementFilter('search-term', '#my-list label', {
		trigger: 'keyup',
		cache: true,
		onShow: function(element) {
			$(element.get('for')).checked = true;
		},
		onHide: function(element) {
			$(element.get('for')).checked = false;
		}
	});
});
</pre><p>If you aren&#8217;t familiar with ElementFilter, be sure to <a
href="http://davidwalsh.name/plugin-element-filter">read the original post</a>.  The only code specific to my purpose is in the onShow and onHide methods.  Awesome!</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/filter-checkboxes.php" class="demo">View Demo</a><div
class="clear"></div></div><p>Give it a shot.  I&#8217;ll be bribing my IT team to put something like this in place.  It will make managing SPAM much easier!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/checkbox-filter">Checkbox Filtering Using MooTools&nbsp;ElementFilter</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/plugin-element-filter' rel='bookmark' title='Permanent Link: New MooTools Plugin:&nbsp;ElementFilter'>New MooTools Plugin:&nbsp;ElementFilter</a></li><li><a
href='http://davidwalsh.name/mootools-checkboxes-plugin' rel='bookmark' title='Permanent Link: MooTools dwCheckboxes&nbsp;Plugin'>MooTools dwCheckboxes&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/checkbox-form-input-arrays' rel='bookmark' title='Permanent Link: Using Form Input Arrays For&nbsp;Checkboxes'>Using Form Input Arrays For&nbsp;Checkboxes</a></li><li><a
href='http://davidwalsh.name/check-all-none-checkboxes-using-mootools' rel='bookmark' title='Permanent Link: Check All/None Checkboxes Using&nbsp;MooTools'>Check All/None Checkboxes Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/checked-pseudo-selector-mootools' rel='bookmark' title='Permanent Link: Create a Custom &#8220;:checked&#8221; Pseudo Selector for MooTools&nbsp;1.2'>Create a Custom &#8220;:checked&#8221; Pseudo Selector for MooTools&nbsp;1.2</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/checkbox-filter/feed</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>iPhone-Style Passwords Using MooTools&#160;PassShark</title><link>http://davidwalsh.name/iphone-password</link> <comments>http://davidwalsh.name/iphone-password#comments</comments> <pubDate>Wed, 09 Dec 2009 13:50:54 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[MooTools]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4331</guid> <description><![CDATA[Every once in a while I come across a plugin that blows me out of the water and the most recent culprit is PassShark: a MooTools plugin that duplicates the iPhone&#8217;s method of showing/hiding the last character in a password field. This gem of a MooTools plugin, which conquers some problems that plague jQuery counterparts, [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/iphone-password">iPhone-Style Passwords Using MooTools&nbsp;PassShark</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/iphone-thoughts' rel='bookmark' title='Permanent Link: iPhone'>iPhone</a></li><li><a
href='http://davidwalsh.name/iphone-click' rel='bookmark' title='Permanent Link: iPhone Click Effect Using MooTools or&nbsp;jQuery'>iPhone Click Effect Using MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/iphone-hath-cometh' rel='bookmark' title='Permanent Link: iPhone Hath&nbsp;Cometh'>iPhone Hath&nbsp;Cometh</a></li><li><a
href='http://davidwalsh.name/iphone-checkboxes-mootools' rel='bookmark' title='Permanent Link: iPhone Checkboxes Using&nbsp;MooTools'>iPhone Checkboxes Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/detect-iphone' rel='bookmark' title='Permanent Link: iPhone &#038; iPod Detection Using&nbsp;JavaScript'>iPhone &#038; iPod Detection Using&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<img
src="http://davidwalsh.name/dw-content/iphone-front.jpg" alt="iPhone" class="image" /><p>Every once in a while I come across a plugin that blows me out of the water and the most recent culprit is PassShark:  a MooTools plugin that duplicates the iPhone&#8217;s method of showing/hiding the last character in a password field.  This gem of a MooTools plugin, which conquers some problems that plague jQuery counterparts, was authored by valued MooTools contributors Luis Merino and Nathan Querido.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/iphone-password.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The MooTools PassShark&nbsp;Usage</h2><pre class="js">
window.addEvent('load',function() {
	new PassShark('pass',{
		interval: 300,
        	duration: 1500,
        	replacement: '%u25CF',
        	debug: false
    });
});
</pre><p>The only required parameter is the ID of the input/password element you&#8217;d like to act as an iPhone password field.  Options include:</p><ul><li>interval:  Amount of time between new character checks.</li><li>duration:  Amount of time to show a given character before obfuscating it.</li><li>replacement: The character to replace the character.</li></ul><p>Sometimes the less options the better!</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/iphone-password.php" class="demo">View Demo</a><div
class="clear"></div></div><p>PassShark is yet another perfect showcase of what MooTools allows you to accomplish.  Big ups to Luis Merino and Nathan Querido for releasing this gem.  To get more specific information about their great plugin, <a
href="http://www.queridodesign.net/blog/passshark">visit their blog post</a>.  MooTools FTW!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/iphone-password">iPhone-Style Passwords Using MooTools&nbsp;PassShark</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/iphone-thoughts' rel='bookmark' title='Permanent Link: iPhone'>iPhone</a></li><li><a
href='http://davidwalsh.name/iphone-click' rel='bookmark' title='Permanent Link: iPhone Click Effect Using MooTools or&nbsp;jQuery'>iPhone Click Effect Using MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/iphone-hath-cometh' rel='bookmark' title='Permanent Link: iPhone Hath&nbsp;Cometh'>iPhone Hath&nbsp;Cometh</a></li><li><a
href='http://davidwalsh.name/iphone-checkboxes-mootools' rel='bookmark' title='Permanent Link: iPhone Checkboxes Using&nbsp;MooTools'>iPhone Checkboxes Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/detect-iphone' rel='bookmark' title='Permanent Link: iPhone &#038; iPod Detection Using&nbsp;JavaScript'>iPhone &#038; iPod Detection Using&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/iphone-password/feed</wfw:commentRss> <slash:comments>16</slash:comments> </item> <item><title>New York Times-Style Text Selection Widget Using MooTools or&#160;jQuery</title><link>http://davidwalsh.name/text-select-widget</link> <comments>http://davidwalsh.name/text-select-widget#comments</comments> <pubDate>Wed, 04 Nov 2009 14:06:13 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4022</guid> <description><![CDATA[Aaron Newton made a great request to me last week: why not make my MooTools Documentation Bookmarklet function more like the New York Time&#8217;s text selection widget. NYT&#8217;s text selection widget listens for text selection and presents the user with a &#8220;search&#8221; icon they may click on to learn more about that term. I&#8217;ve tried [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/text-select-widget">New York Times-Style Text Selection Widget Using MooTools or&nbsp;jQuery</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/text-selection-ajax' rel='bookmark' title='Permanent Link: Record Text Selections Using MooTools or jQuery&nbsp;AJAX'>Record Text Selections Using MooTools or jQuery&nbsp;AJAX</a></li><li><a
href='http://davidwalsh.name/google-fade' rel='bookmark' title='Permanent Link: Google-Style Element Fading Using MooTools or&nbsp;jQuery'>Google-Style Element Fading Using MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/csstricks-css-text-selection-highlighting' rel='bookmark' title='Permanent Link: CSS-Tricks &#8212; CSS &#038; Text Selection &#038;&nbsp;Highlighting'>CSS-Tricks &#8212; CSS &#038; Text Selection &#038;&nbsp;Highlighting</a></li><li><a
href='http://davidwalsh.name/digg-share-widget' rel='bookmark' title='Permanent Link: Digg-Style Dynamic Share Widget Using&nbsp;MooTools'>Digg-Style Dynamic Share Widget Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/load-more-widget' rel='bookmark' title='Permanent Link: David Walsh on NetTuts:  Create a Twitter-Like “Load More”&nbsp;Widget'>David Walsh on NetTuts:  Create a Twitter-Like “Load More”&nbsp;Widget</a></li></ol>]]></description> <content:encoded><![CDATA[<p> <img
src="http://davidwalsh.name/dw-content/nytimeswidget.jpg" alt="NY Times Widget" /></p><p>Aaron Newton made a great request to me last week:  why not make my <a
href="http://davidwalsh.name/mootools-documentation">MooTools Documentation Bookmarklet</a> function more like the New York Time&#8217;s text selection widget.  NYT&#8217;s text selection widget listens for text selection and presents the user with a &#8220;search&#8221; icon they may click on to learn more about that term.  I&#8217;ve tried to answer that challenge &#8212; not in bookmarklet form but in website widget form.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/selection-search.php" class="demo">View MooTools Demo</a> <a
href="http://davidwalsh.name/dw-content/selection-search.php?library=jquery" class="demo">View jQuery Demo</a><div
class="clear"></div></div><h2>The Sample&nbsp;HTML</h2><pre class="html">
&lt;div id=&quot;content-area&quot;&gt;
	.htaccess AJAX Apache / Server APIs Blog Bookmarking / Social Books Browsers CSS / Design Google Guest Blogger Hosting / Domain JavaScript jQuery
	link() Microsoft MooTools MySQL Optimization PHP Poll rand() Security Shell Theory / Ideas Usability / Accessibility XML / XHTML
	This blog is targeted toward all levels of web designers and developers. All web topics are discussed, including CSS, JavaScript (MooTools and jQuery), PHP, and more.
&lt;/div&gt;
</pre><p>The above code is next to meaningless per the widget &#8212; I simply want to illustrate the area I&#8217;d like it to work in has an ID of <span
class="keyword">content-area</span>.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
window.addEvent('domready',function(){
	(function($) {
		//gets the selected text
		var getSelection = function() {
			return $try(
				function() { return window.getSelection(); },
				function() { return document.getSelection(); },
				function() { 
			        var selection = document.selection &amp;&amp; document.selection.createRange();
					if(selection.text) { return selection.text; }
					return false;
			      }
			) || false;
		};
		//vars 
		var url = 'http://davidwalsh.name/?s={term}', selectionImage;
		//event to listen
		$('content-area').addEvent('mouseup',function(e) {
			var selection = getSelection();
			if(selection &amp;&amp; (selection = new String(selection).replace(/^\s+|\s+$/g,''))) {
				//ajax here { http://davidwalsh.name/text-selection-ajax }
				if(!selectionImage) {
					selectionImage = new Element('a',{
						href: url,
						opacity:0,
						id: 'selection-image',
						title: 'Click here to learn more about this term',
						target: '_blank'
					}).inject(document.body,'top');
				}
				//handle the every-time event
				//alert(selection);
				selectionImage.set('href',url.replace('{term}',encodeURI(selection))).setStyles({
					top: e.page.y - 30,	//offsets
					left: e.page.x - 13 //offsets
				}).tween('opacity',0);
			}
		});
		
		$(document.body).addEvent('mousedown',function() {
			//hider
			if(selectionImage) { selectionImage.tween('opacity',1); }
		});
		
	})(document.id);
});
</pre><p>During the <span
class="function">mouseup</span> event within the selected container (<span
class="keyword">content-area</span>), we determine if any text has been highlighted.  If so, we:</p><ol><li>Insert the <span
class="param">A</span> element if it has not yet been injected into the body.</li><li>Change the <span
class="param">A</span> element&#8217;s URL to accommodate for the new search term.</li><li>Position the element to at an offset position above where the mouse goes up.</li></ol><p>During every <span
class="function">mousedown</span> event we hide the <span
class="param">A</span> element.</p><h2>The jQuery&nbsp;JavaScript</h2><pre class="js">
/* attempt to find a text selection */
function getSelected() {
	if(window.getSelection) { return window.getSelection(); }
	else if(document.getSelection) { return document.getSelection(); }
	else {
		var selection = document.selection &amp;&amp; document.selection.createRange();
		if(selection.text) { return selection.text; }
		return false;
	}
	return false;
}
/* create sniffer */
$(document).ready(function() {
	var url = 'http://davidwalsh.name/?s={term}', selectionImage;
	$('#content-area').mouseup(function(e) {
		var selection = getSelected();
		if(selection &amp;&amp; (selection = new String(selection).replace(/^\s+|\s+$/g,''))) {
			//ajax here { http://davidwalsh.name/text-selection-ajax }
			if(!selectionImage) {
				selectionImage = $('&lt;a&gt;').attr({
					href: url, 
					title: 'Click here to learn more about this term',
					target: '_blank',
					id: 'selection-image'
				}).hide();
				$(document.body).append(selectionImage);
			}
			selectionImage.attr('href',url.replace('{term}',encodeURI(selection))).css({
				top: e.pageY - 30,	//offsets
				left: e.pageX - 13 //offsets
			}).fadeIn();
		}
	});
	$(document.body).mousedown(function() {
		if(selectionImage) { selectionImage.fadeOut(); }
	});
});
</pre><p>Follows the same principal as above.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/selection-search.php" class="demo">View MooTools Demo</a> <a
href="http://davidwalsh.name/dw-content/selection-search.php?library=jquery" class="demo">View jQuery Demo</a><div
class="clear"></div></div><h2>Ideas &amp;&nbsp;Enhancements</h2><ul><li>Depending on your philosophy, you may want to implement a minimum character check as well:</p><pre class="js">
if(selection &amp;&amp; (selection = new String(selection).replace(/^\s+|\s+$/g,'')) &amp;&amp; selection.length &gt; 4) { //5 char min
</pre></li><li>You may want to also fidget with adding/modifying text selection with keyboard keys as well.  I&#8217;ve chosen to pass on that.</li><li><a
href="http://davidwalsh.name/text-selection-ajax">Saving the selection content via AJAX</a> for analytical reasons may not be a bad idea either.</li></ul><p>Have any other ideas for improvement?  Would you have any use for this on your website(s)?</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/text-select-widget">New York Times-Style Text Selection Widget Using MooTools or&nbsp;jQuery</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/text-selection-ajax' rel='bookmark' title='Permanent Link: Record Text Selections Using MooTools or jQuery&nbsp;AJAX'>Record Text Selections Using MooTools or jQuery&nbsp;AJAX</a></li><li><a
href='http://davidwalsh.name/google-fade' rel='bookmark' title='Permanent Link: Google-Style Element Fading Using MooTools or&nbsp;jQuery'>Google-Style Element Fading Using MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/csstricks-css-text-selection-highlighting' rel='bookmark' title='Permanent Link: CSS-Tricks &#8212; CSS &#038; Text Selection &#038;&nbsp;Highlighting'>CSS-Tricks &#8212; CSS &#038; Text Selection &#038;&nbsp;Highlighting</a></li><li><a
href='http://davidwalsh.name/digg-share-widget' rel='bookmark' title='Permanent Link: Digg-Style Dynamic Share Widget Using&nbsp;MooTools'>Digg-Style Dynamic Share Widget Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/load-more-widget' rel='bookmark' title='Permanent Link: David Walsh on NetTuts:  Create a Twitter-Like “Load More”&nbsp;Widget'>David Walsh on NetTuts:  Create a Twitter-Like “Load More”&nbsp;Widget</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/text-select-widget/feed</wfw:commentRss> <slash:comments>25</slash:comments> </item> <item><title>JavaScript Copy to&#160;Clipboard</title><link>http://davidwalsh.name/clipboard</link> <comments>http://davidwalsh.name/clipboard#comments</comments> <pubDate>Mon, 19 Oct 2009 13:11:19 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4001</guid> <description><![CDATA[Providing your users the ability to copy text to the clipboard can make your website much more convenient and valuable. Unfortunately Flash 10 broke most of the methods for doing so. Luckily a great library named ZeroClipboard exists. ZeroClipboard uses a pinch of Flash and touch of JavaScript to make copying to the clipboard happen. [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/clipboard">JavaScript Copy to&nbsp;Clipboard</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-clipboard-plugin' rel='bookmark' title='Permanent Link: MooTools Clipboard&nbsp;Plugin'>MooTools Clipboard&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/control-save' rel='bookmark' title='Permanent Link: Save Web Form Content Using Control +&nbsp;S'>Save Web Form Content Using Control +&nbsp;S</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/detecting-google-chrome-javascript' rel='bookmark' title='Permanent Link: Detecting Google Chrome Using&nbsp;JavaScript'>Detecting Google Chrome Using&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Providing your users the ability to copy text to the clipboard can make your website much more convenient and valuable.  Unfortunately Flash 10 broke most of the methods for doing so.  Luckily a great library named <a
href="http://code.google.com/p/zeroclipboard/">ZeroClipboard</a> exists.  ZeroClipboard uses a pinch of Flash and touch of JavaScript to make copying to the clipboard happen.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/zero-clipboard.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The Sample&nbsp;HTML</h2><pre class="html">
&lt;script type=&quot;text/javascript&quot; src=&quot;ZeroClipboard.js&quot;&gt;&lt;/script&gt;
&lt;textarea name=&quot;box-content&quot; id=&quot;box-content&quot; rows=&quot;5&quot; cols=&quot;70&quot;&gt;
	The David Walsh Blog is the best blog around!  MooTools FTW!
&lt;/textarea&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;p&gt;&lt;input type=&quot;button&quot; id=&quot;copy&quot; name=&quot;copy&quot; value=&quot;Copy to Clipboard&quot; /&gt;&lt;/p&gt;
</pre><p>The above HTML features a form element with the ID &#8220;box-content&#8221; and a button with the ID &#8220;copy&#8221;.  Both of those element IDs will come into play with ZeroClipboard.</p><h2>The ZeroClipboard&nbsp;JavaScript</h2><pre class="js">
//set path
ZeroClipboard.setMoviePath('http://davidwalsh.name/dw-content/ZeroClipboard.swf');
//create client
var clip = new ZeroClipboard.Client();
//event
clip.addEventListener('mousedown',function() {
	clip.setText(document.getElementById('box-content').value);
});
clip.addEventListener('complete',function(client,text) {
	alert('copied: ' + text);
});
//glue it to the button
clip.glue('copy');
</pre><p>With the ZeroClipboard object loaded we:</p><ul><li>Set the path to the SWF file.</li><li>Create what ZeroClipboard calls a &#8220;client&#8221;:  A client is a single instance of the clipboard library on the page, linked to a particular button or other DOM element.</li><li>Add a mousedown event listener that places text from inside our textarea into the clipboard.</li><li>Add an optional complete event where we can add functionality to execute once the text has been successfully added to the clipboard.</li><li>&#8220;Glue&#8221; the button to the functionality we&#8217;ve added in the steps above.</li></ul><p>That&#8217;s it!  ZeroClipboard is an outstanding utility to allow copy to the clipboard functionality on any website.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/clipboard">JavaScript Copy to&nbsp;Clipboard</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-clipboard-plugin' rel='bookmark' title='Permanent Link: MooTools Clipboard&nbsp;Plugin'>MooTools Clipboard&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/control-save' rel='bookmark' title='Permanent Link: Save Web Form Content Using Control +&nbsp;S'>Save Web Form Content Using Control +&nbsp;S</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/detecting-google-chrome-javascript' rel='bookmark' title='Permanent Link: Detecting Google Chrome Using&nbsp;JavaScript'>Detecting Google Chrome Using&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/clipboard/feed</wfw:commentRss> <slash:comments>25</slash:comments> </item> <item><title>Form Element AJAX Spinner Attachment Using&#160;jQuery</title><link>http://davidwalsh.name/ajax-spinner-jquery</link> <comments>http://davidwalsh.name/ajax-spinner-jquery#comments</comments> <pubDate>Fri, 16 Oct 2009 12:49:34 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[Usability / Accessibility]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3740</guid> <description><![CDATA[Yesterday I showed you how to attach an AJAX spinner next to a form element using my beloved MooTools. Today I&#8217;ll show you how to implement that same functionality using jQuery. View Demo The&#160;XHTML &#60;select class="ajax"&#62; &#60;option value=""&#62;-- Select a Site--&#60;/option&#62; &#60;option value="David Walsh Blog"&#62;David Walsh Blog&#60;/option&#62; &#60;option value="Script &#38; Style"&#62;Script &#38; Style&#60;/option&#62; &#60;option value="Band [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/ajax-spinner-jquery">Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/ajax-spinner' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;MooTools'>Form Element AJAX Spinner Attachment Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/animated-ajax-jquery' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;jQuery'>Animated AJAX Record Deletion Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/print-select-options' rel='bookmark' title='Permanent Link: Select Dropdowns, MooTools, and CSS&nbsp;Print'>Select Dropdowns, MooTools, and CSS&nbsp;Print</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Yesterday I showed you how to <a
href="http://davidwalsh.name/ajax-spinner">attach an AJAX spinner next to a form element using my beloved MooTools</a>.  Today I&#8217;ll show you how to implement that same functionality using jQuery.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/ajax-request-spinner.php?jquery" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;XHTML</h2><pre class="html">
&lt;select class="ajax"&gt;
	&lt;option value=""&gt;-- Select a Site--&lt;/option&gt;
	&lt;option value="David Walsh Blog"&gt;David Walsh Blog&lt;/option&gt;
	&lt;option value="Script &amp; Style"&gt;Script &amp; Style&lt;/option&gt;
	&lt;option value="Band Website Template"&gt;Band Website Template&lt;/option&gt;
&lt;/select&gt;

&lt;br /&gt;&lt;br /&gt;

&lt;input type="text" id="my-text" class="ajax" /&gt;
</pre><p>Elements with the &#8220;ajax&#8221; CSS class will be our target.</p><h2>The jQuery&nbsp;JavaScript</h2><pre class="js">
$(document).ready(function() {
	//create image
	$('&lt;img src="move-spinner.gif" id="spinner" /&gt;').css('position','absolute').hide().appendTo('body');
	//for every field change
	$('.ajax').change(function() {
		//get element position
		var position = $(this).offset();
		//position image
		$('#spinner').css({ top: position.top , left: position.left + $(this).width() + 30 }).fadeIn();
		//ajax
		$.post('&lt;?php echo $_SERVER['REQUEST_URI']; ?&gt;',{
			ajax:1,
			value: $(this).val()
		},function() {
			$('#spinner').fadeOut();
		});
	});
});
</pre><p>We inject the spinner image into the page and reposition it depending on which field is doing the request.  Very simple!</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/ajax-request-spinner.php?jquery" class="demo">View Demo</a><div
class="clear"></div></div><p>Isn&#8217;t JavaScript fun?  Oh yeah&#8230;and it makes the user experience better too.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/ajax-spinner-jquery">Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/ajax-spinner' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;MooTools'>Form Element AJAX Spinner Attachment Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/animated-ajax-jquery' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;jQuery'>Animated AJAX Record Deletion Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/print-select-options' rel='bookmark' title='Permanent Link: Select Dropdowns, MooTools, and CSS&nbsp;Print'>Select Dropdowns, MooTools, and CSS&nbsp;Print</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/ajax-spinner-jquery/feed</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>Form Element AJAX Spinner Attachment Using&#160;MooTools</title><link>http://davidwalsh.name/ajax-spinner</link> <comments>http://davidwalsh.name/ajax-spinner#comments</comments> <pubDate>Thu, 15 Oct 2009 13:12:02 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3732</guid> <description><![CDATA[Many times you&#8217;ll see a form dynamically change available values based on the value of a form field. For example, a &#8220;State&#8221; field will change based on which Country a user selects. What annoys me about these forms is that they&#8217;ll often do an AJAX request to grab the states but wont show any indicator [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/ajax-spinner">Form Element AJAX Spinner Attachment Using&nbsp;MooTools</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/print-select-options' rel='bookmark' title='Permanent Link: Select Dropdowns, MooTools, and CSS&nbsp;Print'>Select Dropdowns, MooTools, and CSS&nbsp;Print</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dotter-submit-button' rel='bookmark' title='Permanent Link: Using Dotter for Form&nbsp;Submissions'>Using Dotter for Form&nbsp;Submissions</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Many times you&#8217;ll see a form dynamically change available values based on the value of a form field.  For example, a &#8220;State&#8221; field will change based on which Country a user selects.  What annoys me about these forms is that they&#8217;ll often do an AJAX request to grab the states but wont show any indicator to the user that something is happening.  We&#8217;re going to use MooTools to add an AJAX spinner image next to form fields that perform such AJAX requests.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/ajax-request-spinner.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;XHTML</h2><pre class="html">
&lt;select class="ajax"&gt;
	&lt;option value=""&gt;-- Select a Site--&lt;/option&gt;
	&lt;option value="David Walsh Blog"&gt;David Walsh Blog&lt;/option&gt;
	&lt;option value="Script &amp; Style"&gt;Script &amp; Style&lt;/option&gt;
	&lt;option value="Band Website Template"&gt;Band Website Template&lt;/option&gt;
&lt;/select&gt;

&lt;br /&gt;&lt;br /&gt;

&lt;input type="text" id="my-text" class="ajax" /&gt;
</pre><p>Add the &#8220;ajax&#8221; class (or any class for that matter) to the elements you&#8217;d like the spinner to display by.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
window.addEvent('domready',function() {
	//inject image
	var spinner = new Element('img',{
		src: 'move-spinner.gif',
		styles: {
			position:'absolute'
		},
		opacity: 0
	}).inject(document.body);
	//form element events
	$$('.ajax').each(function(el) {
		//get coordinates
		var coords = el.getCoordinates(document.body);
		//ajax request object
		var request = new Request({
			url: '<?php echo $_SERVER['REQUEST_URI']; ?>',
			method: 'post',
			onRequest: function() {
				spinner.setStyles({
					left: coords.right + 10,
					top: coords.top + 5
				}).fade('in');
			},
			onComplete: function() {
				spinner.fade('out');
			}
		});
		//change event
		el.addEvent('change',function() {
			//ajax request
			request.send({
				data: {
					ajax: 1,
					value: el.get('value')
				}
			});
		});
	});
});
</pre><p>We first add the spinner image to the document but hide it right away.  When any of the form elements with the &#8220;ajax&#8221; class changes value, we move the spinner image to the right of the element.  Then we use Reqeust&#8217;s onRequest and onComplete methods to show and hide the spinner.  Simple!</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/ajax-request-spinner.php" class="demo">View Demo</a><div
class="clear"></div></div><p>Look forward to a jQuery version tomorrow.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/ajax-spinner">Form Element AJAX Spinner Attachment Using&nbsp;MooTools</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/print-select-options' rel='bookmark' title='Permanent Link: Select Dropdowns, MooTools, and CSS&nbsp;Print'>Select Dropdowns, MooTools, and CSS&nbsp;Print</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dotter-submit-button' rel='bookmark' title='Permanent Link: Using Dotter for Form&nbsp;Submissions'>Using Dotter for Form&nbsp;Submissions</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/ajax-spinner/feed</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Highlight Table Rows, Columns, and Cells Using MooTools&#160;1.2.3</title><link>http://davidwalsh.name/highlight-table-columns</link> <comments>http://davidwalsh.name/highlight-table-columns#comments</comments> <pubDate>Wed, 16 Sep 2009 12:12:17 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3052</guid> <description><![CDATA[Row highlighting and individual cell highlighting in tables is pretty simple in every browser that supports :hover on all elements (basically everything except IE6). Column highlighting is a bit more difficult. Luckily MooTools 1.2.3 makes the process easy. View Demo The&#160;XHTML &#60;table id="highlight-table"&#62; &#60;colgroup&#62;&#60;/colgroup&#62; &#60;colgroup class="slim"&#62;&#60;/colgroup&#62; &#60;colgroup class="slim"&#62;&#60;/colgroup&#62; &#60;colgroup class="slim"&#62;&#60;/colgroup&#62; &#60;colgroup class="slim"&#62;&#60;/colgroup&#62; &#60;thead&#62; &#60;tr&#62; &#60;th&#62;&#60;/th&#62; [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/highlight-table-columns">Highlight Table Rows, Columns, and Cells Using MooTools&nbsp;1.2.3</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/dynamic-table-of-contents-mootools' rel='bookmark' title='Permanent Link: Create a Dynamic Table of Contents Using MooTools&nbsp;1.2'>Create a Dynamic Table of Contents Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/mootools-zebra-tables-plugin' rel='bookmark' title='Permanent Link: MooTools Zebra Tables&nbsp;Plugin'>MooTools Zebra Tables&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/mootools-highlighter-search' rel='bookmark' title='Permanent Link: Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin'>Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/mootools-print-links' rel='bookmark' title='Permanent Link: MooTools &#038; Printing &#8211; Creating a Links Table of&nbsp;Contents'>MooTools &#038; Printing &#8211; Creating a Links Table of&nbsp;Contents</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Row highlighting and individual cell highlighting in tables is pretty simple in every browser that supports <span
class="param">:hover</span> on all elements (basically everything except IE6).  Column highlighting is a bit more difficult.  Luckily MooTools 1.2.3 makes the process easy.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/mootools-table-columns.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;XHTML</h2><pre class="html">
&lt;table id="highlight-table"&gt;
       &lt;colgroup&gt;&lt;/colgroup&gt;
       &lt;colgroup class="slim"&gt;&lt;/colgroup&gt;
       &lt;colgroup class="slim"&gt;&lt;/colgroup&gt;
       &lt;colgroup class="slim"&gt;&lt;/colgroup&gt;
       &lt;colgroup class="slim"&gt;&lt;/colgroup&gt;
    &lt;thead&gt;
       &lt;tr&gt;
           &lt;th&gt;&lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
           &lt;th&gt;&lt;/th&gt;
       &lt;/tr&gt;
    &lt;/thead&gt;
   	&lt;tbody&gt;
   		&lt;tr&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   		&lt;/tr&gt;
   		&lt;tr&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   			&lt;td&gt;&lt;/td&gt;
   		&lt;/tr&gt;
		&lt;!-- MORE ROWS --&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
</pre><p>A normal table.  The cells being empty is inconsequential to the functionality &#8212; place whatever you&#8217;d like in the table.</p><h2>The&nbsp;CSS</h2><pre class="css">
table               { border-collapse: collapse; width: 100%; margin-top:10px; }
td                  { border: 1px solid #ccc; padding: 10px; }
thead               { width: 100%; height: 109px; background: url(header.png) no-repeat; }
.slim               { width: 88px; }
.column-hover		{ background:#eee; }
.row-hover			{ background:#ddd; }
.cell-hover			{ background:#fffea1; }
</pre><p>Note that I&#8217;ve created 3 separate <span
class="param">hover</span> classes &#8212; one for each type of hover possible within the table.</p><h2>The MooTools JavaScript Version 1 &#8211;&nbsp;Inefficient</h2><pre class="js">
	window.addEvent('domready',function(){
	// variables and settings
	var table = document.id('highlight-table');
	table.getElements('td').each(function(el) {
		var parent = el.getParent('tr');
		var siblings = parent.getElements('td');
		var index = siblings.indexOf(el) + 1;
		var childSelector = 'tr td:nth-child(' + index + ')';
		//add events to the table cell
		el.addEvents({
			mouseenter: function() {
				//this column
				table.getElements(childSelector).addClass('column-hover');
				//this row
				parent.addClass('row-hover');
				//this cell
				el.addClass('cell-hover');
			},
			mouseleave: function() {
				//this column
				table.getElements(childSelector).removeClass('column-hover');
				//this row
				parent.removeClass('row-hover');
				//this cell
				el.removeClass('cell-hover');
			}
		});
	});
});
</pre><p>The first step is grabbing every TD within the table.  Iterate through that array of TDs adding <span
class="func">mouseenter</span> and <span
class="func">mouseleave</span> events to the element.  The <span
class="func">mouseenter</span> method adds the necessary CSS classes, the <span
class="func">mouseleave</span> event removes them.  The difficult part, in theory, is the column highlighting.  Using a CSS 3 &#8220;nth-child&#8221; selector made the column-highlighting process easier than I had expected.</p><h2>The MooTools JavaScript Version 2 &#8211; More&nbsp;Efficient</h2><pre class="js">
window.addEvent('domready',function(){
/*  METHOD 2:  Better  */
var table = document.id('highlight-table');
var rows = table.getElements('tr');

//for every row...
rows.each(function(tr,trCount){
	//we don't want the header
	if(tr.getParent().get('tag') == 'thead') { return false; }
	//add the row class to the row
	tr.addClass('row-' + trCount);
	//add the row listener
	tr.addEvents({
		'mouseenter': function(){
			tr.addClass('row-hover');
		},
		'mouseleave': function(){
			tr.removeClass('row-hover');
		}
	});
	//for every cell...
	tr.getElements('td').each(function(td,tdCount) {
		//remember column and column items
		var column = 'col-' + tdCount;
		var friends = 'td.' + column;
		//add td's column class
		td.addClass(column);
		//add the cell and column event listeners
		td.addEvents({
			'mouseenter': function(){
				$$(friends).erase(td).addClass('column-hover');
				td.addClass('cell-hover');
			},
			'mouseleave': function() {
				$$(friends).erase(td).removeClass('column-hover');
				td.removeClass('cell-hover');
			}
		});
	});
});	
});
</pre><p> This version is much faster because more of the work is done up front and done only once.  I give all the proper class names at the beginning of the script and access the collections only when I need them.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/mootools-table-columns.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>A Few&nbsp;Thoughts</h2><ul><li>Remember that since every TD is analyzed, this process can be very taxing on large page.</li><li>You can use simple CSS <span
class="param">:hover</span> definitions for the row and cell highlighting in all browsers except IE6.</li><li>Nested tables will raise havoc on this system.  The easy way to get prevent the problem is checking the element&#8217;s TABLE parent ID to make sure it&#8217;s the same as the initial table you wanted to highlight.</li><li>Since this was more of an experiment than anything, I skipped making this into a MooTools class.  If anyone wanted to give that a go, I&#8217;d love to see what you come up with.</li></ul><p>Great idea and execution by Chris.  I am obligated to say MooTools FTW though!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/highlight-table-columns">Highlight Table Rows, Columns, and Cells Using MooTools&nbsp;1.2.3</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/dynamic-table-of-contents-mootools' rel='bookmark' title='Permanent Link: Create a Dynamic Table of Contents Using MooTools&nbsp;1.2'>Create a Dynamic Table of Contents Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/mootools-zebra-tables-plugin' rel='bookmark' title='Permanent Link: MooTools Zebra Tables&nbsp;Plugin'>MooTools Zebra Tables&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/mootools-highlighter-search' rel='bookmark' title='Permanent Link: Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin'>Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/mootools-print-links' rel='bookmark' title='Permanent Link: MooTools &#038; Printing &#8211; Creating a Links Table of&nbsp;Contents'>MooTools &#038; Printing &#8211; Creating a Links Table of&nbsp;Contents</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/highlight-table-columns/feed</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Select Dropdowns, MooTools, and CSS&#160;Print</title><link>http://davidwalsh.name/print-select-options</link> <comments>http://davidwalsh.name/print-select-options#comments</comments> <pubDate>Fri, 04 Sep 2009 13:08:45 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3555</guid> <description><![CDATA[I know I&#8217;ve harped on this over and over again but it&#8217;s important to enhance pages for print. You can do some things using simple CSS but today&#8217;s post features MooTools and jQuery. We&#8217;ll be taking the options of a SELECT element and generating a list in case the user prints the page. View Demo [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/print-select-options">Select Dropdowns, MooTools, and CSS&nbsp;Print</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/php-form-helper-quick-easy-select-dropdowns' rel='bookmark' title='Permanent Link: PHP Form Helper — Quick &#038; Easy SELECT&nbsp;Dropdowns'>PHP Form Helper — Quick &#038; Easy SELECT&nbsp;Dropdowns</a></li><li><a
href='http://davidwalsh.name/faux-select' rel='bookmark' title='Permanent Link: Dress Up Your Select Elements with&nbsp;FauxSelect'>Dress Up Your Select Elements with&nbsp;FauxSelect</a></li><li><a
href='http://davidwalsh.name/multi-select-transfers-using-mootools-12' rel='bookmark' title='Permanent Link: Multi-Select Transfers Using MooTools&nbsp;1.2'>Multi-Select Transfers Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I know I&#8217;ve harped on this over and over again but it&#8217;s important to enhance pages for print.  You can do some things using simple CSS but today&#8217;s post features MooTools and jQuery.  We&#8217;ll be taking the options of a SELECT element and generating a list in case the user prints the page.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/print-select.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;XHTML</h2><pre class="html">
&lt;label for="websites"&gt;Which is your favorite website?&lt;/label&gt;
&lt;select name="websites" id="websites"&gt;
	&lt;option value="davidwalsh.name" selected="selected"&gt;David Walsh Blog&lt;/option&gt;
	&lt;option value="scriptandstyle.com"&gt;Script &amp; Style&lt;/option&gt;
	&lt;option value="csstricks.com"&gt;CSS Tricks&lt;/option&gt;
	&lt;option value="mootools.net"&gt;MooTools&lt;/option&gt;
&lt;/select&gt;
</pre><p>Just a normal select list, nothing special.</p><h2>The&nbsp;CSS</h2><pre class="css">
@media screen { 
	.print-select   { display:none; }
}
@media print { 
	.print-select   { padding:10px; /* width:40%; */ border:1px solid #ccc; }
}
</pre><p>Simple &#8212; show the generated options DIV only during print.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
(function($) {
	window.addEvent('domready',function() {
		$$('select').each(function(select) {
			//get options
			var options = select.getElements('option');
			//create div
			var div = new Element('div',{
				'class': 'print-select',
				html: '&lt;p&gt;&lt;strong&gt;Options&lt;/strong&gt;&lt;/p&gt;'/*,
				style: 'width:' + (select.getSize().x - 20) + 'px' //subtracting padding */
			}).inject(select,'after');
			//create list
			var list = new Element('ul'), items = '';
			options.each(function(option) {
				items += '&lt;li&gt;' + option.get('text') + (option.selected ? ' &lt;em&gt;(selected)&lt;/em&gt;' : '') + '&lt;/li&gt;';
			});
			list.set('html',items);
			//list into div
			list.inject(div);
		});
	});
})(document.id);
</pre><p>The script grabs every SELECT element in the page and generates a list of the SELECT&#8217;s options &#8212; it even notes which element(s) are selected!</p><h2>The jQuery&nbsp;JavaScript</h2><p>Want to know how to accomplish this task using the jQuery JavaScript library?  Chris Coyier dropped it on his <a
href="http://css-tricks.com/making-selects-printable/">CSS-Tricks blog</a> today!</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/print-select.php" class="demo">View Demo</a><div
class="clear"></div></div><p>Just another useful CSS-printing trick brought to you by the warped <a
href="http://scriptandstyle.com">Script &amp; Style</a> minds.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/print-select-options">Select Dropdowns, MooTools, and CSS&nbsp;Print</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/php-form-helper-quick-easy-select-dropdowns' rel='bookmark' title='Permanent Link: PHP Form Helper — Quick &#038; Easy SELECT&nbsp;Dropdowns'>PHP Form Helper — Quick &#038; Easy SELECT&nbsp;Dropdowns</a></li><li><a
href='http://davidwalsh.name/faux-select' rel='bookmark' title='Permanent Link: Dress Up Your Select Elements with&nbsp;FauxSelect'>Dress Up Your Select Elements with&nbsp;FauxSelect</a></li><li><a
href='http://davidwalsh.name/multi-select-transfers-using-mootools-12' rel='bookmark' title='Permanent Link: Multi-Select Transfers Using MooTools&nbsp;1.2'>Multi-Select Transfers Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/noscript-compatible-select-form-element-onchange-event' rel='bookmark' title='Permanent Link: Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event'>Create a NoScript Compatible Select Form Element with an onChange&nbsp;Event</a></li><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/print-select-options/feed</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>QuickBoxes for&#160;Dojo</title><link>http://davidwalsh.name/quickboxes-dojo</link> <comments>http://davidwalsh.name/quickboxes-dojo#comments</comments> <pubDate>Wed, 15 Jul 2009 12:27:34 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[Usability / Accessibility]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=3164</guid> <description><![CDATA[Adding to my mental portfolio is important to me. First came MooTools, then jQuery, and now Dojo. I speak often with Peter Higgins of Dojo fame and decided it was time to step into his world. I chose a simple but useful plugin, QuickBoxes, to port over from MooTools. The following is the result. View [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/quickboxes-dojo">QuickBoxes for&nbsp;Dojo</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-checkboxes-plugin' rel='bookmark' title='Permanent Link: MooTools dwCheckboxes&nbsp;Plugin'>MooTools dwCheckboxes&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/link-nudging-dojo' rel='bookmark' title='Permanent Link: Link Nudging Using&nbsp;Dojo'>Link Nudging Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/remove-images-dojo' rel='bookmark' title='Permanent Link: Remove Broken Images Using&nbsp;Dojo'>Remove Broken Images Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/missing-image-dojo' rel='bookmark' title='Permanent Link: Use Custom Missing Image Graphics Using&nbsp;Dojo'>Use Custom Missing Image Graphics Using&nbsp;Dojo</a></li></ol>]]></description> <content:encoded><![CDATA[<img
src="http://davidwalsh.name/dw-content/dojo-logo.jpg" alt="Dojo Toolkit" class="image" /><p>Adding to my mental portfolio is important to me.  First came MooTools, then jQuery, and now Dojo.  I speak often with Peter Higgins of Dojo fame and decided it was time to step into his world.  I chose a simple but useful plugin, QuickBoxes, to port over from MooTools.  The following is the result.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/dojo-quickboxes.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The Dojo&nbsp;JavaScript</h2><pre class="js">
//safety closure
;(function(d, $){
	//plugin begins
    d.QuickBoxes = function(args, node){
		//scoping
		node = d.byId(node);
		//settings
		var active = 0;
		args.elements = $(args.elements);
		//for every checkbox
		args.elements.forEach(function(el) {
			//connect the MouseDown event
			d.connect(el,'onmousedown',function(ev){
				d.stopEvent(ev);
				active = 1;
				el.checked = !el.checked;
			});
			//connect the MouseEnter event
			d.connect(el,'onmouseenter',function(e){
				if(active == 1) {
					el.checked = ('toggle' == args.mode ? !el.checked : 'check' == args.mode);
				}
			});
			//connect the Click event
			d.connect(el,'onclick',function(e){
				el.checked = !el.checked;
				active = 0;
			});
			//fix the labels
			var label = $('label[for=' + el.getAttribute('id') + ']');
			if(label.length) {
				d.connect(label[0],'onclick',function(e){
					el.checked = !el.checked;
				});
			}
		});
		//add the mouseup event to the Window
		d.connect(d.body(),'mouseup',function(){ active = 0; });
	};	
	//usage
	d.addOnLoad(function(){
		var togglers = new d.QuickBoxes({ elements: '.toggle', mode: 'toggle' });
		var checked = new d.QuickBoxes({ elements: '.checked', mode: 'check' });
		var unchecked = new d.QuickBoxes({ elements: '.unchecked', mode: 'uncheck' });
	});
})(dojo, dojo.query);
</pre><p>If you take a look at the Dojo version and the MooTools version, they&#8217;re very much the same.  Like I&#8217;ve preached with Moo and jQuery, the frameworks all do the same thing but with a different syntax.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/dojo-quickboxes.php" class="demo">View Demo</a><div
class="clear"></div></div><p>A special thanks to <a
href="http://higginsforpresident.net">Peter Higgins</a> for his help &#8212; in all honestly, I was pretty lost at a few points of this simple plugin.  It was good to dabble in Dojo and I look forward to more experimentation.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/quickboxes-dojo">QuickBoxes for&nbsp;Dojo</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-checkboxes-plugin' rel='bookmark' title='Permanent Link: MooTools dwCheckboxes&nbsp;Plugin'>MooTools dwCheckboxes&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/link-nudging-dojo' rel='bookmark' title='Permanent Link: Link Nudging Using&nbsp;Dojo'>Link Nudging Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/remove-images-dojo' rel='bookmark' title='Permanent Link: Remove Broken Images Using&nbsp;Dojo'>Remove Broken Images Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/missing-image-dojo' rel='bookmark' title='Permanent Link: Use Custom Missing Image Graphics Using&nbsp;Dojo'>Use Custom Missing Image Graphics Using&nbsp;Dojo</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/quickboxes-dojo/feed</wfw:commentRss> <slash:comments>10</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 133/393 queries in 6.570 seconds using disk

Served from: davidwalsh.name @ 2010-09-02 23:39:32 -->