aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorMatias Niemelä2013-06-13 22:30:11 -0400
committerMisko Hevery2013-06-17 21:23:22 -0700
commitcec4ce28b93793caba75c7bab009d30bc97b6146 (patch)
tree08169435a1da8da5a7eb3b7c6f1b7680d8fc29fe /docs
parent0cac8729fb3824ebb07cee84ef78b43900c7e75d (diff)
downloadangular.js-cec4ce28b93793caba75c7bab009d30bc97b6146.tar.bz2
chore(ngdocs): allow user to press escape key to close docs search
Diffstat (limited to 'docs')
-rw-r--r--docs/src/templates/index.html10
-rw-r--r--docs/src/templates/js/docs.js15
2 files changed, 23 insertions, 2 deletions
diff --git a/docs/src/templates/index.html b/docs/src/templates/index.html
index eec2e5a2..3b75207e 100644
--- a/docs/src/templates/index.html
+++ b/docs/src/templates/index.html
@@ -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">
diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js
index 2350e698..63ad31f4 100644
--- a/docs/src/templates/js/docs.js
+++ b/docs/src/templates/js/docs.js
@@ -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 };