mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 07:43:47 +00:00
711f67ce00
Bug: T366314 Change-Id: I71657b7f1f26bcf52f5ade5b7668955a1f4df24b
30 lines
808 B
JavaScript
30 lines
808 B
JavaScript
const config = require( './config.json' );
|
|
const init = () => {
|
|
if ( !config.VectorWrapTablesTemporary ) {
|
|
return;
|
|
}
|
|
const tables = document.querySelectorAll( '.mw-parser-output table.wikitable' );
|
|
Array.from( tables ).forEach( ( table ) => {
|
|
const styles = window.getComputedStyle( table );
|
|
const isFloat = styles.getPropertyValue( 'float' ) === 'right' || styles.getPropertyValue( 'float' ) === 'left';
|
|
|
|
// Don't wrap tables within tables
|
|
const parent = table.parentElement;
|
|
if (
|
|
parent &&
|
|
!parent.matches( '.noresize' ) &&
|
|
!parent.closest( 'table' ) &&
|
|
!isFloat
|
|
) {
|
|
const wrapper = document.createElement( 'div' );
|
|
wrapper.classList.add( 'noresize' );
|
|
parent.insertBefore( wrapper, table );
|
|
wrapper.appendChild( table );
|
|
}
|
|
} );
|
|
};
|
|
|
|
module.exports = {
|
|
init
|
|
};
|