Skip to content

fixes #28696 #28725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,22 @@
return "\u2212"; // "\u2212" is '−' minus sign
}

$(".search-input").on("keyup",function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move content of the handler into the already existing handler (near the top of function startSearch).

if ($(this).val().length === 0) {
window.history.pushState("", "std - Rust", "?search=");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either use replaceState, or ensure that we only push at most 1 instance of this. Otherwise we just mess up the browser’s history stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the advice @nagisa I am going to change that

$('#main.content').removeClass('hidden');
$('#search.content').addClass('hidden');
}
});

$('.search-input').on('search', function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, also, search event is webkit (safari, epiphany) specific. It is not standard, nor it is supported widely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added search for webkit for ("X") in chrome... or maybe remove X in chrome... what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use a standard event (input should do), like in this PR.

if ($(this).val().length === 0) {
window.history.pushState("", "std - Rust", "?search=");
$('#main.content').removeClass('hidden');
$('#search.content').addClass('hidden');
}
});

$("#toggle-all-docs").on("click", function() {
var toggle = $("#toggle-all-docs");
if (toggle.hasClass("will-expand")) {
Expand Down