mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-11-28 01:50:09 +00:00
Use Parsoid's regularity to find caption
Follow up to Ic652576f84e07c9fc8ef8be216a6fc94466198a6 where this was hinted at. The comment about active formatting elements is removed due to I7b4e9df8490357f44d31d6a869fa9b7a15f029ea. Bug: T321440 Change-Id: Ifb12dac64bd7a7fb8444ac2ada557868502cf213
This commit is contained in:
parent
e1e89e4cdf
commit
b0f83b39fb
|
@ -292,9 +292,6 @@
|
|||
* Processes a Parsoid thumb, making use of the specified structure,
|
||||
* https://www.mediawiki.org/wiki/Specs/HTML#Media
|
||||
*
|
||||
* Active formatting elements are sometimes re-opened inside
|
||||
* the structure and accounted for using .closest()
|
||||
*
|
||||
* @param {Object} thumb
|
||||
*/
|
||||
MMVB.processParsoidThumb = function ( thumb ) {
|
||||
|
@ -309,7 +306,9 @@
|
|||
),
|
||||
link = $link.prop( 'href' ),
|
||||
alt = $thumb.attr( 'alt' ),
|
||||
title = mw.Title.newFromImg( $thumb );
|
||||
title = mw.Title.newFromImg( $thumb ),
|
||||
caption,
|
||||
$thumbCaption;
|
||||
|
||||
if ( !bs.isValidExtension( title ) ) {
|
||||
// Short-circuit event handler and interface setup, because
|
||||
|
@ -325,6 +324,13 @@
|
|||
bs.preloadAssets( $thumbContainer );
|
||||
}
|
||||
|
||||
if ( ( $thumbContainer.prop( 'tagName' ) || '' ).toLowerCase() === 'figure' ) {
|
||||
$thumbCaption = $thumbContainer.find( 'figcaption' );
|
||||
caption = this.htmlUtils.htmlToTextWithTags( $thumbCaption.html() || '' );
|
||||
} else {
|
||||
caption = $link.prop( 'title' ) || undefined;
|
||||
}
|
||||
|
||||
// This is the data that will be passed onto the mmv
|
||||
this.thumbs.push( {
|
||||
thumb: thumb,
|
||||
|
@ -332,8 +338,7 @@
|
|||
title: title,
|
||||
link: link,
|
||||
alt: alt,
|
||||
// FIXME: findCaption can further make use of Parsoid's regularity
|
||||
caption: this.findCaption( $thumbContainer, $link )
|
||||
caption: caption
|
||||
} );
|
||||
|
||||
$link.on( 'click', function ( e ) {
|
||||
|
@ -469,7 +474,7 @@
|
|||
return $link.prop( 'title' ) || undefined;
|
||||
}
|
||||
|
||||
$potentialCaptions = $thumbContainer.find( '.thumbcaption, figcaption' );
|
||||
$potentialCaptions = $thumbContainer.find( '.thumbcaption' );
|
||||
if ( $potentialCaptions.length < 2 ) {
|
||||
$thumbCaption = $potentialCaptions.eq( 0 );
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue