From cec4ce28b93793caba75c7bab009d30bc97b6146 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Thu, 13 Jun 2013 22:30:11 -0400 Subject: chore(ngdocs): allow user to press escape key to close docs search --- docs/src/templates/js/docs.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'docs/src/templates/js/docs.js') diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index 2350e698..63ad31f4 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -138,6 +138,21 @@ docsApp.directive.focused = function($timeout) { }; }; +docsApp.directive.docsSearchInput = function() { + return function(scope, element, attrs) { + var ESCAPE_KEY_KEYCODE = 27; + element.bind('keydown', function(event) { + if(event.keyCode == ESCAPE_KEY_KEYCODE) { + event.stopPropagation(); + event.preventDefault(); + scope.$apply(function() { + scope.hideResults(); + }); + } + }); + }; +}; + docsApp.directive.code = function() { return { restrict:'E', terminal: true }; -- cgit v1.2.3