<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en" xml:base="http://davidwalsh.name/wp-atom.php"><title type="text">David Walsh :: PHP, CSS, MooTools, jQuery, and Everything Else</title> <subtitle type="text">PHP, CSS, MooTools, jQuery, and Everything Else</subtitle><updated>2010-03-18T16:38:53Z</updated> <generator uri="http://wordpress.org/" version="2.9.2">WordPress</generator><link rel="alternate" type="text/html" href="http://davidwalsh.name" /> <id>http://davidwalsh.name/feed/atom</id><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Bludice" /><feedburner:info uri="bludice" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>43.072994</geo:lat><geo:long>-89.519924</geo:long><feedburner:emailServiceId>Bludice</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Track Clicks Outside Active Elements with MooTools or&#160;jQuery]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/hCjj-74hAvs/mootools-outter-click" /> <id>http://davidwalsh.name/?p=4934</id> <updated>2010-03-18T16:38:53Z</updated> <published>2010-03-18T13:12:21Z</published> <category scheme="http://davidwalsh.name" term="MooTools" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /> <summary type="html"><![CDATA[Buried in the MooTools and jQuery code from my Twitter Dropdowns posts was a small but useful snippet of code:  hide an &#8220;active&#8221; element when the user clicks outside of the elements.Take a look at the image above.  When you click the &#8220;Menu 1&#8243; button, the dropdown menu displays.  Both the buttons [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/mootools-outter-click">Track Clicks Outside Active Elements with MooTools or&nbsp;jQuery</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;jQuery'>Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/twitter-dropdown' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;MooTools'>Create Twitter-Style Dropdowns Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/track-ajax-link-clicks-google-analytics' rel='bookmark' title='Permanent Link: Track Ajax Link Clicks Using Google&nbsp;Analytics'>Track Ajax Link Clicks Using Google&nbsp;Analytics</a></li><li><a
href='http://davidwalsh.name/jquery-add-event' rel='bookmark' title='Permanent Link: Implement MooTools&#8217; Elements.addEvent in&nbsp;jQuery'>Implement MooTools&#8217; Elements.addEvent in&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/implement-jquery-click-syntax-mootools' rel='bookmark' title='Permanent Link: Implement jQuery-like &#8220;Click&#8221; Syntax In MooTools&nbsp;1.2'>Implement jQuery-like &#8220;Click&#8221; Syntax In MooTools&nbsp;1.2</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/mootools-outter-click">&lt;p&gt;Buried in the MooTools and jQuery code from my Twitter Dropdowns posts was a small but useful snippet of code:  hide an &amp;#8220;active&amp;#8221; element when the user clicks outside of the elements.&lt;/p&gt;&lt;p&gt;&lt;img
src="http://davidwalsh.name/dw-content/parent-menu.jpg" alt="Twitter Dropdown Menu" /&gt;&lt;/p&gt;&lt;p&gt;Take a look at the image above.  When you click the &amp;#8220;Menu 1&amp;#8243; button, the dropdown menu displays.  Both the buttons and dropdown are wrapped in a DIV.  When the menu gets activated, that wrapping DIV (or &amp;#8220;parent&amp;#8221;) is stored in a variable.  For each dropdown, we add an event to the body to check where the user clicks.  The following snippet explains what happens next.&lt;/p&gt;&lt;h2&gt;The MooTools Javascript&lt;/h2&gt;&lt;pre class="js"&gt;
/*
- showingParent is the wrapper div.
- hideMenu hides the showingParent's dropdown, etc.
*/

/* hide when clicked outside */
$(document.body).addEvent('click',function(e) {
	if(showingParent &amp;#038;&amp;#038; !e.target || !$(e.target).getParents().contains(showingParent)) { 
		hideMenu(); //hide the menu! clicked outside!
	}
});
&lt;/pre&gt;&lt;p&gt;The Event object (e, in this case), specifically Event.target, tells us which element was clicked.  Once we know which element is clicked, we can step up the DOM tree, looking for the &amp;#8220;parent&amp;#8221; element we had saved.  If we find the saved parent element, we know the click occurred inside the designated area and we do *not* close the active element.  If we don&amp;#8217;t find the saved parent, the user clicked outside the active element and we should close the menu.&lt;/p&gt;&lt;h2&gt;The jQuery Javascript&lt;/h2&gt;&lt;pre class="js"&gt;
$(document.body).bind('click',function(e) {
	if(showingParent) {
		var parentElement = showingParent[0];
		if(!$.contains(parentElement,e.target) || parentElement != e.target) {
			hideMenu();
		}
	}
});
&lt;/pre&gt;&lt;p&gt;The same principle applies;  jQuery&amp;#8217;s syntax is simply different.&lt;/p&gt;&lt;p&gt; If you still have questions about the context of its use, check out the &lt;a
href="http://davidwalsh.name/twitter-dropdown"&gt;MooTools&lt;/a&gt; or &lt;a
href="http://davidwalsh.name/twitter-dropdown-jquery"&gt;jQuery&lt;/a&gt; Twitter Dropdown articles to see this technique in practice.  This ability is extremely effective and valuable when trying to create usable dropdowns.  Have fun with this!&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/mootools-outter-click"&gt;Track Clicks Outside Active Elements with MooTools or&amp;nbsp;jQuery&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&amp;nbsp;jQuery'&gt;Create Twitter-Style Dropdowns Using&amp;nbsp;jQuery&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/twitter-dropdown' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&amp;nbsp;MooTools'&gt;Create Twitter-Style Dropdowns Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/track-ajax-link-clicks-google-analytics' rel='bookmark' title='Permanent Link: Track Ajax Link Clicks Using Google&amp;nbsp;Analytics'&gt;Track Ajax Link Clicks Using Google&amp;nbsp;Analytics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/jquery-add-event' rel='bookmark' title='Permanent Link: Implement MooTools&amp;#8217; Elements.addEvent in&amp;nbsp;jQuery'&gt;Implement MooTools&amp;#8217; Elements.addEvent in&amp;nbsp;jQuery&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/implement-jquery-click-syntax-mootools' rel='bookmark' title='Permanent Link: Implement jQuery-like &amp;#8220;Click&amp;#8221; Syntax In MooTools&amp;nbsp;1.2'&gt;Implement jQuery-like &amp;#8220;Click&amp;#8221; Syntax In MooTools&amp;nbsp;1.2&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/hCjj-74hAvs" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/mootools-outter-click#comments" thr:count="18" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/mootools-outter-click/feed/atom" thr:count="18" /> <thr:total>18</thr:total> <feedburner:origLink>http://davidwalsh.name/mootools-outter-click</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Create a Quick MooTools Slideshow with Preloading&#160;Images]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/x1MIqYjzvsw/slideshow-preload-images" /> <id>http://davidwalsh.name/?p=4933</id> <updated>2010-03-17T13:21:28Z</updated> <published>2010-03-17T13:21:28Z</published> <category scheme="http://davidwalsh.name" term="CSS / Design" /><category scheme="http://davidwalsh.name" term="MooTools" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /> <summary type="html"><![CDATA[I&#8217;ve been creating a lot of slideshow posts lately.  Why, you ask?  Because they help me get chicks.  A quick formula for you:
var numChicks = $$('.slideshow').length; //simple!The following code snippet will show you how to create a simple slideshow with MooTools;  the script will also preload the images and feature a [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/slideshow-preload-images">Create a Quick MooTools Slideshow with Preloading&nbsp;Images</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-image-preloading-progress-bar' rel='bookmark' title='Permanent Link: MooTools Image Preloading with Progress&nbsp;Bar'>MooTools Image Preloading with Progress&nbsp;Bar</a></li><li><a
href='http://davidwalsh.name/mootools-slideshow' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using&nbsp;MooTools'>Create a Simple Slideshow Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/mootools-slideshow-ii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part II:  Controls and&nbsp;Events'>Create a Simple Slideshow Using MooTools, Part II:  Controls and&nbsp;Events</a></li><li><a
href='http://davidwalsh.name/slideshow-thumbnails-captions' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&nbsp;Captions'>Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&nbsp;Captions</a></li><li><a
href='http://davidwalsh.name/create-a-simple-slideshow-iii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part III: Creating a&nbsp;Class'>Create a Simple Slideshow Using MooTools, Part III: Creating a&nbsp;Class</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/slideshow-preload-images">&lt;img
style="width: 450px; height: 300px;" src="http://davidwalsh.name/dw-content/epics/1.jpg" alt="David Walsh Slideshow" /&gt;&lt;p&gt;I&amp;#8217;ve been creating a lot of slideshow posts lately.  Why, you ask?  Because they help me get chicks.  A quick formula for you:&lt;/p&gt;&lt;pre class="js"&gt;var numChicks = $$('.slideshow').length; //simple!
&lt;/pre&gt;&lt;p&gt;The following code snippet will show you how to create a simple slideshow with MooTools;  the script will also preload the images and feature a progress message.  Why preload images?  They make the slideshow more elegant and you can avoid an onLoad mess.  Oh, and chicks&amp;#8230;loads and loads of chicks.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
class="demo" href="http://davidwalsh.name/dw-content/preload-slideshow.php"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;The HTML&lt;/h2&gt;&lt;pre class="html"&gt;&amp;lt;div id="slideshow-holder"&amp;gt;
	&amp;lt;div id="progress"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/pre&gt;&lt;p&gt;Basically just two DIVs which will hold content.&lt;/p&gt;&lt;h2&gt;The CSS&lt;/h2&gt;&lt;pre class="css"&gt;#slideshow-holder	{ width:600px; height:400px; background:url(spinner.gif) center center no-repeat #fff; position:relative; }
#progress			{ position:absolute; width:100%; text-align:center; color:#999; top:225px; }
&lt;/pre&gt;&lt;p&gt;The image holder is given set dimensions, starts with a background spinner, and its position set to relative;  the images will all be positioned absolutely.  The progress holder is set right below the spinner.&lt;/p&gt;&lt;h2&gt;The MooTools Javascript&lt;/h2&gt;&lt;pre class="js"&gt;window.addEvent('domready',function() {
	/* preloading */
	var imagesDir = 'epics/';
	var images = ['2.jpg','3.jpg','1.jpg','4.jpg','5.jpg'];
	var holder = $('slideshow-holder');
	images.each(function(img,i){ images[i] = imagesDir + '' + img; }); //add dir to images
	var progressTemplate = 'Loading image {x} of ' + images.length;
	var updateProgress = function(num) {
		progress.set('text',progressTemplate.replace('{x}',num));
	};
	var progress = $('progress');
	updateProgress('text','0');
	var loader = new Asset.images(images, {
		onProgress: function(c,index) {
			updateProgress('text',index + 1);
		},
		onComplete: function() {
			var slides = [];
			/* put images into page */
			images.each(function(im) {
				slides.push(new Element('img',{
					src:im,
					width: 600,
					height: 400,
					styles: {
						opacity:0,
						top:0,
						left:0,
						position:'absolute',
						'z-index': 10
					}
				}).inject(holder));
				holder.setStyle('background','url(logo.png) center 80px no-repeat');
			});
			var showInterval = 5000;
			var index = 0;
			progress.set('text','Images loaded.  MooTools FTW.');
			(function() {slides[index].tween('opacity',1); }).delay(1000);
			var start = function() {
				(function() {
					holder.setStyle('background','');
					slides[index].fade(0);
					++index;
					index = (slides[index] ? index : 0);
					slides[index].fade(1);
				}).periodical(showInterval);
			};

			/* start the show */
			start();
		}
	});
});
&lt;/pre&gt;&lt;p&gt;The first set of variable declarations represent basic settings for the preloader:  images, preload-message-updating, etc.  We pass our Asset.images instance an array of images.  When each image loads, we update the status message.  When every image has loaded, we remove the status message and start the slideshow.  That&amp;#8217;s it!&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
class="demo" href="http://davidwalsh.name/dw-content/preload-slideshow.php"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Of course the above could be turned into the class&amp;#8230;.I&amp;#8217;m just slightly lazy&amp;#8230;Feel free to turn it into a class and share with everyone!&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/slideshow-preload-images"&gt;Create a Quick MooTools Slideshow with Preloading&amp;nbsp;Images&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-image-preloading-progress-bar' rel='bookmark' title='Permanent Link: MooTools Image Preloading with Progress&amp;nbsp;Bar'&gt;MooTools Image Preloading with Progress&amp;nbsp;Bar&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-slideshow' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using&amp;nbsp;MooTools'&gt;Create a Simple Slideshow Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-slideshow-ii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part II:  Controls and&amp;nbsp;Events'&gt;Create a Simple Slideshow Using MooTools, Part II:  Controls and&amp;nbsp;Events&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/slideshow-thumbnails-captions' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&amp;nbsp;Captions'&gt;Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&amp;nbsp;Captions&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/create-a-simple-slideshow-iii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part III: Creating a&amp;nbsp;Class'&gt;Create a Simple Slideshow Using MooTools, Part III: Creating a&amp;nbsp;Class&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/x1MIqYjzvsw" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/slideshow-preload-images#comments" thr:count="9" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/slideshow-preload-images/feed/atom" thr:count="9" /> <thr:total>9</thr:total> <feedburner:origLink>http://davidwalsh.name/slideshow-preload-images</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Create Twitter-Style Dropdowns Using&#160;jQuery]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/Mzq_zynfAK8/twitter-dropdown-jquery" /> <id>http://davidwalsh.name/?p=4930</id> <updated>2010-03-16T13:10:11Z</updated> <published>2010-03-16T13:10:11Z</published> <category scheme="http://davidwalsh.name" term="CSS / Design" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /><category scheme="http://davidwalsh.name" term="jQuery" /> <summary type="html"><![CDATA[Twitter does some great stuff with javascript.  What I really appreciate about what they do is that there aren&#8217;t any epic JS functionalities &#8212; they&#8217;re all simple touches.  One of those simple touches is the &#8220;Login&#8221; dropdown on their homepage.  I&#8217;ve taken some time to duplicate that functionality with jQuery.View DemoThe HTML&#60;div [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/twitter-dropdown-jquery">Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/twitter-dropdown' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;MooTools'>Create Twitter-Style Dropdowns Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/mootools-outter-click' rel='bookmark' title='Permanent Link: Track Clicks Outside Active Elements with MooTools or&nbsp;jQuery'>Track Clicks Outside Active Elements with MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/search-options' rel='bookmark' title='Permanent Link: Search Type Options with&nbsp;MooTools'>Search Type Options with&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/snook-navigation-mootools' rel='bookmark' title='Permanent Link: Create Snook-Style Navigation Using&nbsp;MooTools'>Create Snook-Style Navigation Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/animated-button' rel='bookmark' title='Permanent Link: Create an Animated Sliding Button Using&nbsp;MooTools'>Create an Animated Sliding Button Using&nbsp;MooTools</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/twitter-dropdown-jquery">&lt;a
href="http://davidwalsh.name/dw-content/twitter-dropdown-jquery.php"&gt;&lt;img
src="http://davidwalsh.name/dw-content/fail-whale.png" alt="Twitter Dropdown" class="image" /&gt;&lt;/a&gt;&lt;p&gt;Twitter does some great stuff with javascript.  What I really appreciate about what they do is that there aren&amp;#8217;t any epic JS functionalities &amp;#8212; they&amp;#8217;re all simple touches.  One of those simple touches is the &amp;#8220;Login&amp;#8221; dropdown on their homepage.  I&amp;#8217;ve taken some time to duplicate that functionality with jQuery.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/twitter-dropdown-jquery.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;The HTML&lt;/h2&gt;&lt;pre class="html"&gt;
&amp;lt;div id=&amp;quot;menu1&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;relative&amp;quot;&amp;gt;
	&amp;lt;a href=&amp;quot;/demos&amp;quot; title=&amp;quot;Popular MooTools Tutorials&amp;quot; id=&amp;quot;dd1&amp;quot; class=&amp;quot;dropdown&amp;quot; style=&amp;quot;width:170px;text-decoration:none;&amp;quot;&amp;gt;&amp;lt;span&amp;gt;Menu 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;
	&amp;lt;div id=&amp;quot;dropdown1&amp;quot; class=&amp;quot;dropdown-menu&amp;quot;&amp;gt;
		&amp;lt;a href=&amp;quot;/about-david-walsh&amp;quot; title=&amp;quot;Learn a bit about me.&amp;quot;&amp;gt;About Me&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/page/1&amp;quot; title=&amp;quot;The David Walsh Blog&amp;quot;&amp;gt;Blog&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/chat&amp;quot; title=&amp;quot;#davidwalshblog IRC Chat&amp;quot;&amp;gt;Chat&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/contact&amp;quot; title=&amp;quot;Contact David Walsh&amp;quot;&amp;gt;Contact Me&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/demos&amp;quot; title=&amp;quot;CSS, PHP, jQuery, MooTools Demos&amp;quot;&amp;gt;Demos &amp;amp;amp; Downloads&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/js&amp;quot; title=&amp;quot;ScrollSpy, Lazyload, Overlay, Context Menu&amp;quot;&amp;gt;MooTools Plugins&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/network&amp;quot; title=&amp;quot;David Walsh Blog, Script &amp;amp;amp; Style, Band Website Template, Wynq&amp;quot;&amp;gt;Network&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/web-development-tools&amp;quot; title=&amp;quot;JS, CSS Compression&amp;quot;&amp;gt;Web Dev Tools&amp;lt;/a&amp;gt;
	&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div id=&amp;quot;menu2&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;relative&amp;quot;&amp;gt;
	&amp;lt;a href=&amp;quot;/demos&amp;quot; title=&amp;quot;Popular MooTools Tutorials&amp;quot; id=&amp;quot;dd2&amp;quot; class=&amp;quot;dropdown&amp;quot; rel=&amp;quot;dropdown2&amp;quot; style=&amp;quot;width:170px;text-decoration:none;&amp;quot;&amp;gt;&amp;lt;span&amp;gt;Menu 2&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;
	&amp;lt;div id=&amp;quot;dropdown2&amp;quot; class=&amp;quot;dropdown-menu&amp;quot;&amp;gt;
		&amp;lt;p&amp;gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.&amp;lt;/p&amp;gt;
	&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;
&lt;/pre&gt;&lt;p&gt;A series of DIVS wrapping a link (the dropdown &amp;#8220;trigger&amp;#8221;) and a DIV containing the menu items.&lt;/p&gt;&lt;h2&gt;The CSS&lt;/h2&gt;&lt;pre class="css"&gt;
/* dropdowns: general */
a.dropdown { background: #88bbd4; padding: 4px 6px 6px; text-decoration: none; font-weight: bold; color: #fff; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; }
a.dropdown:hover { background: #59b; }
a.dropdown { position: relative; margin-left: 3px; }
a.dropdown span { background-image: url(toggle_down_light.png); background-repeat: no-repeat; background-position: 100% 50%; padding: 4px 16px 6px 0; }
a.dropdown.dropdown-active { color:#59b; background-color:#ddeef6; }
a.dropdown.dropdown-active span { background:url(toggle_up_dark.png) 100% 50% no-repeat; }
.dropdown-menu	{ background:#ddeef6; padding:7px 12px; position:absolute; top:16px; right:0; display:none; z-index:5000; -moz-border-radius-topleft: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; }
	.dropdown-menu p { font-size:11px; }
.dropdown-menu a:link, .dropdown-menu a:visited	{ font-weight:bold; color:#59b; text-decoration:none; line-height:1.7em; }
.dropdown-menu a:active, .dropdown-menu a:hover { color:#555; }

			* html .dropdown-menu { top:28px; }
			*+ html .dropdown-menu { top:28px; }

/* dropdowns: specific */
#menu1			{ float:left; margin-right:20px; }
	#dropdown1	{ width:150px; }
	#dropdown1 a	{ display:block; }
#menu2			{ float:left; }
	#dropdown2	{ width:150px; font-size:11px; }
.relative		{ position:relative; }
&lt;/pre&gt;&lt;p&gt;There&amp;#8217;s a lot of CSS involved but most of it is simple visual styling as opposed to styling for javascript&amp;#8217;s sake.  Do, however, note where relative and absolute positioning is used.  The outermost DIV may be positioned absolutely if you&amp;#8217;d like.  Also note that I&amp;#8217;m not doing anything to accommodate for rounded corners in IE &amp;#8212; I recommend &lt;a
href="http://www.dillerdesign.com/experiment/DD_roundies/" rel="nofollow" target="_blank"&gt;DD_Roundies&lt;/a&gt; for that.&lt;/p&gt;&lt;h2&gt;The jQuery Javascript&lt;/h2&gt;&lt;pre class="javascript"&gt;
$(document).ready(function() {
	/* for keeping track of what's "open" */
	var activeClass = 'dropdown-active', showingDropdown, showingMenu, showingParent;
	/* hides the current menu */
	var hideMenu = function() {
		if(showingDropdown) {
			showingDropdown.removeClass(activeClass);
			showingMenu.hide();
		}
	};
	
	/* recurse through dropdown menus */
	$('.dropdown').each(function() {
		/* track elements: menu, parent */
		var dropdown = $(this);
		var menu = dropdown.next('div.dropdown-menu'), parent = dropdown.parent();
		/* function that shows THIS menu */
		var showMenu = function() {
			hideMenu();
			showingDropdown = dropdown.addClass('dropdown-active');
			showingMenu = menu.show();
			showingParent = parent;
		};
		/* function to show menu when clicked */
		dropdown.bind('click',function(e) {
			if(e) e.stopPropagation();
			if(e) e.preventDefault();
			showMenu();
		});
		/* function to show menu when someone tabs to the box */
		dropdown.bind('focus',function() {
			showMenu();
		});
	});
	
	/* hide when clicked outside */
	$(document.body).bind('click',function(e) {
		if(showingParent) {
			var parentElement = showingParent[0];
			if(!$.contains(parentElement,e.target) || !parentElement == e.target) {
				hideMenu();
			}
		}
	});
});

&lt;/pre&gt;&lt;p&gt;I&amp;#8217;ve commented to the code to illustrate what each block does.  In a nutshell:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;I create placeholder variables which will keep track of the current menu, dropdown, and parent for the opened menu&lt;em&gt;.&lt;/em&gt; This functionality is only included because I don&amp;#8217;t want more than one menu to be open at a time.&lt;/li&gt;&lt;li&gt;I create a function that hides the current menu &amp;#8212; this can be used from anywhere within the closure.&lt;/li&gt;&lt;li&gt;I cycle through each dropdown and add events to relevant elements to show and hide menus.&lt;/li&gt;&lt;li&gt;I add an event to the body to close the current menu if the user clicks outside of the menu.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;That&amp;#8217;s it!&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/twitter-dropdown-jquery.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Be sure to check out the &lt;a
href="http://davidwalsh.name/twitter-dropdown"&gt;MooTools version&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/twitter-dropdown-jquery"&gt;Create Twitter-Style Dropdowns Using&amp;nbsp;jQuery&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/twitter-dropdown' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&amp;nbsp;MooTools'&gt;Create Twitter-Style Dropdowns Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-outter-click' rel='bookmark' title='Permanent Link: Track Clicks Outside Active Elements with MooTools or&amp;nbsp;jQuery'&gt;Track Clicks Outside Active Elements with MooTools or&amp;nbsp;jQuery&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/search-options' rel='bookmark' title='Permanent Link: Search Type Options with&amp;nbsp;MooTools'&gt;Search Type Options with&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/snook-navigation-mootools' rel='bookmark' title='Permanent Link: Create Snook-Style Navigation Using&amp;nbsp;MooTools'&gt;Create Snook-Style Navigation Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/animated-button' rel='bookmark' title='Permanent Link: Create an Animated Sliding Button Using&amp;nbsp;MooTools'&gt;Create an Animated Sliding Button Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/Mzq_zynfAK8" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/twitter-dropdown-jquery#comments" thr:count="6" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/twitter-dropdown-jquery/feed/atom" thr:count="6" /> <thr:total>6</thr:total> <feedburner:origLink>http://davidwalsh.name/twitter-dropdown-jquery</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Book Review: MooTools 1.2 Beginner’s&#160;Guide]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/p_Au0dxU23Q/mootools-book" /> <id>http://davidwalsh.name/?p=4931</id> <updated>2010-03-12T03:49:53Z</updated> <published>2010-03-12T03:49:53Z</published> <category scheme="http://davidwalsh.name" term="Books" /><category scheme="http://davidwalsh.name" term="MooTools" /> <summary type="html"><![CDATA[In the interest in full disclosure, I was sent this book by Packt Publishing in hopes that I would review it.  I’m reviewing this  book, however, in the interest of my audience.Unless you live under a rock or simply check my site for Christina Ricci pics every morning, you know I&#8217;m a bit [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/mootools-book">Book Review: MooTools 1.2 Beginner’s&nbsp;Guide</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/book-review-enterprise-ajax-strategies-building-high-performance-web-applications' rel='bookmark' title='Permanent Link: Book Review:  Enterprise Ajax &#8212; Strategies For Building High Performance Web&nbsp;Applications'>Book Review:  Enterprise Ajax &#8212; Strategies For Building High Performance Web&nbsp;Applications</a></li><li><a
href='http://davidwalsh.name/php5-cms-framework-development' rel='bookmark' title='Permanent Link: Book Review:  PHP5 CMS Framework&nbsp;Development'>Book Review:  PHP5 CMS Framework&nbsp;Development</a></li><li><a
href='http://davidwalsh.name/book-review-wicked-cool-php' rel='bookmark' title='Permanent Link: Book Review:  Wicked Cool&nbsp;PHP'>Book Review:  Wicked Cool&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/book-review-ajax-security-addison-wesley' rel='bookmark' title='Permanent Link: Book Review:  Ajax&nbsp;Security'>Book Review:  Ajax&nbsp;Security</a></li><li><a
href='http://davidwalsh.name/free-sitepoint-ruby-on-rails-book' rel='bookmark' title='Permanent Link: Free SitePoint Ruby on Rails&nbsp;Book!'>Free SitePoint Ruby on Rails&nbsp;Book!</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/mootools-book">&lt;img
src="http://davidwalsh.name/dw-content/mootools-beginners.png" alt="MooTools Book" class="image" /&gt;&lt;p&gt;&lt;em&gt;In the interest in full disclosure, I was sent this book by Packt Publishing in hopes that I would review it.  I’m reviewing this  book, however, in the interest of my audience.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Unless you live under a rock or simply check my site for Christina Ricci pics every morning, you know I&amp;#8217;m a bit of a MooTools fanboy.  I spend hours every day writing MooTools tutorials, getting in touch with the MooTools community and development team members, and oh yeah&amp;#8230;coding a bit too.  When it was brought to my attention that Jacob Gube and Garrick Cheung had written a MooTools book for beginners, I was really excited to check it out.  The following are my thoughts on their book.&lt;/p&gt;&lt;h2&gt;The Authors&lt;/h2&gt;&lt;p&gt;Jacob Gube, Garrick Cheung&lt;/p&gt;&lt;h2&gt;The Tagline&lt;/h2&gt;&lt;p&gt;Learn how to create dynamic, interactive, and responsive cross-browser web applications using this popular JavaScript framework.&lt;/p&gt;&lt;h2&gt;Shooting From the Hip&lt;/h2&gt;&lt;p&gt;Instead of giving you this super long review that you wont read, I&amp;#8217;ve decided to put my thoughts into bullet format.  How clever!&lt;/p&gt;&lt;ul&gt;&lt;li&gt;What I really love about this book is that it&amp;#8217;s not a bunch of &amp;#8220;theory&amp;#8221; information &amp;#8212; it&amp;#8217;s no-nonsense, code-based learning.  I LOVE these style of books.&lt;/li&gt;&lt;li&gt;The book is ~ 150 pages, which is about right for a beginner&amp;#8217;s guide.  Making it too long would be a huge mistake.&lt;/li&gt;&lt;li&gt;The price point is $40.  Reasonable.&lt;/li&gt;&lt;li&gt;The book covers a large array of sample projects and code examples &amp;#8212; you aren&amp;#8217;t looking at the same code snippets everywhere.  Awesome.&lt;/li&gt;&lt;li&gt;One gripe is that I don&amp;#8217;t recall the book ever discussing the difference between MooTools and similar libraries like jQuery, Dojo, etc.  MooTools&amp;#8217; object-oriented architecture and the idea of modifying native object prototypes is core to the framework and differentiates MooTools from other libraries.  That really should be included in a &amp;#8220;version 2&amp;#8243; book.&lt;/li&gt;&lt;li&gt;I was not included as a MooTools resource &amp;#8212; clearly an oversight.  Hahaha.&lt;/li&gt;&lt;li&gt;The book *does* cover creating a unique build of MooTools Core and -More.  This is very important as beginners should know that MooTools is built to be incredibly modular and Moo programmers should code with that same idea in mind.&lt;/li&gt;&lt;li&gt;The book flows very well and the progression of difficulty is perfect.  Beginners will really appreciate the pace of the book.&lt;/li&gt;&lt;li&gt;While Jacob isn&amp;#8217;t a member of the team, he co-authored with contributor Garrick Cheung and asked Christoph Pojer, a MooTools Core Developer, to be technical reviewer.  Involving people very close to the team was a great idea; it helps the book&amp;#8217;s credibility and allows for all options to be considered. &lt;em&gt;*  I don&amp;#8217;t mean to say this to discredit Jacob &amp;#8212; he&amp;#8217;s done a great job with this book and you certainly don&amp;#8217;t need to be a team member/contributor to be a MooTools expert.&lt;/em&gt;&lt;/li&gt;&lt;li&gt;I know it&amp;#8217;s Packt&amp;#8217;s style, but the &amp;#8220;Impact&amp;#8221;-style heading fonts are ugly.&lt;/li&gt;&lt;li&gt;The book doesn&amp;#8217;t try to explain or gloss over basic javascript.  Thank you, thank you, thank you!&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;The Verdict&lt;/h2&gt;&lt;p&gt;I was very impressed with this book and I believe it&amp;#8217;s the perfect book for any developer looking to enter the MooTools pastures.  My only major desire is that the book cover MooTools&amp;#8217; native object prototype modification; beside that oversight, I&amp;#8217;d recommend this book to both rookie and novice MooTools developers.  MooTools 1.2 Beginner&amp;#8217;s Guide should be required reading for MooTools developers looking to master the basic of MooTools.&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/mootools-book"&gt;Book Review: MooTools 1.2 Beginner’s&amp;nbsp;Guide&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/book-review-enterprise-ajax-strategies-building-high-performance-web-applications' rel='bookmark' title='Permanent Link: Book Review:  Enterprise Ajax &amp;#8212; Strategies For Building High Performance Web&amp;nbsp;Applications'&gt;Book Review:  Enterprise Ajax &amp;#8212; Strategies For Building High Performance Web&amp;nbsp;Applications&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/php5-cms-framework-development' rel='bookmark' title='Permanent Link: Book Review:  PHP5 CMS Framework&amp;nbsp;Development'&gt;Book Review:  PHP5 CMS Framework&amp;nbsp;Development&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/book-review-wicked-cool-php' rel='bookmark' title='Permanent Link: Book Review:  Wicked Cool&amp;nbsp;PHP'&gt;Book Review:  Wicked Cool&amp;nbsp;PHP&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/book-review-ajax-security-addison-wesley' rel='bookmark' title='Permanent Link: Book Review:  Ajax&amp;nbsp;Security'&gt;Book Review:  Ajax&amp;nbsp;Security&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/free-sitepoint-ruby-on-rails-book' rel='bookmark' title='Permanent Link: Free SitePoint Ruby on Rails&amp;nbsp;Book!'&gt;Free SitePoint Ruby on Rails&amp;nbsp;Book!&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/p_Au0dxU23Q" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/mootools-book#comments" thr:count="9" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/mootools-book/feed/atom" thr:count="9" /> <thr:total>9</thr:total> <feedburner:origLink>http://davidwalsh.name/mootools-book</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Create Twitter-Style Dropdowns Using&#160;MooTools]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/vLJOw8pbrQE/twitter-dropdown" /> <id>http://davidwalsh.name/?p=4929</id> <updated>2010-03-11T14:05:57Z</updated> <published>2010-03-11T14:05:57Z</published> <category scheme="http://davidwalsh.name" term="CSS / Design" /><category scheme="http://davidwalsh.name" term="MooTools" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /> <summary type="html"><![CDATA[Twitter does some great stuff with javascript.  What I really appreciate about what they do is that there aren&#8217;t any epic JS functionalities &#8212; they&#8217;re all simple touches.  One of those simple touches is the &#8220;Login&#8221; dropdown on their homepage.  I&#8217;ve taken some time to duplicate that functionality with MooTools.View DemoThe HTML&#60;div [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/twitter-dropdown">Create Twitter-Style Dropdowns Using&nbsp;MooTools</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;jQuery'>Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/search-options' rel='bookmark' title='Permanent Link: Search Type Options with&nbsp;MooTools'>Search Type Options with&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/snook-navigation-mootools' rel='bookmark' title='Permanent Link: Create Snook-Style Navigation Using&nbsp;MooTools'>Create Snook-Style Navigation Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/animated-button' rel='bookmark' title='Permanent Link: Create an Animated Sliding Button Using&nbsp;MooTools'>Create an Animated Sliding Button Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/skype-mootools' rel='bookmark' title='Permanent Link: Skype-Style Buttons Using&nbsp;MooTools'>Skype-Style Buttons Using&nbsp;MooTools</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/twitter-dropdown">&lt;a
href="http://davidwalsh.name/dw-content/twitter-dropdown.php"&gt;&lt;img
src="http://davidwalsh.name/dw-content/fail-whale.png" alt="Twitter Dropdown" class="image" /&gt;&lt;/a&gt;&lt;p&gt;Twitter does some great stuff with javascript.  What I really appreciate about what they do is that there aren&amp;#8217;t any epic JS functionalities &amp;#8212; they&amp;#8217;re all simple touches.  One of those simple touches is the &amp;#8220;Login&amp;#8221; dropdown on their homepage.  I&amp;#8217;ve taken some time to duplicate that functionality with MooTools.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/twitter-dropdown.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;The HTML&lt;/h2&gt;&lt;pre class="html"&gt;
&amp;lt;div id=&amp;quot;menu1&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;relative&amp;quot;&amp;gt;
	&amp;lt;a href=&amp;quot;/demos&amp;quot; title=&amp;quot;Popular MooTools Tutorials&amp;quot; id=&amp;quot;dd1&amp;quot; class=&amp;quot;dropdown&amp;quot; style=&amp;quot;width:170px;text-decoration:none;&amp;quot;&amp;gt;&amp;lt;span&amp;gt;Menu 1&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;
	&amp;lt;div id=&amp;quot;dropdown1&amp;quot; class=&amp;quot;dropdown-menu&amp;quot;&amp;gt;
		&amp;lt;a href=&amp;quot;/about-david-walsh&amp;quot; title=&amp;quot;Learn a bit about me.&amp;quot;&amp;gt;About Me&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/page/1&amp;quot; title=&amp;quot;The David Walsh Blog&amp;quot;&amp;gt;Blog&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/chat&amp;quot; title=&amp;quot;#davidwalshblog IRC Chat&amp;quot;&amp;gt;Chat&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/contact&amp;quot; title=&amp;quot;Contact David Walsh&amp;quot;&amp;gt;Contact Me&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/demos&amp;quot; title=&amp;quot;CSS, PHP, jQuery, MooTools Demos&amp;quot;&amp;gt;Demos &amp;amp;amp; Downloads&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/js&amp;quot; title=&amp;quot;ScrollSpy, Lazyload, Overlay, Context Menu&amp;quot;&amp;gt;MooTools Plugins&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/network&amp;quot; title=&amp;quot;David Walsh Blog, Script &amp;amp;amp; Style, Band Website Template, Wynq&amp;quot;&amp;gt;Network&amp;lt;/a&amp;gt;
		&amp;lt;a href=&amp;quot;/web-development-tools&amp;quot; title=&amp;quot;JS, CSS Compression&amp;quot;&amp;gt;Web Dev Tools&amp;lt;/a&amp;gt;
	&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div id=&amp;quot;menu2&amp;quot;&amp;gt;&amp;lt;div class=&amp;quot;relative&amp;quot;&amp;gt;
	&amp;lt;a href=&amp;quot;/demos&amp;quot; title=&amp;quot;Popular MooTools Tutorials&amp;quot; id=&amp;quot;dd2&amp;quot; class=&amp;quot;dropdown&amp;quot; rel=&amp;quot;dropdown2&amp;quot; style=&amp;quot;width:170px;text-decoration:none;&amp;quot;&amp;gt;&amp;lt;span&amp;gt;Menu 2&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;
	&amp;lt;div id=&amp;quot;dropdown2&amp;quot; class=&amp;quot;dropdown-menu&amp;quot;&amp;gt;
		&amp;lt;p&amp;gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.&amp;lt;/p&amp;gt;
	&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;
&lt;/pre&gt;&lt;p&gt;A series of DIVS wrapping a link (the dropdown &amp;#8220;trigger&amp;#8221;) and a DIV containing the menu items.&lt;/p&gt;&lt;h2&gt;The CSS&lt;/h2&gt;&lt;pre class="css"&gt;
/* dropdowns: general */
a.dropdown { background: #88bbd4; padding: 4px 6px 6px; text-decoration: none; font-weight: bold; color: #fff; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; }
a.dropdown:hover { background: #59b; }
a.dropdown { position: relative; margin-left: 3px; }
a.dropdown span { background-image: url(toggle_down_light.png); background-repeat: no-repeat; background-position: 100% 50%; padding: 4px 16px 6px 0; }
a.dropdown.dropdown-active { color:#59b; background-color:#ddeef6; }
a.dropdown.dropdown-active span { background:url(toggle_up_dark.png) 100% 50% no-repeat; }
.dropdown-menu	{ background:#ddeef6; padding:7px 12px; position:absolute; top:16px; right:0; display:none; z-index:5000; -moz-border-radius-topleft: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-top-left-radius: 5px; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; }
	.dropdown-menu p { font-size:11px; }
.dropdown-menu a:link, .dropdown-menu a:visited	{ font-weight:bold; color:#59b; text-decoration:none; line-height:1.7em; }
.dropdown-menu a:active, .dropdown-menu a:hover { color:#555; }

/* dropdowns: specific */
#menu1			{ float:left; margin-right:20px; }
	#dropdown1	{ width:150px; }
	#dropdown1 a	{ display:block; }
#menu2			{ float:left; }
	#dropdown2	{ width:150px; font-size:11px; }
.relative		{ position:relative; }
&lt;/pre&gt;&lt;p&gt;There&amp;#8217;s a lot of CSS involved but most of it is simple visual styling as opposed to styling for javascript&amp;#8217;s sake.  Do, however, note where relative and absolute positioning is used.  The outermost DIV may be positioned absolutely if you&amp;#8217;d like.  Also note that I&amp;#8217;m not doing anything to accommodate for rounded corners in IE &amp;#8212; I recommend &lt;a
href="http://www.dillerdesign.com/experiment/DD_roundies/" rel="nofollow" target="_blank"&gt;DD_Roundies&lt;/a&gt; for that.&lt;/p&gt;&lt;h2&gt;The MooTools Javascript&lt;/h2&gt;&lt;pre class="javascript"&gt;
window.addEvent('domready',function() {
	(function($) {
		/* for keeping track of what's &amp;quot;open&amp;quot; */
		var activeClass = 'dropdown-active', showingDropdown, showingMenu, showingParent;
		/* hides the current menu */
		var hideMenu = function() {
			if(showingDropdown) {
				showingDropdown.removeClass(activeClass);
				showingMenu.setStyle('display','none');
			}
		};
		/* recurse through dropdown menus */
		$$('.dropdown').each(function(dropdown) {
			/* track elements: menu, parent */
			var menu = dropdown.getNext('div.dropdown-menu'), parent = dropdown.getParent('div');
			/* function that shows THIS menu */
			var showMenu = function() {
				hideMenu();
				showingDropdown = dropdown.addClass('dropdown-active');
				showingMenu = menu.setStyle('display','block');
				showingParent = parent;
			};
			/* function to show menu when clicked */
			dropdown.addEvent('click',function(e) {
				if(e) e.stop();
				showMenu();
			});
			/* function to show menu when someone tabs to the box */
			dropdown.addEvent('focus',function() {
				showMenu();
			});
		});
		/* hide when clicked outside */
		$(document.body).addEvent('click',function(e) {
			if(showingParent &amp;amp;&amp;amp; !e.target || !$(e.target).getParents().contains(showingParent)) { 
				hideMenu();
			}
		});
	})(document.id);
});
&lt;/pre&gt;&lt;p&gt;I&amp;#8217;ve commented to the code to illustrate what each block does.  In a nutshell:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;I create placeholder variables which will keep track of the current menu, dropdown, and parent for the opened menu&lt;em&gt;.&lt;/em&gt; This functionality is only included because I don&amp;#8217;t want more than one menu to be open at a time.&lt;/li&gt;&lt;li&gt;I create a function that hides the current menu &amp;#8212; this can be used from anywhere within the closure.&lt;/li&gt;&lt;li&gt;I cycle through each dropdown and add events to relevant elements to show and hide menus.&lt;/li&gt;&lt;li&gt;I add an event to the body to close the current menu if the user clicks outside of the menu.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;That&amp;#8217;s it!&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/twitter-dropdown.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Look forward to a MooTools Class version soon.  Also look forward to jQuery and Dojo versions!&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/twitter-dropdown"&gt;Create Twitter-Style Dropdowns Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&amp;nbsp;jQuery'&gt;Create Twitter-Style Dropdowns Using&amp;nbsp;jQuery&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/search-options' rel='bookmark' title='Permanent Link: Search Type Options with&amp;nbsp;MooTools'&gt;Search Type Options with&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/snook-navigation-mootools' rel='bookmark' title='Permanent Link: Create Snook-Style Navigation Using&amp;nbsp;MooTools'&gt;Create Snook-Style Navigation Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/animated-button' rel='bookmark' title='Permanent Link: Create an Animated Sliding Button Using&amp;nbsp;MooTools'&gt;Create an Animated Sliding Button Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/skype-mootools' rel='bookmark' title='Permanent Link: Skype-Style Buttons Using&amp;nbsp;MooTools'&gt;Skype-Style Buttons Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/vLJOw8pbrQE" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/twitter-dropdown#comments" thr:count="15" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/twitter-dropdown/feed/atom" thr:count="15" /> <thr:total>15</thr:total> <feedburner:origLink>http://davidwalsh.name/twitter-dropdown</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Introducing MooTools&#160;NextPrev]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/6-Mk8xz5t9Y/mootools-nextprev" /> <id>http://davidwalsh.name/?p=4796</id> <updated>2010-03-10T14:04:46Z</updated> <published>2010-03-10T14:04:46Z</published> <category scheme="http://davidwalsh.name" term="MooTools" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /> <summary type="html"><![CDATA[One thing I love doing is duplicating OS functionalities.  One of the things your OS allows you to do easily is move from one item to another.  Most of the time you&#8217;re simply trying to get to the next or the previous item.  MooTools NextPrev is a compact javascript class that allows [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/mootools-nextprev">Introducing MooTools&nbsp;NextPrev</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-elementspy' rel='bookmark' title='Permanent Link: Introducing MooTools&nbsp;ElementSpy'>Introducing MooTools&nbsp;ElementSpy</a></li><li><a
href='http://davidwalsh.name/mootools-dotter' rel='bookmark' title='Permanent Link: Introducing MooTools&nbsp;Dotter'>Introducing MooTools&nbsp;Dotter</a></li><li><a
href='http://davidwalsh.name/mootools-lazyload' rel='bookmark' title='Permanent Link: Introducing MooTools&nbsp;LazyLoad'>Introducing MooTools&nbsp;LazyLoad</a></li><li><a
href='http://davidwalsh.name/introducing-mootools-cache' rel='bookmark' title='Permanent Link: Introducing MooTools&nbsp;Cache'>Introducing MooTools&nbsp;Cache</a></li><li><a
href='http://davidwalsh.name/mootools-link-alert' rel='bookmark' title='Permanent Link: Introducing MooTools&nbsp;LinkAlert'>Introducing MooTools&nbsp;LinkAlert</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/mootools-nextprev">&lt;p&gt;&lt;a
href="http://davidwalsh.name/dw-content/next-prev.php"&gt;&lt;img
src="http://davidwalsh.name/dw-content/nextprev.jpg" alt="MooTools NextPrev" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;One thing I love doing is duplicating OS functionalities.  One of the things your OS allows you to do easily is move from one item to another.  Most of the time you&amp;#8217;re simply trying to get to the next or the previous item.  MooTools NextPrev is a compact javascript class that allows you to move about a collection of items quickly using human terms.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/next-prev.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;The MooTools Class&lt;/h2&gt;&lt;pre class="js"&gt;
var NextPrev = new Class({
	Implements: [Options,Events],
	options: {
		baseEvent: 'keyup',
		eventContainer: document,
		eventCheckNext: function(e){
			return true;
		},
		eventCheckPrevious: function(e){ 
			return true;
		},
		onLoad: $empty,
		onNext: $empty,
		onPrevious: $empty,
		startIndex: 0
	},
	initialize: function(collection,options) {
		this.setOptions(options);
		this.collection = $$(collection);
		if(this.options.container == document) this.options.container = document.body;
		this.index = this.options.startIndex;
		if(this.options.baseEvent) {
			$(this.options.eventContainer).addEvent(this.options.baseEvent,function(e) {
				if(this.options.eventCheckNext(e)) {
					this.move.bind(this)('next');
				}
				else if(this.options.eventCheckPrevious(e)) {
					this.move.bind(this)('previous');
				}
			}.bind(this));
		}
		this.fireEvent('load',[this.collection[this.index]]);
	},
	move: function(norp) {
		var previous = this.index;
		switch($type(norp)) {
			case 'string':
				var ev = 'next';
				if(norp == 'next') {
					var plus = this.index + 1;
					this.index = this.collection[plus] ? plus : 0;
				}
				else {
					var minus = this.index - 1;
					this.index = this.collection[minus] ? minus : this.collection.length-1;
					ev = 'previous';
				}
				this.fireEvent(ev,[this.collection[this.index],this.collection[previous]]);
				break;
			case 'element':
				this.index = this.collection.indexOf(norp) || 0;
				break;
			default:
				this.index = norp;
				break;
		}
		this.fireEvent('change',[this.collection[this.index],this.collection[previous]]);
		return this;
	}
});
&lt;/pre&gt;&lt;p&gt;The following are arguments, options, and events for NextPrev:&lt;/p&gt;&lt;h3&gt;Arguments&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;span
class="function"&gt;collection&lt;/span&gt;: The collection of elements..&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;options&lt;/span&gt;: The instance options.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;Options&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;span
class="function"&gt;baseEvent&lt;/span&gt;: &lt;em&gt;(defaults to &amp;#8216;keyup&amp;#8217;)&lt;/em&gt; The event to listen to.&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;eventContainer&lt;/span&gt;: &lt;em&gt;(defaults to document)&lt;/em&gt; The event listener container.&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;eventCheckNext&lt;/span&gt;: &lt;em&gt;(defaults to function)&lt;/em&gt; The function that decides if the conditions to trigger a &amp;#8220;next&amp;#8221; have been met.&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;eventCheckPrevious&lt;/span&gt;: &lt;em&gt;(defaults to function)&lt;/em&gt; The function that decides if the conditions to trigger a &amp;#8220;previous&amp;#8221; have been met.&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;startIndex&lt;/span&gt;: &lt;em&gt;(defaults to 0)&lt;/em&gt; The starting index for the collection.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;Events&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;span
class="function"&gt;change&lt;/span&gt;: Fired when the index changes.&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;load&lt;/span&gt;: Fired every time the class is initialized.&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;next&lt;/span&gt;: Fired when the next directive is triggered.&lt;/li&gt;&lt;li&gt;&lt;span
class="function"&gt;previous&lt;/span&gt;: Fired when the previous directive is triggered.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;Public Methods&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;span
class="function"&gt;move&lt;/span&gt;: May be passed the Strings &amp;#8220;next&amp;#8221; or &amp;#8220;prev&amp;#8221;, or a DOM node.&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Sample Usage&lt;/h2&gt;&lt;pre class="js"&gt;
var np2 = new NextPrev($$('#images img'),{
	eventCheckNext: function(e) {
		if(e) e.stop(e);
		return e.key == 'right';
	},
	eventCheckPrevious: function(e) {
		if(e) e.stop(e);
		return e.key == 'left';
	},
	onNext: function(cur,prev) {
		prev.removeClass('featured');
		cur.addClass('featured');
	},
	onPrevious: function(cur,prev) {
		prev.removeClass('featured');
		cur.addClass('featured');
	},
	onLoad: function(cur) {
		cur.addClass('featured');
	}
});
&lt;/pre&gt;&lt;p&gt;The code above hijacks the &amp;#8220;left&amp;#8221; and &amp;#8220;right&amp;#8221; keys, moving forward and backward in the collection depending on which key was pressed.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/next-prev.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;NextPrev is extremely simple but also quite flexible.  You decide the events, keys, actions, etc &amp;#8212; the plugin simple allows for simple control of position in the list.  Have ideas for this class?  Know what you&amp;#8217;d use it for?  Let me know!&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/mootools-nextprev"&gt;Introducing MooTools&amp;nbsp;NextPrev&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-elementspy' rel='bookmark' title='Permanent Link: Introducing MooTools&amp;nbsp;ElementSpy'&gt;Introducing MooTools&amp;nbsp;ElementSpy&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-dotter' rel='bookmark' title='Permanent Link: Introducing MooTools&amp;nbsp;Dotter'&gt;Introducing MooTools&amp;nbsp;Dotter&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-lazyload' rel='bookmark' title='Permanent Link: Introducing MooTools&amp;nbsp;LazyLoad'&gt;Introducing MooTools&amp;nbsp;LazyLoad&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/introducing-mootools-cache' rel='bookmark' title='Permanent Link: Introducing MooTools&amp;nbsp;Cache'&gt;Introducing MooTools&amp;nbsp;Cache&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-link-alert' rel='bookmark' title='Permanent Link: Introducing MooTools&amp;nbsp;LinkAlert'&gt;Introducing MooTools&amp;nbsp;LinkAlert&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/6-Mk8xz5t9Y" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/mootools-nextprev#comments" thr:count="7" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/mootools-nextprev/feed/atom" thr:count="7" /> <thr:total>7</thr:total> <feedburner:origLink>http://davidwalsh.name/mootools-nextprev</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Create a Simple News Scroller Using&#160;Dojo]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/I8s9Z63_jZI/news-scroller-dojo" /> <id>http://davidwalsh.name/?p=4925</id> <updated>2010-03-09T15:06:14Z</updated> <published>2010-03-09T14:09:36Z</published> <category scheme="http://davidwalsh.name" term="CSS / Design" /><category scheme="http://davidwalsh.name" term="Javascript" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /> <summary type="html"><![CDATA[My journey into Dojo javascript has been exciting and I&#8217;m continuing to learn more as I port MooTools scripts to Dojo.  My latest experiment is porting a simple new scroller from MooTools to Dojo.  The code is very similar!View DemoThe HTML
News Item 1Pellentesque habitant morbi...Read More
News Item 2Pellentesque habitant morbi...Read MoreThe news items [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/news-scroller-dojo">Create a Simple News Scroller Using&nbsp;Dojo</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-scroller' rel='bookmark' title='Permanent Link: Create a Simple News Scroller Using MooTools, Part I:  The&nbsp;Basics'>Create a Simple News Scroller Using MooTools, Part I:  The&nbsp;Basics</a></li><li><a
href='http://davidwalsh.name/mootools-slideshow-ii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part II:  Controls and&nbsp;Events'>Create a Simple Slideshow Using MooTools, Part II:  Controls and&nbsp;Events</a></li><li><a
href='http://davidwalsh.name/mootools-slideshow' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using&nbsp;MooTools'>Create a Simple Slideshow Using&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/create-a-simple-slideshow-iii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part III: Creating a&nbsp;Class'>Create a Simple Slideshow Using MooTools, Part III: Creating a&nbsp;Class</a></li><li><a
href='http://davidwalsh.name/slideshow-thumbnails-captions' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&nbsp;Captions'>Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&nbsp;Captions</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/news-scroller-dojo">&lt;a
href="http://davidwalsh.name/dw-content/news-scroller-dojo.php" class="demo"&gt;&lt;img
src="http://davidwalsh.name/dw-content/news-scroller-1.jpg" alt="" class="image" /&gt;&lt;/a&gt;&lt;p&gt;My journey into Dojo javascript has been exciting and I&amp;#8217;m continuing to learn more as I port MooTools scripts to Dojo.  My latest experiment is porting a &lt;a
href="http://davidwalsh.name/mootools-scroller"&gt;simple new scroller from MooTools&lt;/a&gt; to Dojo.  The code is very similar!&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/news-scroller-dojo.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;The HTML&lt;/h2&gt;&lt;pre class="html"&gt;
&lt;div id="news-feed"&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;strong style="font-size:14px;"&gt;News Item 1&lt;/strong&gt;&lt;br /&gt;Pellentesque habitant morbi...&lt;a href="#"&gt;Read More&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;strong style="font-size:14px;"&gt;News Item 2&lt;/strong&gt;&lt;br /&gt;Pellentesque habitant morbi...&lt;a href="/news/2"&gt;Read More&lt;/a&gt;&lt;/li&gt;
		
	&lt;/ul&gt;
&lt;/div&gt;
&lt;/pre&gt;&lt;p&gt;The news items are placed into list items.  The UL  will be the element that&amp;#8217;s animated.&lt;/p&gt;&lt;h2&gt;The CSS&lt;/h2&gt;&lt;pre class="css"&gt;
#news-feed	 { height:200px; width:300px; overflow:hidden; position:relative; border:1px solid #ccc; background:#eee; }
#news-feed ul	{ position:absolute; top:0; left:0; list-style-type:none; padding:0; margin:0; }
#news-feed ul li { min-height:180px; font-size:12px; margin:0; padding:10px; overflow:hidden; }
&lt;/pre&gt;&lt;p&gt;The absolute positioning is essential to proper animation.  Unlike my MooTools example, this example no longer requires a fixed height for each news item.  I did add a minimum height so only one item shows up within the scroller window at a time.&lt;/p&gt;&lt;h2&gt;The Dojo Javascript&lt;/h2&gt;&lt;pre class="js"&gt;
dojo.require('dojo.NodeList-fx');
dojo.addOnLoad(function() {
	/* settings */
	var list = dojo.query('#news-feed ul'),
		items = list.query("li"),
		showDuration = 3000,
		scrollDuration = 500,
		scrollTopDuration = 200,
		index = 0,
		interval;

	/* movement */
	var start = function() { interval = setInterval(move,showDuration); };
	var stop = function() { if(interval) clearInterval(interval); };
	var reset = function() {
	    list.anim({ top: 0}, scrollTopDuration, null, start);
	};
	/* action! */
	var move = function() {
	    list.anim({ top: (0 - (dojo.coords(items[++index]).t)) }, scrollDuration, null, function(){
			if(index == items.length - 1) {
				index = 0-1;
				stop();
				setTimeout(reset,showDuration);
			}
	    });
	};

	/* stop and start during mouseenter, mouseleave  */
	list.onmouseenter(stop).onmouseleave(start);

	/* go! */
	start();
});
&lt;/pre&gt;&lt;p&gt;This is where I have the epic description&amp;#8230;but the above code (at least for MooTools users) should look familiar.  The logic is exactly the same but the code uses &lt;span
class="function"&gt;dojo.*&lt;/span&gt; methods instead of MooTools&amp;#8217; &lt;span
class="function"&gt;Fx&lt;/span&gt;, &lt;span
class="function"&gt;$$&lt;/span&gt;, &lt;span
class="function"&gt;$&lt;/span&gt;, and &lt;span
class="function"&gt;Element.Dimensions&lt;/span&gt; methods.&lt;/p&gt;&lt;h2&gt;The MooTools Javascript&lt;/h2&gt;&lt;pre class="js"&gt;
window.addEvent('domready',function() {
	/* settings */
	var list = $('news-feed').getFirst('ul');
	var items = list.getElements('li');
	var showDuration = 3000;
	var scrollDuration = 500;
	var index = 0;
	var height = items[0].getSize().y;
	/* action func */
	var move = function() {
		list.set('tween',{
			duration: scrollDuration,
			onComplete: function() {
				if(index == items.length - 1) {
					index = 0 - 1;
					list.scrollTo(0,0);
				}
			}
		}).tween('top',0 - (++index * height));
	};
	/* go! */
	window.addEvent('load',function() {		
		move.periodical(showDuration);
	});
});
&lt;/pre&gt;&lt;p&gt;The above code was taken from my original post.  Take a moment to compare the Dojo and MooTools code.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/news-scroller-dojo.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;What do you think?  Three Dojo posts in &amp;#8212; what are your thoughts about Dojo to this point?&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/news-scroller-dojo"&gt;Create a Simple News Scroller Using&amp;nbsp;Dojo&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-scroller' rel='bookmark' title='Permanent Link: Create a Simple News Scroller Using MooTools, Part I:  The&amp;nbsp;Basics'&gt;Create a Simple News Scroller Using MooTools, Part I:  The&amp;nbsp;Basics&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-slideshow-ii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part II:  Controls and&amp;nbsp;Events'&gt;Create a Simple Slideshow Using MooTools, Part II:  Controls and&amp;nbsp;Events&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-slideshow' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using&amp;nbsp;MooTools'&gt;Create a Simple Slideshow Using&amp;nbsp;MooTools&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/create-a-simple-slideshow-iii' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part III: Creating a&amp;nbsp;Class'&gt;Create a Simple Slideshow Using MooTools, Part III: Creating a&amp;nbsp;Class&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/slideshow-thumbnails-captions' rel='bookmark' title='Permanent Link: Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&amp;nbsp;Captions'&gt;Create a Simple Slideshow Using MooTools, Part IV: Thumbnails and&amp;nbsp;Captions&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/I8s9Z63_jZI" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/news-scroller-dojo#comments" thr:count="2" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/news-scroller-dojo/feed/atom" thr:count="2" /> <thr:total>2</thr:total> <feedburner:origLink>http://davidwalsh.name/news-scroller-dojo</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[&#8220;MooTools as a General Purpose Application Framework&#8221; by Christoph&#160;Pojer]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/KDBF0XHHF5I/mootools-video" /> <id>http://davidwalsh.name/?p=4928</id> <updated>2010-03-08T21:31:21Z</updated> <published>2010-03-08T21:31:21Z</published> <category scheme="http://davidwalsh.name" term="MooTools" /> <summary type="html"><![CDATA[I wanted to bring attention to an outstanding presentation given by MooTools Core Developer Christoph Pojer.  Given at FOSDEM 2010, Christoph provides an overview of what MooTools is, who should use it, how it should be used.  Examples are given throughout the presentation. I highly recommend MooTools users of all experience levels watch this video, as [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/mootools-video">&#8220;MooTools as a General Purpose Application Framework&#8221; by Christoph&nbsp;Pojer</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/php5-cms-framework-development' rel='bookmark' title='Permanent Link: Book Review:  PHP5 CMS Framework&nbsp;Development'>Book Review:  PHP5 CMS Framework&nbsp;Development</a></li><li><a
href='http://davidwalsh.name/javascript-framework-considerations' rel='bookmark' title='Permanent Link: 8 Considerations For Choosing Your Javascript&nbsp;Framework'>8 Considerations For Choosing Your Javascript&nbsp;Framework</a></li><li><a
href='http://davidwalsh.name/contribute-javascript-framework' rel='bookmark' title='Permanent Link: 5 Ways to Contribute to Your Favorite Javascript&nbsp;Framework'>5 Ways to Contribute to Your Favorite Javascript&nbsp;Framework</a></li><li><a
href='http://davidwalsh.name/javascript-frameworks-fight-mootools-jquery-prototype' rel='bookmark' title='Permanent Link: When Javascript Frameworks&nbsp;Collide'>When Javascript Frameworks&nbsp;Collide</a></li><li><a
href='http://davidwalsh.name/mootools-dollar-safe-mode' rel='bookmark' title='Permanent Link: MooTools, Framework Compatibility, and Dollar $afe&nbsp;Mode'>MooTools, Framework Compatibility, and Dollar $afe&nbsp;Mode</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/mootools-video">&lt;p&gt;I wanted to bring attention to an outstanding presentation given by MooTools Core Developer &lt;a
href="http://cpojer.net" target="_blank" rel="nofollow"&gt;Christoph Pojer&lt;/a&gt;.  Given at &lt;a
href="http://fosdem.org/2010/" target="_blank" rel="nofollow"&gt;FOSDEM&lt;/a&gt; 2010, Christoph provides an overview of what MooTools is, who should use it, how it should be used.  Examples are given throughout the presentation. &lt;/p&gt; &lt;br
/&gt; &lt;object
width="425" height="344"&gt;&lt;param
name="movie" value="http://www.youtube.com/v/6nOVQDMOvvE&amp;#038;color1=0xb1b1b1&amp;#038;color2=0xcfcfcf&amp;#038;hl=en_US&amp;#038;feature=player_embedded&amp;#038;fs=1"&gt;&lt;/param&gt;&lt;param
name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param
name="allowScriptAccess" value="always"&gt;&lt;/param&gt;&lt;embed
src="http://www.youtube.com/v/6nOVQDMOvvE&amp;#038;color1=0xb1b1b1&amp;#038;color2=0xcfcfcf&amp;#038;hl=en_US&amp;#038;feature=player_embedded&amp;#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;p&gt; I highly recommend MooTools users of all experience levels watch this video, as well as jQuery or Dojo users looking to simply understand what this framework is about.&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/mootools-video"&gt;&amp;#8220;MooTools as a General Purpose Application Framework&amp;#8221; by Christoph&amp;nbsp;Pojer&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/php5-cms-framework-development' rel='bookmark' title='Permanent Link: Book Review:  PHP5 CMS Framework&amp;nbsp;Development'&gt;Book Review:  PHP5 CMS Framework&amp;nbsp;Development&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/javascript-framework-considerations' rel='bookmark' title='Permanent Link: 8 Considerations For Choosing Your Javascript&amp;nbsp;Framework'&gt;8 Considerations For Choosing Your Javascript&amp;nbsp;Framework&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/contribute-javascript-framework' rel='bookmark' title='Permanent Link: 5 Ways to Contribute to Your Favorite Javascript&amp;nbsp;Framework'&gt;5 Ways to Contribute to Your Favorite Javascript&amp;nbsp;Framework&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/javascript-frameworks-fight-mootools-jquery-prototype' rel='bookmark' title='Permanent Link: When Javascript Frameworks&amp;nbsp;Collide'&gt;When Javascript Frameworks&amp;nbsp;Collide&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-dollar-safe-mode' rel='bookmark' title='Permanent Link: MooTools, Framework Compatibility, and Dollar $afe&amp;nbsp;Mode'&gt;MooTools, Framework Compatibility, and Dollar $afe&amp;nbsp;Mode&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/KDBF0XHHF5I" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/mootools-video#comments" thr:count="0" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/mootools-video/feed/atom" thr:count="0" /> <thr:total>0</thr:total> <feedburner:origLink>http://davidwalsh.name/mootools-video</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Remove Broken Images Using&#160;Dojo]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/T-RyuXs-aNw/remove-images-dojo" /> <id>http://davidwalsh.name/?p=4921</id> <updated>2010-03-02T13:22:47Z</updated> <published>2010-03-02T13:22:47Z</published> <category scheme="http://davidwalsh.name" term="Javascript" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /> <summary type="html"><![CDATA[In an effort to get better with the Dojo Toolkit, I&#8217;ve decided to port yet another one of my previous posts:  Remove Broken Images Using MooTools or jQuery.  Broken images are an eyesore to any website so there&#8217;s no point to keeping them in the page.  Here&#8217;s how you can remove them [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/remove-images-dojo">Remove Broken Images Using&nbsp;Dojo</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/remove-broken-images' rel='bookmark' title='Permanent Link: Remove Broken Images Using MooTools or&nbsp;jQuery'>Remove Broken Images Using MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/email-image-error-mootools' rel='bookmark' title='Permanent Link: Send Email Notifications for Broken Images Using MooTools&nbsp;Ajax'>Send Email Notifications for Broken Images Using MooTools&nbsp;Ajax</a></li><li><a
href='http://davidwalsh.name/broken-images-jquery-ajax' rel='bookmark' title='Permanent Link: Send Email Notifications for Broken Images Using jQuery&nbsp;Ajax'>Send Email Notifications for Broken Images Using jQuery&nbsp;Ajax</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/quickboxes-dojo' rel='bookmark' title='Permanent Link: QuickBoxes for&nbsp;Dojo'>QuickBoxes for&nbsp;Dojo</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/remove-images-dojo">&lt;p&gt;In an effort to get better with the Dojo Toolkit, I&amp;#8217;ve decided to port yet another one of my previous posts: &lt;a
href="http://davidwalsh.name/remove-broken-images"&gt;Remove Broken Images Using MooTools or jQuery&lt;/a&gt;.  Broken images are an eyesore to any website so there&amp;#8217;s no point to keeping them in the page.  Here&amp;#8217;s how you can remove them on the client side.&lt;/p&gt;&lt;h2&gt;The Dojo Javascript&lt;/h2&gt;&lt;pre class="js"&gt;
dojo.ready(function() {
	dojo.query('img').forEach(function(img){
		dojo.connect(img,'onerror',function() {
			dojo.destroy(img);
		});
	});
});
&lt;/pre&gt;&lt;p&gt;Just as simple as jQuery and MooTools &amp;#8212; just a different syntax!&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/remove-images-dojo"&gt;Remove Broken Images Using&amp;nbsp;Dojo&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/remove-broken-images' rel='bookmark' title='Permanent Link: Remove Broken Images Using MooTools or&amp;nbsp;jQuery'&gt;Remove Broken Images Using MooTools or&amp;nbsp;jQuery&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/email-image-error-mootools' rel='bookmark' title='Permanent Link: Send Email Notifications for Broken Images Using MooTools&amp;nbsp;Ajax'&gt;Send Email Notifications for Broken Images Using MooTools&amp;nbsp;Ajax&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/broken-images-jquery-ajax' rel='bookmark' title='Permanent Link: Send Email Notifications for Broken Images Using jQuery&amp;nbsp;Ajax'&gt;Send Email Notifications for Broken Images Using jQuery&amp;nbsp;Ajax&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/link-nudging-dojo' rel='bookmark' title='Permanent Link: Link Nudging Using&amp;nbsp;Dojo'&gt;Link Nudging Using&amp;nbsp;Dojo&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/quickboxes-dojo' rel='bookmark' title='Permanent Link: QuickBoxes for&amp;nbsp;Dojo'&gt;QuickBoxes for&amp;nbsp;Dojo&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/T-RyuXs-aNw" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/remove-images-dojo#comments" thr:count="5" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/remove-images-dojo/feed/atom" thr:count="5" /> <thr:total>5</thr:total> <feedburner:origLink>http://davidwalsh.name/remove-images-dojo</feedburner:origLink></entry> <entry> <author> <name>David Walsh</name> <uri>http://davidwalsh.name</uri> </author><title type="html"><![CDATA[Link Nudging Using&#160;Dojo]]></title><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Bludice/~3/jMx7h9P6F78/link-nudging-dojo" /> <id>http://davidwalsh.name/?p=4909</id> <updated>2010-03-03T15:30:04Z</updated> <published>2010-03-01T13:58:20Z</published> <category scheme="http://davidwalsh.name" term="CSS / Design" /><category scheme="http://davidwalsh.name" term="Javascript" /><category scheme="http://davidwalsh.name" term="XML / XHTML" /> <summary type="html"><![CDATA[In the past we&#8217;ve tinkered with link nudging with MooTools and link nudging with jQuery.  In an effort to familiarize myself with other javascript frameworks, we&#8217;re going to try to duplicate that effect with another awesome framework:  Dojo.View DemoThe Javascript:  Attempt 1dojo.addOnLoad(function() {
var links = dojo.query('a.nudge');
//foreach...
dojo.forEach(links,function(link) {
var left = dojo.style(link,'paddingLeft');
dojo.connect(link,'onmouseenter',function() {
dojo.animateProperty({
node:link,
properties: {
paddingLeft: [...]<p>Don't forget to <a
href="http://twitter.com/davidwalshblog">follow me on Twitter</a> and be sure to visit <a
href="http://scriptandstyle.com">Script & Style</a> for the best Javascript and CSS articles around!<a
href="http://buysellads.com/buy/detail/1687">Sponsor the David Walsh Blog</a> and get your brand in front of several thousand users per day!<br/><br/><a
href="http://davidwalsh.name/link-nudging-dojo">Link Nudging Using&nbsp;Dojo</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/jquery-link-nudging' rel='bookmark' title='Permanent Link: jQuery Link&nbsp;Nudging'>jQuery Link&nbsp;Nudging</a></li><li><a
href='http://davidwalsh.name/news-scroller-dojo' rel='bookmark' title='Permanent Link: Create a Simple News Scroller Using&nbsp;Dojo'>Create a Simple News Scroller Using&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/quickboxes-dojo' rel='bookmark' title='Permanent Link: QuickBoxes for&nbsp;Dojo'>QuickBoxes for&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/mootools-link-nudging' rel='bookmark' title='Permanent Link: MooTools Link&nbsp;Nudging'>MooTools Link&nbsp;Nudging</a></li></ol>]]></summary> <content type="html" xml:base="http://davidwalsh.name/link-nudging-dojo">&lt;a
href="http://davidwalsh.name/dw-content/dojo-nudge.php"&gt;&lt;img
src="http://davidwalsh.name/dw-content/dojo-logo.jpg" alt="Dojo Toolkit" class="image" /&gt;&lt;/a&gt;&lt;p&gt;In the past we&amp;#8217;ve tinkered with &lt;a
href="http://davidwalsh.name/mootools-link-nudging"&gt;link nudging with MooTools&lt;/a&gt; and &lt;a
href="http://davidwalsh.name/jquery-link-nudging"&gt;link nudging with jQuery&lt;/a&gt;.  In an effort to familiarize myself with other javascript frameworks, we&amp;#8217;re going to try to duplicate that effect with another awesome framework:  Dojo.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/dojo-nudge.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;The Javascript:  Attempt 1&lt;/h2&gt;&lt;pre class="js"&gt;
dojo.addOnLoad(function() {
	var links = dojo.query('a.nudge');
	//foreach...
	dojo.forEach(links,function(link) {
		var left = dojo.style(link,'paddingLeft');
		dojo.connect(link,'onmouseenter',function() {
			dojo.animateProperty({
				node:link,
				properties: {
					paddingLeft: (left + 10)
				}
			}).play();
		});
		dojo.connect(link,'onmouseleave',function() {
			dojo.animateProperty({
				node:link,
				properties: {
					paddingLeft: left
				}
			}).play();
		});
	});
});
&lt;/pre&gt;&lt;p&gt;Once the DOM is ready, we use the &lt;span
class="function"&gt;dojo.query&lt;/span&gt; method to find all of the links to nudge.  For every link we find, we record its original left padding and add &lt;span
class="function"&gt;mouseenter&lt;/span&gt; and &lt;span
class="function"&gt;mouseleave&lt;/span&gt; events to each link to animate its left padding.&lt;/p&gt;&lt;h2&gt;The Javascript:  Better Solution&lt;/h2&gt;&lt;pre class="js"&gt;
dojo.ready(function() {
	dojo.query('a.nudge').forEach(function(link){
		var left = dojo.style(link,'paddingLeft');
		dojo.connect(link,'onmouseenter',function() {
		    dojo.anim(link, { paddingLeft:20 });
		});
		dojo.connect(link,'onmouseleave',function() {
		    dojo.anim(link, { paddingLeft:left });
		});
	});
});
&lt;/pre&gt;&lt;p&gt;Dojo lead Pete Higgins showed me a more condensed version of his script.&lt;/p&gt;&lt;div
class="actions"&gt;&lt;a
href="http://davidwalsh.name/dw-content/dojo-nudge.php" class="demo"&gt;View Demo&lt;/a&gt;&lt;div
class="clear"&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Simple, no?  The best way to learn to use any javascript framework is to duplicate a given set of code you are familiar with, much like we did here.  What do you think about this Dojo example?  Look close to jQuery and MooTools?&lt;/p&gt;&lt;p&gt;Don't forget to &lt;a
href="http://twitter.com/davidwalshblog"&gt;follow me on Twitter&lt;/a&gt; and be sure to visit &lt;a
href="http://scriptandstyle.com"&gt;Script &amp; Style&lt;/a&gt; for the best Javascript and CSS articles around!&lt;a
href="http://buysellads.com/buy/detail/1687"&gt;Sponsor the David Walsh Blog&lt;/a&gt; and get your brand in front of several thousand users per day!&lt;br/&gt;&lt;br/&gt;&lt;a
href="http://davidwalsh.name/link-nudging-dojo"&gt;Link Nudging Using&amp;nbsp;Dojo&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Related posts:&lt;ol&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/jquery-link-nudging' rel='bookmark' title='Permanent Link: jQuery Link&amp;nbsp;Nudging'&gt;jQuery Link&amp;nbsp;Nudging&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/news-scroller-dojo' rel='bookmark' title='Permanent Link: Create a Simple News Scroller Using&amp;nbsp;Dojo'&gt;Create a Simple News Scroller Using&amp;nbsp;Dojo&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/quickboxes-dojo' rel='bookmark' title='Permanent Link: QuickBoxes for&amp;nbsp;Dojo'&gt;QuickBoxes for&amp;nbsp;Dojo&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/remove-images-dojo' rel='bookmark' title='Permanent Link: Remove Broken Images Using&amp;nbsp;Dojo'&gt;Remove Broken Images Using&amp;nbsp;Dojo&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a
href='http://davidwalsh.name/mootools-link-nudging' rel='bookmark' title='Permanent Link: MooTools Link&amp;nbsp;Nudging'&gt;MooTools Link&amp;nbsp;Nudging&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Bludice/~4/jMx7h9P6F78" height="1" width="1"/&gt;</content><link rel="replies" type="text/html" href="http://davidwalsh.name/link-nudging-dojo#comments" thr:count="8" /><link rel="replies" type="application/atom+xml" href="http://davidwalsh.name/link-nudging-dojo/feed/atom" thr:count="8" /> <thr:total>8</thr:total> <feedburner:origLink>http://davidwalsh.name/link-nudging-dojo</feedburner:origLink></entry> </feed><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 97/324 queries in 6.960 seconds using disk

Served from: davidwalsh.name @ 2010-03-21 06:44:51 -->
