the compact javascript framework
in partnership with mediatemple
Contains the Class Function, aims to ease the creation of reusable Classes.
MIT-style license.
Class.js | Contains the Class Function, aims to ease the creation of reusable Classes. |
Class | The base class object of the http://mootools.net framework. |
Properties | |
empty | Returns an empty function |
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. |
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.
properties | the collection of properties that apply to the class. |
var Cat = new Class({ initialize: function(name){ this.name = name; } }); var myCat = new Cat('Micia'); alert(myCat.name); //alerts 'Micia'
Properties | |
empty | Returns an empty function |
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. |
Returns the copy of the Class extended with the passed in properties.
properties | the properties to add to the base class in this new Class. |
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
Implements the passed in properties to the base Class prototypes, altering the base class, unlike Class.extend.
properties | the properties to add to the base class. |
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'
Documentation by Aaron Newton & Mootools Developers, generated by NaturalDocs and GeSHi