Welcome to mirror list, hosted at ThFree Co, Russian Federation.

accordion.js « js « static - github.com/darshanbaral/aafu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c5160ed449478d7ddb4e2e8fc93280d40e603e10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const allPanels = Array.from(document.querySelectorAll(".panel"));
const allAccordion = Array.from(document.querySelectorAll(".accordion"));
const expandAccordion = elem => {
  if (!elem.parentElement.classList.contains("active")) {
    allAccordion.forEach(acc => {
      acc.classList.remove("active");
    });
    elem.parentElement.classList.add("active");
    allPanels.forEach(function(elem) {
      elem.style.maxHeight = null;
    });
    let activePanel = elem.parentElement.nextElementSibling;
    if (
      activePanel.id != "skill-panel" &&
      document.querySelector("#skill-panel")
    ) {
      let skillBars = Array.from(document.querySelectorAll("#skill-percent"));
      skillBars.forEach(elem => {
        elem.style.width = "0";
      });
    } //else {
    //console.log("Skill Section Disabled");
    //}
    activePanel.style.maxHeight = activePanel.scrollHeight + "px";
  } // else {
  //  console.log("Already Expanded");
  //}
};