Davide Alberani 9 роки тому
батько
коміт
8faa198008
1 змінених файлів з 27 додано та 0 видалено
  1. 27 0
      angular_app/js/directives.js

+ 27 - 0
angular_app/js/directives.js

@@ -0,0 +1,27 @@
+'use strict';
+
+/* Directives for DOM manipulation and interaction. */
+
+/* Directive that can be used to make an input field react to the press of Enter. */
+eventManApp.directive('eventmanPressEnter', function () {
+    return function (scope, element, attrs) {
+        element.bind("keydown keypress", function (event) {
+            if(event.which === 13) {
+                scope.$apply(function (){
+                    scope.$eval(attrs.ngEnter);
+                });
+                event.preventDefault();
+            }
+        });
+    };
+});
+
+eventManApp.directive('eventmanFocus', function () {
+    function link(scope, element, attrs) {
+        element[0].focus();
+    };
+    return {
+        link: link
+    };
+});
+