// 탭메뉴 클래스 넣기 - 요소 존재 확인 후 실행 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 li = tab.parentElement; // a의 부모 li 찾기 if (li) { li.classList.remove('on'); } var tabHref = tab.getAttribute('href'); // a 태그에서 href 가져오기 // 뒤에서부터 매칭 - sub3/01.php 형식 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 (li) { li.classList.add('on'); // li에 클래스 추가 } // 활성화된 탭의 텍스트를 h1에 넣기 var span = tab.querySelector('span'); var activeTabText = span ? span.textContent : tab.textContent; sub5h1Element.textContent = activeTabText; } } }); } else { // 요소가 없으면 10ms 후 다시 시도 setTimeout(initTabMenu, 10); } } // 즉시 시작 initTabMenu(); $(document).ready(function () { // 애니메이션 효과 AOS.init({ duration: 700, offset: -20, 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, observer: true, effect: "fade", autoplay: { delay: 2500, disableOnInteraction: false }, pagination: { el: '.swiper-pagination', clickable: true, } }); // section2 슬라이드 var swiper1 = new Swiper('.swiper1', { loop: true, speed: 900, slidesPerView: 1.7, // 또는 1.5, 2.2 등 centeredSlides: true, spaceBetween: 50, // slidesPerGroup: 3, 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 }, breakpoints: { 300: { slidesPerView: 1, spaceBetween: 50, }, 400: { slidesPerView: 1.3, spaceBetween: 40, }, 500: { slidesPerView: 1.4, spaceBetween: 30, }, } }); // section5 연세정담view var swiper2 = new Swiper('.swiper2', { loop: true, speed: 800, slidesPerView: 1, // slidesPerGroup: 3, spaceBetween: 20, 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: 1, // 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: 1, // 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(); 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(); // 현재 화면 중앙에 팝업 위치 var scrollTop = $(window).scrollTop(); var windowHeight = $(window).height(); matchingPopupImg.closest('.modal').css({ 'position': 'absolute', 'top': scrollTop + (-470) + 'px', // 상단에서 50px 아래 'left': '50%', 'transform': 'translateX(-50%)' }); $('.doctorsBg').addClass('on'); matchingPopupImg.closest('.modal').fadeIn(300); } }) $('.sub1_3_popup_wrap .closeBtn').click(function (e) { e.preventDefault(); e.stopPropagation(); $('.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); } });