mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-26 22:55:49 +00:00
Temporary: move static files into content
During migration, while we launch Redocly with -d content, the static files need to be in content. Eventually, when we stop using -d, we need to move the files again. Previously: /assets : static assets used by templates /img : images used in documentation (mostly) Now: /content/static : static assets used by templates /img : images used in documentation (mostly) Eventually: /static : static assets used by templates /docs/img : images used in documentation
This commit is contained in:
78
content/static/js/contribute-carousel.js
Normal file
78
content/static/js/contribute-carousel.js
Normal file
@@ -0,0 +1,78 @@
|
||||
let currentIndex = 1;
|
||||
|
||||
let isFirstLoad = true; // Add a flag to determine if it's the initial load
|
||||
|
||||
function updateCarousel() {
|
||||
const centerImage = document.getElementById("center-image");
|
||||
const leftImage = document.getElementById("left-image");
|
||||
const rightImage = document.getElementById("right-image");
|
||||
|
||||
if (!isFirstLoad) {
|
||||
// Only run the exit animation if it's not the first load
|
||||
centerImage.classList.add("exit");
|
||||
leftImage.classList.add("exit");
|
||||
rightImage.classList.add("exit");
|
||||
}
|
||||
|
||||
setTimeout(
|
||||
() => {
|
||||
if (events[currentIndex - 1]) {
|
||||
document.getElementById("prev-btn").style.opacity = 1;
|
||||
leftImage.style.visibility = "visible";
|
||||
leftImage.src = `assets/img/events/${events[currentIndex - 1].image}`;
|
||||
} else {
|
||||
document.getElementById("prev-btn").style.opacity = 0.5;
|
||||
leftImage.style.visibility = "hidden";
|
||||
}
|
||||
|
||||
centerImage.src = `assets/img/events/${events[currentIndex].image}`;
|
||||
centerImage.onclick = function() { // Add an onclick event to the main image
|
||||
window.open(events[currentIndex].link, '_blank'); // Open a new tab with the event link
|
||||
};
|
||||
|
||||
if (events[currentIndex + 1]) {
|
||||
document.getElementById("next-btn").style.opacity = 1;
|
||||
rightImage.style.visibility = "visible";
|
||||
rightImage.src = `assets/img/events/${events[currentIndex + 1].image}`;
|
||||
} else {
|
||||
document.getElementById("next-btn").style.opacity = 0.5;
|
||||
rightImage.style.visibility = "hidden";
|
||||
}
|
||||
|
||||
document.getElementById("event-name").textContent =
|
||||
events[currentIndex].name;
|
||||
document.getElementById("event-location").textContent =
|
||||
events[currentIndex].location;
|
||||
document.getElementById("event-date").textContent =
|
||||
events[currentIndex].date;
|
||||
|
||||
if (!isFirstLoad) {
|
||||
// Only run the enter animation if it's not the first load
|
||||
centerImage.classList.remove("exit");
|
||||
leftImage.classList.remove("exit");
|
||||
rightImage.classList.remove("exit");
|
||||
}
|
||||
},
|
||||
isFirstLoad ? 0 : 700
|
||||
); // If it's the first load, update immediately; otherwise, wait for the transition
|
||||
|
||||
// After the initial setup, set isFirstLoad to false
|
||||
isFirstLoad = false;
|
||||
}
|
||||
|
||||
document.getElementById("prev-btn").addEventListener("click", function () {
|
||||
if (currentIndex > 0) {
|
||||
currentIndex--;
|
||||
updateCarousel();
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("next-btn").addEventListener("click", function () {
|
||||
if (currentIndex < events.length - 1) {
|
||||
currentIndex++;
|
||||
updateCarousel();
|
||||
}
|
||||
});
|
||||
|
||||
// Initial setup
|
||||
updateCarousel();
|
||||
Reference in New Issue
Block a user