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
122 KiB
JavaScript

8 years ago
!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,r,n){(function(t){!function(e){if("object"==typeof n&&void 0!==r)r.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:this).hotkeys=e()}}(function(){function t(){return p||"all"}function r(t,e,r){t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent&&t.attachEvent("on"+e,function(){r(window.event)})}function n(e){var r,n=e.keyCode||e.which||e.charCode,o=v["*"];if(-1===g.indexOf(n)&&g.push(n),93!==n&&224!==n||(n=91),n in b){b[n]=!0;for(var s in d)d[s]===n&&(f[s]=!0);if(!o)return}for(var a in b)b[a]=e[y[a]];if(f.filter.call(this,e)){if(r=t(),o)for(u=0;u<o.length;u++)o[u].scope===r&&i(e,o[u],r);if(n in v)for(var u=0;u<v[n].length;u++)i(e,v[n][u],r)}}function i(t,e,r){var n;if(e.scope===r||"all"===e.scope){n=e.mods.length>0;for(var i in b)(!b[i]&&e.mods.indexOf(+i)>-1||b[i]&&-1===e.mods.indexOf(+i))&&(n=!1);(0!==e.mods.length||b[16]||b[18]||b[17]||b[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 o(t,e){if(t.length!==e.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function s(t){for(var e=t.slice(0,t.length-1),r=0;r<e.length;r++)e[r]=d[e[r]];return e}function a(t){var e;return t=t.replace(/\s/g,""),""===(e=t.split(","))[e.length-1]&&(e[e.length-2]+=","),e}function u(t){var r=t.keyCode||e.which||e.charCode,n=g.indexOf(r);if(n>=0&&g.splice(n,1),93!==r&&224!==r||(r=91),r in b){b[r]=!1;for(var i in d)d[i]===r&&(f[i]=!1)}}function f(t,e,r){var n=a(t),i=[],o=0;for(void 0===r&&(r=e,e="all");o<n.length;o++)i=[],(t=n[o].split("+")).length>1&&(i=s(t),t=[t[t.length-1]]),(t="*"===(t=t[0])?"*":m(t))in v||(v[t]=[]),v[t].push({shortcut:n[o],scope:e,method:r,key:n[o],mods:i})}Array.prototype.indexOf||(Array.prototype.indexOf=function(t){for(var e=0;e<this.length;e++)if(this[e]===t)return e;return-1});for(var l,c=navigator.userAgent.toLowerCase().indexOf("firefox")>0,h={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,home:36,end:35,pageup:33,pagedown:34,"⇪":20,CapsLock:20,",":188,".":190,"/":191,"`":192,"-":c?173:189,"=":c?61:187,";":c?59:186,"'":222,"[":219,"]":221,"\\":220},p="all",d={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":c?224:91,command:c?224:91},g=[],y={16:"shiftKey",18:"altKey",17:"ctrlKey"},b={16:!1,18:!1,17:!1},m=function(t){return h[t]||t.toUpperCase().charCodeAt(0)},v={},w=1;w<20;w++)h["f"+w]=111+w;y[c?224:91]="metaKey",b[c?224:91]=!1,r(document,"keydown",function(t){n(t)}),r(document,"keyup",function(t){u(t)}),l={setScope:function(t){p=t||"all"},getScope:t,deleteScope:function(t){var e,r,n;for(e in v)for(r=v[e],n=0;n<r.length;)r[n].scope===t?r.splice(n,1):n++},getPressedKeyCodes:function(t){return g.slice(0)},isPressed:function(t){return"string"==typeof t&&(t=m(t)),-1!==g.indexOf(t)},filter:function(t){var e=(t.target||t.srcElement).tagName;return!("INPUT"===e||"SELECT"===e||"TEXTAREA"===e)},unbind:function(e,r){for(var n,i,u=a(e),f=[],l=0;l<u.length;l++){if((n=u[l].split("+")).length>1&&(f=s(n)),e=n[n.length-1],e=m(e),void 0===r&&(r=t()),!v[e])return;for(var c=0;c<v[e].length;c++)(i=v[e][c]).scope===r&&o(i.mods,f)&&(v[e][c]={})}}};for(var _ in l)f[_]=l[_];var x=window.hotkeys;return f.noConflict=function(t){return t&&window.hotkeys===f&&(window.hotkeys=x),f},window.hotkeys=f,f})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[fu