This commit is contained in:
ken 2026-08-06 17:44:26 +08:00
parent 27dcb4c2e5
commit 44049b8112
9 changed files with 146 additions and 54 deletions

View File

@ -1132,56 +1132,59 @@ $(function() {
}
}
// E. 重新計算標題 (關鍵邏輯:若 hasOriginalTitle 為真,則不進入此區塊)
if (!hasOriginalTitle) {
if (linkText === "" && $img.length > 0) {
var rawAlt = ($img.attr('alt') || '').trim();
var forbidden = ['這是一張圖片', '圖片', 'image', 'photo', '圖', ''];
var imgAlt = forbidden.some(function(txt) { return rawAlt.toLowerCase() === txt; })
? ($a.attr('aria-label') || i18n.link) : rawAlt;
var fileInfo = fileExt ? '[' + fileExt.toUpperCase() + '] ' : '';
$a.attr('title', (fileInfo + imgAlt + " " + windowTask).trim());
$img.attr('alt', imgAlt);
}
else if (linkText !== "") {
if (fileExt !== "" || hasBadSymbol || currentTitle === "" || currentTitle.includes('/uploads/')) {
if (fileExt !== "") {
$a.attr('title', linkText + " ." + fileExt + " " + windowTask);
} else {
$a.attr('title', windowTask);
}
// E. 重新計算標題 (關鍵邏輯:若 hasOriginalTitle 為真,則不進入此區塊)
if (!hasOriginalTitle) {
if (linkText === "" && $img.length > 0) {
var rawAlt = ($img.attr('alt') || '').trim();
var forbidden = ['這是一張圖片', '圖片', 'image', 'photo', '圖', ''];
var imgAlt = forbidden.some(function(txt) { return rawAlt.toLowerCase() === txt; })
? ($a.attr('aria-label') || i18n.link) : rawAlt;
var fileInfo = fileExt ? '[' + fileExt.toUpperCase() + '] ' : '';
$a.attr('title', (fileInfo + imgAlt + " " + windowTask).trim());
$img.attr('alt', imgAlt);
}
else if (linkText !== "") {
if (fileExt !== "" || hasBadSymbol || currentTitle === "" || currentTitle.includes('/uploads/')) {
if (fileExt !== "") {
$a.attr('title', linkText + " ." + fileExt + " " + windowTask);
} else {
$a.attr('title', windowTask);
}
}
}
}
// ✅ 符合 HM1240404Etitle 不應與連結文字或圖片 alt 重複
if (hasOriginalTitle && currentTitle !== "") {
var titleWithoutWindow = currentTitle
.replace('(在本視窗開啟)', '')
.replace('(在新視窗開啟)', '')
.replace('Open in this window', '')
.replace('Open in new window', '')
.replace('另開新視窗前往', '')
.replace('另開新視窗', '')
.trim();
// ✅ 符合 HM1240404Etitle 不應與連結文字或圖片 alt 重複
if (hasOriginalTitle && currentTitle !== "") {
var titleWithoutWindow = currentTitle
.replace('(在本視窗開啟)', '')
.replace('(在新視窗開啟)', '')
.replace('Open in this window', '')
.replace('Open in new window', '')
.replace('另開新視窗前往', '')
.replace('另開新視窗', '')
.trim();
// ✅ title 去掉開窗字串後,若與連結文字或圖片原始 alt 相同,則只保留開窗提示
if (
(titleWithoutWindow === linkText && linkText !== i18n.link) ||
(imgAltOriginal !== '' && titleWithoutWindow === imgAltOriginal)
) {
$a.attr('title', windowTask);
}
// ✅ 最終清理:若 title 出現空括號 () 則移除並補上正確開窗提示
var finalTitle = ($a.attr('title') || '').trim();
if (finalTitle.includes('()')) {
finalTitle = finalTitle.replace(/\(\)/g, '').trim();
$a.attr('title', finalTitle + ' ' + windowTask);
}
// ✅ title 去掉開窗字串後,若與連結文字或圖片原始 alt 相同,則只保留開窗提示
// ✅ 新增:若 linkText 包含副檔名且 title 也是同樣檔名,也只保留開窗提示
if (
(titleWithoutWindow === linkText && linkText !== i18n.link) ||
(imgAltOriginal !== '' && titleWithoutWindow === imgAltOriginal) ||
(fileExt !== '' && linkText.toLowerCase().endsWith('.' + fileExt) && titleWithoutWindow === linkText)
) {
$a.attr('title', windowTask);
return; // ✅ 加上 return避免繼續執行後面的清理邏輯造成二次污染
}
// ✅ 最終清理:若 title 出現空括號 () 則移除並補上正確開窗提示
var finalTitle = ($a.attr('title') || '').trim();
if (finalTitle.includes('()')) {
finalTitle = finalTitle.replace(/\(\)/g, '').trim();
$a.attr('title', finalTitle + ' ' + windowTask);
}
}
// F. 最終清理:移除冗餘 label避免螢幕閱讀器唸兩次
$a.removeAttr('aria-label');
});
@ -3115,6 +3118,96 @@ $(document).ready(function () {
fixSortLinkA11y();
fixSearchInputA11y();
}, 500);
});
//會員tab邏輯
$(document).ready(function () {
setTimeout(function () {
$('.dtr-control').removeAttr('tabindex');
}, 500);
});
function fixTabKeyboardNav() {
setTimeout(function () {
var $tablist = $('.member-plugins[role="tablist"]');
var $tabs = $tablist.find('a[role="tab"]');
// 初始化 roving tabindex 和 aria-selected
$tabs.each(function (i) {
var $tab = $(this);
var isActive = $tab.closest('li').hasClass('active');
$tab.attr({
'tabindex': isActive ? '0' : '-1',
'aria-selected': isActive ? 'true' : 'false'
});
});
// 方向鍵切換頁籤
$tabs.on('keydown', function (e) {
var $current = $(this);
var currentIndex = $tabs.index($current);
var $target;
if (e.keyCode === 39 || e.keyCode === 40) {
// 右鍵或下鍵:下一個
e.preventDefault();
$target = $tabs.eq((currentIndex + 1) % $tabs.length);
} else if (e.keyCode === 37 || e.keyCode === 38) {
// 左鍵或上鍵:上一個
e.preventDefault();
$target = $tabs.eq((currentIndex - 1 + $tabs.length) % $tabs.length);
} else if (e.keyCode === 36) {
// Home第一個
e.preventDefault();
$target = $tabs.first();
} else if (e.keyCode === 35) {
// End最後一個
e.preventDefault();
$target = $tabs.last();
} else {
return;
}
// 更新 roving tabindex 和 aria-selected
$tabs.attr({ 'tabindex': '-1', 'aria-selected': 'false' });
$target.attr({ 'tabindex': '0', 'aria-selected': 'true' });
$target.focus().trigger('click');
});
// 點擊頁籤時同步更新狀態
$tabs.on('click', function () {
$tabs.attr({ 'tabindex': '-1', 'aria-selected': 'false' });
$(this).attr({ 'tabindex': '0', 'aria-selected': 'true' });
});
}, 500);
}
$(document).ready(function () {
fixTabKeyboardNav();
});
function removeBareUrlLinks() {
setTimeout(function() {
$('.dataTables_wrapper a').each(function() {
var $a = $(this);
var text = $a.text().trim();
if (/^https?:\/\//i.test(text)) {
$a.replaceWith(text);
}
});
}, 500);
}
$(document).ready(function() {
removeBareUrlLinks();
});
//麵包屑無障礙
$(document).ready(function () {
$('.widget-breadcrumb .breadcrumb li:last-child a').attr('aria-current', 'page');
// 若尚未有 nav 包住,自動加上
$('.widget-breadcrumb .breadcrumb').each(function () {
if (!$(this).closest('nav').length) {
$(this).wrap('<nav aria-label="麵包屑導覽"></nav>');
}
});
});
// 執行 member等高計算目前改用flexbox故mark掉 by ika 20160105
// $(window).load(function() {

View File

@ -15,10 +15,8 @@
font-size: 0.750em;
border-radius: 0.125em;
z-index: 1050;
opacity: .5;
&:hover {
background:#c71585;
opacity:1;
background:#90005a;
}
}

View File

@ -7,6 +7,9 @@
//
// Member Index
// ## Gerneral styles for Index
.show-member .nav-pills>li.active>a, .show-member .nav-pills>li.active>a:focus, .show-member .nav-pills>li.active>a:hover, .show-member .nav-pills>li.active>a.hover-class{
color: #333;
}
.i-member-profile-item{
list-style: none;
word-break: break-all;

View File

@ -17,8 +17,7 @@
<dl class="i-archive__file-list" data-list="files" data-level="2">
<dd class="i-archive__file-wrap">
<i class="fa-solid fa-file"></i>
<a class="i-archive__file-name" href="{{file-url}}" target="{{target}}" title="{{file-name}}">{{file-name}}</a>
<span class="i-archive__file-type label label-primary {{file-type}}">{{file-type}}</span>
<a class="i-archive__file-name" href="{{file-url}}" target="{{target}}" title="{{file-name}}">{{file-name}}<span class="i-archive__file-type label label-primary {{file-type}}">{{file-type}}</span></a>
</dd>
</dl>
</div>

View File

@ -18,8 +18,7 @@
<div class="panel-body">
<ul class="i-archive-files-list" data-list="files" data-level="2">
<li>
<a href="{{file-url}}" class="i-archive-files-item" target="{{target}}" title="{{file-name}}">{{file-name}}</a>
<span class="label label-primary {{file-type}}">{{file-type}}</span>
<a href="{{file-url}}" class="i-archive-files-item" target="{{target}}" title="{{file-name}}">{{file-name}}<span class="label label-primary {{file-type}}">{{file-type}}</span></a>
</li>
</ul>
</div>

View File

@ -8,7 +8,7 @@
<div class="i-member-item-inner clearfix">
<div class="i-member-pic-wrap col-sm-4 col-xs-4">
<a href="{{link_to_show}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" alt="{{name}}">
</a>
</div>
<div class="i-member-profile-data-wrap col-sm-8 col-xs-8">

View File

@ -8,7 +8,7 @@
<div class="i-member-item-inner clearfix">
<div class="i-member-pic-wrap">
<a href="{{link_to_show}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" alt="{{name}}">
</a>
</div>
<div class="i-member-profile-data-wrap">

View File

@ -8,7 +8,7 @@
<div class="i-member-item-inner clearfix">
<div class="i-member-pic-wrap">
<a href="{{link_to_show}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" alt="{{name}}">
</a>
</div>
<div class="i-member-profile-data-wrap">

View File

@ -10,7 +10,7 @@
<div class="i-member-item-inner clearfix">
<div class="i-member-pic-wrap">
<a href="{{link_to_show}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" title="{{name}}">
<img class="i-member-pic" src="{{image}}" alt="{{name}}">
</a>
</div>