Convert all classes to use new-style class definitions. All tests pass.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@1651 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Schuyler Erle
2006-10-06 15:57:33 +00:00
parent 5280553306
commit 3be99e67e6
28 changed files with 93 additions and 133 deletions

View File

@@ -179,7 +179,7 @@ OpenLayers.Ajax.Request = OpenLayers.Class.create();
OpenLayers.Ajax.Request.Events = OpenLayers.Ajax.Request.Events =
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
OpenLayers.Ajax.Request.prototype = OpenLayers.Util.extend(new OpenLayers.Ajax.Base(), { OpenLayers.Ajax.Request.prototype = OpenLayers.Class.inherit( OpenLayers.Ajax.Base, {
initialize: function(url, options) { initialize: function(url, options) {
this.transport = OpenLayers.Ajax.getTransport(); this.transport = OpenLayers.Ajax.getTransport();
this.setOptions(options); this.setOptions(options);

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Control.ArgParser = OpenLayers.Class.create(); OpenLayers.Control.ArgParser = OpenLayers.Class.create();
OpenLayers.Control.ArgParser.prototype = OpenLayers.Control.ArgParser.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type OpenLayers.LonLat */ /** @type OpenLayers.LonLat */
center: null, center: null,

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create(); OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create();
OpenLayers.Control.KeyboardDefaults.prototype = OpenLayers.Control.KeyboardDefaults.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type int */ /** @type int */
slideFactor: 50, slideFactor: 50,

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create(); OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create();
OpenLayers.Control.LayerSwitcher.prototype = OpenLayers.Control.LayerSwitcher.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type String */ /** @type String */
activeColor: "darkblue", activeColor: "darkblue",

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Control.MouseDefaults = OpenLayers.Class.create(); OpenLayers.Control.MouseDefaults = OpenLayers.Class.create();
OpenLayers.Control.MouseDefaults.prototype = OpenLayers.Control.MouseDefaults.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type Boolean */ /** @type Boolean */
performedDrag: false, performedDrag: false,

View File

@@ -12,8 +12,8 @@ OpenLayers.Control.MouseToolbar = OpenLayers.Class.create();
OpenLayers.Control.MouseToolbar.X = 6; OpenLayers.Control.MouseToolbar.X = 6;
OpenLayers.Control.MouseToolbar.Y = 300; OpenLayers.Control.MouseToolbar.Y = 300;
OpenLayers.Control.MouseToolbar.prototype = OpenLayers.Control.MouseToolbar.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), OpenLayers.Class.inherit( OpenLayers.Control,
OpenLayers.Util.extend( new OpenLayers.Control.MouseDefaults(), { OpenLayers.Control.MouseDefaults, {
mode: null, mode: null,
@@ -306,5 +306,5 @@ OpenLayers.Control.MouseToolbar.prototype =
return false; return false;
} }
} }
})); });

View File

@@ -11,7 +11,7 @@ OpenLayers.Control.PanZoom = OpenLayers.Class.create();
OpenLayers.Control.PanZoom.X = 4; OpenLayers.Control.PanZoom.X = 4;
OpenLayers.Control.PanZoom.Y = 4; OpenLayers.Control.PanZoom.Y = 4;
OpenLayers.Control.PanZoom.prototype = OpenLayers.Control.PanZoom.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type int */ /** @type int */
slideFactor: 50, slideFactor: 50,

View File

@@ -11,7 +11,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class.create();
OpenLayers.Control.PanZoomBar.X = 4; OpenLayers.Control.PanZoomBar.X = 4;
OpenLayers.Control.PanZoomBar.Y = 4; OpenLayers.Control.PanZoomBar.Y = 4;
OpenLayers.Control.PanZoomBar.prototype = OpenLayers.Control.PanZoomBar.prototype =
OpenLayers.Util.extend( new OpenLayers.Control.PanZoom(), { OpenLayers.Class.inherit( OpenLayers.Control.PanZoom, {
/** @type Array(...) */ /** @type Array(...) */
buttons: null, buttons: null,

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Control.Permalink = OpenLayers.Class.create(); OpenLayers.Control.Permalink = OpenLayers.Class.create();
OpenLayers.Control.Permalink.prototype = OpenLayers.Control.Permalink.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type DOMElement */ /** @type DOMElement */
element: null, element: null,

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Control.Scale = OpenLayers.Class.create(); OpenLayers.Control.Scale = OpenLayers.Class.create();
OpenLayers.Control.Scale.prototype = OpenLayers.Control.Scale.prototype =
OpenLayers.Util.extend( new OpenLayers.Control(), { OpenLayers.Class.inherit( OpenLayers.Control, {
/** @type DOMElement */ /** @type DOMElement */
element: null, element: null,

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Feature.WFS = OpenLayers.Class.create(); OpenLayers.Feature.WFS = OpenLayers.Class.create();
OpenLayers.Feature.WFS.prototype = OpenLayers.Feature.WFS.prototype =
OpenLayers.Util.extend( new OpenLayers.Feature(), { OpenLayers.Class.inherit( OpenLayers.Feature, {
/** /**
* @constructor * @constructor
@@ -19,16 +19,11 @@ OpenLayers.Feature.WFS.prototype =
*/ */
initialize: function(layer, xmlNode) { initialize: function(layer, xmlNode) {
var newArguments = arguments; var newArguments = arguments;
if (arguments.length > 0) { var data = this.processXMLNode(xmlNode);
var data = this.processXMLNode(xmlNode); newArguments = new Array(layer, data.lonlat, data)
newArguments = new Array(layer, data.lonlat, data)
}
OpenLayers.Feature.prototype.initialize.apply(this, newArguments); OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
this.createMarker();
if (arguments.length > 0) { this.layer.addMarker(this.marker);
this.createMarker();
this.layer.addMarker(this.marker);
}
}, },
destroy: function() { destroy: function() {

View File

@@ -134,4 +134,4 @@ OpenLayers.Icon.prototype = {
/** @final @type String */ /** @final @type String */
CLASS_NAME: "OpenLayers.Icon" CLASS_NAME: "OpenLayers.Icon"
}; };

View File

@@ -104,24 +104,21 @@ OpenLayers.Layer.prototype = {
* @param {Object} options Hashtable of extra options to tag onto the layer * @param {Object} options Hashtable of extra options to tag onto the layer
*/ */
initialize: function(name, options) { initialize: function(name, options) {
if (arguments.length > 0) { //store a copy of the custom options for later cloning
this.options = OpenLayers.Util.extend(new Object(), options);
//add options to layer
OpenLayers.Util.extend(this, this.options);
//store a copy of the custom options for later cloning this.name = name;
this.options = OpenLayers.Util.extend(new Object(), options);
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
//add options to layer
OpenLayers.Util.extend(this, this.options); if (this.div == null) {
this.div = OpenLayers.Util.createDiv();
this.name = name; this.div.style.width = "100%";
this.div.style.height = "100%";
this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); this.div.id = this.id;
if (this.div == null) {
this.div = OpenLayers.Util.createDiv();
this.div.style.width = "100%";
this.div.style.height = "100%";
this.div.id = this.id;
}
} }
}, },

View File

@@ -10,7 +10,7 @@
*/ */
OpenLayers.Layer.EventPane = OpenLayers.Class.create(); OpenLayers.Layer.EventPane = OpenLayers.Class.create();
OpenLayers.Layer.EventPane.prototype = OpenLayers.Layer.EventPane.prototype =
OpenLayers.Util.extend(new OpenLayers.Layer, { OpenLayers.Class.inherit( OpenLayers.Layer, {
/** EventPaned layers are always base layers, by necessity. /** EventPaned layers are always base layers, by necessity.
* *
@@ -33,11 +33,8 @@ OpenLayers.Layer.EventPane.prototype =
*/ */
initialize: function(name, options) { initialize: function(name, options) {
OpenLayers.Layer.prototype.initialize.apply(this, arguments); OpenLayers.Layer.prototype.initialize.apply(this, arguments);
if (this.pane == null) {
if (arguments.length > 0) { this.pane = OpenLayers.Util.createDiv();
if (this.pane == null) {
this.pane = OpenLayers.Util.createDiv();
}
} }
}, },

View File

@@ -28,9 +28,7 @@ OpenLayers.Layer.HTTPRequest.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = arguments; var newArguments = arguments;
if (arguments.length > 0) { newArguments = [name, options];
newArguments = [name, options];
}
OpenLayers.Layer.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
this.url = url; this.url = url;
this.params = OpenLayers.Util.extend( new Object(), params); this.params = OpenLayers.Util.extend( new Object(), params);

View File

@@ -31,7 +31,7 @@ OpenLayers.Layer.KaMap.prototype =
newArguments.push(name, url, params, options); newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {}); this.params = (params ? params : {});
if (arguments.length > 0 && params) { if (params) {
OpenLayers.Util.applyDefaults( OpenLayers.Util.applyDefaults(
this.params, this.params,
this.DEFAULT_PARAMS this.DEFAULT_PARAMS

View File

@@ -24,11 +24,9 @@ OpenLayers.Layer.MapServer.prototype =
*/ */
initialize: function(name, url, params) { initialize: function(name, url, params) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params params = OpenLayers.Util.upperCaseObject(params);
params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params);
newArguments.push(name, url, params);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) { if (arguments.length > 0) {

View File

@@ -52,26 +52,20 @@ OpenLayers.Layer.WFS.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params params = OpenLayers.Util.upperCaseObject(params);
params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params, options);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params newArguments.push(name, options);
newArguments.push(name, options);
}
OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
if (arguments.length > 0) { OpenLayers.Util.applyDefaults(
OpenLayers.Util.applyDefaults( this.params,
this.params, OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) );
);
}
}, },

View File

@@ -31,19 +31,14 @@ OpenLayers.Layer.WMS.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params params = OpenLayers.Util.upperCaseObject(params);
params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params, options);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
OpenLayers.Util.applyDefaults(
if (arguments.length > 0) { this.params,
OpenLayers.Util.applyDefaults( OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
this.params, );
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
}
// unless explicitly set in options, if the layer is transparent, // unless explicitly set in options, if the layer is transparent,
// it will be an overlay // it will be an overlay

View File

@@ -35,20 +35,15 @@ OpenLayers.Layer.WMS.Untiled.prototype =
*/ */
initialize: function(name, url, params, options) { initialize: function(name, url, params, options) {
var newArguments = new Array(); var newArguments = new Array();
if (arguments.length > 0) { //uppercase params
//uppercase params params = OpenLayers.Util.upperCaseObject(params);
params = OpenLayers.Util.upperCaseObject(params); newArguments.push(name, url, params, options);
newArguments.push(name, url, params, options);
}
OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this, OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,
newArguments); newArguments);
OpenLayers.Util.applyDefaults(
if (arguments.length > 0) { this.params,
OpenLayers.Util.applyDefaults( OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
this.params, );
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
);
}
// unless explicitly set in options, if the layer is transparent, // unless explicitly set in options, if the layer is transparent,
// it will be an overlay // it will be an overlay

View File

@@ -32,7 +32,7 @@ OpenLayers.Layer.WorldWind.prototype =
newArguments.push(name, url, params, options); newArguments.push(name, url, params, options);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {}); this.params = (params ? params : {});
if (arguments.length > 0 && params) { if (params) {
OpenLayers.Util.applyDefaults( OpenLayers.Util.applyDefaults(
this.params, this.params,
this.DEFAULT_PARAMS this.DEFAULT_PARAMS

View File

@@ -28,20 +28,18 @@ OpenLayers.Marker.prototype = {
* @param {OpenLayers.LonLat lonlat * @param {OpenLayers.LonLat lonlat
*/ */
initialize: function(lonlat, icon) { initialize: function(lonlat, icon) {
if (arguments.length > 0) { this.lonlat = lonlat;
this.lonlat = lonlat;
var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); if (this.icon == null) {
if (this.icon == null) { this.icon = newIcon;
this.icon = newIcon; } else {
} else { this.icon.url = newIcon.url;
this.icon.url = newIcon.url; this.icon.size = newIcon.size;
this.icon.size = newIcon.size; this.icon.offset = newIcon.offset;
this.icon.offset = newIcon.offset; this.icon.calculateOffset = newIcon.calculateOffset;
this.icon.calculateOffset = newIcon.calculateOffset;
}
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
} }
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
}, },
destroy: function() { destroy: function() {

View File

@@ -8,7 +8,7 @@
* @requires OpenLayers/Marker.js * @requires OpenLayers/Marker.js
*/ */
OpenLayers.Marker.Box = OpenLayers.Class.create(); OpenLayers.Marker.Box = OpenLayers.Class.create();
OpenLayers.Marker.Box.prototype = OpenLayers.Util.extend( new OpenLayers.Marker(), { OpenLayers.Marker.Box.prototype = OpenLayers.Class.inherit( OpenLayers.Marker, {
/** @type OpenLayers.LonLat */ /** @type OpenLayers.LonLat */
bounds: null, bounds: null,
@@ -21,13 +21,11 @@ OpenLayers.Marker.Box.prototype = OpenLayers.Util.extend( new OpenLayers.Marker(
* @param {OpenLayers.LonLat lonlat * @param {OpenLayers.LonLat lonlat
*/ */
initialize: function(bounds, borderColor, borderWidth) { initialize: function(bounds, borderColor, borderWidth) {
if (arguments.length > 0) { this.bounds = bounds;
this.bounds = bounds; this.div = OpenLayers.Util.createDiv();
this.div = OpenLayers.Util.createDiv(); this.div.style.overflow = 'hidden';
this.div.style.overflow = 'hidden'; this.events = new OpenLayers.Events(this, this.div, null);
this.events = new OpenLayers.Events(this, this.div, null); this.setBorder(borderColor, borderWidth);
this.setBorder(borderColor, borderWidth);
}
}, },
setBorder: function (color, width) { setBorder: function (color, width) {

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Popup.Anchored = OpenLayers.Class.create(); OpenLayers.Popup.Anchored = OpenLayers.Class.create();
OpenLayers.Popup.Anchored.prototype = OpenLayers.Popup.Anchored.prototype =
OpenLayers.Util.extend( new OpenLayers.Popup(), { OpenLayers.Class.inherit( OpenLayers.Popup, {
/** "lr", "ll", "tr", "tl" - relative position of the popup. /** "lr", "ll", "tr", "tl" - relative position of the popup.
* @type String */ * @type String */

View File

@@ -13,7 +13,7 @@ OpenLayers.Popup.AnchoredBubble = OpenLayers.Class.create();
OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5; OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;
OpenLayers.Popup.AnchoredBubble.prototype = OpenLayers.Popup.AnchoredBubble.prototype =
OpenLayers.Util.extend( new OpenLayers.Popup.Anchored(), { OpenLayers.Class.inherit( OpenLayers.Popup.Anchored, {
/** @type DOMElement */ /** @type DOMElement */
contentDiv:null, contentDiv:null,

View File

@@ -46,16 +46,14 @@ OpenLayers.Tile.prototype = {
* @param {OpenLayers.Size} size * @param {OpenLayers.Size} size
*/ */
initialize: function(layer, position, bounds, url, size) { initialize: function(layer, position, bounds, url, size) {
if (arguments.length > 0) { this.layer = layer;
this.layer = layer; this.position = position;
this.position = position; this.bounds = bounds;
this.bounds = bounds; this.url = url;
this.url = url; this.size = size;
this.size = size;
//give the tile a unique id based on its BBOX. //give the tile a unique id based on its BBOX.
this.id = OpenLayers.Util.createUniqueID("Tile_"); this.id = OpenLayers.Util.createUniqueID("Tile_");
}
}, },
/** nullify references to prevent circular references and memory leaks /** nullify references to prevent circular references and memory leaks

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Tile.Image = OpenLayers.Class.create(); OpenLayers.Tile.Image = OpenLayers.Class.create();
OpenLayers.Tile.Image.prototype = OpenLayers.Tile.Image.prototype =
OpenLayers.Util.extend( new OpenLayers.Tile(), { OpenLayers.Class.inherit( OpenLayers.Tile, {
/** @type DOMElement img */ /** @type DOMElement img */
imgDiv: null, imgDiv: null,

View File

@@ -9,7 +9,7 @@
*/ */
OpenLayers.Tile.WFS = OpenLayers.Class.create(); OpenLayers.Tile.WFS = OpenLayers.Class.create();
OpenLayers.Tile.WFS.prototype = OpenLayers.Tile.WFS.prototype =
OpenLayers.Util.extend( new OpenLayers.Tile(), { OpenLayers.Class.inherit( OpenLayers.Tile, {
/** @type Array(OpenLayers.Feature)*/ /** @type Array(OpenLayers.Feature)*/
features: null, features: null,
@@ -28,11 +28,8 @@ OpenLayers.Tile.WFS.prototype =
*/ */
initialize: function(layer, position, bounds, urls, size) { initialize: function(layer, position, bounds, urls, size) {
var newArguments = arguments; var newArguments = arguments;
if (arguments.length > 0) { newArguments = [layer, position, bounds, null, size];
newArguments = [layer, position, bounds, null, size];
}
OpenLayers.Tile.prototype.initialize.apply(this, newArguments); OpenLayers.Tile.prototype.initialize.apply(this, newArguments);
this.urls = urls; this.urls = urls;
this.features = new Array(); this.features = new Array();
}, },