This commit is contained in:
ken 2026-08-10 17:25:34 +08:00
parent 83eafda261
commit e2860da2c7
15 changed files with 174 additions and 68 deletions

View File

@ -1101,56 +1101,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');
});
@ -3060,6 +3063,116 @@ function removeHiddenContentLinks() {
$(document).ready(function () {
setTimeout(removeHiddenContentLinks, 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>');
}
});
});
//gallery view
function fixGalleryViewLinkA11y() {
$('a.btn.view').each(function () {
var $a = $(this);
$a.find('span').each(function () {
var $span = $(this);
// 避免重複處理
if ($span.hasClass('sr-only')) return;
var style = $span.attr('style') || '';
if (style.indexOf('display: none') !== -1 || style.indexOf('display:none') !== -1) {
$span.removeAttr('style').addClass('sr-only');
}
});
$a.find('i, svg').attr('aria-hidden', 'true');
});
}
// 執行 member等高計算目前改用flexbox故mark掉 by ika 20160105
// $(window).load(function() {
// if ($('.index-member-3').length && $(window).width() > 992) {

View File

@ -3,7 +3,7 @@
a[accesskey] {
position: absolute;
margin-left: -0.9375em;
color: transparent;
color: #ffffff !important;
}
#orbit-bar a[accesskey] {
@ -18,6 +18,6 @@ a[accesskey] {
a[accesskey] {
position: relative!important;
margin-left: -0.9375em;
color: #fff;
color: #ffffff !important;
}
}

View File

@ -31,11 +31,11 @@
// display: none!important;
// }
// }
[accesskey="U"],[accesskey="W"]{
@media(max-width:768px){
color: #666!important;
}
}
// [accesskey="U"],[accesskey="W"]{
// @media(max-width:768px){
// color: #666!important;
// }
// }
.orbit-bar-inner{
[accesskey="U"]{
height: 40px;

View File

@ -276,11 +276,6 @@ ul.button-mid{
width: fit-content;
font-size: 3em;
}
p{
padding: 3px 15px;
background-color:#00000066;
width: fit-content;
}
a{
color: #fff;
background-color: $theme-color-second;

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

@ -6,7 +6,7 @@
<li class="widget-content">
<div class="link-img-wrap{{display_image}}">
<a href="{{link_to_show}}" target="{{target}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</a>
</div>
<a href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">{{title}}</a>

View File

@ -6,7 +6,7 @@
<li class="widget-content">
<div class="link-img-wrap{{display_image}}">
<a href="{{link_to_show}}" target="{{target}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</a>
</div>
<span data-list="statuses" data-level="1">

View File

@ -6,7 +6,7 @@
<li class="widget-content">
<div class="link-img-wrap{{display_image}}">
<a href="{{link_to_show}}" target="{{target}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</a>
</div>
<a href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">{{title}}</a>

View File

@ -7,7 +7,7 @@
<div class="link-img-wrap{{display_image}}">
<a href="{{link_to_show}}" target="{{target}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</a>
</div>
<div class="widget-content-title">

View File

@ -6,7 +6,7 @@
<li class="widget-content widget-content-horizontal ">
<a href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">
<div class="link-img-wrap{{display_image}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</div>
</a>
<div class="widget-content-title">

View File

@ -6,7 +6,7 @@
<li class="widget-content widget-content-horizontal col-sm-6">
<a href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">
<div class="link-img-wrap{{display_image}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</div>
<div class="widget-content-title">
<a class="" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">{{title}}</a>

View File

@ -7,7 +7,7 @@
<div class="hex-border">
<a href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">
<div class="link-img-wrap{{display_image}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</div>
<a class="widget-content-title" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}" onclick="{{onclick}}">{{title}}</a>
<span data-list="statuses" data-level="1">

View File

@ -6,7 +6,7 @@
<li class="index-content">
<a class="index-content-title" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">
<div class="link-img-wrap{{display_image}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</div>
<h4>
{{title}}

View File

@ -6,7 +6,7 @@
<li class="index-content col-md-4 col-sm-4">
<a class="index-content-title" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">
<div class="link-img-wrap{{display_image}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
<img src="{{img_src}}" alt="{{img_description}}">
</div>
<h4>
<span class="link-title">