Skip to content

Open Source

Firefox 3.6.4 release candidate available for download and testing

Mozilla Developer News - Fri, 05/28/2010 - 23:24

The release candidate build of Firefox 3.6.4 is now available for download and public testing. This version fixes issues found in the previous beta of Firefox 3.6.4. If no issues are found during testing this build will be officially released as Firefox 3.6.4 final in the coming weeks.

Users who have already downloaded or opted in to previous betas should receive the latest beta as an automatic update. If you did not download the previous beta and would like to help us test this release, please download the latest Firefox 3.6.4 beta from mozilla.com.

For general information about Firefox 3.6.4 and the uninterrupted browsing feature, please see the previous beta announcement.

Categories: Open Source

Thunderbird 3.1 release candidate now available for download

Mozilla Developer News - Thu, 05/27/2010 - 18:16

Please note: the Thunderbird 3.1 Release Candidate is a public preview release intended for developer testing and community feedback. It includes several new features as well as improvements to performance, memory, password handling, and the upgrade process. We recommend that you read the release notes and known issues before installing this release candidate.

The Thunderbird 3.1 Release Candidate is now available for download. This milestone is focused on providing a preview of the functionality provided by the new features and changes that will be included in Thunderbird 3.1.

New features in Thunderbird 3.1 that require feedback include:

  • New Quick Filter toolbar
  • New Migration Assistant
  • Saved Files Manager
  • Several fixes to improve upgrading from Thunderbird 2
  • Several design improvements and corrections to the interface
  • Stability, memory, and password handling improvements

Testers can download Thunderbird 3.1 Release Candidate builds for Windows, Mac OS X, and Linux in 44 different languages. Developers should also read the Thunderbird 3.1 for Developers article on the Mozilla Developer Center.

Note: Please do not link directly to the download site. Instead we strongly encourage you to link to this Thunderbird 3.1 Release Candidate milestone announcement so that everyone will know what this milestone is, what they should expect, and who should be downloading to participate in testing at this stage of development.

Categories: Open Source

A Magical Journey into the Base Fx Class

MooTools - The Blog - Tue, 05/18/2010 - 18:46
Fx is not just for animating elements

In a recent project I worked on with Thomas Aylott the page did some calculations and displayed the result after the user pulled some sliders around. Rather than just change the text from one number to another, the element would increment the number before the user’s very eyes. With a fun interface like that, they had no choice but to apply for a new credit card right then.

Admittedly, I may not have thought to extend Fx to do something like that. After all, the first line of the docs for Fx is: “This Class will rarely be used on its own, …” My first thought would be to use a periodical with a counter and then set the text until the counter was done. But Thomas extended Fx instead. Though it’s the base class for all animations (tween, morph, scroller, etc.) its methods can be used for all sorts of abstract “animations.”

For this article I’ve just come up with a few potentially useful extensions of Fx to get the idea across that you can use it for more than just element animations.

How Fx Works

Essentially Fx just calculates a sequence of values between two numbers. The options kick in to make those values more interesting. This class, Fx.Log, simply updates the text of an element every step of the effect. Notice that this class is essentially the base Fx class except for the tiny set method.

Here’s another demo that visualizes all the visible options of Fx. After you draw the effect, hover the dots to see the exact value calculated (or view source and see them all together.) Playing around with this demo might tell you more about how Fx works than anything else out there.

Fx.Diff

By default, Fx uses 50 fps. So every second it’ll kick out 50 different values and fire the set method 50 different times. For the next few demos I only wanted to do something if the rounded value is different than the last rounded value, so I came up with Fx.Diff. If the value is different, it’ll call the render method.

Fx.Diff = new Class({

    Extends: Fx,
    count: 0,
    render: $empty,

    set: function(now){
        now = now.round();
        var diff = now - this.count;
        if (diff) {
            this.render(diff, now);
            this.count += diff;
        }
        return this;
    }

});
Fx.Count

Since this appears to be no different than the very first demo, we’ll just look at the code. Note, the difference is that the first counting demo would change the text in the element every single frame (50 times a second), but this code would only change it if the new rounded value is different from the last.

Fx.Count = new Class({

    Extends: Fx.Diff,

    initialize: function(element, options){
        this.element = document.id(element);
        this.parent(options);
    },

    render: function(){
        this.element.set('text', this.count);
        return this;
    }

});
Fx.Typewriter

I can actually see myself using this one somewhere:

Notice that Fx.Typewriter overwrites the start method of Fx. The Fx start method takes two arguments, from and to. The usage for Fx.Typewriter is to simply pass in a string of text like so: myFx.start('A whole bunch of text'). This new method knows the from argument is always 0, splits up the text into an array (one item per character) and then uses that length as the to argument. After that logic is done, it simply calls the parent start method. Then the render method takes over by figuring out how many characters to display, filtering out the tail end of the array, joining what matters, and finally setting the text of our element.

Fx.Text

There’s a very creative effect called Fx.Text on the forge. It’s an animated text replacement effect. I think it’s really cool and does a great job of extending Fx.

Fx.Cornify

This next script is far too magical to simply show you the code. You’ll need to view the source for this beauty.

How many? (caution, start with low numbers)

Duration:

Ryan Florence is a MooTools enthusiast and contributor. He maintains his JavaScript focused blog, MooDocs.net, and moo4q. Follow him on twitter or checkout his plugins on the Forge.

Categories: Open Source

OpenLaszlo view: May 2010 Edition Available

OpenLaszlo Project Blog - Thu, 05/13/2010 - 00:13

Please check out this month's edition of the OpenLaszlo featuring the Debug Console:
http://www.openlaszlo.org/node/413

An archive of all previous editions can now be found on the OpenLaszlo.org website here:
http://www.openlaszlo.org/documentation

As always, if you have comments or suggestions for the OpenLaszlo , please email us at admin@openlaszlo.org. We'd love to hear from you!

Categories: Open Source

Announcing: MooTools in Real Life

MooTools - The Blog - Wed, 05/05/2010 - 19:52

If you’ve been paying attention for the past few years, you’ve probably noticed the growth of MooTools, both as a project and as a thriving community. Unfortunately, it has come to light that many so called “members” of the JavaScript community may, in fact, be automata.

To protect ourselves and the MooTools community, we’ve started two physical screening programs (or “meetups”), one in London and the other in the heart of Silicon Valley.

In a surprising turn of events, both groups have had very informative meetings in which actual people have shown up, allowing us to conclusively state that at least some of the members of the MooTools community are, in fact, human. Insightful discussions were had by all, new users and advanced developers alike.

If you’re in the Bay Area or London, it is imperative that you attend at least one of our screening sessions, to verify yourself as human. To be notified about future meetups, as well as voice your opinion on when/where they should be, you can join the Meetup.com group for your area:

Anything Interesting to Share?

If you have something insightful and MooTools-related to share, and think you can spin it into a fifteen minute presentation, please let us know.

Right now, we don’t have any formal communication set up, but it shouldn’t be to hard to get in touch with either Darren (London) or myself (Bay Area). Contact information can be found on the developers page.

Thanks for using MooTools, and we hope to see you there!

Categories: Open Source

Thunderbird 3.1 Beta 2 available for download and testing

Mozilla Developer News - Wed, 05/05/2010 - 17:56

Thunderbird 3.1 Beta 2 is now available now for download and public testing. This latest preview version of Thunderbird includes a new quick filter toolbar, a new migration assistant for users upgrading from Thunderbird 2, and improved support for Personas.

The main goals of this release are to test the new features introduced in this milestone and to find out about possible problems as users upgrade.  Notable changes include:

  • Several fixes to improve upgrading from Thunderbird 2.
  • Several fixes for auto complete, tabs, and activity manager.
  • Several design improvements and corrections to the interface.
  • Stability and memory improvements.

Users of this latest preview version of Thunderbird should not expect all of their add-ons to work properly with this milestone.

For a more detailed list of bug fixes, see the the full bug list.

Downloading

Please read the release notes before downloading for more information about this release including known issues.

Testers can download Thunderbird 3.1 Beta 2 for Windows, Mac OS X, and Linux. Community chat about Thunderbird 3.1 can be followed at GetSatisfaction and on irc.mozilla.org in #thunderbird.

Categories: Open Source

Updated Firefox 3.6.4 beta available for download and testing

Mozilla Developer News - Wed, 05/05/2010 - 02:23

An updated beta of Firefox 3.6.4 is now available for download and public testing. This version fixes issues found in the previous beta of Firefox 3.6.4.

Users who have already downloaded or opted in to the previous Firefox 3.6.4 beta should receive the latest beta as an automatic update.  An additional opt-in upgrade offer will be made to users on the beta channel later this week.  If you did not download the previous beta and would like to help us test this release, please download the latest Firefox 3.6.4 beta from mozilla.com.

For general information about Firefox 3.6.4 and the uninterrupted browsing feature, please see the previous beta announcement.

Categories: Open Source

More than Meets the Eye: Form Validator

MooTools - The Blog - Fri, 04/30/2010 - 22:09

Continuing with my “More than Meets the Eye” series, today I want to talk to you about the MooTools More Form.Validator. There was a comment left on my last post in this series (about Form.Request) specifically requesting that I cover this relatively complex plugin that’s useful for telling users about the validity of data they enter into forms before they send them.

Getting Started with Validators

The main class you need to concern yourself with is the Form.Valdiator class itself which provides methods that apply specific rules to inputs to see if they are valid. You can then choose how you want to inform your users that they need to address these problems, but that’s not the job to Form.Validator (though it is the job of Form.Validator.Inline, which we’ll cover in a bit).

Let’s talk little bit about the rules that are applied. Form.Validator allows you to define rules that test the state of an input and return true or false - true if the input passes the validation rule, and false if it doesn’t. Here’s a simple example:

Form.Validator.add('doesNotContainTheLetterQ', {
        errorMsg: 'This field cannot contain the letter Q!',
        test: function(field){
                return !field.get('value').test(/q/,'i');
        }
});

The above code adds a global validator that allows you to assert that the input doesn’t use the letter Q. The arguments are the validators’ key and then an object that contains an error message to show the user should they encounter the error, and a function that is passed the input as an argument. This function inspects the value or, really, anything you like, and then returns true or false.

The key you give your validator is important. At any time you can validate a field against any validator by using this key as a reference by doing:

myFormValidator.test(key, input[, warnOnly]);

The first two arguments are the important ones here; the key of your validator and the input to test. Where things get interesting are when Form.Validator does this for you. By giving your input that key as a css class name, you tell Form.Validator to validate that field with this validator. In this manner you can quickly and unobtrusively decorate your inputs with the requirements and validate the form. If something goes wrong with your JavaScript, your form will submit as normal. Here’s a really simple example:

The alerts aren’t pretty, but you can see how our validator is now applied when you submit the form.

Form.Validator ships with several validators listed in the documentation. These include simple stuff like required that just validates that the user put something - anything - in the input. But there are also validators for email addresses, only letters, dates, urls, etc. The key is you can write your own - you don’t need to wait for us to release something for you to make use of it. There are an extended list of validators in Form.Validator.Extras that include some edge cases. Things like validating that two inputs have the same value (like an email verification for example).

Using Validators with Arguments

It’s also possible to configure validators with data unique to the input. For example, let’s say you want to have an input with a minimum length validator - the user must type in at least 5 characters. You could write a validator called minimum5 or whatever, but then you’d have to duplicate it for any other character length. For this purpose, Form.Validator allows you to assign values to the input, like so:

<input type="text" name="username" class="minLength:10" id="username"/>

These values - the 10 and 100 values in the example above - get passed along as JSON decoded values to the validator. Here’s what that looks like:

Form.Validator.add('minLength', {
    errorMsg: function(element, props){
        return 'Please enter at least {minLength} characters (you entered {length} characters).'.substitute({minLength:props.minLength,length:element.get('value').length });
    },
    test: function(element, props){
        if (props.minLength != null) return (element.get('value').length >= props.minLength;
        else return true;
    }
});

As you can see, the error message (which in our previous validator was just a string - the message) can also be a function which is passed the input and then any properties defined in the HTML. The fact that the message can be a function allows you to include information not only about how the validator is configured but also other information, like some aspect of the value the user actually entered. The test is also passed along these p roperties of course which allows you to make the properties a condition of the test. We could, in theory, rewrite our doesNotContainTheLetterQ validator to accept an argument about the character (or, better yet, characters) that we want to disallow:

Form.Validator.add('doesNotContain', {
    errorMsg: function(field, props){
        return 'The value you input cannot contain any of the following letters: ' + props.doesNotContain;
    },
    test: function(field, props){
        if (props.doesNotContain)
            return !field.get('value').match(new RegExp('[' + props.doesNotContain + ']', 'i'));
        else return true;
    }
});

Note that the properties defined have to be JSON decodable, so you can’t have your input like this:

<input type="text" class="doesNotContain:qz"/>

Instead you’d have to quote the string:

<input type="text" class="doesNotContain:'qz'"/>

Here’s our example:

The base Form.Validator class comes with a plethora of options and events. You can configure it to validate inputs whenever they change (on blur), or to only show one error at a time (serial). You can tell it to ignore hidden fields (those that are not visible, there’s no point in validating inputs with type=”hidden”) and disabled inputs. There are numerous useful methods that let you run the entire validation routine on the form (.validate()), reset all the errors (.reset()) or validate / reset a specific field (.validateField() and .resetField()). You can pause the validator and resume it (.stop() and .start()) as well as ignore / un-ignore a specific field (.ignoreField() and .enforceField()) and more. There’s even an element method that lets you validate a form (Element.prototype.validate).

Form.Validator.Inline - the “Pretty” One

Now that we’ve covered the basics of how Form.Validator works, let’s consider the fact that our examples so far have been rather ugly (who wants alert messages?). MooTools More ships with a default implementation that smoothly displays messages inline, right after the input: Form.Validator.Inline. This class is the “pretty” version of Form.Validator but don’t think of it as the only game in town. You can easily implement your own “pretty” version without a lot of effort. If you want to put errors in a popup or fade them in over the entire screen or play a sound it doesn’t matter. The base Form.Validator class is there for you.

Looking at the Form.Validator.Inline implementation, you’ll find all the same options and methods from Form.Validator along with a few extras that control how your messages appear. For instance, by default, the validation rules show up immediately after the input. This requires a bit of forethought in how you structure your HTML. If your input is inline with something else (like a submit button), validation errors are going to change that when they appear (because they are divs, which by default are block level elements).

The only real option that Form.Validator.Inline has to offer is whether or not to scroll to errors (useful if your form is long and will likely cause the user to scroll to the submit button). Here’s a simple example, building on our previous one:

As you can see, the error message slides in, but it breaks our layout a bit. Let’s do some CSS work to make this look a little nicer.

It’s not The Sistine Chapel but it does look nicer. Our error doesn’t appear to break our layout anymore either.

As a final example, I’ll show you a version that extends Form.Validator.Inline to put the validation messages in tips that popup pointing at the input. Here’s a demo:

If you want you can check out the source on github and download it with its dependencies on Clientcide.

Go Forth and Validate

Overall the purpose of Form.Validator is not to be the only solution for displaying validation messages to your users, but rather a flexible solution for client side form validation on which to build. You can extend it and manipulate it to display messages in any way you choose - and you should!. The default “pretty” implementation - Form.Validator.Inline - is just one way to use the class. In my opinion Form.Validator is one of the classes in MooTools More that shows off the power of MooTools’ object oriented design, allowing for a great deal of flexibility and reuse.

Thanks to Lloyd for suggesting this edition’s topic. If there’s a plugin in MooTools More you’d like me to focus on next time, by all means, make a suggestion in the comments.

Aaron Newton is a contributor to MooTools and the principal developer of MooTools More. He is the author of the book MooTools Essentials as well as the Mootorial online MooTools tutorial. He posts (rarely these days) at his blog Clientcide.com and (much more often) on Twitter as anutron. He works for Cloudera, (which is hiring, by the way).

Categories: Open Source

MooTools 1.3 ßeta 1

MooTools - The Blog - Wed, 04/28/2010 - 01:25

MooTools 1.3 beta 1 launches today. Lots of bug fixes and improvements, and all that jazz. Before presenting you with a random rundown of features, let me be clear about something: MooTools 1.3 is (or will be) 100% compatible with every public documented API of MooTools 1.2. So chill already.

Anyways, here’s what’s new:

Globals

MooTools 1.3 moves away from the $name functions. Most of the useless ones, such as $chk (god knows why I thought it was a good idea to have $chk), were completely nixed. Some of them moved to the proper object’s namespace ($merge » Object.merge, $pick » Array.prototype.pick). Some others were renamed without the stupid $ in front ($type » typeOf, $defined » nil). In the end, there are a lot less global variables now. You can refer to the 1.3 documentation to have a proper list of what’s changed. Keep in mind that the old version of the methods will still work, by default. There will be a way in the future to “compile” MooTools without the compatibility stuff, but the feature is not ready yet.

From types with love

Every native type has now a from method that will try to convert every object passed to that type. Array.from, for instance, replaces both $A and $splat. Function.from will return a function that returns the passed in value, if it wasn’t a function itself. String.from… well you know that at this point, don’t you? We also changed how we internally handle Native types, but that should be none of your concerns, since they were handled with private apis anyways.

Generating your own MooTools, from your own computer

It is now possible, easy, and even perhaps recommended to generate MooTools (and its plugins) yourself. Last few months I’ve been working, on and off, on a pretty advanced projects-builder. It’s called Packager, it supports multiple project dependancies and has a very similar syntax of what’s used in the Forge right now. It’s written in php and you can use it from your php webpages to dynamically include JavaScripts for development, or you can build a single .js for production from the command line.

If you care to build MooTools and MooTools projects for yourself, you should take these steps:

  1. Clone MooTools 1.3b1.1 from github.
  2. Clone whatever other Packager-ready MooTools project from github (color, table and touch, for instance, are my Packager-ready plugins).
  3. Clone Packager itself from github.
  4. Read Packager’s README. Pretty much everything you need to know is in there.

Ofcourse, Packager itself is not limited to MooTools, MooTools plugins or just javascript projects. A tutorial post on how to use Packager for development is coming soon (few years tops).

If you dislike php, worry not! There is also a Django builder, called Depender, written by our Aaron Newton, on github as well. I really don’t know how it works, as I don’t do python, but I do know it’s scope is way greater than that of Packager. Depender can, for instance, dynamically build your MooTools for production use, like that. But don’t take my word for it, go check it out on github.

Slick

The most notable new feature in 1.3 is Slick. Slick is our new, shiny, super fast, exhaustively tested, pure-javascript selector engine. There will probably be a dedicated Slick post in the following days (or months, given our relaxed release cycles), but here’s a few Slick-facts for those who haven’t checked it out already:

  • Slick is a MooTools-family project by MooTools developers Thomas Aylott, Fabio Costa and yours truly. It can be forked from github, free of charge!
  • Slick is an incredibly advanced evolution of our previous selector engine.
  • Slick is written using only pure-javascript, none of the MooTools apis are required. It can be used in any project or framework, and it does not require MooTools to function (though the MooTools DOM components do require Slick).
  • Slick is speedy, blows away the 1.2 selector engine by 50%, at least. We will give you detailed data in the post dedicated to Slick.
  • Slick supports every selector you can think of. Seriously, every one of them. I promise you.
  • Slick is customizable, you can make your own pseudo-selectors, your own attribute-selectors, and many more your-own kinds of things.
  • Slick supports reversed combinators. You might not know what they are, but they are pretty darn cool.
  • Slick has a detached parser. You can parse a css-style-selector string and get back a property-filled object.
  • Slick perfectly supports XML documents.
  • Slick is slick!

On another note, thanks to the Slick’s parser, you will be able to build an element using a css selector. Let me give you an example of this cool new feature (courtesy of our amazing Christoph Pojer):

Creating an element using an object (the 1.2 way):
new Element("input", {"id": "someID", "class": "someClass1 someClass2", "disabled": true});
Creating an element using a selector string (the coolest way):
new Element("input#someID.someClass1.someClass2[disabled=true]");
In conclusion

As I get back to work on an exciting number of totally amazing upcoming MooTools projects that you know nothing about because you don’t follow me on github, I’ll leave you with a few useful 1.3 links:

UPDATE: There was a “merge” problem with beta1, so we quickly fixed it and re-tagged beta 1.1.

Have fun with 1.3! I know I will.

Valerio

Categories: Open Source

Object Oriented jQuery with MooTools @ jQuery Conference

MooTools - The Blog - Tue, 04/27/2010 - 15:12

Hey there MooToolers. I just returned from speaking at jQuery Conference 2010 in San Francisco on “Object Oriented jQuery with MooTools” and thought I’d share some notes on the experience.

My Talk

If you ask me how I did I’d say I missed a few connecting ideas but got the concept out there and got some people thinking. Several people came up to me afterward asking how to actually give this a shot on their web apps. Also, if you are reading this on a Mac, do this: command + option + control + 8 (⌃⌥⌘8). I think for the first time in the history of OSX this keyboard shortcut was useful. The projector had a hard time with my bright colored code on a black background so I inverted the the whole presentation!

Some of you have read my post Pigs take flight about using the Class module from MooTools to write modular code in a way we all love but use jQuery for DOM manipulation, effects, AJAX, etc. That was the basis of my talk. You can find the slides and a demo at my blog here.

The Demo is especially awesome.

Thoughts

It was very well attended, said to be the largest JavaScript conference ever. There were a lot of really talented people there and all of the speakers did great. I am humbled by the ability of the jQuery team to put together great events and market their library, I’d even say a bit jealous!

It seems at the user level people see frameworks as rivals or something, but at the framework developer level they generally feel like we’re on the same team, working to make the web better.

There was a lot of talk about organizing code, which is a problem that jQuery doesn’t try to solve. I don’t think any other framework can step in quite like MooTools to do it and yet keep the jQuery API in tact when writing an application’s code (thanks to mutators). Another testament that -core is rock solid and ridiculously versatile for JavaScript generally, not just the DOM. I also found that a lot of people didn’t know that you can create custom builds of MooTools to solve all sorts of JavaScript problems.

So, thanks jQuery for a great weekend!

Categories: Open Source

OpenLaszlo 4.7.2 is Available

OpenLaszlo Project Blog - Mon, 04/19/2010 - 23:01

We are pleased to announce that OpenLaszlo 4.7.2 is available and can be downloaded here: http://www.openlaszlo.org/download

OpenLaszlo 4.7.2 is a bug fix release to OpenLaszlo 4.7.1, and contains 5 important community bug fixes and a new feature adding Silence Level and Timeout attributes to microphone (see the JIRA report 4.7.2 Fixed Bugs for details.

In addition, for OpenLaszlo 4.7.2 and the trunk development branch we have updated our build tools. If you are building from source, then you will need to do the same. Please see the OpenLaszlo wiki page, SubversionBuildInstructions, for updated instructions.

OpenLaszlo continues to be grateful for the significant contributions by André Bargull and Raju Bitter. You guys are amazing - thank you! In addition, we want to thank Cem Sonmez for helping us isolate issues on Linux. Thanks for filing detailed bug reports, creating test apps, and helping us resolve these important bugs. We would also like to thank the entire OpenLaszlo community for your support in so many ways, like submitting bug fixes and participating in discussions to help make OpenLaszlo a better platform.

Categories: Open Source

OpenLaszlo <View>: April 14, 2010 Edition

OpenLaszlo Project Blog - Thu, 04/15/2010 - 18:38

Check out the latest scoop in the April 14th edition of the OpenLaszlo <view>:

http://www.openlaszlo.org/misc/OpenLaszloView041410.pdf

Categories: Open Source

Dojo and MooTools

MooTools - The Blog - Thu, 04/01/2010 - 18:02

Over the past several months we here at MooTools have been contemplating how much of what we do is duplicated effort. When we started this whole project years ago it was because we wanted to do things our own way, but as MooTools and JavaScript in general have progressed, we find ourselves facing the tedium of all the low lying code that has to be written to get Browsers to play nice, not to mention the richer things like our inheritance system and other utilities like effects, DomReady, etc. etc.

At FOSDEM we ended up hanging out with the Dojo crew. We like them; they are always doing interesting things and their framework is one that we’ve always looked at and said to ourselves, “If we ever needed feature X we’d probably just port it from them.” Anyway, at FOSDEM a group of their developers and ours got together and started brainstorming about closer ways to work together. Since then the discussion has gotten closer and closer to where we are now.

MooJo

Starting today the Dojo and MooTools projects will begin merging and joining forces. Part of this is to share resources - more hands coding makes more code, right? But part of it is, well, we’ll be frank, we’re kind of tired of reinventing the wheel. We love the solutions in MooTools, but at the end of the day, the API is all that matters. It doesn’t matter how you detect that the DOM is ready, so long as when it is your code runs. The same could be said for selector engines, XMLHttpRequest, and a whole host of other things. What this means in practical terms is that we just don’t have to do as much work and, to be frank, after 4 years of working on MooTools, we’re happy to cede some of the more tedious tasks to Dojo. Sure, their architecture isn’t quite the same (or maybe even as good) as ours, but it works. This will free our development team’s time to work on their own projects and maybe start getting paid for it, which brings us to the second point.

Making MooJo Profitable

For the past four years we’ve been writing code and releasing it for free. In our talks with the Dojo team we all agreed that all this free time donated to anyone who happened to want our work just wasn’t quite worth the hassle. Don’t get us wrong, writing the code is fun, but it’s all the other stuff. The bug reports, the hand-holding in the forums and on IRC, the constant demand to “compete” with other frameworks (whatever that means). It just sucks the pleasure right out of it. We find ourselves burning nights and weekends to write code for strangers to use and it gets old.

Going forward, the code base will continue to be free, but access to the documentation will require a small “donation” (we’ll probably set a really small minimum, like, say $.25) - frankly, the documentation has gotten too good to be free (we contemplated printing it and just selling it as a book, but micropayments is much more “Web 2.0”). Filing bugs will still be free of course. But we’re working on a system that lets our users put money towards the bugs they care about the most. The bug with the most money donated gets our time and gets in the next release. We think this will cut down on both the number of bugs we get but also help manage expectations. If you have a bug that you think is important, you either need a lot of people to agree with you (which they will if the bug is really broad) or you need to pay a lot (in which case it’s like you’re hiring us as freelancers).

What will we do with the money raised? We’ll probably start sponsoring more meet-ups and sending more people to conferences, but we’ll also be able to compensate the developers who bring you all this great stuff. Certainly no one can argue with that.

Compatiblity

As we begin merging functionality we’ll likely retire large portions of both frameworks. MooTools has a great effects library while Dojo has a lot of solid widgets. MooTools ART will likely get shelved in favor of dojo.gfx, Dojo will likely drop it’s effects libraries in favor of MooTools’ effects which are really nice, much of MooTools More will either be retired (in favor of existing Dojo widgets) or turned into Dojo widgets themselves, etc.

For backwards compatibility we’ll be implementing the “donation” system as well. For the portions of the MooTools and Dojo cores that are deprecated we’ll allow the users to prioritize which parts we offer compatibility for. Same goes for effects, plugins, etc. We hope this new model will encourage businesses that use our awesome frameworks to recognize the value we bring and to compensate us for our time.

If you have any questions, post them in the comments below. Comments are still free - we haven’t implemented the “donation” system for them yet, either.

Update: Yes, this was an April Fool’s joke. We love Dojo and that whole team… but not that much.

Categories: Open Source

Get friendly with the Natives

MooTools - The Blog - Wed, 03/24/2010 - 04:48

Have you extended a Native lately? It’s an incredibly helpful thing. Often people write ugly functions that take a string or whatever as an argument and return some manipulation of the string. Extending natives is a great way to do the same thing, but it is much prettier (aka: explicit, readable, easier-to-debug.)

The Difference:

I’ve seen stuff like this:

fn1(fn2(10, fn3('house')));

Hard to figure out what’s happening. Instead you can write code like:

fn3('house').fn2(10).fn1();    
A Useful, Real Example, zeroPad

I’ve used this in a couple scripts, it takes a number and returns a string with zeros padded in front: 123 becomes ‘000123’. Really handy for filenames and the like. Here’s the ugly version:

Functionally Based Example
function zeroPad(num, zeros){
  zeros = zeros || 3;
  var str = '' + num;
  zeros.times(function(){ str = '0'+str; });
  return str;
};

// usage
doSomething(zeroPad(document.getElementById('myInput').value, 3));
Native Extentions Based Example
Number.implement({
  zeroPad: function(zeros){
    var str = '' + this;
    zeros.times(function(){ str = '0'+str; });
    return str;
  }
});

// so that it works on both numbers and strings
String.implement({
  zeroPad: function(zeros){
    return this.toInt().zeroPad(zeros);
  }
});

// usage
$('myInput').get('value').zeroPad(3).doSomething();
Side by Side:
doSomething(zeroPad(document.getElementById('myInput').value, 3));
// vs
$('myInput').get('value').zeroPad(3).doSomething();

Awesome? Yes. You can do the same thing to:

Some say extending natives is a bad idea. Personally, I think it’s awesome—but this topic is a sore spot for some. Extending natives is a feature of javascript itself that any general application framework like MooTools is entitled to use. There could be an entire article dedicated to this topic but this article isn’t it. This article is simply here to show how to use this handy feature.

Flippin’ Sweet Array methods

Arian Stolwijk created this amazing gem: Array.Math. Code samples often tell the story faster:

[2,5,1,6].sum(); // 14
[2,5,6,2].product(3); // [6,15,18,6]
[9,12,15].quotient(3) // [3,4,5]

This is all made possible by extending the Array native, see?

    Array.implement({

        sum: function(start,length){
            var sum = 0, 
                start = start ? start : 0,
                length = length ? length : this.count()-start;
            length = start ? length + 2 : length;
            for(var i=start;i&lt;length;i++) sum += this[i];
            return sum;
        },

        product: function(p){
            var arr = $type(p) == 'array';
            return this.map(function(entity,i){
                return arr ? (entity * p[i]) : (entity * p);
            });
        },

        quotient: function(q){
            var arr = $type(q) == 'array';
            return this.map(function(entity,i){
                return arr ? (entity / q[i]) : (entity / q);
            });
        },

        // and a whole lot more awesome ...

    });
Quick Tips
  • this is the number or string, or whatever, when inside the method.
  • Return something that makes sense (usually this).
  • You can implement several methods all in the same code block.

This is just one more great tool to help keep your code organized and readable.

Categories: Open Source

A Better Way to use Elements

MooTools - The Blog - Sat, 03/20/2010 - 00:41

Javascript development in the browser is all about the Elements. Manipulating the DOM happens every few lines of code. It’s important enough that some libraries provide little more than DOM enhancements. Not to worry though, MooTools provides greatly in this area as well.

$ and $$

Most of you probably know the two document methods getElementById and querySelectorAll; because if you do, you understand how we select elements with MooTools methods. For those of you that don’t, you provide an ID string of an element in to getElementById, and a CSS selector string to querySelectorAll. The functions $ (which is an alias to document.id, see this post on Dollar Safe Mode for details) and $$ are basically equivalent to getElementById and querySelectorAll, respectively. Of course, since it’s MooTools, they’re more than that.

The dollar function, if given a string, will basically call getElementById on the document. If passed an element, it will just return the element, and if you pass an object with a toElement method, it will try to convert it to an element (we’ll explore that more a couple sections down). A key difference you’ll find between MooTools’ dollar function and jQuery’s is this: MooTools’ $() will only ever return 1 Element, and it will return null if no matching element is found. This means unless you’re absolutely 110% certain the element will exist, you’ll need to check the returned value before starting to call Element methods on it.

    var loginEl = $('Login');
    if (loginEl) {
            loginEl.fade('in');
    }  

The MooTools Team prefers two separate methods for the selecting elements; to remove any doubt about what a certain function call may be returning, we have one method for individual elements and another for multiple elements. In this case, it’s preferable to be explicit, instead of relying to ambiguous auto-magic. When we see $, we expect an element if it exists. When we see $$, we expect an array of elements (which, as you know, an array can always be empty). The double dollar function has some neat tricks that are explained in its own section below.

All this talk about Elements, but only about how to select them. MooTools also provides an excellent Element construction API.

new Element()

With vanilla JS (mmm, vanilla…), you’d use document.createElement whenever you wanted to create and add a new element to the DOM. MooTools tries to make the JavaScript API more pleasant to use; part of that is a more consistent and easy to use syntax and part of it is using more Object-Oriented programming practices. It feels a lot more OO when creating objects using the new keyword, whereas the standard way is more procedural.

It turns out that every element you could create inherits from the Element prototype. Specifically, the elements you create through document.createElement would be HTMLDivElement, or HTMLParagraphElement, or whichever element you create. Like I said, they all inherit from the base Element prototype, and then HTMLElement, and so on. MooTools extends the base Element class, so that all elements receive some MooTools love.

MooTools augments the Element native, providing a super-duper sweet constructor. You can provide the tag name, and then an object of properties to set on the new element. The returned object is of the same type as the $ method mentioned above. The properties you can set are fairly extensive, so check out the documentation to learn more about them, but here’s a demonstration.

toElement

The dollar method provides another function: converting the instance of class into an element(-al?) form. This is similar to a toString function, which converts objects into strings when needed. You can define a method in a class called toElement, and return an element to “represent” the instance. Let’s take a look at a snippet from a Person Class:

Several extensions in MooTools More take advantage of this, like Form.Request, Form.Validator, HtmlTable, and others. And many plugins in the Forge use this approach as well. This means that after creating an instance of one of these classes, you can just hold on to the instance in your code. Whenever you want to affect the element that the instance is controlling, you just use $(instance) to retrieve it.

Aaron even cooked up a ToElement mixin, and wrote a bit more about this over here.

Elements

I pointed out earlier that $$ returns an array-like object containing Elements. It actually returns an object called exactly that: Elements. Behind the scenes, MooTools gets an array of all the elements that meet the selector (so it’s still an array), and then extends the array with all the Elements methods. Why would we want that?

All the methods that MooTools adds to the Element native are added to the Elements class as well. You can do some pretty nifty chaining because of this. First of all, you don’t have to check that it didn’t return null. This is because any method you call on Elements, will loop through the array and try to call the method on each individual element. Even with an empty array, the loop won’t cause an error. And any method you call that would normally return a value, will return an array of the values from each element. An example should make this clearer:

    //assigns a click event to all A tags
    $$('a').addEvent('click',  function(e) {
            e.preventDefault();
            alert(this.href);
    });  

    //gets all divs with an id set, and then returns
    //an array of the IDs  sorted alphabetically
    var ids = $$('div[id]').get('id').sort();  

    //gets all divs with a UL immediately inside
    //and assigns a class name to  the divs
    $$('div &gt; ul').getParent().addClass('has-list');

While you could put together long chains acting on all the elements you’ve selected, I’d advise against this. It certainly looks cool, and will work fine one or 2 methods out on the chain. But every method call will cause another loop through all the elements. If you’re doing a lot of things to every element, you might as well do it all in a single pass. I’ll show you what I mean.

    //this would loop through each time at addEvent, addClass, and fade
    $$('li  a').addEvent('click', function(e) {}).addClass('alertable').fade('in');  

    //whereas this will only cause 1 loop
    $$('li a').each(function(link)  {
            link.addEvent('click', function(e) {
                     alert(this.title);
            });
            link.addClass('alertable');
            link.fade('in');
    }); 

Still, when doing something simple, you can skip the each call, since Elements will handle that for you.

Concluding

MooTools provides a lot of expressive power when working with the DOM. It’s consistent API makes it a snap to add events, change styles, create elements and more. The object oriented nature of its implementation makes it so that you can extend Elements for your own purposes. Look forward to my next post where I’ll talk about extending Elements in various ways and cover best practices for when you decide to bend Elements to your own will.

Sean McArthur is a software developer at Blazonco.com who is madly in love with MooTools. Most of his contributions involve sharing tips and information about MooTools (and programming in general) at his blog and on Twitter.

Categories: Open Source

1.4.1 release candidate 1 is ready

The Dojo Toolkit blogs - Fri, 01/22/2010 - 00:15

The 1.4.1rc1 release is now available for testing at http://download.dojotoolkit.org/release-1.4.1rc1/

Given the timing of the Firefox 3.6 release, this is a great opportunity to test for regressions. Please try testing on the new Firefox release (or any other browser) and report your results by EOB Friday. Thanks!

Categories: Open Source

1.4.1 release candidate 1 is ready

The Dojo Toolkit - Announcements - Fri, 01/22/2010 - 00:15

The 1.4.1rc1 release is now available for testing at http://download.dojotoolkit.org/release-1.4.1rc1/

Given the timing of the Firefox 3.6 release, this is a great opportunity to test for regressions. Please try testing on the new Firefox release (or any other browser) and report your results by EOB Friday. Thanks!

Categories: Open Source

1.4.1 release candidate 1 is ready

The Dojo Toolkit blogs - Fri, 01/22/2010 - 00:15

The 1.4.1rc1 release is now available for testing at http://download.dojotoolkit.org/release-1.4.1rc1/

Given the timing of the Firefox 3.6 release, this is a great opportunity to test for regressions. Please try testing on the new Firefox release (or any other browser) and report your results by EOB Friday. Thanks!

Categories: Open Source

1.4.1 release candidate 1 is ready

The Dojo Toolkit - Announcements - Fri, 01/22/2010 - 00:15

The 1.4.1rc1 release is now available for testing at http://download.dojotoolkit.org/release-1.4.1rc1/

Given the timing of the Firefox 3.6 release, this is a great opportunity to test for regressions. Please try testing on the new Firefox release (or any other browser) and report your results by EOB Friday. Thanks!

Categories: Open Source

3-day Online Dojo Conference - dojo.connect

The Dojo Toolkit blogs - Mon, 01/04/2010 - 21:15

This year we wanted to create an Dojo Conference / Event that is more inclusive for the Dojo Community than our traditional Dojo Developer Days. To that end, we have established a Dojo Conference, dojo.connect to provide an online virtual conference so that more people may attend and learn Dojo. The full conference is three days long, with the first two days consisting of practical sessions on how to use Dojo to build amazing web apps. The third day will consist of round tables and discussions centered around Dojo's future developmental goals.

These days many conferences are simply big marketing and networking exercises and can be very expensive to attend. This is especially true when travel is taken into account. It is often impractical for foreign visitors to come to the US to attend a conference or to get many US developers to attend overseas. Dojo.connect is different in that its goal is to provide practical information and education working with Dojo. Real-time interaction with speakers and attendees is not sacrificed however, and will be accomplished either via voice communication and/or text chat. Most of the active Dojo Developers and other active community members will be presenting various techniques, strategies, and advice to help developers and companies build great applications. Opportunities will exist to discuss and contribute to the future direction of Dojo through communication with those individuals that make Dojo happen.

A portion of the proceeds collected from the conference will be funneled back into the Dojo Foundation in order to support its on going efforts and infrastructure expenses.

We hope you will find the conference enjoyable and informative and will consider signing up and attending. For more information about dojo.connect, see http://widespreadconferences.com/dojoconnect.html.

Categories: Open Source