Skip to content

Commit

Permalink
Use keyCapture service in contextMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
LFDM committed Jun 19, 2014
1 parent 638b275 commit 61f0cfa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/js/arethusa.context_menu/directives/context_menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ angular.module('arethusa.contextMenu').factory('menuElement', function () {
'$document',
'$parse',
'menuElement',
function ($document, $parse, menuElement) {
'keyCapture',
function ($document, $parse, menuElement, keyCapture) {
return {
restrict: 'A',
scope: {
Expand Down Expand Up @@ -104,12 +105,13 @@ angular.module('arethusa.contextMenu').factory('menuElement', function () {

$document.bind('click', handleOtherClick);
$document.bind('contextmenu', handleOtherClick);
// Close when ESC is hit
$document.bind('keyup', function (event) {
if (opened && event.keyCode === 27) {

keyCapture.onKeyPressed(keyCapture.keyCodes.esc, function() {
if (opened) {
closeAndApply();
keyCapture.stopPropagation();
}
});
}, 1000);
}
};
}
Expand Down

0 comments on commit 61f0cfa

Please sign in to comment.