Hide the search bar when pressing ESC key

This commit is contained in:
Samy Pessé
2014-04-06 16:02:43 -07:00
parent b598c9a272
commit ff52a2317b
2 changed files with 17 additions and 5 deletions
+16 -4
View File
@@ -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 {