$(document).ready(function () { $(".logo-slider").slick({ autoplay: false, autoplaySpeed: 7000, dots: true, arrows: false, infinite: false, centerMode: false, slidesToShow: 1, slidesToScroll: 1, centerPadding: "0", variableWidth: false, responsive: [ { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1, }, }, ], }); // Accordion functionality $(".accordion-header").click(function () { var accordionItem = $(this).parent(); var accordionContent = accordionItem.find(".accordion-content"); var isActive = accordionItem.hasClass("active"); // Toggle the clicked item if (isActive) { // Close accordion accordionItem.removeClass("active"); accordionItem.attr("aria-expanded", "false"); accordionContent.css("max-height", "0"); } else { // Open accordion with dynamic height accordionItem.addClass("active"); accordionItem.attr("aria-expanded", "true"); // Temporarily clone content to measure height without affecting display var tempContent = accordionContent.clone(); tempContent.css({ position: "absolute", visibility: "hidden", "max-height": "none", height: "auto", "padding-bottom": "0", overflow: "visible", }); accordionContent.parent().append(tempContent); // Get the scroll height of the cloned content var contentHeight = tempContent.prop("scrollHeight"); // Calculate the total height including all child elements and their margins var totalHeight = 0; tempContent.find("*").each(function () { var $this = $(this); var elementHeight = $this.outerHeight(true); // Includes margin var elementTop = $this.offset().top; var contentTop = tempContent.offset().top; if (elementHeight > 0 && elementTop >= contentTop) { var elementBottom = elementTop + elementHeight; var relativeBottom = elementBottom - contentTop; totalHeight = Math.max(totalHeight, relativeBottom); } }); // Also check for any elements that might extend beyond the normal flow var maxBottom = 0; tempContent.find("*").each(function () { var $this = $(this); var rect = this.getBoundingClientRect(); var tempRect = tempContent[0].getBoundingClientRect(); var relativeBottom = rect.bottom - tempRect.top; maxBottom = Math.max(maxBottom, relativeBottom); }); // Use the largest calculated height var calculatedHeight = Math.max(contentHeight, totalHeight, maxBottom); tempContent.remove(); // Add generous extra padding to ensure content is fully visible var finalHeight = calculatedHeight + 150; // Increased to 150px padding // Animate to the calculated height accordionContent.css("max-height", finalHeight + "px"); } }); // Keyboard accessibility $(".accordion-header").keydown(function (e) { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); $(this).click(); } }); });