You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hotkeys/test/hotkeys.test.js

2 lines
123 KiB
JavaScript

!function(){return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r||t)},l,l.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}}()({1:[function(t,e,r){(function(t){!function(n){if("object"==typeof r&&void 0!==e)e.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:this).hotkeys=n()}}(function(){Array.prototype.indexOf||(Array.prototype.indexOf=function(t){for(var e=0;e<this.length;e++)if(this[e]===t)return e;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(t){for(var e=this.length-1;e>=0;e--)if(this[e]===t)return e;return-1});for(var t,e="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0,r={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,"⇪":20,capslock:20,",":188,".":190,"/":191,"`":192,"-":e?173:189,"=":e?61:187,";":e?59:186,"'":222,"[":219,"]":221,"\\":220},n="all",i={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":e?224:91,cmd:e?224:91,command:e?224:91},o=[],s={16:"shiftKey",18:"altKey",17:"ctrlKey"},a={16:!1,18:!1,17:!1},u={},f=1;f<20;f++)r["f"+f]=111+f;function l(t){return r[t.toLowerCase()]||t.toUpperCase().charCodeAt(0)}function c(t){n=t||"all"}function h(){return n||"all"}function p(t,e,r){t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent&&t.attachEvent("on"+e,function(){r(window.event)})}function d(t,e,r){var n;if(e.scope===r||"all"===e.scope){for(var i in n=e.mods.length>0,a)(!a[i]&&e.mods.indexOf(+i)>-1||a[i]&&-1===e.mods.indexOf(+i))&&(n=!1);(0!==e.mods.length||a[16]||a[18]||a[17]||a[91])&&!n&&"*"!==e.shortcut||!1===e.method(t,e)&&(t.preventDefault?t.preventDefault():t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.cancelBubble&&(t.cancelBubble=!0))}}function g(t,e){for(var r=t.length>=e.length?t:e,n=t.length>=e.length?e:t,i=0;i<r.length;i++)if(-1===n.indexOf(r[i]))return!1;return!0}function y(t){for(var e=t.slice(0,t.length-1),r=0;r<e.length;r++)e[r]=i[e[r].toLowerCase()];return e}function b(t){var e,r;for(t||(t=""),r=(e=(t=t.replace(/\s/g,"")).split(",")).lastIndexOf("");r>=0;)e[r-1]+=",",e.splice(r,1),r=e.lastIndexOf("");return e}function m(t,e,r){var n=b(t),i=[],o=0;for(void 0===r&&(r=e,e="all");o<n.length;o++)i=[],(t=n[o].split("+")).length>1&&(i=y(t)),(t="*"===(t=t[t.length-1])?"*":l(t))in u||(u[t]=[]),u[t].push({shortcut:n[o],scope:e,method:r,key:n[o],mods:i})}for(var v in s[e?224:91]="metaKey",a[e?224:91]=!1,"undefined"!=typeof document&&(p(document,"keydown",function(t){!function(t){var e,r=t.keyCode||t.which||t.charCode,n=u["*"];if(-1===o.indexOf(r)&&o.push(r),93!==r&&224!==r||(r=91),r in a){for(var f in a[r]=!0,i)i[f]===r&&(m[f]=!0);if(!n)return}for(var l in a)a[l]=t[s[l]];if(m.filter.call(this,t)){if(e=h(),n)for(c=0;c<n.length;c++)n[c].scope===e&&d(t,n[c],e);if(r in u)for(var c=0;c<u[r].length;c++)d(t,u[r][c],e)}}(t)}),p(document,"keyup",function(t){!function(t){var e=t.keyCode||t.which||t.charCode,r=o.indexOf(e);r>=0&&o.splice(r,1);93!==e&&224!==e||(e=91);if(e in a)for(var n in a[e]=!1,i)i[n]===e&&(m[n]=!1)}(t)})),t={setScope:c,getScope:h,deleteScope:function(t,e){var r,n,i;for(r in t||(t=h()),u)for(n=u[r],i=0;i<n.length;)n[i].scope===t?n.splice(i,1):i++;h()===t&&c(e||"all")},getPressedKeyCodes:function(){return o.slice(0)},isPressed:function(t){return"string"==typeof t&&(t=l(t)),-1!==o.indexOf(t)},filter:function(t){var e=(t.target||t.srcElement).tagName;return!("INPUT"===e||"SELECT"===e||"TEXTAREA"===e)},unbind:function(t,e){for(var r,n,i=b(t),o=[],s=0;s<i.length;s++){if((r=i[s].split("+")).length>1&&(o=y(r)),t="*"===(t=r[r.length-1])?