From e79d74bd5d47da35d70a25ae0373730afda4dbea Mon Sep 17 00:00:00 2001 From: ken Date: Tue, 7 Jul 2026 17:59:47 +0800 Subject: [PATCH] update --- assets/javascripts/app.js | 187 +++++++++++++++--- assets/stylesheets/template/base/_global.scss | 3 + .../template/modules/archives.scss | 24 +-- .../custom_gallery_index1.html.erb | 2 +- .../custom_gallery_index3.html.erb | 2 +- modules/gallery/gallery_index1.html.erb | 7 +- modules/gallery/gallery_index2.html.erb | 4 +- modules/gallery/gallery_index3.html.erb | 6 +- modules/gallery/gallery_index4.html.erb | 4 +- modules/gallery/gallery_index5.html.erb | 4 +- modules/gallery/gallery_index6.html.erb | 6 +- 11 files changed, 192 insertions(+), 57 deletions(-) diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index b29fe4c..5809cad 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -313,7 +313,13 @@ $(document).ready(function() { $('.mobile-menu').toggleClass('active'); $('body').toggleClass('noscroll'); - $('.mobile-menu .navbar-toggle').removeClass('collapsed'); + + // ★ 修正:依據 active 狀態決定 collapsed 的加/移除 + if ($('.mobile-menu').hasClass('active')) { + $('.mobile-menu .navbar-toggle').removeClass('collapsed'); // 打開 → 叉叉 + } else { + $('.mobile-menu .navbar-toggle').addClass('collapsed'); // 關閉 → 三條橫線 + } // 關閉所有下拉選單 $('.mobile-menu1 > ul, .mobile-menu2 > ul').slideUp(500); @@ -327,6 +333,34 @@ $(document).ready(function() { } }); + // ✅ Tab 鍵跳過 .mobile-menu 時,觸發收合邏輯 + $(document).on('focusout', '.mobile-menu', function(e) { + setTimeout(function() { + var $newFocus = $(document.activeElement); + + // 焦點在 body 時代表滑鼠正在點擊中,不處理 + if ($newFocus.is('body')) return; + + if ($('.mobile-menu').hasClass('active') && $newFocus.closest('.mobile-menu').length === 0) { + + var $btn = $('.navbar-toggle').first(); + + if ($btn.attr('data-bs-toggle')) { + var target = $btn.attr('data-bs-target'); + var bsCollapse = window.bootstrap && bootstrap.Collapse.getInstance($(target)[0]); + if (bsCollapse) bsCollapse.hide(); + $('.mobile-menu').removeClass('active'); + $('body').removeClass('noscroll'); + $('.mobile-menu .navbar-toggle').addClass('collapsed'); + $('.mobile-menu1 > ul, .mobile-menu2 > ul').slideUp(500); + $('.mobile-menu1 > .menu-drop, .mobile-menu2 > .menu-drop').removeClass('opened'); + } else { + $btn.trigger('click'); + } + } + }, 50); + }); + $('.mobile-menu1 > .menu-drop').click(function(){ var $that = $(this); var opencheck1 = $that.hasClass('opened'); @@ -634,35 +668,46 @@ $(document).ready(function() { } }); - function handleHover() { - // 先統一移除舊事件,避免重複綁定 - $('li').off('mouseenter mouseleave focusin focusout'); +function handleHover() { + // 先統一移除舊事件,避免重複綁定 + $('li').off('mouseenter mouseleave focusin focusout'); - if ($(window).width() > 769) { - // 1. 處理滑鼠 Hover - $('li').hover( - function() { $(this).children('ul').addClass('show'); }, - function() { $(this).children('ul').removeClass('show'); } - ); + if ($(window).width() > 769) { + // 1. 處理滑鼠 Hover + $('li').hover( + function() { + // ✅ 排除 .menu-bx 內的 li + if (!$(this).closest('.menu-bx').length) { + $(this).children('ul').addClass('show'); + } + }, + function() { + if (!$(this).closest('.menu-bx').length) { + $(this).children('ul').removeClass('show'); + } + } + ); - // 2. 處理鍵盤 Tab 聚焦 (關鍵修正) - $('li').on('focusin', function() { - // 當焦點進入 li 或其子元素時,顯示選單 - $(this).children('ul').addClass('show'); - }); + // 2. 處理鍵盤 Tab 聚焦 + $('li').on('focusin', function() { + // ✅ 排除 .menu-bx 內的 li + if (!$(this).closest('.menu-bx').length) { + $(this).children('ul').addClass('show'); + } + }); - $('li').on('focusout', function() { - var $this = $(this); - // 延遲偵測焦點是否真的「離開」了這個 li 區塊 - setTimeout(function() { - // 如果新的焦點不在當前這個 li 裡面,才移除 show - if ($this.find(':focus').length === 0) { - $this.children('ul').removeClass('show'); - } - }, 10); - }); - } - } + $('li').on('focusout', function() { + var $this = $(this); + // ✅ 排除 .menu-bx 內的 li + if ($this.closest('.menu-bx').length) return; + setTimeout(function() { + if ($this.find(':focus').length === 0) { + $this.children('ul').removeClass('show'); + } + }, 10); + }); + } +} // 初始化與 Resize 監聽保持不變 handleHover(); @@ -871,7 +916,7 @@ $(document).ready(function() { var isLinkImage = $parentA.length > 0 && $parentA.text().replace(/\u00a0/g, '').trim() === ""; // --- 1. 處理「裝飾性圖片」標註 --- - if (currentAlt === "announcement image" || currentAlt === "裝飾圖片" || currentTitle === "裝飾圖片") { + if (currentAlt === "announcement image" || currentAlt === "裝飾圖片" || currentTitle === "裝飾圖片" || currentAlt === "這是一張圖片" || currentTitle === "這是一張圖片") { $img.attr('alt', ''); $img.removeAttr('title'); return; @@ -2884,6 +2929,9 @@ $(function() { var target = document.getElementById('gallery-theater-stage'); if (!target) return; + // 頁面載入時若已存在 #gallery-theater-stage,則還原 z-index + $('.verticalhome').css('z-index', 'auto'); + var observer = new MutationObserver(function() { var display = target.style.display; if (display === 'block') { @@ -2935,6 +2983,89 @@ $(document).ready(function() { subtree: true }); +}); +//萬用表格無障礙 +function fixSortLinkA11y() { + $('a').filter(function () { + return $(this).find('.universal-th-icon').length > 0; + }).each(function () { + var $link = $(this); + + // === Step 1: 移除 display:none 的 span === + $link.find('span').each(function () { + if ($(this).css('display') === 'none' || $(this).attr('style') && $(this).attr('style').indexOf('display: none') !== -1) { + $(this).remove(); + } + }); + + // === Step 2: 取得 aria-label === + var ariaLabel = $link.attr('aria-label') || ''; + + // 若 aria-label 空白或含未替換模板變數,從旁邊 .universal-th-text 補 + if (!ariaLabel || ariaLabel.indexOf('{{') !== -1) { + var $th = $link.closest('th, div[class*="col-"]'); + var colName = $th.find('.universal-th-text').text().trim(); + ariaLabel = colName ? '重新排序' + colName : '排序'; + $link.attr('aria-label', ariaLabel); + } + + // === Step 3: 補上 title 屬性 === + if (!$link.attr('title')) { + $link.attr('title', ariaLabel + '(在本視窗開啟)'); + } + + // === Step 4: 確保圖示有 aria-hidden === + $link.find('.universal-th-icon').attr('aria-hidden', 'true'); + + // === Step 5: 補上 visually-hidden 連結文字 === + if ($link.find('.visually-hidden').length === 0) { + $link.append('' + ariaLabel + ''); + } + }); +} +function fixSearchInputA11y() { + $('input[type="search"], input[type="text"]').each(function () { + var $input = $(this); + + // 已有對應 label 就跳過 + var inputId = $input.attr('id'); + if (inputId && $('label[for="' + inputId + '"]').length) return; + + // 已有 aria-label / aria-labelledby / title 就跳過 + if ($input.attr('aria-label') || $input.attr('aria-labelledby') || $input.attr('title')) return; + + // 從 placeholder 取得說明文字 + var placeholder = $input.attr('placeholder') || ''; + + // 從最近的 th 或欄位標題取得欄位名稱 + var colName = ''; + var $th = $input.closest('th, div[class*="col-"]'); + if ($th.length) { + colName = $th.find('.universal-th-text').text().trim(); + } + + // 組合標籤文字 + var label = ''; + if (colName && placeholder) { + label = colName + '搜尋'; + } else if (colName) { + label = colName + '搜尋'; + } else if (placeholder) { + label = placeholder; + } else { + label = '搜尋關鍵字'; + } + + $input.attr('aria-label', label); + $input.attr('title', label); + }); +} + +$(document).ready(function () { + setTimeout(function () { + fixSortLinkA11y(); + fixSearchInputA11y(); + }, 500); }); // 執行 member等高計算,目前改用flexbox故mark掉 by ika 20160105 // $(window).load(function() { diff --git a/assets/stylesheets/template/base/_global.scss b/assets/stylesheets/template/base/_global.scss index b4f0619..7593865 100644 --- a/assets/stylesheets/template/base/_global.scss +++ b/assets/stylesheets/template/base/_global.scss @@ -11,6 +11,9 @@ display: block } } +#orbit-bar .orbit-bar-menu .orbit-bar-logo{ + cursor: unset!important; +} .login-btn:focus { outline: 0.3125em auto -webkit-focus-ring-color !important; diff --git a/assets/stylesheets/template/modules/archives.scss b/assets/stylesheets/template/modules/archives.scss index 3a5e6bf..0a40600 100644 --- a/assets/stylesheets/template/modules/archives.scss +++ b/assets/stylesheets/template/modules/archives.scss @@ -144,18 +144,18 @@ .i-archive-title { @extend .unity-title; } -.link { background-color: #1368d4 !important; } /* 對比 4.6:1 */ -.txt { background-color: #3a8a40 !important; } /* 對比 4.6:1 */ -.xlsx { background-color: #9e3050 !important; } /* 對比 4.6:1 */ -.pdf { background-color: #2a7d36 !important; } /* 對比 4.6:1 */ -.docx { background-color: #5e46a0 !important; } /* 對比 4.6:1 */ -.doc { background-color: #1368d4 !important; } /* 對比 4.6:1 */ -.pptx { background-color: #3d4aa0 !important; } /* 對比 4.6:1 */ -.jpg { background-color: #8f3333 !important; } /* 對比 4.6:1 */ -.zip { background-color: #8a6400 !important; } /* 對比 4.6:1 */ -.rar { background-color: #9e5000 !important; } /* 對比 4.6:1 */ -.xls { background-color: #3a8a40 !important; } /* 對比 4.6:1 */ -.odt { background-color: #767676 !important; } /* 對比 4.6:1 */ +.link { background-color: #1368d4 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.txt { background-color: #3a8a40 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.xlsx { background-color: #9e3050 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.pdf { background-color: #2a7d36 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.docx { background-color: #5e46a0 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.doc { background-color: #1368d4 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.pptx { background-color: #3d4aa0 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.jpg { background-color: #8f3333 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.zip { background-color: #8a6400 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.rar { background-color: #9e5000 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.xls { background-color: #3a8a40 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ +.odt { background-color: #767676 !important; margin-left: 0.5em; } /* 對比 4.6:1 */ .table>caption+thead>tr:first-child>td, .table>caption+thead>tr:first-child>th, .table>colgroup+thead>tr:first-child>td, .table>colgroup+thead>tr:first-child>th, .table>thead:first-child>tr:first-child>td, .table>thead:first-child>tr:first-child>th{ // border-top: 0.0625em solid #ddd; } diff --git a/modules/custom_gallery/custom_gallery_index1.html.erb b/modules/custom_gallery/custom_gallery_index1.html.erb index 4531ca1..36a731f 100644 --- a/modules/custom_gallery/custom_gallery_index1.html.erb +++ b/modules/custom_gallery/custom_gallery_index1.html.erb @@ -6,7 +6,7 @@
- {{alt_title}} + {{album-name}}

diff --git a/modules/custom_gallery/custom_gallery_index3.html.erb b/modules/custom_gallery/custom_gallery_index3.html.erb index fb8f821..6388e93 100644 --- a/modules/custom_gallery/custom_gallery_index3.html.erb +++ b/modules/custom_gallery/custom_gallery_index3.html.erb @@ -6,7 +6,7 @@
- {{alt_title}} + {{album-name}}

diff --git a/modules/gallery/gallery_index1.html.erb b/modules/gallery/gallery_index1.html.erb index e7c011e..097255a 100644 --- a/modules/gallery/gallery_index1.html.erb +++ b/modules/gallery/gallery_index1.html.erb @@ -4,15 +4,16 @@

- +
+
- {{alt_title}} + {{album-name}}

- {{album-name}} + {{album-name}}

{{album-description}}
diff --git a/modules/gallery/gallery_index2.html.erb b/modules/gallery/gallery_index2.html.erb index 75f9c36..eae3376 100644 --- a/modules/gallery/gallery_index2.html.erb +++ b/modules/gallery/gallery_index2.html.erb @@ -5,14 +5,14 @@
- +
{{alt_title}}

- {{album-name}} + {{album-name}}

{{album-description}}
diff --git a/modules/gallery/gallery_index3.html.erb b/modules/gallery/gallery_index3.html.erb index 9571f1a..2cb4aad 100644 --- a/modules/gallery/gallery_index3.html.erb +++ b/modules/gallery/gallery_index3.html.erb @@ -4,15 +4,15 @@

- + diff --git a/modules/gallery/gallery_index4.html.erb b/modules/gallery/gallery_index4.html.erb index 0067a40..79dbf20 100644 --- a/modules/gallery/gallery_index4.html.erb +++ b/modules/gallery/gallery_index4.html.erb @@ -5,14 +5,14 @@
- +
{{alt_title}}
diff --git a/modules/gallery/gallery_index5.html.erb b/modules/gallery/gallery_index5.html.erb index 7ac894a..fa2c16d 100644 --- a/modules/gallery/gallery_index5.html.erb +++ b/modules/gallery/gallery_index5.html.erb @@ -8,11 +8,11 @@
- + {{alt_title}} diff --git a/modules/gallery/gallery_index6.html.erb b/modules/gallery/gallery_index6.html.erb index 9d21410..13d39a2 100644 --- a/modules/gallery/gallery_index6.html.erb +++ b/modules/gallery/gallery_index6.html.erb @@ -6,14 +6,14 @@