2019-07-02 21:10:10 +00:00
|
|
|
( function () {
|
2019-01-23 20:16:11 +00:00
|
|
|
var
|
2019-07-02 21:10:10 +00:00
|
|
|
newPageIssueLink = require( './PageIssueLink.js' ),
|
|
|
|
newPageIssueLearnMoreLink = require( './PageIssueLearnMoreLink.js' );
|
2019-01-23 20:16:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifies the `issue` DOM to create a banner designed for single / multiple issue templates,
|
|
|
|
* and handles event-binding for that issues overlay.
|
|
|
|
*
|
|
|
|
* @param {IssueSummary} issue
|
|
|
|
* @param {string} msg
|
|
|
|
* @param {string} overlayUrl
|
|
|
|
* @param {Object} overlayManager
|
|
|
|
* @param {boolean} [multiple]
|
|
|
|
*/
|
|
|
|
function insertPageIssueBanner( issue, msg, overlayUrl, overlayManager, multiple ) {
|
|
|
|
var $learnMoreEl = newPageIssueLearnMoreLink( msg ),
|
|
|
|
$issueContainer = multiple ?
|
|
|
|
issue.$el.parents( '.mbox-text-span, .mbox-text-div' ) :
|
|
|
|
issue.$el.find( '.mbox-text' ),
|
|
|
|
$clickContainer = multiple ? issue.$el.parents( '.mbox-text' ) : issue.$el;
|
|
|
|
|
2019-08-30 17:23:55 +00:00
|
|
|
$issueContainer.prepend(
|
2023-08-04 16:46:36 +00:00
|
|
|
issue.issue.icon.$el.clone().addClass( 'mf-icon--small' )
|
2019-08-30 17:23:55 +00:00
|
|
|
);
|
2019-01-23 20:16:11 +00:00
|
|
|
$issueContainer.prepend( $learnMoreEl );
|
|
|
|
|
|
|
|
$clickContainer.on( 'click', function () {
|
|
|
|
overlayManager.router.navigate( overlayUrl );
|
|
|
|
return false;
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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".
|
2022-10-02 12:44:18 +00:00
|
|
|
* Used on category namespaces, or when page-issue banners have been disabled.
|
2019-01-23 20:16:11 +00:00
|
|
|
*
|
|
|
|
* @param {string} labelText
|
|
|
|
* @param {string} section
|
|
|
|
*/
|
|
|
|
function insertPageIssueNotice( labelText, section ) {
|
|
|
|
var $link = newPageIssueLink( labelText );
|
|
|
|
$link.attr( 'href', '#/issues/' + section );
|
2019-04-03 23:32:18 +00:00
|
|
|
// eslint-disable-next-line no-jquery/no-global-selector
|
2022-04-01 15:23:00 +00:00
|
|
|
$link.insertAfter( $( 'h1.mw-first-heading' ) );
|
2019-01-23 20:16:11 +00:00
|
|
|
}
|
|
|
|
|
2019-07-02 21:10:10 +00:00
|
|
|
module.exports = {
|
2019-01-23 20:16:11 +00:00
|
|
|
insertPageIssueBanner: insertPageIssueBanner,
|
|
|
|
insertPageIssueNotice: insertPageIssueNotice
|
2019-07-02 21:10:10 +00:00
|
|
|
};
|
|
|
|
}() );
|