Removing unused image load error handling code. r=fredj (closes #3420)
This commit is contained in:
@@ -279,13 +279,14 @@ OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
OpenLayers.Util.modifyDOMElement(image, id, px, sz, position,
|
||||
border, null, opacity);
|
||||
|
||||
if(delayDisplay) {
|
||||
if (delayDisplay) {
|
||||
image.style.display = "none";
|
||||
OpenLayers.Event.observe(image, "load",
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoad, image));
|
||||
OpenLayers.Event.observe(image, "error",
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError, image));
|
||||
|
||||
function display() {
|
||||
image.style.display = "";
|
||||
OpenLayers.Event.stopObservingElement(image);
|
||||
}
|
||||
OpenLayers.Event.observe(image, "load", display);
|
||||
OpenLayers.Event.observe(image, "error", display);
|
||||
}
|
||||
|
||||
//set special properties
|
||||
@@ -294,8 +295,6 @@ OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
if (imgURL) {
|
||||
image.src = imgURL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return image;
|
||||
};
|
||||
@@ -321,33 +320,6 @@ OpenLayers.Util.setOpacity = function(element, opacity) {
|
||||
null, null, null, opacity);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: onImageLoad
|
||||
* Bound to image load events. For all images created with <createImage> or
|
||||
* <createAlphaImageDiv>, this function will be bound to the load event.
|
||||
*/
|
||||
OpenLayers.Util.onImageLoad = function() {
|
||||
// The complex check here is to solve issues described in #480.
|
||||
// Every time a map view changes, it increments the 'viewRequestID'
|
||||
// property. As the requests for the images for the new map view are sent
|
||||
// out, they are tagged with this unique viewRequestID.
|
||||
//
|
||||
// If an image has no viewRequestID property set, we display it regardless,
|
||||
// but if it does have a viewRequestID property, we check that it matches
|
||||
// the viewRequestID set on the map.
|
||||
//
|
||||
// If the viewRequestID on the map has changed, that means that the user
|
||||
// has changed the map view since this specific request was sent out, and
|
||||
// therefore this tile does not need to be displayed (so we do not execute
|
||||
// this code that turns its display on).
|
||||
//
|
||||
if (!this.viewRequestID ||
|
||||
(this.map && this.viewRequestID == this.map.viewRequestID)) {
|
||||
this.style.display = "";
|
||||
}
|
||||
OpenLayers.Element.removeClass(this, "olImageLoadError");
|
||||
};
|
||||
|
||||
/**
|
||||
* Property: IMAGE_RELOAD_ATTEMPTS
|
||||
* {Integer} How many times should we try to reload an image before giving up?
|
||||
@@ -355,38 +327,6 @@ OpenLayers.Util.onImageLoad = function() {
|
||||
*/
|
||||
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 0;
|
||||
|
||||
/**
|
||||
* Function: onImageLoadError
|
||||
*/
|
||||
OpenLayers.Util.onImageLoadError = function() {
|
||||
this._attempts = (this._attempts) ? (this._attempts + 1) : 1;
|
||||
if (this._attempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {
|
||||
var urls = this.urls;
|
||||
if (urls && OpenLayers.Util.isArray(urls) && urls.length > 1){
|
||||
var src = this.src.toString();
|
||||
var current_url, k;
|
||||
for (k = 0; current_url = urls[k]; k++){
|
||||
if(src.indexOf(current_url) != -1){
|
||||
break;
|
||||
}
|
||||
}
|
||||
var guess = Math.floor(urls.length * Math.random());
|
||||
var new_url = urls[guess];
|
||||
k = 0;
|
||||
while(new_url == current_url && k++ < 4){
|
||||
guess = Math.floor(urls.length * Math.random());
|
||||
new_url = urls[guess];
|
||||
}
|
||||
this.src = src.replace(current_url, new_url);
|
||||
} else {
|
||||
this.src = this.src;
|
||||
}
|
||||
} else {
|
||||
OpenLayers.Element.addClass(this, "olImageLoadError");
|
||||
}
|
||||
this.style.display = "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Property: alphaHackNeeded
|
||||
* {Boolean} true if the png alpha hack is necessary and possible, false otherwise.
|
||||
@@ -497,17 +437,9 @@ OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
|
||||
|
||||
var div = OpenLayers.Util.createDiv();
|
||||
var img = OpenLayers.Util.createImage(null, null, null, null, null, null,
|
||||
null, false);
|
||||
null, delayDisplay);
|
||||
div.appendChild(img);
|
||||
|
||||
if (delayDisplay) {
|
||||
img.style.display = "none";
|
||||
OpenLayers.Event.observe(img, "load",
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoad, div));
|
||||
OpenLayers.Event.observe(img, "error",
|
||||
OpenLayers.Function.bind(OpenLayers.Util.onImageLoadError, div));
|
||||
}
|
||||
|
||||
OpenLayers.Util.modifyAlphaImageDiv(div, id, px, sz, imgURL, position,
|
||||
border, sizing, opacity);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user