-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathskip-link-focus.min.js
8 lines (8 loc) · 1.02 KB
/
skip-link-focus.min.js
1
2
3
4
5
6
7
8
/**
* Skip Link Focus v1.0.0
* https://github.com/cedaro/skip-link-focus
*
* @copyright Modifications Copyright (c) 2015 Cedaro, LLC
* @license BSD-3-Clause
*/
(function(t,e){"use strict";if("function"===typeof define&&define.amd){define([],e)}else if("object"===typeof exports){module.exports=e()}else{t.skipLinkFocus=e()}})(this,function(){"use strict";function t(t){t=t||{};t.selector=t.selector||".skip-link";if(window&&/webkit|opera|msie|trident/i.test(navigator.userAgent)&&window.addEventListener){var i,s=window.document.querySelectorAll(t.selector);window.addEventListener("hashchange",function(){n(location.hash.substring(1))},false);for(i=0;i<s.length;++i){s[i].addEventListener("click",e)}if(location.hash&&location.hash.substring(1)){n(location.hash.substring(1))}}}function e(t){n(t.target.hash.substring(1))}function n(t){var e;if(!/^[A-z0-9_-]+$/.test(t)){return}e=window.document.getElementById(t);if(e){if(!/^(?:a|select|input|button|textarea)$/i.test(e.tagName)){e.tabIndex=-1}e.focus()}}return{init:t,skipToElement:n}});