<?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>Solutoire.com &#187; Mootools</title>
	<atom:link href="http://solutoire.com/category/mootools/feed/" rel="self" type="application/rss+xml" />
	<link>http://solutoire.com</link>
	<description>Publicing platform</description>
	<lastBuildDate>Thu, 26 Feb 2009 17:07:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Delayed Image Preloading Using Mootools</title>
		<link>http://solutoire.com/2008/11/02/delayed-image-preloading-usin-mootools/</link>
		<comments>http://solutoire.com/2008/11/02/delayed-image-preloading-usin-mootools/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 15:44:50 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[image preloading]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://solutoire.com/?p=190</guid>
		<description><![CDATA[
It&#8217;s almost three months ago since my last post! I&#8217;m quite busy at the moment. That&#8217;s why I&#8217;ll just write a quickie on delayed image preloading using Mootools (1.2.1, also might work with 1.2 and 1.1).

Image preloading

Most of the times you&#8217;ll need preloading when there are elements in the DOM that are hidden, but have [...]]]></description>
			<content:encoded><![CDATA[<p>
It&#8217;s almost three months ago since my last post! I&#8217;m quite busy at the moment. That&#8217;s why I&#8217;ll just write a quickie on delayed image preloading using <a href="http://www.mootools.net" title="Mootools Home">Mootools</a> (1.2.1, also might work with 1.2 and 1.1).
</p>
<h2>Image preloading</h2>
<p>
Most of the times you&#8217;ll need preloading when there are elements in the DOM that are hidden, but have an image background. On the moment the elements are shown and the images are not found in cache, the images are loaded from the server. This action has a small delay, so your element first shows up without the image background. That might confuse the visitor.
</p>
<p>Note that there are other possible scenario&#8217;s that need image preloading, but this case is a nice introduction.</p>
<h2>Delaying image preloading</h2>
<p>
Why in the world would we like to delay the preloading of the images? Well, most browsers only allow two concurrent requests at the same time to the same domain (correct me if I&#8217;m wrong). When we do the image preloading on <code><a href="http://mootools.net/docs/Utilities/DomReady" title="Mootools Documentation: DomReady">domready</a></code>, it might hold up other resources that need to be loaded. Because we preload images that are not shown when the page loads, we can delay the preloading.
</p>
<h2>The javascript</h2>
<p>
Let&#8217;s say we have a total of five images that need to be preloaded. Here&#8217;s how I would preload the image, 3 seconds after the dom is ready:
</p>
<pre class="javascript"><code>Array.each.delay(3000,this,[
	['foo.gif', 'bar.png','moo.png','tools.png', 'mootools.png'],
	function(src){var img = new Image();img.src = src;}
]);
</code></pre>
<p>
Easy huh? It delays a call to Array.each by 3000 ms. Then it passes the array of images as the first argument, and the function as the second. You can read more about <code>delay</code> at the <a href="http://mootools.net/docs/Native/Function#Function:delay" title="Mootools Documentation">Mootools Docs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2008/11/02/delayed-image-preloading-usin-mootools/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Writing A Feed Reader</title>
		<link>http://solutoire.com/2008/06/27/writing-a-feed-reader/</link>
		<comments>http://solutoire.com/2008/06/27/writing-a-feed-reader/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 18:46:25 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Feed Reader]]></category>
		<category><![CDATA[Google AJAX Feed API]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://solutoire.com/?p=175</guid>
		<description><![CDATA[
Yesterday I was playing around with the Google AJAX Feed API. With the API, you can download any public Atom or RSS feed using only javascript. By mixing the Google AJAX Feed API with MooTools 1.2, I wrote a tiny feed reader application in 30 lines of javascript goodness.



My tiny feed reader

The Feed Reader

This feed [...]]]></description>
			<content:encoded><![CDATA[<p>
Yesterday I was playing around with the <a href="http://code.google.com/apis/ajaxfeeds/" title="Google AJAX Feed API">Google AJAX Feed API</a>. With the API, you can download any public Atom or RSS feed using only javascript. By mixing the Google AJAX Feed API with <a href="http://mootools.net/" title="MooTools Javascript Framework">MooTools 1.2</a>, I wrote a <a href="http://solutoire.com/experiments/apps/feedreader/" title="Feed Reader Example">tiny feed reader</a> application in 30 lines of javascript goodness.
</p>
<div class="img">
<a href="http://solutoire.com/experiments/apps/feedreader/" title="Feed Reader Example"><img src="http://solutoire.com/blog/wp-content/uploads/2008/06/feed.png" alt="My tiny feed reader" title="feed" width="320" height="147" /></a><br />
<i>My tiny feed reader</i>
</div>
<h2>The Feed Reader</h2>
<p>
This feed reader polls the <a href="http://www.colourlovers.com/" title="COLOURlovers">COLOURlovers.com</a> Palettes feed and Colours feed every 20 seconds for new items. New items are highlighted with the MooTools <code><a href="http://docs.mootools.net/Fx/Fx.Tween#Element:highlight" title="MooTools Docs - Fx/Fx.Tween">Element.highlight()</a></code> function. The Google AJAX Feed API passes <abbr title="JavaScript Object Notation">JSON</abbr> to a callback function, which adds the new &#8216;colour&#8217; or &#8216;palette&#8217; entries to the list. Below you can see the uncommented code. The <a href="http://solutoire.com/experiments/apps/feedreader/" title="MooTools Feed Reader">feed reader example</a> contains a <a href="http://solutoire.com/experiments/apps/feedreader/scripts/feed.js">commented version</a>.
</p>
<pre><code>var Site = {
	entries: [],
	timer: 0,
	init: function(){
		this.paletteFeed = new google.feeds.Feed('http://feeds.feedburner.com/ColourloversCoup0Palettes/New');
		this.colourFeed = new google.feeds.Feed('http://feeds.feedburner.com/ColourloversCoup0Colours/New');
		this.poll.periodical(1000, this);
	},
	poll: function(){
		if (--this.timer &lt;= 0) {
			this.colourFeed.load(this.onLoadCallback.bind(this));
			this.paletteFeed.load(this.onLoadCallback.bind(this));
			this.timer = 20;
		}
		$('refresh').set('html','Refreshing feeds in ' + this.timer + ' second(s)...');
	},
	onLoadCallback:function(json){
		if (json.error) return;
		for (var i = json.feed.entries.length - 1; i &gt;= 0; i--) {
			var entry = json.feed.entries[i];
			if (!this.entries.contains(entry.title)) {
				this.entries.push(entry.title);
				$('feeds').innerHTML = ('&lt;li class=&quot;entry&quot;&gt;&lt;a href=&quot;{link}&quot; title=&quot;{title}&quot;&gt;{content}&lt;/a&gt;&lt;/li&gt;').substitute(entry) + $('feeds').innerHTML;
			}
		}
		$$('.entry').set('tween',{duration:2000}).highlight().removeClass('entry');
	}
};
google.load('feeds', '1');
window.addEvent('domready', Site.init.bind(Site));
</code></pre>
<h2>What&#8217;s next?</h2>
<ul>
<li><a href="http://code.google.com/apis/ajaxfeeds/" title="Google AJAX Feed API">Google AJAX Feed API</a></li>
<li><a href="http://docs.mootools.net/" title="MooTools Docs">MooTools Docs</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2008/06/27/writing-a-feed-reader/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mootools Puzzle Game</title>
		<link>http://solutoire.com/2008/03/28/mootools-puzzle-game/</link>
		<comments>http://solutoire.com/2008/03/28/mootools-puzzle-game/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 18:45:57 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[about]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[puzzle]]></category>

		<guid isPermaLink="false">http://solutoire.com/2008/03/28/mootools-puzzle-game/</guid>
		<description><![CDATA[
I wrote a pretty useless puzzle game that makes use of Mootools. I was updating the &#8216;about&#8217; page on this blog, and I was looking for an original way to show a picture of myself. So take a look at the the about page and play around with it.



Play with me

]]></description>
			<content:encoded><![CDATA[<p>
I wrote a pretty useless puzzle game that makes use of Mootools. I was updating the &#8216;about&#8217; page on this blog, and I was looking for an original way to show a picture of myself. So take a look at the the <a href="http://www.solutoire.com/about" title="About Bas Wenneker">about page</a> and <a href="http://www.solutoire.com/about#puzzle" title="Puzzle with me">play around</a> with it.
</p>
<div class="img">
<a href="http://solutoire.com/about#puzzle" title="Puzzle Game"><img src="http://solutoire.com/blog/wp-content/uploads/2008/03/puzzle-game.png" style="border:0px;" alt="Puzzle Game" /></a><br />
<i>Play with me</i>
</div>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2008/03/28/mootools-puzzle-game/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Update: Mootools CSS Styled Scrollbar</title>
		<link>http://solutoire.com/2008/03/11/update-mootools-css-styled-scrollbar/</link>
		<comments>http://solutoire.com/2008/03/11/update-mootools-css-styled-scrollbar/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 07:16:30 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[scrollbar]]></category>

		<guid isPermaLink="false">http://solutoire.com/2008/03/11/update-mootools-css-styled-scrollbar/</guid>
		<description><![CDATA[
I&#8217;ve updated my previous post Mootools CSS Styled Scrollbar. I&#8217;ve added instructions about how to make it work with Mootools version 1.11. Also the example is updated. On the Mootools forums someone called &#8216;horseweapon&#8217; wrote a simple function that used my code to make scrollbars. I used his function to work with the example. You [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve updated my previous post <a href="http://solutoire.com/2008/03/10/mootools-css-styled-scrollbar/" title="Mootools CSS Styled Scrollbar">Mootools CSS Styled Scrollbar</a>. I&#8217;ve added instructions about how to make it work with Mootools version 1.11. Also the example is updated. On the Mootools forums someone called &#8216;horseweapon&#8217; wrote a <a href="http://forum.mootools.net/viewtopic.php?pid=43321#post-43311" title="Mootools Forums">simple function</a> that used my code to make scrollbars. I used his function to work with the example. You can see the updated example <a href="http://solutoire.com/experiments/scrollbar/index.html" title="Mootools Scrollbar Example">over here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2008/03/11/update-mootools-css-styled-scrollbar/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mootools CSS Styled Scrollbar</title>
		<link>http://solutoire.com/2008/03/10/mootools-css-styled-scrollbar/</link>
		<comments>http://solutoire.com/2008/03/10/mootools-css-styled-scrollbar/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 21:59:35 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[scrollbar]]></category>

		<guid isPermaLink="false">http://solutoire.com/2008/03/10/mootools-css-styled-scrollbar/</guid>
		<description><![CDATA[
I wrote a small piece of javascript that creates a css styled scrollbar from the Mootools (version 1.2b2) Slider class. I know there is a scrollbar class for Mootools but it&#8217;s more than 100 lines of code. If you only need one or two bars, try my solution instead. The example page shows three div [...]]]></description>
			<content:encoded><![CDATA[<p>
I wrote a small piece of javascript that creates a css styled scrollbar from the Mootools (version 1.2b2) Slider class. I know there is <a href="http://mootools.net/uploads/scrollbar/" title="Mootools Scrollbar Class">a scrollbar class</a> for Mootools but it&#8217;s more than 100 lines of code. If you only need one or two bars, try my solution instead. <a href="http://www.solutoire.com/experiments/scrollbar/index.html" title="Mootools Scrollbar Example">The example page</a> shows three div elements with a styled horizontal and/or vertical scrollbars.
</p>
<div class="img">
<a href="http://www.solutoire.com/experiments/scrollbar/index.html" title="Mootools Scrollbar"><img src="http://solutoire.com/blog/wp-content/uploads/2008/03/scrollbar.png" alt="Mootools Scrollbar" /></a><br />
<i>Mootools Powered Scrollbar</i>
</div>
<h2>Update: making it work with Mootools 1.11</h2>
<p>
It&#8217;s easy to get his working under Mootools 1.11. The syntax for getting the <code>scrollsizes</code> and <code>sizes</code> in Mootools 1.2b2 has changed a bit:
</p>
<pre><code class=""javascript">// => Mootools 1.2b2, elements' size and vertical scrollsize
var size = element.getSize().y;
var scrollSize = element.getScrollSize().y;
// => Mootools 1.11, elements' size and vertical scrollsize
var size = element.getSize().size.y;
var scrollSize = element.getSize().scrollSize.y;
</code></pre>
<p>
For the scrollbars, I&#8217;ve used the size and scrollsize of the content element. So to get the scrollbars working under Mootools 1.11, you have to change only one line per scrollbar (see the <code>steps</code> option):
</p>
<pre><code class=""javascript">// => For vertical scrollbars
...
new Slider(scrollbar, handle, {
	steps: content.getSize().scrollSize.y - content3.getSize().size.y,
	mode: 'vertical',
...
// => For horizontol scrollbars
...
new Slider(scrollbar, handle, {
	steps: content.getSize().scrollSize.x - content3.getSize().size.x,
	mode: 'vertical',
...
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2008/03/10/mootools-css-styled-scrollbar/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Building and Testing the Mootools SVN Trunk</title>
		<link>http://solutoire.com/2008/02/08/building-and-testing-the-mootools-svn-trunk/</link>
		<comments>http://solutoire.com/2008/02/08/building-and-testing-the-mootools-svn-trunk/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 07:19:37 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://solutoire.com/2008/02/08/building-and-testing-the-mootools-svn-trunk/</guid>
		<description><![CDATA[
Ever wondered how the Mootools development team tests Mootools SVN Trunk code? Personally, I don&#8217;t think they build their js file with the download builder bookmarklet I posted a few weeks ago. I&#8217;ll go into how to load all Mootools components from the SVN Trunk when testing.

Where to start

I assume you&#8217;re familiar with SVN, for [...]]]></description>
			<content:encoded><![CDATA[<p>
Ever wondered how the Mootools development team tests Mootools SVN Trunk code? Personally, I don&#8217;t think they build their js file with the <a href="http://solutoire.com/2008/01/03/the-mootools-download-builder-bookmarklet/" title="The Mootools Download Builder Bookmarklet">download builder bookmarklet</a> I posted a few weeks ago. I&#8217;ll go into how to load all Mootools components from the SVN Trunk when testing.
</p>
<h2>Where to start</h2>
<p>
I assume you&#8217;re familiar with SVN, for those not, the <a href="http://svnbook.red-bean.com/">SVN Book</a> is a good place to start. My development environment looks like this:
</p>
<ul>
<li><a href="http://www.eclipse.org/downloads/">Eclipse</a> IDE for Java Developers</li>
<li>Downloaded <a href="http://www.aptana.com/node/187">Aptana</a> as an Eclipse plugin</li>
<li><a href="http://subclipse.tigris.org/">Subclipse</a>, Eclipse SVN plugin</li>
</ul>
<p>
Of course you don&#8217;t need all this, you can also use the <a href="http://tortoisesvn.tigris.org/" title="Turtoise SVN Browser Project page">Turtoise SVN Browser</a> and use the IDE of your choice. Next step, is to <a href="http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.tour.initial" title="SVN Book - Checkout">checkout</a> the Mootools SVN trunk, by pointing your SVN browser to <a href="http://svn.mootools.net/trunk" title="Mootools SVN trunk">http://svn.mootools.net/trunk</a>. The trunk holds the latest development version of Mootools. In Aptana, you can do the following: File &rsaquo; New &rsaquo; Other &rsaquo; SVN &rsaquo; Checkout Projects from SVN &rsaquo; Create new repository location. The rest you can figure out yourself.
</p>
<h2>Zillions of files</h2>
<p>
Once you have downloaded the trunk, you can see a few folders, which are containing a lot of files. Now, what to do if you want to test your own code with the SVN trunk version of Mootools, and you don&#8217;t like to use the download builder? Very easy if you ask me. Just do the following:
</p>
<ul>
<li>Create a new folder in the trunk root (ex. MyFolder)</li>
<li>Create a new HTML file (ex. index.html)</li>
</ul>
<p>
Your filestructure should look something like this:
</p>
<div class="img">
<img src='http://solutoire.com/blog/wp-content/uploads/2008/02/mootools-trunk.png' alt='Mootools SVN Trunk' /><br />
<i>Example Mootools File structure</i>
</div>
<p>
Now we need some code that includes all trunk javascript files from the <code>Source</code> folder into the document. This can easily be done by the following piece of code:
</p>
<pre><code class="html">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
		&lt;title&gt;Untitled Document&lt;/title&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;../Specs/Builder.js&quot;&gt;&lt;/script&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			// This code includes all js files from the Source folder
			Builder.includeType('source');
		&lt;/script&gt;
	&lt;/head&gt;
	&lt;body&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
			window.addEvent('load', function(){
				alert('Version: ' + MooTools.version);
			});
			window.addEvent('domready', function(){
				alert('This alert won\'t show up!');
			});
		&lt;/script&gt;
	&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>
When the page has loaded it alerts the Mootools version.
</p>
<h2>Important</h2>
<p>
As you can see in the code above I added an event handler to the load event of the window. Of course this is a bad practice, I should use the <a href="http://demos.mootools.net/DomReadyVS.Load" title="Mootools domready Event demo">&#8216;domready&#8217;</a> event, which is fired sooner because it doesn&#8217;t wait on images to load. In this case I have to use the load event, because we include the javascript code for the &#8216;domready&#8217; event when the page is already loading. So the &#8216;domready&#8217; event doesn&#8217;t even fire.
</p>
<p>So now you can test like a real pro and use the SVN trunk code to stay ahead of version changes. How did you test before? Share it by leaving a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2008/02/08/building-and-testing-the-mootools-svn-trunk/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Mootools Download Builder Bookmarklet</title>
		<link>http://solutoire.com/2008/01/03/the-mootools-download-builder-bookmarklet/</link>
		<comments>http://solutoire.com/2008/01/03/the-mootools-download-builder-bookmarklet/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 21:05:23 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://solutoire.com/2008/01/03/the-mootools-download-builder-bookmarklet/</guid>
		<description><![CDATA[
Personally, I love Mootools download builder. There&#8217;s just one feature that is missing, it becomes very annoying everytime I needs the entire Mootools library. I can remember the old (?) download builder had a &#8220;check all&#8221; button, which included (checks) all Mootools components to the file I was about to download. Nowadays, the download builder [...]]]></description>
			<content:encoded><![CDATA[<p>
Personally, I love Mootools download builder. There&#8217;s just one feature that is missing, it becomes very annoying everytime I needs the entire Mootools library. I can remember the old (?) download builder had a &#8220;check all&#8221; button, which included (checks) all Mootools components to the file I was about to download. Nowadays, the download builder doesn&#8217;t have this feature anymore. Well, actually the download builder has the functionality to check all components, but it lacks a button. I wrote a bookmarklet that let&#8217;s you do the trick.
</p>
<div class="img">
<img src='http://solutoire.com/blog/wp-content/uploads/2008/01/mootools-download.png' alt='Mootools Download Builder' /><br />
<i>The Mootools Download Builder</i>
</div>
<h2>Bookmarklets</h2>
<p>
Wikipedia has the following to say about bookmarklets:
</p>
<blockquote><p>A bookmarklet is an applet, a small computer application, stored as the URL of a bookmark in a web browser or as a hyperlink on a web page.</p></blockquote>
<p>
So it&#8217;s a small piece of javascript, that can be saved as a bookmark, and executed when the bookmark is pressed.
</p>
<p>
For the Mootools Download Builder I wrote a bookmarklet that toggles all checkboxes. It looks like this:
</p>
<pre><code class="javascript">// Name of the Download Builder function to execute ('none' or 'all').
var function_name;	

// Boolean: true when all checkboxes are checked, false otherwise.
var checked_all = Download.chks.every(function(chk){
	return chk.hasClass('selected')
});

// Determine which function to execute.
if(checked_all){
	// All checkboxes are checked, so execute Download.none().
	function_name =  'none';
}else{
	// No checkboxes are checked, so execute Download.all().
	function_name =  'all';
} 

// Toggle all checkboxes.
Download[function_name]();
</code></pre>
<p>
Because bookmarklets can have to be on a single line, I wrote a compact version of the code above:
</p>
<pre><code class="javascript">// Compact version of the bookmarklet.
Download[Download.chks.every(function(chk){return chk.hasClass('selected')})?'none':'all']();
</code></pre>
<p>
The HTML for the bookmarklet looks like this:
</p>
<pre><code class="html">// HTML for the bookmarklet
&lt;a href=&quot;javascript:Download[Download.chks.every(function(chk){return chk.hasClass('selected')})?'none':'all']();&quot;&gt;Toggle Mootools Components&lt;/a&gt;
</code></pre>
<p>
To test it, bookmark the following link: <a href="javascript:Download[Download.chks.every(function(chk){return chk.hasClass('selected')})?'none':'all']()">Toggle Mootools Components</a>. Then go to the <a href="http://mootools.net/download/" title="Mootools Download Builder">Mootools Download Builder</a>, and press the bookmarklet. You can see all components are toggled.
</p>
<h2>Mootools Download Builders</h2>
<p>
No, it&#8217;s not a typo, there are several download builder around. They&#8217;re all different.
</p>
<ul>
<li><a href="http://mootools.net/download/" title="Mootools Download Builder: stable">http://mootools.net/download/</a>: Build Mootools using the latest stable components.</li>
<li><a href="http://mootools.net/download/tags/1-2b1" title="Mootools Download Builder: stable">http://mootools.net/download/tags/1-2b1</a>: Build Mootools using the 1.2 beta1 components.</li>
<li><a href="http://mootools.net/download/trunk" title="Mootools Download Builder: trunk">http://mootools.net/download/trunk</a>: Build Mootools using the latest svn revision.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2008/01/03/the-mootools-download-builder-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Understanding Mootools Selectors $, $$, $E and $ES</title>
		<link>http://solutoire.com/2007/09/20/understanding-mootools-selectors-e-and-es/</link>
		<comments>http://solutoire.com/2007/09/20/understanding-mootools-selectors-e-and-es/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 15:38:07 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[$]]></category>
		<category><![CDATA[$$]]></category>
		<category><![CDATA[dollar]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://solutoire.com/2007/09/20/understanding-mootools-selectors-e-and-es/</guid>
		<description><![CDATA[
While browsing the Mootools forums I came across an excellent post by Fløe Rasmus. He explains to a mootools newbie how to use the selector functions $ and $$. In this article I&#8217;ll explain how $, $$, $E and $ES work, and as a bonus I&#8217;ll list all the dollar functions in Mootools v1.11.

The $ [...]]]></description>
			<content:encoded><![CDATA[<p>
While browsing the Mootools forums I came across <a href="http://forum.mootools.net/viewtopic.php?id=5432#post-27105">an excellent post</a> by <a href="http://phloe.net/">Fløe Rasmus</a>. He explains to a mootools newbie how to use the selector functions $ and $$. In this article I&#8217;ll explain how $, $$, $E and $ES work, and as a bonus I&#8217;ll list all the dollar functions in Mootools v1.11.
</p>
<h2>The $ (dollar) function</h2>
<p>
Most people think this is just a shortcut for <code>document.getElementById()</code>, but actually it&#8217;s not. The <code>$()</code> takes one argument. This argument is called <em>mixed</em> in php terms, because it can be a string, or a dom element. Whenever the argument is a string <em>s</em>, it returns the element with id <em>s</em> with all <code>Element</code> <a href="http://docs.mootools.net/Native/Element.js">methods</a> applied. When the argument is a dom element, it just applies all Element methods to the element, and returns it. Here&#8217;s how it works:
</p>
<pre><code class="javascript">var w3cEl = document.getElementById('myDiv'); // w3cEl => W3C dom element
var mooEl = $('myDiv'); // mooEl => Mootools Element
var mooEl2 = $(w3cRef); // mooEl2 => Mootools Element
var mooEl3 = $(mooEl2); // mooEl3 => mooEl2
</code></pre>
<p>
So the $ function applies the Element methods to it&#8217;s argument. When passing a Mootools Element to <code>$</code> it &#8216;ll be detected and no methods are applied, because the argument already has those methods (see example above <code>mooEl3</code>).
</p>
<h2>The $$ (double dollar) function</h2>
<p>
The double dollar function is more like <code>document.getElementsByTagName()</code> on steroids, both will return an array with multiple elements.
</p>
<pre><code class="javascript">var w3cArr = document.getElementsByTagName('div'); // w3cArr => Array of W3C dom elements
var mooArr = $$('div'); // mooArr => Array of Mootools Elements
</code></pre>
<p>
But <code>$$</code> can do more. It&#8217;ll accept one or more css selectors (or elements) and return an array of elements matching those selectors:
</p>
<pre><code class="javascript">$$('a.external'); // => Array of links with class 'external'
$$('a[href=#]'); // => Array of links with href="#"
$$('form input[disabled]'); // Array of input elements inside a form with a disabled attribute
$$('form input[disabled=disabled]'); // Array of disabled input elements inside a form (valid XHTML)
$$('div[class^=foo]'); // => Array of divs with classname starting with 'foo'
$$('[class$=bar]'); // => Array of elements with classname ending with 'bar'
$$('*[class$=bar]'); // => Returns the same as the previous selector
</code></pre>
<p>
Want to know more about the css3 selectors? Read the W3C <a href="http://www.w3.org/TR/css3-selectors/#selectors" title="W3C about CSS3">css3 selector</a> specification. Keep in mind the Mootools <code>$$</code> function doesn&#8217;t support all selectors.
</p>
<h2>The $E function</h2>
<p>
This function is very much like the <code>$</code> function. The first argument of <code>$E</code> is a css selector string and it returns the first found element found with the selector. The second element is the filter (id string or DOM element). See it like a scope, when the filter is passed, the selector is executed inside the filter element. So instead of passing an id to the dollar function, you can pass a css selector to <code>$E</code>.
</p>
<pre><code class="javascript">$E('div#foo'); // => Same as $('foo')
$E('ul#bar li'); // => The first list item of the unordered list with id 'bar'
$E('form input[type=checkbox]'); // => First checkbox of the first form
$E('input[type=checkbox]', 'myForm'); // => First checkbox of the element with id 'myForm'
</code></pre>
<h2>The $ES (Element.getElements) function</h2>
<p>
The <code>$ES</code> function is very much the same as the <code>$$</code> and the <code>$E</code> functions. The first argument is the css selector, and the second argument is the filter. <code>$ES</code> returns an array of elements found with the css selector, which is executed inside the filter element. It&#8217;s pretty straightforward:
</p>
<pre><code class="javascript">$ES('a.external'); // => Same as $$('a.external')
$ES('a.external', document); // => Same as $ES('a.external')
$ES('input', 'myForm'); // => Array of input elements within the element with id 'myForm'
$ES('input[type=text]', 'myForm'); // => Array of textbox elements within the element with id 'myForm'
</code></pre>
<h2>Bonus: other $ functions</h2>
<p>
There are some more dollar function that come with Mootools:
</p>
<ul>
<li><code>$chk</code>: Returns true if the passed in value/object exists or is 0, otherwise returns false.</li>
<li><code>$clear</code>: Clears a timeout or an Interval.</li>
<li><code>$defined</code>: Returns true if the passed in value/object is defined, that means is not null or undefined.</li>
<li><code>$extend</code>: Copies all the properties from the second passed object to the first passed Object.</li>
<li><code>$merge</code>: Merges a number of objects recursively without referencing them or their sub-objects.</li>
<li><code>$native</code>: Will add a .extend method to the objects passed as a parameter, but the property passed in will be copied to the object’s prototype only if non previously existent.</li>
<li><code>$pick</code>: Returns the first object if defined, otherwise returns the second.</li>
<li><code>$random</code>: Returns a random integer number between the two passed in values.</li>
<li><code>$time</code>: Returns the current timestamp.</li>
<li><code>$type</code>: Returns the type of object that matches the element passed in.</li>
<li><code>$A</code>: Returns a copy of the passed Array.</li>
<li><code>$each</code>: Use to iterate through iterables that are not regular arrays, such as builtin getElementsByTagName calls, arguments of a function, or an object.</li>
<li><code>$H</code>: Shortcut to create a Hash from an Object.</li>
<li><code>$RGB</code>: 	Shortcut to create a new color, based on red, green, blue values.</li>
<li><code>$HSV</code>: Shortcut to create a new color, based on hue, saturation, brightness values.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2007/09/20/understanding-mootools-selectors-e-and-es/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Submitting forms asynchronously using Mootools</title>
		<link>http://solutoire.com/2007/09/10/submitting-forms-asynchronously-using-mootools/</link>
		<comments>http://solutoire.com/2007/09/10/submitting-forms-asynchronously-using-mootools/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 19:49:08 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://solutoire.com/2007/09/10/submitting-forms-asynchronously-using-mootools/</guid>
		<description><![CDATA[
In this article I&#8217;ll explain how to submit your forms using some Mootools magic. The techniques used are pretty basic and easy to understand. Sit back and relax, or just take a look at the result.

Setting up the form

First, we need a form. So let&#8217;s make a simple comment form:

&#60;form id=\&#34;myForm\&#34; action=\&#34;script.php\&#34;&#62;
	&#60;table cellpadding=\&#34;0\&#34; cellspacing=\&#34;0\&#34;&#62;
		&#60;col width=\&#34;100\&#34;&#62;
		&#60;col [...]]]></description>
			<content:encoded><![CDATA[<p>
In this article I&#8217;ll explain how to submit your forms using some <a href="http://www.mootools.net">Mootools</a> magic. The techniques used are pretty basic and easy to understand. Sit back and relax, or just take a look at the <a href="/experiments/mootools_form/index.html">result</a>.
</p>
<h2>Setting up the form</h2>
<p>
First, we need a form. So let&#8217;s make a simple comment form:
</p>
<pre><code class="html">&lt;form id=\&quot;myForm\&quot; action=\&quot;script.php\&quot;&gt;
	&lt;table cellpadding=\&quot;0\&quot; cellspacing=\&quot;0\&quot;&gt;
		&lt;col width=\&quot;100\&quot;&gt;
		&lt;col width=\&quot;200\&quot;&gt;
		&lt;tr&gt;
			&lt;td&gt;Name:&lt;/td&gt;
			&lt;td&gt;&lt;input type=\&quot;text\&quot; name=\&quot;author\&quot; value=\&quot;\&quot; /&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;Email:&lt;/td&gt;
			&lt;td&gt;&lt;input type=\&quot;text\&quot; name=\&quot;email\&quot; value=\&quot;\&quot; /&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;Comment:&lt;/td&gt;
			&lt;td&gt;&lt;textarea name=\&quot;comment\&quot;&gt;&lt;/textarea&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td colspan=\&quot;2\&quot;&gt;&lt;input type=\&quot;submit\&quot; id=\&quot;submit\&quot; value=\&quot;submit\&quot; /&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
&lt;/form&gt;
</code></pre>
<p>
This form consists of four controls. Two textboxes for the authors name and email address, a textarea for the comment text and a submit button. In the next part I&#8217;ll explain how to submit the form asynchronously using Mootools.
</p>
<h2>Submit the form using Ajax</h2>
<p>
It&#8217;s surprising how easy it is to submit the form using ajax. Basically we need to do three things:
</p>
<ol>
<li>Listen for the &#8216;click&#8217; event on the submit button.</li>
<li>Stop the event from submitting the form.</li>
<li>Send the form using <code>$(formElement).send()</code></li>
</ol>
<p>
A solution could look something like this:
</p>
<pre><code class="javascript">$('submit').addEvent( 'click', function(evt){
	// Stops the submission of the form.
	new Event(evt).stop();

	// Sends the form to the action path,
	// which is 'script.php'
	$('myForm').send();
} );</code></pre>
<p>
Ok, that&#8217;s cool, we can submit a form asynchronously in about three lines of code. But this is not all, when using ajax for form submission, you need to let the user know what is happening/has happened. In the next part I&#8217;ll tell how to do that.
</p>
<h2>Show progress to the user</h2>
<p>
When you&#8217;re using ajax to submit a form, you need to show the user that something is going on in the background. A way to do that is to show an animated ajax loader gif. At <a href="http://www.ajaxload.info/">ajaxload.info</a> you can generate pretty sweet ajax loaders. First choose from around 20 different animated gifs, and specify the back and foreground color. In the article <a href="http://solutoire.com/2007/02/16/mootools-ajax-xhr-classes/">&#8216;Mootools: Ajax &#038; XHR classes&#8217;</a> I explained how to show and hide the loader gif. To give you a quick example, here&#8217;s how to do it, with GMail style progress indicators:
</p>
<pre><code class="javascript">// Variable that holds the effects.
var fx = {
	'loading': new Fx.Style( 'loading', 'opacity',{ duration: 200 } ),
	'success': new Fx.Style( 'success', 'opacity',{ duration: 200 } ),
	'fail': new Fx.Style( 'fail', 'opacity',{ duration: 200 } )
};

// Hides the loading div, and shows the el div for
// a period of four seconds.
var showHide = function( el ){
	fx.loading.set(0);
	(fx[ el ]).start(0,1);
	(function(){ (fx[ el ]).start(1,0); }).delay( 4000 );
}

// Listen for click events on the submit button.
$('submit').addEvent( 'click', function(evt){
	// Stops the submission of the form.
	new Event(evt).stop();

	// Sends the form to the action path,
	// which is 'script.php'.
	$('myForm').send({
		onRequest: function(){
			// Show loading div.
			fx.loading.start( 0,1 );
		},
		onSuccess: function(){
			// Hide loading and show success for 3 seconds.
			showHide( 'success' );
		},
		onFailure: function(){
			// Hide loading and show fail for 3 seconds.
			showHide( 'fail' );
		}
	});
} );
</code></pre>
<p>Putting this all together, and style things a bit, we get a responsive form which submission is asynchronous. You can go see <a href="/experiments/mootools_form/index.html">the example</a>, or you can <a href="/experiments/mootools_form/mootools_form.zip">download</a> the zipped example code.</p>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2007/09/10/submitting-forms-asynchronously-using-mootools/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Mootools: &#8216;Ajax &amp; XHR&#8217; classes</title>
		<link>http://solutoire.com/2007/02/16/mootools-ajax-xhr-classes/</link>
		<comments>http://solutoire.com/2007/02/16/mootools-ajax-xhr-classes/#comments</comments>
		<pubDate>Fri, 16 Feb 2007 21:12:36 +0000</pubDate>
		<dc:creator>Bas Wenneker</dc:creator>
				<category><![CDATA[Mootools]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[xhr]]></category>

		<guid isPermaLink="false">http://solutoire.com/2007/02/16/mootools-ajax-xhr-classes/</guid>
		<description><![CDATA[
I&#8217;m writing this article because my old article about the Mootools ajax class is outdated because of the API changes in Mootools version 1.0. This article will be an update of the previous article.

Using th XHR class

The XHR class is new since Mootools 1.0. It&#8217;s a basic wrapper for the XMLHTTPRequest. To have a better [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;m writing this article because my old article about the Mootools ajax class is outdated because of the API changes in Mootools version 1.0. This article will be an update of the <a href="http://solutoire.com/2006/11/29/mootools-the-ajax-class/">previous article</a>.
</p>
<h2>Using th XHR class</h2>
<p>
The XHR class is new since Mootools 1.0. It&#8217;s a basic wrapper for the XMLHTTPRequest. To have a better understanding of the options of the XHR class let&#8217;s take a look at it&#8217;s source.
</p>
<pre><code class="javascript">var XHR = new Class({

	options: {
		method: 'post',
		async: true,
		onRequest: Class.empty,
		onStateChange: Class.empty,
		onSuccess: Class.empty,
		onFailure: Class.empty,
		headers: {}
	},

	initialize: function(options){
	...
</code></pre>
<p>
So you can see the default values for the options. The meaning of each options is described in the <a href="http://docs.mootools.net/files/Remote/XHR-js.html">Mootools docs</a>. As you can see an XHR object is initialized by <code>new XHR({options object})</code>. No url is set when making a new XHR object. Here&#8217;s a basic example of an ajax call to <code>'location/myscript.php'</code> and when the call&#8217;s successfull it let shows you the response in an alert box.
</p>
<pre><code class="javascript">var showSuccess = new function(req){
	alert(req);
};

//a GET request
new XHR({method: 'get', onSucces: showSuccess}).send('location/myscript.php', 'answerme=1&#038;q=test');

//this does the same, but using POST
new XHR({onSuccess: showSucces}).send('location/myscript.php', 'answerme=1&#038;q=test');
</code></pre>
<h2>Using the Ajax class</h2>
<p>In the old Mootools there where two constructors for the Ajax class. New Ajax objects were created by <code>new ajax(...)</code> and <code>new Ajax(...)</code>. In version 1.0 it&#8217;s only possible to use <code>new Ajax(...)</code>.
</p>
<p>
The Ajax class is a very simple way to make requests to server-side scripts. Now, check the following code, it’s a small part of the Ajax class I took from <a href="http://svn.mootools.net/trunk/Remote/Ajax.js">SVN</a> lately.
</p>
<pre><code class="javascript">var Ajax = XHR.extend({

	options: {
		postBody: null,
		update: null,
		onComplete: Class.empty,
		evalScripts: false,
		evalResponse: false,
		encoding: 'utf-8'
	},

	initialize: function(url, options){
</code></pre>
<p>
What exactly can we learn from this code? We can see the the Ajax class extend the XHR object, so it depends on the XHR class. We can also see that the Ajax class is initialized by new Ajax(url,options) where url is a string containing the location of a server-side script. The second argument is the options object, of which we can see the default in the default options object of the Ajax class. The options shown in are not the complete set of options. Because Ajax extends the XHR class, the options of the XHR class can also be set. Here&#8217;s an example of how to make a POST request to a script located at <code>'location/myscript.php'</code>, the response will be shown when the call fails.
</p>
<pre><code class="javascript">var showFailure = function(){
	alert('Call failed!');
}

new Ajax('location/myscript.php', {postBody:'answerme=1&#038;q=2', onFailure: showFailure}).request();</code></pre>
<p>
As you can see the onFailure option isn&#8217;t set in the default options of the Ajax class. The Ajax class takes the onFailure option from the XHR class because it extends it.
</p>
<h2>Which one should I use?</h2>
<p>
Ok, Mootools provides two classes for making ajax calls, which should you use? If, you&#8217;re sending forms by the use of asynchronous requests, you should use the <code>Ajax class</code>. In the Mootools docs is described how to <a href="http://docs.mootools.net/files/Remote/Ajax-js.html#Element.send">send a form</a> through ajax. In most other ways you won&#8217;t need it and you&#8217;ll be good with the XHR class.
</p>
<h2>A more advanced example</h2>
<p>Here&#8217;s an example that shows an ajax loader image when the request is being processed:</p>
<pre><code class="javascript">//element with the ajax loader image
var loadingImg = $('ajaxLoader');

//function that switches visibility of loadingImg
var showLoad = new function(show){
	if(show){
		loadingImg.style.display = 'block';
	}else{
		loadingImg.style.display = 'none';
	}
};

//request function
var xhrFunc = new function(){
	//show loader image
	showLoad(true);

	new XHR({
		onSuccess: function(req){
			//hide image
			showLoad(false);
			//alert request
			alert(req);
		}}).send('location/myscript.php','answerme=1');
};
</code></pre>
<p>This should get you started, for further reading I refer to my older article about the <a href="http://solutoire.com/2006/11/29/mootools-the-ajax-class/">ajax class</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://solutoire.com/2007/02/16/mootools-ajax-xhr-classes/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
