add
添加项目文件
This commit is contained in:
77
zh/docs/assets/javascripts/carousel.js
Normal file
77
zh/docs/assets/javascripts/carousel.js
Normal file
@@ -0,0 +1,77 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// 获取所有轮播图容器
|
||||
const carousels = document.querySelectorAll('.image-carousel');
|
||||
|
||||
carousels.forEach(carousel => {
|
||||
const slides = carousel.querySelectorAll('.carousel-slide');
|
||||
const prevBtn = carousel.querySelector('.carousel-prev');
|
||||
const nextBtn = carousel.querySelector('.carousel-next');
|
||||
const dots = carousel.querySelectorAll('.carousel-dot');
|
||||
let currentIndex = 0;
|
||||
|
||||
// 显示特定索引的幻灯片
|
||||
function showSlide(index) {
|
||||
// 隐藏所有幻灯片
|
||||
slides.forEach(slide => {
|
||||
slide.style.display = 'none';
|
||||
});
|
||||
|
||||
// 移除所有圆点的active类
|
||||
dots.forEach(dot => {
|
||||
dot.classList.remove('active');
|
||||
});
|
||||
|
||||
// 显示当前幻灯片
|
||||
slides[index].style.display = 'block';
|
||||
|
||||
// 确保导航按钮总是可见
|
||||
if (prevBtn) prevBtn.style.display = 'flex';
|
||||
if (nextBtn) nextBtn.style.display = 'flex';
|
||||
|
||||
// 给当前圆点添加active类
|
||||
if (dots.length > 0 && index < dots.length) {
|
||||
dots[index].classList.add('active');
|
||||
}
|
||||
}
|
||||
|
||||
// 显示初始幻灯片
|
||||
showSlide(currentIndex);
|
||||
|
||||
// 前一张按钮点击事件
|
||||
if (prevBtn) {
|
||||
prevBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation(); // 阻止事件冒泡
|
||||
currentIndex = currentIndex > 0 ? currentIndex - 1 : slides.length - 1;
|
||||
showSlide(currentIndex);
|
||||
});
|
||||
}
|
||||
|
||||
// 下一张按钮点击事件
|
||||
if (nextBtn) {
|
||||
nextBtn.addEventListener('click', (e) => {
|
||||
e.stopPropagation(); // 阻止事件冒泡
|
||||
currentIndex = currentIndex < slides.length - 1 ? currentIndex + 1 : 0;
|
||||
showSlide(currentIndex);
|
||||
});
|
||||
}
|
||||
|
||||
// 圆点点击事件
|
||||
dots.forEach((dot, index) => {
|
||||
dot.addEventListener('click', () => {
|
||||
currentIndex = index;
|
||||
showSlide(currentIndex);
|
||||
});
|
||||
});
|
||||
|
||||
// 可选:键盘导航
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'ArrowLeft') {
|
||||
currentIndex = currentIndex > 0 ? currentIndex - 1 : slides.length - 1;
|
||||
showSlide(currentIndex);
|
||||
} else if (e.key === 'ArrowRight') {
|
||||
currentIndex = currentIndex < slides.length - 1 ? currentIndex + 1 : 0;
|
||||
showSlide(currentIndex);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
51
zh/docs/assets/javascripts/extra.js
Normal file
51
zh/docs/assets/javascripts/extra.js
Normal file
@@ -0,0 +1,51 @@
|
||||
function checkForm() {
|
||||
alert('eee');
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// 页面内容溢出检测函数
|
||||
function checkPageOverflow() {
|
||||
// 获取所有页面元素
|
||||
var pages = document.querySelectorAll('.page');
|
||||
|
||||
pages.forEach(function(page) {
|
||||
// 获取页面内容高度
|
||||
var contentHeight = 0;
|
||||
Array.from(page.children).forEach(function(child) {
|
||||
contentHeight += child.offsetHeight;
|
||||
});
|
||||
|
||||
// 获取页面可用高度 (减去内边距)
|
||||
var pageStyles = window.getComputedStyle(page);
|
||||
var paddingTop = parseFloat(pageStyles.paddingTop);
|
||||
var paddingBottom = parseFloat(pageStyles.paddingBottom);
|
||||
var availableHeight = page.offsetHeight - paddingTop - paddingBottom;
|
||||
|
||||
// 检查是否溢出
|
||||
if (contentHeight > availableHeight) {
|
||||
page.setAttribute('data-overflow', 'true');
|
||||
|
||||
// 如果下一个元素不是 page-break,添加一个
|
||||
var nextElement = page.nextElementSibling;
|
||||
if (!nextElement || !nextElement.classList.contains('page-break')) {
|
||||
var pageBreak = document.createElement('div');
|
||||
pageBreak.className = 'page-break';
|
||||
page.parentNode.insertBefore(pageBreak, page.nextSibling);
|
||||
}
|
||||
} else {
|
||||
page.removeAttribute('data-overflow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 初始检查
|
||||
checkPageOverflow();
|
||||
|
||||
// 窗口大小改变时重新检查
|
||||
window.addEventListener('resize', checkPageOverflow);
|
||||
|
||||
// 图片加载后重新检查(图片会影响内容高度)
|
||||
document.querySelectorAll('img').forEach(function(img) {
|
||||
img.addEventListener('load', checkPageOverflow);
|
||||
});
|
||||
});
|
||||
1
zh/docs/assets/javascripts/glightbox.min.js
vendored
Normal file
1
zh/docs/assets/javascripts/glightbox.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user