Skip to content
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

Fixes search window does not appear #2458

Merged
merged 19 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b858db5
- Changed LunrJs to MinisearchJs for client-side search
Hetarth02 Jul 5, 2023
34303e0
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl i…
Hetarth02 Jul 16, 2023
1fb8e07
- Updated the duplication issue
Hetarth02 Jul 16, 2023
724bd89
- Corrected typo
Hetarth02 Jul 16, 2023
bb1dbc4
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Aug 24, 2023
defe107
New Search Modal UI (#2202)
Hetarth02 Aug 24, 2023
f32d6de
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Aug 24, 2023
984ef8c
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Sep 26, 2023
149bdd0
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Oct 15, 2023
24d8a5f
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 4, 2023
60ca700
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 10, 2023
be00b02
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 13, 2023
b2feabd
Merge branch 'JuliaDocs:master' into master
Hetarth02 Nov 13, 2023
85828de
Merge branch 'JuliaDocs:master' into master
Hetarth02 Dec 10, 2023
e250ebb
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Jan 23, 2024
0bd65e2
Merge branch 'master' of https://github.com/Hetarth02/Documenter.jl
Hetarth02 Feb 20, 2024
cb09c65
- Added DOM content loaded check before the search modal
Hetarth02 Feb 20, 2024
89b01f3
- Updated CHANGELOG.md
Hetarth02 Feb 20, 2024
4b2e6a2
rephrase changelog
mortenpi Feb 21, 2024
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

* Fix search filter toggle button styling in the HTML output. ([#2406], [#2408])
* Fix the search filter toggle button styling in the HTML output. ([#2406], [#2408])
* The theme selector for the HTML output now correctly picks `Automatic (OS)` if the user hasn't explicitly set the theme. ([#2414], [#2438])
* Fix the search window sometimes not appearing in the HTML output. ([#2430], [#2458])

## Version [v1.2.1] - 2023-12-02

Expand Down Expand Up @@ -1795,7 +1796,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2408]: https://github.com/JuliaDocs/Documenter.jl/issues/2408
[#2414]: https://github.com/JuliaDocs/Documenter.jl/issues/2414
[#2415]: https://github.com/JuliaDocs/Documenter.jl/issues/2415
[#2430]: https://github.com/JuliaDocs/Documenter.jl/issues/2430
[#2438]: https://github.com/JuliaDocs/Documenter.jl/issues/2438
[#2458]: https://github.com/JuliaDocs/Documenter.jl/issues/2458
[JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953
[JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054
[JuliaLang/julia#39841]: https://github.com/JuliaLang/julia/issues/39841
Expand Down
168 changes: 86 additions & 82 deletions assets/html/js/shortcut.js
Original file line number Diff line number Diff line change
@@ -1,100 +1,104 @@
// libraries: jquery
// arguments: $

let search_modal_header = `
<header class="modal-card-head gap-2 is-align-items-center is-justify-content-space-between w-100 px-3">
<div class="field mb-0 w-100">
<p class="control has-icons-right">
<input class="input documenter-search-input" type="text" placeholder="Search" />
<span class="icon is-small is-right has-text-primary-dark">
<i class="fas fa-magnifying-glass"></i>
</span>
</p>
</div>
<div class="icon is-size-4 is-clickable close-search-modal">
<i class="fas fa-times"></i>
</div>
</header>
`;

let initial_search_body = `
<div class="has-text-centered my-5 py-5">Type something to get started!</div>
`;

let search_modal_footer = `
<footer class="modal-card-foot">
<span>
<kbd class="search-modal-key-hints">Ctrl</kbd> +
<kbd class="search-modal-key-hints">/</kbd> to search
</span>
<span class="ml-3"> <kbd class="search-modal-key-hints">esc</kbd> to close </span>
</footer>
`;

$(document.body).append(
`
<div class="modal" id="search-modal">
<div class="modal-background"></div>
<div class="modal-card search-min-width-50 search-min-height-100 is-justify-content-center">
${search_modal_header}
<section class="modal-card-body is-flex is-flex-direction-column is-justify-content-center gap-4 search-modal-card-body">
${initial_search_body}
</section>
${search_modal_footer}
$(document).ready(function () {
let search_modal_header = `
<header class="modal-card-head gap-2 is-align-items-center is-justify-content-space-between w-100 px-3">
<div class="field mb-0 w-100">
<p class="control has-icons-right">
<input class="input documenter-search-input" type="text" placeholder="Search" />
<span class="icon is-small is-right has-text-primary-dark">
<i class="fas fa-magnifying-glass"></i>
</span>
</p>
</div>
</div>
`
);
<div class="icon is-size-4 is-clickable close-search-modal">
<i class="fas fa-times"></i>
</div>
</header>
`;

document.querySelector(".docs-search-query").addEventListener("click", () => {
openModal();
});
let initial_search_body = `
<div class="has-text-centered my-5 py-5">Type something to get started!</div>
`;

document.querySelector(".close-search-modal").addEventListener("click", () => {
closeModal();
});
let search_modal_footer = `
<footer class="modal-card-foot">
<span>
<kbd class="search-modal-key-hints">Ctrl</kbd> +
<kbd class="search-modal-key-hints">/</kbd> to search
</span>
<span class="ml-3"> <kbd class="search-modal-key-hints">esc</kbd> to close </span>
</footer>
`;

$(document).on("click", ".search-result-link", function () {
closeModal();
});
$(document.body).append(
`
<div class="modal" id="search-modal">
<div class="modal-background"></div>
<div class="modal-card search-min-width-50 search-min-height-100 is-justify-content-center">
${search_modal_header}
<section class="modal-card-body is-flex is-flex-direction-column is-justify-content-center gap-4 search-modal-card-body">
${initial_search_body}
</section>
${search_modal_footer}
</div>
</div>
`
);

document.addEventListener("keydown", (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === "/") {
document.querySelector(".docs-search-query").addEventListener("click", () => {
openModal();
} else if (event.key === "Escape") {
closeModal();
}
});

return false;
});
document
.querySelector(".close-search-modal")
.addEventListener("click", () => {
closeModal();
});

// Functions to open and close a modal
function openModal() {
let searchModal = document.querySelector("#search-modal");
$(document).on("click", ".search-result-link", function () {
closeModal();
});

searchModal.classList.add("is-active");
document.querySelector(".documenter-search-input").focus();
}
document.addEventListener("keydown", (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === "/") {
openModal();
} else if (event.key === "Escape") {
closeModal();
}

function closeModal() {
let searchModal = document.querySelector("#search-modal");
let initial_search_body = `
<div class="has-text-centered my-5 py-5">Type something to get started!</div>
`;
return false;
});

searchModal.classList.remove("is-active");
document.querySelector(".documenter-search-input").blur();
// Functions to open and close a modal
function openModal() {
let searchModal = document.querySelector("#search-modal");

if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) {
$(".search-modal-card-body").addClass("is-justify-content-center");
searchModal.classList.add("is-active");
document.querySelector(".documenter-search-input").focus();
}

$(".documenter-search-input").val("");
$(".search-modal-card-body").html(initial_search_body);
}
function closeModal() {
let searchModal = document.querySelector("#search-modal");
let initial_search_body = `
<div class="has-text-centered my-5 py-5">Type something to get started!</div>
`;

document
.querySelector("#search-modal .modal-background")
.addEventListener("click", () => {
closeModal();
});
searchModal.classList.remove("is-active");
document.querySelector(".documenter-search-input").blur();

if (!$(".search-modal-card-body").hasClass("is-justify-content-center")) {
$(".search-modal-card-body").addClass("is-justify-content-center");
}

$(".documenter-search-input").val("");
$(".search-modal-card-body").html(initial_search_body);
}

document
.querySelector("#search-modal .modal-background")
.addEventListener("click", () => {
closeModal();
});
});
Loading