mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-19 20:03:09 +08:00
fix(custom.js): fix examples code-folding issue...
The .JS code that hides the code blocks below each Emscripten LVGL example was lost when reliance on jQuery was removed. This commit adds that functionality back in. Transition of code appearing and disappearing is now instant, by design.
This commit is contained in:
committed by
Gabor Kiss-Vamosi
parent
ebcd244671
commit
706715f798
@@ -296,3 +296,34 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||
console.error("Fetch error: " + error.message);
|
||||
});
|
||||
});
|
||||
|
||||
/*---------------------------------------------------------------------
|
||||
* This listener adds a click handler to all .toggle elements.
|
||||
* When a .toggle is clicked, all children are hidden except .header.
|
||||
* When .header is clicked, all children are toggled.
|
||||
*---------------------------------------------------------------------*/
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.querySelectorAll(".toggle").forEach(function (toggle) {
|
||||
Array.from(toggle.children).forEach(function (child) {
|
||||
if (!child.classList.contains("header")) {
|
||||
child.style.display = "none";
|
||||
}
|
||||
});
|
||||
var header = toggle.querySelector(".header");
|
||||
if (header) {
|
||||
header.addEventListener("click", function (e) {
|
||||
const toggle = e.target.closest(".toggle");
|
||||
Array.from(toggle.children).forEach(function (child) {
|
||||
if (!child.classList.contains("header")) {
|
||||
if (child.style.display === "none") {
|
||||
child.style.display = "";
|
||||
} else {
|
||||
child.style.display = "none";
|
||||
}
|
||||
}
|
||||
});
|
||||
header.classList.toggle("open");
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user