diff options
| author | Matias Niemelä | 2013-10-22 00:34:56 -0400 | 
|---|---|---|
| committer | Matias Niemelä | 2013-10-22 21:23:59 -0400 | 
| commit | 74912802c644ca929e39a7583cb7a9a05f12e91f (patch) | |
| tree | fce7bccc924024824ec0c776dba3e19b5321ddf2 /docs/src/templates/js/docs.js | |
| parent | 6c20ec193f11aa647be1b2ad2ac5b3e7c2894bd7 (diff) | |
| download | angular.js-74912802c644ca929e39a7583cb7a9a05f12e91f.tar.bz2 | |
feat(ngdocs): add forward slash shortcut key for search bar
Diffstat (limited to 'docs/src/templates/js/docs.js')
| -rw-r--r-- | docs/src/templates/js/docs.js | 16 | 
1 files changed, 13 insertions, 3 deletions
| 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() { | 
