|
@ -4,6 +4,7 @@ |
|
|
*/ |
|
|
*/ |
|
|
function Images() { |
|
|
function Images() { |
|
|
this.images = {}; |
|
|
this.images = {}; |
|
|
|
|
|
this.imageBroken = {}; |
|
|
this.callback = undefined; |
|
|
this.callback = undefined; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -23,13 +24,12 @@ Images.prototype.setOnloadCallback = function(callback) { |
|
|
* @return {Image} img The image object |
|
|
* @return {Image} img The image object |
|
|
*/ |
|
|
*/ |
|
|
Images.prototype.load = function(url, brokenUrl) { |
|
|
Images.prototype.load = function(url, brokenUrl) { |
|
|
var img = this.images[url]; |
|
|
|
|
|
|
|
|
var img = this.images[url]; // make a pointer
|
|
|
if (img === undefined) { |
|
|
if (img === undefined) { |
|
|
// create the image
|
|
|
// create the image
|
|
|
var me = this; |
|
|
var me = this; |
|
|
img = new Image(); |
|
|
img = new Image(); |
|
|
img.onload = function () { |
|
|
img.onload = function () { |
|
|
|
|
|
|
|
|
// IE11 fix -- thanks dponch!
|
|
|
// IE11 fix -- thanks dponch!
|
|
|
if (this.width == 0) { |
|
|
if (this.width == 0) { |
|
|
document.body.appendChild(this); |
|
|
document.body.appendChild(this); |
|
@ -52,8 +52,16 @@ Images.prototype.load = function(url, brokenUrl) { |
|
|
me.callback(this); |
|
|
me.callback(this); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else if (me.imageBroken[url] === true) { |
|
|
|
|
|
console.error("Could not load brokenImage:", brokenUrl); |
|
|
|
|
|
delete this.src; |
|
|
|
|
|
if (me.callback) { |
|
|
|
|
|
me.callback(this); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
else { |
|
|
else { |
|
|
this.src = brokenUrl; |
|
|
this.src = brokenUrl; |
|
|
|
|
|
me.imageBroken[url] = true; |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|