Fix runaway prev/next issue

Prev/next handlers were multiplying after every click.

Change-Id: I1e21b2711cc08a6edbbd26ec844e966f7582b3c8
This commit is contained in:
Gergő Tisza 2014-02-11 01:12:31 +00:00
parent cc9e2daf2f
commit f4ab39df1e

View file

@ -189,6 +189,8 @@
viewer.resize( ui );
return false;
} );
this.setupEventHandlers();
}
MMVP = MultimediaViewer.prototype;
@ -347,14 +349,6 @@
this.lightbox.iface.load( image );
}
this.lightbox.iface.$imageWrapper.on( 'mmv-next', function () {
viewer.nextImage();
} );
this.lightbox.iface.$imageWrapper.on( 'mmv-prev', function () {
viewer.prevImage();
} );
$( document.body ).addClass( 'mw-mlb-lightbox-open' );
imageWidths = this.ui.getImageSizeApiArgs();
@ -486,6 +480,18 @@
this.loadIndex( this.lightbox.currentIndex - 1 );
};
MMVP.setupEventHandlers = function() {
var viewer = this;
this.lightbox.iface.$imageWrapper.on( 'mmv-next', function () {
viewer.nextImage();
} );
this.lightbox.iface.$imageWrapper.on( 'mmv-prev', function () {
viewer.prevImage();
} );
};
function handleHash() {
var statedIndex,
$foundElement,