From 74912802c644ca929e39a7583cb7a9a05f12e91f Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Tue, 22 Oct 2013 00:34:56 -0400 Subject: feat(ngdocs): add forward slash shortcut key for search bar --- docs/src/templates/index.html | 6 +++--- docs/src/templates/js/docs.js | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'docs/src/templates') diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html index b40e9d31..3841846c 100644 --- a/docs/src/templates/index.html +++ b/docs/src/templates/index.html @@ -198,15 +198,15 @@ autocomplete="off" />
- - -

{{ key }}

+ + +
diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index beec604b..fbabf193 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -132,9 +132,19 @@ docsApp.directive.focused = function($timeout) { }; }; -docsApp.directive.docsSearchInput = function() { +docsApp.directive.docsSearchInput = ['$document',function($document) { return function(scope, element, attrs) { - var ESCAPE_KEY_KEYCODE = 27; + var ESCAPE_KEY_KEYCODE = 27, + FORWARD_SLASH_KEYCODE = 191; + angular.element($document[0].body).bind('keydown', function(event) { + var input = element[0]; + if(event.keyCode == FORWARD_SLASH_KEYCODE && document.activeElement != input) { + event.stopPropagation(); + event.preventDefault(); + input.focus(); + } + }); + element.bind('keydown', function(event) { if(event.keyCode == ESCAPE_KEY_KEYCODE) { event.stopPropagation(); @@ -145,7 +155,7 @@ docsApp.directive.docsSearchInput = function() { } }); }; -}; +}]; docsApp.directive.code = function() { -- cgit v1.2.3