Rollup merge of #92735 - GuillaumeGomez:crate-filter-url-param, r=jsha
Add crate filter parameter in URL Fixes #92621. r? `@jsha`
This commit is contained in:
commit
f2721fab23
7 changed files with 140 additions and 58 deletions
|
@ -54,7 +54,6 @@ function resourcePath(basename, extension) {
|
|||
return getVar("root-path") + basename + getVar("resource-suffix") + extension;
|
||||
}
|
||||
|
||||
|
||||
(function () {
|
||||
window.rootPath = getVar("root-path");
|
||||
window.currentCrate = getVar("current-crate");
|
||||
|
@ -232,7 +231,7 @@ function hideThemeButtonState() {
|
|||
document.title = searchState.titleBeforeSearch;
|
||||
// We also remove the query parameter from the URL.
|
||||
if (searchState.browserSupportsHistoryApi()) {
|
||||
history.replaceState("", window.currentCrate + " - Rust",
|
||||
history.replaceState(null, window.currentCrate + " - Rust",
|
||||
getNakedUrl() + window.location.hash);
|
||||
}
|
||||
},
|
||||
|
@ -246,18 +245,6 @@ function hideThemeButtonState() {
|
|||
});
|
||||
return params;
|
||||
},
|
||||
putBackSearch: function(search_input) {
|
||||
var search = searchState.outputElement();
|
||||
if (search_input.value !== "" && hasClass(search, "hidden")) {
|
||||
searchState.showResults(search);
|
||||
if (searchState.browserSupportsHistoryApi()) {
|
||||
var extra = "?search=" + encodeURIComponent(search_input.value);
|
||||
history.replaceState(search_input.value, "",
|
||||
getNakedUrl() + extra + window.location.hash);
|
||||
}
|
||||
document.title = searchState.title;
|
||||
}
|
||||
},
|
||||
browserSupportsHistoryApi: function() {
|
||||
return window.history && typeof window.history.pushState === "function";
|
||||
},
|
||||
|
@ -282,14 +269,10 @@ function hideThemeButtonState() {
|
|||
}
|
||||
|
||||
search_input.addEventListener("focus", function() {
|
||||
searchState.putBackSearch(this);
|
||||
search_input.origPlaceholder = searchState.input.placeholder;
|
||||
search_input.origPlaceholder = search_input.placeholder;
|
||||
search_input.placeholder = "Type your search here.";
|
||||
loadSearch();
|
||||
});
|
||||
search_input.addEventListener("blur", function() {
|
||||
search_input.placeholder = searchState.input.origPlaceholder;
|
||||
});
|
||||
|
||||
if (search_input.value != '') {
|
||||
loadSearch();
|
||||
|
@ -330,7 +313,7 @@ function hideThemeButtonState() {
|
|||
var hash = ev.newURL.slice(ev.newURL.indexOf("#") + 1);
|
||||
if (searchState.browserSupportsHistoryApi()) {
|
||||
// `window.location.search`` contains all the query parameters, not just `search`.
|
||||
history.replaceState(hash, "",
|
||||
history.replaceState(null, "",
|
||||
getNakedUrl() + window.location.search + "#" + hash);
|
||||
}
|
||||
elem = document.getElementById(hash);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue