1
/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3
* full text of the license. */
6
* Constructor: OpenLayers.Class
7
* Base class used to construct all other classes. Includes support for
8
* multiple inheritance.
10
* This constructor is new in OpenLayers 2.5. At OpenLayers 3.0, the old
11
* syntax for creating classes and dealing with inheritance
14
* To create a new OpenLayers-style class, use the following syntax:
15
* > var MyClass = OpenLayers.Class(prototype);
17
* To create a new OpenLayers-style class with multiple inheritance, use the
19
* > var MyClass = OpenLayers.Class(Class1, Class2, prototype);
22
OpenLayers.Class = function() {
23
var Class = function() {
25
* This following condition can be removed at 3.0 - this is only for
26
* backwards compatibility while the Class.inherit method is still
27
* in use. So at 3.0, the following three lines would be replaced with
29
* this.initialize.apply(this, arguments);
31
if (arguments && arguments[0] != OpenLayers.Class.isPrototype) {
32
this.initialize.apply(this, arguments);
37
for(var i=0, len=arguments.length; i<len; ++i) {
38
if(typeof arguments[i] == "function") {
39
// get the prototype of the superclass
40
parent = arguments[i].prototype;
42
// in this case we're extending with the prototype
43
parent = arguments[i];
45
OpenLayers.Util.extend(extended, parent);
47
Class.prototype = extended;
52
* Property: isPrototype
53
* *Deprecated*. This is no longer needed and will be removed at 3.0.
55
OpenLayers.Class.isPrototype = function () {};
58
* APIFunction: OpenLayers.create
59
* *Deprecated*. Old method to create an OpenLayers style class. Use the
60
* <OpenLayers.Class> constructor instead.
65
OpenLayers.Class.create = function() {
67
if (arguments && arguments[0] != OpenLayers.Class.isPrototype) {
68
this.initialize.apply(this, arguments);
75
* APIFunction: inherit
76
* *Deprecated*. Old method to inherit from one or more OpenLayers style
77
* classes. Use the <OpenLayers.Class> constructor instead.
80
* class - One or more classes can be provided as arguments
85
OpenLayers.Class.inherit = function () {
86
var superClass = arguments[0];
87
var proto = new superClass(OpenLayers.Class.isPrototype);
88
for (var i=1, len=arguments.length; i<len; i++) {
89
if (typeof arguments[i] == "function") {
90
var mixin = arguments[i];
91
arguments[i] = new mixin(OpenLayers.Class.isPrototype);
93
OpenLayers.Util.extend(proto, arguments[i]);