-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Style: Allow tables to overflow for reponsiveness by wrapping w/JS
- Loading branch information
1 parent
cb01bd4
commit 8d2fcab
Showing
4 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Wrap the tables in PEP bodies in a div, to allow for responsive scrolling | ||
|
||
"use strict"; | ||
|
||
const pepContentId = "pep-content"; | ||
|
||
|
||
// Wrap passed table element in wrapper divs | ||
function wrapTable (table) { | ||
const wrapper = document.createElement("div"); | ||
wrapper.classList.add("table-wrapper"); | ||
table.parentNode.insertBefore(wrapper, table); | ||
wrapper.appendChild(table); | ||
} | ||
|
||
|
||
// Wrap all tables in the PEP content in wrapper divs | ||
function wrapPepContentTables () { | ||
const pepContent = document.getElementById(pepContentId); | ||
const bodyTables = pepContent.getElementsByTagName("table"); | ||
Array.from(bodyTables).forEach(wrapTable); | ||
} | ||
|
||
|
||
// Wrap the tables as soon as the DOM is loaded | ||
document.addEventListener("DOMContentLoaded", () => { | ||
if (document.getElementById(pepContentId)) { | ||
wrapPepContentTables(); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters