diff --git a/lib/OpenLayers/Ajax.js b/lib/OpenLayers/Ajax.js index 0cb5526b05..6759223827 100644 --- a/lib/OpenLayers/Ajax.js +++ b/lib/OpenLayers/Ajax.js @@ -179,7 +179,7 @@ OpenLayers.Ajax.Request = OpenLayers.Class.create(); OpenLayers.Ajax.Request.Events = ['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) { this.transport = OpenLayers.Ajax.getTransport(); this.setOptions(options); diff --git a/lib/OpenLayers/Control/ArgParser.js b/lib/OpenLayers/Control/ArgParser.js index c54b7afe80..52fd93de5e 100644 --- a/lib/OpenLayers/Control/ArgParser.js +++ b/lib/OpenLayers/Control/ArgParser.js @@ -9,7 +9,7 @@ */ OpenLayers.Control.ArgParser = OpenLayers.Class.create(); OpenLayers.Control.ArgParser.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), { + OpenLayers.Class.inherit( OpenLayers.Control, { /** @type OpenLayers.LonLat */ center: null, diff --git a/lib/OpenLayers/Control/KeyboardDefaults.js b/lib/OpenLayers/Control/KeyboardDefaults.js index 6032fcff5f..a494be1a20 100644 --- a/lib/OpenLayers/Control/KeyboardDefaults.js +++ b/lib/OpenLayers/Control/KeyboardDefaults.js @@ -9,7 +9,7 @@ */ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create(); OpenLayers.Control.KeyboardDefaults.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), { + OpenLayers.Class.inherit( OpenLayers.Control, { /** @type int */ slideFactor: 50, diff --git a/lib/OpenLayers/Control/LayerSwitcher.js b/lib/OpenLayers/Control/LayerSwitcher.js index 43337559e1..fb43e7a79f 100644 --- a/lib/OpenLayers/Control/LayerSwitcher.js +++ b/lib/OpenLayers/Control/LayerSwitcher.js @@ -9,7 +9,7 @@ */ OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create(); OpenLayers.Control.LayerSwitcher.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), { + OpenLayers.Class.inherit( OpenLayers.Control, { /** @type String */ activeColor: "darkblue", diff --git a/lib/OpenLayers/Control/MouseDefaults.js b/lib/OpenLayers/Control/MouseDefaults.js index 7acf97c488..0445f0525d 100644 --- a/lib/OpenLayers/Control/MouseDefaults.js +++ b/lib/OpenLayers/Control/MouseDefaults.js @@ -9,7 +9,7 @@ */ OpenLayers.Control.MouseDefaults = OpenLayers.Class.create(); OpenLayers.Control.MouseDefaults.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), { + OpenLayers.Class.inherit( OpenLayers.Control, { /** @type Boolean */ performedDrag: false, diff --git a/lib/OpenLayers/Control/MouseToolbar.js b/lib/OpenLayers/Control/MouseToolbar.js index 312f14277a..89d5f2fbc4 100644 --- a/lib/OpenLayers/Control/MouseToolbar.js +++ b/lib/OpenLayers/Control/MouseToolbar.js @@ -12,8 +12,8 @@ OpenLayers.Control.MouseToolbar = OpenLayers.Class.create(); OpenLayers.Control.MouseToolbar.X = 6; OpenLayers.Control.MouseToolbar.Y = 300; OpenLayers.Control.MouseToolbar.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), - OpenLayers.Util.extend( new OpenLayers.Control.MouseDefaults(), { + OpenLayers.Class.inherit( OpenLayers.Control, + OpenLayers.Control.MouseDefaults, { mode: null, @@ -306,5 +306,5 @@ OpenLayers.Control.MouseToolbar.prototype = return false; } } -})); +}); diff --git a/lib/OpenLayers/Control/PanZoom.js b/lib/OpenLayers/Control/PanZoom.js index 1241c95aa6..8b6803b7e6 100644 --- a/lib/OpenLayers/Control/PanZoom.js +++ b/lib/OpenLayers/Control/PanZoom.js @@ -11,7 +11,7 @@ OpenLayers.Control.PanZoom = OpenLayers.Class.create(); OpenLayers.Control.PanZoom.X = 4; OpenLayers.Control.PanZoom.Y = 4; OpenLayers.Control.PanZoom.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), { + OpenLayers.Class.inherit( OpenLayers.Control, { /** @type int */ slideFactor: 50, diff --git a/lib/OpenLayers/Control/PanZoomBar.js b/lib/OpenLayers/Control/PanZoomBar.js index 1795a93e9d..0be1ebccc7 100644 --- a/lib/OpenLayers/Control/PanZoomBar.js +++ b/lib/OpenLayers/Control/PanZoomBar.js @@ -11,7 +11,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class.create(); OpenLayers.Control.PanZoomBar.X = 4; OpenLayers.Control.PanZoomBar.Y = 4; OpenLayers.Control.PanZoomBar.prototype = - OpenLayers.Util.extend( new OpenLayers.Control.PanZoom(), { + OpenLayers.Class.inherit( OpenLayers.Control.PanZoom, { /** @type Array(...) */ buttons: null, diff --git a/lib/OpenLayers/Control/Permalink.js b/lib/OpenLayers/Control/Permalink.js index fe3b5f6f75..d3f45f5f78 100644 --- a/lib/OpenLayers/Control/Permalink.js +++ b/lib/OpenLayers/Control/Permalink.js @@ -9,7 +9,7 @@ */ OpenLayers.Control.Permalink = OpenLayers.Class.create(); OpenLayers.Control.Permalink.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), { + OpenLayers.Class.inherit( OpenLayers.Control, { /** @type DOMElement */ element: null, diff --git a/lib/OpenLayers/Control/Scale.js b/lib/OpenLayers/Control/Scale.js index 770e4735f4..75c274b3f1 100644 --- a/lib/OpenLayers/Control/Scale.js +++ b/lib/OpenLayers/Control/Scale.js @@ -9,7 +9,7 @@ */ OpenLayers.Control.Scale = OpenLayers.Class.create(); OpenLayers.Control.Scale.prototype = - OpenLayers.Util.extend( new OpenLayers.Control(), { + OpenLayers.Class.inherit( OpenLayers.Control, { /** @type DOMElement */ element: null, diff --git a/lib/OpenLayers/Feature/WFS.js b/lib/OpenLayers/Feature/WFS.js index 1821915104..2fccc4f1e0 100644 --- a/lib/OpenLayers/Feature/WFS.js +++ b/lib/OpenLayers/Feature/WFS.js @@ -9,7 +9,7 @@ */ OpenLayers.Feature.WFS = OpenLayers.Class.create(); OpenLayers.Feature.WFS.prototype = - OpenLayers.Util.extend( new OpenLayers.Feature(), { + OpenLayers.Class.inherit( OpenLayers.Feature, { /** * @constructor @@ -19,16 +19,11 @@ OpenLayers.Feature.WFS.prototype = */ initialize: function(layer, xmlNode) { var newArguments = arguments; - if (arguments.length > 0) { - var data = this.processXMLNode(xmlNode); - newArguments = new Array(layer, data.lonlat, data) - } + var data = this.processXMLNode(xmlNode); + newArguments = new Array(layer, data.lonlat, data) OpenLayers.Feature.prototype.initialize.apply(this, newArguments); - - if (arguments.length > 0) { - this.createMarker(); - this.layer.addMarker(this.marker); - } + this.createMarker(); + this.layer.addMarker(this.marker); }, destroy: function() { diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index c541ce173a..98a28ab3b1 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -134,4 +134,4 @@ OpenLayers.Icon.prototype = { /** @final @type String */ CLASS_NAME: "OpenLayers.Icon" -}; \ No newline at end of file +}; diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index e29d602ee2..dcf74c7aa0 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -104,24 +104,21 @@ OpenLayers.Layer.prototype = { * @param {Object} options Hashtable of extra options to tag onto the layer */ 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.options = OpenLayers.Util.extend(new Object(), options); - - //add options to layer - OpenLayers.Util.extend(this, this.options); - - this.name = name; - - this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); - - if (this.div == null) { - this.div = OpenLayers.Util.createDiv(); - this.div.style.width = "100%"; - this.div.style.height = "100%"; - this.div.id = this.id; - } + this.name = name; + + this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); + + if (this.div == null) { + this.div = OpenLayers.Util.createDiv(); + this.div.style.width = "100%"; + this.div.style.height = "100%"; + this.div.id = this.id; } }, diff --git a/lib/OpenLayers/Layer/EventPane.js b/lib/OpenLayers/Layer/EventPane.js index 90eecaa561..ece5317566 100644 --- a/lib/OpenLayers/Layer/EventPane.js +++ b/lib/OpenLayers/Layer/EventPane.js @@ -10,7 +10,7 @@ */ OpenLayers.Layer.EventPane = OpenLayers.Class.create(); OpenLayers.Layer.EventPane.prototype = - OpenLayers.Util.extend(new OpenLayers.Layer, { + OpenLayers.Class.inherit( OpenLayers.Layer, { /** EventPaned layers are always base layers, by necessity. * @@ -33,11 +33,8 @@ OpenLayers.Layer.EventPane.prototype = */ initialize: function(name, options) { OpenLayers.Layer.prototype.initialize.apply(this, arguments); - - if (arguments.length > 0) { - if (this.pane == null) { - this.pane = OpenLayers.Util.createDiv(); - } + if (this.pane == null) { + this.pane = OpenLayers.Util.createDiv(); } }, diff --git a/lib/OpenLayers/Layer/HTTPRequest.js b/lib/OpenLayers/Layer/HTTPRequest.js index a57054589a..e17d8a4029 100644 --- a/lib/OpenLayers/Layer/HTTPRequest.js +++ b/lib/OpenLayers/Layer/HTTPRequest.js @@ -28,9 +28,7 @@ OpenLayers.Layer.HTTPRequest.prototype = */ initialize: function(name, url, params, options) { var newArguments = arguments; - if (arguments.length > 0) { - newArguments = [name, options]; - } + newArguments = [name, options]; OpenLayers.Layer.prototype.initialize.apply(this, newArguments); this.url = url; this.params = OpenLayers.Util.extend( new Object(), params); diff --git a/lib/OpenLayers/Layer/KaMap.js b/lib/OpenLayers/Layer/KaMap.js index 091a7f9533..d8966a30fe 100644 --- a/lib/OpenLayers/Layer/KaMap.js +++ b/lib/OpenLayers/Layer/KaMap.js @@ -31,7 +31,7 @@ OpenLayers.Layer.KaMap.prototype = newArguments.push(name, url, params, options); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); this.params = (params ? params : {}); - if (arguments.length > 0 && params) { + if (params) { OpenLayers.Util.applyDefaults( this.params, this.DEFAULT_PARAMS diff --git a/lib/OpenLayers/Layer/MapServer.js b/lib/OpenLayers/Layer/MapServer.js index c86ffd8eb0..670249c1db 100644 --- a/lib/OpenLayers/Layer/MapServer.js +++ b/lib/OpenLayers/Layer/MapServer.js @@ -24,11 +24,9 @@ OpenLayers.Layer.MapServer.prototype = */ initialize: function(name, url, params) { var newArguments = new Array(); - if (arguments.length > 0) { - //uppercase params - params = OpenLayers.Util.upperCaseObject(params); - newArguments.push(name, url, params); - } + //uppercase params + params = OpenLayers.Util.upperCaseObject(params); + newArguments.push(name, url, params); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); if (arguments.length > 0) { diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index 9bdd210940..c5aa8fb691 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -52,26 +52,20 @@ OpenLayers.Layer.WFS.prototype = */ initialize: function(name, url, params, options) { var newArguments = new Array(); - if (arguments.length > 0) { - //uppercase params - params = OpenLayers.Util.upperCaseObject(params); - newArguments.push(name, url, params, options); - } + //uppercase params + params = OpenLayers.Util.upperCaseObject(params); + newArguments.push(name, url, params, options); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); var newArguments = new Array(); - if (arguments.length > 0) { - //uppercase params - newArguments.push(name, options); - } + //uppercase params + newArguments.push(name, options); OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments); - if (arguments.length > 0) { - OpenLayers.Util.applyDefaults( - this.params, - OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) - ); - } + OpenLayers.Util.applyDefaults( + this.params, + OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) + ); }, diff --git a/lib/OpenLayers/Layer/WMS.js b/lib/OpenLayers/Layer/WMS.js index b37910ed73..1c6f73b73b 100644 --- a/lib/OpenLayers/Layer/WMS.js +++ b/lib/OpenLayers/Layer/WMS.js @@ -31,19 +31,14 @@ OpenLayers.Layer.WMS.prototype = */ initialize: function(name, url, params, options) { var newArguments = new Array(); - if (arguments.length > 0) { - //uppercase params - params = OpenLayers.Util.upperCaseObject(params); - newArguments.push(name, url, params, options); - } + //uppercase params + params = OpenLayers.Util.upperCaseObject(params); + newArguments.push(name, url, params, options); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); - - if (arguments.length > 0) { - OpenLayers.Util.applyDefaults( - this.params, - OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) - ); - } + OpenLayers.Util.applyDefaults( + this.params, + OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) + ); // unless explicitly set in options, if the layer is transparent, // it will be an overlay diff --git a/lib/OpenLayers/Layer/WMS/Untiled.js b/lib/OpenLayers/Layer/WMS/Untiled.js index a706dba20a..01d17d0c98 100644 --- a/lib/OpenLayers/Layer/WMS/Untiled.js +++ b/lib/OpenLayers/Layer/WMS/Untiled.js @@ -35,20 +35,15 @@ OpenLayers.Layer.WMS.Untiled.prototype = */ initialize: function(name, url, params, options) { var newArguments = new Array(); - if (arguments.length > 0) { - //uppercase params - params = OpenLayers.Util.upperCaseObject(params); - newArguments.push(name, url, params, options); - } + //uppercase params + params = OpenLayers.Util.upperCaseObject(params); + newArguments.push(name, url, params, options); OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this, newArguments); - - if (arguments.length > 0) { - OpenLayers.Util.applyDefaults( - this.params, - OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) - ); - } + OpenLayers.Util.applyDefaults( + this.params, + OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS) + ); // unless explicitly set in options, if the layer is transparent, // it will be an overlay diff --git a/lib/OpenLayers/Layer/WorldWind.js b/lib/OpenLayers/Layer/WorldWind.js index dd7304744a..c188a39104 100644 --- a/lib/OpenLayers/Layer/WorldWind.js +++ b/lib/OpenLayers/Layer/WorldWind.js @@ -32,7 +32,7 @@ OpenLayers.Layer.WorldWind.prototype = newArguments.push(name, url, params, options); OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); this.params = (params ? params : {}); - if (arguments.length > 0 && params) { + if (params) { OpenLayers.Util.applyDefaults( this.params, this.DEFAULT_PARAMS diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 70a59d907a..f9126aaceb 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -28,20 +28,18 @@ OpenLayers.Marker.prototype = { * @param {OpenLayers.LonLat lonlat */ initialize: function(lonlat, icon) { - if (arguments.length > 0) { - this.lonlat = lonlat; - - var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); - if (this.icon == null) { - this.icon = newIcon; - } else { - this.icon.url = newIcon.url; - this.icon.size = newIcon.size; - this.icon.offset = newIcon.offset; - this.icon.calculateOffset = newIcon.calculateOffset; - } - this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); + this.lonlat = lonlat; + + var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon(); + if (this.icon == null) { + this.icon = newIcon; + } else { + this.icon.url = newIcon.url; + this.icon.size = newIcon.size; + this.icon.offset = newIcon.offset; + this.icon.calculateOffset = newIcon.calculateOffset; } + this.events = new OpenLayers.Events(this, this.icon.imageDiv, null); }, destroy: function() { diff --git a/lib/OpenLayers/Marker/Box.js b/lib/OpenLayers/Marker/Box.js index 6bf8552ed5..31b850bb14 100644 --- a/lib/OpenLayers/Marker/Box.js +++ b/lib/OpenLayers/Marker/Box.js @@ -8,7 +8,7 @@ * @requires OpenLayers/Marker.js */ 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 */ bounds: null, @@ -21,13 +21,11 @@ OpenLayers.Marker.Box.prototype = OpenLayers.Util.extend( new OpenLayers.Marker( * @param {OpenLayers.LonLat lonlat */ initialize: function(bounds, borderColor, borderWidth) { - if (arguments.length > 0) { - this.bounds = bounds; - this.div = OpenLayers.Util.createDiv(); - this.div.style.overflow = 'hidden'; - this.events = new OpenLayers.Events(this, this.div, null); - this.setBorder(borderColor, borderWidth); - } + this.bounds = bounds; + this.div = OpenLayers.Util.createDiv(); + this.div.style.overflow = 'hidden'; + this.events = new OpenLayers.Events(this, this.div, null); + this.setBorder(borderColor, borderWidth); }, setBorder: function (color, width) { diff --git a/lib/OpenLayers/Popup/Anchored.js b/lib/OpenLayers/Popup/Anchored.js index 490f2ffce0..f78c47fa12 100644 --- a/lib/OpenLayers/Popup/Anchored.js +++ b/lib/OpenLayers/Popup/Anchored.js @@ -9,7 +9,7 @@ */ OpenLayers.Popup.Anchored = OpenLayers.Class.create(); OpenLayers.Popup.Anchored.prototype = - OpenLayers.Util.extend( new OpenLayers.Popup(), { + OpenLayers.Class.inherit( OpenLayers.Popup, { /** "lr", "ll", "tr", "tl" - relative position of the popup. * @type String */ diff --git a/lib/OpenLayers/Popup/AnchoredBubble.js b/lib/OpenLayers/Popup/AnchoredBubble.js index 8d7e2628c8..199dc8aecc 100644 --- a/lib/OpenLayers/Popup/AnchoredBubble.js +++ b/lib/OpenLayers/Popup/AnchoredBubble.js @@ -13,7 +13,7 @@ OpenLayers.Popup.AnchoredBubble = OpenLayers.Class.create(); OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5; OpenLayers.Popup.AnchoredBubble.prototype = - OpenLayers.Util.extend( new OpenLayers.Popup.Anchored(), { + OpenLayers.Class.inherit( OpenLayers.Popup.Anchored, { /** @type DOMElement */ contentDiv:null, diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index eb9fc46eb9..12c701ac50 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -46,16 +46,14 @@ OpenLayers.Tile.prototype = { * @param {OpenLayers.Size} size */ initialize: function(layer, position, bounds, url, size) { - if (arguments.length > 0) { - this.layer = layer; - this.position = position; - this.bounds = bounds; - this.url = url; - this.size = size; + this.layer = layer; + this.position = position; + this.bounds = bounds; + this.url = url; + this.size = size; - //give the tile a unique id based on its BBOX. - this.id = OpenLayers.Util.createUniqueID("Tile_"); - } + //give the tile a unique id based on its BBOX. + this.id = OpenLayers.Util.createUniqueID("Tile_"); }, /** nullify references to prevent circular references and memory leaks diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index 46b781f8d6..4fdd79058b 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -9,7 +9,7 @@ */ OpenLayers.Tile.Image = OpenLayers.Class.create(); OpenLayers.Tile.Image.prototype = - OpenLayers.Util.extend( new OpenLayers.Tile(), { + OpenLayers.Class.inherit( OpenLayers.Tile, { /** @type DOMElement img */ imgDiv: null, diff --git a/lib/OpenLayers/Tile/WFS.js b/lib/OpenLayers/Tile/WFS.js index 46140bce22..2dad373811 100644 --- a/lib/OpenLayers/Tile/WFS.js +++ b/lib/OpenLayers/Tile/WFS.js @@ -9,7 +9,7 @@ */ OpenLayers.Tile.WFS = OpenLayers.Class.create(); OpenLayers.Tile.WFS.prototype = - OpenLayers.Util.extend( new OpenLayers.Tile(), { + OpenLayers.Class.inherit( OpenLayers.Tile, { /** @type Array(OpenLayers.Feature)*/ features: null, @@ -28,11 +28,8 @@ OpenLayers.Tile.WFS.prototype = */ initialize: function(layer, position, bounds, urls, size) { 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); - this.urls = urls; this.features = new Array(); },