mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-15 18:40:05 +00:00
34 lines
668 B
JavaScript
34 lines
668 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
|
|
tables = bodyContent.querySelectorAll( 'table' );
|
|
|
|
tables.forEach( ( table ) => {
|
|
wrapTable( table );
|
|
} );
|
|
}
|
|
|
|
module.exports = {
|
|
init: init
|
|
};
|