Debian Codegraph @

skins/MinervaNeue/resources/skins.minerva.scripts/page-issues/page/pageIssueFormatter.js

raw symbols SCIP
1 ( function () {
2 const newPageIssueLink = require( './PageIssueLink.js' );
3 const newPageIssueLearnMoreLink = require( './PageIssueLearnMoreLink.js' );
4
5 /**
6 * Modifies the `issue` DOM to create a banner designed for single / multiple issue templates,
7 * and handles event-binding for that issues overlay.
8 *
9 * @param {IssueSummary} issue
10 * @param {string} msg
11 * @param {string} overlayUrl
12 * @param {Object} overlayManager
13 * @param {boolean} [multiple]
14 */
15 function insertPageIssueBanner( issue, msg, overlayUrl, overlayManager, multiple ) {
16 const $learnMoreEl = newPageIssueLearnMoreLink( msg );
17 const $issueContainer = multiple ?
18 issue.$el.parents( '.mbox-text-span, .mbox-text-div' ) :
19 issue.$el.find( '.mbox-text' );
20 const $clickContainer = multiple ? issue.$el.parents( '.mbox-text' ) : issue.$el;
21
22 $issueContainer.prepend( issue.issue.iconElement );
23 $issueContainer.prepend( $learnMoreEl );
24
25 $clickContainer.on( 'click', () => {
26 overlayManager.router.navigate( overlayUrl );
27 return false;
28 } );
29 }
30
31 /**
32 * Modifies the page DOM to insert a page-issue notice below the title of the page,
33 * containing a link with a message like "this page has issues".
34 * Used on category namespaces, or when page-issue banners have been disabled.
35 *
36 * @param {string} labelText
37 * @param {string} section
38 */
39 function insertPageIssueNotice( labelText, section ) {
40 const $link = newPageIssueLink( labelText );
41 $link.attr( 'href', '#/issues/' + section );
42 // eslint-disable-next-line no-jquery/no-global-selector
43 $link.insertAfter( $( 'h1.mw-first-heading' ) );
44 }
45
46 module.exports = {
47 insertPageIssueBanner,
48 insertPageIssueNotice
49 };
50 }() );