mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
chore(ngdocs): allow user to press escape key to close docs search
This commit is contained in:
parent
0cac8729fb
commit
cec4ce28b9
2 changed files with 23 additions and 2 deletions
|
|
@ -173,8 +173,14 @@
|
|||
<li class="divider-vertical"></li>
|
||||
</ul>
|
||||
<form class="navbar-search pull-right" ng-submit="submit()">
|
||||
<input type="text" name="as_q" class="search-query" placeholder="Search" ng-change="search(q)" ng-model="q" autocomplete="off">
|
||||
<input type="hidden" name="as_sitesearch" value="angularjs.org">
|
||||
<input type="text"
|
||||
name="as_q"
|
||||
class="search-query"
|
||||
placeholder="Search"
|
||||
ng-change="search(q)"
|
||||
ng-model="q"
|
||||
docs-search-input
|
||||
autocomplete="off" />
|
||||
</form>
|
||||
<div ng-show="hasResults" class="search-results">
|
||||
<a href="" ng-click="hideResults()" class="search-close">
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
|
|
|
|||
Loading…
Reference in a new issue