Don't clobber existing prototypes. Since OpenLayers doesn't use 'foo.bind'

anymore, preferring OpenLayers.Function.bind(function, object), we don't
need to provide this -- so if someone provides something different, don't 
clobber it. (Closes #962)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@4339 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-09-16 17:15:54 +00:00
parent 48ceca88a5
commit d75f7430af
+137 -125
View File
@@ -83,75 +83,82 @@ OpenLayers.String = {
} }
}; };
/** if (!String.prototype.startsWith) {
* APIMethod: String.startsWith /**
* Deprecated. Whether or not a string starts with another string. * APIMethod: String.startsWith
* * Deprecated. Whether or not a string starts with another string.
* Parameters: *
* sStart - {Sring} The string we're testing for. * Parameters:
* * sStart - {Sring} The string we're testing for.
* Returns: *
* {Boolean} Whether or not this string starts with the string passed in. * Returns:
*/ * {Boolean} Whether or not this string starts with the string passed in.
String.prototype.startsWith = function(sStart) { */
OpenLayers.Console.warn( String.prototype.startsWith = function(sStart) {
"This method has been deprecated and will be removed in 3.0. " + OpenLayers.Console.warn(
"Please use OpenLayers.String.startsWith instead" "This method has been deprecated and will be removed in 3.0. " +
); "Please use OpenLayers.String.startsWith instead"
return OpenLayers.String.startsWith(this, sStart); );
}; return OpenLayers.String.startsWith(this, sStart);
};
}
/** if (!String.prototype.contains) {
* APIMethod: String.contains /**
* Deprecated. Whether or not a string contains another string. * APIMethod: String.contains
* * Deprecated. Whether or not a string contains another string.
* Parameters: *
* str - {String} The string that we're testing for. * Parameters:
* * str - {String} The string that we're testing for.
* Returns: *
* {Boolean} Whether or not this string contains with the string passed in. * Returns:
*/ * {Boolean} Whether or not this string contains with the string passed in.
String.prototype.contains = function(str) { */
OpenLayers.Console.warn( String.prototype.contains = function(str) {
"This method has been deprecated and will be removed in 3.0. " + OpenLayers.Console.warn(
"Please use OpenLayers.String.contains instead" "This method has been deprecated and will be removed in 3.0. " +
); "Please use OpenLayers.String.contains instead"
return OpenLayers.String.contains(this, str); );
}; return OpenLayers.String.contains(this, str);
};
}
/** if (!String.prototype.trim) {
* APIMethod: String.trim /**
* Deprecated. Removes leading and trailing whitespace characters from a string. * APIMethod: String.trim
* * Deprecated. Removes leading and trailing whitespace characters from a string.
* Returns: *
* {String} A trimmed version of the string - all leading and * Returns:
* trailing spaces removed * {String} A trimmed version of the string - all leading and
*/ * trailing spaces removed
String.prototype.trim = function() { */
OpenLayers.Console.warn( String.prototype.trim = function() {
"This method has been deprecated and will be removed in 3.0. " + OpenLayers.Console.warn(
"Please use OpenLayers.String.trim instead" "This method has been deprecated and will be removed in 3.0. " +
); "Please use OpenLayers.String.trim instead"
return OpenLayers.String.trim(this); );
}; return OpenLayers.String.trim(this);
};
/** }
* APIMethod: camelize
* Deprecated. Camel-case a hyphenated string.
* Ex. "chicken-head" becomes "chickenHead", and
* "-chicken-head" becomes "ChickenHead".
*
* Returns:
* {String} The string, camelized
*/
String.prototype.camelize = function() {
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);
};
if (!String.prototype.camelize) {
/**
* APIMethod: camelize
* Deprecated. Camel-case a hyphenated string.
* Ex. "chicken-head" becomes "chickenHead", and
* "-chicken-head" becomes "ChickenHead".
*
* Returns:
* {String} The string, camelized
*/
String.prototype.camelize = function() {
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);
};
}
/********************* /*********************
* * * *
@@ -183,26 +190,27 @@ OpenLayers.Number = {
} }
}; };
/** if (!Number.prototype.limitSigDigs) {
* APIMethod: Number.limitSigDigs /**
* Deprecated. Limit the number of significant digits on an integer. Does *not* * APIMethod: Number.limitSigDigs
* work with floats! * Deprecated. Limit the number of significant digits on an integer. Does *not*
* * work with floats!
* Parameters: *
* sig - {Integer} * Parameters:
* * sig - {Integer}
* Returns: *
* {Integer} The number, rounded to the specified number of significant digits. * Returns:
* If null, 0, or negative value passed in, returns 0 * {Integer} The number, rounded to the specified number of significant digits.
*/ * If null, 0, or negative value passed in, returns 0
Number.prototype.limitSigDigs = function(sig) { */
OpenLayers.Console.warn( Number.prototype.limitSigDigs = function(sig) {
"This method has been deprecated and will be removed in 3.0. " + OpenLayers.Console.warn(
"Please use OpenLayers.Number.limitSigDigs instead" "This method has been deprecated and will be removed in 3.0. " +
); "Please use OpenLayers.Number.limitSigDigs instead"
return OpenLayers.Number.limitSigDigs(this, sig); );
}; return OpenLayers.Number.limitSigDigs(this, sig);
};
}
/********************* /*********************
* * * *
@@ -255,43 +263,47 @@ OpenLayers.Function = {
} }
}; };
/** if (!Function.prototype.bind) {
* APIMethod: Function.bind /**
* Deprecated. Bind a function to an object. * APIMethod: Function.bind
* Method to easily create closures with 'this' altered. * Deprecated. Bind a function to an object.
* * Method to easily create closures with 'this' altered.
* Parameters: *
* object - {Object} the this parameter * Parameters:
* * object - {Object} the this parameter
* Returns: *
* {Function} A closure with 'this' altered to the first * Returns:
* argument. * {Function} A closure with 'this' altered to the first
*/ * argument.
Function.prototype.bind = function() { */
OpenLayers.Console.warn( Function.prototype.bind = function() {
"This method has been deprecated and will be removed in 3.0. " + OpenLayers.Console.warn(
"Please use OpenLayers.Function.bind instead" "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]); // new function takes the same arguments with this function up front
return OpenLayers.Function.bind.apply(null, arguments); Array.prototype.unshift.apply(arguments, [this]);
}; return OpenLayers.Function.bind.apply(null, arguments);
};
}
/** if (!Function.prototype.bindAsEventListener) {
* APIMethod: Function.bindAsEventListener /**
* Deprecated. Bind a function to an object, and configure it to receive the * APIMethod: Function.bindAsEventListener
* 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. * Parameters:
* * object - {Object} A reference to this.
* Returns: *
* {Function} * Returns:
*/ * {Function}
Function.prototype.bindAsEventListener = function(object) { */
OpenLayers.Console.warn( Function.prototype.bindAsEventListener = function(object) {
"This method has been deprecated and will be removed in 3.0. " + OpenLayers.Console.warn(
"Please use OpenLayers.Function.bindAsEventListener instead" "This method has been deprecated and will be removed in 3.0. " +
); "Please use OpenLayers.Function.bindAsEventListener instead"
return OpenLayers.Function.bindAsEventListener(this, object); );
}; return OpenLayers.Function.bindAsEventListener(this, object);
};
}