/** * Accordion JavaScript without any dependency. * * @author Matthias Kittsteiner * @license GPLv2 and later * @version 2.0.12 */ var collapse_others=true;document.addEventListener("DOMContentLoaded",function(){var accordion_list=document.querySelectorAll(".accordion");var accordion_links=document.querySelectorAll('.accordion-link, a[href*="#"]');var hashRegex=new RegExp("#[A-Za-z0-9_-]+");initialize_accordion();function initialize_accordion(){var hash=window.location.hash;if(!hash.length||!hashRegex.test(hash))return;var hash_element=document.getElementById(hash.substr(1));var hash_parents=get_parents(hash_element,".accordion");Array.from(accordion_list).forEach(function(accordion){close_accordion(accordion,true);if(hash_parents.length){if(accordion.contains(hash_element)||hash.substr(1)===accordion.getAttribute("id")){Array.from(accordion.querySelectorAll(".accordion-link")).forEach(function(link){open_accordion(accordion)})}else{return true}}else if(hash_element){fire_event(hash_element.querySelector(".accordion-link"),"click")}})}Array.from(accordion_links).forEach(function(link){link.addEventListener("click",function(event){var current_accordion=null;var current_target=event.currentTarget;var id_element=document.querySelector(current_target.hash+', [data-scroll-id="'+current_target.hash.substr(1)+'"]');var is_accordion_element=false;Array.from(accordion_list).forEach(function(accordion){if(accordion.contains(current_target)||accordion.contains(id_element)){if(accordion.contains(id_element)){event.preventDefault();is_accordion_element=true}current_accordion=accordion;if(accordion.classList.contains("accordion-visible")){close_accordion(accordion)}else{open_accordion(accordion)}}else if(collapse_others){close_accordion(accordion)}});if(!is_accordion_element&&history.pushState){try{history.pushState("",document.title,current_target.hash)}catch(e){}}setTimeout(function(){var admin_bar=document.getElementById("wpadminbar");var admin_bar_height=admin_bar?admin_bar.offsetHeight:0;var body_offset_top=document.body.getBoundingClientRect().top;if(mobileWidth>1e3){mobileWidth=840}if(window.matchMedia("(min-width: "+mobileWidth+"px)").matches){var header=document.querySelector("#masthead.nav-fixed-wrapper, #masthead.fixed:not(.nav-fixed-wrapper) .nav-fixed")}else{var header=document.getElementById("mobile-menu-toggle")}var header_height=header?header.offsetHeight:0;var target=document.querySelector(".accordion-visible");if(target){var target_offset_top=target.getBoundingClientRect().top-(body_offset_top+header_height+admin_bar_height);animate(document.scrollingElement||document.documentElement,"scrollTop","",window.pageYOffset,target_offset_top,300,true)}function animate(elem,style,unit,from,to,time,prop){if(!elem){return}var start=(new Date).getTime(),timer=setInterval(function(){var step=Math.min(1,((new Date).getTime()-start)/time);if(prop){elem[style]=from+step*(to-from)+unit}else{elem.style[style]=from+step*(to-from)+unit}if(step===1){clearInterval(timer)}},25);if(prop){elem[style]=from+unit}else{elem.style[style]=from+unit}}},500)})});function close_accordion(accordion,initial){var content=accordion.querySelector(".accordion-container");var icon=accordion.querySelector(".accordion-title .icon");var id="#"+accordion.getAttribute("id")||accordion.getAttribute("data-scroll-id");icon.classList.remove("top");icon.classList.add("bottom");content.setAttribute("aria-hidden","true");slideUp(content);accordion.classList.remove("accordion-visible");accordion.classList.add("closed");if(history.pushState&&id===location.hash&&initial!==true){try{history.pushState("",document.title,window.location.pathname+window.location.search)}catch(e){}}}function open_accordion(accordion){var content=accordion.querySelector(".accordion-container");var id=accordion.getAttribute("id")||accordion.getAttribute("data-scroll-id");var hash="#"+id;var icon=accordion.querySelector(".accordion-title .icon");icon.classList.remove("bottom");icon.classList.add("top");content.setAttribute("aria-hidden","false");slideDown(content);accordion.classList.remove("closed");accordion.classList.add("accordion-visible");if(history.pushState){try{history.pushState(null,null,hash)}catch(e){}}}function get_parents(elem,selector){if(!Element.prototype.matches){Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(s){var matches=(this.document||this.ownerDocument).querySelectorAll(s),i=matches.length;while(--i>=0&&matches.item(i)!==this){}return i>-1}}var parents=[];for(;elem&&elem!==document;elem=elem.parentNode){if(selector){if(elem.matches(selector)){parents.push(elem)}}else{parents.push(elem)}}return parents}function fire_event(el,etype){if(!el)return;if(el.fireEvent){el.fireEvent("on"+etype)}else{var evObj=document.createEvent("Events");evObj.initEvent(etype,true,false);el.dispatchEvent(evObj)}}function slideDown(el,timing){timing=timing||"300ms ease";el.style.transition="none";el.style.visibility="hidden";el.style.maxHeight="none";var height=el.offsetHeight+"px";el.style.removeProperty("visibility");el.style.maxHeight="0";el.style.overflow="hidden";el.style.transition="max-height "+timing+", opacity "+timing+"";var endSlideDown=function(){el.style.removeProperty("transition");el.removeEventListener("transitionend",endSlideDown)};requestAnimationFrame(function(){el.addEventListener("transitionend",endSlideDown);el.style.maxHeight=height;el.style.opacity="1"})}function slideUp(el,timing){timing=timing||"300ms ease";el.style.transition="none";var height=el.offsetHeight+"px";el.style.maxHeight=height;el.style.overflow="hidden";el.style.transition="max-height "+timing+", opacity "+timing+"";var endSlideDown=function(){el.style.removeProperty("transition");el.removeEventListener("transitionend",endSlideDown)};requestAnimationFrame(function(){el.style.maxHeight="0";el.style.opacity="0"})}}); //# sourceMappingURL=accordion.min.js.map