mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-29 03:27:44 +00:00
Rollup merge of #28736 - nagisa:rustdocjsfix, r=alexcrichton
This commit is contained in:
commit
f368a18059
@ -133,7 +133,7 @@
|
|||||||
$(document).on("keypress", handleShortcut);
|
$(document).on("keypress", handleShortcut);
|
||||||
$(document).on("keydown", handleShortcut);
|
$(document).on("keydown", handleShortcut);
|
||||||
$(document).on("click", function(ev) {
|
$(document).on("click", function(ev) {
|
||||||
if (!$(e.target).closest("#help > div").length) {
|
if (!$(ev.target).closest("#help > div").length) {
|
||||||
$("#help").addClass("hidden");
|
$("#help").addClass("hidden");
|
||||||
$("body").removeClass("blur");
|
$("body").removeClass("blur");
|
||||||
}
|
}
|
||||||
@ -515,7 +515,6 @@
|
|||||||
var $active = $results.filter('.highlighted');
|
var $active = $results.filter('.highlighted');
|
||||||
|
|
||||||
if (e.which === 38) { // up
|
if (e.which === 38) { // up
|
||||||
e.preventDefault();
|
|
||||||
if (!$active.length || !$active.prev()) {
|
if (!$active.length || !$active.prev()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -523,7 +522,6 @@
|
|||||||
$active.prev().addClass('highlighted');
|
$active.prev().addClass('highlighted');
|
||||||
$active.removeClass('highlighted');
|
$active.removeClass('highlighted');
|
||||||
} else if (e.which === 40) { // down
|
} else if (e.which === 40) { // down
|
||||||
e.preventDefault();
|
|
||||||
if (!$active.length) {
|
if (!$active.length) {
|
||||||
$results.first().addClass('highlighted');
|
$results.first().addClass('highlighted');
|
||||||
} else if ($active.next().length) {
|
} else if ($active.next().length) {
|
||||||
@ -531,7 +529,6 @@
|
|||||||
$active.removeClass('highlighted');
|
$active.removeClass('highlighted');
|
||||||
}
|
}
|
||||||
} else if (e.which === 13) { // return
|
} else if (e.which === 13) { // return
|
||||||
e.preventDefault();
|
|
||||||
if ($active.length) {
|
if ($active.length) {
|
||||||
document.location.href = $active.find('a').prop('href');
|
document.location.href = $active.find('a').prop('href');
|
||||||
}
|
}
|
||||||
@ -722,20 +719,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startSearch() {
|
function startSearch() {
|
||||||
|
var searchTimeout;
|
||||||
$(".search-input").on("keyup",function() {
|
$(".search-input").on("keyup input",function() {
|
||||||
|
clearTimeout(searchTimeout);
|
||||||
if ($(this).val().length === 0) {
|
if ($(this).val().length === 0) {
|
||||||
window.history.replaceState("", "std - Rust", "?search=");
|
window.history.replaceState("", "std - Rust", "?search=");
|
||||||
$('#main.content').removeClass('hidden');
|
$('#main.content').removeClass('hidden');
|
||||||
$('#search.content').addClass('hidden');
|
$('#search.content').addClass('hidden');
|
||||||
|
} else {
|
||||||
|
searchTimeout = setTimeout(search, 500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$('.search-form').on('submit', function(e){
|
||||||
var keyUpTimeout;
|
e.preventDefault();
|
||||||
$('.do-search').on('click', search);
|
clearTimeout(searchTimeout);
|
||||||
$('.search-input').on('keyup', function() {
|
search();
|
||||||
clearTimeout(keyUpTimeout);
|
});
|
||||||
keyUpTimeout = setTimeout(search, 500);
|
$('.search-input').on('change paste', function(e) {
|
||||||
|
// Do NOT e.preventDefault() here. It will prevent pasting.
|
||||||
|
clearTimeout(searchTimeout);
|
||||||
|
// zero-timeout necessary here because at the time of event handler execution the
|
||||||
|
// pasted content is not in the input field yet. Shouldn’t make any difference for
|
||||||
|
// change, though.
|
||||||
|
setTimeout(search, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Push and pop states are used to add search results to the browser
|
// Push and pop states are used to add search results to the browser
|
||||||
|
Loading…
Reference in New Issue
Block a user