/* Reading time function -------------------------------------------------------------- */ const mainElement = jQuery('main'); const mainContent = mainElement.text(); const wordCount = mainContent.split(' ').length; const readingTime = Math.ceil(wordCount / 700); const postMetaElement = jQuery('.post-reading-time'); postMetaElement.text(`${readingTime} min read`); jQuery(document).ready(function(){ jQuery('.block-heros-v8 li.fundraiser-card a').on('click', function(event){ event.preventDefault(); }); }); ; /* Wrap all iframe in special wrapper so they can be made responsive -------------------------------------------------------------- */ jQuery('.block-long-form-content-v1 iframe').wrap('
'); /* Nav logic -------------------------------------------------------------- */ // Loop through each block with the class "long-form-content-v1" jQuery(".block-long-form-content-v1").each(function() { // Create a new unordered list to hold the anchor links var anchorList = jQuery(""); // Loop through each H2 heading within the current block jQuery(this).find("h2").each(function() { // If the H2 does not have a class of "nav-title", create an anchor link for it if (!jQuery(this).hasClass("nav-title")) { // Create a unique ID for the H2 element var id = jQuery(this).text().trim().toLowerCase().replace(/[^a-z0-9]+/g, "-"); jQuery(this).attr("id", id); // Create a new list item with an anchor link to the H2 element var listItem = jQuery("
  • "); var anchor = jQuery("").attr("href", "#" + id).text(jQuery(this).text()); listItem.append(anchor); // Add the new list item to the unordered list anchorList.append(listItem); } }); // Add the unordered list to the block's anchor-links container jQuery(this).find(".anchor-links").append(anchorList); }); /* Smooth scroll -------------------------------------------------------------- */ jQuery(".block-long-form-content-v1 .smooth-scroll").click(function (event) { jQuery("html,body").animate( { scrollTop: jQuery(this.hash).offset().top - 20 }, 1500 ); }); ;