January 13th, 2009 by Aaron N.
David Nolen just posted this to the MooTools Google group:
Well thought out blog post about why Prototype is preferred over jQuery. Not a mindless flame war piece, but a reasoned argument. Interestingly enough, MooTools actually _combines_ what he likes about Prototype and jQuery into one package! In particular, MooTools has a uniform design throughout, inheritance, a great CSS selector engine, good functional aspects, supports function chaining, and of course provies a couple of things that Prototype doesn’t properly have (multiple inheritance via Implements). I pointed some of these things out in a comment.
Good recommended reading.
David
Posted in 3rd Party Libraries, Best Practices, Prototype | Comments Off
September 20th, 2006 by Aaron N.
So I posted yesterday in my flurry of catch-up posts about the mad4milk.net guys new framework: MooTools. I’ve had a little time to dig into it and I must say that I’m blown away. In many ways, this is the framework that I’d say CNET should write for itself if it were to take on such a task. Read the rest of this entry »
Posted in 3rd Party Libraries, CNET JS Standards, moo.fx, MooTools, Optimization, Prototype, Scriptactulous | 2 Comments »
September 19th, 2006 by Aaron N.
Justin Palmer is shedding more light on Prototype updates.
This time around he covers events and DOM traversal:
Events
In days past bind was great at accepting additional arguments, however, bindAsEventListener didn’t get this love until now. We can pass those additional arguments to bindAsEventListener with ease:
var Clicker =
Class.
create();
Clicker.
prototype =
{
initialize:
function(link
) {
Event.
observe(link,
‘click’,
this.
onClick.
bindAsEventListener(this,
‘red’));
},onClick:
function(event, color
) {
Event.
element(event
).
setStyle({color: color
});
Event.
stop(event
);
}
}
new Clicker(‘cool’);
DOM made simple
We all hate the DOM, so how about some simpler methods to traverse it?
$(‘menu’).up();
$(‘menu’).down()
$(‘menu’).next()
$(‘menu’).previous()
$(‘menu’).down(2) // grab second arg
$(‘menu’).down(‘li’, 0)
$(‘sidebar’).descendants()
$(‘selected’).previousSiblings()
$(‘actions’).ancestors()
$(‘actions’).siblings()
And it looks like documentation is in the works:
On the documentation front: We have something in the works. We have the API about 80% documented and will have this up for public consumption as soon as we can. This will start off as very basic API docs, but we plan on putting a lot of effort in this as time goes by. On that note, you can send your thanks to Andrew Dupont considering he has worked very hard on the docs.
Posted in 'Industry' News, Prototype | Comments Off
September 19th, 2006 by Aaron N.
I know that Bill Scott’s carousel widget (written with the Yahoo UI Library) is already in play here on CNET Redball (News.com is using it). Here’s a Prototype version that seems to be a lot smaller – you’ll need Prototype (you might be able to get away with the lite version @ 8K, otherwise, 33K), but NOT scriptaculous. Might be worth considering swapping out? Does all the ajax stuff, too.
Sebastien Gruhier has written a Prototype version of the YUI Carousel component.
This version is lightweight and has a few parameters compared to the more flexible YUI version (that comes with a 200kb price tag).

Posted in Examples, Prototype, Visual Effects | 1 Comment »
August 30th, 2006 by Aaron N.
I always get a sinking feeling when Prototype starts to change. Sam (who maintains the project) is checking fixes for the next release today and Justin Palmer (encytemedia.com) is posting things that he’s seeing get checked in as it happens. On the one hand, the next version offers some nice improvements (thus far, there may be even more changes to come), but on the other, it’s stuff I’ve got to go dig into and incorporate into my work…
via ajaxian:
Justin Palmer has updated us with a bunch of recent Prototype updates including:
Posted in 'Industry' News, Prototype | Comments Off
August 25th, 2006 by Aaron N.
I just found this Encytemedia post on Prototype inheratance that’s totally worth the read. Additionally, at the end he (Justin Palmer) points to Dean Edward’s Base script that provides an interesting alternative.
…All that has since changed. Thanks to the persuasion of The Javascript MacGyver, Sam replaced the Object.prototype bits in favor of Object.extend and Object.inspect. With this decision, however Prototype’s inheritance scheme can be messy, and it’s certainly hard to read if you don’t spend time trying to really figure out what’s going on.
Posted in Best Practices, Code Snippets, Examples, Prototype, Reference | Comments Off
August 22nd, 2006 by Aaron N.
Now, what was I just saying?
via Ajaxian:
Cody Swann was working on a web application that was using the Dynamic Script Pattern, which Dojo has excellent support for, but Prototype didn’t.
Cody then extended Prototype to support ScriptSrcTransport similarly to how Dojo does it.
The code below support the Simple, Polling and JSONP and JSON Callbacks described in the Dojo book.
Posted in Code Snippets, Examples, Optimization, Organizing Code, Prototype, Server-side Integration | Comments Off
August 2nd, 2006 by Aaron N.
One of the aspects of having a lot of action going on around a development space that’s rather new is that you get a lot of people solving problems just like the ones you’re having. These people release their work and you can make use of them if you like.
So you go download a few, pick the one that looks best and get started working. Meanwhile ten more solutions hit the market and you’ve already commited yourself. Stopping what you’re doing and going back has that oh-so-familiar pitfal that we’ve all experienced: you either waste a lot of time reading up and trying out those ten new things or, almost worse, discover that someone has a better solution than the one you’re half way through implementing.
I saw this post below on Ajaxian today and figured I’d read it because I’d been curious about Rico and Dojo in particular but hadn’t gotten around to trying them out. Dojo is friggin awesome. From a tech prod perspective, I think it’s the slickest thing I’ve seen yet. Implementing the various aspects of the Dojo platform seems super-duper easy, almost to the point that you don’t need to know a lot of javascript. So now I gotta go download, install, and fiddle with it for a few weeks and then probably rewrite some of my existing work. Sheesh.
In the article linked to below, you’ll find screencasts for each of the six frameworks. They aren’t terribly detailed, but the give you a decent idea of what it’s like to actually use the libraries. Read the rest of this entry »
Posted in 3rd Party Libraries, Ajax, Examples, Prototype, Visual Effects | Comments Off
July 27th, 2006 by Aaron N.
I just happened upon event:Selectors. It’s very similar to Behaviour.js (the author’s spelling, not mine) in most respects, though its much smaller (72 lines / ~2k) and has some nice added functionality using Prototype shortcuts (Behaviour is stand-alone and duplicates a lot of Prototype stuff and is, therefore, larger).
Basic usage:
var Rules = {
'#icons a:mouseover': function(element) {
var app = element.id;
new Effect.BlindDown(app + '-content', {queue: 'end', duration: 0.2});
},
'#icons a:mouseout': function(element) {
var app = element.id;
new Effect.BlindUp(app + '-content', {queue: 'end', duration: 0.2});
}
}
Now, this alone is nice, but nothing exceptional. You could do the same thing with prototype thusly:
Event.observe(window,"load",function() {
$$('#icons a').each(function(tag) {
Event.observe(tag,'mouseover', function() {
var app = tag.id;
new Effect....
});
});
});
Ok, so it’s definitely longer to do without it, but not terribly so. But what really gets me excited is this:
'#footer:loaded': function(element) {
element.setStyle({backgroundColor: '#ccc'});
}
This will apply the code to the element once it’s loaded. That’s just awesome. That’s just awesome times five. Wait, it gets better: it will also apply all your rules to your Ajax responses, too (if you want it to). This means when you bring in a chunk of html into the DOM you don’t have to set up all your events on it again.
It has a few other nice touches (you can, for instance, apply these events to more than one selector, for instance). Check it out.
Posted in 3rd Party Libraries, CSS, Event Scripting, Organizing Code, Prototype | Comments Off
July 11th, 2006 by Aaron N.
Holy cow this is awesome.
via ajaxian: original post
Dean, John, Matthias and a load of other people were working on a really robust solution to the DOM Ready problem. In case you haven’t seen Dean’s post, they did it and it is good shit. If you want to read more of an explanation head over to Dean’s site.
I’ve been waiting for, but in a very idle way, not doing much about, a really solid solution to this for a long time. It just so happens to be extremely useful for a certain Rails plugin I’m working on with Luke Redpath so as soon as it was written I knew I needed to extend Prototype to use this new technique.
So, here’s an extension to Prototype that allows you to attach one or more functions that will be executed as soon as the DOM is ready to work with. This will not wait for images or other assets to load like window.onload does.
Here’s the script: domready.js
To use it simply add a script tag after your prototype.js script tag or append the code to the bottom of prototype.js.
Then, to execute a function when the DOM is ready:
Event.onDOMReady(function() { //stuff here! });
You can call the function repeated times to add more functions to be triggered if you need to.
Posted in Event Scripting, Prototype | 13 Comments »