1 line
3.3 KiB
JavaScript
1 line
3.3 KiB
JavaScript
!function(u,d,m){function f(e){var t;27==e.which&&(t=S(e.target,".menupop"))&&(t.querySelector(".menupop > .ab-item").focus(),E(t))}function p(e){var t;13==e.which&&(S(e.target,".ab-sub-wrapper")||(t=S(e.target,".menupop"))&&(e.preventDefault(),r(t)?E(t):y(t)))}function h(e){var t;13===e.which&&(t=e.target.getAttribute("href"),-1!=m.userAgent.toLowerCase().indexOf("applewebkit")&&t&&"#"==t.charAt(0)&&setTimeout(function(){var e=u.getElementById(t.replace("#",""));e.setAttribute("tabIndex","0"),e.focus()},100))}function v(e,t){var n;S(t.target,".ab-sub-wrapper")||(t.preventDefault(),(n=S(t.target,".menupop"))&&(r(n)?E(n):(w(e),y(n))))}function g(e){var t=e.target.parentNode,n=t.querySelector(".shortlink-input");return e.preventDefault&&e.preventDefault(),e.returnValue=!1,t.classList.add("selected"),n.focus(),n.select(),!(n.onblur=function(){t.classList.remove("selected")})}function b(){if("sessionStorage"in d)try{for(var e in sessionStorage)-1!=e.indexOf("wp-autosave-")&&sessionStorage.removeItem(e)}catch(e){}}function r(e){return e.classList.contains("hover")}function y(e){e.classList.add("hover")}function E(e){e.classList.remove("hover")}function w(e){for(var t=0;t<e.length;t++)r(e[t])&&E(e[t])}function L(e){if(!e.target||!e.target.id||"wpadminbar"==e.target.id||"wp-admin-bar-top-secondary"==e.target.id)try{d.scrollTo({top:-32,left:0,behavior:"smooth"})}catch(e){d.scrollTo(0,-32)}}function S(e,t){for(Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;0<=--n&&t.item(n)!==this;);return-1<n});e&&e!==u;e=e.parentNode)if(e.matches(t))return e;return null}u.addEventListener("DOMContentLoaded",function(){var e,t,n=u.getElementById("wpadminbar"),r=n.querySelectorAll("li.menupop"),o=n.querySelectorAll(".ab-item"),a=u.getElementById("wp-admin-bar-logout"),i=u.getElementById("adminbarsearch"),s=u.getElementById("wp-admin-bar-get-shortlink"),c=n.querySelector(".screen-reader-shortcut"),l=/Mobile\/.+Safari/.test(m.userAgent)?"touchstart":"click";n.classList.remove("nojs"),"ontouchstart"in d&&(u.body.addEventListener(l,function(e){S(e.target,"li.menupop")||w(r)}),n.addEventListener("touchstart",function e(){for(var t=0;t<r.length;t++)r[t].addEventListener("click",v.bind(null,r));n.removeEventListener("touchstart",e)})),n.addEventListener("click",L);for(t=0;t<r.length;t++)hoverintent(r[t],y.bind(null,r[t]),E.bind(null,r[t])).options({timeout:180}),r[t].addEventListener("keydown",p);for(t=0;t<o.length;t++)o[t].addEventListener("keydown",f);i&&((e=u.getElementById("adminbar-search")).addEventListener("focus",function(){i.classList.add("adminbar-focused")}),e.addEventListener("blur",function(){i.classList.remove("adminbar-focused")})),c.addEventListener("keydown",h),s&&s.addEventListener("click",g),d.location.hash&&d.scrollBy(0,-32),m.userAgent&&-1===u.body.className.indexOf("no-font-face")&&/Android (1.0|1.1|1.5|1.6|2.0|2.1)|Nokia|Opera Mini|w(eb)?OSBrowser|webOS|UCWEB|Windows Phone OS 7|XBLWP7|ZuneWP7|MSIE 7/.test(m.userAgent)&&(u.body.className+=" no-font-face"),a.addEventListener("click",b)})}(document,window,navigator); |