MooTools
Encyclopedia
MooTools is a lightweight, object-oriented, web-application framework
Software framework
In computer programming, a software framework is an abstraction in which software providing generic functionality can be selectively changed by user code, thus providing application specific software...

 for JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

, written in JavaScript. It is released under the free, open-source MIT License
MIT License
The MIT License is a free software license originating at the Massachusetts Institute of Technology . It is a permissive license, meaning that it permits reuse within proprietary software provided all copies of the licensed software include a copy of the MIT License terms...

. It is used on more than 5% of all websites, and is one of the most popular JavaScript libraries.

History

Valerio Proietti first authored the framework and released it in September 2006 taking as his inspiration Prototype
Prototype Javascript Framework
The Prototype JavaScript Framework is a JavaScript framework created by Sam Stephenson in February 2005 as part of the foundation for Ajax support in Ruby on Rails. It is implemented as a single file of JavaScript code, usually named prototype.js...

 and Dean Edward's base2. MooTools originated from Moo.fx
Moo.fx
moo.fx is a JavaScript effects library, first released in October 2005 by Valerio Proietti as an add-on to the Prototype Javascript Framework. It can be used as a lighter alternative to script.aculo.us or other, bigger libraries...

, a popular plug-in Proietti produced for Prototype in October 2005, which is still maintained and used.

Whereas Prototype extended—prototyped—many of JavaScript's native String, Array, and Function objects with additional methods, Proietti desired a framework that (at the time) further extended the native Element object as well to offer greater control of the Document Object Model
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...

 (DOM).

Components

MooTools includes a number of components, but not all need to be loaded for each application. Some of the component categories are:
  • Core: A collection of utility functions that all the other components require.
  • More: An official collection of add-ons that extend the Core and provide enhanced functionality.
  • Class: The base library for Class object instantiation.
  • Natives: A collection of JavaScript
    JavaScript
    JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

     Native Object enhancements. The Natives add functionality, compatibility, and new methods that simplify coding.
  • Element: Contains a large number of enhancements and compatibility standardization to the HTML Element
    HTML element
    An HTML element is an individual component of an HTML document. HTML documents are composed of a tree of HTML elements and other nodes, such as text nodes. Each element can have attributes specified. Elements can also have content, including other elements and text. HTML elements represent...

     object.
  • Fx: An advanced effects-API to animate page elements.
  • Request: Includes XHR interface, Cookie, JSON
    JSON
    JSON , or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects...

    , and HTML
    HTML
    HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

     retrieval-specific tools for developers to exploit.
  • Window: Provides a cross-browser interface to client-specific information, such as the dimensions of the window.

Browser compatibility

MooTools is compatible and tested with:
  • Safari
    Safari (web browser)
    Safari is a web browser developed by Apple Inc. and included with the Mac OS X and iOS operating systems. First released as a public beta on January 7, 2003 on the company's Mac OS X operating system, it became Apple's default browser beginning with Mac OS X v10.3 "Panther". Safari is also the...

     3+
  • Internet Explorer
    Internet Explorer
    Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...

     6+
  • Mozilla Firefox 2+
  • Opera
    Opera (web browser)
    Opera is a web browser and Internet suite developed by Opera Software with over 200 million users worldwide. The browser handles common Internet-related tasks such as displaying web sites, sending and receiving e-mail messages, managing contacts, chatting on IRC, downloading files via BitTorrent,...

     9+
  • Chrome
    Google Chrome
    Google Chrome is a web browser developed by Google that uses the WebKit layout engine. It was first released as a beta version for Microsoft Windows on September 2, 2008, and the public stable release was on December 11, 2008. The name is derived from the graphical user interface frame, or...

     4+

Benefits

MooTools provides the user with a number of advantages over native JavaScript. These include:
  • An extensible and modular framework allowing developers to choose their own customized combination of components.
  • MooTools follows object-oriented practices and the DRY
    Don't repeat yourself
    In software engineering, Don't Repeat Yourself is a principle of software development aimed at reducing repetition of information of all kinds, especially useful in multi-tier architectures...

     principle.
  • An advanced effects component, with optimized transitions such as easing equations used by many Flash developers.
  • Enhancements to the DOM
    Document Object Model
    The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...

    , enabling developers to easily add, modify, select, and delete DOM elements. Storing and retrieving information with Element storage is also supported.


The framework includes built-in functions for manipulation of CSS
CSS
-Computing:*Cascading Style Sheets, a language used to describe the style of document presentations in web development*Central Structure Store in the PHIGS 3D API*Closed source software, software that is not distributed with source code...

, DOM
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...

 elements, native JavaScript objects, Ajax
Ajax (programming)
Ajax is a group of interrelated web development methods used on the client-side to create asynchronous web applications...

 requests, DOM effects, and more. MooTools also provides a detailed, coherent application programming interface
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

 (API) as well as a custom downloads module allowing developers to download only the modules and dependencies they need for a particular app.

Emphasis on modularity and reusability

Every JavaScript framework has its philosophy, and MooTools is interested in taking full advantage of the flexibility and power of JavaScript in a way that emphasizes greater modularity and code reuse. MooTools accomplishes these goals in a way that is intuitive to a developer coming from a class-based inheritance
Class-based programming
Class-based programming, or more commonly class-orientation, refers to the style of object-oriented programming in which inheritance is achieved by defining classes of objects, as opposed to the objects themselves .The most popular and developed model of OOP is a class-based model, as opposed to an...

 language like Java with the MooTools Class object.

Class is an object of key/value pairs that can contain either properties or methods (functions). Class is effortlessly mixed and extended with other Class instantiations allowing for the greatest focus of MooTools: Code reuse achieved through maximizing the power of JavaScript's prototypical inheritance, but in a Class object syntax more familiar to classical inheritance models.

Object-oriented programming

MooTools contains a robust Class creation and inheritance system that resembles most classically based Object-oriented programming language
Object-oriented programming language
This is a list of object-oriented programming programming languages.-Languages with object-oriented features:*ABAP*Ada 95*AmigaE*BETA*Blue*Boo*C++*C#*COBOL*Cobra*ColdFusion*Common Lisp*COOL*CorbaScript*Clarion*CLU*Curl*D*Dylan*E*Eiffel...

s. For example, the following is MooTools' equivalent of the examples in Wikipedia's polymorphism page:


var Animal = new Class({

initialize: function(name) {
this.name = name;
}

});

var Cat = new Class({
Extends: Animal,

talk: function {
return 'Meow!';
}

});

var Dog = new Class({

Extends: Animal,

talk: function {
return 'Arf! Arf';
}

});

var animals = {
a: new Cat('Missy'),
b: new Cat('Mr. Bojangles'),
c: new Dog('Lassie')
};

Object.each(animals, function(animal) {
alert(animal.name + ': ' + animal.talk);
});

// alerts the following:
//
// Missy: Meow!
// Mr. Bojangles: Meow!
// Lassie: Arf! Arf!

See also

  • Moo.fx
    Moo.fx
    moo.fx is a JavaScript effects library, first released in October 2005 by Valerio Proietti as an add-on to the Prototype Javascript Framework. It can be used as a lighter alternative to script.aculo.us or other, bigger libraries...

  • Ajax framework
    Ajax framework
    In web application development, an Ajax framework is a framework which leverages Ajax, a collection of technologies for building dynamic web pages on the client side...

  • Rich Internet application
    Rich Internet application
    A Rich Internet Application is a Web application that has many of the characteristics of desktop application software, typically delivered either by way of a site-specific browser, via a browser plug-in, independent sandboxes, extensive use of JavaScript, or virtual machines...

  • Web 2.0
    Web 2.0
    The term Web 2.0 is associated with web applications that facilitate participatory information sharing, interoperability, user-centered design, and collaboration on the World Wide Web...

  • Comparison of JavaScript frameworks
    Comparison of JavaScript frameworks
    - Rationale :There are many JavaScript frameworks available. The intention of this comparison is to show some examples of JavaScript frameworks with their different features.- Table of Javascript Frameworks :- External links :* * * * * * * *...

  • XMLHttpRequest
    XMLHttpRequest
    XMLHttpRequest is an API available in web browser scripting languages such as JavaScript. It is used to send HTTP or HTTPS requests directly to a web server and load the server response data directly back into the script. The data might be received from the server as XML text or as plain text...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK