This commit is contained in:
ken 2026-08-05 20:22:09 +08:00
parent ec417d0bed
commit ce50cb345f
5 changed files with 97 additions and 55 deletions

View File

@ -1118,56 +1118,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');
});
@ -3323,6 +3326,41 @@ setTimeout(function() {
}
});
}, 500);
function fixSearchButtonA11y() {
var pageLang = $('html').attr('lang') || 'zh-Hant-TW';
var isEn = pageLang.toLowerCase().startsWith('en');
var label = isEn ? 'Submit site search' : '送出網內搜尋';
// 找搜尋表單內的送出按鈕
$('.search-container button[type="submit"], .search-box button[type="submit"], #search button[type="submit"]').each(function () {
var $btn = $(this);
// 修正 title
if (!$btn.attr('title') || $btn.attr('title').trim() === '按鈕' || $btn.attr('title').trim() === 'button') {
$btn.attr('title', label);
}
// 修正 sr-only / visually-hidden span 文字
var $srSpan = $btn.find('.sr-only, .visually-hidden');
if ($srSpan.length) {
if ($srSpan.text().trim() === '按鈕' || $srSpan.text().trim() === 'button' || $srSpan.text().trim() === '') {
$srSpan.text(label);
}
} else {
// 沒有 sr-only span 就補一個
$btn.find('i, svg').attr('aria-hidden', 'true');
$btn.append('<span class="sr-only">' + label + '</span>');
}
// 移除 role="button"button 本身已是 button
$btn.removeAttr('role');
});
}
$(document).ready(function () {
setTimeout(fixSearchButtonA11y, 500);
});
// 執行 member等高計算目前改用flexbox故mark掉 by ika 20160105
// $(window).load(function() {
// if ($('.index-member-3').length && $(window).width() > 992) {

View File

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

View File

@ -46,6 +46,7 @@
outline: 0.3125em auto -webkit-focus-ring-color !important;
}
.layout-header {
background-image:linear-gradient(180deg, transparent 0, #000000ba 30%, #000000fa);
width: 100%;
z-index: 10;
position: relative;

View File

@ -5,7 +5,10 @@ a.voice-player {
padding-left: 0.5em;
color: #ff6300;
}
.btn-info{
background-color: #007da3;
border-color: #007da3;
}
.universal-th-text{
white-space: pre;
}

View File

@ -9,7 +9,7 @@
<div class="link-img-wrap{{display_image}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
</div>
<a class="widget-content-title" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">{{title}}</a>
<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">
<span class="label status {{status-class}}">{{status}}</span>
</span>