/*!
- * Show gallery captions when focused. Copied directly from jquery.mw-jump.js.
- * Also Dynamically resize images to justify them.
+ * Enhance MediaWiki galleries (from the `<gallery>` parser tag).
+ *
+ * - Toggle gallery captions when focused.
+ * - Dynamically resize images to fill horizontal space.
*/
( function ( mw, $ ) {
var $galleries,
.addClass( 'mw-gallery-packed-overlay' )
.removeClass( 'mw-gallery-packed-hover' );
} else {
- // Note use of just "a", not a.image, since we want this to trigger if a link in
- // the caption receives focus
+ // Note use of just `a`, not `a.image`, since we also want this to trigger if a link
+ // within the caption text receives focus.
+ // This is based on code from the 'jquery.mw-jump' module.
$content.find( 'ul.mw-gallery-packed-hover li.gallerybox' ).on( 'focus blur', 'a', function ( e ) {
// Confusingly jQuery leaves e.type as focusout for delegated blur events
var gettingFocus = e.type !== 'blur' && e.type !== 'focusout';