{"version":3,"sources":["../bower_components/what-input/what-input.js"],"names":["window","whatInput","eventBuffer","clearTimer","setInput","event","buffer","timer","setTimeout","bufferedEvent","unBufferedEvent","clearTimeout","eventKey","key","value","inputMap","type","pointerType","currentInput","eventTarget","target","eventTargetNode","nodeName","toLowerCase","eventTargetType","getAttribute","body","hasAttribute","keyMap","nonTypingInputs","indexOf","ignoreMap","switchInput","logKeys","string","setAttribute","inputTypes","push","keyCode","which","srcElement","pointerMap","activeKeys","unLogKeys","arrayPos","splice","bindEvents","document","PointerEvent","addEventListener","MSPointerEvent","mouseWheel","detectWheel","createElement","undefined","onmousewheel","keydown","keyup","mousedown","mousemove","MSPointerDown","MSPointerMove","pointerdown","pointermove","touchstart","9","13","16","27","32","37","38","39","40","2","3","4","Array","prototype","ask","keys","types","set"],"mappings":"AAAAA,OAAAC,UAAA,WAEA,YA+FA,SAAAC,KACAC,IACAC,EAAAC,OAEAC,GAAA,EACAC,EAAAP,OAAAQ,WAAA,WACAF,GAAA,GACA,KAGA,QAAAG,GAAAJ,GACAC,GAAAF,EAAAC,GAGA,QAAAK,GAAAL,GACAF,IACAC,EAAAC,GAGA,QAAAF,KACAH,OAAAW,aAAAJ,GAGA,QAAAH,GAAAC,GACA,GAAAO,GAAAC,EAAAR,GACAS,EAAAC,EAAAV,EAAAW,KAIA,IAHA,YAAAF,IAAAA,EAAAG,EAAAZ,IAGAa,IAAAJ,EAAA,CACA,GAAAK,GAAAC,EAAAf,GACAgB,EAAAF,EAAAG,SAAAC,cACAC,EAAA,UAAAH,EAAAF,EAAAM,aAAA,QAAA,MAIAC,EAAAC,aAAA,8BAGAT,GAGA,aAAAJ,GAGA,QAAAc,EAAAhB,KAIA,aAAAS,GACA,WAAAA,GACA,UAAAA,GAAAQ,EAAAC,QAAAN,GAAA,IAGAO,EAAAD,QAAAlB,OAKAoB,EAAAlB,GAIA,aAAAA,GAAAmB,EAAArB,GAGA,QAAAoB,GAAAE,GACAhB,EAAAgB,EACAR,EAAAS,aAA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,QACAC,UAAA,QACAC,cAAA,UACAC,cAAA,UACAC,YAAA,UACAC,YAAA,UACAC,WAAA,QAIAjD,GAAAqC,KAAA,OAGA,IAuBA7C,GAvBA6B,KAGAR,GACAqC,EAAA,MACAC,GAAA,QACAC,GAAA,QACAC,GAAA,MACAC,GAAA,QACAC,GAAA,OACAC,GAAA,KACAC,GAAA,QACAC,GAAA,QAIAhC,GACAiC,EAAA,QACAC,EAAA,QACAC,EAAA,QAoMA,OArBA,oBAAA5E,SACA6E,MAAAC,UAAAhD,UAIAiB,SAAArB,KACAoB,IAIAC,SAAAE,iBAAA,mBAAAH,KAcAiC,IAAA,WAAA,MAAA7D,IAGA8D,KAAA,WAAA,MAAAtC,IAGAuC,MAAA,WAAA,MAAA7C,IAGA8C,IAAAlD","file":"what-input.min.js","sourcesContent":["window.whatInput = (function() {\n\n 'use strict';\n\n /*\n ---------------\n variables\n ---------------\n */\n\n // array of actively pressed keys\n var activeKeys = [];\n\n // cache document.body\n var body;\n\n // boolean: true if touch buffer timer is running\n var buffer = false;\n\n // the last used input type\n var currentInput = null;\n\n // `input` types that don't accept text\n var nonTypingInputs = [\n 'button',\n 'checkbox',\n 'file',\n 'image',\n 'radio',\n 'reset',\n 'submit'\n ];\n\n // detect version of mouse wheel event to use\n // via https://developer.mozilla.org/en-US/docs/Web/Events/wheel\n var mouseWheel = detectWheel();\n\n // list of modifier keys commonly used with the mouse and\n // can be safely ignored to prevent false keyboard detection\n var ignoreMap = [\n 16, // shift\n 17, // control\n 18, // alt\n 91, // Windows key / left Apple cmd\n 93 // Windows menu / right Apple cmd\n ];\n\n // mapping of events to input types\n var inputMap = {\n 'keydown': 'keyboard',\n 'keyup': 'keyboard',\n 'mousedown': 'mouse',\n 'mousemove': 'mouse',\n 'MSPointerDown': 'pointer',\n 'MSPointerMove': 'pointer',\n 'pointerdown': 'pointer',\n 'pointermove': 'pointer',\n 'touchstart': 'touch'\n };\n\n // add correct mouse wheel event mapping to `inputMap`\n inputMap[detectWheel()] = 'mouse';\n\n // array of all used input types\n var inputTypes = [];\n\n // mapping of key codes to a common name\n var keyMap = {\n 9: 'tab',\n 13: 'enter',\n 16: 'shift',\n 27: 'esc',\n 32: 'space',\n 37: 'left',\n 38: 'up',\n 39: 'right',\n 40: 'down'\n };\n\n // map of IE 10 pointer events\n var pointerMap = {\n 2: 'touch',\n 3: 'touch', // treat pen like touch\n 4: 'mouse'\n };\n\n // touch buffer timer\n var timer;\n\n\n /*\n ---------------\n functions\n ---------------\n */\n\n // allows events that are also triggered to be filtered out for `touchstart`\n function eventBuffer() {\n clearTimer();\n setInput(event);\n\n buffer = true;\n timer = window.setTimeout(function() {\n buffer = false;\n }, 650);\n }\n\n function bufferedEvent(event) {\n if (!buffer) setInput(event);\n }\n\n function unBufferedEvent(event) {\n clearTimer();\n setInput(event);\n }\n\n function clearTimer() {\n window.clearTimeout(timer);\n }\n\n function setInput(event) {\n var eventKey = key(event);\n var value = inputMap[event.type];\n if (value === 'pointer') value = pointerType(event);\n\n // don't do anything if the value matches the input type already set\n if (currentInput !== value) {\n var eventTarget = target(event);\n var eventTargetNode = eventTarget.nodeName.toLowerCase();\n var eventTargetType = (eventTargetNode === 'input') ? eventTarget.getAttribute('type') : null;\n\n if (\n (// only if the user flag to allow typing in form fields isn't set\n !body.hasAttribute('data-whatinput-formtyping') &&\n\n // only if currentInput has a value\n currentInput &&\n\n // only if the input is `keyboard`\n value === 'keyboard' &&\n\n // not if the key is `TAB`\n keyMap[eventKey] !== 'tab' &&\n\n // only if the target is a form input that accepts text\n (\n eventTargetNode === 'textarea' ||\n eventTargetNode === 'select' ||\n (eventTargetNode === 'input' && nonTypingInputs.indexOf(eventTargetType) < 0)\n )) || (\n // ignore modifier keys\n ignoreMap.indexOf(eventKey) > -1\n )\n ) {\n // ignore keyboard typing\n } else {\n switchInput(value);\n }\n }\n\n if (value === 'keyboard') logKeys(eventKey);\n }\n\n function switchInput(string) {\n currentInput = string;\n body.setAttribute('data-whatinput', currentInput);\n\n if (inputTypes.indexOf(currentInput) === -1) inputTypes.push(currentInput);\n }\n\n function key(event) {\n return (event.keyCode) ? event.keyCode : event.which;\n }\n\n function target(event) {\n return event.target || event.srcElement;\n }\n\n function pointerType(event) {\n if (typeof event.pointerType === 'number') {\n return pointerMap[event.pointerType];\n } else {\n return (event.pointerType === 'pen') ? 'touch' : event.pointerType; // treat pen like touch\n }\n }\n\n // keyboard logging\n function logKeys(eventKey) {\n if (activeKeys.indexOf(keyMap[eventKey]) === -1 && keyMap[eventKey]) activeKeys.push(keyMap[eventKey]);\n }\n\n function unLogKeys(event) {\n var eventKey = key(event);\n var arrayPos = activeKeys.indexOf(keyMap[eventKey]);\n\n if (arrayPos !== -1) activeKeys.splice(arrayPos, 1);\n }\n\n function bindEvents() {\n body = document.body;\n\n // pointer events (mouse, pen, touch)\n if (window.PointerEvent) {\n body.addEventListener('pointerdown', bufferedEvent);\n body.addEventListener('pointermove', bufferedEvent);\n } else if (window.MSPointerEvent) {\n body.addEventListener('MSPointerDown', bufferedEvent);\n body.addEventListener('MSPointerMove', bufferedEvent);\n } else {\n\n // mouse events\n body.addEventListener('mousedown', bufferedEvent);\n body.addEventListener('mousemove', bufferedEvent);\n\n // touch events\n if ('ontouchstart' in window) {\n body.addEventListener('touchstart', eventBuffer);\n }\n }\n\n // mouse wheel\n body.addEventListener(mouseWheel, bufferedEvent);\n\n // keyboard events\n body.addEventListener('keydown', unBufferedEvent);\n body.addEventListener('keyup', unBufferedEvent);\n document.addEventListener('keyup', unLogKeys);\n }\n\n\n /*\n ---------------\n utilities\n ---------------\n */\n\n // detect version of mouse wheel event to use\n // via https://developer.mozilla.org/en-US/docs/Web/Events/wheel\n function detectWheel() {\n return mouseWheel = 'onwheel' in document.createElement('div') ?\n 'wheel' : // Modern browsers support \"wheel\"\n\n document.onmousewheel !== undefined ?\n 'mousewheel' : // Webkit and IE support at least \"mousewheel\"\n 'DOMMouseScroll'; // let's assume that remaining browsers are older Firefox\n }\n\n\n /*\n ---------------\n init\n\n don't start script unless browser cuts the mustard,\n also passes if polyfills are used\n ---------------\n */\n\n if (\n 'addEventListener' in window &&\n Array.prototype.indexOf\n ) {\n\n // if the dom is already ready already (script was placed at bottom of )\n if (document.body) {\n bindEvents();\n\n // otherwise wait for the dom to load (script was placed in the )\n } else {\n document.addEventListener('DOMContentLoaded', bindEvents);\n }\n }\n\n\n /*\n ---------------\n api\n ---------------\n */\n\n return {\n\n // returns string: the current input type\n ask: function() { return currentInput; },\n\n // returns array: currently pressed keys\n keys: function() { return activeKeys; },\n\n // returns array: all the detected input types\n types: function() { return inputTypes; },\n\n // accepts string: manually set the input type\n set: switchInput\n };\n\n}());\n"],"sourceRoot":"assets/scripts/"}