2023-04-30 21:01:29 +00:00
|
|
|
/**
|
|
|
|
* Wrap table in div container to make it scrollable without breaking layout
|
2023-04-30 21:02:42 +00:00
|
|
|
*
|
2023-04-30 21:01:29 +00:00
|
|
|
* @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
|
|
|
|
};
|