Skip to content

Commit

Permalink
Merge pull request #8 from karanjthakkar/master
Browse files Browse the repository at this point in the history
Removed usage of prototype extensions
  • Loading branch information
trym committed Dec 17, 2015
2 parents d52e551 + 532b5ff commit 5517b26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions addon/create-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function(bindEvent, unbindEvent) {

return Ember.Mixin.create({

bindShortcuts: function() {
bindShortcuts: Ember.on(bindEvent, function() {
var self = this;
var shortcuts = this.get('keyboardShortcuts');

Expand All @@ -19,17 +19,17 @@ export default function(bindEvent, unbindEvent) {
var mousetrap = new Mousetrap(document.body);
var preventDefault = true;

function invokeAction(action) {
function invokeAction(action, eventType) {
var type = Ember.typeOf(action);

if (type === 'string') {
mousetrap.bind(shortcut, function(){
self.send(action);
return preventDefault !== true;
});
}, eventType);
}
else if (type === 'function') {
mousetrap.bind(shortcut, action.bind(self));
mousetrap.bind(shortcut, action.bind(self), eventType);
}
else {
throw new Error('Invalid value for keyboard shortcut: ' + action);
Expand All @@ -49,7 +49,7 @@ export default function(bindEvent, unbindEvent) {
preventDefault = false;
}

invokeAction(actionObject.action);
invokeAction(actionObject.action, actionObject.eventType);
} else {
invokeAction(actionObject);
}
Expand All @@ -58,13 +58,13 @@ export default function(bindEvent, unbindEvent) {

});

}.on(bindEvent),
}),

unbindShortcuts: function() {
unbindShortcuts: Ember.on(unbindEvent, function() {
this.mousetraps.forEach(
(mousetrap) => mousetrap.reset()
);
}.on(unbindEvent)
})

});

Expand Down
2 changes: 1 addition & 1 deletion blueprints/ember-keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
normalizeEntityName: function() {},

afterInstall: function() {
return this.addBowerPackageToProject('mousetrap', '~1.5.2');
return this.addBowerPackageToProject('mousetrap', '~1.5.3');
}
};

0 comments on commit 5517b26

Please sign in to comment.