mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-15 03:34:03 +00:00
Use exchars instead of exsentences for the extract
To avoid sentence parsing bugs in other languages. We have to artificially remove the always-added ellipsis from textextracts to mimic previous behavior, and we'll add ellipsis via CSS afterwards. Bug: T135824 Change-Id: Idf27f2fd18f7197e588c609eeb62ac8fc80626d7
This commit is contained in:
parent
107d6edd37
commit
ea072139df
|
@ -8,6 +8,12 @@
|
|||
var article = {},
|
||||
$window = $( window );
|
||||
|
||||
/**
|
||||
* Number of chars to request for the article extract
|
||||
* @property CHARS
|
||||
*/
|
||||
article.CHARS = 525;
|
||||
|
||||
/**
|
||||
* Size constants for popup images
|
||||
* @property SIZES
|
||||
|
@ -55,7 +61,7 @@
|
|||
formatversion: 2,
|
||||
redirects: true,
|
||||
exintro: true,
|
||||
exsentences: 5,
|
||||
exchars: article.CHARS,
|
||||
// there is an added geometric limit on .mwe-popups-extract
|
||||
// so that text does not overflow from the card
|
||||
explaintext: true,
|
||||
|
@ -100,6 +106,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
re.query.pages[ 0 ].extract = removeEllipsis( re.query.pages[ 0 ].extract );
|
||||
|
||||
mw.popups.render.cache[ href ] = {};
|
||||
mw.popups.render.cache[ href ].popup = article.createPopup( re.query.pages[ 0 ], href );
|
||||
mw.popups.render.cache[ href ].getOffset = article.getOffset;
|
||||
|
@ -667,4 +675,11 @@
|
|||
*/
|
||||
mw.popups.render.getClosestYPosition = getClosestYPosition;
|
||||
|
||||
/**
|
||||
* Remove ellipsis if exists at the end
|
||||
*/
|
||||
function removeEllipsis( text ) {
|
||||
return text.replace( /\.\.\.$/, '' );
|
||||
}
|
||||
|
||||
} )( jQuery, mediaWiki );
|
||||
|
|
Loading…
Reference in a new issue