`}).join("")}
function renderSolutions(data){const solutions=Object.keys(data[selectedCMS]);const allOption=`
`;const otherOptions=solutions.map(solution=>{const checked=solution===selectedSolution?"checked":"";return `
`}).join("");solutionContainer.innerHTML=allOption+otherOptions}
function createLinks(linksArr){const links=linksArr[0];const keys=Object.keys(links);let linksHTML="";if(keys.length===1){const key=keys[0];linksHTML=`
${key}
`}else{linksHTML=keys.map(k=>{return `
${k}`}).join("
")}
return `
${linksHTML}
`}
function createCard(card){return `
${card.label ? `${card.label}` : ''}
${card.title}
${createLinks(card.links)}
`}
function renderCards(data){let mergedSections={};if(selectedSolution==="All"){const allSolutions=data[selectedCMS];Object.values(allSolutions).forEach(solution=>{Object.keys(solution).forEach(section=>{if(!mergedSections[section]){mergedSections[section]=[]}
mergedSections[section]=mergedSections[section].concat(solution[section])})})}else{mergedSections=data[selectedCMS][selectedSolution]}
cardsContainer.innerHTML=Object.keys(mergedSections).map(section=>{const cards=mergedSections[section].map(createCard).join("");return `
`}).join("")}
cmsContainer.addEventListener("click",(e)=>{const cmsItem=e.target.closest(".pl-cms-item");if(!cmsItem)return;selectedCMS=cmsItem.dataset.cms;selectedSolution="All";renderCMS(object);updateCMSParams(selectedCMS);renderSolutions(object);renderCards(object);if(solutionHead){solutionHead.innerHTML=`
${
selectedCMS === "Others"
? "Filter by Other CMS"
: "Filter by Solution"
}`}
clearFilterLabels();addFilterLabel(selectedCMS);addFilterLabel(selectedSolution,!0);if(window.innerWidth
{if(e.target.name!=="solution")return;selectedSolution=e.target.value;renderCards(object);updateSolutionParams(selectedSolution);clearFilterLabels();addFilterLabel(selectedCMS);addFilterLabel(selectedSolution);if(window.innerWidth>=mobileBreakpoint){scrollToContainer()}});function initPluginUI(data){renderCMS(data);renderSolutions(data);renderCards(data);clearFilterLabels();addFilterLabel(selectedCMS);addFilterLabel(selectedSolution,!0)}
initPluginUI(object);const mobileBreakpoint=992;const triggerBtn=jQuery(".pl-mob-show .pl-banner-desc");const stickyEl=jQuery(".pl-sticky");const stickyE2=jQuery(".pl-hide");function toggleSticky(){if(!stickyEl.length)return;if(stickyEl.is(":visible")){stickyEl.stop(!0,!0).slideUp(300);setTimeout(()=>{scrollToContainer()},300)}else{stickyEl.stop(!0,!0).slideDown(300)}}
triggerBtn.on("click",toggleSticky);stickyE2.on("click",toggleSticky);function scrollToContainer(){const target=document.querySelector(".container-fluid.pl-container");const header=document.querySelector(".mo-header");if(!target)return;const headerHeight=header?header.offsetHeight:80;const offset=target.getBoundingClientRect().top+window.pageYOffset-headerHeight;window.scrollTo({top:offset,behavior:"smooth"})}
function scrollToSolutions(){const target=document.querySelector(".pl-solutions");const header=document.querySelector(".mo-header");if(!target)return;const headerHeight=header?header.offsetHeight:0;const offset=target.getBoundingClientRect().top+window.pageYOffset-headerHeight-60;window.scrollTo({top:offset,behavior:"smooth"})}
function clearFilterLabels(){if(!filterContainer)return;const labels=filterContainer.querySelectorAll(".pl-filter-label");labels.forEach(label=>label.remove())}
function addFilterLabel(text,showAll=!1){if(!filterContainer||!text)return;if(text==="All"&&!showAll)return;const span=document.createElement("span");span.className="pl-text pl-filter-label";span.textContent=text;filterContainer.appendChild(span)}
function updateSolutionParams(solution) {
const params = new URLSearchParams(window.location.search);
let cms = params.get("cms");
if (!cms) {
cms = document
.querySelector(".pl-cms-item.active")
?.dataset.cms;
}
if (!cms) return;
params.set("cms", cms);
if (solution === "All") {
params.delete("solution");
} else {
params.set("solution", solution);
}
const newUrl = window.location.pathname + "?" + params.toString();
window.history.replaceState({}, "", newUrl);
}
function updateCMSParams(cms) {
const params = new URLSearchParams(window.location.search);
params.set("cms", cms);
params.delete("solution");
const newUrl = window.location.pathname + "?" + params.toString();
window.history.replaceState({}, "", newUrl);
}
const params = new URLSearchParams(window.location.search);
const cmsParam = params.get("cms");
const solutionParam = params.get("solution");
if (cmsParam) {
selectedCMS = cmsParam;
} else {
selectedCMS = document.querySelector(".pl-cms-item.active") ?.dataset.cms || selectedCMS;
}
selectedSolution = solutionParam || "All";
renderCMS(object);
renderSolutions(object);
document.querySelectorAll(".pl-cms-item").forEach((item) => {
item.classList.remove("active");
if (item.dataset.cms === selectedCMS) {
item.classList.add("active");
}
});
const solutionInput = document.querySelector(
`input[name="solution"][value="${selectedSolution}"]`
);
if (solutionInput) {
solutionInput.checked = true;
}
renderCards(object);
clearFilterLabels();
addFilterLabel(selectedCMS);
addFilterLabel(selectedSolution, selectedSolution === "All");
if (solutionHead) {
solutionHead.innerHTML = `${
selectedCMS === "Others"
? "Filter by Other CMS"
: "Filter by Solution"
}`;
}
})