murph-skeleton/assets/js/admin/modules/table-fixed.js

25 lines
479 B
JavaScript
Raw Normal View History

2021-06-15 14:16:07 +02:00
const $ = require('jquery')
2021-03-24 12:27:07 +01:00
2021-06-15 14:16:07 +02:00
const resizeTbody = (tbody) => {
tbody.height($(window).height() - tbody.offset().top - 20)
2021-03-24 12:27:07 +01:00
}
2021-06-15 14:16:07 +02:00
const tableFixed = () => {
const tables = $('table[data-table-fixed], *[data-table-fixed] > table')
2021-03-24 12:27:07 +01:00
2021-06-15 14:16:07 +02:00
tables.each((i, t) => {
const table = $(t)
table.addClass('table-fixed')
2021-03-24 12:27:07 +01:00
2021-06-15 14:16:07 +02:00
const tbody = table.find('tbody')
2021-03-24 12:27:07 +01:00
2021-06-15 14:16:07 +02:00
resizeTbody(tbody)
2021-03-24 12:27:07 +01:00
2021-06-15 14:16:07 +02:00
$(window).resize(function () {
resizeTbody(tbody)
})
})
2021-03-24 12:27:07 +01:00
}
2021-06-15 14:16:07 +02:00
module.exports = tableFixed