$(document).ready(function() { /*------------------------- heroheader -------------------------*/ $(".hamburger").click(function(){ $(".navbox").addClass("show"); }); $(".close_hamburger").click(function(){ $(".navbox").removeClass("show"); }); $(".dropBt").on('click',function(e) { e.preventDefault(); $(this) .siblings(".haveDrop") .toggleClass("open"); $(this) .closest(".toggleIcon") .toggleClass("closebt"); $(this) .parent() .siblings() .find(".dropBt") .removeClass("active"); $(this) .parent() .siblings() .find(".haveDrop") .removeClass("open"); $(this) .parent() .siblings() .find(".toggleIcon") .removeClass("closebt"); }); $(".navbox").on('mouseleave', function() { // 移除之前添加的类 $(".haveDrop").removeClass("open"); $(".toggleIcon").removeClass("closebt"); $(".dropBt").removeClass("active"); }); $(".mod-language").click(function () { $(".language-content").toggle(200); }); $(".mod-language").on('mouseleave', function() { $(".language-content").hide(200); }); $(".mod-message").click(function () { $(".message-content").toggle(200); }); $(".mod-message").on('mouseleave', function() { $(".message-content").hide(200); }); $(".lineshare").click(function () { $(".lineshare-content").toggle(200); }); $(".lineshare").on('mouseleave', function() { $(".lineshare-content").hide(200); }); $(".membernav").click(function () { $(".lists").toggle(200); }); // $(".membernav").on('mouseleave', function() { // $(".lists").hide(200); // }); $(".moreopen").click(function () { $(this).find('.more-inner').toggle(200); }); $(".ic_more").click(function () { $(".sidenav").toggle(200); }); $('.ringopen').click(function() { $(this).closest('.items').find('.drop').toggle(200); $(this) .parent().parent() .siblings() .find(".drop") .hide(200); $(this).closest('.items').find('.ringopen').toggleClass('show'); $(this) .parent().parent() .siblings() .find(".ringopen") .removeClass('show'); }); $('.titleopen').click(function() { $(this).parent().find('.drop').toggle(200); $(this) .parent().parent() .siblings() .find(".drop") .hide(200); $(this) .parent().parent() .siblings() .find(".ringopen") .removeClass('show'); }); /*------------------------- 輪撥 -------------------------*/ var swiper = new Swiper(".categorySwiper2", { slidesPerView: 2, spaceBetween: 12, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, breakpoints: { 680: { slidesPerView: 5, spaceBetween: 12, }, }, }); /*------------------------- lightbox -------------------------*/ $(".lightbox-close").click(function () { $(".lightbox-target").removeClass('lightboxopen'); }); $(".newmargin").click(function () { $(".lightbox-margin").addClass('lightboxopen'); }); $(".esgfuture").click(function () { $(".lightbox-esgfuture").addClass('lightboxopen'); }); /*------------------------- 選單位置 -------------------------*/ // 初始化 Swiper var categorySwiper2 = new Swiper(".categorySwiper2", { slidesPerView: "auto", navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, }); // 取得 hash(例如 #intern_plan) var currentHash = window.location.hash; if (currentHash) { // 清除所有 active $(".swiper-slide a").removeClass("active"); // 根據 hash 加上 active,並滑動到該 slide $(".swiper-slide a").each(function () { if ($(this).attr("href").endsWith(currentHash)) { $(this).addClass("active"); // 找出該 slide 的 index,滑動過去 var index = $(this).closest(".swiper-slide").index(); categorySwiper2.slideTo(index, 500); } }); } $('.history button').click(function() { // 先移除所有 .history 元素上的 open 類 $('.history').removeClass('open'); // 然後只給當前點擊按鈕的父元素添加 open 類 $(this).closest('.history').toggleClass('open'); }); // 標籤點擊事件 $('.tab').click(function() { // 移除所有標籤和內容區域的活動狀態 $('.tab').removeClass('active'); $('.tab-content').removeClass('active'); // 為當前點擊的標籤添加活動狀態 $(this).addClass('active'); // 獲取對應的內容區域並顯示 var tabId = $(this).attr('data-tab'); $('#' + tabId).addClass('active'); }); /*------------------------- 文件ready ok jquery結束 -------------------------*/ });