Do not load related articles on diff comparision pages

Bug: T122076
Change-Id: I1dc00b3bd76053d353dc31137c4c15a10286184e
This commit is contained in:
Baha 2015-12-29 07:55:43 +05:00
parent f19aee12b8
commit d2599c5211
2 changed files with 27 additions and 2 deletions

View file

@ -88,6 +88,7 @@
],
"dependencies": [
"mediawiki.api",
"mediawiki.Uri",
"ext.relatedArticles.readMore.gateway",
"jquery.throttle-debounce"
],

View file

@ -1,6 +1,7 @@
( function ( $, mw ) {
var config = mw.config.get( [ 'skin', 'wgNamespaceNumber', 'wgMFMode', 'wgIsMainPage' ] ),
var config = mw.config.get( [ 'skin', 'wgNamespaceNumber', 'wgMFMode',
'wgIsMainPage', 'wgAction' ] ),
relatedPages = new mw.relatedPages.RelatedPagesGateway(
new mw.Api(),
mw.config.get( 'wgPageName' ),
@ -14,6 +15,11 @@
} ),
$window = $( window );
/**
* Load related articles when the user scrolls past half of the window height.
*
* @ignore
*/
function loadRelatedArticles() {
/**
* Threshold value to load related articles - after about half scroll
@ -36,11 +42,29 @@
$window.off( 'scroll', debouncedLoad );
}
}
/**
* Is the current page a diff page?
*
* @ignore
* @return {boolean}
*/
function isDiffPage() {
var queryParams = new mw.Uri( window.location.href ).query;
return !!(
queryParams.type === 'revision' ||
queryParams.hasOwnProperty( 'diff' ) ||
queryParams.hasOwnProperty( 'oldid' )
);
}
if (
config.wgNamespaceNumber === 0 &&
!config.wgIsMainPage &&
// T120735
mw.config.get( 'wgAction' ) === 'view' &&
config.wgAction === 'view' &&
!isDiffPage() &&
// any skin except minerva stable
( config.skin !== 'minerva' || config.wgMFMode === 'beta' )
) {