Class.js

Contains the Class Function, aims to ease the creation of reusable Classes.

License

MIT-style license.

Summary
Class.jsContains the Class Function, aims to ease the creation of reusable Classes.
ClassThe base class object of the http://mootools.net framework.
Properties
emptyReturns an empty function
extendReturns the copy of the Class extended with the passed in properties.
implementImplements the passed in properties to the base Class prototypes, altering the base class, unlike Class.extend.

Class

The base class object of the http://mootools.net framework.  Creates a new class, its initialize method will fire upon class instantiation.  Initialize wont fire on instantiation when you pass null.

Arguments

propertiesthe collection of properties that apply to the class.

Example

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

Properties

empty

Returns an empty function

extend

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

Arguments

propertiesthe 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

propertiesthe 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'
Returns the copy of the Class extended with the passed in properties.

Documentation by Aaron Newton & Mootools Developers, generated by NaturalDocs and GeSHi