mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 15:24:43 +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>
|
<li class="divider-vertical"></li>
|
||||||
</ul>
|
</ul>
|
||||||
<form class="navbar-search pull-right" ng-submit="submit()">
|
<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="text"
|
||||||
<input type="hidden" name="as_sitesearch" value="angularjs.org">
|
name="as_q"
|
||||||
|
class="search-query"
|
||||||
|
placeholder="Search"
|
||||||
|
ng-change="search(q)"
|
||||||
|
ng-model="q"
|
||||||
|
docs-search-input
|
||||||
|
autocomplete="off" />
|
||||||
</form>
|
</form>
|
||||||
<div ng-show="hasResults" class="search-results">
|
<div ng-show="hasResults" class="search-results">
|
||||||
<a href="" ng-click="hideResults()" class="search-close">
|
<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() {
|
docsApp.directive.code = function() {
|
||||||
return { restrict:'E', terminal: true };
|
return { restrict:'E', terminal: true };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue