laipower/wp-content/themes/generatepress/js/a11y.min.js

2 lines
2.1 KiB
JavaScript
Raw Normal View History

2020-04-07 13:03:04 +00:00
/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var e,t=location.hash.substring(1);/^[A-z0-9_-]+$/.test(t)&&(e=document.getElementById(t))&&(/^(?:a|select|input|button|textarea)$/i.test(e.tagName)||(e.tabIndex=-1),e.focus())},!1),function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var e=document.body;e.addEventListener("mousedown",function(){e.classList.add("using-mouse")}),e.addEventListener("keydown",function(){e.classList.remove("using-mouse")})}}(),function(){"use strict";if("querySelector"in document&&"addEventListener"in window&&document.body.classList.contains("dropdown-hover"))for(var e=document.querySelectorAll("nav .main-nav ul a"),t=function(){if(!this.closest("nav").classList.contains("toggled")&&!this.closest("nav").classList.contains("slideout-navigation"))for(var e=this;-1===e.className.indexOf("main-nav");)"li"===e.tagName.toLowerCase()&&(-1!==e.className.indexOf("sfHover")?e.className=e.className.replace(" sfHover",""):e.className+=" sfHover"),e=e.parentElement},s=0;s<e.length;s++)e[s].addEventListener("focus",t),e[s].addEventListener("blur",t);if("ontouchend"in document.documentElement&&document.body.classList.contains("dropdown-hover")){var n=document.querySelectorAll(".sf-menu .menu-item-has-children");for(s=0;s<n.length;s++)n[s].addEventListener("touchend",function(e){if(!(this.closest("nav").classList.contains("toggled")||1!==e.touches.length&&0!==e.touches.length||(e.stopPropagation(),this.classList.contains("sfHover")))){e.target!==this&&e.target.parentNode!==this&&!e.target.parentNode.parentNode||e.preventDefault();var t=this.closest("nav").querySelectorAll("ul.toggled-on");if(t&&!this.closest("ul").classList.contains("toggled-on")&&!this.closest("li").classList.contains("sfHover"))for(var s=0;s<t.length;s++)t[s].classList.remove("toggled-on"),t[s].closest("li").classList.remove("sfHover");this.classList.add("sfHover");var n,o=this;document.addEventListener("touchend",n=function(e){e.stopPropagation(),o.classList.remove("sfHover"),document.removeEventListener("touchend",n)})}})}}();