mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-22 19:23:38 +08:00
chore(ngdocs): allow user to press escape key to close docs search
This commit is contained in:
committed by
Misko Hevery
parent
0cac8729fb
commit
cec4ce28b9
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user