Script and makefile adjustments for updating extlib
[larjonas-mediagoblin.git] / extlib / leaflet / src / core / Class.js
blob09a9e539343e8f6957dd64d3c7a165527f96e820
1 /*
2 * Class powers the OOP facilities of the library. Thanks to John Resig and Dean Edwards for inspiration!
3 */
5 L.Class = function() {};
7 L.Class.extend = function(/*Object*/ props) /*-> Class*/ {
9 // extended class with the new prototype
10 var NewClass = function() {
11 if (!L.Class._prototyping && this.initialize) {
12 this.initialize.apply(this, arguments);
16 // instantiate class without calling constructor
17 L.Class._prototyping = true;
18 var proto = new this();
19 L.Class._prototyping = false;
21 proto.constructor = NewClass;
22 NewClass.prototype = proto;
24 // add superclass access
25 proto.superclass = this.prototype;
27 // add class name
28 //proto.className = props;
30 // mix static properties into the class
31 if (props.statics) {
32 L.Util.extend(NewClass, props.statics);
33 delete props.statics;
36 // mix includes into the prototype
37 if (props.includes) {
38 L.Util.extend.apply(null, [proto].concat(props.includes));
39 delete props.includes;
42 // merge options
43 if (props.options && proto.options) {
44 props.options = L.Util.extend({}, proto.options, props.options);
47 // mix given properties into the prototype
48 L.Util.extend(proto, props);
50 // allow inheriting further
51 NewClass.extend = arguments.callee;
53 // method for adding properties to prototype
54 NewClass.include = function(props) {
55 L.Util.extend(this.prototype, props);
58 //inherit parent's statics
59 for (var i in this) {
60 if (this.hasOwnProperty(i) && i != 'prototype') {
61 NewClass[i] = this[i];
65 return NewClass;