Moo.js

My Object Oriented javascript.

Dependancies

Has no dependancies.

Author

Valerio Proietti, http://mad4milk.net

License

MIT-style license.

Credits

Summary
Moo.js My Object Oriented javascript.
Class The base class object of the http://mootools.net framework.
Properties
empty Returns an empty function
create same as new Class.
extend Returns the copy of the Class extended with the passed in properties.
implement Implements the passed in properties to the base Class prototypes, altering the base class, unlike Class.extend.
Object related Functions
Functions
Object. extend Copies all the properties from the second passed object to the first passed Object.
Object. Native Will add a .extend method to the objects passed as a parameter, equivalent to Class.implement

Class

The base class object of the http://mootools.net framework.

Arguments

properties the collection of properties that apply to the class.  Creates a new class, its initialize method will fire upon class instantiation.

Example

var Cat = new Class({
initialize: function(name){
this.name = name;
}
});
var myCat = new Cat('Micia');
alert myCat.name; //alerts 'Micia'
Summary
Properties
empty Returns an empty function
create same as new Class.
extend Returns the copy of the Class extended with the passed in properties.
implement Implements the passed in properties to the base Class prototypes, altering the base class, unlike Class.extend.

Properties

empty

Returns an empty function

create

same as new Class. see Class

extend

Returns the copy of the Class extended with the passed in properties.

Arguments

properties the properties to add to the base class in this new Class.

Example

var Animal = new Class({
initialize: function(age){
this.age = age;
}
});
var Cat = Animal.extend({
initialize: function(name, age){
this.parent(age); //will call the previous initialize;
this.name = name;
}
});
var myCat = new Cat('Micia', 20);
alert myCat.name; //alerts 'Micia'
alert myCat.age; //alerts 20

implement

Implements the passed in properties to the base Class prototypes, altering the base class, unlike Class.extend.

Arguments

properties the properties to add to the base class.

Example

var Animal = new Class({
initialize: function(age){
this.age = age;
}
});
Animal.implement({
setName: function(name){
this.name = name
}
});
var myAnimal = new Animal(20);
myAnimal.setName('Micia');
alert(myAnimal.name); //alerts 'Micia'

Object related Functions

Summary
Functions
Object. extend Copies all the properties from the second passed object to the first passed Object.
Object. Native Will add a .extend method to the objects passed as a parameter, equivalent to Class.implement

Functions

Object. extend

Object.extend = function()

Copies all the properties from the second passed object to the first passed Object.  If you do myWhatever.extend = Object.extend the first parameter will become myWhatever, and your extend function will only need one parameter.

Example

var firstOb = {
'name': 'John',
'lastName': 'Doe'
};
var secondOb = {
'age': '20',
'sex': 'male',
'lastName': 'Dorian'
};
Object.extend(firstOb, secondOb);
//firstOb will become:
{
'name': 'John',
'lastName': 'Dorian',
'age': '20',
'sex': 'male'
};

Returns

The first object, extended.

Object. Native

Object.Native = function()

Will add a .extend method to the objects passed as a parameter, equivalent to Class.implement

Arguments

a number of classes/native javascript objects

Returns the copy of the Class extended with the passed in properties.
Object.extend = function()
Copies all the properties from the second passed object to the first passed Object.
Object.Native = function()
Implements the passed in properties to the base Class prototypes, altering the base class, unlike <Class.extend>.
Will add a .extend method to the objects passed as a parameter, equivalent to Class.implement
The base class object of the http://mootools.net framework.