hotkeys-js
Advanced tools
Comparing version 2.0.7 to 2.0.8
@@ -1,3 +0,3 @@ | ||
/*! hotkeys-js v2.0.7 | MIT (c) 2017 kenny wang <wowohoo@qq.com> | https://github.com/jaywcjlove/hotkeys.git */ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).hotkeys=e()}}(function(){function n(e){return h[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)}function t(e){g=e||"all"}function o(){return g||"all"}function r(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent&&e.attachEvent("on"+n,function(){t(window.event)})}function i(e){var n,t=e.keyCode||e.which||e.charCode,r=x["*"];if(-1===v.indexOf(t)&&v.push(t),93!==t&&224!==t||(t=91),t in m){m[t]=!0;for(var i in y)y[i]===t&&(s[i]=!0);if(!r)return}for(var a in m)m[a]=e[w[a]];if(s.filter.call(this,e)){if(n=o(),r)for(l=0;l<r.length;l++)r[l].scope===n&&f(e,r[l],n);if(t in x)for(var l=0;l<x[t].length;l++)f(e,x[t][l],n)}}function f(e,n,t){var o;if(n.scope===t||"all"===n.scope){o=n.mods.length>0;for(var r in m)(!m[r]&&n.mods.indexOf(+r)>-1||m[r]&&-1===n.mods.indexOf(+r))&&(o=!1);(0!==n.mods.length||m[16]||m[18]||m[17]||m[91])&&!o&&"*"!==n.shortcut||!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function a(e,n){for(var t=e.length>=n.length?e:n,o=e.length>=n.length?n:e,r=0;r<t.length;r++)if(-1===o.indexOf(t[r]))return!1;return!0}function l(e){for(var n=e.slice(0,e.length-1),t=0;t<n.length;t++)n[t]=y[n[t].toLowerCase()];return n}function d(e){e||(e="");var n,t;for(t=(n=(e=e.replace(/\s/g,"")).split(",")).lastIndexOf("");t>=0;)n[t-1]+=",",n.splice(t,1),t=n.lastIndexOf("");return n}function c(n){var t=n.keyCode||e.which||e.charCode,o=v.indexOf(t);if(o>=0&&v.splice(o,1),93!==t&&224!==t||(t=91),t in m){m[t]=!1;for(var r in y)y[r]===t&&(s[r]=!1)}}function s(e,t,o){var r=d(e),i=[],f=0;for(void 0===o&&(o=t,t="all");f<r.length;f++)i=[],(e=r[f].split("+")).length>1&&(i=l(e)),(e="*"===(e=e[e.length-1])?"*":n(e))in x||(x[e]=[]),x[e].push({shortcut:r[f],scope:t,method:o,key:r[f],mods:i})}Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var n=0;n<this.length;n++)if(this[n]===e)return n;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(e){for(var n=this.length-1;n>=0;n--)if(this[n]===e)return n;return-1});for(var u,p="undefined"!=typeof navigator&&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,"-":p?173:189,"=":p?61:187,";":p?59:186,"'":222,"[":219,"]":221,"\\":220},g="all",y={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":p?224:91,cmd:p?224:91,command:p?224:91},v=[],w={16:"shiftKey",18:"altKey",17:"ctrlKey"},m={16:!1,18:!1,17:!1},x={},k=1;k<20;k++)h["f"+k]=111+k;w[p?224:91]="metaKey",m[p?224:91]=!1,"undefined"!=typeof document&&(r(document,"keydown",function(e){i(e)}),r(document,"keyup",function(e){c(e)})),u={setScope:t,getScope:o,deleteScope:function(e,n){var r,i,f;e||(e=o());for(r in x)for(i=x[r],f=0;f<i.length;)i[f].scope===e?i.splice(f,1):f++;o()===e&&t(n||"all")},getPressedKeyCodes:function(){return v.slice(0)},isPressed:function(e){return"string"==typeof e&&(e=n(e)),-1!==v.indexOf(e)},filter:function(e){var n=(e.target||e.srcElement).tagName;return!("INPUT"===n||"SELECT"===n||"TEXTAREA"===n)},unbind:function(e,t){for(var r,i,f=d(e),c=[],s=0;s<f.length;s++){if((r=f[s].split("+")).length>1&&(c=l(r)),e=r[r.length-1],e="*"===e?"*":n(e),t||(t=o()),!x[e])return;for(var u=0;u<x[e].length;u++)(i=x[e][u]).scope===t&&a(i.mods,c)&&(x[e][u]={})}}};for(var O in u)s[O]=u[O];if("undefined"!=typeof window){var C=window.hotkeys;s.noConflict=function(e){return e&&window.hotkeys===s&&(window.hotkeys=C),s},window.hotkeys=s}return window.hotkeys=s,s}); | ||
/*! hotkeys-js v2.0.8 | MIT (c) 2018 kenny wang <wowohoo@qq.com> | https://github.com/jaywcjlove/hotkeys.git */ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).hotkeys=e()}}(function(){function e(e){return p[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)}function n(e){h=e||"all"}function t(){return h||"all"}function o(e,n,t){e.addEventListener?e.addEventListener(n,t,!1):e.attachEvent&&e.attachEvent("on"+n,function(){t(window.event)})}function r(e){var n,o=e.keyCode||e.which||e.charCode,r=m["*"];if(-1===y.indexOf(o)&&y.push(o),93!==o&&224!==o||(o=91),o in w){w[o]=!0;for(var f in g)g[f]===o&&(c[f]=!0);if(!r)return}for(var a in w)w[a]=e[v[a]];if(c.filter.call(this,e)){if(n=t(),r)for(l=0;l<r.length;l++)r[l].scope===n&&i(e,r[l],n);if(o in m)for(var l=0;l<m[o].length;l++)i(e,m[o][l],n)}}function i(e,n,t){var o;if(n.scope===t||"all"===n.scope){o=n.mods.length>0;for(var r in w)(!w[r]&&n.mods.indexOf(+r)>-1||w[r]&&-1===n.mods.indexOf(+r))&&(o=!1);(0!==n.mods.length||w[16]||w[18]||w[17]||w[91])&&!o&&"*"!==n.shortcut||!1===n.method(e,n)&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function f(e,n){for(var t=e.length>=n.length?e:n,o=e.length>=n.length?n:e,r=0;r<t.length;r++)if(-1===o.indexOf(t[r]))return!1;return!0}function a(e){for(var n=e.slice(0,e.length-1),t=0;t<n.length;t++)n[t]=g[n[t].toLowerCase()];return n}function l(e){e||(e="");var n,t;for(t=(n=(e=e.replace(/\s/g,"")).split(",")).lastIndexOf("");t>=0;)n[t-1]+=",",n.splice(t,1),t=n.lastIndexOf("");return n}function d(e){var n=e.keyCode||e.which||e.charCode,t=y.indexOf(n);if(t>=0&&y.splice(t,1),93!==n&&224!==n||(n=91),n in w){w[n]=!1;for(var o in g)g[o]===n&&(c[o]=!1)}}function c(n,t,o){var r=l(n),i=[],f=0;for(void 0===o&&(o=t,t="all");f<r.length;f++)i=[],(n=r[f].split("+")).length>1&&(i=a(n)),(n="*"===(n=n[n.length-1])?"*":e(n))in m||(m[n]=[]),m[n].push({shortcut:r[f],scope:t,method:o,key:r[f],mods:i})}Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var n=0;n<this.length;n++)if(this[n]===e)return n;return-1}),Array.prototype.lastIndexOf||(Array.prototype.lastIndexOf=function(e){for(var n=this.length-1;n>=0;n--)if(this[n]===e)return n;return-1});for(var s,u="undefined"!=typeof navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")>0,p={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,"-":u?173:189,"=":u?61:187,";":u?59:186,"'":222,"[":219,"]":221,"\\":220},h="all",g={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":u?224:91,cmd:u?224:91,command:u?224:91},y=[],v={16:"shiftKey",18:"altKey",17:"ctrlKey"},w={16:!1,18:!1,17:!1},m={},x=1;x<20;x++)p["f"+x]=111+x;v[u?224:91]="metaKey",w[u?224:91]=!1,"undefined"!=typeof document&&(o(document,"keydown",function(e){r(e)}),o(document,"keyup",function(e){d(e)})),s={setScope:n,getScope:t,deleteScope:function(e,o){var r,i,f;e||(e=t());for(r in m)for(i=m[r],f=0;f<i.length;)i[f].scope===e?i.splice(f,1):f++;t()===e&&n(o||"all")},getPressedKeyCodes:function(){return y.slice(0)},isPressed:function(n){return"string"==typeof n&&(n=e(n)),-1!==y.indexOf(n)},filter:function(e){var n=(e.target||e.srcElement).tagName;return!("INPUT"===n||"SELECT"===n||"TEXTAREA"===n)},unbind:function(n,o){for(var r,i,d=l(n),c=[],s=0;s<d.length;s++){if((r=d[s].split("+")).length>1&&(c=a(r)),n=r[r.length-1],n="*"===n?"*":e(n),o||(o=t()),!m[n])return;for(var u=0;u<m[n].length;u++)(i=m[n][u]).scope===o&&f(i.mods,c)&&(m[n][u]={})}}};for(var k in s)c[k]=s[k];if("undefined"!=typeof window){var O=window.hotkeys;c.noConflict=function(e){return e&&window.hotkeys===c&&(window.hotkeys=O),c},window.hotkeys=c}return window.hotkeys=c,c}); | ||
{ | ||
"name": "hotkeys-js", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.", | ||
@@ -5,0 +5,0 @@ "author": "kenny wang <wowohoo@qq.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package