@discourse/itsatrap
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -20,4 +20,4 @@ /*global define:false */ | ||
* | ||
* @version 1.6.5 | ||
* @url craig.is/killing/mice | ||
* @version 2.0.1 | ||
* @url github.com/discourse/itsatrap | ||
*/ | ||
@@ -1110,2 +1110,41 @@ (function(window, document, undefined) { | ||
var _globalCallbacks = {}; | ||
var _originalStopCallback = ItsATrap.prototype.stopCallback; | ||
ItsATrap.prototype.stopCallback = function(e, element, combo, sequence) { | ||
var self = this; | ||
if (self.paused) { | ||
return true; | ||
} | ||
if (_globalCallbacks[combo] || _globalCallbacks[sequence]) { | ||
return false; | ||
} | ||
return _originalStopCallback.call(self, e, element, combo); | ||
}; | ||
/** | ||
* adds a bindGlobal method to ItsATrap that allows you to | ||
* bind specific keyboard shortcuts that will still work | ||
* inside a text input field | ||
* | ||
* usage: | ||
* ItsATrap.bindGlobal('ctrl+s', _saveChanges); | ||
*/ | ||
ItsATrap.prototype.bindGlobal = function(keys, callback, action) { | ||
var self = this; | ||
self.bind(keys, callback, action); | ||
if (keys instanceof Array) { | ||
for (var i = 0; i < keys.length; i++) { | ||
_globalCallbacks[keys[i]] = true; | ||
} | ||
return; | ||
} | ||
_globalCallbacks[keys] = true; | ||
}; | ||
ItsATrap.init(); | ||
@@ -1112,0 +1151,0 @@ |
{ | ||
"name": "@discourse/itsatrap", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Fork of the original Mousetrap, Simple library for handling keyboard shortcuts", | ||
@@ -10,4 +10,3 @@ "main": "itsatrap.js", | ||
"scripts": { | ||
"test": "mocha --reporter=nyan tests/test.itsatrap.js", | ||
"build": "yarn run grunt --force " | ||
"test": "mocha --reporter=nyan tests/test.itsatrap.js" | ||
}, | ||
@@ -34,5 +33,4 @@ "repository": { | ||
"mocha": "^5.2.0", | ||
"sinon": "^7.2.2", | ||
"grunt-cli": "^1.4.3" | ||
"sinon": "^7.2.2" | ||
} | ||
} |
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
7
172994
8
2114