MooTools 1.2 beta 1

November 14th, 2007, posted by Valerio

The first beta for MooTools 1.2 is finally here!

After months in the making, we can confidently say that MooTools 1.2 is now feature complete. However, there are still some bugs left to squash.

Head over to MooTools download page to start playing with it right away.

A Note About Compatibility

Some parts of MooTools 1.2 aren't immediately compatible with those found in MooTools 1.1. In the downloads page, you'll find a box that says: "include compatibility with previous version". Clicking that box will add the missing pieces and will make MooTools 1.2 play nice with code written for MooTools 1.1.

New stuff that we already covered:

The amazing Hash

Specs!

Effects Enhancements

Important stuff thats not yet covered in a blog article:

Full IFrames support with the Native IFrame Class.

Swiff: Flash content injection Class. Include Flash files, the easy way!

A Little Help, Please!

We are currently looking for bug reports and incompatibilities with previous plugins. If you want to help out, open a ticket in the Trac, and we will make sure that the problem is fixed for the final release.

Read more for a (not so) brief "what's new" list.

(P.S. This list is not exhaustive, it's just the stuff we could remember.)

Core
  • Every native method is now backed up by generics. Array.flatten(arguments)
  • New Function $lambda, that makes any value into a function. $lambda(1)(); or $lambda(function(){return 1;})();
  • New Function $arguments, returns the specified arguments index of the passed in function. var x = $arguments(1); x(1, 2);
  • Hash is now a Native, too. This is especially useful for Generics on objects. Defined in the core along with its .each method. {a:1,b:2}.each(function(value, key){console.log(value, key);});
  • The Array .each method is now defined in the core. [1,2,3].each(function(item){console.log(item);});
  • $type now returns the relative type for each defined Native (including window, document, and others). $type(window);
  • New Function $exec, which is now the standard function to evaluate code in the global scope. $exec('var x = 10;'); window.x;
Browser
  • Window and Document are now Natives. new Window(iframe.contentWindow)
  • New Browser object, that holds useful information on the browser being used. This informations used to be stored in the window object. Browser.Engine.webkit;
  • .head, .html and .window are now automatically created shortcuts on document instantiation.
Array
  • New Array method .flatten. Flattens a multidimensional array in a single, 2d array. Especially useful with arguments.
  • New Array method .link. Links the contents of an array with an hash based on names/functions. If the functions successfully runs on an array item, the item will be linked to that name.
Hash
  • Hash is now a Native. It sports almost the same methods as Array (.map, .every, .some, .each) plus others from the original Hash class.
Number
  • Now the Number Native also includes all the methods from the Math object, to allow for a more OOP experience. (10).sin(); (10).cos(); (10).pow(2);.
String
  • New String method .stripScripts, to strip and optionally evaluate script tags from a string.
Class
  • Class method .extend has been deprecated. Now every class accepts Extends and Implements properties. new Class({Extends: OtherClass, Implements: [Events, Options]})
Element
  • New TextNode Native, to allow easy creation and manipulation of text nodes. new TextNode('ciao').inject(document.body);
  • New IFrame Native, to allow for easy IFrames creation / augmentation. new IFrame('/index.html').inject(document.body);
  • .inject, .grab, .append methods now supports instantiated text nodes. element.grab(new TextNode('ciao'))
  • Element Storage, to store information linked to the DOM elements, but in the storage.
  • .store and .retrieve Element methods, to work with the Element Storage. element.store('property', 100); element.retrieve('property');
  • New Element .set, .get and .erase methods. Can be used as set/get/removeProperty shortcuts, and they also support defining new "getters" and "setters".
  • Element .match method, to match an element against a selector. element.match('div.someClass[name=stupid]');
  • New Element .wraps method, to wrap an element with another one.
  • New Element .replaces method, to replace an element with another one. This replaces the .replaceWith method.
  • Element .remove is now .dispose to resolve a naming conflict in internet explorer.
  • Element methods .getFirst, .getLast, .getPrevious, .getNext now support a selector to match the result to. inputElement.getParent('form');
  • Added methods .getAllNext, .getAllPrevious, .getParents. They also support matching against selectors, but they return elements collections.
  • Element method .setHTML deprecated in favor of .set('html', value). Also added the .get('html') counterpart.
  • Element method .setText deprecated in favor of .set('text', value). Also added the .get('text') counterpart.
  • Element method .getValue deprecated in favor of .get('value').
  • Element method .getTag deprecated in favor of .get('tag').
  • Element Custom Events creation API is changed, and its now 100% more intuitive.
  • Element Events section overhauled. When adding a new Listener with .addEvent the window event will be automatically instantiated, removing the cruft.
  • Element Styles section overhauled. Styles are more solid than ever, and you can even write your own style rules.
Selectors
  • Support for pseudo selectors (CSS3) has been added. You can now even define your own custom pseudo selectors.
  • The performance of the CSS selectors has been vastly improved.
  • Selectors now include support for matching a selector against an element.
Element/Document Dimensions
  • Dimensions is a new component to handle the size and position in space of elements and the document.
  • Methods are not attached to the window object anymore, but rather on document.
  • Method .getSize is now deprecated, as well as .getHeight and .getWidth. The official method to get the offset size of either the document or an element is now .getOffsetSize, which returns an object containing x and y keys.
  • Methods .getScrollHeight and .getScrollWidth are now deprecated. The official method to get the scroll size of either the document or an element is now .getScrollSize, returning an object containing x and y keys.
  • Methods .getScrollTop and .getScrollLeft are now deprecated. The official method to get the scroll of either the document or an element is now .getScroll, returning an object containing x and y keys.
  • New Method .getRelativePosition, gets the position relative to an element's offset parent. This returns the values that you would need to set via CSS to make it appear where it is on the page. Returns an object containing x and y keys.
  • Method .getPosition has been enhanced to work in every situation, without the need to manually include scrolled parent nodes. It also accepts an additional argument, relative, to automatically calculate the difference of positions of these two elements (this and relative). Returns an object containing x and y keys.
  • New Element method .position, to position an element with x and y coordinates. Note: this is relative to the element's offset parent, so its best used along with .getRelativePosition.
  • New Element method .positioned, to check if an element is positioned with absolute, relative or fixed style.
  • New Element method .getOffsetParent, to get the real offset parent of an element. This is to circumvent a bug with Internet Explorer not returning the real offsetParent.
Sortables
  • Support for sortable floated lists has been added.
  • Support for sorting between many lists has been added.
  • You can now add and remove items from sortable lists on the fly.
  • Positioning logic has been hugely improved and everything now works independent of CSS configurations.
  • Serializing is now much more robust and allows for the use of a custom callback.
Drag
  • Drag.Base is now simply named Drag.
  • The onSnap event has been deprecated.
  • The onStart event is now fired after the element has been dragged farther than the distance defined in the snap option.
  • The onCancel event is now fired correctly when the user begins a drag but lets up the mouse button before moving a distance greater than the distance defined by the snap option.
  • The onComplete event will no longer be fired if the user simple clicks on the draggable element without actually dragging.
  • The mousedown event is no longer prevented from propagating, so textareas are focusable and links are clickable inside of draggable elements without defined handles.
Drag.Move
  • When making an element draggable, the element will now stay in the same place on the page without manually setting its position after the call to makeDraggable.
Fx
  • Fx.Base is now simply named Fx.
  • The base class for all the Fx has been completely rewritten for optimization and a cleaner API.
  • Fx:pause and Fx:resume methods have been added.
  • The Fx constructors now accept durations as one of the three strings 'short', 'normal', and 'long' corresponding to values of 250, 500, and 1000 milliseconds.
  • A new 'link' option is provided to control what happens when calls are made to start while an effect is currently running
    • link: 'cancel' - like wait:false from previous releases, will cancel the currently running effect to start the new one.
    • link: 'ignore' - like wait:true from previous releases, will ignore any calls made to start while a transition is in progress.
    • link: 'chain' - will chain all calls made to start so that they run one at a time in succession.
Fx.Tween
  • Fx.Style is now named Fx.Tween to more accurately reflect the behavior and to be consistent with the new Element:tween.
  • Element:tween has been added which will use the Element's internal Fx.Tween instance to transition any property in a single function call.
  • Element:highlight has been added which will fade an Element's background color from the specified value down to its current color. Default color is '#ff8'.
  • Element:fade has been added which will fade an Element to the specified state or opacity in a single function call. Possible values are:
    • 'in', 'out', 'toggle' - fade the element in, out, or to the opposite of its current state (respectively).
    • 'show', 'hide' - set the elements opacity immediately to 1 or 0 respectively, without a transition.
    • numeric value between 0 and 1 - fade the element to the specified opacity.
Fx.Morph
  • Fx.Styles is now named Fx.Morph to more accurately reflect the behavior and to be consistent with the new Element:morph.
  • Element:morph has been added which will use the Element's internal Fx.Morph instance to transition any number of properties in a single function call.
  • CSS Selectors may now also be used as the argument to grab the transition styles from so properties can be stored in the Stylesheets.
Fx.Slide
  • Element:slide has been added which will use the Element's internal Fx.Slide instance to slide the element in and out in a single function call. Possible values are:
    • 'in', 'out', 'toggle' - slide the element in, out, or to the opposite of its current state (respectively).
    • 'show', 'hide' - set the slide state of the element immediately to in or out respectively, without a transition.
Fx.Transitions
  • When Fx.Transitions is included, the transition may now be passed to the Fx option as a colon separated string (type:how). Examples include:
    • 'linear', 'sine:in', 'expo:out', 'quad:in', 'bounce:out', 'elastic:out', 'quint:in:out', etc.
Request
  • New Request class replaces XHR and Ajax as the MooTools XMLHttpRequest wrapper.
  • The Request constructor takes in only options, one of which is the URL, which used to be passed as the first argument.
  • Request:send now takes an options object, or a String or Element to be used as data as the only argument.
    • Any options passed to send are used in place of the defaults that were provided (if they were provided) when creating the instance.
  • New Request methods for handling specific types of requests more easily.
    • Request:get, Request:post - Strings passed to these functions will be used as the url, an object passed will be the data, and the method will be get and post respectively.
    • GET, POST, PUT, and DELETE methods have also been added to make RPC with MooTools easier. All behave the same way as get and post.
  • Element:send no longer takes options as an argument, but rather, takes the url to send the request to. In order to use special options for the internal Request instance, you must use Element:set.
Request.HTML
  • Request.HTML adds some extra functionality for automatically processing HTML responses to the Request Class.
  • After a successful Request, the response's HTML is processed, scripts can be evaluated, and several arguments are passed to the onSuccess callback.
    • tree - the original tree of the HTML snippet that was returned from the Request.
    • elements - a flattened array of all the Elements that were returned from the Request.
    • html - the raw HTML string that was returned from the Response.
  • Element:load has been added which allows you to update the HTML content of an element from the response of a Request called using the Element's internal Request.HTML instance.
Request.JSON
  • Request.JSON now replaces JSON.Remote and adds some extra functionality for automatically processing JSON responses to the Request Class.
  • After a successful Request, the response's JSON is processed and passed directly to the onSuccess callback.
A Final Note

Thanks for reading this far! We promise you won't be disappointed with 1.2.

40 Responses to “MooTools 1.2 beta 1”

  1. procyon Says:

    Great,great news Valerio :) Thank you and all the Mootools team for the awesome work.

  2. Jason Says:

    <3

  3. SteveE Says:

    Inspiring work, many thanks.

  4. Awesome job, Valerio and team. I've followed the timeline for quite a while now and I appreciate your dedication, hard work, and imagination. I look forward to using future versions.

  5. Hell yes! It's been a long time coming. Congrats and all that. Well done!

  6. You can thank us all you want, but there's a lot of people who have also contributed to the work. :D

    In paticular, big thanks goes out to procyon for his help in the documentation. Not by any means, would MooTools have arrived to 1.2beta if he hadn't contributed soo much to the documentation.

    We still have a lot of work ahead, however! Get your butts cookin' and meet us at the irc channel: irc://irc.freenode.net/mootools . We'd love your input, and help with some of the things that have yet to be finished for 1.2.0 release.

  7. BrankGnol Says:

    Waouh, that's a Changelog :)

    Great work, dudes !

  8. Nico ! Says:

    Thanks a lot for all what you do ! I like JS thanks to you !

  9. It's awesome, I was asked about the .set change for setHTML and now I see all that very clear and guessed right. Thanks a lot, specially those who participate in the irc too. I'm just going to try the 1.2 out.

  10. Guys, you are simply awesome!!!!

  11. Mourner Says:

    Awesome work!

    Can't download it though - the download page returns some strange html file instead of js :(

  12. Congrats to everyone. I'm all in favor not to be afraid to change names. The earlier the better. It always has to be done at the end.

    I've got a whole library that relies on mootools 1.1 . And I love the fact that you can choose if you want a compatible version. A great thing would be to have a compatible version that call firebug's console.log at every deprecated call. That way, we could update our code rapidly, not repairing 1 error at a time.

    Thx again.

  13. Tom Says:

    Can only confirm the other comments... Awesome work!!!!!! Truly amazing!!! Mootools saves me tuns of time!

  14. moro Says:

    awesome! :-)

  15. Chris Says:

    Yay!

  16. njy Says:

    @Valerio: Overwhelming release guys! Just a note: I've already posted a question about the supported DOCTYPE, in the sense that usually you say that the only officially supported DT is strict, but you've added support for IFrames, that aren't part of that DT (it's in the transitional and above). So, the point is: can we use the transitional DT without problems? And the accordion and etc... will work as expected or what?

    Anyway, thanks for everything!

    Good work.

  17. Diddos to your hard work. I have found MooTools to be the best javascript framework!

  18. rasmus Says:

    what?! the example regarding Hash: is this a typo or did you really extend the native Object?

    {a:1,b:2}.each(function(value, key){console.log(value, key);});

  19. Daya Sharma Says:

    Can we namespace Mootools just like YahooUI library? Right now there is no way to use Mootools & Protoype together i.e. in RubyOnRails. The conflicts are just too many & it becomes impossible to use Mootools in framework like Rails without coding View Helpers.

  20. @rasmus, right a little type-o. Should be: new Hash({a: 1, b: 2}).each(....

    @Daya, you'd have to manually name space all the globals and change all the global calls like $ to a namespace. Even after all of that, however, Prototype and MooTools will still not collaborate. Prototype and MooTools modify some of the Native prototypes to enhance JavaScript. Therefore, if we both share the same property name, then it could be a race condition to who uses what. My best advice: port the code to the framework of your choice. You'll be most "overall" efficient in the long run.

  21. gonchuki Says:

    great! have to chek it out as I have been getting some incompatibilities with my wordpress install (both with 1.11 and a trunk build some days ago), but have yet to check if it's an issue with injected js by some plugin I have installed.

  22. Daya Sharma Says:

    @Olmo, I understand that but thats like asking every developer to resolve their own incompatibilities and to avoid conflicts like these YUI namespaced everything & if yahoo can do it you too surely can. This will increase mootools adoption many folds & thats the main reason yahoo did it.

  23. Tamlyn Says:

    Many thanks to everyone who contributed to this. There are at least 10 items listed above that I want to immediately integrate into my existing code. Made my day!

    I looking forward to completing my application and sharing my JavaScript classes with the community (though many are specific to the app).

  24. @Daya, continue the conversation in your forum post. As you seem to misunderstand the main problem.

  25. Matt Says:

    This is looking fantastic! I've been playing around with 1.2 for a little while, but I didn't even realize there was this many changes.

  26. njy Says:

    @Olmo: hi Olmo! If you want, you can answer to my question too =) ... it seems Valerio is a little busy at this time: it's the transitional DT officially supported? If so, the famouse FAQ that says that MooTools expects a strict DT is no more valid? Is this right?

    Anyway thanks!

  27. @njy, yes you should be able to use any XHTML Doctype. Including Transitional or Frameset. The documentation was updated a long time ago to never say 'Strict', it now says 'an XHMTML Doctype'.

  28. Valerio Says:

    A final clarification about doctypes:

    XHTML Doctype is only required for a certain number of scripts, specifically those that depend on Dimensions.js. Calculating a crossbrowser document dimension is impossible unless you use an XHTML Doctype.

  29. njy Says:

    @Tom: Oh excellent Tom! Sorry but I was not able to find a place in the documenation where you guys specicy the required/allowed DOCTYPEs. Can you point me to it? So that I can try not to ask dumb questions anymore :) ...

    Thanks again guys.

    p.s.: just as a hint: "documentation" speaking I was able only to find this http://dev.mootools.net/wiki/faq that is, as of now, the official faq, right? There you say that the only allowed DT is FIXED. Just to let you update that part. Thanks.

  30. njy Says:

    @Valerio: sorry I've wrote the answer while you were writing your :) ... anyway: thanks for the clarification. So quite everything is functioning in transitional/frameset, while in strict is 100% ok. Well, finally I've clarified my dubts :)

    Anyway, just a final question that (I think) can be useful for everyone: do you know what happens when you specify a strict Doctype -and- manipulate the DOM adding some nodes that are -not- a part of the Doctype? I'm making some tests about that, and it seems to accept those nodes while mantaining the original Doctype. But that is strange, since Firefox & co are quite adherent to the standard. Do you guys have some more infos? Cheers!

  31. Lutz Says:

    Great! I've been looking forward towards 1.2 for a long time, very thought through update. This is why I love mootools.

  32. Chris Says:

    Great work guys, I've been watching the svn every morining for the last few months untill I saw Valerio tag the beta yeasterday. Can't wait for the full release, keep up the good work! On a side note, I'm currently in the middle of a project using 1.1 so in case the new version is released soon I hope the old download builder will still be available for a few weeks. I use packito on the final scripts and build a download with only the stuff I need, keeping mootools lightweight.. the way it deserves ;) laterzzzz

  33. gonchuki Says:

    @njy: from my personal experience browsers are very lenient to malformed code even when injected via javascript, at least in IE and FF. It even lets you do things out of spec like adding 2 or more theads and tfoots.

  34. Ryan Rampersad Says:

    Moooo! Everyone has been working hard in the IRC channel and trac tickets! Thanks everyone! I'll get working on the walkthrough as soon as I have a break :D

  35. Dr.Death Says:

    getPosition() in opera sometimes give wrong values!

  36. njy Says:

    @Dr.Death: wich Doctype are you using? That can be the problem. As Valerio already said up here, there are some position/dimensions related problems with Doctypes different than "strict".

  37. Dr.Death Says:

    2njy: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

  38. tofu Says:

    wicked!

  39. jorge báez Says:

    Great work. thanks to all team and contributors.

    What are the estimates for 1.2 ???? It's pretty exciting!

  40. njy Says:

    @Dr.Death: mmmh, maybe you should open a ticket on Trac for it ;) ! Cheers

Sorry, comments are closed for this article.