Skip to content

Commit

Permalink
feat(core): add config var 'wgCitizenTableNowrapClasses' (#621)
Browse files Browse the repository at this point in the history
* add config var 'wgCitizenTableNowrapClasses'
* refactor: load config via require
  • Loading branch information
simontaurus committed May 18, 2023
1 parent 0fb2738 commit a7b99d1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions includes/Hooks/ResourceLoaderHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static function getCitizenResourceLoaderConfig(
return [
'wgCitizenEnablePreferences' => $config->get( 'CitizenEnablePreferences' ),
'wgCitizenSearchModule' => $config->get( 'CitizenSearchModule' ),
'wgCitizenTableNowrapClasses' => $config->get( 'CitizenTableNowrapClasses' ),
];
}

Expand Down
14 changes: 4 additions & 10 deletions resources/skins.citizen.scripts/tables.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 ) => {
Expand Down
12 changes: 12 additions & 0 deletions skin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7b99d1

Please sign in to comment.