mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-20 00:10:26 +00:00
feat(ngdocs): add forward slash shortcut key for search bar
This commit is contained in:
parent
6c20ec193f
commit
74912802c6
2 changed files with 16 additions and 6 deletions
|
|
@ -198,15 +198,15 @@
|
|||
autocomplete="off" />
|
||||
</form>
|
||||
<div ng-show="hasResults" class="search-results">
|
||||
<a href="" ng-click="hideResults()" class="search-close">
|
||||
<span class="icon-remove-sign"></span>
|
||||
</a>
|
||||
<div ng-repeat="(key, value) in results" class="search-group" ng-class="colClassName">
|
||||
<h4>{{ key }}</h4>
|
||||
<div ng-repeat="item in value" class="search-result">
|
||||
<a ng-click="hideResults()" href="{{ item.url }}">{{ item.shortName }}</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="" ng-click="hideResults()" class="search-close">
|
||||
<span class="icon-remove-sign"></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue