diff --git a/assets/javascripts/app.js b/assets/javascripts/app.js index 07c5a43..00d9c6b 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 === "裝飾圖片" || currentAlt === "這是一張圖片" || currentTitle === "這是一張圖片") { + if (currentAlt === "announcement image" || currentAlt === "裝飾圖片" || currentTitle === "裝飾圖片" || currentAlt === "這是一張圖片" || currentTitle === "這是一張圖片"||currentAlt === "This is a image" ||currentTitle === "This is a image"){ $img.attr('alt', ''); $img.removeAttr('title'); return; @@ -2674,18 +2674,39 @@ $(function() { var $mobileBtn = $('.mobile-button'); if ($mobileBtn.length > 0) { $mobileBtn.attr({ 'role': 'button', 'tabindex': '0', 'aria-haspopup': 'true', 'aria-expanded': 'false' }); + // ✅ 找到 app.js 2677 行這段,改為: $mobileBtn.on('focus', function() { - $(this).closest('li').find('ul').addClass('show'); - $(this).attr('aria-expanded', 'true'); - }); - $mobileBtn.on('keydown', function(e) { - if (e.which === 13 || e.which === 32) { - e.preventDefault(); - var $ul = $(this).closest('li').find('ul'); - $ul.toggleClass('show'); - $(this).attr('aria-expanded', $ul.hasClass('show') ? 'true' : 'false'); + var isExpanded = $(this).attr('aria-expanded') === 'true'; + // ✅ 只在未展開時才展開,避免覆蓋 Enter 收合後的狀態 + if (!isExpanded) { + $(this).closest('li').find('ul').addClass('show'); + $(this).attr('aria-expanded', 'true'); } }); +$mobileBtn.on('keydown', function(e) { + if (e.which === 13 || e.which === 32) { + e.preventDefault(); + var $btn = $(this); + var $ul = $btn.closest('li').find('ul'); + var isExpanded = $btn.attr('aria-expanded') === 'true'; + if (isExpanded) { + $ul.removeClass('show'); + $btn.attr('aria-expanded', 'false'); + } else { + $ul.addClass('show'); + $btn.attr('aria-expanded', 'true'); + setTimeout(function() { + $ul.find('a').first().focus(); + }, 50); + } + } + if (e.which === 27) { + var $btn = $(this); + var $ul = $btn.closest('li').find('ul'); + $ul.removeClass('show'); + $btn.attr('aria-expanded', 'false'); + } +}); $('#language-li-ul').on('focusout', function() { var $container = $(this); setTimeout(function() { @@ -3280,6 +3301,66 @@ $(function() { fixOrbitBarLabelToButton(); }, 200); }); +}); +$(function() { + function fixNavDropdownKeyboard() { + setTimeout(function() { + // ✅ 找所有有子選單的父層連結 + $('#main-nav > li > a[aria-haspopup="true"]').each(function() { + var $parentLink = $(this); + var $submenu = $parentLink.next('ul'); + if ($submenu.length === 0) return; + + $parentLink.off('keydown.navDropdown').on('keydown.navDropdown', function(e) { + // ✅ Enter 鍵:若選單已展開則收合,未展開則展開(不跳頁) + if (e.which === 13) { + var isExpanded = $parentLink.attr('aria-expanded') === 'true'; + if (isExpanded) { + e.preventDefault(); // ✅ 阻止跳頁 + $parentLink.attr('aria-expanded', 'false'); + $submenu.removeClass('show'); + } + // 未展開時讓原本的 hover/focus 展開邏輯處理,不攔截 + } + + // ✅ Escape 鍵收合 + if (e.which === 27) { + $parentLink.attr('aria-expanded', 'false'); + $submenu.removeClass('show'); + $parentLink.focus(); + } + }); + }); + + // ✅ 二層子選單同樣處理 + $('#main-nav li > a[aria-haspopup="true"]').filter(function() { + return $(this).closest('ul').hasClass('modules-menu-level-1'); + }).each(function() { + var $parentLink = $(this); + var $submenu = $parentLink.next('ul'); + if ($submenu.length === 0) return; + + $parentLink.off('keydown.navDropdown2').on('keydown.navDropdown2', function(e) { + if (e.which === 13) { + var isExpanded = $parentLink.attr('aria-expanded') === 'true'; + if (isExpanded) { + e.preventDefault(); + $parentLink.attr('aria-expanded', 'false'); + $submenu.removeClass('show'); + } + } + if (e.which === 27) { + $parentLink.attr('aria-expanded', 'false'); + $submenu.removeClass('show'); + $parentLink.focus(); + } + }); + }); + + }, 500); + } + + fixNavDropdownKeyboard(); }); // 執行 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 fa9166d..72dbcc8 100644 --- a/assets/stylesheets/template/base/_global.scss +++ b/assets/stylesheets/template/base/_global.scss @@ -8,6 +8,11 @@ .fa-classic, .fa-regular, .fa-solid, .far, .fas ,.fa{ font-family: "FontAwesome"; } +li#language-li { + @media(max-width:767px){ + display: none !important; + } +} #orbit-bar .orbit-bar-inner > label:focus, #orbit-bar .orbit-bar-inner > label.focus{ .orbit-bar-search-sign-language{ display: block diff --git a/assets/stylesheets/template/layout/header.scss b/assets/stylesheets/template/layout/header.scss index 0801304..d224efb 100644 --- a/assets/stylesheets/template/layout/header.scss +++ b/assets/stylesheets/template/layout/header.scss @@ -1,6 +1,11 @@ @charset "utf-8"; @import "../initial"; +li#language-li { + @media(max-width:767px){ + display: none !important; + } +} @media (max-width: 540px) { body #orbit-bar .orbit-bar-inner>button { border-color: #fff; diff --git a/modules/ad_banner/_ad_banner_widget2.html.erb b/modules/ad_banner/_ad_banner_widget2.html.erb index 70ef492..6cc584d 100644 --- a/modules/ad_banner/_ad_banner_widget2.html.erb +++ b/modules/ad_banner/_ad_banner_widget2.html.erb @@ -49,20 +49,23 @@