diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index 49213b5..d94891c 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -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('' + label + ''); + } + + // 補上 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() { @@ -2313,7 +2357,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(); @@ -2381,7 +2425,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) { @@ -3166,6 +3210,16 @@ $(document).ready(function () { setTimeout(function() { $('.internal-page .ad-banner-widget-0 .w-ad-banner__image').attr('alt', ''); }, 800); +setTimeout(function() { + var found = false; + $('.navbar-header a[accesskey="M"]').each(function() { + if (found) { + $(this).remove(); + } else { + found = true; + } + }); +}, 1000); // 執行 member等高計算,目前改用flexbox故mark掉 by ika 20160105 // $(window).load(function() { // if ($('.index-member-3').length && $(window).width() > 992) { diff --git a/assets/stylesheets/template/base/_accesskey.scss b/assets/stylesheets/template/base/_accesskey.scss index 2cef1cf..1f3788e 100644 --- a/assets/stylesheets/template/base/_accesskey.scss +++ b/assets/stylesheets/template/base/_accesskey.scss @@ -18,6 +18,7 @@ a[accesskey] { a[accesskey] { position: relative!important; margin-left: -0.9375em; - color: transparent !important; + color: transparent ; + float: left; } } diff --git a/assets/stylesheets/template/base/_go_back_top.scss b/assets/stylesheets/template/base/_go_back_top.scss index 1f9e4d5..cc6276d 100644 --- a/assets/stylesheets/template/base/_go_back_top.scss +++ b/assets/stylesheets/template/base/_go_back_top.scss @@ -3,7 +3,7 @@ @import "variables"; .go-back-top { - background:#00000080; + background:#2760b0; text-align: center; padding: 0.625em 0.75em; position: fixed; diff --git a/assets/stylesheets/template/layout/footer.scss b/assets/stylesheets/template/layout/footer.scss index 2da65b6..61844d1 100644 --- a/assets/stylesheets/template/layout/footer.scss +++ b/assets/stylesheets/template/layout/footer.scss @@ -6,7 +6,7 @@ z-index: 1; clear: both; color: #E4E4E4; - background: url(/assets/bg_footer.png) repeat #24436E; + background: url(/assets/bg_footer.png) repeat #183864; position: relative; padding: 2em 0; color: $theme-color-main; diff --git a/assets/stylesheets/template/layout/header.scss b/assets/stylesheets/template/layout/header.scss index 39deb6c..af3ea82 100644 --- a/assets/stylesheets/template/layout/header.scss +++ b/assets/stylesheets/template/layout/header.scss @@ -95,6 +95,9 @@ display: flex; align-items: center; justify-content: flex-end; + @media(max-width:768px){ + width: 100%; + } ul{ padding: 0; } @@ -122,7 +125,7 @@ text-decoration: none; padding:5px; } - + @media (min-width:1025px) { position: relative; } @@ -139,14 +142,6 @@ margin-top: 1em!important; margin-bottom: 1em!important; } - @media (min-width: 769px){ - float: none!important; - } - // @media (max-width: $screen-sm) { - // width: 100%; - // display: flex; - // flex-flow: row-reverse; - // } .navbar-brand { line-height: 2.125em; color: $theme-color-main; diff --git a/assets/stylesheets/template/modules/announcement.scss b/assets/stylesheets/template/modules/announcement.scss index 91ae5eb..c132da2 100644 --- a/assets/stylesheets/template/modules/announcement.scss +++ b/assets/stylesheets/template/modules/announcement.scss @@ -2010,6 +2010,9 @@ a.w-annc__more.btn.btn-primary.pull-right { text-align: center; border-radius: 0; background: #2f4877!important; + .en{ + color: #f2f2f2!important; + } } .w-annc__more-wrap{ padding-right: 1em; diff --git a/home/header.html.erb b/home/header.html.erb index 38762d1..34a8ef7 100644 --- a/home/header.html.erb +++ b/home/header.html.erb @@ -21,21 +21,23 @@