diff --git a/united4earth/static/js/main.js b/united4earth/static/js/main.js index 6e0311b6ee422ad4dbf406e9cf4784048c6fd6d1..ae7b3e3142e97a0f8aa2bf23723c8c6793676bbe 100644 --- a/united4earth/static/js/main.js +++ b/united4earth/static/js/main.js @@ -911,6 +911,7 @@ function visibilityControler(solidDisplay,parentSection) { setTimeout(() => { let section = parentSection; let isRepresentativeSection = false ; + let isActionStep = false; //console.log("section classes",section.classList,solidDisplay); sectionClasses = section.classList; @@ -918,11 +919,18 @@ function visibilityControler(solidDisplay,parentSection) { if(sectionClass.includes('contact-representative')){ isRepresentativeSection = true; } + else if (sectionClass.includes('action-step')) { + isActionStep = true; + } }); //Handle representative section seperately if (isRepresentativeSection == true){ visibilityControlerRepresentative(section); } + //handle steps seperately + else if(isActionStep == true){ + visibilityControlerActionStep(section); + } else{ //get content of the display let content = solidDisplay.querySelector("div").innerText; @@ -954,6 +962,21 @@ function visibilityControlerRepresentative(section){ }, 2000); } +//handle action step section +function visibilityControlerActionStep(section) { + setTimeout(() => { + stepContent = section.querySelector('u4e-multiple-action-steps > solid-display > div').innerText; + stepContent= stepContent.replace(/\s/g,""); + stepContent= stepContent.replace(/\n/g,""); + // console.log('step content is',stepContent); + if (stepContent == '') { + section.style.display = "none"; + } + else{ + section.style.display = "block"; + } + }, 500); +} /*********************** IF SPECIFIC REPRESENTATIVES ARE TARGETTED @@ -1014,30 +1037,22 @@ function hideRepresentativeSearch(solidDisplay){ function styleActiveActionStep(solidDisplay){ //get all "active" fields in display activeFields = solidDisplay.querySelectorAll("*[name=active]"); - console.log("step fields",activeFields); + // console.log("step fields",activeFields); //if none, hide section - if (activeFields.length == 0) { - solidDisplay.closest('section').style.display='none'; - } - else{ + if (!activeFields.length == 0) { activeFields.forEach(activeField => { activeFieldValue = activeField.innerText; //if Active is true, set "active" class to parent display if (activeFieldValue.toLowerCase() == 'true' ){ activeField.closest('solid-display').classList.add('active'); - console.log(activeField.closest('solid-display').classList); + // console.log(activeField.closest('solid-display').classList); } - }); + }); } } - - - /*********************** - LANGUAGE SWITCH - + LANGUAGE SWITCH ***********************/ - async function manageSelectLanguage() { let languageSelects = document.querySelectorAll(".languageChoice") //console.log("languages",languageSelects);