Deprecating all prototype extensions. This puts all OpenLayers functionality in the OpenLayers namespace. If you are using any of the Function, String, or Number prototype extensions, start using the functional equivalents in the OpenLayers namespace - the prototype extensions will be gone in 3.0 (closes #712).
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4302 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -53,14 +53,14 @@ OpenLayers.nullHandler = function(request) {
|
||||
OpenLayers.loadURL = function(uri, params, caller,
|
||||
onComplete, onFailure) {
|
||||
|
||||
if (OpenLayers.ProxyHost && uri.startsWith("http")) {
|
||||
if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(uri, "http")) {
|
||||
uri = OpenLayers.ProxyHost + escape(uri);
|
||||
}
|
||||
|
||||
var success = (onComplete) ? onComplete.bind(caller)
|
||||
var success = (onComplete) ? OpenLayers.Function.bind(onComplete, caller)
|
||||
: OpenLayers.nullHandler;
|
||||
|
||||
var failure = (onFailure) ? onFailure.bind(caller)
|
||||
var failure = (onFailure) ? OpenLayers.Function.bind(onFailure, caller)
|
||||
: OpenLayers.nullHandler;
|
||||
|
||||
// from prototype.js
|
||||
@@ -307,11 +307,11 @@ OpenLayers.Ajax.Request = OpenLayers.Class(OpenLayers.Ajax.Base, {
|
||||
|
||||
if (this.options.asynchronous) {
|
||||
this.transport.onreadystatechange =
|
||||
this.onStateChange.bind(this);
|
||||
OpenLayers.Function.bind(this.onStateChange, this);
|
||||
|
||||
setTimeout((function() {
|
||||
this.respondToReadyState(1)
|
||||
}).bind(this), 10);
|
||||
setTimeout(OpenLayers.Function.bind(
|
||||
(function() {this.respondToReadyState(1)}),this), 10
|
||||
);
|
||||
}
|
||||
|
||||
this.setRequestHeaders();
|
||||
|
||||
+185
-54
@@ -4,7 +4,7 @@
|
||||
|
||||
/**
|
||||
* Header: OpenLayers Base Types
|
||||
* Modifications to standard JavaScript types are described here.
|
||||
* OpenLayers custom string, number and function functions are described here.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
@@ -13,10 +13,79 @@
|
||||
* *
|
||||
*********************/
|
||||
|
||||
OpenLayers.String = {
|
||||
/**
|
||||
* APIMethod: OpenLayers.String.startsWith
|
||||
* Whether or not a string starts with another string.
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The string to test.
|
||||
* sub - {Sring} The substring to look for.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The first string starts with the second.
|
||||
*/
|
||||
startsWith: function(str, sub) {
|
||||
return (str.indexOf(sub) == 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: OpenLayers.String.contains
|
||||
* Whether or not a string contains another string.
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The string to test.
|
||||
* sub - {String} The substring to look for.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The first string contains the second.
|
||||
*/
|
||||
contains: function(str, sub) {
|
||||
return (str.indexOf(sub) != -1);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: OpenLayers.String.trim
|
||||
* Removes leading and trailing whitespace characters from a string.
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The (potentially) space padded string. This string is not
|
||||
* modified.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A trimmed version of the string - all leading and
|
||||
* trailing spaces removed.
|
||||
*/
|
||||
trim: function(str) {
|
||||
return str.replace(/^\s*(.*?)\s*$/, "$1");
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: OpenLayers.String.camelize
|
||||
* Camel-case a hyphenated string.
|
||||
* Ex. "chicken-head" becomes "chickenHead", and
|
||||
* "-chicken-head" becomes "ChickenHead".
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The string to be camelized. The original is not modified.
|
||||
*
|
||||
* Returns:
|
||||
* {String} The string, camelized
|
||||
*/
|
||||
camelize: function(str) {
|
||||
var oStringList = str.split('-');
|
||||
var camelizedString = oStringList[0];
|
||||
for (var i = 1; i < oStringList.length; i++) {
|
||||
var s = oStringList[i];
|
||||
camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
|
||||
}
|
||||
return camelizedString;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* APIMethod: String.startsWith
|
||||
* Whether or not a string starts with another string.
|
||||
* Deprecated. Whether or not a string starts with another string.
|
||||
*
|
||||
* Parameters:
|
||||
* sStart - {Sring} The string we're testing for.
|
||||
@@ -25,12 +94,16 @@
|
||||
* {Boolean} Whether or not this string starts with the string passed in.
|
||||
*/
|
||||
String.prototype.startsWith = function(sStart) {
|
||||
return (this.substr(0,sStart.length) == sStart);
|
||||
OpenLayers.Console.warn(
|
||||
"This method has been deprecated and will be removed in 3.0. " +
|
||||
"Please use OpenLayers.String.startsWith instead"
|
||||
);
|
||||
return OpenLayers.String.startsWith(this, sStart);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIMethod: String.contains
|
||||
* Whether or not a string contains another string.
|
||||
* Deprecated. Whether or not a string contains another string.
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The string that we're testing for.
|
||||
@@ -39,24 +112,32 @@ String.prototype.startsWith = function(sStart) {
|
||||
* {Boolean} Whether or not this string contains with the string passed in.
|
||||
*/
|
||||
String.prototype.contains = function(str) {
|
||||
return (this.indexOf(str) != -1);
|
||||
OpenLayers.Console.warn(
|
||||
"This method has been deprecated and will be removed in 3.0. " +
|
||||
"Please use OpenLayers.String.contains instead"
|
||||
);
|
||||
return OpenLayers.String.contains(this, str);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIMethod: String.trim
|
||||
* Removes leading and trailing whitespace characters from a string.
|
||||
* Deprecated. Removes leading and trailing whitespace characters from a string.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A trimmed version of the string - all leading and
|
||||
* trailing spaces removed
|
||||
*/
|
||||
String.prototype.trim = function() {
|
||||
return this.replace(/^\s+/, '').replace(/\s+$/, '');
|
||||
OpenLayers.Console.warn(
|
||||
"This method has been deprecated and will be removed in 3.0. " +
|
||||
"Please use OpenLayers.String.trim instead"
|
||||
);
|
||||
return OpenLayers.String.trim(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIMethod: camelize
|
||||
* Camel-case a hyphenated string.
|
||||
* Deprecated. Camel-case a hyphenated string.
|
||||
* Ex. "chicken-head" becomes "chickenHead", and
|
||||
* "-chicken-head" becomes "ChickenHead".
|
||||
*
|
||||
@@ -64,13 +145,11 @@ String.prototype.trim = function() {
|
||||
* {String} The string, camelized
|
||||
*/
|
||||
String.prototype.camelize = function() {
|
||||
var oStringList = this.split('-');
|
||||
var camelizedString = oStringList[0];
|
||||
for (var i = 1; i < oStringList.length; i++) {
|
||||
var s = oStringList[i];
|
||||
camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
|
||||
}
|
||||
return camelizedString;
|
||||
OpenLayers.Console.warn(
|
||||
"This method has been deprecated and will be removed in 3.0. " +
|
||||
"Please use OpenLayers.String.camelize instead"
|
||||
);
|
||||
return OpenLayers.String.camelize(this);
|
||||
};
|
||||
|
||||
|
||||
@@ -80,10 +159,34 @@ String.prototype.camelize = function() {
|
||||
* *
|
||||
*********************/
|
||||
|
||||
OpenLayers.Number = {
|
||||
/**
|
||||
* APIMethod: OpenLayers.Number.limitSigDigs
|
||||
* Limit the number of significant digits on an integer.
|
||||
*
|
||||
* Parameters:
|
||||
* num - {Integer}
|
||||
* sig - {Integer}
|
||||
*
|
||||
* Returns:
|
||||
* {Integer} The number, rounded to the specified number of significant
|
||||
* digits.
|
||||
*/
|
||||
limitSigDigs: function(num, sig) {
|
||||
var fig;
|
||||
if(sig > 0) {
|
||||
fig = parseFloat(num.toPrecision(sig));
|
||||
} else {
|
||||
fig = 0;
|
||||
}
|
||||
return fig;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* APIMethod: Number.limitSigDigs
|
||||
* Limit the number of significant digits on an integer. Does *not* work
|
||||
* with floats!
|
||||
* Deprecated. Limit the number of significant digits on an integer. Does *not*
|
||||
* work with floats!
|
||||
*
|
||||
* Parameters:
|
||||
* sig - {Integer}
|
||||
@@ -93,17 +196,11 @@ String.prototype.camelize = function() {
|
||||
* If null, 0, or negative value passed in, returns 0
|
||||
*/
|
||||
Number.prototype.limitSigDigs = function(sig) {
|
||||
var numStr = (sig > 0) ? this.toString() : "0";
|
||||
if (numStr.contains(".")) {
|
||||
var msg = "limitSigDig can not be called on a floating point number";
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
}
|
||||
if ( (sig > 0) && (sig < numStr.length) ) {
|
||||
var exp = numStr.length - sig;
|
||||
numStr = Math.round( this / Math.pow(10, exp)) * Math.pow(10, exp);
|
||||
}
|
||||
return parseInt(numStr);
|
||||
OpenLayers.Console.warn(
|
||||
"This method has been deprecated and will be removed in 3.0. " +
|
||||
"Please use OpenLayers.Number.limitSigDigs instead"
|
||||
);
|
||||
return OpenLayers.Number.limitSigDigs(this, sig);
|
||||
};
|
||||
|
||||
|
||||
@@ -113,9 +210,54 @@ Number.prototype.limitSigDigs = function(sig) {
|
||||
* *
|
||||
*********************/
|
||||
|
||||
OpenLayers.Function = {
|
||||
/**
|
||||
* APIMethod: OpenLayers.Function.bind
|
||||
* Bind a function to an object. Method to easily create closures with
|
||||
* 'this' altered.
|
||||
*
|
||||
* Parameters:
|
||||
* func - {Function} Input function.
|
||||
* object - {Object} The object to bind to the input function (as this).
|
||||
*
|
||||
* Returns:
|
||||
* {Function} A closure with 'this' set to the passed in object.
|
||||
*/
|
||||
bind: function(func, object) {
|
||||
// create a reference to all arguments past the second one
|
||||
var args = Array.prototype.slice.apply(arguments, [2]);
|
||||
return function() {
|
||||
// Push on any additional arguments from the actual function call.
|
||||
// These will come after those sent to the bind call.
|
||||
var newArgs = args.concat(
|
||||
Array.prototype.slice.apply(arguments, [0])
|
||||
);
|
||||
return func.apply(object, newArgs);
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: OpenLayers.Function.bindAsEventListener
|
||||
* Bind a function to an object, and configure it to receive the event
|
||||
* object as first parameter when called.
|
||||
*
|
||||
* Parameters:
|
||||
* func - {Function} Input function to serve as an event listener.
|
||||
* object - {Object} A reference to this.
|
||||
*
|
||||
* Returns:
|
||||
* {Function}
|
||||
*/
|
||||
bindAsEventListener: function(func, object) {
|
||||
return function(event) {
|
||||
return func.call(object, event || window.event);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* APIMethod: Function.bind
|
||||
* Bind a function to an object.
|
||||
* Deprecated. Bind a function to an object.
|
||||
* Method to easily create closures with 'this' altered.
|
||||
*
|
||||
* Parameters:
|
||||
@@ -126,31 +268,19 @@ Number.prototype.limitSigDigs = function(sig) {
|
||||
* argument.
|
||||
*/
|
||||
Function.prototype.bind = function() {
|
||||
var __method = this;
|
||||
var args = [];
|
||||
var object = arguments[0];
|
||||
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
|
||||
return function(moreargs) {
|
||||
var i;
|
||||
var newArgs = [];
|
||||
for (i = 0; i < args.length; i++) {
|
||||
newArgs.push(args[i]);
|
||||
}
|
||||
for (i = 0; i < arguments.length; i++) {
|
||||
newArgs.push(arguments[i]);
|
||||
}
|
||||
return __method.apply(object, newArgs);
|
||||
};
|
||||
OpenLayers.Console.warn(
|
||||
"This method has been deprecated and will be removed in 3.0. " +
|
||||
"Please use OpenLayers.Function.bind instead"
|
||||
);
|
||||
// new function takes the same arguments with this function up front
|
||||
Array.prototype.unshift.apply(arguments, [this]);
|
||||
return OpenLayers.Function.bind.apply(null, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIMethod: Function.bindAsEventListener
|
||||
* Bind a function to an object, and configure it to receive the event object
|
||||
* as first parameter when called.
|
||||
* Deprecated. Bind a function to an object, and configure it to receive the
|
||||
* event object as first parameter when called.
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object} A reference to this.
|
||||
@@ -159,8 +289,9 @@ Function.prototype.bind = function() {
|
||||
* {Function}
|
||||
*/
|
||||
Function.prototype.bindAsEventListener = function(object) {
|
||||
var __method = this;
|
||||
return function(event) {
|
||||
return __method.call(object, event || window.event);
|
||||
};
|
||||
OpenLayers.Console.warn(
|
||||
"This method has been deprecated and will be removed in 3.0. " +
|
||||
"Please use OpenLayers.Function.bindAsEventListener instead"
|
||||
);
|
||||
return OpenLayers.Function.bindAsEventListener(this, object);
|
||||
};
|
||||
|
||||
@@ -135,7 +135,7 @@ OpenLayers.Element = {
|
||||
*/
|
||||
getStyle: function(element, style) {
|
||||
element = OpenLayers.Util.getElement(element);
|
||||
var value = element.style[style.camelize()];
|
||||
var value = element.style[OpenLayers.String.camelize(style)];
|
||||
if (!value) {
|
||||
if (document.defaultView &&
|
||||
document.defaultView.getComputedStyle) {
|
||||
@@ -143,7 +143,7 @@ OpenLayers.Element = {
|
||||
var css = document.defaultView.getComputedStyle(element, null);
|
||||
value = css ? css.getPropertyValue(style) : null;
|
||||
} else if (element.currentStyle) {
|
||||
value = element.currentStyle[style.camelize()];
|
||||
value = element.currentStyle[OpenLayers.String.camelize(style)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,9 @@ OpenLayers.Control.LayerSwitcher =
|
||||
'layerSwitcher': this
|
||||
}
|
||||
OpenLayers.Event.observe(inputElem, "mouseup",
|
||||
this.onInputClick.bindAsEventListener(context));
|
||||
OpenLayers.Function.bindAsEventListener(this.onInputClick,
|
||||
context)
|
||||
);
|
||||
|
||||
// create span
|
||||
var labelSpan = document.createElement("span");
|
||||
@@ -290,7 +292,9 @@ OpenLayers.Control.LayerSwitcher =
|
||||
labelSpan.style.verticalAlign = (baseLayer) ? "bottom"
|
||||
: "baseline";
|
||||
OpenLayers.Event.observe(labelSpan, "click",
|
||||
this.onInputClick.bindAsEventListener(context));
|
||||
OpenLayers.Function.bindAsEventListener(this.onInputClick,
|
||||
context)
|
||||
);
|
||||
// create line break
|
||||
var br = document.createElement("br");
|
||||
|
||||
@@ -463,11 +467,11 @@ OpenLayers.Control.LayerSwitcher =
|
||||
this.div.style.backgroundColor = "transparent";
|
||||
|
||||
OpenLayers.Event.observe(this.div, "mouseup",
|
||||
this.mouseUp.bindAsEventListener(this));
|
||||
OpenLayers.Function.bindAsEventListener(this.mouseUp, this));
|
||||
OpenLayers.Event.observe(this.div, "click",
|
||||
this.ignoreEvent);
|
||||
OpenLayers.Event.observe(this.div, "mousedown",
|
||||
this.mouseDown.bindAsEventListener(this));
|
||||
OpenLayers.Function.bindAsEventListener(this.mouseDown, this));
|
||||
OpenLayers.Event.observe(this.div, "dblclick", this.ignoreEvent);
|
||||
|
||||
|
||||
@@ -496,7 +500,7 @@ OpenLayers.Control.LayerSwitcher =
|
||||
this.baseLayersDiv = document.createElement("div");
|
||||
this.baseLayersDiv.style.paddingLeft = "10px";
|
||||
/*OpenLayers.Event.observe(this.baseLayersDiv, "click",
|
||||
this.onLayerClick.bindAsEventListener(this));
|
||||
OpenLayers.Function.bindAsEventListener(this.onLayerClick, this));
|
||||
*/
|
||||
|
||||
|
||||
@@ -545,9 +549,9 @@ OpenLayers.Control.LayerSwitcher =
|
||||
this.maximizeDiv.style.right = "0px";
|
||||
this.maximizeDiv.style.left = "";
|
||||
this.maximizeDiv.style.display = "none";
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
"click",
|
||||
this.maximizeControl.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(this.maximizeDiv, "click",
|
||||
OpenLayers.Function.bindAsEventListener(this.maximizeControl, this)
|
||||
);
|
||||
|
||||
this.div.appendChild(this.maximizeDiv);
|
||||
|
||||
@@ -564,9 +568,9 @@ OpenLayers.Control.LayerSwitcher =
|
||||
this.minimizeDiv.style.right = "0px";
|
||||
this.minimizeDiv.style.left = "";
|
||||
this.minimizeDiv.style.display = "none";
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
"click",
|
||||
this.minimizeControl.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(this.minimizeDiv, "click",
|
||||
OpenLayers.Function.bindAsEventListener(this.minimizeControl, this)
|
||||
);
|
||||
|
||||
this.div.appendChild(this.minimizeDiv);
|
||||
},
|
||||
|
||||
@@ -84,7 +84,9 @@ OpenLayers.Control.MouseDefaults = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
registerWheelEvents: function() {
|
||||
|
||||
this.wheelObserver = this.onWheelEvent.bindAsEventListener(this);
|
||||
this.wheelObserver = OpenLayers.Function.bindAsEventListener(
|
||||
this.onWheelEvent, this
|
||||
);
|
||||
|
||||
//register mousewheel events specifically on the window and document
|
||||
OpenLayers.Event.observe(window, "DOMMouseScroll", this.wheelObserver);
|
||||
|
||||
@@ -218,9 +218,10 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
'absolute');
|
||||
this.maximizeDiv.style.display = 'none';
|
||||
this.maximizeDiv.className = this.displayClass + 'MaximizeButton';
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
'click',
|
||||
this.maximizeControl.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(this.maximizeDiv, 'click',
|
||||
OpenLayers.Function.bindAsEventListener(this.maximizeControl,
|
||||
this)
|
||||
);
|
||||
this.div.appendChild(this.maximizeDiv);
|
||||
|
||||
// minimize button div
|
||||
@@ -233,9 +234,10 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
'absolute');
|
||||
this.minimizeDiv.style.display = 'none';
|
||||
this.minimizeDiv.className = this.displayClass + 'MinimizeButton';
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
'click',
|
||||
this.minimizeControl.bindAsEventListener(this));
|
||||
OpenLayers.Event.observe(this.minimizeDiv, 'click',
|
||||
OpenLayers.Function.bindAsEventListener(this.minimizeControl,
|
||||
this)
|
||||
);
|
||||
this.div.appendChild(this.minimizeDiv);
|
||||
|
||||
var eventsToStop = ['dblclick','mousedown'];
|
||||
|
||||
@@ -112,11 +112,11 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.div.appendChild(btn);
|
||||
|
||||
OpenLayers.Event.observe(btn, "mousedown",
|
||||
this.buttonDown.bindAsEventListener(btn));
|
||||
OpenLayers.Function.bindAsEventListener(this.buttonDown, btn));
|
||||
OpenLayers.Event.observe(btn, "dblclick",
|
||||
this.doubleClick.bindAsEventListener(btn));
|
||||
OpenLayers.Function.bindAsEventListener(this.doubleClick, btn));
|
||||
OpenLayers.Event.observe(btn, "click",
|
||||
this.doubleClick.bindAsEventListener(btn));
|
||||
OpenLayers.Function.bindAsEventListener(this.doubleClick, btn));
|
||||
btn.action = id;
|
||||
btn.map = this.map;
|
||||
btn.slideFactor = this.slideFactor;
|
||||
|
||||
@@ -170,9 +170,9 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
var textNode = document.createTextNode(" ");
|
||||
controls[i].panel_div = element;
|
||||
OpenLayers.Event.observe(controls[i].panel_div, "click",
|
||||
this.onClick.bind(this, controls[i]));
|
||||
OpenLayers.Function.bind(this.onClick, this, controls[i]));
|
||||
OpenLayers.Event.observe(controls[i].panel_div, "mousedown",
|
||||
OpenLayers.Event.stop.bindAsEventListener());
|
||||
OpenLayers.Function.bindAsEventListener(OpenLayers.Event.stop));
|
||||
}
|
||||
|
||||
if (this.map) { // map.addControl() has already been called on the panel
|
||||
|
||||
@@ -404,7 +404,9 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
|
||||
// keep a bound copy of handleBrowserEvent() so that we can
|
||||
// pass the same function to both Event.observe() and .stopObserving()
|
||||
this.eventHandler = this.handleBrowserEvent.bindAsEventListener(this);
|
||||
this.eventHandler = OpenLayers.Function.bindAsEventListener(
|
||||
this.handleBrowserEvent, this
|
||||
);
|
||||
|
||||
// if eventTypes is specified, create a listeners list for each
|
||||
// custom application event.
|
||||
|
||||
@@ -208,7 +208,7 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {
|
||||
* @private
|
||||
*/
|
||||
'point': function(str) {
|
||||
var coords = str.trim().split(this.regExes.spaces);
|
||||
var coords = OpenLayers.String.trim(str).split(this.regExes.spaces);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(coords[0], coords[1])
|
||||
);
|
||||
@@ -221,7 +221,7 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {
|
||||
* @private
|
||||
*/
|
||||
'multipoint': function(str) {
|
||||
var points = str.trim().split(',');
|
||||
var points = OpenLayers.String.trim(str).split(',');
|
||||
var components = [];
|
||||
for(var i=0; i<points.length; ++i) {
|
||||
components.push(this.parse.point.apply(this, [points[i]]).geometry);
|
||||
@@ -238,7 +238,7 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {
|
||||
* @private
|
||||
*/
|
||||
'linestring': function(str) {
|
||||
var points = str.trim().split(',');
|
||||
var points = OpenLayers.String.trim(str).split(',');
|
||||
var components = [];
|
||||
for(var i=0; i<points.length; ++i) {
|
||||
components.push(this.parse.point.apply(this, [points[i]]).geometry);
|
||||
@@ -256,7 +256,7 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {
|
||||
*/
|
||||
'multilinestring': function(str) {
|
||||
var line;
|
||||
var lines = str.trim().split(this.regExes.parenComma);
|
||||
var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma);
|
||||
var components = [];
|
||||
for(var i=0; i<lines.length; ++i) {
|
||||
line = lines[i].replace(this.regExes.trimParens, '$1');
|
||||
@@ -275,7 +275,7 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {
|
||||
*/
|
||||
'polygon': function(str) {
|
||||
var ring, linestring, linearring;
|
||||
var rings = str.trim().split(this.regExes.parenComma);
|
||||
var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma);
|
||||
var components = [];
|
||||
for(var i=0; i<rings.length; ++i) {
|
||||
ring = rings[i].replace(this.regExes.trimParens, '$1');
|
||||
@@ -296,7 +296,7 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {
|
||||
*/
|
||||
'multipolygon': function(str) {
|
||||
var polygon;
|
||||
var polygons = str.trim().split(this.regExes.doubleParenComma);
|
||||
var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma);
|
||||
var components = [];
|
||||
for(var i=0; i<polygons.length; ++i) {
|
||||
polygon = polygons[i].replace(this.regExes.trimParens, '$1');
|
||||
@@ -316,7 +316,7 @@ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, {
|
||||
'geometrycollection': function(str) {
|
||||
// separate components of the collection with |
|
||||
str = str.replace(/,\s*([A-Za-z])/g, '|$1');
|
||||
var wktArray = str.trim().split('|');
|
||||
var wktArray = OpenLayers.String.trim(str).split('|');
|
||||
var components = [];
|
||||
for(var i=0; i<wktArray.length; ++i) {
|
||||
components.push(OpenLayers.Format.WKT.prototype.read.apply(this,[wktArray[i]]));
|
||||
|
||||
@@ -60,21 +60,23 @@ OpenLayers.Format.XML = OpenLayers.Class(OpenLayers.Format, {
|
||||
text = text.substring(index);
|
||||
}
|
||||
var node = OpenLayers.Util.Try(
|
||||
(function() {
|
||||
var xmldom;
|
||||
/**
|
||||
* Since we want to be able to call this method on the prototype
|
||||
* itself, this.xmldom may not exist even if in IE.
|
||||
*/
|
||||
if(window.ActiveXObject && !this.xmldom) {
|
||||
xmldom = new ActiveXObject("Microsoft.XMLDOM");
|
||||
} else {
|
||||
xmldom = this.xmldom;
|
||||
|
||||
OpenLayers.Function.bind((
|
||||
function() {
|
||||
var xmldom;
|
||||
/**
|
||||
* Since we want to be able to call this method on the prototype
|
||||
* itself, this.xmldom may not exist even if in IE.
|
||||
*/
|
||||
if(window.ActiveXObject && !this.xmldom) {
|
||||
xmldom = new ActiveXObject("Microsoft.XMLDOM");
|
||||
} else {
|
||||
xmldom = this.xmldom;
|
||||
|
||||
}
|
||||
xmldom.loadXML(text);
|
||||
return xmldom;
|
||||
}
|
||||
xmldom.loadXML(text);
|
||||
return xmldom;
|
||||
}).bind(this),
|
||||
), this),
|
||||
function() {
|
||||
return new DOMParser().parseFromString(text, 'text/xml');
|
||||
},
|
||||
|
||||
@@ -49,7 +49,9 @@ OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {
|
||||
initialize: function(control, callbacks, options) {
|
||||
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
||||
// cache the bound event listener method so it can be unobserved later
|
||||
this.eventListener = this.handleKeyEvent.bindAsEventListener(this);
|
||||
this.eventListener = OpenLayers.Function.bindAsEventListener(
|
||||
this.handleKeyEvent, this
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,7 +39,9 @@ OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {
|
||||
*/
|
||||
initialize: function(control, callbacks, options) {
|
||||
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
||||
this.wheelListener = this.onWheelEvent.bindAsEventListener(this);
|
||||
this.wheelListener = OpenLayers.Function.bindAsEventListener(
|
||||
this.onWheelEvent, this
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -228,11 +228,12 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
|
||||
if (!sameMarkerClicked) {
|
||||
var popup = this.createPopup();
|
||||
OpenLayers.Event.observe(popup.div, "click",
|
||||
function() {
|
||||
for(var i=0; i < this.layer.map.popups.length; i++) {
|
||||
this.layer.map.removePopup(this.layer.map.popups[i]);
|
||||
}
|
||||
}.bind(this));
|
||||
OpenLayers.Function.bind(function() {
|
||||
for(var i=0; i < this.layer.map.popups.length; i++) {
|
||||
this.layer.map.removePopup(this.layer.map.popups[i]);
|
||||
}
|
||||
}, this)
|
||||
);
|
||||
this.layer.map.addPopup(popup);
|
||||
}
|
||||
OpenLayers.Event.stop(evt);
|
||||
|
||||
@@ -393,13 +393,14 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
||||
var data = this.writer.write(this.features);
|
||||
|
||||
var url = this.url;
|
||||
if (OpenLayers.ProxyHost && this.url.startsWith("http")) {
|
||||
if (OpenLayers.ProxyHost &&
|
||||
OpenLayers.String.startsWith(this.url, "http")) {
|
||||
url = OpenLayers.ProxyHost + escape(this.url);
|
||||
}
|
||||
|
||||
var success = this.commitSuccess.bind(this);
|
||||
var success = OpenLayers.Function.bind(this.commitSuccess, this);
|
||||
|
||||
var failure = this.commitFailure.bind(this);
|
||||
var failure = OpenLayers.Function.bind(this.commitFailure, this);
|
||||
|
||||
data = OpenLayers.Ajax.serializeXMLToString(data);
|
||||
|
||||
|
||||
@@ -301,15 +301,15 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
|
||||
// Because Mozilla does not support the "resize" event for elements
|
||||
// other than "window", we need to put a hack here.
|
||||
if (navigator.appName.contains("Microsoft")) {
|
||||
if (OpenLayers.String.contains(navigator.appName, "Microsoft")) {
|
||||
// If IE, register the resize on the div
|
||||
this.events.register("resize", this, this.updateSize);
|
||||
} else {
|
||||
// Else updateSize on catching the window's resize
|
||||
// Note that this is ok, as updateSize() does nothing if the
|
||||
// map's size has not actually changed.
|
||||
OpenLayers.Event.observe(window, 'resize',
|
||||
this.updateSize.bind(this));
|
||||
OpenLayers.Event.observe(window, 'resize',
|
||||
OpenLayers.Function.bind(this.updateSize, this));
|
||||
}
|
||||
|
||||
// only append link stylesheet if the theme property is set
|
||||
@@ -354,7 +354,7 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
|
||||
this.popups = [];
|
||||
|
||||
this.unloadDestroy = this.destroy.bind(this);
|
||||
this.unloadDestroy = OpenLayers.Function.bind(this.destroy, this);
|
||||
|
||||
|
||||
// always call map.destroy()
|
||||
|
||||
@@ -170,7 +170,7 @@ OpenLayers.Popup = OpenLayers.Class({
|
||||
OpenLayers.Event.stop(e);
|
||||
}
|
||||
OpenLayers.Event.observe(closeImg, "click",
|
||||
closePopup.bindAsEventListener(this));
|
||||
OpenLayers.Function.bindAsEventListener(closePopup, this));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
http://openlayers.org/pipermail/dev/2007-January/000205.html
|
||||
|
||||
OpenLayers.Event.observe( this.imgDiv, "load",
|
||||
this.checkImgURL.bind(this) );
|
||||
OpenLayers.Function.bind(this.checkImgURL, this) );
|
||||
*/
|
||||
this.frame.appendChild(this.imgDiv);
|
||||
this.layer.div.appendChild(this.frame);
|
||||
@@ -206,7 +206,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
this.events.triggerEvent("loadend");
|
||||
}
|
||||
}
|
||||
OpenLayers.Event.observe(this.imgDiv, 'load', onload.bind(this));
|
||||
OpenLayers.Event.observe(this.imgDiv, 'load',
|
||||
OpenLayers.Function.bind(onload, this));
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -255,9 +255,9 @@ OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
if(delayDisplay) {
|
||||
image.style.display = "none";
|
||||
OpenLayers.Event.observe(image, "load",
|
||||
OpenLayers.Util.onImageLoad.bind(image));
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoad, image));
|
||||
OpenLayers.Event.observe(image, "error",
|
||||
OpenLayers.Util.onImageLoadError.bind(image));
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError, image));
|
||||
|
||||
}
|
||||
|
||||
@@ -453,9 +453,9 @@ OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
|
||||
if (delayDisplay) {
|
||||
img.style.display = "none";
|
||||
OpenLayers.Event.observe(img, "load",
|
||||
OpenLayers.Util.onImageLoad.bind(div));
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoad, div));
|
||||
OpenLayers.Event.observe(img, "error",
|
||||
OpenLayers.Util.onImageLoadError.bind(div));
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError, div));
|
||||
}
|
||||
|
||||
OpenLayers.Util.modifyAlphaImageDiv(div, id, px, sz, imgURL, position,
|
||||
@@ -791,9 +791,10 @@ OpenLayers.Util.getParameters = function(url) {
|
||||
|
||||
//parse out parameters portion of url string
|
||||
var paramsString = "";
|
||||
if (url.contains('?')) {
|
||||
if (OpenLayers.String.contains(url, '?')) {
|
||||
var start = url.indexOf('?') + 1;
|
||||
var end = url.contains("#") ? url.indexOf('#') : url.length;
|
||||
var end = OpenLayers.String.contains(url, "#") ?
|
||||
url.indexOf('#') : url.length;
|
||||
paramsString = url.substring(start, end);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user