biofriction-wp-theme/node_modules/foundation-sites/dist/js/plugins/foundation.util.keyboard.js...

1 line
15 KiB
Plaintext

{"version":3,"sources":["webpack://__FOUNDATION_EXTERNAL__.[name]/webpack/universalModuleDefinition","webpack://__FOUNDATION_EXTERNAL__.[name]/webpack/bootstrap","webpack://__FOUNDATION_EXTERNAL__.[name]/external {\"root\":[\"__FOUNDATION_EXTERNAL__\",\"foundation.core\"],\"amd\":\"./foundation.core\",\"commonjs\":\"./foundation.core\",\"commonjs2\":\"./foundation.core\"}","webpack://__FOUNDATION_EXTERNAL__.[name]/external {\"root\":[\"__FOUNDATION_EXTERNAL__\",\"foundation.core\"],\"amd\":\"./foundation.core.utils\",\"commonjs\":\"./foundation.core.utils\",\"commonjs2\":\"./foundation.core.utils\"}","webpack://__FOUNDATION_EXTERNAL__.[name]/./js/entries/plugins/foundation.util.keyboard.js","webpack://__FOUNDATION_EXTERNAL__.[name]/./js/foundation.util.keyboard.js","webpack://__FOUNDATION_EXTERNAL__.[name]/external {\"root\":[\"jQuery\"],\"amd\":\"jquery\",\"commonjs\":\"jquery\",\"commonjs2\":\"jquery\"}"],"names":["Foundation","Keyboard","keyCodes","commands","findFocusable","$element","find","filter","$","is","attr","parseKey","event","key","which","keyCode","String","fromCharCode","toUpperCase","replace","shiftKey","ctrlKey","altKey","keys","getKeyCodes","handleKey","component","functions","commandList","cmds","command","fn","console","warn","ltr","Rtl","extend","rtl","returnValue","apply","handled","unhandled","register","componentName","trapFocus","$focusable","$firstFocusable","eq","$lastFocusable","on","target","preventDefault","focus","releaseFocus","off","kcs","k","kc"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yEAAyE;AACzE,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gC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AIA,KAAK,CAACsC,MAAN,KAAiBF,cAAc,CAAC,CAAD,CAA/B,IAAsCrC,QAAQ,CAACC,KAAD,CAAR,KAAoB,KAA9D,EAAqE;AACnEA,aAAK,CAACuC,cAAN;AACAL,uBAAe,CAACM,KAAhB;AACD,OAHD,MAIK,IAAIxC,KAAK,CAACsC,MAAN,KAAiBJ,eAAe,CAAC,CAAD,CAAhC,IAAuCnC,QAAQ,CAACC,KAAD,CAAR,KAAoB,WAA/D,EAA4E;AAC/EA,aAAK,CAACuC,cAAN;AACAH,sBAAc,CAACI,KAAf;AACD;AACF,KATD;AAUD,GAxFY;;AAyFb;;;;AAIAC,cA7Fa,wBA6FAhD,QA7FA,EA6FU;AACrBA,YAAQ,CAACiD,GAAT,CAAa,sBAAb;AACD;AA/FY,CAAf;AAkGA;;;;;AAIA,SAAS9B,WAAT,CAAqB+B,GAArB,EAA0B;AACxB,MAAIC,CAAC,GAAG,EAAR;;AACA,OAAK,IAAIC,EAAT,IAAeF,GAAf;AAAoBC,KAAC,CAACD,GAAG,CAACE,EAAD,CAAJ,CAAD,GAAaF,GAAG,CAACE,EAAD,CAAhB;AAApB;;AACA,SAAOD,CAAP;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AC/JD,oD","file":"foundation.util.keyboard.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"./foundation.core\"), require(\"./foundation.core.utils\"), require(\"jquery\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"./foundation.core\", \"./foundation.core.utils\", \"jquery\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"foundation.util.keyboard\"] = factory(require(\"./foundation.core\"), require(\"./foundation.core.utils\"), require(\"jquery\"));\n\telse\n\t\troot[\"__FOUNDATION_EXTERNAL__\"] = root[\"__FOUNDATION_EXTERNAL__\"] || {}, root[\"__FOUNDATION_EXTERNAL__\"][\"foundation.util.keyboard\"] = factory(root[\"__FOUNDATION_EXTERNAL__\"][\"foundation.core\"], root[\"__FOUNDATION_EXTERNAL__\"][\"foundation.core\"], root[\"jQuery\"]);\n})(window, function(__WEBPACK_EXTERNAL_MODULE__foundation_core__, __WEBPACK_EXTERNAL_MODULE__foundation_core_utils__, __WEBPACK_EXTERNAL_MODULE_jquery__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 23);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core__;","module.exports = __WEBPACK_EXTERNAL_MODULE__foundation_core_utils__;","import { Foundation } from './foundation.core';\nimport { Keyboard } from '../../foundation.util.keyboard';\n\nFoundation.Keyboard = Keyboard;\n\nexport { Foundation, Keyboard };\n","/*******************************************\n * *\n * This util was created by Marius Olbertz *\n * Please thank Marius on GitHub /owlbertz *\n * or the web http://www.mariusolbertz.de/ *\n * *\n ******************************************/\n\n'use strict';\n\nimport $ from 'jquery';\nimport { rtl as Rtl } from './foundation.core.utils';\n\nconst keyCodes = {\n 9: 'TAB',\n 13: 'ENTER',\n 27: 'ESCAPE',\n 32: 'SPACE',\n 35: 'END',\n 36: 'HOME',\n 37: 'ARROW_LEFT',\n 38: 'ARROW_UP',\n 39: 'ARROW_RIGHT',\n 40: 'ARROW_DOWN'\n}\n\nvar commands = {}\n\n// Functions pulled out to be referenceable from internals\nfunction findFocusable($element) {\n if(!$element) {return false; }\n return $element.find('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]').filter(function() {\n if (!$(this).is(':visible') || $(this).attr('tabindex') < 0) { return false; } //only have visible elements and those that have a tabindex greater or equal 0\n return true;\n });\n}\n\nfunction parseKey(event) {\n var key = keyCodes[event.which || event.keyCode] || String.fromCharCode(event.which).toUpperCase();\n\n // Remove un-printable characters, e.g. for `fromCharCode` calls for CTRL only events\n key = key.replace(/\\W+/, '');\n\n if (event.shiftKey) key = `SHIFT_${key}`;\n if (event.ctrlKey) key = `CTRL_${key}`;\n if (event.altKey) key = `ALT_${key}`;\n\n // Remove trailing underscore, in case only modifiers were used (e.g. only `CTRL_ALT`)\n key = key.replace(/_$/, '');\n\n return key;\n}\n\nvar Keyboard = {\n keys: getKeyCodes(keyCodes),\n\n /**\n * Parses the (keyboard) event and returns a String that represents its key\n * Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE\n * @param {Event} event - the event generated by the event handler\n * @return String key - String that represents the key pressed\n */\n parseKey: parseKey,\n\n /**\n * Handles the given (keyboard) event\n * @param {Event} event - the event generated by the event handler\n * @param {String} component - Foundation component's name, e.g. Slider or Reveal\n * @param {Objects} functions - collection of functions that are to be executed\n */\n handleKey(event, component, functions) {\n var commandList = commands[component],\n keyCode = this.parseKey(event),\n cmds,\n command,\n fn;\n\n if (!commandList) return console.warn('Component not defined!');\n\n if (typeof commandList.ltr === 'undefined') { // this component does not differentiate between ltr and rtl\n cmds = commandList; // use plain list\n } else { // merge ltr and rtl: if document is rtl, rtl overwrites ltr and vice versa\n if (Rtl()) cmds = $.extend({}, commandList.ltr, commandList.rtl);\n\n else cmds = $.extend({}, commandList.rtl, commandList.ltr);\n }\n command = cmds[keyCode];\n\n fn = functions[command];\n if (fn && typeof fn === 'function') { // execute function if exists\n var returnValue = fn.apply();\n if (functions.handled || typeof functions.handled === 'function') { // execute function when event was handled\n functions.handled(returnValue);\n }\n } else {\n if (functions.unhandled || typeof functions.unhandled === 'function') { // execute function when event was not handled\n functions.unhandled();\n }\n }\n },\n\n /**\n * Finds all focusable elements within the given `$element`\n * @param {jQuery} $element - jQuery object to search within\n * @return {jQuery} $focusable - all focusable elements within `$element`\n */\n\n findFocusable: findFocusable,\n\n /**\n * Returns the component name name\n * @param {Object} component - Foundation component, e.g. Slider or Reveal\n * @return String componentName\n */\n\n register(componentName, cmds) {\n commands[componentName] = cmds;\n },\n\n\n // TODO9438: These references to Keyboard need to not require global. Will 'this' work in this context?\n //\n /**\n * Traps the focus in the given element.\n * @param {jQuery} $element jQuery object to trap the foucs into.\n */\n trapFocus($element) {\n var $focusable = findFocusable($element),\n $firstFocusable = $focusable.eq(0),\n $lastFocusable = $focusable.eq(-1);\n\n $element.on('keydown.zf.trapfocus', function(event) {\n if (event.target === $lastFocusable[0] && parseKey(event) === 'TAB') {\n event.preventDefault();\n $firstFocusable.focus();\n }\n else if (event.target === $firstFocusable[0] && parseKey(event) === 'SHIFT_TAB') {\n event.preventDefault();\n $lastFocusable.focus();\n }\n });\n },\n /**\n * Releases the trapped focus from the given element.\n * @param {jQuery} $element jQuery object to release the focus for.\n */\n releaseFocus($element) {\n $element.off('keydown.zf.trapfocus');\n }\n}\n\n/*\n * Constants for easier comparing.\n * Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE\n */\nfunction getKeyCodes(kcs) {\n var k = {};\n for (var kc in kcs) k[kcs[kc]] = kcs[kc];\n return k;\n}\n\nexport {Keyboard};\n","module.exports = __WEBPACK_EXTERNAL_MODULE_jquery__;"],"sourceRoot":""}