From: Ed Sanders Date: Fri, 20 Sep 2019 12:22:04 +0000 (+0100) Subject: Gallery: Don't fire wikipage.content hook twice during init X-Git-Tag: 1.34.0-rc.0~133^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/File:Nonexistent.jpg?a=commitdiff_plain;h=e75a8edd8cddf18b5e8a755a95f5c014b45f06d2;p=lhc%2Fweb%2Fwiklou.git Gallery: Don't fire wikipage.content hook twice during init We know the hook has already been fired once, because we listen to it to start the gallery. Firing it again here can cause other listeners to fail as only the last-fired argument is stored. Bug: T233401 Change-Id: I32ca866964c7a1f644a3cc28d636ec1430b8ef58 --- diff --git a/resources/src/mediawiki.page.gallery.slideshow.js b/resources/src/mediawiki.page.gallery.slideshow.js index 667c2ba21b..a36e409aa5 100644 --- a/resources/src/mediawiki.page.gallery.slideshow.js +++ b/resources/src/mediawiki.page.gallery.slideshow.js @@ -24,7 +24,7 @@ this.drawCarousel(); this.setSizeRequirement(); this.toggleThumbnails( !!this.$gallery.attr( 'data-showthumbnails' ) ); - this.showCurrentImage(); + this.showCurrentImage( true ); // Events $( window ).on( @@ -229,8 +229,10 @@ /** * Displays the image set as {@link #$currentImage} in the carousel. + * + * @param {boolean} init Image being show during gallery init (i.e. first image) */ - mw.GallerySlideshow.prototype.showCurrentImage = function () { + mw.GallerySlideshow.prototype.showCurrentImage = function ( init ) { var $thumbnail, $imgLink, $imageLi = this.getCurrentImage(), $caption = $imageLi.find( '.gallerytext' ); @@ -279,7 +281,10 @@ if ( this.$thumbnail.attr( 'src' ) === $thumbnail.attr( 'src' ) ) { this.$img.attr( 'src', info.thumburl ); this.setImageSize(); - mw.hook( 'wikipage.content' ).fire( this.$imgContainer ); + // Don't fire hook twice during init + if ( !init ) { + mw.hook( 'wikipage.content' ).fire( this.$imgContainer ); + } // Pre-fetch the next image this.loadImage( this.getNextImage().find( 'img' ) );