2024-08-30 10:49:35 +00:00
|
|
|
const newPageIssueLink = require( './PageIssueLink.js' );
|
|
|
|
const newPageIssueLearnMoreLink = require( './PageIssueLearnMoreLink.js' );
|
2019-01-23 20:16:11 +00:00
|
|
|
|
2024-08-30 10:49:35 +00:00
|
|
|
/**
|
|
|
|
* Modifies the `issue` DOM to create a banner designed for single / multiple issue templates,
|
|
|
|
* and handles event-binding for that issues overlay.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
* @ignore
|
|
|
|
* @param {IssueSummary} issue
|
|
|
|
* @param {string} msg
|
|
|
|
* @param {string} overlayUrl
|
|
|
|
* @param {Object} overlayManager
|
|
|
|
* @param {boolean} [multiple]
|
|
|
|
*/
|
|
|
|
function insertPageIssueBanner( issue, msg, overlayUrl, overlayManager, multiple ) {
|
|
|
|
const $learnMoreEl = newPageIssueLearnMoreLink( msg );
|
|
|
|
const $issueContainer = multiple ?
|
|
|
|
issue.$el.parents( '.mbox-text-span, .mbox-text-div' ) :
|
|
|
|
issue.$el.find( '.mbox-text' );
|
|
|
|
const $clickContainer = multiple ? issue.$el.parents( '.mbox-text' ) : issue.$el;
|
2019-01-23 20:16:11 +00:00
|
|
|
|
2024-08-30 10:49:35 +00:00
|
|
|
$issueContainer.prepend( issue.issue.iconElement );
|
|
|
|
$issueContainer.prepend( $learnMoreEl );
|
2019-01-23 20:16:11 +00:00
|
|
|
|
2024-08-30 10:49:35 +00:00
|
|
|
$clickContainer.on( 'click', () => {
|
|
|
|
overlayManager.router.navigate( overlayUrl );
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
}
|
2019-01-23 20:16:11 +00:00
|
|
|
|
2024-08-30 10:49:35 +00:00
|
|
|
/**
|
|
|
|
* Modifies the page DOM to insert a page-issue notice below the title of the page,
|
|
|
|
* containing a link with a message like "this page has issues".
|
|
|
|
* Used on category namespaces, or when page-issue banners have been disabled.
|
|
|
|
*
|
|
|
|
* @internal
|
|
|
|
* @ignore
|
|
|
|
* @param {string} labelText
|
|
|
|
* @param {string} section
|
|
|
|
*/
|
|
|
|
function insertPageIssueNotice( labelText, section ) {
|
|
|
|
const $link = newPageIssueLink( labelText );
|
|
|
|
$link.attr( 'href', '#/issues/' + section );
|
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
|
|
|
$link.insertAfter( $( 'h1.mw-first-heading' ) );
|
|
|
|
}
|
2019-01-23 20:16:11 +00:00
|
|
|
|
2024-08-30 10:49:35 +00:00
|
|
|
module.exports = {
|
|
|
|
insertPageIssueBanner,
|
|
|
|
insertPageIssueNotice
|
|
|
|
};
|