diff --git a/UI/WebServerResources/js/Common/ui-desktop.js b/UI/WebServerResources/js/Common/ui-desktop.js index 2d632d31c..c287c9a0c 100644 --- a/UI/WebServerResources/js/Common/ui-desktop.js +++ b/UI/WebServerResources/js/Common/ui-desktop.js @@ -112,5 +112,20 @@ angular.module('SOGo.UIDesktop', ['mm.foundation']) /* Factory registration in Angular module */ - .factory('sgDialog', Dialog.$factory); + .factory('sgDialog', Dialog.$factory) + + /** + * @desc A directive evaluated when the escape key is pressed. + */ + .directive('sgEscape', function() { + var ESCAPE_KEY = 27; + return function (scope, elem, attrs) { + elem.bind('keydown', function (event) { + if (event.keyCode === ESCAPE_KEY) { + scope.$apply(attrs.sgEscape); + } + }); + }; + }); + })();