Skip to content

Commit

Permalink
Merge pull request #9 from adampetrie/add-custom-scoping-to-shortcuts
Browse files Browse the repository at this point in the history
Allow scoped to be a selector and bind mousetrap to that selector instead of the current node.
  • Loading branch information
trym committed Dec 17, 2015
2 parents 5517b26 + acbac10 commit 3a18a1f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addon/create-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export default function(bindEvent, unbindEvent) {
if (actionObject.global === false) {
mousetrap = new Mousetrap(document);
} else if (actionObject.scoped) {
mousetrap = new Mousetrap(self.get('element'));
if (Ember.typeOf(actionObject.scoped) === 'boolean') {
mousetrap = new Mousetrap(self.get('element'));
} else if (Ember.typeOf(actionObject.scoped) === 'string') {
mousetrap = new Mousetrap(document.querySelector(actionObject.scoped));
}
} else if (actionObject.targetElement) {
mousetrap = new Mousetrap(actionObject.targetElement);
}
Expand Down

0 comments on commit 3a18a1f

Please sign in to comment.