Fix #235: search after navigation to another page

This commit is contained in:
Samy Pessé
2014-05-23 22:28:36 +02:00
parent 96bcfa4e20
commit 6340a64cff
4 changed files with 11 additions and 18 deletions
+1 -5
View File
@@ -3,12 +3,11 @@ define([
"utils/url",
"core/events",
"core/state",
"core/search",
"core/progress",
"core/exercise",
"core/quiz",
"core/loading"
], function($, URL, events, state, search, progress, exercises, quiz, loading) {
], function($, URL, events, state, progress, exercises, quiz, loading) {
var prev, next;
var githubCountStars, githubCountWatch;
@@ -96,9 +95,6 @@ define([
// Focus on content
$pageWrapper.focus();
// Prepare search bar
search.prepare();
// Update GitHub count
if (state.githubId) {
if (githubCountStars) {
+5 -8
View File
@@ -67,12 +67,10 @@ define([
e.preventDefault();
toggleSearch();
});
};
var prepare = function() {
var $searchInput = $(".book-search input");
$searchInput.keyup(function(e) {
// Type in search bar
$(document).on("keyup", ".book-search input", function(e) {
var key = (e.keyCode ? e.keyCode : e.which);
var q = $(this).val();
@@ -89,13 +87,12 @@ define([
_.pluck(results, "path")
);
}
});
}
})
};
return {
init: init,
search: search,
toggle: toggleSearch,
prepare: prepare
toggle: toggleSearch
};
});
+4 -4
View File
@@ -1,11 +1,10 @@
define([
"jQuery",
"lodash",
"utils/storage",
"utils/platform",
"core/state"
], function(_, storage, platform, state) {
var $summary = state.$book.find(".book-summary");
], function($, _, storage, platform, state) {
// Toggle sidebar with or withour animation
var toggleSidebar = function(_state, animation) {
if (state != null && isOpen() == _state) return;
@@ -38,6 +37,8 @@ define([
// Filter summary with a list of path
var filterSummary = function(paths) {
var $summary = $(".book-summary");
$summary.find("li").each(function() {
var path = $(this).data("path");
var st = paths == null || _.contains(paths, path);
@@ -48,7 +49,6 @@ define([
};
return {
$el: $summary,
init: init,
toggle: toggleSidebar,
filter: filterSummary