From b62934a8a0768730df66c2f7a2e9b8a8750935d0 Mon Sep 17 00:00:00 2001 From: ken Date: Wed, 19 Aug 2026 16:26:18 +0800 Subject: [PATCH] update --- assets/javascripts/app.js | 119 +++++++++++++++++- .../stylesheets/template/layout/header.scss | 1 + home/header.html.erb | 11 +- 3 files changed, 124 insertions(+), 7 deletions(-) diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index d8fc7ce..bf9fc3d 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -2240,6 +2240,14 @@ $(document).ready(function() { // if($('.show-announcement').hasClass('show-announcement')) { // $('.').css('', ''); // } + $(function() { + var $headerNav = $('.header-nav'); + $headerNav.contents().each(function() { + if (this.nodeType === 3 && this.nodeValue.trim() === '|') { + $(this).remove(); + } + }); + }); $('a').each(function () { const $a = $(this); @@ -2345,7 +2353,7 @@ $(document).ready(function() { if ($(window).width() <769) { $('.modules-menu-level-0').after($('.header-nav')); }else{ - $('.navbar-header').before($('.header-nav')); + $('.navbar-header').after($('.header-nav')); }; $('.sitemenu-vertical .sitemenu-dropdown-toggle').click(function(){ $('.sitemenu-vertical .dropdown-menu').slideToggle(); @@ -2413,7 +2421,7 @@ $(document).ready(function() { $('.modules-menu-level-0').after($('.header-nav')); }else{ - $('.navbar-header').before($('.header-nav')); + $('.navbar-header').after($('.header-nav')); }; if ($(window).width() > 821) { @@ -3280,7 +3288,114 @@ $(document).ready(function () { // 比 fixAccessibilityAll 的 800ms 晚,確保最後執行 setTimeout(fixGalleryViewLinkA11y, 2000); }); +function fixTicketHistoryStatusA11y() { + var $form = $('#check_history_form'); + if (!$form.length) return; + // 建立 role=status 播報區(若不存在) + if (!$('#ticket-history-result-status').length) { + $form.after('
'); + } + + var $statusBox = $('#ticket-history-result-status'); + + // MutationObserver 監聽 #history_area 的變化 + var $historyArea = $('#history_area'); + if (!$historyArea.length) return; + + var observer = new MutationObserver(function () { + var $noRecord = $historyArea.find('span.translation_missing'); + if ($noRecord.length) { + // 取得文字(顯示文字或 title 屬性) + var msg = $noRecord.text().trim() || $noRecord.attr('title') || 'No History Records'; + + // 把訊息寫入 role=status 區塊觸發播報 + $statusBox.text('').text(msg); + + // 同時在 span 上加 role=status(雙保險) + if ($noRecord.attr('role') !== 'status') { + $noRecord.attr('role', 'status').attr('aria-live', 'polite').attr('aria-atomic', 'true'); + } + } else { + // 有查到結果時清空播報區 + $statusBox.text(''); + } + }); + + observer.observe($historyArea[0], { + childList: true, + subtree: true + }); +} + +$(document).ready(function () { + setTimeout(fixTicketHistoryStatusA11y, 500); +}); +$(function() { + function fixSitemenuLinkA11y() { + setTimeout(function() { + $('.sitemenu-list.level-1 .sitemenu-link.level-1').each(function() { + var $a = $(this); + var href = $a.attr('href') || ''; + + if (!href.includes('#collapse')) return; + + var collapseId = href.split('#')[1]; + var $target = $('#' + collapseId); + var linkText = $a.text().replace(/\s+/g, ' ').trim(); + var isExpanded = $target.hasClass('in') || $target.attr('aria-expanded') === 'true'; + + $a.attr('title', linkText + ',' + (isExpanded ? '點擊收合內容' : '點擊展開內容')); + $a.attr('aria-expanded', isExpanded ? 'true' : 'false'); + $a.attr('aria-controls', collapseId); + // ✅ 新增:補上 role="button",讓螢幕閱讀器播報為按鈕而非連結 + $a.attr('role', 'button'); + }); + + $('.sitemenu-list.level-1 .sitemenu-link.level-1').on('click', function() { + var $a = $(this); + var href = $a.attr('href') || ''; + if (!href.includes('#collapse')) return; + + var collapseId = href.split('#')[1]; + var $target = $('#' + collapseId); + var linkText = $a.text().replace(/\s+/g, ' ').trim(); + + setTimeout(function() { + var isExpanded = $target.hasClass('in'); + $a.attr('aria-expanded', isExpanded ? 'true' : 'false'); + $a.attr('title', linkText + ',' + (isExpanded ? '點擊收合內容' : '點擊展開內容')); + }, 400); + }); + + // ✅ 同步處理右側主內容區的展開收合按鈕 + $('#index-archive-group .panel-title a[data-toggle="collapse"]').each(function() { + var $a = $(this); + var linkText = $a.text().replace(/\s+/g, ' ').trim(); + var isExpanded = $a.attr('aria-expanded') === 'true'; + + // ✅ 移除「在本視窗開啟」,改為展開/收合說明 + $a.attr('title', linkText + ',' + (isExpanded ? '點擊收合內容' : '點擊展開內容')); + // ✅ 補上 role="button" + $a.attr('role', 'button'); + }); + + // ✅ 右側按鈕點擊後同步更新 title + $('#index-archive-group .panel-title a[data-toggle="collapse"]').on('click', function() { + var $a = $(this); + var linkText = $a.text().replace(/\s+/g, ' ').trim(); + + setTimeout(function() { + var isExpanded = $a.attr('aria-expanded') === 'true'; + $a.attr('title', linkText + ',' + (isExpanded ? '點擊收合內容' : '點擊展開內容')); + }, 400); + }); + + }, 500); + } + + fixSitemenuLinkA11y(); +}); // 執行 member等高計算,目前改用flexbox故mark掉 by ika 20160105 // $(window).load(function() { // if ($('.index-member-3').length && $(window).width() > 992) { diff --git a/assets/stylesheets/template/layout/header.scss b/assets/stylesheets/template/layout/header.scss index 11e1086..83798d0 100644 --- a/assets/stylesheets/template/layout/header.scss +++ b/assets/stylesheets/template/layout/header.scss @@ -18,6 +18,7 @@ right: 0; width: 29%; padding-top:5em!important; + top:0; } ul{ padding: 0; diff --git a/home/header.html.erb b/home/header.html.erb index 34be93f..eb56b39 100644 --- a/home/header.html.erb +++ b/home/header.html.erb @@ -21,10 +21,7 @@
+
+ ::: + {{header-data}} +