!function (e) { var t, n, i = "active", o = "#desktopGlobalNavigation", r = "#mobileGlobalNavigation", a = '[data-menu-target="firstLayer"]', s = '[data-menu-target="secondLayer"]', c = '[data-menu-target="thirdLayer"]', l = '[data-menu-target="fourthLayer"]', d = "#spMenuButton", h = ".js-mobileSubNavigation", u = {isOpen: !1}, f = window.matchMedia("(max-width: 991px)"), m = function () { f.matches ? (e(r).hide(), e(d).removeClass(i), e(o).hide(), e(d).on("click.spMenuButton", (function () { $mobile = e("#mobileGlobalNavigation"); var t = $mobile.find(".firstLayer"); $mobile.find(".active").removeClass("active"), $mobile.find(".secondLayerLink").show(), $mobile.find(".thirdLayer").show(), $mobile.find(".back").hide(), $mobile.find(".activeLink").removeClass("activeLink"), t.removeAttr("style"), t.show(), e(this).hasClass(i) ? (e(this).removeClass(i), e(h).removeClass(i), e(r).fadeOut(200)) : (e(this).addClass(i), e(h).addClass(i), e(r).slideDown(200)) })), e("".concat(o, " ").concat(a)).each((function () { e(this).off("mouseenter.firstLayerPc"), e(this).off("mouseleave.firstLayerPc"), e(this).find(s).find(c).off("mouseenter.thirdLayerPc") }))) : (e(r).hide(), e(o).show(), e("".concat(o, " ").concat(a)).each((function () { var t = e(this).find(s), n = e(this).find(s).children(); e(this).on({ "mouseenter.firstLayerPc": function () { var r; if (r = document.body.clientWidth, e("".concat(o, " ").concat(a)).each((function () { 1 == e("#gComHeaderBottom").length ? e(this).find(s).css({ width: r, position: "absolute", display: "none", left: -1 * (r - (r - e(this).offset().left)) }) : e(this).find(s).css({ width: r, position: "absolute", top: e(this).height(), display: "none", left: -1 * (r - (r - e(this).offset().left)) }), e(this).find(c).each((function () { e(this).find(l).length > 0 && e(this).addClass("hasChild") })) })), e(this).closest("li").addClass("active"), e(this).find(".selected").removeClass("selected"), t.find(c).each((function () { e(this).find(l).hide() })), !t.hasClass(i)) { n.css({height: ""}), t.css({display: "block"}).addClass(i); var d = e(window).height() / 3 * 2; n.css({height: 0}).stop(!0, !0).animate({height: d}, 200), u.isOpen = !0 } }, "mouseleave.firstLayerPc": function () { e(this).closest("li").removeClass("active"), t.hasClass(i) && (t.fadeOut(200, (function () { n.css({height: 0}) })).removeClass(i), u.isOpen = !1) } }); var r = t.find(c); r.each((function () { e(this).on({ "mouseenter.thirdLayerPc": function () { r.removeClass("selected"), e(this).addClass("selected"), r.find(l).hide(), e(this).find(l).fadeIn(200), r.find(".subLink").hide(), e(this).find(".subLink").show(), r.each((function () { var t = r.find(l).find("li"); t.on({ "mouseenter.fourthLayerPc": function () { t.removeClass("selected"), e(this).addClass("selected") } }) })) } }) })) })), e(d).off("click.spMenuButton")) }; f.addEventListener("change", m), m(), e("#mobileGlobalNavigation .secondLayerLink").on("click", (function (o) { if (e(this).siblings(".thirdLayerContainer").length > "0") { if (e(this).hasClass("activeLink")) return; o.preventDefault(), e(this).addClass("activeLink"); var r = e(this).parent().find(".thirdLayerContainer").addClass("active"), a = e("#mobileGlobalNavigation .firstLayer"), s = e(this).parent(); e("#mobileGlobalNavigation .back").show(), a.hide(), s.show(), e(h).removeClass(i), (t = e(this).parent().find(".subLink")).addClass("active"); var c = r.height() + e(this).height() + 24, l = c + t.height() + 28; t.css({top: c}), s.css({height: l}), n = r.height() + e(this).height() + 24, e(".spMenu").hide() } })), e("#mobileGlobalNavigation .thirdLayerLink").on("click", (function (n) { if (!e(this).hasClass("activeLink")) { n.preventDefault(), $fourthLayerContainer = e(this).next(".fourthLayerContainer"), 0 === $fourthLayerContainer.length && (window.location.href = e(this).attr("href")), e(this).addClass("activeLink"), $fourthLayerContainer.addClass("active"); var i = $fourthLayerContainer.height() + e(this).height() + 24, o = i + t.height() + 28; t.css({top: i}), $thisFirstLayer = $fourthLayerContainer.closest(".firstLayer"), $thisFirstLayer.css({height: o}), $thisFirstLayer.find(".secondLayerLink").hide(), $thisFirstLayer.find(".thirdLayer").hide(), e(this).closest(".thirdLayer").show() } })), e("#mobileGlobalNavigation .back").on("click", (function (o) { if (o.preventDefault(), $thirdActiveLink = e("#mobileGlobalNavigation .thirdLayerContainer").prev(".activeLink"), $fourthActiveLink = e("#mobileGlobalNavigation .fourthLayerContainer").prev(".activeLink"), e("#mobileGlobalNavigation .firstLayer").css("height", "auto"), 0 !== $fourthActiveLink.length) { $fourthActiveLink.removeClass("activeLink"), $fourthActiveLink.closest(".thirdLayerContainer").find(".thirdLayer").show(), $fourthActiveLink.closest(".firstLayer").find(".secondLayerLink").show(), $fourthActiveLink.closest(".thirdLayerContainer").find(".subLink").removeClass("active"), e("#mobileGlobalNavigation .fourthLayerContainer").removeClass("active"), t.css({top: n}); var r = n + t.height() + 28; $fourthActiveLink.closest(".firstLayer").css({height: r}) } else e("#mobileGlobalNavigation .thirdLayerContainer").removeClass("active"), e("#mobileGlobalNavigation .back").hide(), e("#mobileGlobalNavigation .firstLayer").show(), e(h).addClass(i), e("#mobileGlobalNavigation .secondLayerLink").removeClass("activeLink"), t.removeClass("active"), e(".spMenu").show() })); var p = e("#headMenu .spMenuArea").html(); e("#mobileGlobalNavigation .menu-item .menuArea").append(p); var v = e("#headMenu .spSubMenuArea").html(); e("#mobileGlobalNavigation .mobileSubNavigation").append(v), e(window).on("load resize", (function () { if (e(window).width() < 992) { if (0 !== e("#comHeader").find("#gComHeaderBottom").length) { var t = e(".comGroup #comHeader #gComHeaderBottom .gComHeadInner").innerHeight(), n = parseInt(e(".comGroup #comHeader").css("margin-bottom")), i = e(".comGroup #comHeader").offset().left; e(".comGroup #comHeader #gComHeaderBottom .gComHeadInner #mobileGlobalNavigation").css({ top: t + n, left: "-" + i + "px", width: "calc(100% + " + 2 * i + "px)" }) } if (0 !== e("#comHeader").find("#block-mhps-sitebranding").length || 0 !== e("#comHeader").find("#block-sitebranding").length || e(".spectraHeaderFollow").length > 0) { var o = e("#comHeader").innerHeight(), r = parseInt(e("#comHeader").css("margin-bottom")); e("#comHeader #mobileGlobalNavigation").css("top", o + r) } if (1 == e(".mobileFijutsukanMuseumNavigation").length) { e(".gijutsukanMuseumNavigation").hide(); var a = e(".mobileFijutsukanMuseumNavigation").closest(".region-secondary-menu").height(); e(".mobileFijutsukanMuseumNavigation").css("top", a) } } })) }(jQuery) function initHeaderfollow() { if ($('#comHeader').length) { var _body = $('body'); var _head = $('#comHeader'); var _nav = $('.comHeaderFollow'); var _navH = parseInt(_body.css('padding-top'), 10); var _flag = false; var _flag2 = false; _body.addClass('isHeaderFixed'); var _startPos = 0; var _currentPos = $(window).scrollTop(); var _setPos = 0; var _setPos2 = 0; var _initPos; if($('#comHeader').hasClass('comHeaderShort')) { _body.addClass('isHeaderFixedShort'); _nav = $('.comHeaderShortLocal'); _initPos = function () { _currentPos = $(window).scrollTop(); _navH = $('.comHeaderFollow').outerHeight(); if (_currentPos > _navH) { _body.addClass('isScrolled'); } else { _body.removeClass('isScrolled'); } if (_currentPos > _startPos && _body.hasClass('isScrolled')) { var _navM = parseInt(_nav.css('margin-top'), 10); var _diff = _currentPos - _startPos; var _mrg = _navM - _diff; if(_mrg < (_nav.outerHeight() * -1)) _mrg = (_nav.outerHeight() * -1) - 200; _nav.css({'margin-top': _mrg + 'px'}); } else if(_body.hasClass('isScrolled')) { var _navM = parseInt(_nav.css('margin-top'), 10); var _diff = _startPos - _currentPos; var _mrg = _navM + _diff; if(_mrg > 0) _mrg = 0; _nav.css({'margin-top': _mrg + 'px'}); } else { _nav.css({'margin-top': '0px'}); } _startPos = _currentPos; } } else { _initPos = function () { _currentPos = $(window).scrollTop(); _navH = parseInt(_body.css('padding-top'), 10) + 100; var _navM = parseInt(_nav.css('margin-top'), 10); if (_currentPos > _startPos) { _body.removeClass('isHeaderUp').addClass('isHeaderDown'); _flag = false; if (_currentPos >= _navH) { _flag2 = true; } else { _flag2 = false; } } else { _body.removeClass('isHeaderDown').addClass('isHeaderUp'); _flag = true; } if (_flag === true) { if (_currentPos < 0) _currentPos = 0; _setPos = _currentPos; var _diff = -_navH + (_setPos2 - _currentPos); if (_diff > 0) _diff = 0; if (_flag2 === false) { if (_currentPos < _navH) _diff = -_currentPos; } _nav.css('margin-top', _diff + 'px'); //console.log('up'); } else { if (_currentPos < 0) _currentPos = 0; _setPos2 = _currentPos; var _diff = _setPos - _currentPos; if (_currentPos < _navH) _diff = - _currentPos; if (_diff < -_navH) _diff = _navH * -1; if (_diff > _navM) _diff = _navM; _nav.css('margin-top', _diff + 'px'); //console.log('down'); } if (_currentPos > _navH) { _body.addClass('isScrolled'); } else { _body.removeClass('isScrolled'); } _startPos = _currentPos; //console.log(_currentPos); } } $(window).on('scroll load resize', function (e) { if(window.matchMedia('(min-width:992px)').matches){ _initPos(); } else { _nav.css('margin-top', 0 + 'px'); } }); } } // 整站左侧变懒 function initSiderNav (){ if ($('#comSide').length && $('#comConPosi').length) { const _nav = $('#comSide'); const _con = $('#comMainContent'); let _winW; let _winH; let _scrT; let _navH; let _conH; let _navD; let _posT; let startPos = 0; const _marginT = 20; const sideNavSet = function () { _winW = window.innerWidth || document.documentElement.clientWidth || 0; _winH = window.innerHeight || document.documentElement.clientHeight || 0; _scrT = $(window).scrollTop(); _navH = _nav.innerHeight(); _conH = _con.innerHeight(); _navD = _navH - _winH; _posT = _con.offset().top; }; const sideNavInit = function () { function posNormal() { let _mrgT = _scrT - _posT + _marginT; if (_mrgT >= _conH - _navH) { _mrgT = _conH - _navH; } if (_mrgT >= _con - _nav) { _mrgT = _con - _nav; } if (_mrgT <= 0) { _mrgT = 0; } if (_scrT > startPos) { if (_scrT > _posT - _marginT && _winW > 991) { if (_scrT > _nav.offset().top + _navH - _winH) { _nav.css({marginTop: _mrgT + 'px'}); } } else if (_scrT < _posT - _navH && _winW > 991) { _nav.css({marginTop: _mrgT + 'px'}); } else { _nav.css({marginTop: 0}); } } else { if (_scrT > _posT - _marginT && _winW > 991) { if (_scrT < _nav.offset().top) { _nav.css({marginTop: _mrgT + 'px'}); } } else if (_scrT < _posT - _navH && _winW > 991) { _nav.css({marginTop: _mrgT + 'px'}); } else { _nav.css({marginTop: 0}); } } startPos = _scrT; } function posNarrow() { let _mrgT; if (_scrT > startPos) { if (_scrT > _posT - _marginT && _winW > 991) { _mrgT = _scrT - _posT - _navD - _marginT; if (_mrgT >= _conH - _navH) { _mrgT = _conH - _navH; } if (_mrgT <= 0) { _mrgT = 0; } if (_scrT > _nav.offset().top + _navH - _winH) { _nav.css({marginTop: _mrgT + 'px'}); } } else { _nav.css({marginTop: 0}); } } else { _mrgT = _scrT - _posT + _marginT; if (_mrgT >= _conH - _navH) { _mrgT = _conH - _navH; } if (_mrgT >= _con - _nav) { _mrgT = _con - _nav; } if (_mrgT <= 0) { _mrgT = 0; } if (_scrT > _posT - _marginT && _winW > 991) { if (_scrT < _nav.offset().top) { _nav.css({marginTop: _mrgT + 'px'}); } } else if (_scrT < _posT - _navH && _winW > 991) { _nav.css({marginTop: _mrgT + 'px'}); } else { _nav.css({marginTop: 0}); } } startPos = _scrT; } if (_winH >= _navH) { posNormal(); } else { posNarrow(); } }; $(window).on('scroll load resize', function () { sideNavSet(); sideNavInit(); }); } } $(function () { initHeaderfollow(); initSiderNav(); });