update
This commit is contained in:
parent
0287a4eb1e
commit
fbd33808d0
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ 符合 HM1240404E:title 不應與連結文字或圖片 alt 重複
|
||||
if (hasOriginalTitle && currentTitle !== "") {
|
||||
var titleWithoutWindow = currentTitle
|
||||
.replace('(在本視窗開啟)', '')
|
||||
.replace('(在新視窗開啟)', '')
|
||||
.replace('Open in this window', '')
|
||||
.replace('Open in new window', '')
|
||||
.replace('另開新視窗前往', '')
|
||||
.replace('另開新視窗', '')
|
||||
.trim();
|
||||
// ✅ 符合 HM1240404E:title 不應與連結文字或圖片 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');
|
||||
});
|
||||
|
|
@ -1184,6 +1187,47 @@ $(function() {
|
|||
fixAccessibilityAll();
|
||||
}, 800);
|
||||
});
|
||||
// 修正漢堡選單按鈕無障礙
|
||||
$(function() {
|
||||
function fixNavbarToggleA11y() {
|
||||
var isEn = $('html').attr('lang') === 'en';
|
||||
var label = isEn ? '開啟或關閉導覽選單' : '開啟或關閉導覽選單';
|
||||
|
||||
$('.navbar-toggle').each(function() {
|
||||
var $btn = $(this);
|
||||
|
||||
// 修正 title
|
||||
$btn.attr('title', label);
|
||||
|
||||
// 修正 sr-only 文字(原本是 "Toggle navigation")
|
||||
var $sr = $btn.find('.sr-only');
|
||||
if ($sr.length) {
|
||||
$sr.text(label);
|
||||
} else {
|
||||
$btn.prepend('<span class="sr-only">' + label + '</span>');
|
||||
}
|
||||
|
||||
// 補上 aria-label
|
||||
$btn.attr('aria-label', label);
|
||||
|
||||
// 補上 aria-expanded(依據目前是否展開)
|
||||
if (!$btn.attr('aria-expanded')) {
|
||||
var isExpanded = !$btn.hasClass('collapsed');
|
||||
$btn.attr('aria-expanded', isExpanded ? 'true' : 'false');
|
||||
}
|
||||
|
||||
// 點擊時同步更新 aria-expanded
|
||||
$btn.off('click.navA11y').on('click.navA11y', function() {
|
||||
setTimeout(function() {
|
||||
var isExpanded = !$('.navbar-toggle').hasClass('collapsed');
|
||||
$('.navbar-toggle').attr('aria-expanded', isExpanded ? 'true' : 'false');
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(fixNavbarToggleA11y, 500);
|
||||
});
|
||||
|
||||
|
||||
$(function() {
|
||||
|
|
@ -3501,6 +3545,120 @@ 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');
|
||||
});
|
||||
}
|
||||
$(document).ready(function () {
|
||||
// 比 fixAccessibilityAll 的 800ms 晚,確保最後執行
|
||||
setTimeout(fixGalleryViewLinkA11y, 2000);
|
||||
});
|
||||
// 執行 member等高計算,目前改用flexbox故mark掉 by ika 20160105
|
||||
// $(window).load(function() {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,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">
|
||||
|
|
|
|||
|
|
@ -9,7 +9,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">
|
||||
|
|
|
|||
|
|
@ -9,7 +9,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">
|
||||
|
|
|
|||
|
|
@ -11,7 +11,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>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<li class="widget-content">
|
||||
<div class="link-img-wrap{{display_image}}">
|
||||
<a href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<li class="widget-content">
|
||||
<div class="link-img-wrap{{display_image}}">
|
||||
<a href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<ul class="list-unstyled" data-level="0" data-list="web_link">
|
||||
<li class="widget-content">
|
||||
<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 href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">{{title}}</a>
|
||||
<span data-list="statuses" data-level="1">
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<li class="widget-content widget-content-horizontal col-sm-3">
|
||||
<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">
|
||||
<span class="" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">{{title}}</span>
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
Loading…
Reference in New Issue