"use strict"; document.addEventListener("DOMContentLoaded", function () { var a = document.getElementById("global-nav__search-button"); a && a.addEventListener("click", function () { var a = document.getElementById("global-nav__search"); a && (a.classList.toggle("is-active"), setTimeout(function () { document.querySelector("#global-nav__search .search-field").focus() }, 50)) }); var b = document.getElementById("global-nav__search-close"); b && b.addEventListener("click", function () { var a = document.getElementById("global-nav__search"); a && a.classList.remove("is-active") }); var c = document.getElementById("global-nav__toggle"); c && c.addEventListener("click", function (a) { a.currentTarget.classList.toggle("is-open") }); for (var d = document.querySelectorAll("a[href^=\"#\"]"), e = 0; e < d.length; e++) d[e].addEventListener("click", function (a) { a.preventDefault(); var b = 0, c = a.currentTarget.getAttribute("href").replace("#", ""), d = document.getElementById(c); if (d || "" === c) { if (d) { var e = d.getBoundingClientRect().top, f = 50, g = document.getElementById("masthead"); "fixed" === getComputedStyle(g, null).getPropertyValue("position") && (f = g.getBoundingClientRect().bottom + 20), b = e + window.pageYOffset - f } window.scroll({ top: b, behavior: "smooth" }) } }); var f = document.getElementById("back-to-top"); f && f.addEventListener("click", function (a) { a.preventDefault(), window.scroll({ top: 0, behavior: "smooth" }) }); var g = window.innerWidth - document.body.clientWidth; getComputedStyle(document.documentElement).getPropertyValue("--scrollbar-width") && document.querySelector(":root").style.setProperty("--scrollbar-width", g + "px") }); // ============================================================== // トップへ戻る // ============================================================== if ($(window).scrollTop() < 100) { $('#page_top').hide(); } var notifyH = $('.notifyPopup').innerHeight(); $(window).on('load scroll resize', function () { var w = window.innerWidth ? window.innerWidth : $(window).width(); var wTop = $(window).scrollTop(); if (wTop >= 50) { $('#page_top').fadeIn('fast'); if (w >= 640) { var ftTop = $('#wrapperFooter').offset().top; // var ftH = $('#wrapperFooter').innerHeight(); if ($.cookie) { if (!$.cookie('notify')) { ftTop = $('.notifyPopup').offset().top - 20; } else { notifyH = 0; } } if (wTop + window.innerHeight > ftTop + 32) { $('#page_top').css('position', 'absolute'); $('#page_top').css('top', ftTop - 32); } else { $('#page_top').css('position', 'fixed'); $('#page_top').css('bottom', notifyH + 10); $('#page_top').css('top', ''); } } } else { /* $("#page_top").hide('drop', { direction: 'up' }, 'slow'); */ $('#page_top').fadeOut('fast'); } }); $('body').on('click', '#page_top', function (e) { e.preventDefault(); $('html,body').animate( { scrollTop: 0, }, 750 ); });