MooTools -more developer Guillermo Rauch launched a new version of his excellent blog Devthought and brings some fun with him.
Archive for the ‘Examples’ Category
More Friday Fun: Devthought Makes It Rain
February 20th, 2009 by Aaron N.Why You Should Consider Releasing Code
December 31st, 2008 by Aaron N.I posted the other day about Ian Collins’ Moo-ish Template, a scaffold for putting together your own JavaScript library organized as MooTools does (and as I do for Clientcide). But let me tell you why I think you should.
Read the rest of this entry »
Mooish Repository Template and an All-JsonP Showcase
December 28th, 2008 by Aaron N.Ian Collins is apparently hooked on MooTools because he sure has been writing a whole heckuva lot of it. He emailed me a few days back about his site that is all dynamically built off Twitter, Flickr, and other sources using JsonP to fetch all the data. The entire experience is built in JavaScript. Looking at the source of his site you find this lovely little easter egg:
<body> < -- I win at SEO --> </body>
The source of the site itself is all cleanly written MooTools classes, reminding me of my thoughts on programming to patterns.
He’s also released through github a project structure based on MooTools and Clientcide tools and conventions. This is basically how I organize all the Clientcide code along with both test frameworks (Ian includes ScrewUnit – while Clientcide and MooTools use JSSpec, but they both do the same thing – and my Unit Test Framework). Read the rest of this entry »
Ask Clientcide: How do you randomize your header?
November 21st, 2008 by Aaron N.I get a lot of emails from people. Sometimes it’s a charitable soul sending me a bug report (via google code) and, sometimes, an even more charitable soul sending me bug fixes (these are my favorite types of people). Then there’s the Clientcide google group, which is where I prefer questions about my code go so that future readers can see the answers, too.
But today I got this email:
Can you write a blog about how you change the images in your
header.I like your new design so much.
-shin
Awww shucks. Why thank you shin, I like it, too.
So I added a new contact page specifically for suggesting topics you’d like to see me write about (Post a Question / Suggest a Post Topic). And, for starters, I’ll answer this question from shin.
Read the rest of this entry »
Today’s JavaScript WTF
November 17th, 2008 by Aaron N.MooTools cohort Jim Wilson sends me this wonderful little nugget of entertainment today. Microsoft’s SharePoint app has in it’s web app code this lovely little bit of JavaScript:
function DeferCall() {
if (arguments.length == 0) {
return null;
}
var args = arguments;
var fn = null;
if (browseris.ie5up || browseris.nav6up) {
eval("if (typeof(" + args[0] + ")=='function') { fn=" + args[0] + "; }");
}
if (fn == null) { return null; }
if (args.length == 1) {
return fn();
} else if (args.length == 2) {
return fn(args[1]);
} else if (args.length == 3) {
return fn(args[1], args[2]);
} else if (args.length == 4) {
return fn(args[1], args[2], args[3]);
} else if (args.length == 5) {
return fn(args[1], args[2], args[3], args[4]);
} else if (args.length == 6) {
return fn(args[1], args[2], args[3], args[4], args[5]);
} else if (args.length == 7) {
return fn(args[1], args[2], args[3], args[4], args[5], args[6]);
} else if (args.length == 8) {
return fn(args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
} else if (args.length == 9) {
return fn(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
} else if (args.length == 10) {
return fn(args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
} else {
var L_TooManyDefers_Text = "Too many arguments passed to DeferCall"
alert(L_TooManyDefers_Text);
}
return null;
}
As Jim put it, “and we wonder why windows has 40 million lines of code.”
Update: This article got featured on Reddit and I have another post about my actual thoughts on this chunk of code above: The Reddit crowd weighs in on the JavaScript WTF
Class::Binds Mutator
July 1st, 2008 by Aaron N.Jan Kassens, a MooTools contributor, has posted a nifty little trick to help you automatically bind methods to a class. Usually when we reference a method of a class when adding an event, we bind “this” to it to keep our reference to the class (this.addEvent(‘onComplete’, this.complete.bind(this))). This is great until we want to remove that event with removeEvent, which requires we reference the function again. the .bind method creates a copy of the function, so we have to store a reference to it. It’s all very messy. Introducing the Binds mutator. Look for it in the next MooTools patch release, but you can start using it now if you just include the 10 lines Jan has posted.
I wasn’t quite happy with this solution, because it’s too verbose: why always use this.bound.myFn when I always want the bound one? Secondly, I don’t want to do the binding of all these functions by hand. After some discussions on different solutions this is what I come up with as the optimum between speed (don’t worry its faster than the solution above) and usability.
A new so called “class mutator” named Binds. Most of you probably didn’t hear of class mutators before, but you sure have used a class mutator before when you’ve written one or another class. Built in mutators are
ImplementsandExtends...
$merge, $extend, Class.extend, Class.implement, Native.implement
March 28th, 2008 by Aaron N.So I was asked yesterday the following:
Why does Browser use merge but Element use implement?
And after composing a lengthy reply, I thought it might be useful to post it for others: Read the rest of this entry »
Bill Scott – “Designing the Rich Web Experienceâ€
October 17th, 2007 by Aaron N.About a year or so I went to see Bill Scott give this talk down at a gathering hosted by Google (he worked for Yahoo at the time though). The talk was great but I felt I was the wrong audience for it (though I found it very informative). Really, the people who needed to see it, were designers, product managers, and engineers. The talk is awesome as it goes through all the challenges to designing and building user interaction with tons of examples and patterns. On top of that, Bill was a fun speaker.
So I emailed him and asked if he’d be interested in bringing the talk to CNET and, to my astonishment, he did. Maybe 75 of our staff crowded into our largest conference room and watched his presentation. Afterwards I got a lot of thoughtful comments and questions; he had a real impact.
There were, however a lot of people who didn’t get to see this lecture and I’m glad to see that Yahoo got footage of him giving it and have posted it for anyone who missed it. It’s great stuff.
Fx.Sort
July 19th, 2007 by Aaron N.I got a little bored last night and banged this out. A little 2K effect for resorting elements with an effect. More info in the wiki, download in the svn. Read the rest of this entry »
Latest mootools tutorial: how to write a Class
June 25th, 2007 by Aaron N.Here’s a step-by-step and line-by-line example of how to write a Mootools Class. I wrote this example for a javascript class I taught here at CNET for our developers and figured I’d share with everyone else.

