(function ($) { $(function () { // Apply a one-character hanging indent to note and bullet-style copy. document.querySelectorAll("main p, main li").forEach((element) => { if (/^[※・]/.test(element.textContent.trimStart())) { element.classList.add("hanging-indent"); } }); // Turn each campaign overview and subheading into an accordion. document.querySelectorAll("#infomation .campaign-copy, #infomation .campaign-block").forEach((block, index) => { const heading = Array.from(block.children).find((child) => child.tagName === "H4"); if (!heading) { return; } const trigger = document.createElement("button"); const label = document.createElement("span"); const panel = document.createElement("div"); const panelInner = document.createElement("div"); const panelId = `campaign-accordion-panel-${index + 1}`; while (heading.firstChild) { label.appendChild(heading.firstChild); } trigger.type = "button"; trigger.className = "campaign-accordion-trigger"; trigger.setAttribute("aria-expanded", "false"); trigger.setAttribute("aria-controls", panelId); trigger.appendChild(label); heading.classList.add("campaign-accordion-heading"); heading.appendChild(trigger); panel.className = "campaign-accordion-panel"; panel.id = panelId; panel.setAttribute("aria-hidden", "true"); panelInner.className = "campaign-accordion-inner"; Array.from(block.children).forEach((child) => { if (child !== heading) { panelInner.appendChild(child); } }); panel.appendChild(panelInner); block.appendChild(panel); trigger.addEventListener("click", () => { const isOpen = trigger.getAttribute("aria-expanded") === "true"; trigger.setAttribute("aria-expanded", String(!isOpen)); panel.setAttribute("aria-hidden", String(isOpen)); panel.classList.toggle("is-open", !isOpen); }); }); // Apply the existing Information reveal effect to the other content sections. const revealSelectors = [ "#readtext .readtext-title", "#readtext .readtext-lead", "#readtext .readtext-copy", "#performances .performance-title", "#performances .cast-featured", "#performances .cast-card", "#performances .staff-list > div", "#schedule .schedule-title", "#schedule .schedule-tabs", "#ticket .ticket-title", "#ticket .ticket-price", "#ticket .ticket-inner > :not(.ticket-title):not(.ticket-price)" ]; $(revealSelectors.join(", ")).addClass("anime"); const observer = new IntersectionObserver((entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { const el = entry.target; const $el = $(el); const index = $el.closest('section').find(".anime").index(el); el.style.transitionDelay = `${index * 0.1}s`; el.classList.add("anime-on"); observer.unobserve(el); } }); }, { threshold: 0.1, rootMargin: "0px 0px -50px 0px" }); $(".anime").each(function () { observer.observe(this); }); const pageNav = document.querySelector(".page-nav"); const campaignJump = document.querySelector(".campaign-jump"); const pageTop = document.querySelector(".page-top"); const stickyNav = document.querySelector(".sp-sticky-nav"); const scrollToPageTarget = (event) => { const hash = event.currentTarget.getAttribute("href"); const target = hash && hash.startsWith("#") ? document.getElementById(hash.slice(1)) : null; if (target) { event.preventDefault(); target.scrollIntoView({ behavior: "smooth", block: "start" }); } }; if (pageNav) { pageNav.querySelectorAll('a[href^="#"]').forEach((link) => { link.addEventListener("click", scrollToPageTarget); }); } if (pageTop) { pageTop.addEventListener("click", scrollToPageTarget); } if (campaignJump) { campaignJump.addEventListener("click", scrollToPageTarget); const informationSection = document.getElementById("infomation"); let visibilityUpdatePending = false; const updateCampaignJumpVisibility = () => { const hideTarget = informationSection; if (hideTarget) { campaignJump.classList.toggle( "is-hidden", hideTarget.getBoundingClientRect().top <= window.innerHeight ); } visibilityUpdatePending = false; }; const requestVisibilityUpdate = () => { if (!visibilityUpdatePending) { visibilityUpdatePending = true; window.requestAnimationFrame(updateCampaignJumpVisibility); } }; updateCampaignJumpVisibility(); window.addEventListener("scroll", requestVisibilityUpdate, { passive: true }); window.addEventListener("resize", requestVisibilityUpdate); } if (stickyNav) { const stickyLinks = Array.from(stickyNav.querySelectorAll('a[href^="#"]')); const stickyTargets = stickyLinks .map((link) => document.getElementById(link.getAttribute("href").slice(1))) .filter(Boolean); stickyLinks.forEach((link) => { link.addEventListener("click", scrollToPageTarget); }); const sectionObserver = new IntersectionObserver((entries) => { entries.forEach((entry) => { if (!entry.isIntersecting) { return; } stickyLinks.forEach((link) => { const isCurrent = link.getAttribute("href") === `#${entry.target.id}`; if (isCurrent) { link.setAttribute("aria-current", "location"); } else { link.removeAttribute("aria-current"); } }); }); }, { rootMargin: "-20% 0px -70% 0px", threshold: 0 }); stickyTargets.forEach((target) => sectionObserver.observe(target)); } }); })(jQuery);