mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-09-29 13:17:35 +00:00
Ensure click playback happens at the right time
The code to replay clicks and clean up the handler was called after processing each thumbnail, instead of just once at the end. This might have caused many subtle issues such as clicks on any but the first image not replaying correctly; more problematically, of there were no MediaViewer-compatible thumbs, the handler was never cleaned up and the clicks were never replayed. Besides fixing that, this commit also adds a try..finally wrapper so that the click replaying is not broken even if there is an error in the thumb processing code. This might or might not be a good idea. The internets say that try..finally without a catch causes errors in IE8, but only if it is not wrapped in another try..catch, so we are probably fine. (Adding a catch which just rethrows the error would be an alternative, but it messes up stack traces.) Change-Id: I2f645762103274c92c15a0d4b595d18d93b08415 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/497 Bug: 64345
This commit is contained in:
parent
2b0991a049
commit
3be5195ed2
|
@ -125,9 +125,18 @@
|
|||
MMVB.processThumbs = function () {
|
||||
var bs = this;
|
||||
|
||||
this.$thumbs.each( function ( i, thumb ) {
|
||||
bs.processThumb( thumb );
|
||||
} );
|
||||
// if this breaks in IE8, see https://github.com/ebryn/backburner.js/pull/50
|
||||
// but it probably won't since there is a catch further up the chain
|
||||
try {
|
||||
this.$thumbs.each( function ( i, thumb ) {
|
||||
bs.processThumb( thumb );
|
||||
} );
|
||||
} finally {
|
||||
this.thumbsReadyDeferred.resolve();
|
||||
// now that we have set up our real click handler we can we can remove the temporary
|
||||
// handler added in mmv.head.js which just replays clicks to the real handler
|
||||
$( document ).off( 'click.mmv-head' );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -207,11 +216,6 @@
|
|||
$link.add( $enlarge ).click( function ( e ) {
|
||||
return bs.click( this, e, title, alwaysOpen );
|
||||
} );
|
||||
// now that we have set up our real click handler we can we can remove the temporary
|
||||
// handler added in mmv.head.js which just replays clicks to the real handler
|
||||
$( document ).off( 'click.mmv-head' );
|
||||
|
||||
this.thumbsReadyDeferred.resolve();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue