update
This commit is contained in:
1 parent
104058df30
commit
2a5643caec
78 files changed
+274
-134
No files matched your search
+125
-24
@@ -940,7 +940,7 @@ $(function() {
|
||||
$(this).append('<span class="sr-only">網路資源標題</span>');
|
||||
}
|
||||
});
|
||||
$('input').each(function() {
|
||||
$('input.input-search, .search-container input, .search-box input, #search input').each(function() {
|
||||
var $this = $(this);
|
||||
if (!$this.attr('title') || $this.attr('title').trim() === '') {
|
||||
$this.attr('title', '網內搜尋');
|
||||
@@ -968,7 +968,7 @@ $(function() {
|
||||
var isLinkImage = $parentA.length > 0 && $parentA.text().replace(/\u00a0/g, '').trim() === "";
|
||||
|
||||
// --- 1. 處理「裝飾性圖片」標註 ---
|
||||
if (currentAlt === "announcement image" || currentAlt === "裝飾圖片" || currentTitle === "裝飾圖片" || currentAlt === "這是一張圖片" || currentTitle === "這是一張圖片") {
|
||||
if (currentAlt === "announcement image" || currentAlt === "裝飾圖片" || currentTitle === "裝飾圖片" || currentAlt === "這是一張圖片" || currentTitle === "這是一張圖片"||currentAlt === "This is a image" ||currentTitle === "This is a image") {
|
||||
$img.attr('alt', '');
|
||||
$img.removeAttr('title');
|
||||
return;
|
||||
@@ -2000,27 +2000,28 @@ $(function() {
|
||||
});
|
||||
//rucaptcha-image
|
||||
$(document).ready(function () {
|
||||
$('.rucaptcha-image').removeAttr('onload');
|
||||
|
||||
// 檢查是否已插入過
|
||||
if (!$('#captcha_audio').length) {
|
||||
const audioButton = $(`
|
||||
<button
|
||||
title="播放驗證碼語音"
|
||||
type="button"
|
||||
onclick="document.getElementById('captcha_audio').play();"
|
||||
class="fas fa-volume-up"
|
||||
aria-label="播放驗證碼語音"
|
||||
role="button"
|
||||
style="font-size: 1.5em; color: #333; cursor: pointer; border: 2px solid #333; padding: 0.2em;">
|
||||
<span class="sr-only">播放驗證碼語音</span>
|
||||
</button>
|
||||
`);
|
||||
|
||||
const audio = $('<audio id="captcha_audio" src="/rucaptcha/?format=wav&locale=zh_tw"></audio>');
|
||||
|
||||
$('.rucaptcha-image').after(audioButton, audio);
|
||||
// >>> 修正:先確認頁面上真的有驗證碼圖片,再往下執行,避免沒有驗證碼的頁面也發出多餘的 wav 請求
|
||||
if ($('.rucaptcha-image').length) {
|
||||
$('.rucaptcha-image').removeAttr('onload');
|
||||
// 檢查是否已插入過
|
||||
if (!$('#captcha_audio').length) {
|
||||
const audioButton = $(`
|
||||
<button
|
||||
title="播放驗證碼語音"
|
||||
type="button"
|
||||
onclick="document.getElementById('captcha_audio').play();"
|
||||
class="fas fa-volume-up"
|
||||
aria-label="播放驗證碼語音"
|
||||
role="button"
|
||||
style="font-size: 1.5em; color: #333; cursor: pointer; border: 2px solid #333; padding: 0.2em;">
|
||||
<span class="sr-only">播放驗證碼語音</span>
|
||||
</button>
|
||||
`);
|
||||
const audio = $('<audio id="captcha_audio" src="/rucaptcha/?format=wav&locale=zh_tw"></audio>');
|
||||
$('.rucaptcha-image').after(audioButton, audio);
|
||||
}
|
||||
}
|
||||
// <<< 修正結束
|
||||
});
|
||||
|
||||
//萬用表格searchbtn2
|
||||
@@ -2043,6 +2044,28 @@ $(function() {
|
||||
// 預設 aria-expanded 為 false
|
||||
$(".searchbtn2").attr("aria-expanded", "false");
|
||||
});
|
||||
// ✅ searchbtn2 Tab 鍵聚焦時自動展開 .searchbox
|
||||
$(document).ready(function() {
|
||||
function fixSearchbtn2FocusA11y() {
|
||||
setTimeout(function() {
|
||||
$('.searchbtn2').on('focus', function() {
|
||||
var $searchbox = $('.searchbox');
|
||||
|
||||
// ✅ 只在收合狀態時才展開,不影響已展開的狀態
|
||||
if (!$searchbox.is(':visible')) {
|
||||
$searchbox.slideDown(300, function() {
|
||||
// ✅ 同步更新 aria-expanded(與原本 click 邏輯一致)
|
||||
$('.searchbtn2').attr('aria-expanded', 'true');
|
||||
// ✅ 同步加上 ken-click2(與原本 click 邏輯一致)
|
||||
$('.searchbtn2').closest('.ken-click').addClass('ken-click2');
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
|
||||
fixSearchbtn2FocusA11y();
|
||||
});
|
||||
// 強制保持全站search展開
|
||||
$(document).ready(function () {
|
||||
|
||||
@@ -3734,7 +3757,7 @@ $(function() {
|
||||
});
|
||||
//萬用表格無障礙
|
||||
function fixSearchInputA11y() {
|
||||
$('input[type="search"], input[type="text"]').each(function () {
|
||||
$('input[type="search"], input.input-search, .search-container input, .search-box input').each(function () {
|
||||
var $input = $(this);
|
||||
|
||||
// 已有對應 label 就跳過
|
||||
@@ -3814,7 +3837,7 @@ function fixSortLinkA11y() {
|
||||
});
|
||||
}
|
||||
function fixSearchInputA11y() {
|
||||
$('input[type="search"], input[type="text"]').each(function () {
|
||||
$('input[type="search"], input.input-search, .search-container input, .search-box input').each(function () {
|
||||
var $input = $(this);
|
||||
|
||||
// 已有對應 label 就跳過
|
||||
@@ -3864,4 +3887,82 @@ setTimeout(function() {
|
||||
}, 500);
|
||||
|
||||
|
||||
//banner英文
|
||||
$(function() {
|
||||
function fixBannerA11yByLang() {
|
||||
setTimeout(function() {
|
||||
var pageLang = ($('html').attr('lang') || 'zh-Hant').toLowerCase();
|
||||
var isEn = pageLang.startsWith('en');
|
||||
|
||||
var i18n = {
|
||||
playControls: isEn ? 'Playback Controls' : '播放控制選項',
|
||||
resume: isEn ? 'Play' : '繼續播放',
|
||||
pause: isEn ? 'Pause' : '暫停播放',
|
||||
prev: isEn ? 'Previous' : '上一張',
|
||||
next: isEn ? 'Next' : '下一張',
|
||||
slide: isEn ? 'Slide' : '第',
|
||||
slideUnit: isEn ? '' : ' 張投影片'
|
||||
};
|
||||
|
||||
$('.w-ba-banner').each(function() {
|
||||
var $banner = $(this);
|
||||
|
||||
// ✅ 播放控制選項 radiogroup label
|
||||
$banner.find('.controlplay').attr('aria-label', i18n.playControls);
|
||||
|
||||
// ✅ 繼續播放按鈕
|
||||
$banner.find('.resume-slide').attr({
|
||||
'aria-label': i18n.resume,
|
||||
'title': i18n.resume
|
||||
});
|
||||
$banner.find('.resume-slide p').text(i18n.resume);
|
||||
|
||||
// ✅ 暫停播放按鈕
|
||||
$banner.find('.pause-slide').attr({
|
||||
'aria-label': i18n.pause,
|
||||
'title': i18n.pause
|
||||
});
|
||||
$banner.find('.pause-slide p').text(i18n.pause);
|
||||
|
||||
// ✅ 上一張按鈕
|
||||
$banner.find('.prev-button').attr('aria-label', i18n.prev);
|
||||
|
||||
// ✅ 下一張按鈕
|
||||
$banner.find('.next-button').attr('aria-label', i18n.next);
|
||||
|
||||
// ✅ Pager 按鈕
|
||||
var $slides = $banner.find('.w-ba-banner__slide');
|
||||
$banner.find('.banner-pager button').each(function(index) {
|
||||
var slideTitle = $slides.eq(index).data('cycle-title') || '';
|
||||
var ariaLabel = isEn
|
||||
? i18n.slide + ' ' + (index + 1) + (slideTitle ? ' ' + slideTitle : '')
|
||||
: i18n.slide + (index + 1) + i18n.slideUnit + (slideTitle ? ' ' + slideTitle : '');
|
||||
$(this).attr({
|
||||
'aria-label': ariaLabel,
|
||||
'title': ariaLabel
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// ✅ Cycle2 初始化後也重新處理 Pager(因為 pager 是動態產生的)
|
||||
$('.w-ba-banner .cycle-slideshow').on('cycle-post-initialize cycle-after', function() {
|
||||
var $banner = $(this).closest('.w-ba-banner');
|
||||
var $slides = $banner.find('.w-ba-banner__slide');
|
||||
$banner.find('.banner-pager button').each(function(index) {
|
||||
var slideTitle = $slides.eq(index).data('cycle-title') || '';
|
||||
var ariaLabel = isEn
|
||||
? i18n.slide + ' ' + (index + 1) + (slideTitle ? ' ' + slideTitle : '')
|
||||
: i18n.slide + (index + 1) + i18n.slideUnit + (slideTitle ? ' ' + slideTitle : '');
|
||||
$(this).attr({
|
||||
'aria-label': ariaLabel,
|
||||
'title': ariaLabel
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}, 800);
|
||||
}
|
||||
|
||||
fixBannerA11yByLang();
|
||||
});
|
||||
}(jQuery, window));
|
||||
Reference in new issue
Block a user