Fix mobile layout; scroll tables themselves, not cards
This commit is contained in:
23
web/src/main/resources/static/js/table-scroll.js
Normal file
23
web/src/main/resources/static/js/table-scroll.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/* Прокрутка только самой таблицы, а не всей карточки.
|
||||
Оборачиваем таблицы в .table-scroll-box; таблицы в markdown-статьях
|
||||
уже обёрнуты сервером (.table-scroll) и пропускаются. */
|
||||
(function () {
|
||||
function wrap(table) {
|
||||
if (table.closest('.table-scroll, .table-scroll-box')) return;
|
||||
if (table.closest('.md-body')) return;
|
||||
var box = document.createElement('div');
|
||||
box.className = 'table-scroll-box';
|
||||
table.parentNode.insertBefore(box, table);
|
||||
box.appendChild(table);
|
||||
}
|
||||
|
||||
function ready() {
|
||||
document.querySelectorAll('table').forEach(wrap);
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', ready);
|
||||
} else {
|
||||
ready();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user