feat(core): add config to change overflow inherited classes

This commit is contained in:
alistair3149 2024-05-27 17:16:23 -04:00
parent c9210bd0dd
commit 974e6b2750
No known key found for this signature in database
5 changed files with 18 additions and 3 deletions

View file

@ -121,6 +121,7 @@ Name | Description | Values | Default
`$wgCitizenEnableARFonts` | Enable included Noto Naskh Arabic for wikis that serve Arabic | `true` - enable; `false` - disable | `false` `$wgCitizenEnableARFonts` | Enable included Noto Naskh Arabic for wikis that serve Arabic | `true` - enable; `false` - disable | `false`
`$wgCitizenEnableCJKFonts` | Enable included Noto Sans CJK for wikis that serves CJK languages | `true` - enable; `false` - disable | `false` `$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` `$wgCitizenEnablePreferences` | Enable the preferences menu | `true` - enable; `false` - disable | `true`
`$wgCitizenOverflowInheritedClasses` | Defines css classes inherited by the overflow wrapper | List of css classes. Extend with `$wgCitizenOverflowInheritedClasses[] = 'my_class';` | `["floatleft", "floatright" ]`
`$wgCitizenOverflowNowrapClasses` | Defines css classes ignored by the overflow wrapper | List of css classes. Extend with `$wgCitizenOverflowNowrapClasses[] = 'my_class';` | `["citizen-table-nowrap", "diff", "mw-changeslist-line", "mw-recentchanges-table", "infobox", "cargoDynamicTable", "dataTable", "srf-datatable", "smw-datatable", "mw-capiunto-infobox" ]` `$wgCitizenOverflowNowrapClasses` | Defines css classes ignored by the overflow wrapper | List of css classes. Extend with `$wgCitizenOverflowNowrapClasses[] = 'my_class';` | `["citizen-table-nowrap", "diff", "mw-changeslist-line", "mw-recentchanges-table", "infobox", "cargoDynamicTable", "dataTable", "srf-datatable", "smw-datatable", "mw-capiunto-infobox" ]`
### Search suggestions ### Search suggestions

View file

@ -47,6 +47,7 @@ class ResourceLoaderHooks {
) { ) {
return [ return [
'wgCitizenEnablePreferences' => $config->get( 'CitizenEnablePreferences' ), 'wgCitizenEnablePreferences' => $config->get( 'CitizenEnablePreferences' ),
'wgCitizenOverflowInheritedClasses' => $config->get( 'CitizenOverflowInheritedClasses' ),
'wgCitizenOverflowNowrapClasses' => $config->get( 'CitizenOverflowNowrapClasses' ), 'wgCitizenOverflowNowrapClasses' => $config->get( 'CitizenOverflowNowrapClasses' ),
'wgCitizenSearchModule' => $config->get( 'CitizenSearchModule' ) 'wgCitizenSearchModule' => $config->get( 'CitizenSearchModule' )
]; ];

View file

@ -98,10 +98,10 @@ class OverflowElement {
/** /**
* Filters and adds inherited classes to the wrapper element. * Filters and adds inherited classes to the wrapper element.
* *
* @param {Array} inheritedClasses - An array of inherited classes to handle.
* @return {void} * @return {void}
*/ */
handleInheritedClasses( inheritedClasses ) { handleInheritedClasses() {
const inheritedClasses = config.wgCitizenOverflowInheritedClasses;
const filteredClasses = inheritedClasses.filter( ( cls ) => this.element.classList.contains( cls ) ); const filteredClasses = inheritedClasses.filter( ( cls ) => this.element.classList.contains( cls ) );
filteredClasses.forEach( ( cls ) => { filteredClasses.forEach( ( cls ) => {
@ -146,7 +146,7 @@ class OverflowElement {
const wrapper = document.createElement( 'div' ); const wrapper = document.createElement( 'div' );
wrapper.className = 'citizen-overflow-wrapper'; wrapper.className = 'citizen-overflow-wrapper';
this.handleInheritedClasses( [ 'floatleft', 'floatright' ] ); this.handleInheritedClasses();
parentNode.insertBefore( wrapper, this.element ); parentNode.insertBefore( wrapper, this.element );
wrapper.appendChild( this.element ); wrapper.appendChild( this.element );

View file

@ -687,6 +687,15 @@
"descriptionmsg": "citizen-config-enablepreferences", "descriptionmsg": "citizen-config-enablepreferences",
"public": true "public": true
}, },
"OverflowInheritedClasses": {
"value": [
"floatleft",
"floatright"
],
"description": "Defines css classes inherited by overflow wrapper",
"descriptionmsg": "citizen-config-overflowinheritedclasses",
"public": true
},
"OverflowNowrapClasses": { "OverflowNowrapClasses": {
"value": [ "value": [
"citizen-table-nowrap", "citizen-table-nowrap",

View file

@ -19,6 +19,7 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
public function testCitizenResourceLoaderConfig() { public function testCitizenResourceLoaderConfig() {
$this->overrideConfigValues( [ $this->overrideConfigValues( [
'CitizenEnablePreferences' => false, 'CitizenEnablePreferences' => false,
'CitizenOverflowInheritedClasses' => false,
'CitizenOverflowNowrapClasses' => false, 'CitizenOverflowNowrapClasses' => false,
'CitizenSearchModule' => false, 'CitizenSearchModule' => false,
] ); ] );
@ -33,6 +34,7 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
$this->assertArraySubmapSame( [ $this->assertArraySubmapSame( [
'wgCitizenEnablePreferences' => false, 'wgCitizenEnablePreferences' => false,
'wgCitizenSearchModule' => false, 'wgCitizenSearchModule' => false,
'wgCitizenOverflowInheritedClasses' => false,
'wgCitizenOverflowNowrapClasses' => false, 'wgCitizenOverflowNowrapClasses' => false,
], $config ); ], $config );
} }
@ -44,6 +46,7 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
public function testCitizenResourceLoaderConfigAllTrue() { public function testCitizenResourceLoaderConfigAllTrue() {
$this->overrideConfigValues( [ $this->overrideConfigValues( [
'CitizenEnablePreferences' => true, 'CitizenEnablePreferences' => true,
'CitizenOverflowInheritedClasses' => true,
'CitizenOverflowNowrapClasses' => true, 'CitizenOverflowNowrapClasses' => true,
'CitizenSearchModule' => true, 'CitizenSearchModule' => true,
] ); ] );
@ -57,6 +60,7 @@ class ResourceLoaderHooksTest extends MediaWikiIntegrationTestCase {
$this->assertArraySubmapSame( [ $this->assertArraySubmapSame( [
'wgCitizenEnablePreferences' => true, 'wgCitizenEnablePreferences' => true,
'whCitizenOverflowInheritedClasses' => true,
'wgCitizenOverflowNowrapClasses' => true, 'wgCitizenOverflowNowrapClasses' => true,
'wgCitizenSearchModule' => true, 'wgCitizenSearchModule' => true,
], $config ); ], $config );