Lightwindow IE fix

Replace:

this.checkImage = new PeriodicalExecuter(function(i) {
if (!(typeof $(‘lightwindow_image_’+i).naturalWidth != “undefined” && $(‘lightwindow_image_’+i).naturalWidth == 0)) {

this.checkImage.stop();

var imageHeight = $(‘lightwindow_image_’+i).getHeight();
if (imageHeight > this.resizeTo.height) {
this.resizeTo.height = imageHeight;
}
this.resizeTo.width += $(‘lightwindow_image_’+i).getWidth();
this.imageCount–;

$(‘lightwindow_image_’+i).setStyle({
height: ‘100%’, width: ‘100%’
});

if (this.imageCount == 0) {
this._processWindow();
}
}

}.bind(this, i), 1);

With:

// We have to do this instead of .onload
var ie = (document.all)?1:0;
this.checkImage = new PeriodicalExecuter(function(i) {
if(ie){ //THE BROWSER IS IE
if ( $(‘lightwindow_image_’+i).complete && !(typeof $(‘lightwindow_image_’+i).naturalWidth != “undefined” && $(‘lightwindow_image_’+i).naturalWidth == 0)) {
this.checkImage.stop();

var imageHeight = $(‘lightwindow_image_’+i).getHeight();
if (imageHeight > this.resizeTo.height) {
this.resizeTo.height = imageHeight;
}
this.resizeTo.width += $(‘lightwindow_image_’+i).getWidth();
this.imageCount–;

$(‘lightwindow_image_’+i).setStyle({
height: ‘100%’, width: ‘100%’
});

if (this.imageCount == 0) {
this._processWindow();
}
//alert(‘IE has been detected’)
}
}
else
{//NOT IE, PROBABLY FF, OPERA, OTHER
//this line works for all other browsers
if ($(‘lightwindow_image_’+i).complete && !(typeof $(‘lightwindow_image_’+i).naturalWidth != “undefined” && $(‘lightwindow_image_’+i).naturalWidth == 0)) {

this.checkImage.stop();

var imageHeight = $(‘lightwindow_image_’+i).getHeight();
if (imageHeight > this.resizeTo.height) {
this.resizeTo.height = imageHeight;
}
this.resizeTo.width += $(‘lightwindow_image_’+i).getWidth();
this.imageCount–;

$(‘lightwindow_image_’+i).setStyle({
height: ‘100%’, width: ‘100%’
});

if (this.imageCount == 0) {
this._processWindow();
}
}
}

}.bind(this, i), 1);

credit:
http://www.silverstripe.org/all-other-modules/show/251991?start=8

Comments are closed.