@pluginjs/keyboard
Advanced tools
Comparing version 0.7.0 to 0.7.1
/*! | ||
* @pluginjs/keyboard v0.7.0 (https://pluginjs.com) | ||
* @pluginjs/keyboard v0.7.1 (https://pluginjs.com) | ||
* Copyright 2018 Creation Studio Limited | ||
@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License. |
/*! | ||
* @pluginjs/keyboard v0.7.0 (https://pluginjs.com) | ||
* @pluginjs/keyboard v0.7.1 (https://pluginjs.com) | ||
* Copyright 2018 Creation Studio Limited | ||
@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License. |
/*! | ||
* @pluginjs/keyboard v0.7.0 (https://pluginjs.com) | ||
* @pluginjs/keyboard v0.7.1 (https://pluginjs.com) | ||
* Copyright 2018 Creation Studio Limited | ||
@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License. |
/*! | ||
* @pluginjs/keyboard v0.7.0 (https://pluginjs.com) | ||
* @pluginjs/keyboard v0.7.1 (https://pluginjs.com) | ||
* Copyright 2018 Creation Studio Limited | ||
@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License. |
/*! | ||
* @pluginjs/keyboard v0.7.0 (https://pluginjs.com) | ||
* @pluginjs/keyboard v0.7.1 (https://pluginjs.com) | ||
* Copyright 2018 Creation Studio Limited | ||
@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License. |
/*! | ||
* @pluginjs/keyboard v0.7.0 (https://pluginjs.com) | ||
* @pluginjs/keyboard v0.7.1 (https://pluginjs.com) | ||
* Copyright 2018 Creation Studio Limited | ||
* Released under the GPL-3.0 License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@pluginjs/simple-emitter"),require("@pluginjs/utils")):"function"==typeof define&&define.amd?define(["@pluginjs/simple-emitter","@pluginjs/utils"],t):e["@pluginjs/keyboard"]=t(e["@pluginjs/simple-emitter"],e["@pluginjs/utils"])}(this,function(e,t){"use strict";function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var u=new(Function.bind.apply(e,i));return n&&r(u,n.prototype),u}).apply(null,arguments)}e=e&&e.hasOwnProperty("default")?e.default:e;var u={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"caps_lock",27:"esc",32:"space",33:"page_up",34:"page_down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"command",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"num_lock"},o={};for(var s in u)Object.prototype.hasOwnProperty.call(u,s)&&(o[u[s]]=Number(s));var a={16:"shift",17:"ctrl",18:"alt",91:"command"},f=function(){function r(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.element=t||window.document,this.emitter=new e,this.initialize(),this.registerEvent()}var s,f,c;return s=r,c=[{key:"of",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i(this,t)}}],(f=[{key:"initialize",value:function(){var e=this;this.status={},t.each(a,function(t,n){e.status[n]=!1,e.emitter.on("".concat(t,"down"),function(){e.status[n]||(e.status[n]=!0)}),e.emitter.on("".concat(t,"up"),function(){e.status[n]&&(e.status[n]=!1)})})}},{key:"registerEvent",value:function(){var e=this,t=function(t){return e.handler(t)};this.element.addEventListener("keydown",t),this.element.addEventListener("keyup",t)}},{key:"handler",value:function(e){var n=e.keyCode,r="keydown"===e.type?"down":"up",i="";if(93!==n&&224!==n||(n=91),n in a&&!1===this.emitter.emit(n+r))return!1;t.each(this.status,function(e,t){t&&(i+=e)});var u=i+n+r;u in this.emitter.listeners&&!1===this.emitter.emit(u)&&(e.preventDefault(),e.stopPropagation())}},{key:"on",value:function(e,t,n){return this.dispatch(!0,e,t,n)}},{key:"off",value:function(e,t,n){return this.dispatch(!1,e,t,n)}},{key:"dispatch",value:function(e,t,n,r){var i=this;return this.parseKeys(this.processKey(n)).forEach(function(n){var u=n.modifiers,o=n.keyCode,s="";if(null!==u)for(var f=0;f<u.length;f++)s+=a[u[f]];e?i.emitter.on(s+o+t,r):i.emitter.off(s+o+t,r)}),this}},{key:"parseKeys",value:function(e){var t=this,n=[];return e.map(function(e){var r={},i=null,u=(e=e.split("+")).length;return u>1&&(i=t.processModifiers(e),e=[e[u-1]]),e=t.getKeyCode(e[0]),r.modifiers=i,r.keyCode=e,n.push(r),e}),n}},{key:"processKey",value:function(e){var t=(e=e.toLowerCase().replace(/\s/g,"")).split(",");return""===t[t.length-1]&&(t[t.length-2]+=","),t}},{key:"processModifiers",value:function(e){for(var t=e.slice(0,e.length-1),n=0;n<t.length;n++)t[n]=o[t[n]];return t.sort(),t}},{key:"distribute",value:function(e,t,n){return null==n?this.off(e,t,n):this.on(e,t,n)}},{key:"getKeyName",value:function(e){return u[e]}},{key:"getKeyCode",value:function(e){return o[e]}},{key:"up",value:function(e,t){return this.distribute("up",e,t)}},{key:"down",value:function(e,t){return this.distribute("down",e,t)}}])&&n(s.prototype,f),c&&n(s,c),r}();return function(){return f.of.apply(f,arguments)}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@pluginjs/simple-emitter"),require("@pluginjs/utils")):"function"==typeof define&&define.amd?define(["@pluginjs/simple-emitter","@pluginjs/utils"],t):e["@pluginjs/keyboard"]=t(e["@pluginjs/simple-emitter"],e["@pluginjs/utils"])}(this,function(e,t){"use strict";function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t,n){return(i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var u=new(Function.bind.apply(e,i));return n&&r(u,n.prototype),u}).apply(null,arguments)}e=e&&e.hasOwnProperty("default")?e.default:e;var u={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"caps_lock",27:"esc",32:"space",33:"page_up",34:"page_down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"command",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"num_lock"},o={};for(var s in u)Object.prototype.hasOwnProperty.call(u,s)&&(o[u[s]]=Number(s));var a={16:"shift",17:"ctrl",18:"alt",91:"command"},f=function(){function r(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,r),this.element=t||window.document,this.emitter=new e,this.initialize(),this.registerEvent()}var s,f,c;return s=r,c=[{key:"of",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return i(this,t)}}],(f=[{key:"initialize",value:function(){var e=this;this.status={},t.each(a,function(t,n){e.status[n]=!1,e.emitter.on("".concat(t,"down"),function(){e.status[n]||(e.status[n]=!0)}),e.emitter.on("".concat(t,"up"),function(){e.status[n]&&(e.status[n]=!1)})})}},{key:"registerEvent",value:function(){var e=this,t=function(t){return e.handler(t)};this.element.addEventListener("keydown",t),this.element.addEventListener("keyup",t)}},{key:"handler",value:function(e){var n=e.keyCode,r="keydown"===e.type?"down":"up",i="";if((93!==n&&224!==n||(n=91),n in a)&&!1===this.emitter.emit(n+r))return!1;t.each(this.status,function(e,t){t&&(i+=e)});var u=i+n+r;u in this.emitter.listeners&&(!1===this.emitter.emit(u)&&(e.preventDefault(),e.stopPropagation()))}},{key:"on",value:function(e,t,n){return this.dispatch(!0,e,t,n)}},{key:"off",value:function(e,t,n){return this.dispatch(!1,e,t,n)}},{key:"dispatch",value:function(e,t,n,r){var i=this;return this.parseKeys(this.processKey(n)).forEach(function(n){var u=n.modifiers,o=n.keyCode,s="";if(null!==u)for(var f=0;f<u.length;f++)s+=a[u[f]];e?i.emitter.on(s+o+t,r):i.emitter.off(s+o+t,r)}),this}},{key:"parseKeys",value:function(e){var t=this,n=[];return e.map(function(e){var r={},i=null,u=(e=e.split("+")).length;return u>1&&(i=t.processModifiers(e),e=[e[u-1]]),e=t.getKeyCode(e[0]),r.modifiers=i,r.keyCode=e,n.push(r),e}),n}},{key:"processKey",value:function(e){var t=(e=e.toLowerCase().replace(/\s/g,"")).split(",");return""===t[t.length-1]&&(t[t.length-2]+=","),t}},{key:"processModifiers",value:function(e){for(var t=e.slice(0,e.length-1),n=0;n<t.length;n++)t[n]=o[t[n]];return t.sort(),t}},{key:"distribute",value:function(e,t,n){return null==n?this.off(e,t,n):this.on(e,t,n)}},{key:"getKeyName",value:function(e){return u[e]}},{key:"getKeyCode",value:function(e){return o[e]}},{key:"up",value:function(e,t){return this.distribute("up",e,t)}},{key:"down",value:function(e,t){return this.distribute("down",e,t)}}])&&n(s.prototype,f),c&&n(s,c),r}();return function(){return f.of.apply(f,arguments)}}); |
@@ -14,3 +14,3 @@ { | ||
}, | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"category": "core", | ||
@@ -33,14 +33,14 @@ "main": "dist/keyboard.common.js", | ||
"lint:js": "eslint ./src/**/*.js --fix", | ||
"prepublish": "npm run build", | ||
"prepublishOnly": "npm run build", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"@pluginjs/dom": "^0.7.0", | ||
"@pluginjs/simple-emitter": "^0.7.0", | ||
"@pluginjs/utils": "^0.7.0" | ||
"@pluginjs/dom": "^0.7.1", | ||
"@pluginjs/simple-emitter": "^0.7.1", | ||
"@pluginjs/utils": "^0.7.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.1.2", | ||
"@pluginjs/browserslist-config": "^1.2.0", | ||
"@pluginjs/cli": "^0.7.0", | ||
"@pluginjs/browserslist-config": "^1.2.1", | ||
"@pluginjs/cli": "^0.7.1", | ||
"babel-jest": "*", | ||
@@ -72,3 +72,3 @@ "jest": "*", | ||
"title": "Plugin", | ||
"gitHead": "966846899194272d4643d025f031e93f36670c63" | ||
"gitHead": "ddb86f691714a50df747dceda09ab3aa3aa83690" | ||
} |
51269
10
1416
Updated@pluginjs/dom@^0.7.1
Updated@pluginjs/utils@^0.7.1