diff --git a/includes/Skins/ToggleList/ToggleList.js b/includes/Skins/ToggleList/ToggleList.js index 59ebf87e9..cc30e80ee 100644 --- a/includes/Skins/ToggleList/ToggleList.js +++ b/includes/Skins/ToggleList/ToggleList.js @@ -1,34 +1,32 @@ -( function () { +const + checkboxHack = require( ( 'mediawiki.page.ready' ) ).checkboxHack, + CHECKBOX_HACK_CONTAINER_SELECTOR = '.toggle-list', + CHECKBOX_HACK_CHECKBOX_SELECTOR = '.toggle-list__checkbox', + CHECKBOX_HACK_BUTTON_SELECTOR = '.toggle-list__toggle', + CHECKBOX_HACK_TARGET_SELECTOR = '.toggle-list__list'; + +/** + * Automatically dismiss the list when clicking or focusing elsewhere and update the + * aria-expanded attribute based on list visibility. + * + * @param {Window} window + * @param {HTMLElement} component + */ +function bind( window, component ) { const - checkboxHack = require( ( 'mediawiki.page.ready' ) ).checkboxHack, - CHECKBOX_HACK_CONTAINER_SELECTOR = '.toggle-list', - CHECKBOX_HACK_CHECKBOX_SELECTOR = '.toggle-list__checkbox', - CHECKBOX_HACK_BUTTON_SELECTOR = '.toggle-list__toggle', - CHECKBOX_HACK_TARGET_SELECTOR = '.toggle-list__list'; + checkbox = /** @type {HTMLInputElement} */ ( + component.querySelector( CHECKBOX_HACK_CHECKBOX_SELECTOR ) + ), + button = component.querySelector( CHECKBOX_HACK_BUTTON_SELECTOR ), + target = component.querySelector( CHECKBOX_HACK_TARGET_SELECTOR ).parentNode; - /** - * Automatically dismiss the list when clicking or focusing elsewhere and update the - * aria-expanded attribute based on list visibility. - * - * @param {Window} window - * @param {HTMLElement} component - */ - function bind( window, component ) { - const - checkbox = /** @type {HTMLInputElement} */ ( - component.querySelector( CHECKBOX_HACK_CHECKBOX_SELECTOR ) - ), - button = component.querySelector( CHECKBOX_HACK_BUTTON_SELECTOR ), - target = component.querySelector( CHECKBOX_HACK_TARGET_SELECTOR ).parentNode; - - if ( !( checkbox && button && target ) ) { - return; - } - checkboxHack.bind( window, checkbox, button, target ); + if ( !( checkbox && button && target ) ) { + return; } + checkboxHack.bind( window, checkbox, button, target ); +} - module.exports = Object.freeze( { - selector: CHECKBOX_HACK_CONTAINER_SELECTOR, - bind - } ); -}() ); +module.exports = Object.freeze( { + selector: CHECKBOX_HACK_CONTAINER_SELECTOR, + bind +} ); diff --git a/resources/.eslintrc.json b/resources/.eslintrc.json index 1e8a0414a..288ceec16 100644 --- a/resources/.eslintrc.json +++ b/resources/.eslintrc.json @@ -15,6 +15,7 @@ "jsdoc/no-undefined-types": "off", "max-len": "error", "mediawiki/class-doc": "off", + "no-implicit-globals": "off", "no-restricted-properties": [ "error", { diff --git a/resources/skins.minerva.scripts/page-issues/page/PageIssueLearnMoreLink.js b/resources/skins.minerva.scripts/page-issues/page/PageIssueLearnMoreLink.js index e58f43d17..a82b8dc16 100644 --- a/resources/skins.minerva.scripts/page-issues/page/PageIssueLearnMoreLink.js +++ b/resources/skins.minerva.scripts/page-issues/page/PageIssueLearnMoreLink.js @@ -1,15 +1,15 @@ -( function () { - /** - * Creates a "read more" button with given text. - * - * @param {string} msg - * @return {jQuery} - */ - function newPageIssueLearnMoreLink( msg ) { - return $( '' ) - .addClass( 'ambox-learn-more' ) - .text( msg ); - } +/** + * Creates a "read more" button with given text. + * + * @internal + * @ignore + * @param {string} msg + * @return {jQuery} + */ +function newPageIssueLearnMoreLink( msg ) { + return $( '' ) + .addClass( 'ambox-learn-more' ) + .text( msg ); +} - module.exports = newPageIssueLearnMoreLink; -}() ); +module.exports = newPageIssueLearnMoreLink; diff --git a/resources/skins.minerva.scripts/page-issues/page/PageIssueLink.js b/resources/skins.minerva.scripts/page-issues/page/PageIssueLink.js index d2db46c62..1fd17e33b 100644 --- a/resources/skins.minerva.scripts/page-issues/page/PageIssueLink.js +++ b/resources/skins.minerva.scripts/page-issues/page/PageIssueLink.js @@ -1,13 +1,13 @@ -( function () { - /** - * Create a link element that opens the issues overlay. - * - * @param {string} labelText The text value of the element - * @return {jQuery} - */ - function newPageIssueLink( labelText ) { - return $( '' ).addClass( 'cleanup mw-mf-cleanup' ).text( labelText ); - } +/** + * Create a link element that opens the issues overlay. + * + * @internal + * @ignore + * @param {string} labelText The text value of the element + * @return {jQuery} + */ +function newPageIssueLink( labelText ) { + return $( '' ).addClass( 'cleanup mw-mf-cleanup' ).text( labelText ); +} - module.exports = newPageIssueLink; -}() ); +module.exports = newPageIssueLink; diff --git a/resources/skins.minerva.scripts/page-issues/page/pageIssueFormatter.js b/resources/skins.minerva.scripts/page-issues/page/pageIssueFormatter.js index c11129f9a..8b9990067 100644 --- a/resources/skins.minerva.scripts/page-issues/page/pageIssueFormatter.js +++ b/resources/skins.minerva.scripts/page-issues/page/pageIssueFormatter.js @@ -1,50 +1,52 @@ -( function () { - const newPageIssueLink = require( './PageIssueLink.js' ); - const newPageIssueLearnMoreLink = require( './PageIssueLearnMoreLink.js' ); +const newPageIssueLink = require( './PageIssueLink.js' ); +const newPageIssueLearnMoreLink = require( './PageIssueLearnMoreLink.js' ); - /** - * 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 ) { - 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; +/** + * 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; - $issueContainer.prepend( issue.issue.iconElement ); - $issueContainer.prepend( $learnMoreEl ); + $issueContainer.prepend( issue.issue.iconElement ); + $issueContainer.prepend( $learnMoreEl ); - $clickContainer.on( 'click', () => { - overlayManager.router.navigate( overlayUrl ); - return false; - } ); - } + $clickContainer.on( 'click', () => { + 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". - * Used on category namespaces, or when page-issue banners have been disabled. - * - * @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' ) ); - } +/** + * 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' ) ); +} - module.exports = { - insertPageIssueBanner, - insertPageIssueNotice - }; -}() ); +module.exports = { + insertPageIssueBanner, + insertPageIssueNotice +};