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

Fixed docstring collapse/expand icon not changing when clicking rapidly #2217

Merged
merged 16 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 15 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Version [v1.1.1] - 2023-10-12

### Fixed

* Fixed, docstring collapse/expand icon not changing correctly when clicking rapidly. ([#2103], [#2217])

## Version [v1.1.0] - 2023-09-28

### Added
Expand Down Expand Up @@ -1256,6 +1262,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[v0.27.25]: https://github.com/JuliaDocs/Documenter.jl/releases/tag/v0.27.25
[v1.0.0]: https://github.com/JuliaDocs/Documenter.jl/releases/tag/v1.0.0
[v1.0.1]: https://github.com/JuliaDocs/Documenter.jl/releases/tag/v1.0.1
[v1.1.0]: https://github.com/JuliaDocs/Documenter.jl/releases/tag/v1.1.0
[#198]: https://github.com/JuliaDocs/Documenter.jl/issues/198
[#245]: https://github.com/JuliaDocs/Documenter.jl/issues/245
[#487]: https://github.com/JuliaDocs/Documenter.jl/issues/487
Expand Down Expand Up @@ -1662,6 +1669,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2081]: https://github.com/JuliaDocs/Documenter.jl/issues/2081
[#2085]: https://github.com/JuliaDocs/Documenter.jl/issues/2085
[#2100]: https://github.com/JuliaDocs/Documenter.jl/issues/2100
[#2103]: https://github.com/JuliaDocs/Documenter.jl/issues/2103
mortenpi marked this conversation as resolved.
Show resolved Hide resolved
[#2128]: https://github.com/JuliaDocs/Documenter.jl/issues/2128
[#2130]: https://github.com/JuliaDocs/Documenter.jl/issues/2130
[#2134]: https://github.com/JuliaDocs/Documenter.jl/issues/2134
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Documenter"
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "1.1.0"
version = "1.1.1"

[deps]
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"
Expand Down
85 changes: 50 additions & 35 deletions assets/html/js/collapse.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,72 @@
// libraries: jquery
// arguments: $

let timer = 0;
var isExpanded = true;

$(document).on("click", ".docstring header", function () {
let articleToggleTitle = "Expand docstring";

if ($(this).siblings("section").is(":visible")) {
$(this)
.find(".docstring-article-toggle-button")
.removeClass("fa-chevron-down")
.addClass("fa-chevron-right");
} else {
$(this)
.find(".docstring-article-toggle-button")
.removeClass("fa-chevron-right")
.addClass("fa-chevron-down");
debounce(() => {
if ($(this).siblings("section").is(":visible")) {
$(this)
.find(".docstring-article-toggle-button")
.removeClass("fa-chevron-down")
.addClass("fa-chevron-right");
} else {
$(this)
.find(".docstring-article-toggle-button")
.removeClass("fa-chevron-right")
.addClass("fa-chevron-down");

articleToggleTitle = "Collapse docstring";
}
articleToggleTitle = "Collapse docstring";
}

$(this)
.find(".docstring-article-toggle-button")
.prop("title", articleToggleTitle);
$(this).siblings("section").slideToggle();
$(this)
.find(".docstring-article-toggle-button")
.prop("title", articleToggleTitle);
$(this).siblings("section").slideToggle();
});
});

$(document).on("click", ".docs-article-toggle-button", function () {
let articleToggleTitle = "Expand docstring";
let navArticleToggleTitle = "Expand all docstrings";

if (isExpanded) {
$(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
$(".docstring-article-toggle-button")
.removeClass("fa-chevron-down")
.addClass("fa-chevron-right");
debounce(() => {
if (isExpanded) {
$(this).removeClass("fa-chevron-up").addClass("fa-chevron-down");
$(".docstring-article-toggle-button")
.removeClass("fa-chevron-down")
.addClass("fa-chevron-right");

isExpanded = false;
isExpanded = false;

$(".docstring section").slideUp();
} else {
$(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
$(".docstring-article-toggle-button")
.removeClass("fa-chevron-right")
.addClass("fa-chevron-down");
$(".docstring section").slideUp();
} else {
$(this).removeClass("fa-chevron-down").addClass("fa-chevron-up");
$(".docstring-article-toggle-button")
.removeClass("fa-chevron-right")
.addClass("fa-chevron-down");

isExpanded = true;
articleToggleTitle = "Collapse docstring";
navArticleToggleTitle = "Collapse all docstrings";
isExpanded = true;
articleToggleTitle = "Collapse docstring";
navArticleToggleTitle = "Collapse all docstrings";

$(".docstring section").slideDown();
}
$(".docstring section").slideDown();
}

$(this).prop("title", navArticleToggleTitle);
$(".docstring-article-toggle-button").prop("title", articleToggleTitle);
$(this).prop("title", navArticleToggleTitle);
$(".docstring-article-toggle-button").prop("title", articleToggleTitle);
});
});

function debounce(callback, timeout = 300) {
if (Date.now() - timer > timeout) {
callback();
}

clearTimeout(timer);

timer = Date.now();
}
54 changes: 54 additions & 0 deletions assets/html/scss/documenter-dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,58 @@ html.theme--#{$themename} {
.hljs-subst {
color: #f8f8f2;
}

.search-result-link {
border-radius: 0.7em;
transition: all 300ms;
}

.search-result-link:hover, .search-result-link:focus {
background-color: rgba(0, 128, 128, 0.1);
}

.search-result-link .property-search-result-badge {
transition: all 300ms;
}

.search-result-link:hover .property-search-result-badge, .search-result-link:focus .property-search-result-badge {
color: #333 !important;
background-color: #f1f5f9 !important;
}

.property-search-result-badge {
padding: 0.15em 0.5em;
font-size: 0.8em;
font-style: italic;
text-transform: none !important;
line-height: 1.5;
color: whitesmoke;
background-color: #33415580;
border-radius: 0.6rem;
}

.search-result-title {
color: whitesmoke;
}

.search-result-highlight {
background-color: greenyellow;
color: black;
}

.search-divider {
border-bottom: 1px solid #5e6d6f50
}

.w-100 {
width: 100%;
}

.gap-2 {
gap: 0.5rem;
}

.gap-4 {
gap: 1rem;
}
}
4 changes: 4 additions & 0 deletions assets/html/scss/documenter-light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ code.language-julia-repl > span.hljs-meta {
// Workaround to compile in highlightjs theme, so that we could have different
// themes for both
@import "highlightjs/default";

.gap-4 {
gap: 1rem;
}
2 changes: 1 addition & 1 deletion assets/html/themes/documenter-dark.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/html/themes/documenter-light.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading