~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to gis/dhis-gis-geostat/mfbase/openlayers/lib/OpenLayers/BaseTypes/Class.js

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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. */
 
4
 
 
5
/**
 
6
 * Constructor: OpenLayers.Class
 
7
 * Base class used to construct all other classes. Includes support for 
 
8
 *     multiple inheritance. 
 
9
 *     
 
10
 * This constructor is new in OpenLayers 2.5.  At OpenLayers 3.0, the old 
 
11
 *     syntax for creating classes and dealing with inheritance 
 
12
 *     will be removed.
 
13
 * 
 
14
 * To create a new OpenLayers-style class, use the following syntax:
 
15
 * > var MyClass = OpenLayers.Class(prototype);
 
16
 *
 
17
 * To create a new OpenLayers-style class with multiple inheritance, use the
 
18
 *     following syntax:
 
19
 * > var MyClass = OpenLayers.Class(Class1, Class2, prototype);
 
20
 *
 
21
 */
 
22
OpenLayers.Class = function() {
 
23
    var Class = function() {
 
24
        /**
 
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
 
28
         * simply:
 
29
         * this.initialize.apply(this, arguments);
 
30
         */
 
31
        if (arguments && arguments[0] != OpenLayers.Class.isPrototype) {
 
32
            this.initialize.apply(this, arguments);
 
33
        }
 
34
    };
 
35
    var extended = {};
 
36
    var parent;
 
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;
 
41
        } else {
 
42
            // in this case we're extending with the prototype
 
43
            parent = arguments[i];
 
44
        }
 
45
        OpenLayers.Util.extend(extended, parent);
 
46
    }
 
47
    Class.prototype = extended;
 
48
    return Class;
 
49
};
 
50
 
 
51
/**
 
52
 * Property: isPrototype
 
53
 * *Deprecated*.  This is no longer needed and will be removed at 3.0.
 
54
 */
 
55
OpenLayers.Class.isPrototype = function () {};
 
56
 
 
57
/**
 
58
 * APIFunction: OpenLayers.create
 
59
 * *Deprecated*.  Old method to create an OpenLayers style class.  Use the
 
60
 *     <OpenLayers.Class> constructor instead.
 
61
 *
 
62
 * Returns:
 
63
 * An OpenLayers class
 
64
 */
 
65
OpenLayers.Class.create = function() {
 
66
    return function() {
 
67
        if (arguments && arguments[0] != OpenLayers.Class.isPrototype) {
 
68
            this.initialize.apply(this, arguments);
 
69
        }
 
70
    };
 
71
};
 
72
 
 
73
 
 
74
/**
 
75
 * APIFunction: inherit
 
76
 * *Deprecated*.  Old method to inherit from one or more OpenLayers style
 
77
 *     classes.  Use the <OpenLayers.Class> constructor instead.
 
78
 *
 
79
 * Parameters:
 
80
 * class - One or more classes can be provided as arguments
 
81
 *
 
82
 * Returns:
 
83
 * An object prototype
 
84
 */
 
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);
 
92
        }
 
93
        OpenLayers.Util.extend(proto, arguments[i]);
 
94
    }
 
95
    return proto;
 
96
};