{"version":3,"sources":["skip-navigation.js"],"names":["_classCallCheck","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_createClass","protoProps","staticProps","prototype","window","closest","Element","s","querySelectorAll","that","this","matches","item","NodeList","forEach","Array","SkipNavigationController","value","main","focusables","focusableQueryString","get","document","querySelector","skipNavButton","getAttribute","exports","module","addEventListener","skipNav","mainElement","mainId","id","location","hash","setFocusInMain"],"mappings":"AAAA,aAEA,SAASA,gBAAgBC,EAAUC,GAAa,KAAAD,aAAAC,GAAA,MAAA,IAAAC,UAAA,qCAA4C,SAAAC,kBAAoBC,EAAAC,GAAA,IAAA,IAAAC,EAAA,EAApBA,EAAAD,EAAAE,OAAAD,IAAA,CAAA,IAAAE,EAAAH,EAAAC,GAAAE,EAAAC,WAAAD,EAAAC,aAAA,EAAAD,EAAAE,cAAA,EAAA,UAAAF,IAAAA,EAAAG,UAAA,GAAAC,OAAAC,eAAAT,EAAAI,EAAAM,IAAAN,IAA6D,SAAAO,aAAAd,EAAAe,EAAAC,GAAA,OAAAD,GAAAb,kBAAAF,EAAAiB,UAAAF,GAAAC,GAAAd,kBAAAF,EAAAgB,GAAAhB,EAE7GkB,OAASb,UAAWD,QAAME,UAAaa,UAAEC,QAAIb,UAAUY,QAAd,SAAAE,GAA2Bd,IAAwDA,EAAxDA,GAAWC,KAAAA,UAAaD,KAAWC,eAAcc,iBAAjDD,GAA4FE,EAAAC,KAA+G,GAE3T,IAF6TnB,EAAAoB,EAAAnB,OAEpTQ,KAAAA,GAAad,EAAtB0B,KAAmCX,KAAnCQ,WAAwIP,EAAJ,IAAiBd,EAAAA,EAAAA,gBAkBjJ,OAAOqB,IAbPL,OAEIK,WAFJI,SAAAV,UAAAW,UAoBFD,SAASV,UAAUW,QAAUC,MAAMZ,UAAUW,SAS/C,IAAIE,yBAfD,WACF,SAAAA,IACDhC,gBAAA0B,KAAAM,GAuCK,OApCLhB,aAAWa,EAAsBV,KAAUW,CAAAA,CACzCD,IAAAA,iBAuBEI,MAAO,SAAwBC,GAC7B,GAAa,OAATA,EAdV,IAeQ,IAAIC,EAAaD,EAAKV,iBAAiBQ,EAAyBI,sBAfxE7B,EAAA,EAAAA,EAAA4B,EAAA3B,OAAAD,IACA,GAAY,OAAA4B,EAAA5B,GAAAc,QAAA,UAAA,CACDW,EAAAA,GAAAA,QACPhC,SAsBC,CAhBDe,IAAA,cAMIsB,IAAA,WAkBF,OAAOC,SAASC,cAAcP,EAAyBQ,cAAcC,aAAa,WAVjF,CACF1B,IAAA,uBAlB0CsB,IAmB1C,WACDtB,MAAK,kGAOH,CACDA,IAAA,gBACDsB,IAAA,WAkBE,OAAOC,SAASC,cAAc,wBAb/BP,EAxDF,GA4DE,oBAAAU,UACDC,OAAAD,QAAAV,0BALCZ,OAUAwB,iBAAA,mBAAA,WACD7B,IAAG8B,EAAEb,yBADJQ,cAEEN,EAAEF,yBAAec,YAEnB,GAAA,OAAAD,GAAA,OAAAX,EAAA,CAhDH,IAAAa,EAAAb,EAAAc,GAmDAH,EAAOb,iBAAAA,QAAP,WACGZ,OAAA6B,SAAAC,KAAA,KAGD9B,OAAOsB,iBAAY,aAAa,WAClC,GAAOA,OAAUV,SAAAA,KAAAA,QAAAA,IACjBA,yBAAAmB,eAAAjB","file":"skip-navigation.min.js","sourcesContent":["\"use strict\";\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n/*Global Closest fix for IE*/\nif (window.Element && !Element.prototype.closest) {\n Element.prototype.closest = function (s) {\n var matches = (this.document || this.ownerDocument).querySelectorAll(s),\n i,\n that = this;\n\n do {\n i = matches.length;\n\n while (--i >= 0 && matches.item(i) !== that) {//\n }\n } while (i < 0 && (that = that.parentElement));\n /* eslint-disable-line consistent-this */\n\n\n return that;\n };\n}\n/*Global ForEach fix for IE*/\n\n\nif (window.NodeList && !NodeList.prototype.forEach) {\n NodeList.prototype.forEach = Array.prototype.forEach;\n} // NOTE: This file is auto-generated into the Legacy js as skip-navigation.js so that files stay consistent.\n// Achieved via the combineSkipNavJsForLegacy task in the gulpfile.\n\n/**\r\n * Controls the behavior of the skip navigation link\r\n */\n\n\nvar SkipNavigationController =\n/*#__PURE__*/\nfunction () {\n function SkipNavigationController() {\n _classCallCheck(this, SkipNavigationController);\n }\n\n _createClass(SkipNavigationController, null, [{\n key: \"setFocusInMain\",\n\n /**\r\n * Sets the focus of the document in the first focusable item in the given main element\r\n * @param {Node} main\r\n */\n value: function setFocusInMain(main) {\n if (main !== null) {\n var focusables = main.querySelectorAll(SkipNavigationController.focusableQueryString);\n\n for (var i = 0; i < focusables.length; i++) {\n if (focusables[i].closest('header') === null) {\n focusables[i].focus();\n break;\n }\n }\n }\n }\n }, {\n key: \"mainElement\",\n\n /**\r\n * Return the
tag as a node\r\n * @return Node\r\n */\n get: function get() {\n return document.querySelector(SkipNavigationController.skipNavButton.getAttribute('href'));\n }\n /**\r\n * Returns the string used to find focusable elements\r\n * @return String\r\n */\n\n }, {\n key: \"focusableQueryString\",\n get: function get() {\n return 'button, [href], input:not([type=\"hidden\"]), select, textarea, [tabindex]:not([tabindex=\"-1\"])';\n }\n /**\r\n * Returns the skip navigation button as a node.\r\n * @return Node\r\n */\n\n }, {\n key: \"skipNavButton\",\n get: function get() {\n return document.querySelector('.skip-navigation');\n }\n }]);\n\n return SkipNavigationController;\n}(); // Export for Jest testing\n\n\nif (typeof exports !== 'undefined') {\n module.exports = SkipNavigationController;\n} // IIFE\n\n\n(function () {\n window.addEventListener('DOMContentLoaded', function () {\n var skipNav = SkipNavigationController.skipNavButton;\n var main = SkipNavigationController.mainElement;\n\n if (skipNav !== null && main !== null) {\n var mainId = main.id; // Resets URL hash, aids when skip nav is toggled more than once in a session.\n\n skipNav.addEventListener('click', function () {\n window.location.hash = '';\n }); // Sets focus on first focusable item in main when the URL hash changes to main's id\n\n window.addEventListener('hashchange', function () {\n if (window.location.href.indexOf(mainId) >= 0) {\n SkipNavigationController.setFocusInMain(main);\n }\n });\n }\n });\n})();"]}