-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Documenter.jl
committed
Jun 29, 2023
1 parent
995edbc
commit f38cdd8
Showing
34 changed files
with
633 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Part of Documenter.jl | ||
* https://github.com/JuliaDocs/Documenter.jl | ||
* | ||
* License: MIT | ||
*/ | ||
|
||
// Libraries: jquery | ||
// Arguments: $ | ||
|
||
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"); | ||
|
||
articleToggleTitle = "Collapse docstring"; | ||
} | ||
|
||
$(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"); | ||
|
||
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"); | ||
|
||
isExpanded = true; | ||
articleToggleTitle = "Collapse docstring"; | ||
navArticleToggleTitle = "Collapse all docstrings"; | ||
|
||
$(".docstring section").slideDown(); | ||
} | ||
|
||
$(this).prop("title", navArticleToggleTitle); | ||
$(".docstring-article-toggle-button").prop("title", articleToggleTitle); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Part of Documenter.jl | ||
* https://github.com/JuliaDocs/Documenter.jl | ||
* | ||
* License: MIT | ||
*/ | ||
|
||
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"); | ||
|
||
el.appendChild(button); | ||
|
||
const success = function () { | ||
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.addEventListener("click", function () { | ||
copyToClipboard(el.innerText).then(success, failure); | ||
|
||
setTimeout(function () { | ||
button.classList.add("fa-copy"); | ||
button.classList.remove("success", "fa-check", "fa-xmark"); | ||
}, 5000); | ||
}); | ||
} | ||
} | ||
|
||
function copyToClipboard(text) { | ||
// Clipboard API is only available in secure contexts | ||
if (window.navigator && window.navigator.clipboard) { | ||
return window.navigator.clipboard.writeText(text); | ||
} else { | ||
return new Promise(function (resolve, reject) { | ||
try { | ||
const el = document.createElement("textarea"); | ||
el.textContent = text; | ||
el.style.position = "fixed"; | ||
el.style.opacity = 0; | ||
document.body.appendChild(el); | ||
el.select(); | ||
document.execCommand("copy"); | ||
|
||
resolve(); | ||
} catch (err) { | ||
reject(err); | ||
} finally { | ||
document.body.removeChild(el); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
if (document.readyState === "loading") { | ||
document.addEventListener("DOMContentLoaded", addCopyButtonCallbacks); | ||
} else { | ||
addCopyButtonCallbacks(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
Oops, something went wrong.