From 5cc38aee0ad6c3c1290b24e188e710de8bb29895 Mon Sep 17 00:00:00 2001 From: ken Date: Fri, 7 Aug 2026 10:12:36 +0800 Subject: [PATCH] update --- assets/javascripts/app.js | 89 ++++++++++--------- .../template/modules/announcement.scss | 3 + modules/archive/archive_index14.html.erb | 3 +- .../web_resource/_web_res_widget1.html.erb | 2 +- .../web_resource/_web_res_widget2.html.erb | 2 +- .../web_resource/_web_res_widget7.html.erb | 2 +- .../web_resource/_web_res_widget8.html.erb | 2 +- .../web_resource/_web_res_widget9.html.erb | 2 +- modules/web_resource/web_res_index1.html.erb | 2 +- modules/web_resource/web_res_index2.html.erb | 2 +- 10 files changed, 57 insertions(+), 52 deletions(-) diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index f7a825e..db9de37 100644 --- a/assets/javascripts/app.js +++ b/assets/javascripts/app.js @@ -1130,56 +1130,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'); }); diff --git a/assets/stylesheets/template/modules/announcement.scss b/assets/stylesheets/template/modules/announcement.scss index 54fb0f5..253b9d5 100644 --- a/assets/stylesheets/template/modules/announcement.scss +++ b/assets/stylesheets/template/modules/announcement.scss @@ -8,6 +8,9 @@ // Announcement widget // ## Gerneral styles for widgets +td.i-annc__postdate { + min-width: 7em; +} strong.carousel__description{ color: #333!important; } diff --git a/modules/archive/archive_index14.html.erb b/modules/archive/archive_index14.html.erb index 619ab08..8a62923 100644 --- a/modules/archive/archive_index14.html.erb +++ b/modules/archive/archive_index14.html.erb @@ -18,8 +18,7 @@
diff --git a/modules/web_resource/_web_res_widget1.html.erb b/modules/web_resource/_web_res_widget1.html.erb index d42d07e..921269f 100644 --- a/modules/web_resource/_web_res_widget1.html.erb +++ b/modules/web_resource/_web_res_widget1.html.erb @@ -6,7 +6,7 @@
  • {{title}} diff --git a/modules/web_resource/_web_res_widget2.html.erb b/modules/web_resource/_web_res_widget2.html.erb index 41e4694..bcb3f56 100644 --- a/modules/web_resource/_web_res_widget2.html.erb +++ b/modules/web_resource/_web_res_widget2.html.erb @@ -7,7 +7,7 @@
    diff --git a/modules/web_resource/_web_res_widget7.html.erb b/modules/web_resource/_web_res_widget7.html.erb index 702a940..96aa10f 100644 --- a/modules/web_resource/_web_res_widget7.html.erb +++ b/modules/web_resource/_web_res_widget7.html.erb @@ -6,7 +6,7 @@
  • diff --git a/modules/web_resource/_web_res_widget8.html.erb b/modules/web_resource/_web_res_widget8.html.erb index a3a4996..a1fb269 100644 --- a/modules/web_resource/_web_res_widget8.html.erb +++ b/modules/web_resource/_web_res_widget8.html.erb @@ -6,7 +6,7 @@
  • {{title}} diff --git a/modules/web_resource/_web_res_widget9.html.erb b/modules/web_resource/_web_res_widget9.html.erb index 82f1aa7..6b159c1 100644 --- a/modules/web_resource/_web_res_widget9.html.erb +++ b/modules/web_resource/_web_res_widget9.html.erb @@ -7,7 +7,7 @@
    {{title}} diff --git a/modules/web_resource/web_res_index1.html.erb b/modules/web_resource/web_res_index1.html.erb index 23715b0..cc5c3a7 100644 --- a/modules/web_resource/web_res_index1.html.erb +++ b/modules/web_resource/web_res_index1.html.erb @@ -6,7 +6,7 @@
  • {{title}} diff --git a/modules/web_resource/web_res_index2.html.erb b/modules/web_resource/web_res_index2.html.erb index f41769a..4bb2d57 100644 --- a/modules/web_resource/web_res_index2.html.erb +++ b/modules/web_resource/web_res_index2.html.erb @@ -6,7 +6,7 @@