From a7b99d11f082c559ce12e1caa70a7fc476ce92d5 Mon Sep 17 00:00:00 2001 From: Simon Stier <52674635+simontaurus@users.noreply.github.com> Date: Thu, 18 May 2023 19:53:58 +0200 Subject: [PATCH] feat(core): add config var 'wgCitizenTableNowrapClasses' (#621) * add config var 'wgCitizenTableNowrapClasses' * refactor: load config via require --- README.md | 1 + includes/Hooks/ResourceLoaderHooks.php | 1 + resources/skins.citizen.scripts/tables.js | 14 ++++---------- skin.json | 12 ++++++++++++ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 4f61030d..c822a2fc 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ Name | Description | Values | Default `$wgCitizenThemeColor` | The color defined in the `theme-color` meta tag | Hex color code | `#131a21` `$wgCitizenEnableCJKFonts` | Enable included Noto Sans CJK for wikis that serves CJK languages | `true` - enable; `false` - disable | `false` `$wgCitizenEnablePreferences` | Enable the preferences menu | `true` - enable; `false` - disable | `true` +`$wgCitizenTableNowrapClasses` | Defines table css classes ignored by citizen table wrapper | List of css classes. Extend with `$wgCitizenTableNowrapClasses[] = 'my_class';` | `["citizen-table-nowrap", "mw-changeslist-line", "infobox", "cargoDynamicTable", "dataTable"]` ### Search suggestions Name | Description | Values | Default diff --git a/includes/Hooks/ResourceLoaderHooks.php b/includes/Hooks/ResourceLoaderHooks.php index 446623f7..da98cd9b 100644 --- a/includes/Hooks/ResourceLoaderHooks.php +++ b/includes/Hooks/ResourceLoaderHooks.php @@ -47,6 +47,7 @@ class ResourceLoaderHooks { return [ 'wgCitizenEnablePreferences' => $config->get( 'CitizenEnablePreferences' ), 'wgCitizenSearchModule' => $config->get( 'CitizenSearchModule' ), + 'wgCitizenTableNowrapClasses' => $config->get( 'CitizenTableNowrapClasses' ), ]; } diff --git a/resources/skins.citizen.scripts/tables.js b/resources/skins.citizen.scripts/tables.js index d341daca..91661684 100644 --- a/resources/skins.citizen.scripts/tables.js +++ b/resources/skins.citizen.scripts/tables.js @@ -1,3 +1,5 @@ +const config = require( './config.json' ); + /** * Set up scroll affordance for an overflowed element * TODO: Move this out of tables when this is used by more stuff @@ -60,16 +62,8 @@ function setupOverflowState( element ) { * @return {void} */ function wrapTable( table ) { - // TODO: Make this a config flag - const ignoredClasses = [ - 'citizen-table-nowrap', - 'mw-changeslist-line', - 'infobox', - // Extension:Cargo - // dataTable from Extension:Cargo and some other has issue with the wrapper - 'cargoDynamicTable', - 'dataTable' - ]; + // Load ignored classes from config + const ignoredClasses = config.wgCitizenTableNowrapClasses; // Check table and parent for ignored classes const hasIgnoredClass = ( ignoreClass ) => { diff --git a/skin.json b/skin.json index 44f1fc78..612d05b4 100644 --- a/skin.json +++ b/skin.json @@ -604,6 +604,18 @@ "description": "Enables or disable preferences module", "descriptionmsg": "citizen-config-enablepreferences", "public": true + }, + "TableNowrapClasses": { + "value": [ + "citizen-table-nowrap", + "mw-changeslist-line", + "infobox", + "cargoDynamicTable", + "dataTable" + ], + "description": "Defines table css classes ignored by citizen table wrapper", + "descriptionmsg": "citizen-config-tablenowrapclasses", + "public": true } }, "manifest_version": 2