diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index 649d171..e5f8f3b 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -899,7 +899,7 @@ 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; @@ -1186,80 +1186,132 @@ $(function() { }); - $(function() { - function smartFixIcons() { - var isEn = $('html').attr('lang') === 'en'; +$(function() { + function smartFixIcons() { + var isEn = $('html').attr('lang') === 'en'; - var labels = { - calendar : isEn ? 'Date: ' : '日期:', - user : isEn ? 'Author: ' : '發布者:', - tag : isEn ? 'Tag: ' : '標籤:', - clock : isEn ? 'Time: ' : '時間:', - location : isEn ? 'Location: ' : '地點:', - phone : isEn ? 'Phone: ' : '電話:', - envelope : isEn ? 'Email: ' : '信箱:', - folder : isEn ? 'Category: ' : '分類:', - eye : isEn ? 'Views: ' : '瀏覽次數:', - download : isEn ? 'Download: ' : '下載檔案:', - search : isEn ? 'Search' : '搜尋', - bars : isEn ? 'Menu' : '選單', - print : isEn ? 'Print this page': '列印此頁', - share : isEn ? 'Share' : '分享至社群', - close : isEn ? 'Close' : '關閉視窗' - }; + var labels = { + calendar : isEn ? 'Date: ' : '日期:', + user : isEn ? 'Author: ' : '發布者:', + tag : isEn ? 'Tag: ' : '標籤:', + clock : isEn ? 'Time: ' : '時間:', + location : isEn ? 'Location: ' : '地點:', + phone : isEn ? 'Phone: ' : '電話:', + envelope : isEn ? 'Email: ' : '信箱:', + folder : isEn ? 'Category: ' : '分類:', + eye : isEn ? 'Views: ' : '瀏覽次數:', + download : isEn ? 'Download: ' : '下載檔案:', + search : isEn ? 'Search' : '搜尋', + bars : isEn ? 'Menu' : '選單', + print : isEn ? 'Print this page' : '列印此頁', + share : isEn ? 'Share' : '分享至社群', + close : isEn ? 'Close window' : '關閉視窗', + closePopup : isEn ? 'Close announcement' : '關閉公告視窗', + closeGallery: isEn ? 'Close gallery' : '關閉相簿', + toggleDesc : isEn ? 'Show or hide image description' : '顯示或隱藏圖片說明', + themeSwitch : isEn ? 'Switch gallery theme': '切換相簿主題', + showOriginal: isEn ? 'Show original image' : '顯示原始圖片' + }; - $('i').each(function() { - var $icon = $(this); - var $parent = $icon.parent(); + $('i').each(function() { + var $icon = $(this); + var $parent = $icon.parent(); - // 1. 所有圖示先對螢幕閱讀器隱藏 - $icon.attr('aria-hidden', 'true'); + // 1. 所有圖示先對螢幕閱讀器隱藏 + $icon.attr('aria-hidden', 'true'); - // 2. 已有 aria-label 或 sr-only 就不重複處理 - if ($icon.attr('aria-label') || $icon.next('.sr-only').length > 0 || $parent.find('.sr-only').length > 0) { - return; + // 特判:.close-screen-btn 內的圖示,移除無關的 sr-only 並設正確 aria-label + if ($parent.hasClass('close-screen-btn')) { + $parent.find('.sr-only').remove(); + $parent.attr('aria-label', labels.closePopup); + if ($icon.next('.sr-only').length === 0) { + $icon.after('' + labels.closePopup + ''); } + return; + } - var cls = ($icon.attr('class') || '').toLowerCase(); - var labelText = ''; - - // --- 策略 A:常見資訊型圖示 --- - if (cls.includes('calendar')) labelText = labels.calendar; - else if (cls.includes('user') || cls.includes('male')) labelText = labels.user; - else if (cls.includes('tag')) labelText = labels.tag; - else if (cls.includes('clock') || cls.includes('time')) labelText = labels.clock; - else if (cls.includes('map-marker') || cls.includes('location')) labelText = labels.location; - else if (cls.includes('phone')) labelText = labels.phone; - else if (cls.includes('envelope') || cls.includes('mail')) labelText = labels.envelope; - else if (cls.includes('folder')) labelText = labels.folder; - else if (cls.includes('eye')) labelText = labels.eye; - else if (cls.includes('download')) labelText = labels.download; - - // --- 策略 B:功能性按鈕 --- - var $container = $icon.closest('a, button'); - if ($container.length > 0 && $container.text().trim() === '') { - var btnTitle = $container.attr('title'); - if (btnTitle) labelText = btnTitle; - else if (cls.includes('search')) labelText = labels.search; - else if (cls.includes('bars') || cls.includes('navicon')) labelText = labels.bars; - else if (cls.includes('print')) labelText = labels.print; - else if (cls.includes('share')) labelText = labels.share; - else if (cls.includes('close') || cls.includes('times')) labelText = labels.close; + // 特判:.gallery-close 內的圖示,移除錯誤的 sr-only 並補正確說明 + if ($parent.closest('.gallery-close').length > 0) { + $parent.closest('.gallery-close').find('.sr-only').remove(); + $parent.closest('.gallery-close').attr('aria-label', labels.closeGallery); + $parent.closest('.gallery-close').attr('role', 'button'); + $parent.closest('.gallery-close').attr('tabindex', '0'); + if ($icon.next('.sr-only').length === 0) { + $icon.after('' + labels.closeGallery + ''); } + return; + } - // --- 3. 執行補強 --- - if (labelText !== '') { - if ($container.length > 0 && $container.text().trim() === '') { - $container.attr('aria-label', labelText); - } else { - $icon.after('' + labelText + ''); - } + // 特判:.gallery-toggle-desc 補說明 + if ($parent.closest('.gallery-toggle-desc').length > 0) { + var $toggleBtn = $parent.closest('.gallery-toggle-desc'); + if (!$toggleBtn.attr('aria-label')) { + $toggleBtn.attr('aria-label', labels.toggleDesc); + $toggleBtn.attr('role', 'button'); + $toggleBtn.attr('tabindex', '0'); } - }); - } + if ($icon.next('.sr-only').length === 0) { + $icon.after('' + labels.toggleDesc + ''); + } + return; + } - setTimeout(smartFixIcons, 500); - }); + // 特判:.gallery-theme-switch 補說明 + if ($parent.closest('.gallery-theme-switch').length > 0) { + var $themeBtn = $parent.closest('.gallery-theme-switch'); + if (!$themeBtn.attr('aria-label')) { + $themeBtn.attr('aria-label', labels.themeSwitch); + $themeBtn.attr('role', 'button'); + $themeBtn.attr('tabindex', '0'); + } + if ($icon.next('.sr-only').length === 0) { + $icon.after('' + labels.themeSwitch + ''); + } + return; + } + + // 2. 已有 aria-label 或 sr-only 就不重複處理 + if ($icon.attr('aria-label') || $icon.next('.sr-only').length > 0 || $parent.find('.sr-only').length > 0) { + return; + } + + var cls = ($icon.attr('class') || '').toLowerCase(); + var labelText = ''; + + // --- 策略 A:常見資訊型圖示 --- + if (cls.includes('calendar')) labelText = labels.calendar; + else if (cls.includes('user') || cls.includes('male')) labelText = labels.user; + else if (cls.includes('tag')) labelText = labels.tag; + else if (cls.includes('clock') || cls.includes('time')) labelText = labels.clock; + else if (cls.includes('map-marker') || cls.includes('location')) labelText = labels.location; + else if (cls.includes('phone')) labelText = labels.phone; + else if (cls.includes('envelope') || cls.includes('mail')) labelText = labels.envelope; + else if (cls.includes('folder')) labelText = labels.folder; + else if (cls.includes('eye')) labelText = labels.eye; + else if (cls.includes('download')) labelText = labels.download; + + // --- 策略 B:功能性按鈕 --- + var $container = $icon.closest('a, button'); + if ($container.length > 0 && $container.text().trim() === '') { + var btnTitle = $container.attr('title'); + if (btnTitle) labelText = btnTitle; + else if (cls.includes('search')) labelText = labels.search; + else if (cls.includes('bars') || cls.includes('navicon')) labelText = labels.bars; + else if (cls.includes('print')) labelText = labels.print; + else if (cls.includes('share')) labelText = labels.share; + else if (cls.includes('close') || cls.includes('times')) labelText = labels.close; + else if (cls.includes('image') || cls.includes('photo')) labelText = labels.showOriginal; + } + + // --- 3. 執行補強 --- + if (labelText !== '') { + $icon.after('' + labelText + ''); + } + }); + } + + setTimeout(smartFixIcons, 500); +}); // 刪除banner-slide的空連結和空連結目標 for(var i=0;i<$('.w-ba-banner__slide a').length;i++){ if($('.w-ba-banner__slide a').eq(i).attr('href')=="") @@ -3079,6 +3131,146 @@ $(function() { } }, 500); }); +}); +//gallery層級問題 +$(function() { + var target = document.getElementById('gallery-theater-stage'); + if (!target) return; + + var observer = new MutationObserver(function() { + var display = target.style.display; + if (display === 'block') { + $('.verticalhome').css('z-index', '2000'); + } else if (display === 'none') { + $('.verticalhome').css('z-index', 'auto'); + } + }); + + observer.observe(target, { + attributes : true, + attributeFilter: ['style'] + }); +}); +$(document).ready(function() { + + function removeFakeLinks() { + $('a.fake_link').remove(); + } + + // 初始執行一次 + removeFakeLinks(); + + // Shift+Tab 時也執行 + $(document).on('keydown', function(e) { + if (e.key === 'Tab' && e.shiftKey) { + removeFakeLinks(); + } + }); + + // MutationObserver 監聽 DOM 變化,fake_link 一出現就移除 + var observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + mutation.addedNodes.forEach(function(node) { + // 直接是 fake_link + if ($(node).is('a.fake_link')) { + $(node).remove(); + } + // 或其子元素內含 fake_link + if ($(node).find) { + $(node).find('a.fake_link').remove(); + } + }); + }); + }); + + observer.observe(document.body, { + childList: true, + 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 0b5ad41..a64aba2 100644 --- a/assets/stylesheets/template/base/_global.scss +++ b/assets/stylesheets/template/base/_global.scss @@ -12,6 +12,10 @@ } } +.login-btn:focus { + outline: 0.3125em auto -webkit-focus-ring-color !important; + transition: all 0.2s ease-in-out!important; +} .orbit-bar-inner{ li.active { @media(min-width:768px){ diff --git a/assets/stylesheets/template/modules/member.scss b/assets/stylesheets/template/modules/member.scss index 1442874..b32195d 100644 --- a/assets/stylesheets/template/modules/member.scss +++ b/assets/stylesheets/template/modules/member.scss @@ -17,18 +17,18 @@ .i-member-pic-wrap{ overflow: hidden; } -.i-member-item{ - &:hover{ - img{ - transform: scale(1.1) !important; - -webkit-transition: .3s ease-out; - -moz-transition: .3s ease-out; - -ms-transition: .3s ease-out; - -o-transition: .3s ease-out; - transition: .3s ease-out; - } - } -} +// .i-member-item{ +// &:hover{ +// img{ +// transform: scale(1.1) !important; +// -webkit-transition: .3s ease-out; +// -moz-transition: .3s ease-out; +// -ms-transition: .3s ease-out; +// -o-transition: .3s ease-out; +// transition: .3s ease-out; +// } +// } +// } // Index 1 .index-member-1 { .i-member__status-title { diff --git a/modules/announcement/_annc_widget1.html.erb b/modules/announcement/_annc_widget1.html.erb index 37a44d2..801531d 100644 --- a/modules/announcement/_annc_widget1.html.erb +++ b/modules/announcement/_annc_widget1.html.erb @@ -7,7 +7,7 @@
- {{img_description}} + {{img_description}}
diff --git a/modules/announcement/_annc_widget15.html.erb b/modules/announcement/_annc_widget15.html.erb index 8135e52..1ae3f85 100644 --- a/modules/announcement/_annc_widget15.html.erb +++ b/modules/announcement/_annc_widget15.html.erb @@ -27,7 +27,7 @@
  • diff --git a/modules/announcement/_annc_widget16.html.erb b/modules/announcement/_annc_widget16.html.erb index 859fe57..dcc68b0 100644 --- a/modules/announcement/_annc_widget16.html.erb +++ b/modules/announcement/_annc_widget16.html.erb @@ -22,7 +22,7 @@
    - {{img_description}} + {{img_description}}
    diff --git a/modules/announcement/_annc_widget18.html.erb b/modules/announcement/_annc_widget18.html.erb index fc7c154..27239f2 100644 --- a/modules/announcement/_annc_widget18.html.erb +++ b/modules/announcement/_annc_widget18.html.erb @@ -9,7 +9,7 @@
  • diff --git a/modules/announcement/_annc_widget2.html.erb b/modules/announcement/_annc_widget2.html.erb index fcd093f..8985c13 100644 --- a/modules/announcement/_annc_widget2.html.erb +++ b/modules/announcement/_annc_widget2.html.erb @@ -6,7 +6,7 @@
  • diff --git a/modules/announcement/_annc_widget20.html.erb b/modules/announcement/_annc_widget20.html.erb index dbb32c2..e5f428d 100644 --- a/modules/announcement/_annc_widget20.html.erb +++ b/modules/announcement/_annc_widget20.html.erb @@ -9,7 +9,7 @@
  • diff --git a/modules/announcement/_annc_widget21.html.erb b/modules/announcement/_annc_widget21.html.erb index 80c9b2f..5e1afff 100644 --- a/modules/announcement/_annc_widget21.html.erb +++ b/modules/announcement/_annc_widget21.html.erb @@ -27,7 +27,7 @@
  • diff --git a/modules/announcement/_annc_widget23.html.erb b/modules/announcement/_annc_widget23.html.erb index 33e64c3..d9cf614 100644 --- a/modules/announcement/_annc_widget23.html.erb +++ b/modules/announcement/_annc_widget23.html.erb @@ -7,7 +7,7 @@
    diff --git a/modules/announcement/_annc_widget24.html.erb b/modules/announcement/_annc_widget24.html.erb index 6dc75ab..110d301 100644 --- a/modules/announcement/_annc_widget24.html.erb +++ b/modules/announcement/_annc_widget24.html.erb @@ -9,7 +9,7 @@
  • diff --git a/modules/announcement/_annc_widget25.html.erb b/modules/announcement/_annc_widget25.html.erb index 85d1e8a..aada901 100644 --- a/modules/announcement/_annc_widget25.html.erb +++ b/modules/announcement/_annc_widget25.html.erb @@ -29,7 +29,7 @@
  • diff --git a/modules/announcement/_annc_widget26.html.erb b/modules/announcement/_annc_widget26.html.erb index 5da89d8..4cab655 100644 --- a/modules/announcement/_annc_widget26.html.erb +++ b/modules/announcement/_annc_widget26.html.erb @@ -7,7 +7,7 @@
    diff --git a/modules/announcement/_annc_widget3.html.erb b/modules/announcement/_annc_widget3.html.erb index 91f218a..bfea3e6 100644 --- a/modules/announcement/_annc_widget3.html.erb +++ b/modules/announcement/_annc_widget3.html.erb @@ -24,7 +24,7 @@

    {{subtitle}}

    - {{img_description}} + {{img_description}}
  • diff --git a/modules/announcement/_annc_widget4.html.erb b/modules/announcement/_annc_widget4.html.erb index 5fb4743..19e695e 100644 --- a/modules/announcement/_annc_widget4.html.erb +++ b/modules/announcement/_annc_widget4.html.erb @@ -9,7 +9,7 @@
  • diff --git a/modules/custom_announcement/_annc_widget1.html.erb b/modules/custom_announcement/_annc_widget1.html.erb index 7874f6a..47ef71f 100644 --- a/modules/custom_announcement/_annc_widget1.html.erb +++ b/modules/custom_announcement/_annc_widget1.html.erb @@ -5,7 +5,7 @@