mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-13 16:38:44 +00:00
503559a05c
Bug: T330527 Change-Id: I386a88481210f459d2174ff69e0f84d40fc9e3bd
26 lines
692 B
JavaScript
26 lines
692 B
JavaScript
const config = require( './config.json' );
|
|
const init = () => {
|
|
if ( !config.VectorWrapTablesTemporary ) {
|
|
return;
|
|
}
|
|
const tables = document.querySelectorAll( '.mw-parser-output table.wikitable:not(.floatright):not(.floatleft)' );
|
|
Array.from( tables ).forEach( ( table ) => {
|
|
// Don't wrap tables within tables
|
|
const parent = table.parentElement;
|
|
if (
|
|
parent && table.matches( '.wikitable' ) &&
|
|
!parent.matches( '.noresize' ) &&
|
|
!parent.closest( 'table' )
|
|
) {
|
|
const wrapper = document.createElement( 'div' );
|
|
wrapper.classList.add( 'noresize' );
|
|
parent.insertBefore( wrapper, table );
|
|
wrapper.appendChild( table );
|
|
}
|
|
} );
|
|
};
|
|
|
|
module.exports = {
|
|
init
|
|
};
|