Skip to content

Commit

Permalink
Fix formatting issues in JS files using Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
vennelaeruvala committed Nov 15, 2024
1 parent 9db4769 commit 9e1b02f
Show file tree
Hide file tree
Showing 11 changed files with 293 additions and 285 deletions.
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"
}
64 changes: 32 additions & 32 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
Loading

0 comments on commit 9e1b02f

Please sign in to comment.