(function($){
var prevScrollTop=-1;
var $window=$(window);
$window.scroll(function (){
var scrollTop=$window.scrollTop();
var threashold=600;
var s1=prevScrollTop > threashold;
var s2=scrollTop > threashold;
if(s1 ^ s2){
if(s2){
$('.body').addClass('go-to-top-visible');
}else{
$('.go-to-top-common').removeClass('go-to-top-up');
$('.body').removeClass('go-to-top-visible');
}}
prevScrollTop=scrollTop;
});
$('.go-to-top-common').click(function (){
$(this).addClass('go-to-top-up');
$('body,html').animate({
scrollTop: 1,
},
800
);
});
$('.go-to-toc-common').click(function (){
$('body,html').animate({
scrollTop: $('.entry-content .toc').offset().top,
},
800
);
});
$('#search-menu-input').change(function(e){
var searchEdit=$('#search-menu-content .search-edit').first();
if(e.target.checked){
searchEdit.focus();
}else{
searchEdit.blur();
}});
var adminMenu=$('#admin-panel');
var adminHeight=adminMenu.outerHeight();
var adminStartPos=0;
$(window).scroll(function (){
var adminCurrentPos=$(this).scrollTop();
if(adminCurrentPos > adminStartPos){
if(adminCurrentPos >=200){
adminMenu.css('bottom', '-' + adminHeight + 'px');
}}else{
adminMenu.css('bottom', 0);
}
adminStartPos=adminCurrentPos;
});
if(cocoon_localize_script_options.is_fixed_mobile_buttons_enable!=1){
var headerMenu=$('.mobile-header-menu-buttons');
var headerHight=headerMenu.outerHeight();
var headerStartPos=0;
$(window).scroll(function (){
var headerCurrentPos=$(this).scrollTop();
if(window.innerWidth <=600){
if(headerCurrentPos > headerStartPos){
if(headerCurrentPos >=100){
headerMenu.css('top', '-' + headerHight + 'px');
}}else{
headerMenu.css('top', 0);
}}else{
var adminBarHeight =
getComputedStyle(document.documentElement)
.getPropertyValue('--wp-admin--admin-bar--height')
.trim()||'0px';
if(headerCurrentPos > headerStartPos){
if(headerCurrentPos >=100){
headerMenu.css('top',
'calc(' + adminBarHeight + ' - ' + headerHight + 'px)'
);
}}else{
headerMenu.css('top', 'calc(' + adminBarHeight + ')');
}}
headerStartPos=headerCurrentPos;
});
var footerMenu=$('.mobile-footer-menu-buttons');
var footerHeight=footerMenu.outerHeight();
var footerStartPos=0;
$(window).scroll(function (){
var footerCurrentPos=$(this).scrollTop();
if(footerCurrentPos > footerStartPos){
if(footerCurrentPos >=100){
footerMenu.css('bottom',
'calc(-1 * (env(safe-area-inset-bottom) + ' +
footerHeight +
'px))'
);
}}else if(footerCurrentPos - footerStartPos < -8){
footerMenu.css('bottom', 0);
}
footerStartPos=footerCurrentPos;
});
var headerButtons=$('.mobile-header-menu-buttons');
var footerButtons=$('.mobile-footer-menu-buttons');
headerButtons.click(function (){
headerButtons.css('z-index', '3');
footerButtons.css('z-index', '2');
});
footerButtons.click(function (){
headerButtons.css('z-index', '2');
footerButtons.css('z-index', '3');
});
}
const clickEventType=window.ontouchstart!==null ? 'click':'touchend';
$(document).on(clickEventType,
'#comment-reply-btn, .comment-reply-link',
function (){
$('#comment-reply-btn').slideUp();
const respond=document.getElementById('respond');
const styles={
inset: 'auto',
position: 'static',
visibility: 'visible',
};
Object.entries(styles).forEach(( [ key, value ])=> {
respond.style[ key ]=value;
});
$('#respond').slideDown();
}
);
$('.sbtn').click(function (){
var w=$(this).prev('.sform').text();
if(w)
window.open('https://www.google.co.jp/search?q=' + encodeURIComponent(w),
'_blank'
);
});
$('.sidebar-menu-content .widget_archive select').change(function (){
document.location.href=this.options[ this.selectedIndex ].value;
});
$('.sidebar-menu-content .widget_categories select').change(function (){
if(this.options[ this.selectedIndex ].value > 0){
this.parentNode.submit();
}});
function drawerCloser(selecter, checkbox){
$(selecter).click(function (){
$(checkbox).prop('checked', false);
});
}
drawerCloser('.menu-drawer .menu-item a', '#navi-menu-input');
drawerCloser('#slide-in-sidebar a', '#sidebar-menu-input');
$('.mobile-menu-buttons').each(function (){
if($(this).has('.logo-menu-button').length){
$(this).addClass('has-logo-button');
}});
$(window).on('load', function (){
$('#carousel').addClass('loaded');
});
$('.is-style-accordion > .faq > .faq-answer').hide();
$('.is-style-accordion > .faq > .faq-question').click(function (){
$(this).next('.is-style-accordion .faq-answer').slideToggle();
$(this).toggleClass('active');
});
$(document).on('change', '#sidebar-menu-input', function (){
if($(this).prop('checked')){
$('#sidebar').appendTo('#sidebar-menu-content');
$('#sidebar').attr('id', 'slide-in-sidebar');
$('#sidebar').addClass('slide-in-sidebar');
drawerCloser('#slide-in-sidebar a', '#sidebar-menu-input');
}else{
$('#sidebar').removeClass('slide-in-sidebar');
$('#slide-in-sidebar').attr('id', 'sidebar');
$('#sidebar').insertAfter('#main');
}});
var vw=window.innerWidth;
$(window).resize(function (){
if(vw!=window.innerWidth){
$('#sidebar-menu-input').prop('checked', false).change();
}
vw=window.innerWidth;
});
})(jQuery);
(function (){
var f=document.querySelectorAll('.video-click');
for(var i=0; i < f.length; ++i){
f[ i ].onclick=function (){
var iframe=this.getAttribute('data-iframe');
this.parentElement.innerHTML='<div class="video">' + iframe + '</div>';
};}})();
(function (){
function updateHeaderOffset(){
const header=document.getElementById('header-container');
let offset=0;
if(header&&header.classList.contains('fixed-header')){
offset=header.offsetHeight;
}
const mobileHeaderMenuButtons=document.querySelector('.mobile-header-menu-buttons'
);
if(mobileHeaderMenuButtons){
const computedStyle=window.getComputedStyle(mobileHeaderMenuButtons);
const topValue=parseFloat(computedStyle.top);
if(topValue >=0){
offset +=mobileHeaderMenuButtons.offsetHeight;
}else{
}}
document.documentElement.style.setProperty('--cocoon--header-container--position-offset',
offset + 'px'
);
}
document.addEventListener('DOMContentLoaded', updateHeaderOffset);
let resizeTimer;
window.addEventListener('resize', function (){
clearTimeout(resizeTimer);
resizeTimer=setTimeout(function (){
updateHeaderOffset();
}, 100);
});
window.addEventListener('scroll', updateHeaderOffset);
})();