first commit

This commit is contained in:
armansansd
2023-07-12 16:31:19 +01:00
commit 3424b1927b
23306 changed files with 2217776 additions and 0 deletions
File diff suppressed because one or more lines are too long
+481
View File
@@ -0,0 +1,481 @@
/**
* what-input - A global utility for tracking the current input method (mouse, keyboard or touch).
* @version v5.1.4
* @link https://github.com/ten1seven/what-input
* @license MIT
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("whatInput", [], factory);
else if(typeof exports === 'object')
exports["whatInput"] = factory();
else
root["whatInput"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
'use strict';
module.exports = function () {
/*
* bail out if there is no document or window
* (i.e. in a node/non-DOM environment)
*
* Return a stubbed API instead
*/
if (typeof document === 'undefined' || typeof window === 'undefined') {
return {
// always return "initial" because no interaction will ever be detected
ask: function ask() {
return 'initial';
},
// always return null
element: function element() {
return null;
},
// no-op
ignoreKeys: function ignoreKeys() {},
// no-op
specificKeys: function specificKeys() {},
// no-op
registerOnChange: function registerOnChange() {},
// no-op
unRegisterOnChange: function unRegisterOnChange() {}
};
}
/*
* variables
*/
// cache document.documentElement
var docElem = document.documentElement;
// currently focused dom element
var currentElement = null;
// last used input type
var currentInput = 'initial';
// last used input intent
var currentIntent = currentInput;
// check for sessionStorage support
// then check for session variables and use if available
try {
if (window.sessionStorage.getItem('what-input')) {
currentInput = window.sessionStorage.getItem('what-input');
}
if (window.sessionStorage.getItem('what-intent')) {
currentIntent = window.sessionStorage.getItem('what-intent');
}
} catch (e) {}
// event buffer timer
var eventTimer = null;
// form input types
var formInputs = ['input', 'select', 'textarea'];
// empty array for holding callback functions
var functionList = [];
// list of modifier keys commonly used with the mouse and
// can be safely ignored to prevent false keyboard detection
var ignoreMap = [16, // shift
17, // control
18, // alt
91, // Windows key / left Apple cmd
93 // Windows menu / right Apple cmd
];
var specificMap = [];
// mapping of events to input types
var inputMap = {
keydown: 'keyboard',
keyup: 'keyboard',
mousedown: 'mouse',
mousemove: 'mouse',
MSPointerDown: 'pointer',
MSPointerMove: 'pointer',
pointerdown: 'pointer',
pointermove: 'pointer',
touchstart: 'touch',
touchend: 'touch'
// boolean: true if touch buffer is active
};var isBuffering = false;
// boolean: true if the page is being scrolled
var isScrolling = false;
// store current mouse position
var mousePos = {
x: null,
y: null
// map of IE 10 pointer events
};var pointerMap = {
2: 'touch',
3: 'touch', // treat pen like touch
4: 'mouse'
// check support for passive event listeners
};var supportsPassive = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function get() {
supportsPassive = true;
}
});
window.addEventListener('test', null, opts);
} catch (e) {}
/*
* set up
*/
var setUp = function setUp() {
// add correct mouse wheel event mapping to `inputMap`
inputMap[detectWheel()] = 'mouse';
addListeners();
doUpdate('input');
doUpdate('intent');
};
/*
* events
*/
var addListeners = function addListeners() {
// `pointermove`, `MSPointerMove`, `mousemove` and mouse wheel event binding
// can only demonstrate potential, but not actual, interaction
// and are treated separately
var options = supportsPassive ? { passive: true } : false;
// pointer events (mouse, pen, touch)
if (window.PointerEvent) {
window.addEventListener('pointerdown', setInput);
window.addEventListener('pointermove', setIntent);
} else if (window.MSPointerEvent) {
window.addEventListener('MSPointerDown', setInput);
window.addEventListener('MSPointerMove', setIntent);
} else {
// mouse events
window.addEventListener('mousedown', setInput);
window.addEventListener('mousemove', setIntent);
// touch events
if ('ontouchstart' in window) {
window.addEventListener('touchstart', eventBuffer, options);
window.addEventListener('touchend', setInput);
}
}
// mouse wheel
window.addEventListener(detectWheel(), setIntent, options);
// keyboard events
window.addEventListener('keydown', eventBuffer);
window.addEventListener('keyup', eventBuffer);
// focus events
window.addEventListener('focusin', setElement);
window.addEventListener('focusout', clearElement);
};
// checks conditions before updating new input
var setInput = function setInput(event) {
// only execute if the event buffer timer isn't running
if (!isBuffering) {
var eventKey = event.which;
var value = inputMap[event.type];
if (value === 'pointer') {
value = pointerType(event);
}
var ignoreMatch = !specificMap.length && ignoreMap.indexOf(eventKey) === -1;
var specificMatch = specificMap.length && specificMap.indexOf(eventKey) !== -1;
var shouldUpdate = value === 'keyboard' && eventKey && (ignoreMatch || specificMatch) || value === 'mouse' || value === 'touch';
if (currentInput !== value && shouldUpdate) {
currentInput = value;
try {
window.sessionStorage.setItem('what-input', currentInput);
} catch (e) {}
doUpdate('input');
}
if (currentIntent !== value && shouldUpdate) {
// preserve intent for keyboard typing in form fields
var activeElem = document.activeElement;
var notFormInput = activeElem && activeElem.nodeName && formInputs.indexOf(activeElem.nodeName.toLowerCase()) === -1;
if (notFormInput) {
currentIntent = value;
try {
window.sessionStorage.setItem('what-intent', currentIntent);
} catch (e) {}
doUpdate('intent');
}
}
}
};
// updates the doc and `inputTypes` array with new input
var doUpdate = function doUpdate(which) {
docElem.setAttribute('data-what' + which, which === 'input' ? currentInput : currentIntent);
fireFunctions(which);
};
// updates input intent for `mousemove` and `pointermove`
var setIntent = function setIntent(event) {
// test to see if `mousemove` happened relative to the screen to detect scrolling versus mousemove
detectScrolling(event);
// only execute if the event buffer timer isn't running
// or scrolling isn't happening
if (!isBuffering && !isScrolling) {
var value = inputMap[event.type];
if (value === 'pointer') {
value = pointerType(event);
}
if (currentIntent !== value) {
currentIntent = value;
try {
window.sessionStorage.setItem('what-intent', currentIntent);
} catch (e) {}
doUpdate('intent');
}
}
};
var setElement = function setElement(event) {
if (!event.target.nodeName) {
// If nodeName is undefined, clear the element
// This can happen if click inside an <svg> element.
clearElement();
return;
}
currentElement = event.target.nodeName.toLowerCase();
docElem.setAttribute('data-whatelement', currentElement);
if (event.target.classList && event.target.classList.length) {
docElem.setAttribute('data-whatclasses', event.target.classList.toString().replace(' ', ','));
}
};
var clearElement = function clearElement() {
currentElement = null;
docElem.removeAttribute('data-whatelement');
docElem.removeAttribute('data-whatclasses');
};
// buffers events that frequently also fire mouse events
var eventBuffer = function eventBuffer(event) {
// set the current input
setInput(event);
// clear the timer if it happens to be running
window.clearTimeout(eventTimer);
// set the isBuffering to `true`
isBuffering = true;
// run the timer
eventTimer = window.setTimeout(function () {
// if the timer runs out, set isBuffering back to `false`
isBuffering = false;
}, 120);
};
/*
* utilities
*/
var pointerType = function pointerType(event) {
if (typeof event.pointerType === 'number') {
return pointerMap[event.pointerType];
} else {
// treat pen like touch
return event.pointerType === 'pen' ? 'touch' : event.pointerType;
}
};
// detect version of mouse wheel event to use
// via https://developer.mozilla.org/en-US/docs/Web/Events/wheel
var detectWheel = function detectWheel() {
var wheelType = void 0;
// Modern browsers support "wheel"
if ('onwheel' in document.createElement('div')) {
wheelType = 'wheel';
} else {
// Webkit and IE support at least "mousewheel"
// or assume that remaining browsers are older Firefox
wheelType = document.onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll';
}
return wheelType;
};
// runs callback functions
var fireFunctions = function fireFunctions(type) {
for (var i = 0, len = functionList.length; i < len; i++) {
if (functionList[i].type === type) {
functionList[i].fn.call(undefined, type === 'input' ? currentInput : currentIntent);
}
}
};
// finds matching element in an object
var objPos = function objPos(match) {
for (var i = 0, len = functionList.length; i < len; i++) {
if (functionList[i].fn === match) {
return i;
}
}
};
var detectScrolling = function detectScrolling(event) {
if (mousePos['x'] !== event.screenX || mousePos['y'] !== event.screenY) {
isScrolling = false;
mousePos['x'] = event.screenX;
mousePos['y'] = event.screenY;
} else {
isScrolling = true;
}
};
/*
* init
*/
// don't start script unless browser cuts the mustard
// (also passes if polyfills are used)
if ('addEventListener' in window && Array.prototype.indexOf) {
setUp();
}
/*
* api
*/
return {
// returns string: the current input type
// opt: 'intent'|'input'
// 'input' (default): returns the same value as the `data-whatinput` attribute
// 'intent': includes `data-whatintent` value if it's different than `data-whatinput`
ask: function ask(opt) {
return opt === 'intent' ? currentIntent : currentInput;
},
// returns string: the currently focused element or null
element: function element() {
return currentElement;
},
// overwrites ignored keys with provided array
ignoreKeys: function ignoreKeys(arr) {
ignoreMap = arr;
},
// overwrites specific char keys to update on
specificKeys: function specificKeys(arr) {
specificMap = arr;
},
// attach functions to input and intent "events"
// funct: function to fire on change
// eventType: 'input'|'intent'
registerOnChange: function registerOnChange(fn, eventType) {
functionList.push({
fn: fn,
type: eventType || 'input'
});
},
unRegisterOnChange: function unRegisterOnChange(fn) {
var position = objPos(fn);
if (position || position === 0) {
functionList.splice(position, 1);
}
}
};
}();
/***/ })
/******/ ])
});
;
+8
View File
@@ -0,0 +1,8 @@
/**
* what-input - A global utility for tracking the current input method (mouse, keyboard or touch).
* @version v5.1.4
* @link https://github.com/ten1seven/what-input
* @license MIT
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("whatInput",[],t):"object"==typeof exports?exports.whatInput=t():e.whatInput=t()}(this,function(){return function(n){var o={};function i(e){if(o[e])return o[e].exports;var t=o[e]={exports:{},id:e,loaded:!1};return n[e].call(t.exports,t,t.exports,i),t.loaded=!0,t.exports}return i.m=n,i.c=o,i.p="",i(0)}([function(e,t){"use strict";e.exports=function(){if("undefined"==typeof document||"undefined"==typeof window)return{ask:function(){return"initial"},element:function(){return null},ignoreKeys:function(){},specificKeys:function(){},registerOnChange:function(){},unRegisterOnChange:function(){}};var t=document.documentElement,n=null,s="initial",a=s;try{window.sessionStorage.getItem("what-input")&&(s=window.sessionStorage.getItem("what-input")),window.sessionStorage.getItem("what-intent")&&(a=window.sessionStorage.getItem("what-intent"))}catch(e){}var o=null,d=["input","select","textarea"],i=[],c=[16,17,18,91,93],w=[],f={keydown:"keyboard",keyup:"keyboard",mousedown:"mouse",mousemove:"mouse",MSPointerDown:"pointer",MSPointerMove:"pointer",pointerdown:"pointer",pointermove:"pointer",touchstart:"touch",touchend:"touch"},p=!1,r=!1,u={x:null,y:null},l={2:"touch",3:"touch",4:"mouse"},h=!1;try{var e=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("test",null,e)}catch(e){}var m=function(){var e=!!h&&{passive:!0};window.PointerEvent?(window.addEventListener("pointerdown",v),window.addEventListener("pointermove",g)):window.MSPointerEvent?(window.addEventListener("MSPointerDown",v),window.addEventListener("MSPointerMove",g)):(window.addEventListener("mousedown",v),window.addEventListener("mousemove",g),"ontouchstart"in window&&(window.addEventListener("touchstart",x,e),window.addEventListener("touchend",v))),window.addEventListener(b(),g,e),window.addEventListener("keydown",x),window.addEventListener("keyup",x),window.addEventListener("focusin",E),window.addEventListener("focusout",L)},v=function(e){if(!p){var t=e.which,n=f[e.type];"pointer"===n&&(n=S(e));var o=!w.length&&-1===c.indexOf(t),i=w.length&&-1!==w.indexOf(t),r="keyboard"===n&&t&&(o||i)||"mouse"===n||"touch"===n;if(s!==n&&r){s=n;try{window.sessionStorage.setItem("what-input",s)}catch(e){}y("input")}if(a!==n&&r){var u=document.activeElement;if(u&&u.nodeName&&-1===d.indexOf(u.nodeName.toLowerCase())){a=n;try{window.sessionStorage.setItem("what-intent",a)}catch(e){}y("intent")}}}},y=function(e){t.setAttribute("data-what"+e,"input"===e?s:a),I(e)},g=function(e){if(O(e),!p&&!r){var t=f[e.type];if("pointer"===t&&(t=S(e)),a!==t){a=t;try{window.sessionStorage.setItem("what-intent",a)}catch(e){}y("intent")}}},E=function(e){e.target.nodeName?(n=e.target.nodeName.toLowerCase(),t.setAttribute("data-whatelement",n),e.target.classList&&e.target.classList.length&&t.setAttribute("data-whatclasses",e.target.classList.toString().replace(" ",","))):L()},L=function(){n=null,t.removeAttribute("data-whatelement"),t.removeAttribute("data-whatclasses")},x=function(e){v(e),window.clearTimeout(o),p=!0,o=window.setTimeout(function(){p=!1},120)},S=function(e){return"number"==typeof e.pointerType?l[e.pointerType]:"pen"===e.pointerType?"touch":e.pointerType},b=function(){return"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll"},I=function(e){for(var t=0,n=i.length;t<n;t++)i[t].type===e&&i[t].fn.call(void 0,"input"===e?s:a)},O=function(e){u.x!==e.screenX||u.y!==e.screenY?(r=!1,u.x=e.screenX,u.y=e.screenY):r=!0};return"addEventListener"in window&&Array.prototype.indexOf&&(f[b()]="mouse",m(),y("input"),y("intent")),{ask:function(e){return"intent"===e?a:s},element:function(){return n},ignoreKeys:function(e){c=e},specificKeys:function(e){w=e},registerOnChange:function(e,t){i.push({fn:e,type:t||"input"})},unRegisterOnChange:function(e){var t=function(e){for(var t=0,n=i.length;t<n;t++)if(i[t].fn===e)return t}(e);(t||0===t)&&i.splice(t,1)}}}()}])});
//# sourceMappingURL=maps/what-input.min.js.map