<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>David Walsh :: Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞. &#187; MooTools</title> <atom:link href="http://davidwalsh.name/tutorials/mootools/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 02 Sep 2010 03:13:15 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>MooTools Plugin:&#160;Event.Mock</title><link>http://davidwalsh.name/mootools-event</link> <comments>http://davidwalsh.name/mootools-event#comments</comments> <pubDate>Thu, 02 Sep 2010 03:12:12 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[MooTools]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5060</guid> <description><![CDATA[Those of you who visit this blog often know that I have a certain love for the simple things: simple CSS enhancements, simple PHP scripts, and most importantly, simple JavaScript plugins. One plugin that recently caught my attention was Arieh Glazer Event.Mock plugin. Event.Mock is a tiny MooTools plugin (essentially just a small function; not [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-event">MooTools Plugin:&nbsp;Event.Mock</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-event-stop' rel='bookmark' title='Permanent Link: MooTools Tip:&nbsp;Event.stop'>MooTools Tip:&nbsp;Event.stop</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/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/event-delegation' rel='bookmark' title='Permanent Link: Event Delegation with&nbsp;MooTools'>Event Delegation with&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/simple-mootools-event-class-binding' rel='bookmark' title='Permanent Link: Simple MooTools Event / Class&nbsp;Binding'>Simple MooTools Event / Class&nbsp;Binding</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Those of you who visit this blog often know that I have a certain love for the simple things:  simple CSS enhancements, simple PHP scripts, and most importantly, simple JavaScript plugins.  One plugin that recently caught my attention was Arieh Glazer Event.Mock plugin.  Event.Mock is a tiny MooTools plugin (essentially just a small function;  not a MooTools class) that does exactly what it says:  provides a Mock event for easy use with Element.fireEvent.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/http://mootools.net/forge/p/event_mock" class="demo">Download Event.Mock</a><div
class="clear"></div></div><h2>Why&nbsp;Event.Mock?</h2><p>One frequent MooTools occurrence is assigning an event to a given element, then firing an event on the given element.  The problem that occurs is that fireEvent doesn&#8217;t provide an Event object to the event listener&#8217;s function because a real event didn&#8217;t occur.  Thus, if you reference the event within the listener function, you&#8217;ll get an error:</p><pre class="js">
/* assign an event to myElement */
$('myElement').addEvent('click',function(e) {
	var target = e.target;  /* ERROR! -- e is null */
})

/* fire an event */
$('myElement').fireEvent('click');
</pre><p>Event.Mock serves as a fake event to provide to the listener function.</p><h2>The Event.Mock MooTools&nbsp;JavaScript</h2><pre class="js">
/**
 * creates a Mock event to be used with fire event
 * @param Element target an element to set as the target of the event - not required
 *  @param string type the type of the event to be fired. Will not be used by IE - not required.
 *
 */
Event.Mock = function(target,type){
var e = window.event;
type = type || 'click';

if (document.createEvent){
    e = document.createEvent('HTMLEvents');
    e.initEvent(
        type, //event type
        false, //bubbles - set to false because the event should like normal fireEvent
        true //cancelable
    );
}
e = new Event(e);
e.target = target;
return e;
}
</pre><p>Event.Mock accepts two arguments: the first being the fake event&#8217;s target element, the second being the type of event (i.e. &#8220;click&#8221;, &#8220;mouseenter&#8221;, etc.)  That means I can use Event.Mock as such:</p><pre class="js">
/* listen! */
$('myElement').addEvent('click',function(e){
	/* log the event to the console */
	console.log(e);
});

/* fire! */
$('myElement').fireEvent('click',new Event.Mock($('myElement'),'mousedown'));
</pre><p>Boom.  No worries about event errors AND useful information, in the form of a fake event target and type, is event listener function.</p><p>Big ups to Arieh for his simple but useful MooTools plugin!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-event">MooTools Plugin:&nbsp;Event.Mock</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-event-stop' rel='bookmark' title='Permanent Link: MooTools Tip:&nbsp;Event.stop'>MooTools Tip:&nbsp;Event.stop</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/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/event-delegation' rel='bookmark' title='Permanent Link: Event Delegation with&nbsp;MooTools'>Event Delegation with&nbsp;MooTools</a></li><li><a
href='http://davidwalsh.name/simple-mootools-event-class-binding' rel='bookmark' title='Permanent Link: Simple MooTools Event / Class&nbsp;Binding'>Simple MooTools Event / Class&nbsp;Binding</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-event/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Create a Twitter AJAX Button with MooTools, jQuery, or&#160;Dojo</title><link>http://davidwalsh.name/twitter-button</link> <comments>http://davidwalsh.name/twitter-button#comments</comments> <pubDate>Wed, 25 Aug 2010 03:28:19 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Dojo]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5049</guid> <description><![CDATA[There&#8217;s nothing like a subtle, slick website widget that effectively uses CSS and JavaScript to enhance the user experience.  Of course widgets like that take many hours to perfect, but it doesn&#8217;t take long for that effort to be rewarded with above-average user retention and buzz.  One of the widgets I love is Twitter&#8217;s &#8220;Follow&#8221; [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/twitter-button">Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/dojo-ajax' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;Dojo'>Animated AJAX Record Deletion Using&nbsp;Dojo</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/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;jQuery'>Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://davidwalsh.name/dw-content/twitter-follow.php"><img
src="http://davidwalsh.name/dw-content/twitter-button.jpg" alt="Twitter Button" class="image" /></a><p>There&#8217;s nothing like a subtle, slick website widget that effectively uses CSS and JavaScript to enhance the user experience.  Of course widgets like that take many hours to perfect, but it doesn&#8217;t take long for that effort to be rewarded with above-average user retention and buzz.  One of the widgets I love is Twitter&#8217;s &#8220;Follow&#8221; button.  Let me show you how you can implement this functionality with three popular JavaScript toolkits:  MooTools, jQuery, and Dojo.</p><p><em>Note:  This tutorial will only display the client side handling of the form submission &#8212; NOT any PHP/MySQL/server-side handling of the request.</em></p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php" class="demo">View MooTools Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=dojo" class="demo">View Dojo Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=jquery" class="demo">View jQuery Demo</a><div
class="clear"></div></div><h2>The HTML&nbsp;Structure</h2><pre class="html">
<form class="follow-form" method="post" action="twitter-follow.php">
	<input type="hidden" name="followID" value="123456" />
	<button type="submit" value="Actions" class="btn follow" title="123456">
		<i></i><span>follow</span>
	</button>
</form>
</pre><p>The HTML for the button is very simple.  The structure revolves around a BUTTON element which contains an I element and SPAN element.  You&#8217;re probably thinking &#8220;An I element?  WTF.&#8221;  I know I did.  The truth of the matter is that the I element is deprecated and, as far as I&#8217;m concerned, and be used for any purpose the developer would like.  I&#8217;m also sure that Twitter doesn&#8217;t mind saving bytes here or there.</p><h2>The CSS&nbsp;Styles</h2><pre class="css">
/* twitter button and its children */
button.btn { 
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
	background-attachment:scroll;
	background-color:#ddd;
	background-image:url(http://s.twimg.com/a/1282150308/images/buttons/bg-btn.gif);
	background-position:0 0;
	background-repeat:repeat-x;
	border:1px solid #ddd;
	border-bottom:1px solid #ccc;
	color:#333;
	cursor:pointer;
	font-family:"Lucida Grande",sans-serif;
	font-size:11px;
	line-height:14px;
	padding:4px 8px 5px 8px;
	text-shadow:1px 1px 0 #fff;
	vertical-align:top;
}
button.btn:hover {
	border:1px solid #999;
	border-bottom-color:#888;
	color:#000;
	background-color:#d5d5d5;
	background-position:0 -6px;
}
button.btn:active {
	background-image:none !important;
	text-shadow:none !important;
}
			
button.btn i {
	background-image:url(http://s.twimg.com/a/1282150308/images/sprite-icons.png);
	background-position:-176px -32px;
	background-repeat:no-repeat;
	display:inline-block;
	height:13px;
	margin-right:5px;
	width:15px;
}
button.btn i.active	{ background:url(http://s.twimg.com/a/1282150308/images/spinner.gif); }

/* properties for the element that is generated *after* following */
span.following	{  background:#ffd; padding:5px 10px; }
span.following span { width:10px; height:9px; margin-right:5px; display:inline-block; background:url("http://s.twimg.com/a/1282150308/images/sprite-icons.png") -160px -16px no-repeat; }
</pre><p>Most of the styling for this button goes onto the BUTTON element itself.  You&#8217;ll notice directives to round the button;  leaving the button sharp also please the eye.  Through the regular, hover, and active button states, check out how Twitter users the background position and colors to nicely modify the button without the need for additional images.  You&#8217;ll also notice Twitter uses sprites&#8230;as should you.</p><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
/* with mootools */
window.addEvent('domready',function() {
	/* fetch elements */
	$$('form.follow-form').each(function(form) {
		/* stop form event */
		form.addEvent('submit',function(e) {
			/* stop event */
			if(e) e.stop();
			/* send ajax request */
			var i = form.getElement('i');
			new Request({
				url: 'twitter-follow.php',
				method: 'post',
				data: {
					followID: form.getElement('input').value
				},
				onRequest: function() {
					i.addClass('active');
				},
				onSuccess: function() {
					var button = form.getElement('button');
					button.setStyle('display','none');
					new Element('span',{
						html: '<span></span>Following!',
						'class': 'following'
					}).inject(button,'after');
				},
				onComplete: function() {
					i.removeClass('active');
				}
			}).send();
		});
	});
});
</pre><p>The first step is grabbing all of the FORM elements with the follow-form CSS class.  Upon form submission, the default submission action is stopped.  An AJAX request is fired, using the INPUT element&#8217;s ID as the user to follow.  When the request is fired, the I element&#8217;s background image is set to the spinner.  When the request is complete, the button is hidden and a new SPAN element is displayed informing the user that they are now following the given user!</p><h2>The jQuery&nbsp;JavaScript</h2><pre class="js">
// Idiomatic jQuery by Doug Neiner
jQuery(function ($) {
	/* fetch elements and stop form event */
	$("form.follow-form").submit(function (e) {
		/* stop event */
		e.preventDefault();
		/* "on request" */
		$(this).find('i').addClass('active');
		/* send ajax request */
		$.post('twitter-follow.php', {
			followID: $(this).find('input').val()
		}, function () {
			/* find and hide button, create element */
			$(e.currentTarget)
			  .find('button').hide()
			  .after('&lt;span class="following"&gt;&lt;span&gt;&lt;/span&gt;Following!&lt;/span&gt;');
		});
	});
});
</pre><p>The code above is based off of the MooTools code.  The workflow is exactly the same.</p><h2>The Dojo&nbsp;JavaScript</h2><pre class="js">
/* when the DOM is ready */
dojo.ready(function() {
	/* fetch elements */
	dojo.query('form.follow-form').forEach(function(form) {
		/* stop form event */
		dojo.connect(form,'onsubmit',function(e) {
			/* stop event */
			dojo.stopEvent(e);
			/* active class */
			dojo.query('i',form).addClass('active');
			/* get button */
			var button = dojo.query('button',form)[0];
			/* ajax request */
			dojo.xhrPost({
				form: form,
				load: function() {
					dojo.style(button,'display','none');
					dojo.create('span',{
						innerHTML: '<span></span>Following',
						className: 'following'
					},button,'after');
				}
			});
		});
	});
});
</pre><p>The code above is based off of the MooTools code.  The workflow is exactly the same.</p><div
class="actions"> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php" class="demo">View MooTools Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=dojo" class="demo">View Dojo Demo</a> <a
href="http://davidwalsh.name/dw-content/twitter-follow.php?lib=jquery" class="demo">View jQuery Demo</a><div
class="clear"></div></div><p>This &#8220;Follow&#8221; button is only one of many details that Twitter has paid attention to, just to make the user experience on the site better.  Take note from the effort put forth by large websites &#8212; adding these types of details to your smaller websites can make the user experience much better for YOUR users!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/twitter-button">Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-twitter' rel='bookmark' title='Permanent Link: Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit'>Create Twitter-Style Buttons with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/dojo-ajax' rel='bookmark' title='Permanent Link: Animated AJAX Record Deletion Using&nbsp;Dojo'>Animated AJAX Record Deletion Using&nbsp;Dojo</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/twitter-dropdown-jquery' rel='bookmark' title='Permanent Link: Create Twitter-Style Dropdowns Using&nbsp;jQuery'>Create Twitter-Style Dropdowns Using&nbsp;jQuery</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/twitter-button/feed</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&#160;III</title><link>http://davidwalsh.name/dojo-mootools-jquery</link> <comments>http://davidwalsh.name/dojo-mootools-jquery#comments</comments> <pubDate>Thu, 19 Aug 2010 02:32:54 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Dojo]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5045</guid> <description><![CDATA[My love of the JavaScript frameworks knows no bounds. Unfortunately too many developers stick to one framework without taking the time to learn the others. The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make. Let me show you how to accomplish a few more tasks using [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/dojo-mootools-jquery">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/jquery-mootools-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li></ol>]]></description> <content:encoded><![CDATA[<p>My love of the JavaScript frameworks knows no bounds.  Unfortunately too many developers stick to one framework without taking the time to learn the others.  The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make.  Let me show you how to accomplish a few more tasks using three JavaScript frameworks:  MooTools, jQuery, and Dojo.</p><h2>Calculate Element Dimensions and&nbsp;Position</h2><p>Knowing not only the height and width of a dimension but it&#8217;s top/left position from an offset parent or document body can be extremely helpful when trying to animate or move a DOM element.</p><h3>MooTools</h3><pre class="js">
var dimensions = document.id('myElement').getDimensions();
/* returns:
{ 
	height: 4684,
	width: 1408,
	x: 1408,
	y: 4684
}
*/
</pre><h3>jQuery</h3><pre class="js">
var myElement = jQuery('#myElement');
var position = myElement.position();
var dimensions = {
	height: myElement.height(),
	width: myElement.width(),
	top: position.top,
	left: position.left
};
</pre><h3>Dojo</h3><pre class="js">
var dimension = dojo.coords('myElement');
/* returns:
{
	h: 4684,
	l: 0,
	t: 0,
	w: 1408,
	x: 0,
	y: 0
}
*/
</pre><h2>Extend an&nbsp;Object</h2><p>Extending an object means taking on object and merging a second objects properties into it.  This is very helpful in merging default options with instance options.</p><h3>MooTools</h3><pre class="js">
$extend(firstObject,{ anotherProperty:'anothervalue' });
//second arg is added to the first object
</pre><h3>jQuery</h3><pre class="js">
jQuery.extend(firstObject,{ anotherProperty:'anothervalue' })
</pre><h3>Dojo</h3><pre class="js">
dojo.mixin(firstObject,{ anotherProperty:'anothervalue' });
</pre><h2>Stop an&nbsp;Event</h2><p>Stopping an event is helpful when looking to execute functionality (usually an XHR request) when a link is clicked.</p><h3>MooTools</h3><pre class="js">
$('myElement').addEvent('click',function(e) {
	e.stop();
});
</pre><h3>jQuery</h3><pre class="js">
$('#myElement').click(function(e){ 
	event.stopPropagation();
	e.preventDefault();
	// (no internal method that does both)
});
</pre><h3>Dojo</h3><pre class="js">
dojo.connect(dojo.byId('myElement'),'onclick',function(e) {
	dojo.stopEvent(e);
});
</pre><h2>Load Content into an&nbsp;Element</h2><p>Sure we can create an XHR request manually to load content into an element but why do that when your favorite lirbary can do that work for you?</p><h3>MooTools</h3><pre class="js">
document.id('myElement').load('ajax/script.html');
</pre><h3>jQuery</h3><pre class="js">
jQuery('#myElement').load('ajax/script.html');
</pre><h3>Dojo</h3><pre class="js">
//as found on Pete Higgins' website:
//http://higginsforpresident.net/2009/12/140-characters-of-awesome/
dojo.extend(dojo.NodeList, {
	grab: function(url){
		dojo.xhr('GET', { url:url })
			.addCallback(this, function(response){
				this.addContent(response, 'only');
			});
		return this;
	}
});
dojo.query('#myElement').grab('header.html');
</pre><h2>Get and Set HTML&nbsp;Content</h2><p>Getting and setting HTML is a frequent JavaScript operation&#8230;yet each library handles it a bit differently.</p><h3>MooTools</h3><pre class="js">
//get
var html = document.id('myElement').get('html');
//set
document.id('myElement').set('html','<b>Hello!</b>');
</pre><h3>jQuery</h3><pre class="js">
//get
var html = jQuery('#myElement').html();
//set
jQuery('#myElement').html('<b>Hello!</b>');
</pre><h3>Dojo</h3><pre class="js">
//get 
var html = dojo.byId('myElement').innerHTML
//set
dojo.byId('myElement').innerHTML = '<b>Hello!</b>';
</pre><h2>Use Element&nbsp;Storage</h2><p>Element data storage is important because it allows you to store settings within the element itself &#8212; perfect for defeating scope and context issues.</p><h3>MooTools</h3><pre class="js">
//set
document.id('myElement').store('key','value');
//get
var value = document.id('myElement').retrieve('key');
</pre><h3>jQuery</h3><pre class="js">
//set
jQuery('#myElement').data('key','value');
//get
var value = jQuery('#myElement').data('key');
</pre><h3>Dojo</h3><pre class="js">
//set
dojo.attr('myElement','data-key','value');
//get
dojo.attr('myElement','data-key');
</pre><p>There you are &#8212; more proof that the toolkits are one in the same, all except the syntax.  Do yourself a favor and learn more than one JavaScript framework &#8212; you&#8217;ll be better for it!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/dojo-mootools-jquery">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/jquery-mootools-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/twitter-button' rel='bookmark' title='Permanent Link: Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo'>Create a Twitter AJAX Button with MooTools, jQuery, or&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/dojo-mootools-jquery/feed</wfw:commentRss> <slash:comments>13</slash:comments> </item> <item><title>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&#160;II</title><link>http://davidwalsh.name/jquery-mootools-dojo</link> <comments>http://davidwalsh.name/jquery-mootools-dojo#comments</comments> <pubDate>Wed, 11 Aug 2010 13:55:45 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Dojo]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5031</guid> <description><![CDATA[My love of the JavaScript frameworks knows no bounds.  Unfortunately too many developers stick to one framework without taking the time to learn the others.  The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make.  Let me show you how to accomplish a few more tasks using [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-mootools-dojo">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/dojo-mootools' rel='bookmark' title='Permanent Link: Quick Dojo Setup Snippet for MooTools&nbsp;Developers'>Quick Dojo Setup Snippet for MooTools&nbsp;Developers</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<p>My love of the JavaScript frameworks knows no bounds.  Unfortunately too many developers stick to one framework without taking the time to learn the others.  The more frameworks you know, the better a programmer you will be and the more money you&#8217;ll make.  Let me show you how to accomplish a few more tasks using three JavaScript frameworks:  MooTools, jQuery, and Dojo.</p><h2>Loop Through an Element&nbsp;Collection</h2><h3>MooTools</h3><pre class="js">
$$('div').each(function(div) {
	/* do stuff here */
});
</pre><h3>jQuery</h3><pre class="js">
jQuery('div').each(function(){ 
	/* do stuff;  "this" is the element */
});
</pre><h3>Dojo</h3><pre class="js">
dojo.query('div').forEach(function(div){ 
	/* do stuff */
});
</pre><h2>Get an Element Attribute&nbsp;Value</h2><h3>MooTools</h3><pre class="js">
var rel = document.id('myElement').get('rel');
</pre><h3>jQuery</h3><pre class="js">
var rel = jQuery('#myElement').attr('rel');
</pre><h3>Dojo</h3><pre class="js">
//var rel = dojo.query('#myElement').attr('rel')[0];
var rel = dojo.attr('myElement','rel');
</pre><h2>Create a Plugin / Class &#8211;&nbsp;Template</h2><h3>MooTools</h3><pre class="js">
var myClass = new Class({
	
	initialize: function(options) {
		/* do initial processing */
	}
	
});
</pre><h3>jQuery</h3><pre class="js">
jQuery.fn.myClass = function(options) {
	
	return this.each(function() {
		/* do initial processing */
	});
	
};
</pre><h3>Dojo</h3><pre class="js">
dojo.provide('mynamespace.PluginName');
dojo.declare('mynamespace.PluginName',null,{
	
	constructor: function(options) {
		/* do initial processing */
	}
	
});
</pre><h2>Set and Get Cookie&nbsp;Key=&gt;Values</h2><h3>MooTools</h3><pre class="js">
/* set */
Cookie.write('key','value',{ duration: 5 }); //5 days
/* get */
var cookieValue = Cookie.read('key');
</pre><h3>jQuery</h3><pre class="js">
/* 
	requires this plugin:  http://plugins.jquery.com/project/cookie
*/
/* set */
jQuery.cookie('key','value', { expires: 5 });
/* get */
var cookieValue = jQuery.cookie('key');
</pre><h3>Dojo</h3><pre class="js">
/* get dojo's cookie class */
dojo.require('dojo.cookie');
/* set */
dojo.cookie('key','value', { expires: 5 }); //5 days
/* get */
var cookieValue = dojo.cookie('key');
</pre><h2>Retrieve JSON via&nbsp;XHR</h2><h3>MooTools</h3><pre class="js">
var jsonRequest = new Request.JSON({
	url: 'info.json', 
	onSuccess: function(json){
    	/* do something with results */
	}
}).get();
</pre><h3>jQuery</h3><pre class="js">
jQuery.getJSON('info.json',function(json) {
	/* do something with results */
});
</pre><h3>Dojo</h3><pre class="js">
dojo.xhrGet({
	url: 'info.json',
	handleAs: 'json',
	load: function(json) {
		/* do something with results */
	}
});
</pre><p>There you are &#8212; more proof that the toolkits are one in the same, all except the syntax.  Do yourself a favor and learn more than one JavaScript framework &#8212; you&#8217;ll be better for it!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/jquery-mootools-dojo">Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;II</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/dojo-mootools-jquery' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III'>Accomplishing Common Tasks Using MooTools, jQuery, and Dojo&nbsp;III</a></li><li><a
href='http://davidwalsh.name/mootools-jquery-dojo' rel='bookmark' title='Permanent Link: Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo'>Accomplishing Common Tasks Using MooTools, jQuery, and&nbsp;Dojo</a></li><li><a
href='http://davidwalsh.name/dojo-connect' rel='bookmark' title='Permanent Link: dojo.connect: A Powerful Object and Event&nbsp;Listener'>dojo.connect: A Powerful Object and Event&nbsp;Listener</a></li><li><a
href='http://davidwalsh.name/dojo-mootools' rel='bookmark' title='Permanent Link: Quick Dojo Setup Snippet for MooTools&nbsp;Developers'>Quick Dojo Setup Snippet for MooTools&nbsp;Developers</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/jquery-mootools-dojo/feed</wfw:commentRss> <slash:comments>18</slash:comments> </item> <item><title>7 MooTools Plugins You Should Use on Every Website&#160;II</title><link>http://davidwalsh.name/mootools-plugins-ii</link> <comments>http://davidwalsh.name/mootools-plugins-ii#comments</comments> <pubDate>Thu, 05 Aug 2010 14:32:19 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[MooTools]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5024</guid> <description><![CDATA[The advantage of using unobtrusive JavaScript is that you can vastly improve the user experience for website visitors using just a snippet of code. And since the MooTools JavaScript framework’s community is known for creating unique, quality plugins, I’ve compiled a list of plugins you MUST use on every website to take the user experience [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-plugins-ii">7 MooTools Plugins You Should Use on Every Website&nbsp;II</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-zoom' rel='bookmark' title='Permanent Link: MooTools Zoomer&nbsp;Plugin'>MooTools Zoomer&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/7-mootools-plugins' rel='bookmark' title='Permanent Link: 7 MooTools Plugins You Should Use on Every&nbsp;Website'>7 MooTools Plugins You Should Use on Every&nbsp;Website</a></li><li><a
href='http://davidwalsh.name/slideshow-preload-images' rel='bookmark' title='Permanent Link: Create a Quick MooTools Slideshow with Preloading&nbsp;Images'>Create a Quick MooTools Slideshow with Preloading&nbsp;Images</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-lazyload' rel='bookmark' title='Permanent Link: Introducing MooTools&nbsp;LazyLoad'>Introducing MooTools&nbsp;LazyLoad</a></li></ol>]]></description> <content:encoded><![CDATA[<p>The advantage of using unobtrusive JavaScript is that you can vastly improve the user experience for website visitors using just a snippet of code. And since the MooTools JavaScript framework’s community is known for creating unique, quality plugins, I’ve compiled a list of plugins you MUST use on every website to take the user experience to the next level.</p><h2>ScrollSpy</h2><p><img
src="http://davidwalsh.name/dw-content/peter-right.jpg" alt="ScrollSpy" class="image" /></p><p>ScrollSpy is an invaluable tool which listens to the scroll event on any element within the page, allows you to create &#8220;virtual zones&#8221; to spy on, and allow you to fire specified functionality when the user&#8217;s browser enter or leaves the zone.  I&#8217;ve used ScrollSpy on my website for years and will continue to do so.  This compact plugin can have a big impact on your website!</p><div
class="actions"> <a
href="http://davidwalsh.name/js/scrollspy" class="demo">Download</a> <a
href="http://davidwalsh.name/dw-content/scroll-spy.php" class="demo">Example</a> <a
href="http://davidwalsh.name/mootools-scrollspy" class="demo">Article</a><div
class="clear"></div></div><h2>LazyLoad</h2><p>LazyLoad is another plugin that&#8217;s small in size but big in the fight for cutting down load time.  LazyLoad defers the loading of images until the user scrolls within a specified number of pixels of the image.  What make the user download images they might never get to the piece of the page that contains them?</p><div
class="actions"> <a
href="http://davidwalsh.name/js/lazyload" class="demo">Download</a> <a
href="http://davidwalsh.name/dw-content/lazyload3.php" class="demo">Example</a> <a
href="http://davidwalsh.name/mootools-lazyload" class="demo">Article</a><div
class="clear"></div></div><h2>SlideShow</h2><p><img
src="http://davidwalsh.name/dw-content/slideshow.png" alt="SlideShow" /></p><p>SlideShow is the amazing slideshow widget created by MooTools contributor Ryan Florence.  SlideShow is extendable, flexible, and easy to implement.  SlideShow allows for more than just images too &#8212; any number of elements can added to SlideShow.  The masterful plugin also contains built-in transition types so most of the animation is done for you!</p><div
class="actions"> <a
href="http://mootools.net/forge/p/slideshow" class="demo">Download</a> <a
href="http://ryanflorence.com/slideshow/" class="demo">Example</a> <a
href="http://ryanflorence.com/slideshow-a-highly-extendable-mootools-javascript-slideshow/" class="demo">Article</a><div
class="clear"></div></div><h2>Asset</h2><p>Asset is a MooTools More class that allows you to dynamically request stylesheets, images, and JavaScript files asynchronously after the page has been loaded.  With Asset you can preload images, switch themes via CSS file swapping, and lazy load JavaScript plugins on demand</p><div
class="actions"> <a
href="http://mootools.net/more" class="demo">Download</a> <a
href="http://mootools.net/docs/more/Utilities/Assets" class="demo">Documentation</a><div
class="clear"></div></div><h2>TextboxList</h2><p><img
src="http://davidwalsh.name/dw-content/textboxlist.png" alt="TextboxList" /></p><p>TextboxList by Guillermo Rauch is an outstanding plugin for beautifying text INPUT elements which contain comma-separated values.  TextboxList was inspired by Facebook and perfected using the MooTools framework.  TextboxList is also available for jQuery.</p><div
class="actions"> <a
href="http://mootools.net/forge/p/textboxlist" class="demo">Download</a> <a
href="http://davidwalsh.name/dw-content/textboxlist.php" class="demo">Example 1</a> <a
href="http://devthought.com/wp-content/projects/mootools/textboxlist/Demo/" class="demo">Example 2</a> <a
href="http://devthought.com/projects/mootools/textboxlist/" class="demo">Article</a><div
class="clear"></div></div><h2>Zoomer</h2><p><img
src="http://davidwalsh.name/dw-content/criccizoom.png" alt="Zoomer" /></p><p>Zoomer is a refreshing take on image magnification.  Instead of the lightbox which has grown to be tiresome, Zoomer magnifies portions of an image within the original image&#8217;s same dimensions.  You can focus on different portions of an image by moving your mouse around.</p><div
class="actions"> <a
href="http://mootools.net/forge/p/zoomer" class="demo">Download</a> <a
href="http://davidwalsh.name/dw-content/zoomer.php" class="demo">Example</a> <a
href="http://davidwalsh.name/mootools-zoom" class="demo">Article</a><div
class="clear"></div></div><h2>Mobile</h2><p>Created by MooTools Core Developer Christoph Pojer, Mobile is a MooTools set of JavaScript files to enhance your website on mobile operating systems by automatically replacing all your click handlers with touch listeners to overcome the click delay on iOS.  A huge step in getting your website mobile-ready!</p><div
class="actions"><a
href="http://github.com/cpojer/mootools-mobile" class="demo">Download</a><div
class="clear"></div></div><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-plugins-ii">7 MooTools Plugins You Should Use on Every Website&nbsp;II</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/mootools-zoom' rel='bookmark' title='Permanent Link: MooTools Zoomer&nbsp;Plugin'>MooTools Zoomer&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/7-mootools-plugins' rel='bookmark' title='Permanent Link: 7 MooTools Plugins You Should Use on Every&nbsp;Website'>7 MooTools Plugins You Should Use on Every&nbsp;Website</a></li><li><a
href='http://davidwalsh.name/slideshow-preload-images' rel='bookmark' title='Permanent Link: Create a Quick MooTools Slideshow with Preloading&nbsp;Images'>Create a Quick MooTools Slideshow with Preloading&nbsp;Images</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-lazyload' rel='bookmark' title='Permanent Link: Introducing MooTools&nbsp;LazyLoad'>Introducing MooTools&nbsp;LazyLoad</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-plugins-ii/feed</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Implement the Google AJAX Search&#160;API</title><link>http://davidwalsh.name/google-ajax-search</link> <comments>http://davidwalsh.name/google-ajax-search#comments</comments> <pubDate>Mon, 02 Aug 2010 14:04:25 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MooTools]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5020</guid> <description><![CDATA[Let&#8217;s be honest&#8230;WordPress&#8217; search functionality isn&#8217;t great. Let&#8217;s be more honest&#8230;no search functionality is better than Google&#8217;s. Luckily for us, Google provides an awesome method by which we can use their search for our own site: the Google AJAX Search API. Let me show you how to implement this awesome API within your own website! [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/google-ajax-search">Implement the Google AJAX Search&nbsp;API</a></p>Related posts:<ol><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/dojo-flickr' rel='bookmark' title='Permanent Link: Create a Dynamic Flickr Image Search with the Dojo&nbsp;Toolkit'>Create a Dynamic Flickr Image Search with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/google-load' rel='bookmark' title='Permanent Link: google.load():  Utilize Google&#8217;s AJAX Libraries&nbsp;API'>google.load():  Utilize Google&#8217;s AJAX Libraries&nbsp;API</a></li><li><a
href='http://davidwalsh.name/ajax-username-availability-checker-mootools' rel='bookmark' title='Permanent Link: AJAX Username Availability Checker Using MooTools&nbsp;1.2'>AJAX Username Availability Checker Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li></ol>]]></description> <content:encoded><![CDATA[<a
href="http://davidwalsh.name/dw-content/google-ajax-search.php"><img
src="http://davidwalsh.name/dw-content/ajax-search-example.jpg" alt="Google AJAX Search API" /></a><p>Let&#8217;s be honest&#8230;WordPress&#8217; search functionality isn&#8217;t great.  Let&#8217;s be more honest&#8230;no search functionality is better than Google&#8217;s.  Luckily for us, Google provides an awesome method by which we can use their search for our own site:  the Google AJAX Search API.  Let me show you how to implement this awesome API within your own website!</p><div
class="actions"><a
class="demo" href="http://davidwalsh.name/dw-content/google-ajax-search.php">View Demo</a><div
class="clear"></div></div><h2>Sign&nbsp;Up!</h2><p>Google&#8217;s AJAX Search API requires that you <a
href="http://code.google.com/apis/ajaxsearch/key.html">sign up for an API key</a>.  Signing up is free and you&#8217;ll be done with the process of retrieving a key in a few minutes.</p><p><a
href="http://davidwalsh.name/dw-content/google-ajax-search.php"><img
src="http://davidwalsh.name/dw-content/ajax-search-1.jpg" alt="Google AJAX Search API Sign Up" /></a></p><p>You&#8217;ll also need to provide a domain for which they key will work for; one key per domain.</p><h2>The&nbsp;HTML</h2><pre class="html">&lt;!-- SEARCH FORM --&gt;
&lt;form action="http://www.google.com/search" method="get"&gt;
	&lt;!-- HTML5 SEARCH BOX!  --&gt;
	&lt;input type="search" id="search-box" name="q" results="5" placeholder="Search..." autocomplete="on" /&gt;
	&lt;!-- SEARCH davidwalsh.name ONLY! --&gt;
	&lt;input type="hidden" name="sitesearch" value="davidwalsh.name" /&gt;
	&lt;!-- SEARCH BUTTON --&gt;
	&lt;input id="search-submit" type="submit" value="Search" /&gt;
&lt;/form&gt;

&lt;!-- ASYNCHRONOUSLY LOAD THE AJAX SEARCH API;  MOOTOOLS TOO! --&gt;
&lt;script type="text/javascript" src="http://www.google.com/jsapi?key=MY_REALLY_REALLY_REALLY_REALLY_REALLY_REALLY_LONG_KEY"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
	google.load('mootools','1.2.4');
	google.load('search','1');
&lt;/script&gt;</pre><p>You&#8217;ll want to use a &#8220;real&#8221; form so that if the user doesn&#8217;t have JavaScript, they&#8217;ll get directed to Google for their search.  Beyond that, follow the hidden input line to ensure your search will work.  You may also note that the search box has autocomplete and placeholder attributes &#8212; those are HTML5 functionality, nothing to do with Google&#8217;s AJAX Search API.</p><h2>The&nbsp;CSS</h2><pre class="css">/* results positioning */
#search-results		{ position:absolute; z-index:90; top:40px; right:10px; visibility:hidden; }
/* triangle! */
#search-results-pointer { width:0px; height:0px; border-left:20px solid transparent; border-right:20px solid transparent; border-bottom:20px solid #eee; margin-left:80%; }
/* content DIV which holds search results! */
#search-results-content { position:relative; padding:20px; background:#fff; border:3px solid #eee; width:380px; min-height:200px; -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5) }</pre><p>The CSS above simply position the elements where I want them per my design.  I even used a CSS triangle!</p><h2>The&nbsp;JavaScript</h2><pre class="js">window.addEvent('domready',function(){

	/* search */
	var searchBox = $('search-box'), searchLoaded=false, searchFn = function() {

		/*
			We're lazyloading all of the search stuff.
			After all, why create elements, add listeners, etc. if the user never gets there?
		*/
		if(!searchLoaded) {
			searchLoaded = true; //set searchLoaded to "true"; no more loading!

			//build elements!
			var container = new Element('div',{ id: 'search-results' }).inject($('search-area'),'after');
			var wrapper = new Element('div',{
				styles: {
					position: 'relative'
				}
			}).inject(container);
			new Element('div',{ id: 'search-results-pointer' }).inject(wrapper);
			var contentContainer = new Element('div',{ id: 'search-results-content' }).inject(wrapper);
			var closer = new Element('a', {
				href: 'javascript:;',
				text: 'Close',
				styles: {
					position: 'absolute', //position the "Close" link
					bottom: 35,
					right: 20
				},
				events: {
					click: function() {
						container.fade(0);
					}
				}
			}).inject(wrapper);

			//google interaction
			var search = new google.search.WebSearch(),
				control = new google.search.SearchControl(),
				options = new google.search.DrawOptions();

			//set google options
			options.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
			options.setInput(searchBox);

			//set search options
			search.setUserDefinedClassSuffix('siteSearch');
			search.setSiteRestriction('davidwalsh.name');
			search.setLinkTarget(google.search.Search.LINK_TARGET_SELF);

			//set search controls
			control.addSearcher(search);
			control.draw(contentContainer,options);
			control.setNoResultsString('No results were found.');

			//add listeners to search box
			searchBox.addEvents({
				keyup: function(e) {
					if(searchBox.value &amp;&amp; searchBox.value != searchBox.get('placeholder')) {
						container.fade(0.9);
						control.execute(searchBox.value);
					}
					else {
						container.fade(0);
					}
				}
			});
			searchBox.removeEvent('focus',searchFn);
		}
	};
	searchBox.addEvent('focus',searchFn);
});</pre><p>There&#8217;s a fair amount of JavaScript above so stay with me.  The following are the steps for implementing the Google AJAX API:</p><ul><li>Create an element to house the results of the search.</li><li>Create a &#8220;Close&#8221; link which will allow the user to close the search results window.</li><li>Create our Google-given class instance:<ul><li>A Web Search (you can also create Local Search if you&#8217;d like&#8230;). <a
rel="nofollow" href="http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GwebSearch">google.search.WebSearch options</a>.  I&#8217;ve chosen to add tabs and set the input as my search box.</li><li>A SearchControl instance. <a
rel="nofollow" href="http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GSearchControl">google.search.SearchControl options</a>.  &#8220;siteSearch&#8221; is my suffix for results, I&#8217;ve restricted my search to the davidwalsh.name domain, and form submission will trigger results to display in the current window (instead of a new window).</li><li>A DrawOptions instance. <a
rel="nofollow" href="http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GdrawOptions">google.search.DrawOptions options</a>.  With my DrawOptions instance, I&#8217;ve set search control, set the draw container with the options we&#8217;ve created, and I&#8217;ve decided to use Google&#8217;s default &#8220;no results&#8221; message</li></ul></li></ul><p>Once the search controls are created, it&#8217;s time to attach events to the search box to show and hide the search results container based on the contents of the search box.  That&#8217;s all!</p><p>As you can see, I&#8217;ve chosen to use the MooTools (FTW) JavaScript toolkit to create the element that houses the results, the &#8220;Close&#8221; link, and to bind events to the search box.  You could just as easily use Dojo or jQuery for element creation and even handling.</p><div
class="actions"><a
class="demo" href="http://davidwalsh.name/dw-content/google-ajax-search.php">View Demo</a><div
class="clear"></div></div><p>In all honesty, I couldn&#8217;t believe how easy it was to implement Google AJAX search.  It&#8217;s an easy want to implement search on your website, especially if you&#8217;re currently using WordPress&#8217; search.  I recommend taking the time to implement Google&#8217;s AJAX Search API &#8212; the day it takes you to get it working will save your users hours of pain!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/google-ajax-search">Implement the Google AJAX Search&nbsp;API</a></p><p>Related posts:<ol><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/dojo-flickr' rel='bookmark' title='Permanent Link: Create a Dynamic Flickr Image Search with the Dojo&nbsp;Toolkit'>Create a Dynamic Flickr Image Search with the Dojo&nbsp;Toolkit</a></li><li><a
href='http://davidwalsh.name/google-load' rel='bookmark' title='Permanent Link: google.load():  Utilize Google&#8217;s AJAX Libraries&nbsp;API'>google.load():  Utilize Google&#8217;s AJAX Libraries&nbsp;API</a></li><li><a
href='http://davidwalsh.name/ajax-username-availability-checker-mootools' rel='bookmark' title='Permanent Link: AJAX Username Availability Checker Using MooTools&nbsp;1.2'>AJAX Username Availability Checker Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/ajax-spinner-jquery' rel='bookmark' title='Permanent Link: Form Element AJAX Spinner Attachment Using&nbsp;jQuery'>Form Element AJAX Spinner Attachment Using&nbsp;jQuery</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/google-ajax-search/feed</wfw:commentRss> <slash:comments>30</slash:comments> </item> <item><title>Build HTML Tables From MySQL Tables with&#160;PHP</title><link>http://davidwalsh.name/html-mysql-php</link> <comments>http://davidwalsh.name/html-mysql-php#comments</comments> <pubDate>Wed, 21 Jul 2010 16:55:40 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5012</guid> <description><![CDATA[I was recently completing a project which required that I build a series of HTML tables which would represent all of the tables within a MySQL database.  I didn&#8217;t have anything created but after a few minutes I had exactly what I needed. Hopefully this helps you out! View Demo The&#160;CSS table.db-table { border-right:1px solid [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/html-mysql-php">Build HTML Tables From MySQL Tables with&nbsp;PHP</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/php-mysql-database-optimization-function' rel='bookmark' title='Permanent Link: PHP / MySQL Database Optimization&nbsp;Function'>PHP / MySQL Database Optimization&nbsp;Function</a></li><li><a
href='http://davidwalsh.name/backup-mysql-database-php' rel='bookmark' title='Permanent Link: Backup Your MySQL Database Using&nbsp;PHP'>Backup Your MySQL Database Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/php-calendar' rel='bookmark' title='Permanent Link: Build a Calendar Using PHP, XHTML, and&nbsp;CSS'>Build a Calendar Using PHP, XHTML, and&nbsp;CSS</a></li><li><a
href='http://davidwalsh.name/php-microsoft-sql-server-mssql-iis-connect-query-odbc' rel='bookmark' title='Permanent Link: PHP, Microsoft SQL Server (MSSQL), and IIS:  Connect and Query with&nbsp;ODBC'>PHP, Microsoft SQL Server (MSSQL), and IIS:  Connect and Query with&nbsp;ODBC</a></li><li><a
href='http://davidwalsh.name/web-service-php-mysql-xml-json' rel='bookmark' title='Permanent Link: Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON'>Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I was recently completing a project which required that I build a series of HTML tables which would represent all of the tables within a MySQL database.  I didn&#8217;t have anything created but after a few minutes I had exactly what I needed. Hopefully this helps you out!</p><p><a
href="http://davidwalsh.name/dw-content/build-mysql-tables.php"><img
src="http://davidwalsh.name/dw-content/mysql-db-tables.jpg" alt="" class="image" /></a></p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/build-mysql-tables.php" class="demo">View Demo</a><div
class="clear"></div></div><h2>The&nbsp;CSS</h2><pre class="css">
table.db-table 		{ border-right:1px solid #ccc; border-bottom:1px solid #ccc; }
table.db-table th	{ background:#eee; padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; }
table.db-table td	{ padding:5px; border-left:1px solid #ccc; border-top:1px solid #ccc; }
</pre><p>The CSS I&#8217;m styling the table with is as basic as it gets &#8212; style as you wish!</p><h2>The PHP /&nbsp;MySQL</h2><pre class="php">
/* connect to the db */
$connection = mysql_connect('localhost','username','password');
mysql_select_db('my_db',$connection);

/* show tables */
$result = mysql_query('SHOW TABLES',$connection) or die('cannot show tables');
while($tableName = mysql_fetch_row($result)) {

	$table = $tableName[0];
	
	echo '&lt;h3&gt;',$table,'&lt;/h3&gt;';
	$result2 = mysql_query('SHOW COLUMNS FROM '.$table) or die('cannot show columns from '.$table);
	if(mysql_num_rows($result2)) {
		echo '&lt;table cellpadding="0" cellspacing="0" class="db-table"&gt;';
		echo '&lt;tr&gt;&lt;th&gt;Field&lt;/th&gt;&lt;th&gt;Type&lt;/th&gt;&lt;th&gt;Null&lt;/th&gt;&lt;th&gt;Key&lt;/th&gt;&lt;th&gt;Default&lt;th&gt;Extra&lt;/th&gt;&lt;/tr&gt;';
		while($row2 = mysql_fetch_row($result2)) {
			echo '&lt;tr&gt;';
			foreach($row2 as $key=&gt;$value) {
				echo '&lt;td&gt;',$value,'&lt;/td&gt;';
			}
			echo '&lt;/tr&gt;';
		}
		echo '&lt;/table&gt;&lt;br /&gt;';
	}
}
</pre><p>The first step in the process is accessing all of the tables within the database.  Once all tables have been fetched, the next step is to loops through the array of tables we receive and, for each table, build a new HTML table with column information.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/build-mysql-tables.php" class="demo">View Demo</a><div
class="clear"></div></div><p>Nothing groundbreaking but surely has use.  I&#8217;ve also written a blog post about backing up your MySQL database with PHP titled <a
href="http://davidwalsh.name/backup-mysql-database-php">Backup Your MySQL Database Using PHP</a>;  check that out if you&#8217;d prefer to backup your databse information in SQL format!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/html-mysql-php">Build HTML Tables From MySQL Tables with&nbsp;PHP</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/php-mysql-database-optimization-function' rel='bookmark' title='Permanent Link: PHP / MySQL Database Optimization&nbsp;Function'>PHP / MySQL Database Optimization&nbsp;Function</a></li><li><a
href='http://davidwalsh.name/backup-mysql-database-php' rel='bookmark' title='Permanent Link: Backup Your MySQL Database Using&nbsp;PHP'>Backup Your MySQL Database Using&nbsp;PHP</a></li><li><a
href='http://davidwalsh.name/php-calendar' rel='bookmark' title='Permanent Link: Build a Calendar Using PHP, XHTML, and&nbsp;CSS'>Build a Calendar Using PHP, XHTML, and&nbsp;CSS</a></li><li><a
href='http://davidwalsh.name/php-microsoft-sql-server-mssql-iis-connect-query-odbc' rel='bookmark' title='Permanent Link: PHP, Microsoft SQL Server (MSSQL), and IIS:  Connect and Query with&nbsp;ODBC'>PHP, Microsoft SQL Server (MSSQL), and IIS:  Connect and Query with&nbsp;ODBC</a></li><li><a
href='http://davidwalsh.name/web-service-php-mysql-xml-json' rel='bookmark' title='Permanent Link: Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON'>Create a Basic Web Service Using PHP, MySQL, XML, and&nbsp;JSON</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/html-mysql-php/feed</wfw:commentRss> <slash:comments>15</slash:comments> </item> <item><title>ServerSide JavaScript with MooTools and&#160;NodeJS</title><link>http://davidwalsh.name/mootools-nodejs</link> <comments>http://davidwalsh.name/mootools-nodejs#comments</comments> <pubDate>Mon, 12 Jul 2010 14:07:54 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[MooTools]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=5008</guid> <description><![CDATA[This post was authored by Christoph Pojer. To learn more about Christoph, click here. This blog post is intended to provide a starting point for ServerSide JavaScript (SSJS) development with MooTools. It is focused on NodeJS (http://nodejs.org) and tries to explain the main concepts and differences from client side development. It is solely based on [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-nodejs">ServerSide JavaScript with MooTools and&nbsp;NodeJS</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/github-merge-batch' rel='bookmark' title='Permanent Link: Create a GitHub Merge Batch&nbsp;File'>Create a GitHub Merge Batch&nbsp;File</a></li><li><a
href='http://davidwalsh.name/mootools-github' rel='bookmark' title='Permanent Link: Follow MooTools on&nbsp;GitHub!'>Follow MooTools on&nbsp;GitHub!</a></li><li><a
href='http://davidwalsh.name/dojo-require' rel='bookmark' title='Permanent Link: The Beauty of&nbsp;dojo.require()'>The Beauty of&nbsp;dojo.require()</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/javascript-replace' rel='bookmark' title='Permanent Link: Replace All Occurrences of a String in&nbsp;JavaScript'>Replace All Occurrences of a String in&nbsp;JavaScript</a></li></ol>]]></description> <content:encoded><![CDATA[<p><img
src="http://davidwalsh.name/dw-content/moo-node.jpg" alt="MooTools and NodeJS" /></p><div
class="guest-blogger-top"><p>This post was authored by <a
href="http://cpojer.net/" target="_blank" rel="nofollow">Christoph Pojer</a>.  To learn more about Christoph, <a
href="#bio-pojer">click here</a>.</p></div><p> This blog post is intended to provide a starting point for ServerSide JavaScript (SSJS) development with MooTools. It is focused on NodeJS (<a
href="http://nodejs.org" target="_blank">http://nodejs.org</a>) and tries to explain the main concepts and differences from client side development. It is solely based on my current experience, my current work, and the best practices I have defined for myself so far &#8211; though most of this has been heavily influenced by people from other people of the MooTools team.</p><h2>How to Setup&nbsp;NodeJS</h2><ul><li>Download from <a
href="http://nodejs.org/#download" target="_blank">http://nodejs.org/#download</a></li><li>Build via ./configure &#038;&#038; make &#038;&#038; sudo make install</li></ul><p>It can&#8217;t get any easier.</p><h2>Current State of MooTools and&nbsp;SSJS</h2><p> Our current releases, MooTools Core 1.2 and 1.3beta2, do not work out of the box with NodeJS. NodeJS, as well as other serverside JavaScript implementations have adopted the CommonJS standard which includes a module system. Every module you create can export objects via the &#8220;exports&#8221; object. You can include a file by using &#8220;require(&#8216;path/to/module&#8217;)&#8221; which gives you access to the module&#8217;s exported variables:</p><h3>math.js</h3><pre class="js">
exports.add = function(a, b){
	return a + b;
};
</pre><h3>myApplication.js</h3><pre class="js">
var math = require('./math');

var sys = require('sys'); // System module

sys.puts(math.add(13, 37)); // Outputs "50"
</pre><p> You can execute this script via &#8220;node myApplication.js&#8221; on the command line.</p><p> You can find more information about this on the CommonJS Wiki: <a
href="http://wiki.commonjs.org/wiki/Modules/1.1" target="_blank">http://wiki.commonjs.org/wiki/Modules/1.1</a>.</p><p> The key difference between the module system as specified in CommonJS and normal client side script-tags is that they do not share the same (global) scope. This means that creating a variable via &#8220;var foo&#8221; in a module does not automatically make it available on the global object. The global object on the client side is the &#8220;window&#8221;-object which is usually not available on the serverside. In NodeJS the global object is called GLOBAL, whereas some other implementations simply use the name &#8220;global&#8221; or just reference it to &#8220;this&#8221; inside a module. This is not defined by CommonJS so every environment solves it in a different way.</p><p> While it is relatively easy to add support for modules in a JavaScript library that revolves around only one object, MooTools provides several global variables such as Class, Events, Type (Native) etc. In addition to that this new standard is very young and if we ever implement support for CommonJS directly into MooTools we want to define the best practices that we can recommend to our whole community.</p><p><em> Note: CommonJS is not actually a standard but more of a set of specifications that a serverside implementation of JavaScript can (or should) follow to unify the various environments and to make it possible to create modules that work on all platforms without any modifications. </em></p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/ServerSide-MooTools-Build.js" class="demo">Download ServerSide MooTools Build</a><div
class="clear"></div></div><h2>Get MooTools Running on&nbsp;NodeJS</h2><p> Over the past couple of months some members of the MooTools team came up with various ways to make MooTools CommonJS compatible. I have now created a repository on GitHub that helps create a build version of MooTools. This is mostly based on work by <a
href="http://keetology.com/" target="_blank">@keeto</a> and me. We are going to use the work-in-progress version of MooTools Core, which is a pre 1.3 version. If you don&#8217;t have git installed or don&#8217;t feel like entering some commands you can skip ahead to the next section and just download a pre-build version of MooTools: <a
href="http://davidwalsh.name/dw-content/ServerSide-MooTools-Build.js">MooTools.js</a> (based on <a
href="http://github.com/mootools/mootools-core/commit/d29f41a0e1d9fcf80cdd6894317d393e2885bab5" target="_blank">this</a> commit).</p><h3>Get MooTools 1.3wip (command&nbsp;line)</h3><pre class="js">
git clone git://github.com/cpojer/mootools-core.git
</pre><h3>Get Packager (requires php-cli to be&nbsp;installed)</h3><pre class="js">
git clone http://github.com/kamicane/packager.git
</pre><h3>Get the MooTools CommonJS&nbsp;Loader</h3><pre class="js">
git clone git://github.com/cpojer/mootools-loader.git
</pre><h3>Build a Custom MooTools&nbsp;Version</h3><pre class="js">
cd packager # Switch into the Packager folder

./packager register /path/to/mootools-core
./packager register /path/to/mootools-loader

./packager build Loader/Prefix Core/Class Core/Class.Extras Loader/Loader -blocks 1.2compat &gt; MooTools.js
</pre><p>You should see some output like this:</p><pre class="js">
Build using: Core, Loader
Included Files/Components:
- Loader/Prefix: [Prefix]
- Core/Core: [Core, MooTools, Type, typeOf, instanceOf]
- Core/Array: [Array]
- Core/String: [String]
- Core/Function: [Function]
- Core/Number: [Number]
- Core/Class: [Class]
- Core/Class.Extras: [Class.Extras, Chain, Events, Options]
- Core/Object: [Object, Hash]
- Loader/Loader: [Loader]
</pre><p>and a file &#8220;MooTools.js&#8221; should have been created that is ready to be used.</p><h2>Use MooTools in&nbsp;NodeJS</h2><pre class="js">
require.paths.push('path/to/mootoolsjs/');

require('MooTools').apply(GLOBAL);

var sys = require('sys');

var MyClass = new Class({

	initialize: function(){
		sys.puts('It works!');
	}

});

new MyClass;
</pre><p> Run this, again with the &#8220;node&#8221; command, on the command line and you should see &#8220;It works!&#8221; as output.</p><p> Please note that this is quite experimental, the functionality you will find is subject to change and might contain bugs. The above solution has so far only been tested on NodeJS but it should work on other SSJS implementations too</p><h2>Difference Between Applications and&nbsp;Modules</h2><p> One thing that I want to highlight is that I&#8217;m convinced that modules should not create global variables. However, the above mentioned solution puts everything MooTools provides on the global scope. While it is reasonable to do this when you are developing an application and you have control over every aspect of it, I do not believe it is a good idea to do this when you create a module (plugin) that uses MooTools. This is why the solution I came up with has another way to work with it, consider the following example.</p><h3>MyPlugin.js</h3><pre class="js">
var Moo = require('MooTools'),
	Class = Moo.Class,
	Options = Moo.Options,
	typeOf = Moo.typeOf;

exports.MyPlugin = new Class({

	Implements: [Options],
	
	options: {
		name: ''
	},
	
	initialize: function(options){
		if (!options) options = {};

		if (typeOf(options.name) != 'string')
			throw new Error("Ohmy!");
		
		this.setOptions(options);
	}

});
</pre><h3>MyApplication.js</h3><pre class="js">
// Add path to MooTools module so every module can just require "MooTools" without specifying the exact path
require.paths.push('path/to/mootoolsjs/');

var MyPlugin = require('path/to/MyPlugin').MyPlugin;

new MyPlugin({name: 'Kid Rock'});

// We can still add all the MooTools objects to the global scope without breaking anything
require('MooTools').apply(GLOBAL);

new Class(..);
</pre><p>You can now share the MyPlugin-Class with other people and it will work for them even if they do not put the MooTools objects on the global scope.</p><p><em>Note: MooTools still adds extensions to the native types, such as String, Array and Function even if you do not put it on the global scope. Executing &#8220;require(&#8216;MooTools&#8217;)&#8221; once makes all the extensions available in any scope. Note that, at least at the moment, all modules share the exact same datatypes; there are no sandboxed datatypes. If extending the native types in JavaScript does not align with your style of coding you should probably not use MooTools (or JavaScript, as it is a core feature of the language). One of the goals of the MooTools project is to provide a framework that feels natural and does not make a distinction between the core language and functionality of the library.</em></p><h2>Why &#8220;evented&#8221;? Async,&nbsp;huh?</h2><p>JavaScript, as a language mostly used on the clientside, has strong asynchronous capabilities. This means that most of the time you define certain functionality in your application that gets executed when a user &#8211; a real person &#8211; interacts with the content of a website. You usually do this by adding listeners to certain events on DOM elements:</p><pre class="js">
myElement.addEvent('click', function(){
	// This function gets executed upon interaction
});
</pre><p>You call the addEvent method and add a function to it, the program flow continues normally and the function is called asynchronously whenever a user clicks on it. In any case, you do not want to wait with the execution of any other code until this event gets executed. You do not want the click event listener to block. This is the main design goal of NodeJS: to be non-blocking for any I/O operations such as reading or writing a file, storing or retrieving data from a database etc. This means that most code you will write on the serverside passes around functions (callbacks, event listeners) that get executed at a later time (e.g. when results of an operation are ready). You can find a simple example right on the NodeJS website: <a
href="http://nodejs.org/" target="_blank">http://nodejs.org/</a></p><p>To give you a better understanding, this is some sample code of what user authentication could look like with MooTools:</p><pre class="js">
var Moo = require('MooTools'),
	Class = Moo.Class,
	Db = require('Database').getDatabase(),
	sha1 = require('Sha1');

exports.User = new Class({

	initialize: function(name){
  		this.name = name;
	},

	authenticate: function(password, callback){
		var user = this;
		Db.open(function(db){
			db.collection('users', function(err, collection){
				if (err) return callback(err);

				collection.findOne({name: user.name, password: sha1.hex(password)}, function(err, data){
					if (err) return callback(err);

					callback(null, data != null);
				});
			});
		});
	}

});
</pre><p>In your application you would now create a new instance of User and call the authenticate method with a callback like this</p><pre class="js">
	var User = require('User');

	var sys = require('sys');

	var instance = new User('david');
	instance.authenticate('kidrock', function(err, result){
		if (err) return; // handle database error

		if (result) sys.puts('User authenticated');
		else sys.puts('User does not exist');
	});
	sys.puts('Authenticating user');
</pre><p>This example will print out two messages &#8220;Authenticating user&#8221; and the result/success  of the authentication. The order relies on the speed of the database and likely &#8220;Authenticating user&#8221; will be printed out first. You can compare this to a setTimout example</p><pre class="js">
setTimeout(function(){
	log('Bye');
}, 1);
log('Hello');
</pre><p><em>Note: The callback style with the error as first argument is aligned to the way NodeJS currently works with asynchronous operations. Before that a &#8220;Promises&#8221; system was used but it has been removed. A high level implementation can abstract away from the current solution. Feel free to implement your own callback/event system with MooTools and share it with the community :)</em></p><p><em>Note: CommonJS actually specifies module identifiers to be lowercase. However, I like my filenames to start uppercased. You&#8217;ll always see me doing &#8220;require(&#8216;User&#8217;)&#8221; instead of &#8216;user&#8217; in my applications.</em></p><h2>Why ServerSide&nbsp;MooTools?</h2><p>One reason for the existence of JavaScript libraries is the lack of certain functionality especially on the DOM level and the enormous amount of issues between different rendering engines. You do not have any of these problems on the serverside. MooTools, as a library, works on a much lower level than some other libraries and it therefore provides useful utility functionality that we think is missing in JavaScript. In addition to that, even if there are CommonJS specifications, some implementations differ from the others. MooTools Core and an abstraction layer on top of that (like Deck ( <a
href="http://github.com/keeto/deck" target="_blank">http://github.com/keeto/deck</a> )) can greatly benefit you and help you eliminate or reduce low level problems you may encounter at some point during development.</p><p>In addition to that the sophisticated and clean class system provided by MooTools makes it possible to write abstract plugins that will work on both the server- and the clientside without any further modifications (ie. a Language/Internalization class, a schema validator, etc.). For more information on this feel free to <a
href="http://www.youtube.com/watch?v=6nOVQDMOvvE">watch my presentation at FOSDEM 2010 (at 25:00 + Q&#038;A)</a>.</p><div
class="actions"><a
href="http://davidwalsh.name/dw-content/ServerSide-MooTools-Build.js" class="demo">Download ServerSide MooTools Build</a><div
class="clear"></div></div><h2>Other (non-MooTools Related)&nbsp;Stuff</h2><ul><li>Driver for MongoDB which I used to contribute to: <a
href="http://github.com/christkv/node-mongodb-native" target="_blank">http://github.com/christkv/node-mongodb-native</a></li><li>WebSocket Server for NodeJS by MooTools Developer Guillermo Rauch: <a
href="http://github.com/LearnBoost/Socket.IO-node" target="_blank">http://github.com/LearnBoost/Socket.IO-node</a></li><li>ORM on top of the node-mongodb-driver by Nathan White and Guillermo Rauch: <a
href="http://github.com/nw/mongoose" target="_blank">http://github.com/nw/mongoose</a></li><li>Other Node Modules: <a
href="http://wiki.github.com/ry/node/modules" target="_blank">http://wiki.github.com/ry/node/modules</a></li></ul><h2>Bonus: Execute a Script in NodeJS from TextMate by Using&nbsp;NodeJS</h2><p>Add this command as a script:</p><pre class="js">
#!/usr/bin/env node

var sys = require('sys'),
    spawn = require('child_process').spawn;

spawn('node', [process.ENV.TM_FILEPATH]).stdout.addListener('data', function(data) {
  sys.puts(data);
});
</pre><p>Like this:</p><p><a
href="http://davidwalsh.name/dw-content/textmate-node.png" target="_blank"><img
src="http://davidwalsh.name/dw-content/textmate-node.png" alt="NodeJS and MooTools in TextMate" width="500" /></a></p><p><em>Click the image above for a larger view.</em></p><a
name="bio-pojer" id="bio-pojer"></a><div
class="guest-blogger-bio"> <img
src="http://davidwalsh.name/dw-content/cpojer-small.jpg" class="image" /><h2>About Christoph&nbsp;Pojer</h2><p> Christoph is a student of Software Engineering and Business Administration at the Graz University of Technology in Austria.
He is an experienced web developer and a Core Developer of the <a
href="http://mootools.net/">MooTools JavaScript Framework</a>.</p><p> <a
href="http://cpojer.net">Christoph&#8217;s Website</a> &bull; <a
href="http://github.com/cpojer">GitHub</a> &bull; <a
href="http://twitter.com/cpojer">Twitter</a> &bull; <a
href="http://mootools.net/forge/profile/cpojer">Forge</a></p></div><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-nodejs">ServerSide JavaScript with MooTools and&nbsp;NodeJS</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/github-merge-batch' rel='bookmark' title='Permanent Link: Create a GitHub Merge Batch&nbsp;File'>Create a GitHub Merge Batch&nbsp;File</a></li><li><a
href='http://davidwalsh.name/mootools-github' rel='bookmark' title='Permanent Link: Follow MooTools on&nbsp;GitHub!'>Follow MooTools on&nbsp;GitHub!</a></li><li><a
href='http://davidwalsh.name/dojo-require' rel='bookmark' title='Permanent Link: The Beauty of&nbsp;dojo.require()'>The Beauty of&nbsp;dojo.require()</a></li><li><a
href='http://davidwalsh.name/github-css' rel='bookmark' title='Permanent Link: Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript'>Create GitHub-Style Buttons with CSS and jQuery, MooTools, or Dojo&nbsp;JavaScript</a></li><li><a
href='http://davidwalsh.name/javascript-replace' rel='bookmark' title='Permanent Link: Replace All Occurrences of a String in&nbsp;JavaScript'>Replace All Occurrences of a String in&nbsp;JavaScript</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-nodejs/feed</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>MooTools Equal Heights Plugin:&#160;Equalizer</title><link>http://davidwalsh.name/mootools-equal-heights</link> <comments>http://davidwalsh.name/mootools-equal-heights#comments</comments> <pubDate>Fri, 25 Jun 2010 00:15:55 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Markup]]></category> <category><![CDATA[MooTools]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4993</guid> <description><![CDATA[Keeping equal heights between elements within the same container can be hugely important for the sake of a pretty page. Unfortunately sometimes keeping columns the same height can&#8217;t be done with CSS &#8212; you need a little help from your JavaScript friends. Well&#8230;now you&#8217;re in luck. View Demo The MooTools&#160;JavaScript var Equalizer = new Class({ [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-equal-heights">MooTools Equal Heights Plugin:&nbsp;Equalizer</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/plugin-element-filter' rel='bookmark' title='Permanent Link: New MooTools Plugin:&nbsp;ElementFilter'>New MooTools Plugin:&nbsp;ElementFilter</a></li><li><a
href='http://davidwalsh.name/mootools-highlighter-search' rel='bookmark' title='Permanent Link: Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin'>Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/mootools-typewriter' rel='bookmark' title='Permanent Link: MooTools Typewriter Effect&nbsp;Plugin'>MooTools Typewriter Effect&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/persistent-header-opacity' rel='bookmark' title='Permanent Link: Create a Sexy Persistent Header with Opacity Using MooTools or&nbsp;jQuery'>Create a Sexy Persistent Header with Opacity Using MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/image-protector-plugin-for-jquery' rel='bookmark' title='Permanent Link: dwImageProtector Plugin for&nbsp;jQuery'>dwImageProtector Plugin for&nbsp;jQuery</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Keeping equal heights between elements within the same container can be hugely important for the sake of a pretty page.  Unfortunately sometimes keeping columns the same height can&#8217;t be done with CSS &#8212; you need a little help from your JavaScript friends.  Well&#8230;now you&#8217;re in luck.</p><div
class="actions"><a
class="demo" href="http://davidwalsh.name/dw-content/equal-heights.php">View Demo</a><div
class="clear"></div></div><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">var Equalizer = new Class({
	initialize: function(elements) {
		this.elements = $$(elements);
	},
	equalize: function(hw) {
		if(!hw) { hw = 'height'; }
		var max = 0,
			prop = (typeof document.body.style.maxHeight != 'undefined' ? 'min-' : '') + hw; //ie6 ftl
			offset = 'offset' + hw.capitalize();
		this.elements.each(function(element,i) {
			var calc = element[offset];
			if(calc &gt; max) { max = calc; }
		},this);
		this.elements.each(function(element,i) {
			element.setStyle(prop,max - (element[offset] - element.getStyle(hw).toInt()));
		});
		return max;
	}
});
</pre><p>The first step is cycle through each element to find which is the tallest (or widest &#8212; this plugin accommodates for equal widths as well).  Once we know the largest number we can set the min-property for the element to that number while subtracting border and padding.  Simple!</p><h2>The Sample&nbsp;Usage</h2><pre class="js">var columnizer = new Equalizer('.sizeMe').equalize('height'); //call .equalize() as often as you want!
</pre><p>Obviously the class is super small.  You create one instance, passing elements initially.  From that point forward you can simply call the equalize method as many times as you would like.  This is especially useful if the contents of a given column changes frequently.</p><div
class="actions"><a
class="demo" href="http://davidwalsh.name/dw-content/equal-heights.php">View Demo</a><div
class="clear"></div></div><p>Let me know if you see any room for improvement.  I think this plugin will be quite useful for many developers.</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-equal-heights">MooTools Equal Heights Plugin:&nbsp;Equalizer</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/plugin-element-filter' rel='bookmark' title='Permanent Link: New MooTools Plugin:&nbsp;ElementFilter'>New MooTools Plugin:&nbsp;ElementFilter</a></li><li><a
href='http://davidwalsh.name/mootools-highlighter-search' rel='bookmark' title='Permanent Link: Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin'>Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/mootools-typewriter' rel='bookmark' title='Permanent Link: MooTools Typewriter Effect&nbsp;Plugin'>MooTools Typewriter Effect&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/persistent-header-opacity' rel='bookmark' title='Permanent Link: Create a Sexy Persistent Header with Opacity Using MooTools or&nbsp;jQuery'>Create a Sexy Persistent Header with Opacity Using MooTools or&nbsp;jQuery</a></li><li><a
href='http://davidwalsh.name/image-protector-plugin-for-jquery' rel='bookmark' title='Permanent Link: dwImageProtector Plugin for&nbsp;jQuery'>dwImageProtector Plugin for&nbsp;jQuery</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-equal-heights/feed</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>MooTools Class Sniffer&#160;Bookmarklet</title><link>http://davidwalsh.name/mootools-class-bookmarklet</link> <comments>http://davidwalsh.name/mootools-class-bookmarklet#comments</comments> <pubDate>Tue, 22 Jun 2010 03:24:24 +0000</pubDate> <dc:creator>David Walsh</dc:creator> <category><![CDATA[JavaScript]]></category> <category><![CDATA[MooTools]]></category><guid
isPermaLink="false">http://davidwalsh.name/?p=4983</guid> <description><![CDATA[I was recently reviewing a few MooTools-driven websites and one of the questions I wrote down was &#8220;Which MooTools Core classes do you use and how many classes have you created?&#8221; Then I asked myself if there was a way I could figure that out myself. The end result is a JavaScript bookmarklet that finds [...]<p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-class-bookmarklet">MooTools Class Sniffer&nbsp;Bookmarklet</a></p>Related posts:<ol><li><a
href='http://davidwalsh.name/check-for-google-analytics-using-mootools' rel='bookmark' title='Permanent Link: Check for Google Analytics Using MooTools&nbsp;1.2'>Check for Google Analytics Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/slick-pseudo' rel='bookmark' title='Permanent Link: Create Custom Pseudo Class Selectors Using the Slick Selector&nbsp;Engine'>Create Custom Pseudo Class Selectors Using the Slick Selector&nbsp;Engine</a></li><li><a
href='http://davidwalsh.name/javascript-closures' rel='bookmark' title='Permanent Link: Limiting Variable Scope Using&nbsp;(function(){})();'>Limiting Variable Scope Using&nbsp;(function(){})();</a></li><li><a
href='http://davidwalsh.name/mootools-highlighter-search' rel='bookmark' title='Permanent Link: Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin'>Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/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>]]></description> <content:encoded><![CDATA[<p>I was recently reviewing a few MooTools-driven websites and one of the questions I wrote down was &#8220;Which MooTools Core classes do you use and how many classes have you created?&#8221;  Then I asked myself if there was a way I could figure that out myself.  The end result is a JavaScript bookmarklet that finds all of the MooTools classes defined within the Window object.</p><div
class="actions"><a
href="javascript:(function(){if(window.MooTools==undefined){return false;}var a=[];for(obj in window){try{var b=(window.$type!=undefined?$type(window[obj]):typeOf(window[obj]));if(b=='class'){a.push(obj);}}catch(c){}}a.sort();console.log('# Classes: '+a.length);a.each(function(d){console.log(d);});})();" class="demo">MooTools Bookmarklet</a><div
class="clear"></div></div><h2>The MooTools&nbsp;JavaScript</h2><pre class="js">
(function() { 
if(window.MooTools == undefined) return false;
var classes = [];
for(obj in window) {
	try {
		var typo = (window.$type != undefined ? $type(window[obj]) : typeOf(window[obj]));
		if(typo == 'class') {
			classes.push(obj);
		}
	} catch(e) { }
}
classes.sort();
console.log('# Classes: ' + classes.length);
classes.each(function(klass) {
	console.log(klass);
}); })();
</pre><p>The key to finding each class is using the $type (&lt; MooTools 1.3) or typeOf (MooTools 1.3) functions.  If the result is &#8220;class&#8221;, we&#8217;ve found a class in the given scope.  The scope we&#8217;re searching for is window scope.  You can easily change the code snippet to change scope.  Checking every scope would be far too taxing so I&#8217;ve stuck to window-level objects.</p><div
class="actions"><a
href="javascript:(function(){if(window.MooTools==undefined){return false;}var a=[];for(obj in window){try{var b=(window.$type!=undefined?$type(window[obj]):typeOf(window[obj]));if(b=='class'){a.push(obj);}}catch(c){}}a.sort();console.log('# Classes: '+a.length);a.each(function(d){console.log(d);});})();" class="demo">MooTools Bookmarklet</a><div
class="clear"></div></div><p>There you have it.  MooTools 1.3 is structured a bit differently than 1.2 so you&#8217;ll see far fewer classes with 1.3.  Just a part of minimizing globals and tightening up this masterful framework!</p><p><strong>Follow Me!</strong> <a
href="http://twitter.com/davidwalshblog">Twitter</a> | <a
href="http://www.facebook.com/#!/pages/David-Walsh-Blog/186644584869">Facebook</a> | <a
href="http://www.linkedin.com/in/davidjameswalsh">LinkedIn</a> | <a
href="http://mootools.net/forge/profile/davidwalsh">MooTools Forge.</a><br/><br/>Full David Walsh Blog Post: <a
href="http://davidwalsh.name/mootools-class-bookmarklet">MooTools Class Sniffer&nbsp;Bookmarklet</a></p><p>Related posts:<ol><li><a
href='http://davidwalsh.name/check-for-google-analytics-using-mootools' rel='bookmark' title='Permanent Link: Check for Google Analytics Using MooTools&nbsp;1.2'>Check for Google Analytics Using MooTools&nbsp;1.2</a></li><li><a
href='http://davidwalsh.name/slick-pseudo' rel='bookmark' title='Permanent Link: Create Custom Pseudo Class Selectors Using the Slick Selector&nbsp;Engine'>Create Custom Pseudo Class Selectors Using the Slick Selector&nbsp;Engine</a></li><li><a
href='http://davidwalsh.name/javascript-closures' rel='bookmark' title='Permanent Link: Limiting Variable Scope Using&nbsp;(function(){})();'>Limiting Variable Scope Using&nbsp;(function(){})();</a></li><li><a
href='http://davidwalsh.name/mootools-highlighter-search' rel='bookmark' title='Permanent Link: Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin'>Highlighter: A MooTools Search &#038; Highlight&nbsp;Plugin</a></li><li><a
href='http://davidwalsh.name/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></p>]]></content:encoded> <wfw:commentRss>http://davidwalsh.name/mootools-class-bookmarklet/feed</wfw:commentRss> <slash:comments>3</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 93/273 queries in 4.246 seconds using disk

Served from: davidwalsh.name @ 2010-09-02 23:18:37 -->