OpenLayers OpenLayers

Changeset 1647

Show
Ignore:
Timestamp:
10/06/06 11:32:38 (2 years ago)
Author:
sderle
Message:

Added Class.inherit, changed Class.create to make it unnecessary to check for arguments.length > 0 in initialize().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/BaseTypes.js

    r1607 r1647  
    55/* OpenLayers.Class metaclass */ 
    66OpenLayers.Class = { 
    7   create: function() { 
    8     return function() { 
    9       this.initialize.apply(this, arguments); 
     7    isPrototype: function () {}, // magic anonymous value 
     8 
     9    create: function() { 
     10        return function() { 
     11            if (arguments && arguments[0] != OpenLayers.Class.isPrototype) 
     12                this.initialize.apply(this, arguments); 
     13        } 
     14    }, 
     15  
     16    inherit: function () { 
     17        var super = arguments[0]; 
     18        var proto = new super(OpenLayers.Class.isPrototype); 
     19        for (var i = 1; i < arguments.length; i++) { 
     20            if (typeof arguments[i] == "function") { 
     21                var mixin = arguments[i]; 
     22                arguments[i] = new mixin(OpenLayers.Class.isPrototype); 
     23            } 
     24            OpenLayers.Util.extend(proto, arguments[i]); 
     25        } 
     26        return proto; 
    1027    } 
    11   } 
    12 }; 
     28}; 
     29 
     30/* 
     31    OpenLayers.Class.inherit( OpenLayers.Layer.Grid, OpenLayers.Layer.HTTPRequest, { 
     32        some stuff 
     33    }); 
     34*/ 
    1335 
    1436/********************* 
  • trunk/openlayers/tests/list-tests.html

    r1424 r1647  
    11<ul id="testlist"> 
     2    <li>test_Class.html</li> 
    23    <li>test_Pixel.html</li> 
    34    <li>test_Size.html</li>