1(function () { 2 var d = document, 3 accordionToggles = d.querySelectorAll(".js-accordionTrigger"), 4 setAria, 5 setAccordionAria, 6 switchAccordion, 7 touchSupported = "ontouchstart" in window, 8 pointerSupported = "pointerdown" in window; 9 10 11 const skipClickDelay = function (e) { 12 e.preventDefault(); 13 e.target.click(); 14 }; 15 16 const setAriaAttr = function (el, ariaType, newProperty) { 17 el.setAttribute(ariaType, newProperty); 18 }; 19 setAccordionAria = function (el1, el2, expanded) { 20 switch (expanded) { 21 case "true": 22 setAriaAttr(el1, "aria-expanded", "true"); 23 setAriaAttr(el2, "aria-hidden", "false"); 24 break; 25 case "false": 26 setAriaAttr(el1, "aria-expanded", "false"); 27 setAriaAttr(el2, "aria-hidden", "true"); 28 break; 29 default: 30 break; 31 } 32 }; 33 //function 34 switchAccordion = function (e) { 35 console.log("triggered"); 36 e.preventDefault(); 37 var thisAnswer = e.target.parentNode.nextElementSibling; 38 var thisQuestion = e.target; 39 if (thisAnswer.classList.contains("is-collapsed")) {
40 setAccordionAria(thisQuestion, thisAnswer, "true"); 41 } else { 42 setAccordionAria(thisQuestion, thisAnswer, "false"); 43 } 44 thisQuestion.classList.toggle("is-collapsed"); 45 thisQuestion.classList.toggle("is-expanded"); 46 thisAnswer.classList.toggle("is-collapsed"); 47 thisAnswer.classList.toggle("is-expanded"); 48 thisAnswer.classList.toggle("animateIn"); 49 }; 50 for (var i = 0, len = accordionToggles.length; i < len; i++) { 51 if (touchSupported) { 52 accordionToggles[i].addEventListener( 53 "touchstart", 54 skipClickDelay, 55 false 56 ); 57 } 58 if (pointerSupported) { 59 accordionToggles[i].addEventListener( 60 "pointerdown", 61 skipClickDelay, 62 false 63 ); 64 } 65 accordionToggles[i].addEventListener("click", switchAccordion, false); 66 } 67})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.