summaryrefslogtreecommitdiffstats
path: root/theme/javascript/core
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-04-06 16:02:43 -0700
committerSamy Pessé <samypesse@gmail.com>2014-04-06 16:02:43 -0700
commitff52a2317b435d778fce232527b6a4b968a178ff (patch)
treebbd0a7280bda55522e0fd119ca7052765a2b2553 /theme/javascript/core
parentb598c9a272ea12b17a186f1c45393ea2c87921e4 (diff)
downloadgitbook-ff52a2317b435d778fce232527b6a4b968a178ff.zip
gitbook-ff52a2317b435d778fce232527b6a4b968a178ff.tar.gz
gitbook-ff52a2317b435d778fce232527b6a4b968a178ff.tar.bz2
Hide the search bar when pressing ESC key
Diffstat (limited to 'theme/javascript/core')
-rw-r--r--theme/javascript/core/sidebar.js20
1 files changed, 16 insertions, 4 deletions
diff --git a/theme/javascript/core/sidebar.js b/theme/javascript/core/sidebar.js
index 5529be4..27a0abd 100644
--- a/theme/javascript/core/sidebar.js
+++ b/theme/javascript/core/sidebar.js
@@ -48,16 +48,28 @@ define([
toggleSidebar();
});
+ // Init last state if not mobile
+ if (!platform.isMobile) {
+ toggleSidebar(storage.get("sidebar", true), false);
+ }
+
// Toggle search
$book.find(".book-header .toggle-search").click(function(e) {
e.preventDefault();
toggleSearch();
});
- // Init last state if not mobile
- if (!platform.isMobile) {
- toggleSidebar(storage.get("sidebar", true), false);
- }
+ $book.find(".book-summary .book-search input").keyup(function(e) {
+ var key = (e.keyCode ? e.keyCode : e.which);
+ var q = $(this).val();
+
+ if (key == 27) {
+ e.preventDefault();
+ toggleSearch(false);
+ return;
+ }
+ console.log("search", q);
+ });
};
return {