mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-19 09:06:03 +00:00
Fix #235: search after navigation to another page
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
});
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user