mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-12-19 19:40:40 +00:00
8cf9b60ab5
RelatedArticles tries to load the 'ext.cards' module and if it succeeds it continues with showing the related articles on the page. Dependency: I6661527175eb889cec4193b18fa18207f332b4fc Bug: T117108 Change-Id: I33936a3e9cd5d1f0296e48fd1c2bba77fff4e466
33 lines
1,007 B
JavaScript
33 lines
1,007 B
JavaScript
( function ( $ ) {
|
|
|
|
var config = mw.config.get( [ 'skin', 'wgNamespaceNumber', 'wgMFMode', 'wgIsMainPage' ] ),
|
|
relatedPages = new mw.relatedPages.RelatedPagesGateway(
|
|
new mw.Api(),
|
|
mw.config.get( 'wgPageName' ),
|
|
mw.config.get( 'wgRelatedArticles' ),
|
|
mw.config.get( 'wgRelatedArticlesUseCirrusSearch' ),
|
|
mw.config.get( 'wgRelatedArticlesOnlyUseCirrusSearch' )
|
|
),
|
|
LIMIT = 3;
|
|
|
|
if (
|
|
config.wgNamespaceNumber === 0 &&
|
|
!config.wgIsMainPage &&
|
|
// any skin except minerva stable
|
|
( config.skin !== 'minerva' || config.wgMFMode === 'beta' )
|
|
) {
|
|
$.when(
|
|
// Note we load dependencies here rather than ResourceLoader
|
|
// to avoid PHP exceptions when Cards not installed
|
|
// which should never happen given the if statement.
|
|
mw.loader.using( [ 'ext.cards', 'ext.relatedArticles.readMore' ] ),
|
|
relatedPages.getForCurrentPage( LIMIT )
|
|
).done( function ( _, pages ) {
|
|
if ( pages.length ) {
|
|
mw.track( 'ext.relatedArticles.init', pages );
|
|
}
|
|
} );
|
|
}
|
|
|
|
}( jQuery ) );
|