Here is the long-awaited
release of MooTools 1.3. I'll tell you a little about the changes in the framework itself, and in its "environment". There are a lot of differences between versions 1.2 and 1.3, but first things first.
The first thing to say, is that there is an assembly of version 1.3, which is 100% compatible with 1.2, you are not afraid to be updated.
Slick
And so, about the differences. The most tasty thing in the new version is the new css selector engine Slick. It is completely independent of MooTools, can be used separately. It is “izkarobki” supports all imaginable and inconceivable selectors / pseudo-selectors, and if you find this and not enough, do not worry, you can always create a new one.
Examples of use outside MooTools:
Slick.search(document, "div > p.moo:not(.foo)");
Inside MooTools, the same selectors are used as usual.
And now concisely:
- Pure javascript
- 50% faster than old
- Supports any selector you can think of.
- Flexible, allows you to create your pseudo-selectors
- Supports XML search
API changes
Core
- $ methods are now in the past:
- $ chk (value) => (value! = null)
- $ A (item) => Array.from (item)
- $ splat => Array.from
- $ clear => have to use native clearTimeout or clearInterval
- $ defined => (value! = null)
- $ each => Array.each / Object.each depending on context
- $ empty => deleted, function () {} must be used
- $ extend (source, extended) => Object.append (source, extended)
- $ merge ({}, a, b) => Object.merge ({}, a, b)
- $ mixin (a, b) => Object.merge (a, b)
- $ lambda => Function.from
- $ random => Number.random
- $ time => Date.now
- $ type => typeOf with one change, for empty objects now returns the string “null”
- $ unlink => Array.clone / Object.clone
- $ arguments => deleted
- $ pick => Array.pick or [a, b, c] .pick ()
- $ exec => Browser.exec
And
- Native is now called Type
- Array.type / String.type / Number.type / etc. => Type.isArray / Type.isString / Type.isNumber / etc.
- Hash and $ H moved to MooTools More
Browser detection
- Engine detection => user-agent detection.
- Browser.Engine => removed
- Browser.Engine.trident => Browser.ie
- Browser.Engine.gecko => Browser.firefox
- Browser.Engine.webkit => Browser.safari or Browser.chrome
- Browser.Engine.presto => Browser.opera
- Browser.Platform.ipod => Browser.Platform.ios
Array
- Array.extend => Array.append
Function
- myFn.bind (this, [arg1, arg2, arg3]) => myFn.bind (this, arg1, arg2, arg3) or myFn.pass ([arg1, arg2, arg3], this)
- $ try => Function.attempt
- myFn.run (args, bind) => myFn.apply (bind, Array.from (args));
- myFn.create => use .pass, .bind, .delay, .periodical
- myFn.bindWithEvent => is deprecated
Element
- element.injectInside, .injectBefore, .injectAfter, etc => element.inject (context, where);
- element.grabTop, ... => element.grab (context, where)
- element.hasChild (item) => element.contains (item) &&
- item! = element
- Selectors.Pseudo => Slick.definePseudo (name, fn)
- Element.get => no longer supports the second parameter (it is used for animation, for example element.get ('tween', options) now element.set ('tween', options) .get ('tween'))
Using Slick to create new elements has become easier:
new Element("input", {"id": "someID", "class": "someClass1", "disabled": true});
New opportunities
- Type.from (Array.from, String.from, Function.from, etc.) => type conversion
- Fx => unified timer for all effects
Environment
- MooTools Test Runner => now testing is performed automatically not only in every browser, but also on the server
- Packager => a new tool for collecting MooTools for your needs.
Packager
Packager was developed for project management. It works as follows: you create code, create a special comment at the beginning of each file, where you specify the name, author, dependencies, etc., also create a configuration file for the package (project), where you specify the name, description, list of participants in the assembly files, etc., packager works from the terminal:
$ packager register /path/to/project $ packager build ProjectName/* > myproject.js
When assembling takes into account external dependencies. By external, I mean dependencies on other projects that are also registered in Packager. The stuff is very convenient, I have been using for my projects for six months already.
')
Summary
In general, about a third of the code was rewritten. There are also a lot of changes in MooTools More, for example, there is support for pseudo-selectors for events, for example:
element.addEvent('click:once', function(){});
The next big release is MooTools 2 (now for sure).
Repositories:
MooTools Core
MooTools More
Slick
Packager