combokeys-context
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "combokeys-context", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Tim Oram <mitmaro@gmail.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [], |
# ComboKeys Context | ||
[](https://david-dm.org/MitMaro/combokeys-context) | ||
[](https://travis-ci.org/MitMaro/combokeys-context) | ||
[](https://travis-ci.org/MitMaro/combokeys-context) | ||
[](https://coveralls.io/r/MitMaro/combokeys-context?branch=master) | ||
@@ -15,2 +15,6 @@ | ||
## Install | ||
npm install combokeys-context | ||
## Documentation | ||
@@ -20,3 +24,3 @@ | ||
``` | ||
```javascript | ||
var ComboKeys = require('combokeys'); | ||
@@ -68,4 +72,4 @@ var ComboKeysContext = require('combokeys-context'); | ||
##License | ||
## License | ||
Combokeys Context is released under the MIT license. See LICENSE. |
var isArray = require('./util/isArray'); | ||
function wrapHandler(key, evt, combo) { | ||
if (this._context) { | ||
if (this._context && this._bindings[key].contexts[this._context]) { | ||
this._bindings[key].contexts[this._context].call(this._comboKeys, evt, combo); | ||
} else { | ||
} else if (this._bindings[key].global) { | ||
this._bindings[key].global.call(this._comboKeys, evt, combo); | ||
@@ -8,0 +8,0 @@ } |
@@ -436,3 +436,24 @@ | ||
}); | ||
it('calls function in global scope without global scope registered', function() { | ||
var contextCallback = sinon.stub(); | ||
var evt = 'my event'; | ||
var key = 'a'; | ||
context._register(key, 'A', contextCallback); | ||
context._bindings[key].handler(evt, key); | ||
expect(contextCallback).to.not.be.called; | ||
}); | ||
it('calls function in scope without scope registered', function() { | ||
var globalCallback = sinon.stub(); | ||
var evt = 'my event'; | ||
var key = 'a'; | ||
context._register(key, null, globalCallback); | ||
context._context = 'A'; | ||
context._bindings[key].handler(evt, key); | ||
expect(globalCallback).to.be.calledWith(evt, key); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
69565
34
651
73