// ハンバーガーメニュー const header = document.querySelector('.site-header'); const menuBtn = document.querySelector('.open-button'); const nav = document.querySelector('.nav-global'); menuBtn.addEventListener('click', () => { header.classList.toggle('on') menuBtn.classList.toggle('open'); nav.classList.toggle('open'); }); // View Moreボタン document.addEventListener('DOMContentLoaded', function () { const lists = document.querySelectorAll('.more-list'); // 各リストの親要素 lists.forEach(function(list) { const posts = list.querySelectorAll('.art-item'); const button = list.querySelector('.button_view-more'); const initialCount = parseInt(list.getAttribute('data-initial-count')) || 9; // 初期表示件数をデータ属性から取得 const incrementCount = parseInt(list.getAttribute('data-increment-count')) || 3; // 追加表示件数をデータ属性から取得 let currentCount = 0; function showNextPosts(count) { for (let i = currentCount; i < currentCount + count && i < posts.length; i++) { posts[i].style.display = 'block'; } currentCount += count; if (currentCount >= posts.length) { if (button) { button.style.display = 'none'; } } } // 初期表示 showNextPosts(initialCount); // ボタンのクリックイベント if (button) { button.addEventListener('click', function () { showNextPosts(incrementCount); }); } }); }); // タブ //任意のタブにURLからリンクするための設定 function GethashID (hashIDName){ if(hashIDName){ //タブ設定 $('.tab li').find('a').each(function() { var idName = $(this).attr('href'); if(idName == hashIDName){ var parentElm = $(this).parent(); $('.tab li').removeClass("active"); $(parentElm).addClass("active"); $(".area").removeClass("is-active"); $(hashIDName).addClass("is-active"); } }); } } //タブをクリックしたら $('.tab a').on('click', function() { var idName = $(this).attr('href'); GethashID (idName); return false; }); // 上記の動きをページが読み込まれたらすぐに動かす $(window).on('load', function () { $('.tab li:first-of-type').addClass("active"); $('.area:first-of-type').addClass("is-active"); var hashName = location.hash; GethashID (hashName); }); // アコーディオン document.addEventListener("DOMContentLoaded", () => { document.querySelectorAll(".js-details").forEach(function (el) { const summary = el.querySelector(".js-summary"); const answer = el.querySelector(".js-answer"); summary.addEventListener("click", (event) => { // デフォルトの挙動を無効化 event.preventDefault(); // detailsのopen属性を判定 if (el.getAttribute("open") !== null) { // アコーディオンを閉じるときの処理 const closingAnim = answer.animate(closingAnimation(answer), animTiming); closingAnim.onfinish = () => { // アニメーションの完了後にopen属性を取り除く el.removeAttribute("open"); }; } else { // open属性を付与 el.setAttribute("open", "true"); // アコーディオンを開くときの処理 const openingAnim = answer.animate(openingAnimation(answer), animTiming); } }); }); }); // アニメーションの時間とイージング const animTiming = { duration: 300, easing: "ease-in-out", }; // アコーディオンを閉じるときのキーフレーム const closingAnimation = (answer) => [ { height: answer.offsetHeight + "px", opacity: 1, }, { height: 0, opacity: 0, }, ]; // アコーディオンを開くときのキーフレーム const openingAnimation = (answer) => [ { height: 0, opacity: 0, }, { height: answer.offsetHeight + "px", opacity: 1, }, ]; // モーダルを表示した際に固定表示のボタンを非表示にする $('.coming_soon-btn').click(function () { $('html').addClass("modal-active"); // $('.tsutaeru-toolbar ').css("visibility","hidden"); // $('.tsutaeru-toolbar ').css("opacity","0"); // $('.bottom-link').css("visibility","hidden"); // $('.bottom-link').css("opacity","0"); // $('.site-footer').css("visibility","hidden"); // $('.site-footer').css("opacity","0"); }); $('.modal-close-btn').click(function () { $('html').removeClass("modal-active"); // $('.tsutaeru-toolbar').css("visibility","visible"); // $('.tsutaeru-toolbar').css("opacity","1"); // $('.bottom-link').css("visibility","visible"); // $('.bottom-link').css("opacity","1"); // $('.site-footer').css("visibility","visible"); // $('.site-footer').css("opacity","1"); }); // フロートボタン スクロール中非表示(safari以外) const button = document.querySelector('.search-area'); // Safari かどうかを判定する var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // iOS かどうかを判定する var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; // Safari でも iOS でもない場合に発火する処理 if (!isSafari && !isIOS) { // SafariやiOS以外のブラウザで発火する処理 document.onscroll = (event) => { button.style.cssText = "opacity: 0; visibility: hidden;"; }; document.onscrollend = (event) => { button.style.cssText = ""; }; }