AngularJS sgEscape directive for SOGo.UIDesktop

pull/91/head
Francis Lachapelle 2014-10-07 14:39:13 -04:00
parent 16628ab104
commit 4457997276
1 changed files with 16 additions and 1 deletions

View File

@ -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);
}
});
};
});
})();