[OpenLayers-Commits] r3123 - sandbox/sderle/superclass/lib/OpenLayers
commits at openlayers.org
commits at openlayers.org
Thu May 3 12:11:09 EDT 2007
Author: sderle
Date: 2007-05-03 12:11:08 -0400 (Thu, 03 May 2007)
New Revision: 3123
Modified:
sandbox/sderle/superclass/lib/OpenLayers/BaseTypes.js
Log:
Implemented changes to Class.create() and Class.inherit() to simplify class declaration and superclass access. Breaks tests like wine glasses at a Jewish wedding.
Modified: sandbox/sderle/superclass/lib/OpenLayers/BaseTypes.js
===================================================================
--- sandbox/sderle/superclass/lib/OpenLayers/BaseTypes.js 2007-05-03 16:08:39 UTC (rev 3122)
+++ sandbox/sderle/superclass/lib/OpenLayers/BaseTypes.js 2007-05-03 16:11:08 UTC (rev 3123)
@@ -8,16 +8,26 @@
isPrototype: function () {}, // magic anonymous value
create: function() {
- return function() {
+ alert("wtf???");
+ var classObj = function() {
if (arguments && arguments[0] != OpenLayers.Class.isPrototype)
this.initialize.apply(this, arguments);
+ };
+ if (arguments) {
+ classObj.prototype = OpenLayers.Class.inherit.apply(this, arguments);
}
+ return classObj;
},
inherit: function () {
- var superClass = arguments[0];
- var proto = new superClass(OpenLayers.Class.isPrototype);
- for (var i = 1; i < arguments.length; i++) {
+ var proto = {}, start = 0;
+ if (typeof arguments[0] == "function") {
+ var superClass = arguments[0];
+ var proto = new superClass(OpenLayers.Class.isPrototype);
+ proto._super = superClass;
+ start = 1;
+ }
+ for (var i = start; i < arguments.length; i++) {
if (typeof arguments[i] == "function") {
var mixin = arguments[i];
arguments[i] = new mixin(OpenLayers.Class.isPrototype);
@@ -26,10 +36,6 @@
// This is a hack for IE see
// http://trac.openlayers.org/attachment/ticket/552
- //
- // The problem is that ie doesnt recognize toString as a property
- // so the util.extend() doesnt copy it over. we do it manually.
- //
// to be revisited in 3.0
//
if (arguments[i].hasOwnProperty('toString')) {
@@ -57,8 +63,7 @@
*
* This class represents a screen coordinate, in x and y coordinates
*/
-OpenLayers.Pixel = OpenLayers.Class.create();
-OpenLayers.Pixel.prototype = {
+OpenLayers.Pixel = OpenLayers.Class.create({
/** @type float */
x: 0.0,
@@ -137,7 +142,7 @@
/** @final @type str */
CLASS_NAME: "OpenLayers.Pixel"
-};
+});
/*********************
@@ -152,9 +157,7 @@
*
* This class represents a width and height pair
*/
-OpenLayers.Size = OpenLayers.Class.create();
-OpenLayers.Size.prototype = {
-
+OpenLayers.Size = OpenLayers.Class.create({
/** @type float */
w: 0.0,
@@ -209,7 +212,7 @@
/** @final @type String */
CLASS_NAME: "OpenLayers.Size"
-};
+});
/*********************
* *
More information about the Commits
mailing list