feat(navigation): hard-switch to Zibll navigation and Font Awesome 5

This commit is contained in:
kate522 committed 2026-08-18 20:46:21 +08:00
1 parent 3c3ddac8be
commit a0b84977a2
630 files changed
+101647 -11293

No files matched your search

-76
View File
@@ -27,81 +27,6 @@
tabs[next].click();
}
function initSwiperPause(el, swiper) {
if (!swiper.autoplay) return;
var i18n = config.i18n || {};
var manuallyPaused = false;
var button = document.createElement('button');
button.type = 'button';
button.className = 'aksrt-widget-swiper__pause';
button.setAttribute('aria-pressed', 'false');
function pause() {
if (typeof swiper.autoplay.pause === 'function') swiper.autoplay.pause();
else if (typeof swiper.autoplay.stop === 'function') swiper.autoplay.stop();
}
function resume() {
if (typeof swiper.autoplay.resume === 'function') swiper.autoplay.resume();
else if (typeof swiper.autoplay.start === 'function') swiper.autoplay.start();
}
function updateButton() {
button.setAttribute('aria-pressed', manuallyPaused ? 'true' : 'false');
button.setAttribute('aria-label', manuallyPaused ? (i18n.resume || '继续自动播放') : (i18n.pause || '暂停自动播放'));
button.textContent = manuallyPaused ? '▶' : 'Ⅱ';
}
button.addEventListener('click', function () {
manuallyPaused = !manuallyPaused;
if (manuallyPaused) pause();
else resume();
updateButton();
});
el.addEventListener('focusin', pause);
el.addEventListener('focusout', function (event) {
if (!manuallyPaused && !el.contains(event.relatedTarget)) resume();
});
updateButton();
el.appendChild(button);
}
function initSwiper(el) {
if (!once(el, 'Swiper') || typeof window.Swiper !== 'function') return;
var kind = el.dataset.aksrtSwiper || 'cards';
var vertical = kind === 'notice' || el.dataset.direction === 'vertical';
var options = {
direction: vertical ? 'vertical' : 'horizontal',
loop: el.dataset.loop === '1' || kind === 'notice',
speed: Number(el.dataset.speed || 500),
spaceBetween: Number(el.dataset.space || 16),
observer: true,
observeParents: true,
watchOverflow: true,
navigation: {
nextEl: el.querySelector('.swiper-button-next'),
prevEl: el.querySelector('.swiper-button-prev')
},
pagination: { el: el.querySelector('.swiper-pagination'), clickable: true }
};
if (kind === 'scroll' || kind === 'cards') {
options.slidesPerView = 'auto';
options.freeMode = kind === 'scroll';
}
if (kind === 'slider') {
options.effect = el.dataset.effect || 'slide';
options.parallax = !!el.querySelector('[data-swiper-parallax]');
}
var shouldAutoplay = !reducedMotion && (el.dataset.autoplay === '1' || kind === 'notice');
if (shouldAutoplay) {
options.autoplay = { delay: Number(el.dataset.interval || 4000), disableOnInteraction: false, pauseOnMouseEnter: true };
}
try {
el.aksrtSwiper = new window.Swiper(el, options);
if (shouldAutoplay) initSwiperPause(el, el.aksrtSwiper);
} catch (error) {
el.classList.add('is-fallback');
}
}
function videoType(url) {
if (/\.m3u8(?:\?|$)/i.test(url)) return 'hls';
if (/\.flv(?:\?|$)/i.test(url)) return 'flv';
@@ -332,7 +257,6 @@
function scan(root) {
var scope = root || document;
scope.querySelectorAll('[data-aksrt-swiper]').forEach(initSwiper);
scope.querySelectorAll('.aksrt-widget-video[data-video-url]').forEach(initVideo);
scope.querySelectorAll('.aksrt-widget-toc').forEach(initToc);
scope.querySelectorAll('.aksrt-widget-quote').forEach(initQuote);