This is the base class for all the other Ladybug classes, it implements a simple inheritance layer for better encapsulation of the derived classes and a better foundation for object-oriented stuff.
The original code was written by John Resig (http://ejohn.org/blog/simple-javascript-inheritance/).
So, how do you create and/or extend your own classes?
Take the Ladybug.Class
or any derived class and extend it with your own properties and methods. That's all it takes:
// Create an object from the base class
Foo = Ladybug.Class.extend({
bar: function() {
console.log('baz');
}
});
// Subclass your new object
Bar = Foo.extend({
bar: function() {
// Override at first
console.log('I am ');
// Then call parent method
this._super();
}
});
function extend(options)
This is the core of the sub-classing mechanism, just take the base object and call extend
to create a new constructor.
The passed options will define the extended-class methods and properties.
Go back to previous page