diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-04-06 16:02:43 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-04-06 16:02:43 -0700 |
commit | ff52a2317b435d778fce232527b6a4b968a178ff (patch) | |
tree | bbd0a7280bda55522e0fd119ca7052765a2b2553 /theme/javascript/core | |
parent | b598c9a272ea12b17a186f1c45393ea2c87921e4 (diff) | |
download | gitbook-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.js | 20 |
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 { |