update
This commit is contained in:
parent
f1088f1188
commit
5e8de44507
|
|
@ -3111,6 +3111,69 @@ $(document).ready(function () {
|
|||
fixSortLinkA11y();
|
||||
fixSearchInputA11y();
|
||||
}, 500);
|
||||
});
|
||||
function fixUniversalTableA11y() {
|
||||
setTimeout(function () {
|
||||
|
||||
$('.universal-table-show .table-content table').each(function () {
|
||||
var $table = $(this);
|
||||
|
||||
// 為外層表格加上 caption(若尚未有)
|
||||
if ($table.find('caption').length === 0) {
|
||||
$table.prepend('<caption class="sr-only">計畫成員資料表</caption>');
|
||||
}
|
||||
|
||||
$table.find('tbody tr').each(function () {
|
||||
var $tr = $(this);
|
||||
var $cells = $tr.find('td');
|
||||
|
||||
// 每行結構:角色td、資料td、角色td、資料td、角色td、資料td(共6欄)
|
||||
$cells.each(function (index) {
|
||||
var $cell = $(this);
|
||||
var cellText = $cell.text().trim();
|
||||
|
||||
// 判斷是否為標題欄(奇數欄 0、2、4)
|
||||
var isHeaderCell = (index % 2 === 0);
|
||||
|
||||
if (isHeaderCell && cellText !== '' && cellText !== '\u00a0') {
|
||||
// 產生唯一 id:row + rowIndex + col + colIndex
|
||||
var rowIndex = $tr.index();
|
||||
var colIndex = index;
|
||||
var headerId = 'member-header-r' + rowIndex + '-c' + colIndex;
|
||||
|
||||
// 將 td 替換為 th
|
||||
var $th = $('<th>')
|
||||
.attr({
|
||||
'scope': 'row',
|
||||
'id': headerId
|
||||
})
|
||||
.html($cell.html());
|
||||
|
||||
// 複製原有 style/class
|
||||
if ($cell.attr('style')) $th.attr('style', $cell.attr('style'));
|
||||
if ($cell.attr('class')) $th.attr('class', $cell.attr('class'));
|
||||
|
||||
$cell.replaceWith($th);
|
||||
|
||||
} else if (!isHeaderCell) {
|
||||
// 資料欄:找對應的 th id
|
||||
var headerColIndex = index - 1;
|
||||
var rowIndex = $tr.index();
|
||||
var headerId = 'member-header-r' + rowIndex + '-c' + headerColIndex;
|
||||
|
||||
if ($('#' + headerId).length || $('[id="' + headerId + '"]').length) {
|
||||
$cell.attr('headers', headerId);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}, 500);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
fixUniversalTableA11y();
|
||||
});
|
||||
// 執行 member等高計算,目前改用flexbox故mark掉 by ika 20160105
|
||||
// $(window).load(function() {
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ img.image-preview {
|
|||
tbody > tr:nth-of-type(even) {
|
||||
background-color: #cccccc30;
|
||||
}
|
||||
td{
|
||||
td,th{
|
||||
border-bottom: 1px #333 solid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue