const duration = 0.3;const allCards = document.querySelectorAll(".job-description-li");/*get height of the first 2 children+margins*/function getHeightOfTwoChildren(element) {const style = window.getComputedStyle(element);const childrenHeight = [...element.querySelector(".job-description-li-content").children,].slice(0, 2).reduce((sum, child) => {const cs = window.getComputedStyle(child);return (sum +child.offsetHeight +parseFloat(cs.marginTop) +parseFloat(cs.marginBottom));}, 0);return childrenHeight;}const setReadMore = function () {allCards.forEach((card) => {const cardContent = card.querySelector(".job-description-li-content");const maxH = getHeightOfTwoChildren(card);/*set height*/gsap.to(cardContent, { height: maxH + "px", duration: duration });/*eventlistener for the button*/card.querySelector("[data-see-more]").addEventListener("click", (ev) => {const target = ev.target.hasAttribute("data-see-more")? ev.target: ev.target.closest("[data-see-more]");/*close all other open ones*/target.closest(".spacer-20").querySelectorAll("[button-span]").forEach((btnSpan) => {if(btnSpan.textContent === "less" &&target.querySelector("[button-span]") !== btnSpan){btnSpan.click();}});/*update textContent of button*/target.querySelector("[button-span]").textContent =target.querySelector("[button-span]").textContent === "more"?"less":"more";/*toggle height*/gsap.to(cardContent, {height:target.querySelector("[button-span]").textContent === "more"? maxH + "px": "auto",duration: duration,});});});};const resetReadMore = function () {allCards.forEach((card) => {/*reset card height to auto*/gsap.to(card.querySelector(".job-description-li-content"), {height: "auto",duration: duration,});const button = card.querySelector("[data-see-more]");/*show all "read more" buttons*/button.classList.remove("hide");/*reset buttons textcontent to default*/button.querySelector("[button-span]").textContent = "more";/* replace the element with a copy of itself and nuke all the event listeners*/button.replaceWith(button.cloneNode(true));});setReadMore();};window.addEventListener("resize", resetReadMore);setReadMore();