View this documentation in the following language:

Overview

Here you find a javascript class which make it possible, that you can create classes and inherit a class from other classes you are used to in object oriented programming languages.

Create a class:

var Animal = new Class.create({
	speak: function() {alert(this.say);}
,	say: ""
});

Extend a class:

TOP

Of coures it is simple to extend a class. For example we can extend this Animal-class.:

var Human = new Class.create({
	initialize: function(sentence) { this.say = sentence;}
,	say: "Hello World"
}, Animal);

It would also be possible, to extend a class with multiple classes:

var MyClass = new Class.create({
	initialize: function(sentence) { this.say = sentence;}
,	say: "Hello world"
}, Animal, AnotherAnimal,...);

Extend a class later:

TOP

You also can extend a class later: (This extension will also extend all existing instances of this class!)

var Human = new Class.create({
	initialize: function(sentence) { this.say = sentence;}
,	say: "Hallo Welt"
});
// do something
Human.extend(Animal);

Call a constructor of a superclass:

TOP

If you extend from a single class, there are two ways to call the constructor of a parent class:

var Superclass = new Class.create({
	initialize: function(sentence) { this.say = sentence;}
,	say: "Hallo Welt"
});

Possibility 1:

var Subclass = new Class.create({
	initialize: function() { this.super("Subsentence!"); }
}, Superclass);

Possibility 2:

var Subclass = new Class.create({
}, Superclass("Subsentence!"));

Call a constructor of a polymorph extended class:

TOP

If your class extends more then one class, only the second way is useable:

var Superclass = new Class.create({
	initialize: function(sentence) { this.say = sentence; }
,	say: ""
});
var Superclass2 = new Class.create({
	initialize: function(what) { this.see = "A big "+what; }
,	see: ""
});

var Subclass = new Class.create({
}, Superclass("Hello balloon!"), Superclass2("balloon"));