2022-08-26 08:40:48 +00:00
|
|
|
( function ( M ) {
|
2018-08-17 19:00:57 +00:00
|
|
|
var
|
2019-02-07 16:34:18 +00:00
|
|
|
Overlay = M.require( 'mobile.startup' ).Overlay,
|
2019-07-02 21:10:10 +00:00
|
|
|
IssueList = require( './IssueList.js' ),
|
2018-08-17 19:00:57 +00:00
|
|
|
KEYWORD_ALL_SECTIONS = 'all',
|
|
|
|
NS_MAIN = 0,
|
|
|
|
NS_CATEGORY = 14;
|
2018-08-16 19:00:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Overlay for displaying page issues
|
|
|
|
*
|
2018-08-17 19:00:57 +00:00
|
|
|
* @param {IssueSummary[]} issues list of page issue summaries for display.
|
|
|
|
* @param {string} section
|
|
|
|
* @param {number} namespaceID
|
2018-11-24 01:49:47 +00:00
|
|
|
* @return {Overlay}
|
2018-08-16 19:00:38 +00:00
|
|
|
*/
|
2018-11-24 01:49:47 +00:00
|
|
|
function pageIssuesOverlay( issues, section, namespaceID ) {
|
|
|
|
var overlay,
|
2018-09-13 15:33:20 +00:00
|
|
|
// Note only the main namespace is expected to make use of section issues, so the
|
|
|
|
// heading will always be minerva-meta-data-issues-section-header regardless of
|
|
|
|
// namespace.
|
2018-08-17 19:00:57 +00:00
|
|
|
headingText = section === '0' || section === KEYWORD_ALL_SECTIONS ?
|
|
|
|
getNamespaceHeadingText( namespaceID ) :
|
2022-08-26 08:40:48 +00:00
|
|
|
mw.msg( 'minerva-meta-data-issues-section-header' );
|
2018-08-17 19:00:57 +00:00
|
|
|
|
2018-11-24 01:49:47 +00:00
|
|
|
overlay = new Overlay( {
|
2018-11-22 19:10:40 +00:00
|
|
|
className: 'overlay overlay-issues',
|
2018-10-10 21:49:25 +00:00
|
|
|
heading: '<strong>' + headingText + '</strong>'
|
|
|
|
} );
|
2018-08-16 19:00:38 +00:00
|
|
|
|
2019-02-15 19:04:11 +00:00
|
|
|
overlay.$el.find( '.overlay-content' ).append(
|
2018-11-24 01:49:47 +00:00
|
|
|
new IssueList( issues ).$el
|
|
|
|
);
|
|
|
|
return overlay;
|
|
|
|
}
|
2018-08-17 19:00:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain a suitable heading for the issues overlay based on the namespace
|
2020-06-02 21:21:44 +00:00
|
|
|
*
|
2018-08-17 19:00:57 +00:00
|
|
|
* @param {number} namespaceID is the namespace to generate heading for
|
|
|
|
* @return {string} heading for overlay
|
|
|
|
*/
|
|
|
|
function getNamespaceHeadingText( namespaceID ) {
|
|
|
|
switch ( namespaceID ) {
|
|
|
|
case NS_CATEGORY:
|
|
|
|
return mw.msg( 'mobile-frontend-meta-data-issues-categories' );
|
|
|
|
case NS_MAIN:
|
|
|
|
return mw.msg( 'mobile-frontend-meta-data-issues' );
|
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-02 21:10:10 +00:00
|
|
|
module.exports = pageIssuesOverlay;
|
2019-09-27 18:53:01 +00:00
|
|
|
|
|
|
|
// eslint-disable-next-line no-restricted-properties
|
2022-08-26 08:40:48 +00:00
|
|
|
}( mw.mobileFrontend ) );
|