(function ($) { $(function () { newsMore(); interviewslideControl(); talkslideControl(); talkModal(); galleryslideControl(); dataMore(); faqMore(); faqAccordion(); smoothScroll(); hamburgerMenuControl(); paginationControl(); lottieAnimation(); imageAutoSlideControl(); // sideNavScrollControl(); recruitSpMenuControl(); }); function newsMore() { const $list = $('.news_list'); const $btn = $('.news_more-link'); let isOpen = false; const visibleCount = 2; function getClosedHeight() { let height = 0; $list.find('.news_item').slice(0, visibleCount).each(function () { height += $(this).outerHeight(true); }); return height; } const closedHeight = getClosedHeight(); $list.css({ height: closedHeight, transition: 'height 0.4s ease' }); $btn.on('click', function () { if (!isOpen) { // 開く const fullHeight = $list[0].scrollHeight; $list.css('height', fullHeight); $(this) .addClass('is_active') .text('閉じる'); } else { // 閉じる $list.css('height', closedHeight); $(this) .removeClass('is_active') .text('もっと見る'); } isOpen = !isOpen; }); } function interviewslideControl() { const $slider = $('.interview-slider__main'); if (!$slider.length) return; const slideCount = $slider.find('.swiper-slide').length; const isPc = window.matchMedia('(min-width: 768px)').matches; const mainSwiper = new Swiper(".interview-slider__main", { spaceBetween: 24, slidesPerView: 1.2, slidesPerGroup: 1, breakpoints: { 768: { spaceBetween: 24, slidesPerGroup: 1, slidesPerView: 3.7 } }, navigation: { nextEl: ".interview-slider_control .swiper-button-next", prevEl: ".interview-slider_control .swiper-button-prev", }, pagination: { el: ".interview-slider_control .swiper-pagination", clickable: true, }, on: { init(swiper) { // ▼ PCのみ & 3枚以下のときだけ制御 if (isPc && slideCount <= 3) { const $prev = $('.interview-slider_control .swiper-button-prev'); const $next = $('.interview-slider_control .swiper-button-next'); // 操作を無効化 swiper.allowSlideNext = false; swiper.allowSlidePrev = false; // 見た目を disabled に $prev.addClass('swiper-button-disabled'); $next.addClass('swiper-button-disabled'); // クリック不可 $prev.css('pointer-events', 'none'); $next.css('pointer-events', 'none'); } } } }); } function talkslideControl() { const $slider = $('.talk-slider__main'); if (!$slider.length) return; const slideCount = $slider.find('.swiper-slide').length; const isPc = window.matchMedia('(min-width: 768px)').matches; const talkSwiper = new Swiper(".talk-slider__main", { spaceBetween: 21, slidesPerView: 1.2, slidesPerGroup: 1, breakpoints: { 768: { spaceBetween: 24, slidesPerGroup: 1, slidesPerView: 3.7 } }, navigation: { nextEl: ".talk-slider_control .swiper-button-next", prevEl: ".talk-slider_control .swiper-button-prev", }, pagination: { el: ".talk-slider_control .swiper-pagination", clickable: true, }, on: { init(swiper) { // ▼ PCのみ & 3枚以下 if (isPc && slideCount <= 3) { const $prev = $('.talk-slider_control .swiper-button-prev'); const $next = $('.talk-slider_control .swiper-button-next'); // 操作無効 swiper.allowSlideNext = false; swiper.allowSlidePrev = false; // disabled 表示 $prev.addClass('swiper-button-disabled'); $next.addClass('swiper-button-disabled'); // クリック不可 $prev.css('pointer-events', 'none'); $next.css('pointer-events', 'none'); } } } }); } function talkModal() { const $modal = $("#ytModal"); $modal.iziModal({ title: "", headerColor: "#fff", width: "80%", overlayClose: true, closeOnEscape: true, iframe: true, closeButton: true, onClosing: function () { $modal.find("iframe").attr("src", "about:blank"); } }); $(document).on("click", ".js-open-youtube", function (event) { event.preventDefault(); const videoId = $(this).data("video-id"); const embedUrl = `https://www.youtube.com/embed/${videoId}?autoplay=1&rel=0&enablejsapi=1`; $(this).attr("href", embedUrl); $modal.iziModal("open", event); }); $(document).on("click", ".talk_modal__close", function (event) { $modal.iziModal("close", event); }); } function galleryslideControl() { const gallery = new Swiper(".gallery-slider__main", { spaceBetween: 17, slidesPerView: 1.1, centeredSlides: true, loop: true, breakpoints: { 768: { spaceBetween: 61, } }, navigation: { nextEl: ".gallery-slider__main .swiper-button-next", prevEl: ".gallery-slider__main .swiper-button-prev", }, pagination: { el: ".gallery-slider_control .swiper-pagination", clickable: true, }, }); } // 修正版: dataMore関数 function dataMore() { $('[data-lists-button]').on('click', function () { const $button = $(this); const isExpanded = $button.attr('aria-expanded') === 'true'; const contentId = $button.attr('aria-controls'); const $content = $('#' + contentId); const $labelOpen = $button.find('[data-lists-open]'); const $labelClose = $button.find('[data-lists-close]'); // aria状態更新 $button.attr('aria-expanded', !isExpanded); $content.attr('aria-hidden', isExpanded); // 表示テキスト切り替え $labelOpen.prop('hidden', !isExpanded); $labelClose.prop('hidden', isExpanded); // is_active クラス切り替え $button.toggleClass('is_active', !isExpanded); // slideアニメーション if (isExpanded) { $content.stop(true, true).slideUp(300); } else { $content.stop(true, true).slideDown(300); } }); } function faqMore() { const $wrap = $('.moreBox'); const $btn = $('.faqBox_more'); const $items = $wrap.find('.faqBox'); const visibleCount = 5; // 初期:指定件数以降は非表示 $items.slice(visibleCount).hide(); $btn.on('click', function () { const isOpen = $btn.hasClass('is_active'); $btn.toggleClass('is_active'); $items.slice(visibleCount).slideToggle(300); // 文言切り替え if (!isOpen) { $btn.text('閉じる'); } else { $btn.text('もっと見る'); } }); } function faqAccordion() { const $box = $('.faqBox'); const $title = $('.faqBox_title'); const parentClass = '.faqBox'; const contetntClass = '.faqBox_content'; $box.first().addClass('is_active'); $box.first().find(contetntClass).show(); $title .on('click', function() { $(this).parent(parentClass).toggleClass('is_active'); $(this).next(contetntClass).slideToggle(300); }); } /********************************************* * * smoothScroll() * するするスクロール * data-smoothscroll="true" を付ける * * 固定ヘッダーの場合ヘッダーに * data-smoothscroll-fixed-header="true" を付ける * **********************************************/ function smoothScroll() { //特定のリンクをクリックしたら $('[data-smoothscroll="true"]').on('click', function () { var hash = $(this).attr('href'); if (hash === '#') { hash = 'html'; } scrollToAnchor(hash); return false; }); //別ページのページ内リンクに飛ぶ場合 var urlHash = location.hash; if(urlHash) { $('body,html').stop().scrollTop(0); $(window).on('load',function(){ setTimeout(function () { scrollToAnchor(urlHash); }, 100); }); } function scrollToAnchor(hash) { var $target = $(hash); var $fixedHeader = $('[data-smoothscroll-fixed-header="true"]'); var minusHeight = 0; var position = 0; if (!$target.length) { return false; } if ($fixedHeader.length) { minusHeight = $fixedHeader.outerHeight(); } position = $target.offset().top - minusHeight; $('body,html').stop().animate({ scrollTop: position }, 500); } } // ---------------------------------------------------- // ハンバーガーメニュー制御 // ---------------------------------------------------- function hamburgerMenuControl() { const hamburger = document.querySelector('.js-hamburger'); const spMenu = document.getElementById('js-spMenu'); const header = document.querySelector('.st-siteHeader'); const menuLinks = document.querySelectorAll('.side-nav_list a'); if (!hamburger || !spMenu || !header) return; // ▼ 開閉 hamburger.addEventListener('click', function () { const isOpen = hamburger.classList.toggle('is-open'); spMenu.classList.toggle('is-open'); // ▼ 追加:開閉に合わせて body スクロール制御 if (isOpen) { document.body.classList.add('is-fixed'); } else { document.body.classList.remove('is-fixed'); } }); // ▼ メニュー内のリンククリック → メニュー閉じる & スクロール解除 menuLinks.forEach(link => { link.addEventListener('click', () => { hamburger.classList.remove('is-open'); spMenu.classList.remove('is-open'); document.body.classList.remove('is-fixed'); // ← ここで必ず解除 }); }); // ▼ ヘッダー表示状態で top を切り替え const observer = new IntersectionObserver( (entries) => { entries.forEach(entry => { if (entry.isIntersecting) { hamburger.style.top = '76px'; } else { hamburger.style.top = '20px'; } }); }, { root: null, threshold: 0, } ); observer.observe(header); // ← これを忘れてると何も起きない document.addEventListener('DOMContentLoaded', function () { hamburgerMenuControl(); }); } // ---------------------------------------------------- // コラムページネーション // ---------------------------------------------------- function paginationControl() { const $pagination = $('#pagination'); const $items = $('.column_list .column_item'); const perPage = 5; const totalItems = $items.length; const totalPages = Math.max(1, Math.ceil(totalItems / perPage)); $pagination.empty(); // <(prev) const $prev = $('', { text: '‹', // ←のデザイン寄せ href: '#', class: 'pagination-prev' }); $pagination.append($prev); // ページ番号生成 for (let i = 1; i <= totalPages; i++) { const $page = $('', { text: i, href: '#', class: i === 1 ? 'is-current' : '' }); $pagination.append($page); } // >(next) const $next = $('', { text: '›', href: '#', class: 'pagination-next' }); $pagination.append($next); // 初期表示 showPage(1); updateArrow(1); // イベント設定 $pagination.off('click.pagination').on('click.pagination', 'a', function (e) { e.preventDefault(); let current = parseInt($pagination.find('.is-current').text(), 10); // < if ($(this).hasClass('pagination-prev')) { if (current > 1) setPage(current - 1); return; } // > if ($(this).hasClass('pagination-next')) { if (current < totalPages) setPage(current + 1); return; } // 数字クリック const num = parseInt($(this).text(), 10); if (!isNaN(num)) setPage(num); }); function setPage(page) { $pagination.find('a').removeClass('is-current'); $pagination.find('a').each(function () { if ($(this).text() == page) $(this).addClass('is-current'); }); showPage(page); updateArrow(page); // ★ ページ変更後に上部へスクロール window.scrollTo({ top: 0, behavior: "smooth" }); } function showPage(page) { const start = (page - 1) * perPage; const end = start + perPage; $items.each(function (i) { $(this).toggle(i >= start && i < end); }); } function updateArrow(page) { $pagination.find('.pagination-prev').toggleClass('is-disabled', page === 1); $pagination.find('.pagination-next').toggleClass('is-disabled', page === totalPages); } } // ---------------------------------------------------- // Lottieアニメーション // ---------------------------------------------------- function lottieAnimation() { const $lottieContainer = $('#lottie'); // lottie要素が存在しない場合は処理をスキップ if (!$lottieContainer.length) { return; } // HTMLからパスを取得 const lottiePath = $lottieContainer.data('lottie-path'); if (!lottiePath) { console.warn('Lottieのパスが指定されていません'); return; } lottie.loadAnimation({ container: $lottieContainer[0], renderer: 'svg', loop: true, autoplay: true, path: lottiePath }); } // ---------------------------------------------------- // accelvoiceスライドアニメーション // ---------------------------------------------------- function imageAutoSlideControl() { const imageSwiper = document.querySelector('.swiper_image'); if (!imageSwiper) return; // 対象がなければ何もしない new Swiper('.swiper_image', { loop: true, slidesPerView: 1, speed: 800, autoplay: { delay: 3000, disableOnInteraction: false, }, allowTouchMove: false, // 完全自動 }); } // ---------------------------------------------------- // サイドナビ スクロール時 opacity 制御(SP除外) // ---------------------------------------------------- // function sideNavScrollControl() { // const $sideNav = $('.page_recruit-top .side-nav'); // if (!$sideNav.length) return; // // SPは処理しない // if (window.matchMedia('(max-width: 767px)').matches) { // $sideNav.removeClass('is-scrolled'); // return; // } // $(window).on('scroll', function () { // if ($(this).scrollTop() > 0) { // $sideNav.addClass('is-scrolled'); // } else { // $sideNav.removeClass('is-scrolled'); // } // }); // } // ---------------------------------------------------- // 採用サイト SPメニュー制御 // ---------------------------------------------------- function recruitSpMenuControl() { const $menuBtn = $('.recruit-site_menu-btn'); const $menuWrap = $('.recruit-site_menu-sp'); const active = 'is-active'; if (!$menuBtn.length || !$menuWrap.length) return; $menuBtn.on('click', function () { const isOpen = $menuWrap.hasClass(active); if (isOpen) { $menuWrap.removeClass(active); $(this).text('Menu'); $('body').removeClass('is-fixed'); } else { $menuWrap.addClass(active); $(this).text('Close'); $('body').addClass('is-fixed'); } }); // メニュー内リンク押下で閉じる $menuWrap.find('a').on('click', function () { $menuWrap.removeClass(active); $menuBtn.text('Menu'); $('body').removeClass('is-fixed'); }); } })(jQuery);