This commit is contained in:
ken 2026-08-05 15:44:44 +08:00
parent b763199510
commit fa33de0d34
9 changed files with 197 additions and 74 deletions

View File

@ -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);
}
}
}
}
// ✅ 符合 HM1240404Etitle 不應與連結文字或圖片 alt 重複
if (hasOriginalTitle && currentTitle !== "") {
var titleWithoutWindow = currentTitle
.replace('(在本視窗開啟)', '')
.replace('(在新視窗開啟)', '')
.replace('Open in this window', '')
.replace('Open in new window', '')
.replace('另開新視窗前往', '')
.replace('另開新視窗', '')
.trim();
// ✅ 符合 HM1240404Etitle 不應與連結文字或圖片 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');
});
@ -2314,7 +2317,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();
@ -2382,7 +2385,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) {
@ -3074,6 +3077,104 @@ $(document).ready(function () {
fixSortLinkA11y();
fixSearchInputA11y();
}, 500);
});
setTimeout(function() {
var found = false;
$('.navbar-header a[accesskey="M"]').each(function() {
if (found) {
$(this).remove();
} else {
found = true;
}
});
}, 1000);
function fixTabFocusA11y() {
var TAB_ID_MAP = {
'榮譽榜公告': '68d39935085777e3d824750d',
'招生公告': '68d39945085777e3d8247519',
'學校公告': '68d39952085777e3d8247525',
'系所公告': '68d39960085777e3d8247531',
'實習徵才公告': '68d3996f085777e3d824753d',
'校外資訊': '68d3997d085777e3d8247549'
};
// 更新 tab li 加上 aria-controls 關聯
$('.tab_nav2 li').each(function () {
var text = $.trim($(this).text());
var targetId = TAB_ID_MAP[text];
if (targetId) {
$(this).attr('aria-controls', targetId);
}
});
// 移除舊的 click 事件,重新綁定含焦點移轉的版本
$('.tab_nav2 li').off('click').on('click', function () {
var text = $.trim($(this).text());
var targetId = TAB_ID_MAP[text];
if (!targetId) return;
var $target = $('[data-subpart-id="' + targetId + '"]');
if (!$target.length) return;
// 找到區塊內第一個可聚焦的元素
var $firstFocusable = $target.find(
'a, button, input, select, textarea, [tabindex]:not([tabindex="-1"])'
).filter(':visible').first();
// 捲動到目標區塊
$('html, body').animate({
scrollTop: $target.offset().top - 200
}, 500, function () {
if ($firstFocusable.length) {
// 有可聚焦元素就直接 focus 到第一個
$firstFocusable.focus();
} else {
// 沒有的話 fallback 到區塊本身
$target.attr('tabindex', '-1').focus();
}
});
});
// 鍵盤 Enter / Space 也觸發同樣行為
$('.tab_nav2 li').off('keydown.tabFocus').on('keydown.tabFocus', function (e) {
if (e.keyCode === 13 || e.keyCode === 32) {
e.preventDefault();
$(this).trigger('click');
}
});
}
$(document).ready(function () {
setTimeout(fixTabFocusA11y, 500);
});
function fixYoutubeiframeTitle() {
// 建立影片 ID 對應標題的對照表
var YOUTUBE_TITLE_MAP = {
'0HJlYrG4FCk': '國立虎尾科技大學多媒體設計系系所介紹影片'
// 可繼續補充其他影片 ID 與對應標題
// 'xxxxxxxx': '另一支影片的描述'
};
$('iframe[src*="youtube.com/embed"]').each(function () {
var $iframe = $(this);
var src = $iframe.attr('src') || '';
// 從 src 取得影片 ID
var match = src.match(/youtube\.com\/embed\/([^?&]+)/);
if (!match) return;
var videoId = match[1];
// 若 title 是無意義的預設值
var currentTitle = $iframe.attr('title') || '';
if (currentTitle === '' || currentTitle.toLowerCase() === 'youtube') {
var newTitle = YOUTUBE_TITLE_MAP[videoId] || '嵌入式 YouTube 影片影片ID' + videoId + '';
$iframe.attr('title', newTitle);
}
});
}
$(document).ready(function () {
setTimeout(fixYoutubeiframeTitle, 500);
});
// 執行 member等高計算目前改用flexbox故mark掉 by ika 20160105
// $(window).load(function() {

View File

@ -3,7 +3,7 @@
a[accesskey] {
position: absolute;
margin-left: -0.9375em;
color: transparent !important;
color: #fff !important;
background:transparent !important ;
border:transparent!important;
}
@ -21,6 +21,7 @@ a[accesskey] {
position: relative!important;
margin-left: -0.9375em;
color: transparent !important;
float: left;
}
}

View File

@ -28,16 +28,16 @@
}
}
}
label[for="open-orbit-login"] {
@media(max-width:768px){
display: none!important;
}
}
[accesskey="U"],[accesskey="W"]{
@media(max-width:768px){
color: #666!important;
}
}
// label[for="open-orbit-login"] {
// @media(max-width:768px){
// display: none!important;
// }
// }
// [accesskey="U"],[accesskey="W"]{
// @media(max-width:768px){
// color: #666!important;
// }
// }
.orbit-bar-inner{
[accesskey="U"]{
height: 40px;

View File

@ -77,7 +77,7 @@
}
.header-banner { overflow: hidden; }
.header-nav {
padding:2em 0 0 0;
padding:1em 0 0 0;
font-family: $main-font;
text-transform:uppercase;
display: flex;
@ -121,12 +121,6 @@
z-index: 10;
padding: 0;
margin: 0;
@media(min-width:769px){
}
@media (min-width: 769px){
float: none!important;
}
// @media (max-width: $screen-sm) {
// width: 100%;
// display: flex;

View File

@ -7,6 +7,9 @@
//
// Widget
// ## gerenral styles
.i-archive__file-name {
white-space: normal;
}
.i-archive__list{
.date-thead{
min-width: 4em;

View File

@ -22,10 +22,7 @@
<div class="outdropdowns kenjohn">
<div class="dropdowns">
<div class="container header-container">
<div class="header-nav no-print">
<a id="accesskey_top" accesskey="U" title="accesskey top" href="#" title="Toolbar">:::</a>
{{header-data}}
</div>
<div class="navbar-header">
<a title="{{site_title_1}}" class="navbar-brand" href="{{home_link_1}}"><img class="site-logo" src="{{logo_url_1}}" alt="site-logo"></a>
<script>$(document).ready(function(){var url =$('.site-logo').eq(0).attr('src');if(url == "/assets/default-site-logo.png"){$('.navbar-brand').eq(0).remove();};if($('.navbar-brand').length == 2){$('.site-logo').css('height','auto')};$('.site-logo').eq(0).css('margin-right',0);$('.navbar-brand').css('padding-right',0)})</script>
@ -37,10 +34,13 @@
<span class="icon-bar icon-bar-bottom"></span>
</button>
</div>
<div class="header-nav no-print">
<a id="accesskey_top" accesskey="U" title="accesskey top" href="#" title="Toolbar">:::</a>
{{header-data}}
</div>
</div>
<div class="collapse navbar-collapse modules-menu" id="layout-navigation">
<a id="accesskey_menu" title="accesskey menu" accesskey="M" href="#" title="Main menu">:::</a>
<%= render_menu %>
</div>
<!-- <div class="header-buttom layout-content-box " data-pp="200"></div> -->

View File

@ -14,8 +14,8 @@
</dt>
<dl class="i-archive__file-list" data-list="files" data-level="2">
<dd class="i-archive__file-wrap">
<a class="i-archive__file-name" href="{{file-url}}" target="{{target}}" title="{{file-name}}">{{file-name}}</a>
<span class="i-archive__file-type label label-primary {{file-type}}">{{file-type}}</span>
<a class="i-archive__file-name" href="{{file-url}}" target="{{target}}" title="{{file-name}}">{{file-name}} <span class="i-archive__file-type label label-primary {{file-type}}">{{file-type}}</span>
</a>
</dd>
</dl>
</div>

View File

@ -3,8 +3,8 @@
<span>{{album-title}}</span>
</h1>
{{album-description}}
<div data-level="0" data-list="images">
<div class="show-content col-sm-4">
<div class="show-gallery-list" data-level="0" data-list="images">
<div class="show-content col-xs-6 col-sm-4">
<div class="show-content-inner">
<div class="show-pic">
<a href="{{link_to_show}}" onclick="window.location.hash = '{{link_to_show}}';GalleryTheater();return false;">
@ -15,4 +15,28 @@
</div>
</div>
</div>
</div>
</div>
<style>
.show-gallery-list{
display: flex;
flex-wrap: wrap;
}
.show-gallery .show-content {
@media(max-width:480px){
width:100%;
}
}
</style>
<script>
setTimeout(function() {
var albumTitle = $('.show-title span').text().trim();
$('.show-content').each(function(index) {
var $img = $(this).find('img');
if ($img.attr('alt') === 'gallery image') {
$img.attr('alt', albumTitle + (index + 1));
}
});
}, 500);
</script>

View File

@ -9,7 +9,7 @@
<div class="link-img-wrap{{display_image}}">
<img src="{{img_src}}" alt="{{img_description}}" title="{{img_description}}">
</div>
<a class="widget-content-title" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}">{{title}}</a>
<a class="widget-content-title" href="{{link_to_show}}" target="{{target}}" title="{{title_text}}" onclick="{{onclick}}">{{title}}</a>
<span data-list="statuses" data-level="1">
<span class="label status {{status-class}}">{{status}}</span>
</span>