Initialize gallery slideshow on wikipage.content hook
authorDerk-Jan Hartman <hartman.wiki@gmail.com>
Mon, 14 Nov 2016 21:46:10 +0000 (22:46 +0100)
committerDerk-Jan Hartman <hartman.wiki@gmail.com>
Mon, 14 Nov 2016 21:46:10 +0000 (22:46 +0100)
The slideshow mode of gallery tag was triggered upon document.ready,
instead of on wikipage.content. For this reason, after editing and
saving one of these galleries in VE, you would loose your slideshow
mode and default back to packed mode.

Change-Id: I411703b3c1cafbd7d763cbaa8bc9585924c51030

resources/src/mediawiki/page/gallery-slideshow.js

index cf448b0..26f568b 100644 (file)
        };
 
        // Bootstrap all slideshow galleries
-       $( function () {
-               $( '.mw-gallery-slideshow' ).each( function () {
+       mw.hook( 'wikipage.content' ).add( function ( $content ) {
+               $content.find( '.mw-gallery-slideshow' ).each( function () {
                        /*jshint -W031 */
                        new mw.GallerySlideshow( this );
                        /*jshint +W031 */