Create a function -- OpenLayers.Util.getElement -- which replaces "$". This
should be used in all library code. This patch replaces all uses of "$()" in existing code. The primary reason for this is to avoid conflicts with libraries (like Prototype) which might redefine this function differently. git-svn-id: http://svn.openlayers.org/trunk/openlayers@2541 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -8,25 +8,31 @@
|
||||
*/
|
||||
OpenLayers.Util = new Object();
|
||||
|
||||
/* from Prototype.js */
|
||||
if ($ == null) {
|
||||
var $ = function () {
|
||||
var elements = new Array();
|
||||
/**
|
||||
* This is the old $() from prototype
|
||||
*/
|
||||
OpenLayers.Util.getElement = function() {
|
||||
var elements = new Array();
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var element = arguments[i];
|
||||
if (typeof element == 'string')
|
||||
element = document.getElementById(element);
|
||||
|
||||
if (arguments.length == 1)
|
||||
return element;
|
||||
|
||||
if (typeof element == 'string') {
|
||||
element = document.getElementById(element);
|
||||
}
|
||||
if (arguments.length == 1) {
|
||||
return element;
|
||||
}
|
||||
elements.push(element);
|
||||
}
|
||||
|
||||
return elements;
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
};
|
||||
|
||||
/**
|
||||
* Maintain $() from prototype
|
||||
*/
|
||||
if ($ == null) {
|
||||
var $ = OpenLayers.Util.getElement;
|
||||
}
|
||||
|
||||
/* from Prototype.js */
|
||||
OpenLayers.Util.extend = function(destination, source) {
|
||||
|
||||
Reference in New Issue
Block a user