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

Fix: Keep cursor in search box after applying filter #2609

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*.jl.*.cov
*.jl.mem
Manifest.toml
node_modules/


test/doctests/builds/
test/examples/builds/
Expand Down
10 changes: 9 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"tabWidth": 2
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"useTabs": false,
"printWidth": 80,
"endOfLine": "lf"
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

* `deploydocs` now ignores any global GPG signing Git settings (i.e. `commit.gpgSign = false`). ([#2592])
## [Unreleased]

### Fixed
- Fixed an issue where the cursor would be removed from the search box after applying filters.

### Fixed

Expand Down
62 changes: 31 additions & 31 deletions assets/html/js/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,65 +5,65 @@ let timer = 0;
var isExpanded = true;

$(document).on(
"click",
".docstring .docstring-article-toggle-button",
'click',
'.docstring .docstring-article-toggle-button',
function () {
let articleToggleTitle = "Expand docstring";
let articleToggleTitle = 'Expand docstring';
const parent = $(this).parent();

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

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

parent
.children(".docstring-article-toggle-button")
.prop("title", articleToggleTitle);
parent.siblings("section").slideToggle();
.children('.docstring-article-toggle-button')
.prop('title', articleToggleTitle);
parent.siblings('section').slideToggle();
});
}
);

$(document).on("click", ".docs-article-toggle-button", function (event) {
let articleToggleTitle = "Expand docstring";
let navArticleToggleTitle = "Expand all docstrings";
$(document).on('click', '.docs-article-toggle-button', function (event) {
let articleToggleTitle = 'Expand docstring';
let navArticleToggleTitle = 'Expand all docstrings';
let animationSpeed = event.noToggleAnimation ? 0 : 400;

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

isExpanded = false;

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

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

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

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

Expand Down
34 changes: 17 additions & 17 deletions assets/html/js/copy.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
function addCopyButtonCallbacks() {
for (const el of document.getElementsByTagName("pre")) {
const button = document.createElement("button");
button.classList.add("copy-button", "fa-solid", "fa-copy");
button.setAttribute("aria-label", "Copy this code block");
button.setAttribute("title", "Copy");
for (const el of document.getElementsByTagName('pre')) {
const button = document.createElement('button');
button.classList.add('copy-button', 'fa-solid', 'fa-copy');
button.setAttribute('aria-label', 'Copy this code block');
button.setAttribute('title', 'Copy');

el.appendChild(button);

const success = function () {
button.classList.add("success", "fa-check");
button.classList.remove("fa-copy");
button.classList.add('success', 'fa-check');
button.classList.remove('fa-copy');
};

const failure = function () {
button.classList.add("error", "fa-xmark");
button.classList.remove("fa-copy");
button.classList.add('error', 'fa-xmark');
button.classList.remove('fa-copy');
};

button.addEventListener("click", function () {
button.addEventListener('click', function () {
copyToClipboard(el.innerText).then(success, failure);

setTimeout(function () {
button.classList.add("fa-copy");
button.classList.remove("success", "fa-check", "fa-xmark");
button.classList.add('fa-copy');
button.classList.remove('success', 'fa-check', 'fa-xmark');
}, 5000);
});
}
Expand All @@ -35,13 +35,13 @@ function copyToClipboard(text) {
} else {
return new Promise(function (resolve, reject) {
try {
const el = document.createElement("textarea");
const el = document.createElement('textarea');
el.textContent = text;
el.style.position = "fixed";
el.style.position = 'fixed';
el.style.opacity = 0;
document.body.appendChild(el);
el.select();
document.execCommand("copy");
document.execCommand('copy');

resolve();
} catch (err) {
Expand All @@ -53,8 +53,8 @@ function copyToClipboard(text) {
}
}

if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", addCopyButtonCallbacks);
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', addCopyButtonCallbacks);
} else {
addCopyButtonCallbacks();
}
2 changes: 1 addition & 1 deletion assets/html/js/headroom.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// mobile).
window.Headroom = Headroom; // work around buggy module loading?
$(document).ready(function () {
$("#documenter .docs-navbar").headroom({
$('#documenter .docs-navbar').headroom({
tolerance: { up: 10, down: 10 },
});
});
6 changes: 3 additions & 3 deletions assets/html/js/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// arguments: $

$(document).ready(function () {
let meta = $("div[data-docstringscollapsed]").data();
let meta = $('div[data-docstringscollapsed]').data();

if (meta?.docstringscollapsed) {
$("#documenter-article-toggle-button").trigger({
type: "click",
$('#documenter-article-toggle-button').trigger({
type: 'click',
noToggleAnimation: true,
});
}
Expand Down
28 changes: 28 additions & 0 deletions assets/html/js/package-lock.json

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

5 changes: 5 additions & 0 deletions assets/html/js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"prettier": "^3.3.3"
}
}
Loading
Loading