diff --git a/UI/WebServerResources/js/Common/ui-desktop.js b/UI/WebServerResources/js/Common/ui-desktop.js index 529611c3c..d1fdf68a6 100644 --- a/UI/WebServerResources/js/Common/ui-desktop.js +++ b/UI/WebServerResources/js/Common/ui-desktop.js @@ -114,6 +114,28 @@ /* Factory registration in Angular module */ .factory('sgDialog', Dialog.$factory) + /** + * sgEnter - A directive evaluated when the enter key is pressed + * @memberof SOGo.UIDesktop + * @example: + + + */ + .directive('sgEnter', function() { + var ENTER_KEY = 13; + return function(scope, element, attrs) { + element.bind("keydown keypress", function(event) { + if (event.which === ENTER_KEY) { + scope.$apply(function() { + scope.$eval(attrs.sgEnter); + }); + event.preventDefault(); + } + }); + }; + }) + /** * sgEscape - A directive evaluated when the escape key is pressed * @memberof SOGo.UIDesktop @@ -125,7 +147,7 @@ .directive('sgEscape', function() { var ESCAPE_KEY = 27; return function(scope, elem, attrs) { - elem.bind('keydown', function (event) { + elem.bind('keydown', function(event) { if (event.keyCode === ESCAPE_KEY) { scope.$apply(attrs.sgEscape); }