From 70f030c5f2d223078c2cedfdc8264717c953acf8 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 31 Dec 2022 05:14:53 +0000 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=91=B7=20lint=20code=20to=20MediaWi?= =?UTF-8?q?ki=20standards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check commit and GitHub actions for more details --- resources/skins.citizen.scripts/skin.js | 246 +++++++++--------- .../ext.PortableInfobox.styles.less | 2 +- 2 files changed, 124 insertions(+), 124 deletions(-) diff --git a/resources/skins.citizen.scripts/skin.js b/resources/skins.citizen.scripts/skin.js index c3d4d6508..33dbd67d9 100644 --- a/resources/skins.citizen.scripts/skin.js +++ b/resources/skins.citizen.scripts/skin.js @@ -1,8 +1,8 @@ -const checkboxHack = require('./checkboxHack.js'), - CHECKBOX_HACK_CONTAINER_SELECTOR = '.mw-checkbox-hack-container', - CHECKBOX_HACK_CHECKBOX_SELECTOR = '.mw-checkbox-hack-checkbox', - CHECKBOX_HACK_BUTTON_SELECTOR = '.mw-checkbox-hack-button', - CHECKBOX_HACK_TARGET_SELECTOR = '.mw-checkbox-hack-target' +const checkboxHack = require( './checkboxHack.js' ), + CHECKBOX_HACK_CONTAINER_SELECTOR = '.mw-checkbox-hack-container', + CHECKBOX_HACK_CHECKBOX_SELECTOR = '.mw-checkbox-hack-checkbox', + CHECKBOX_HACK_BUTTON_SELECTOR = '.mw-checkbox-hack-button', + CHECKBOX_HACK_TARGET_SELECTOR = '.mw-checkbox-hack-target'; /** * Wait for first paint before calling this function. @@ -11,8 +11,8 @@ const checkboxHack = require('./checkboxHack.js'), * @param {Document} document * @return {void} */ -function enableCssAnimations(document) { - document.documentElement.classList.add('citizen-animations-ready') +function enableCssAnimations( document ) { + document.documentElement.classList.add( 'citizen-animations-ready' ); } /** @@ -24,20 +24,20 @@ function enableCssAnimations(document) { * @return {void} */ function bind() { - // Search for all dropdown containers using the CHECKBOX_HACK_CONTAINER_SELECTOR. - const containers = document.querySelectorAll(CHECKBOX_HACK_CONTAINER_SELECTOR) + // Search for all dropdown containers using the CHECKBOX_HACK_CONTAINER_SELECTOR. + const containers = document.querySelectorAll( CHECKBOX_HACK_CONTAINER_SELECTOR ); - containers.forEach((container) => { - const checkbox = container.querySelector(CHECKBOX_HACK_CHECKBOX_SELECTOR), - button = container.querySelector(CHECKBOX_HACK_BUTTON_SELECTOR), - target = container.querySelector(CHECKBOX_HACK_TARGET_SELECTOR) + containers.forEach( ( container ) => { + const checkbox = container.querySelector( CHECKBOX_HACK_CHECKBOX_SELECTOR ), + button = container.querySelector( CHECKBOX_HACK_BUTTON_SELECTOR ), + target = container.querySelector( CHECKBOX_HACK_TARGET_SELECTOR ); - if (!(checkbox && button && target)) { - return - } + if ( !( checkbox && button && target ) ) { + return; + } - checkboxHack.bind(window, checkbox, button, target) - }) + checkboxHack.bind( window, checkbox, button, target ); + } ); } /** @@ -46,13 +46,13 @@ function bind() { * @return {void} */ function uncheckCheckboxHacks() { - const checkboxes = document.querySelectorAll( - CHECKBOX_HACK_CHECKBOX_SELECTOR + ':checked' - ) + const checkboxes = document.querySelectorAll( + CHECKBOX_HACK_CHECKBOX_SELECTOR + ':checked' + ); - checkboxes.forEach((checkbox) => { - /** @type {HTMLInputElement} */ ;(checkbox).checked = false - }) + checkboxes.forEach( ( checkbox ) => { + /** @type {HTMLInputElement} */ ( checkbox ).checked = false; + } ); } /** @@ -61,43 +61,43 @@ function uncheckCheckboxHacks() { * @param {Document} document * @return {void} */ -function initStickyHeader(document) { - const scrollObserver = require('./scrollObserver.js') - - // Detect scroll direction and add the right class - scrollObserver.initDirectionObserver( - () => { - document.body.classList.remove('citizen-scroll--up') - document.body.classList.add('citizen-scroll--down') - }, - () => { - document.body.classList.remove('citizen-scroll--down') - document.body.classList.add('citizen-scroll--up') - }, - 10 - ) - - const sentinel = document.getElementById( - 'citizen-body-header-sticky-sentinel' - ) - - // In some pages we use display:none to disable the sticky header - // Do not start observer if it is set to display:none - if ( - sentinel && - getComputedStyle(sentinel).getPropertyValue('display') !== 'none' - ) { - const observer = scrollObserver.initIntersectionObserver( - () => { - document.body.classList.add('citizen-body-header--sticky') - }, - () => { - document.body.classList.remove('citizen-body-header--sticky') - } - ) - - observer.observe(sentinel) - } +function initStickyHeader( document ) { + const scrollObserver = require( './scrollObserver.js' ); + + // Detect scroll direction and add the right class + scrollObserver.initDirectionObserver( + () => { + document.body.classList.remove( 'citizen-scroll--up' ); + document.body.classList.add( 'citizen-scroll--down' ); + }, + () => { + document.body.classList.remove( 'citizen-scroll--down' ); + document.body.classList.add( 'citizen-scroll--up' ); + }, + 10 + ); + + const sentinel = document.getElementById( + 'citizen-body-header-sticky-sentinel' + ); + + // In some pages we use display:none to disable the sticky header + // Do not start observer if it is set to display:none + if ( + sentinel && + getComputedStyle( sentinel ).getPropertyValue( 'display' ) !== 'none' + ) { + const observer = scrollObserver.initIntersectionObserver( + () => { + document.body.classList.add( 'citizen-body-header--sticky' ); + }, + () => { + document.body.classList.remove( 'citizen-body-header--sticky' ); + } + ); + + observer.observe( sentinel ); + } } /** @@ -106,83 +106,83 @@ function initStickyHeader(document) { * @return {void} */ function registerServiceWorker() { - const scriptPath = mw.config.get('wgScriptPath') - - // Only allow serviceWorker when the scriptPath is at root because of its scope - // I can't figure out how to add the Service-Worker-Allowed HTTP header - // to change the default scope - if (scriptPath === '') { - if ('serviceWorker' in navigator) { - const SW_MODULE_NAME = 'skins.citizen.serviceWorker', - version = mw.loader.moduleRegistry[SW_MODULE_NAME].version, - // HACK: Faking a RL link - swUrl = + const scriptPath = mw.config.get( 'wgScriptPath' ); + + // Only allow serviceWorker when the scriptPath is at root because of its scope + // I can't figure out how to add the Service-Worker-Allowed HTTP header + // to change the default scope + if ( scriptPath === '' ) { + if ( 'serviceWorker' in navigator ) { + const SW_MODULE_NAME = 'skins.citizen.serviceWorker', + version = mw.loader.moduleRegistry[ SW_MODULE_NAME ].version, + // HACK: Faking a RL link + swUrl = scriptPath + '/load.php?modules=' + SW_MODULE_NAME + '&only=scripts&raw=true&skin=citizen&version=' + - version + version; - navigator.serviceWorker.register(swUrl, { scope: '/' }) - } - } + navigator.serviceWorker.register( swUrl, { scope: '/' } ); + } + } } /** * @param {Window} window * @return {void} */ -function main(window) { - const search = require('./search.js') - - enableCssAnimations(window.document) - search.init(window) - initStickyHeader(window.document) - - // Set up checkbox hacks - bind() - - // Table of Contents - const tocContainer = document.getElementById('mw-panel-toc') - if (tocContainer) { - const toc = require('./tableOfContents.js') - toc.init() - } - - // Collapsible sections - if (document.body.classList.contains('citizen-sections-enabled')) { - const sections = require('./sections.js') - sections.init() - } - - mw.loader.load('skins.citizen.preferences') - mw.loader.load('https://story-cdn.teahouse.team/t-footer/assets/index.js') - mw.loader.load( - 'https://story-cdn.teahouse.team/t-footer/assets/index.css', - 'text/css' - ) - registerServiceWorker() - - window.addEventListener( - 'beforeunload', - () => { - // T295085: Close all dropdown menus when page is unloaded to prevent them - // from being open when navigating back to a page. - uncheckCheckboxHacks() - // Set up loading indicator - document.documentElement.classList.add('citizen-loading') - }, - false - ) +function main( window ) { + const search = require( './search.js' ); + + enableCssAnimations( window.document ); + search.init( window ); + initStickyHeader( window.document ); + + // Set up checkbox hacks + bind(); + + // Table of Contents + const tocContainer = document.getElementById( 'mw-panel-toc' ); + if ( tocContainer ) { + const toc = require( './tableOfContents.js' ); + toc.init(); + } + + // Collapsible sections + if ( document.body.classList.contains( 'citizen-sections-enabled' ) ) { + const sections = require( './sections.js' ); + sections.init(); + } + + mw.loader.load( 'skins.citizen.preferences' ); + mw.loader.load( 'https://story-cdn.teahouse.team/t-footer/assets/index.js' ); + mw.loader.load( + 'https://story-cdn.teahouse.team/t-footer/assets/index.css', + 'text/css' + ); + registerServiceWorker(); + + window.addEventListener( + 'beforeunload', + () => { + // T295085: Close all dropdown menus when page is unloaded to prevent them + // from being open when navigating back to a page. + uncheckCheckboxHacks(); + // Set up loading indicator + document.documentElement.classList.add( 'citizen-loading' ); + }, + false + ); } if ( - document.readyState === 'interactive' || + document.readyState === 'interactive' || document.readyState === 'complete' ) { - main(window) + main( window ); } else { - document.addEventListener('DOMContentLoaded', function () { - main(window) - }) + document.addEventListener( 'DOMContentLoaded', function () { + main( window ); + } ); } diff --git a/skinStyles/extensions/PortableInfobox/ext.PortableInfobox.styles.less b/skinStyles/extensions/PortableInfobox/ext.PortableInfobox.styles.less index 7a71837f8..0ea23ecb3 100644 --- a/skinStyles/extensions/PortableInfobox/ext.PortableInfobox.styles.less +++ b/skinStyles/extensions/PortableInfobox/ext.PortableInfobox.styles.less @@ -28,9 +28,9 @@ .portable-infobox { /* In case if tooltips go out of boundary */ overflow: visible; + border-radius: var( --border-radius--medium ); /* @noflip */ margin-left: 1.4rem; - border-radius: var( --border-radius--medium ); font-size: 0.875rem; .boxshadow( 2 );