diff options
Diffstat (limited to '')
-rw-r--r-- | third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/angularjs/js/directives/todoEscape.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/angularjs/js/directives/todoEscape.js b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/angularjs/js/directives/todoEscape.js new file mode 100644 index 0000000000..944b52c5f3 --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/angularjs/js/directives/todoEscape.js @@ -0,0 +1,24 @@ +/*global angular */ + +/** + * Directive that executes an expression when the element it is applied to gets + * an `escape` keydown event. + */ +angular.module('todomvc') + .directive('todoEscape', function () { + 'use strict'; + + var ESCAPE_KEY = 27; + + return function (scope, elem, attrs) { + elem.bind('keydown', function (event) { + if (event.keyCode === ESCAPE_KEY) { + scope.$apply(attrs.todoEscape); + } + }); + + scope.$on('$destroy', function () { + elem.unbind('keydown'); + }); + }; + }); |