// 탭메뉴 클래스 넣기 - 요소 존재 확인 후 실행 function initTabMenu() { var h1Element = document.querySelector('.subTop .txt h1'); var sub5h1Element = document.querySelector('.sub5_top .txt h1, .sub1_top .txt h1'); var tabs = document.querySelectorAll('.tabMenu a'); if (h1Element && tabs.length > 0) { // 요소가 있을 때만 실행 var currentPath = window.location.pathname; tabs.forEach(function (tab) { var span = tab.querySelector('span'); // a 안의 span 찾기 if (span) { span.classList.remove('on'); } var tabHref = tab.getAttribute('href'); // a 태그에서 href 가져오기 var hrefMatch = tabHref.match(/(sub\d+\/\d+\.php)/); var pathMatch = currentPath.match(/(sub\d+\/\d+\.php)$/); if (hrefMatch && pathMatch) { var tabSection = hrefMatch[1]; var currentSection = pathMatch[1]; if (tabSection === currentSection) { if (span) { span.classList.add('on'); // span에 클래스 추가 } // 활성화된 탭의 텍스트를 h1에 넣기 var activeTabText = span ? span.textContent : tab.textContent; sub5h1Element.textContent = activeTabText; } } }); } else { // 요소가 없으면 10ms 후 다시 시도 setTimeout(initTabMenu, 10); } } // 즉시 시작 initTabMenu(); $(document).ready(function () { // 애니메이션 효과 AOS.init({ duration: 800, // offset: 100, easing: 'ease-in-out', once: true, // 한번만 실행행 }); $("#gnb ul li p a").click(function () { $("html, body").animate({ scrollTop: $($.attr(this, "href")).offset().top - 100 }, 500); return false; }); // header 메뉴 $(".topnav").hover(function () { $(this).parent().find(".subnav").fadeIn(10).show(); $(this).parent().hover(function () { }, function () { $(this).parent().find(".subnav").fadeOut(10); }); }); // 사이트맵 $('.siteMap').click(function (e) { e.preventDefault(); $('#siteMap').toggleClass('on'); $('.overlay').toggle(); // 오버레이도 함께 토글 }); // 오버레이 클릭시 닫기 // $('.overlay').click(function (e) { // if (e.target === this) { // 배경 클릭시만 // closeSiteMap(); // } // }); // close 버튼 클릭시 닫기 $('span.close').click(function () { closeSiteMap(); }); // 공통 함수 function closeSiteMap() { $('#siteMap').removeClass('on'); $('.overlay').hide(); } // 메인 슬라이드 var swiper001 = new Swiper('.swiper-container-first .swiper0', { loop: true, speed: 900, slidesPerView: 1, loopedSlides: 9, autoplay: { delay: 2500, disableOnInteraction: false }, }); // section2 슬라이드 var swiper1 = new Swiper('.swiper1', { loop: true, speed: 900, slidesPerView: 3, // slidesPerGroup: 3, spaceBetween: 40, loop: true, observer: true, // observeParents: true, loopedSlides: 9, // Navigation arrows navigation: { nextEl: '.swiper-container1 .swiper-button-next', prevEl: '.swiper-container1 .swiper-button-prev', }, autoplay: { delay: 3800, disableOnInteraction: false }, }); // section5 연세정담view var swiper2 = new Swiper('.swiper2', { loop: true, speed: 800, slidesPerView: 3, // slidesPerGroup: 3, spaceBetween: 40, centeredSlides: true, observer: true, // observeParents: true, // If we need pagination pagination: { el: '.swiper-pagination', clickable: true, }, autoplay: { delay: 3000, disableOnInteraction: false }, // Navigation arrows navigation: { nextEl: '.swiper2 .swiper-button-next', prevEl: '.swiper2 .swiper-button-prev', } }); // sub1-4 둘러보기 var swiper3 = new Swiper('.swiper3', { loop: true, slidesPerView: 3, // slidesPerGroup: 3, spaceBetween: 10, centeredSlides: true, observer: true, // observeParents: true, // If we need pagination pagination: { el: '.swiper-pagination', clickable: true, }, autoplay: { delay: 4000, disableOnInteraction: false }, }); var swiper4 = new Swiper('.swiper4', { loop: true, slidesPerView: 3, // slidesPerGroup: 3, spaceBetween: 10, centeredSlides: true, observer: true, // observeParents: true, // If we need pagination pagination: { el: '.swiper-pagination', clickable: true, }, autoplay: { delay: 4000, disableOnInteraction: false }, }); $('#lightgallery1').lightGallery({ selector: '.mySwiper3 .swiper-slide' }); $('#lightgallery2').lightGallery({ selector: '.mySwiper4 .swiper-slide' }); // 치료진 팝업 $('.sub1_03 .doctors li a').click(function (e) { e.preventDefault(); // 치료진 리스트 이미지의 alt찾기 var altText = $(this).find('img').attr('alt'); var matchingPopupImg = $('.sub1_3_popup_wrap .modal img[alt="' + altText + '"]'); // 팝업을 찾았다면 if (matchingPopupImg.length > 0) { // 다른 열려있던 팝업들 모두 닫기 $('.sub1_3_popup_wrap .modal').hide(); // matchingPopupImg.closest('.modal').show(); $('.doctorsBg').addClass('on'); matchingPopupImg.closest('.modal').fadeIn(300); } }) $('.sub1_3_popup_wrap .closeBtn').click(function (e) { e.preventDefault(); e.stopPropagation(); // $('.doctorsBg').removeClass('on'); // $('.sub1_3_popup_wrap .modal').hide(); $('.sub1_3_popup_wrap .modal').fadeOut(300, function () { $('.doctorsBg').removeClass('on'); }); }); $('.sub1_3_popup_wrap .modal').click(function (e) { e.stopPropagation(); }); // 웨일브라우저에서 폰트 굵게 보이는 문제 수정 if (navigator.userAgent.includes('Whale')) { var style = document.createElement('style'); style.innerHTML = ` .subTop .con h1, #sub h2, .subtitle h2, .sub2_01 .s2 .top ul li b, #sub .num, .sub1_5 .info h3, .sub1_5 .info .table h4 { font-family: 'NanumSquareNeoBold', sans-serif !important; } `; document.head.appendChild(style); } });