1 line
1.2 KiB
JavaScript
1 line
1.2 KiB
JavaScript
jQuery(document).ready(function(){var t=!1;void 0!==eztoc_smooth_local.JumpJsLinks&&1===parseInt(eztoc_smooth_local.JumpJsLinks)&&(t=!0),document.querySelectorAll(".ez-toc-link").forEach(t=>{t=t.replaceWith(t.cloneNode(!0))}),document.querySelectorAll(".ez-toc-section").forEach(t=>{t.setAttribute("ez-toc-data-id","#"+decodeURI(t.getAttribute("id")))}),jQuery("a.ez-toc-link").click(function(){let e=jQuery(this).attr("data-href"),i=jQuery(this).attr("href");if(1===parseInt(eztoc_smooth_local.add_request_uri)){if(jQuery(this).attr("data-href")){let r=jQuery(this).attr("data-href").split("#");r&&r.length>1&&(e=`#${r[1]}`)}if(jQuery(this).attr("href")){let a=jQuery(this).attr("href").split("#");a&&a.length>1&&(i=`#${a[1]}`)}}let l=t?e:i,o=jQuery("#wpadminbar"),s=jQuery("header"),h=0;if(parseInt(eztoc_smooth_local.scroll_offset)>30&&(h=parseInt(eztoc_smooth_local.scroll_offset)),o.length&&(h+=o.height()),(s.length&&"fixed"==s.css("position")||"sticky"==s.css("position"))&&(h+=s.height()),jQuery('[ez-toc-data-id="'+decodeURI(l)+'"]').length>0&&(h=jQuery('[ez-toc-data-id="'+decodeURI(l)+'"]').offset().top-h),jQuery("html, body").animate({scrollTop:h},500),t)return!1})}); |