mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-15 18:40:05 +00:00
35 lines
708 B
JavaScript
35 lines
708 B
JavaScript
|
/**
|
||
|
* Wrap table in div container to make it scrollable without breaking layout
|
||
|
*
|
||
|
* @param {HTMLTableElement} table
|
||
|
* @return {void}
|
||
|
*/
|
||
|
function wrapTable( table ) {
|
||
|
const wrapper = document.createElement( 'div' );
|
||
|
wrapper.classList.add( 'citizen-table-wrapper' );
|
||
|
table.parentNode.insertBefore( wrapper, table );
|
||
|
wrapper.appendChild( table );
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param {HTMLElement} bodyContent
|
||
|
* @return {void}
|
||
|
*/
|
||
|
function init( bodyContent ) {
|
||
|
if ( !bodyContent.querySelector( 'table' ) ) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
const
|
||
|
config = require( './config.json' ),
|
||
|
tables = bodyContent.querySelectorAll( 'table' );
|
||
|
|
||
|
tables.forEach( ( table ) => {
|
||
|
wrapTable( table );
|
||
|
} );
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
init: init
|
||
|
};
|