foundation-sites
Version:
The most advanced responsive front-end framework in the world.
3 lines (2 loc) • 3.9 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./foundation.core"),require("jquery")):"function"==typeof define&&define.amd?define(["./foundation.core","jquery"],t):"object"==typeof exports?exports["foundation.util.keyboard"]=t(require("./foundation.core"),require("jquery")):(e.__FOUNDATION_EXTERNAL__=e.__FOUNDATION_EXTERNAL__||{},e.__FOUNDATION_EXTERNAL__["foundation.util.keyboard"]=t(e.__FOUNDATION_EXTERNAL__["foundation.core"],e.jQuery))}(window,function(n,r){return i={"./foundation.core":function(e,t){e.exports=n},"./js/entries/plugins/foundation.util.keyboard.js":function(e,t,n){"use strict";n.r(t);var r=n("./foundation.core");n.d(t,"Foundation",function(){return r.Foundation});var o=n("./js/foundation.util.keyboard.js");n.d(t,"Keyboard",function(){return o.Keyboard}),r.Foundation.Keyboard=o.Keyboard},"./js/foundation.util.keyboard.js":function(e,t,n){"use strict";n.r(t),n.d(t,"Keyboard",function(){return f});var t=n("jquery"),o=n.n(t),i=n("./foundation.core"),r={9:"TAB",13:"ENTER",27:"ESCAPE",32:"SPACE",35:"END",36:"HOME",37:"ARROW_LEFT",38:"ARROW_UP",39:"ARROW_RIGHT",40:"ARROW_DOWN"},u={};function a(e){return!!e&&e.find("a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]").filter(function(){return!(!o()(this).is(":visible")||o()(this).attr("tabindex")<0)}).sort(function(e,t){if(o()(e).attr("tabindex")===o()(t).attr("tabindex"))return 0;var n=parseInt(o()(e).attr("tabindex"),10),r=parseInt(o()(t).attr("tabindex"),10);return void 0===o()(e).attr("tabindex")&&0<r?1:void 0===o()(t).attr("tabindex")&&0<n?-1:0===n&&0<r?1:0===r&&0<n||n<r?-1:r<n?1:void 0})}function d(e){var t=(t=r[e.which||e.keyCode]||String.fromCharCode(e.which).toUpperCase()).replace(/\W+/,"");return e.shiftKey&&(t="SHIFT_".concat(t)),e.ctrlKey&&(t="CTRL_".concat(t)),t=(t=e.altKey?"ALT_".concat(t):t).replace(/_$/,"")}var f={keys:function(e){var t,n={};for(t in e)e.hasOwnProperty(t)&&(n[e[t]]=e[t]);return n}(r),parseKey:d,handleKey:function(e,t,n){var r=u[t],t=this.parseKey(e);if(!r)return console.warn("Component not defined!");!0!==e.zfIsKeyHandled&&((t=n[(void 0===r.ltr?r:Object(i.rtl)()?o.a.extend({},r.ltr,r.rtl):o.a.extend({},r.rtl,r.ltr))[t]])&&"function"==typeof t?(t=t.apply(),e.zfIsKeyHandled=!0,!n.handled&&"function"!=typeof n.handled||n.handled(t)):!n.unhandled&&"function"!=typeof n.unhandled||n.unhandled())},findFocusable:a,register:function(e,t){u[e]=t},trapFocus:function(e){var t=a(e),n=t.eq(0),r=t.eq(-1);e.on("keydown.zf.trapfocus",function(e){e.target===r[0]&&"TAB"===d(e)?(e.preventDefault(),n.focus()):e.target===n[0]&&"SHIFT_TAB"===d(e)&&(e.preventDefault(),r.focus())})},releaseFocus:function(e){e.off("keydown.zf.trapfocus")}}},23:function(e,t,n){e.exports=n("./js/entries/plugins/foundation.util.keyboard.js")},jquery:function(e,t){e.exports=r}},u={},o.m=i,o.c=u,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=23);function o(e){if(u[e])return u[e].exports;var t=u[e]={i:e,l:!1,exports:{}};return i[e].call(t.exports,t,t.exports,o),t.l=!0,t.exports}var i,u});
//# sourceMappingURL=foundation.util.keyboard.min.js.map