Reworked wedge element, Fixed code copy button, Silenced SplideJS error for now

Update composer.php, common.json, and 8 more files...
This commit is contained in:
2023-12-20 00:24:52 +01:00
parent 0f63ab3371
commit 44a05eb73a
10 changed files with 118 additions and 131 deletions

View File

@@ -1,7 +1,6 @@
// Highlights the code blocks when included on a page.
// This command is separated in its own file since highlight.js isn't on every page and because I can't use JS
// in a script element without using an external .js file.
Array.from(document.getElementsByClassName("code")).forEach(eCodeContainer => {
let language = null;
@@ -24,26 +23,33 @@ Array.from(document.getElementsByClassName("code")).forEach(eCodeContainer => {
// Adding the action to copy the code to elements with the "js-code-copy" class.
// The search works by searching the closest parent with the "code" class or that is a "code" element, and then
// reading each of its children with the "code-line" class.
Array.from(document.getElementsByClassName("js-code-copy")).forEach(eCodeCopyButton => {
let eParentCodeBlock = eCodeCopyButton;
document.addEventListener("DOMContentLoaded", () => {
//let codeCopyButtonCount = 0;
while(eParentCodeBlock != null &&!eParentCodeBlock.classList.contains("code") &&
eParentCodeBlock.nodeName.toLowerCase() !== "code") {
eParentCodeBlock = eParentCodeBlock.parentElement;
}
Array.from(document.getElementsByClassName("js-code-copy")).forEach(eCodeCopyButton => {
let eParentCodeBlock = eCodeCopyButton;
while(eParentCodeBlock != null &&!eParentCodeBlock.classList.contains("code") &&
eParentCodeBlock.nodeName.toLowerCase() !== "code") {
eParentCodeBlock = eParentCodeBlock.parentElement;
}
if(eParentCodeBlock != null) {
let code = "";
Array.from(eParentCodeBlock.children).forEach(eCodeLine => {
if(eCodeLine.classList.contains("code-line")) {
code += eCodeLine.textContent + "\n"
}
});
eCodeCopyButton.onclick = function() {
navigator.clipboard.writeText(code);
};
}
//codeCopyButtonCount++;
});
if(eParentCodeBlock != null) {
let code = "";
Array.from(eParentCodeBlock.children).forEach(eCodeLine => {
if(eCodeLine.classList.contains("code-line")) {
code += eCodeLine.textContent + "\n"
}
});
eCodeCopyButton.onclick = function() {
navigator.clipboard.writeText(code);
};
}
});
//console.debug("Added code copying to " + codeCopyButtonCount + " button(s)");
});

View File

@@ -1,14 +1,19 @@
// Creating the galleries with SplideJs
window.addEventListener('load', function() {
new Splide( '.splide', {
perPage: 2,
cover: true,
heightRatio: 0.4,
breakpoints: {
768: {
perPage: 1,
try {
new Splide( '.splide', {
perPage: 2,
cover: true,
heightRatio: 0.4,
breakpoints: {
768: {
perPage: 1,
},
},
},
} ).mount();
}).mount();
} catch(err) {
console.log("Unable to setup Splide !");
console.log(err);
}
});