From ff38e76f96b94e1233119ea8d6113fa2ec17993c Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 7 Oct 2014 14:39:13 -0400 Subject: [PATCH] AngularJS sgEscape directive for SOGo.UIDesktop --- UI/WebServerResources/js/Common/ui-desktop.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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); + } + }); + }; + }); + })();