Comparing version 1.1.3 to 1.2.0
@@ -6,6 +6,6 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
define([], factory); | ||
else { | ||
var a = factory(); | ||
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; | ||
} | ||
else if(typeof exports === 'object') | ||
exports["keybinder"] = factory(); | ||
else | ||
root["keybinder"] = factory(); | ||
})(this, function() { | ||
@@ -12,0 +12,0 @@ return /******/ (function(modules) { // webpackBootstrap |
@@ -1,147 +0,2 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else { | ||
var a = factory(); | ||
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; | ||
} | ||
})(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"; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Keybinder = function () { | ||
function Keybinder(selector) { | ||
var _this = this; | ||
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
var callback = arguments[2]; | ||
_classCallCheck(this, Keybinder); | ||
if (typeof selector !== 'string' || selector === 'undefined' || selector.length < 1) { | ||
return "selector error"; | ||
} | ||
// check if the callback is valid | ||
if (typeof callback !== 'function' || callback === 'undefined') { | ||
return "Callback error"; | ||
} | ||
this.document = document; | ||
// if everything works out with the selector, continue | ||
this.tag = this.document.querySelector(selector); | ||
// specify callback | ||
this.callback = callback.bind(this.tag); | ||
this.log = {}; | ||
this.keys = {}; | ||
var x = this.keys; | ||
// create keys object | ||
keys.map(function (v) { | ||
x[v.toLowerCase()] = 1; | ||
return; | ||
}); | ||
// add event listener to element | ||
if (this.document.addEventListener) { | ||
this.tag.addEventListener("keydown", this.cbHandler.bind(this)); | ||
this.tag.addEventListener("keyup", this.rmkey.bind(this)); | ||
// add event listener for when out of focus | ||
this.tag.addEventListener("blur", function () { | ||
_this.log = {}; | ||
}); | ||
} | ||
} | ||
// callback handler function | ||
_createClass(Keybinder, [{ | ||
key: 'cbHandler', | ||
value: function cbHandler(e) { | ||
var key = e.key.toLowerCase(); | ||
this.log[key] = 1; | ||
if (JSON.stringify(this.log) == JSON.stringify(this.keys)) { | ||
e.preventDefault(); | ||
this.callback(); | ||
} | ||
} | ||
}, { | ||
key: 'rmkey', | ||
value: function rmkey(e) { | ||
var key = e.key; | ||
delete this.log[key.toLowerCase()]; | ||
} | ||
}]); | ||
return Keybinder; | ||
}(); | ||
var keybinder = function keybinder() { | ||
return new Keybinder(arguments[0], arguments[1], arguments[2]); | ||
}; | ||
module.exports = keybinder; | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.keybinder=t():e.keybinder=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(t){var r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments[2];if(n(this,e),"string"!=typeof t||"undefined"===t||t.length<1)return"selector error";if("function"!=typeof o||"undefined"===o)return"Callback error";this.document=document,this.tag=this.document.querySelector(t),this.callback=o.bind(this.tag),this.log={},this.keys={};var s=this.keys;i.map(function(e){s[e.toLowerCase()]=1}),this.document.addEventListener&&(this.tag.addEventListener("keydown",this.cbHandler.bind(this)),this.tag.addEventListener("keyup",this.rmkey.bind(this)),this.tag.addEventListener("blur",function(){r.log={}}))}return r(e,[{key:"cbHandler",value:function(e){var t=e.key.toLowerCase();this.log[t]=1,JSON.stringify(this.log)==JSON.stringify(this.keys)&&(e.preventDefault(),this.callback())}},{key:"rmkey",value:function(e){var t=e.key;delete this.log[t.toLowerCase()]}}]),e}(),o=function(){return new i(arguments[0],arguments[1],arguments[2])};e.exports=o}])}); | ||
//# sourceMappingURL=keybinder.min.js.map |
{ | ||
"name": "keybinder", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Javascript keybinder", | ||
@@ -5,0 +5,0 @@ "main": "build/keybinder.min.js", |
@@ -7,11 +7,18 @@ const path = require('path'); | ||
const WebpackBrowserPlugin = require('webpack-browser-plugin'); | ||
console.log(PROD); | ||
// const WebpackBrowserPlugin = require('webpack-browser-plugin'); | ||
// plugins.push( | ||
// new WebpackBrowserPlugin({ | ||
// browser: "Chrome" | ||
// }) | ||
// ) | ||
let plugins = []; | ||
PROD ? [ | ||
plugins.push(new webpack.optimize.UglifyJsPlugin({ | ||
PROD ? plugins.push(new webpack.optimize.UglifyJsPlugin({ | ||
compress: { warnings: false } | ||
})) | ||
] : ''; | ||
: '' ; | ||
@@ -24,2 +31,3 @@ module.exports = { | ||
filename: PROD ? "build/keybinder.min.js" : "build/keybinder.js", | ||
library: "keybinder", | ||
libraryTarget: "umd" | ||
@@ -39,7 +47,3 @@ }, | ||
}, | ||
plugins: plugins.push( | ||
new WebpackBrowserPlugin({ | ||
browser: "Chrome" | ||
}) | ||
) | ||
plugins: plugins | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
149112
194