feat: initial commit - 汽车贴膜门店 WordPress 主题 (B2B Trade v2.0.0)
- WordPress classic theme for car tinting/foil shop - 13 homepage template parts - Customizer panel with 13 sections - RFQ inquiry form handler - Bootstrap 5.3 + AOS + Colorbox frontend - 13 SVG placeholder images - Chinese content defaults
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
document.documentElement.classList.remove('no-js');
|
||||
document.documentElement.classList.add('js');
|
||||
|
||||
var reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
|
||||
function initStickyHeader() {
|
||||
var header = document.querySelector('#header');
|
||||
if (!header) return;
|
||||
function updateHeader() {
|
||||
header.classList.toggle('sticky', window.scrollY > 1);
|
||||
}
|
||||
updateHeader();
|
||||
window.addEventListener('scroll', updateHeader, { passive: true });
|
||||
}
|
||||
|
||||
function initAnimations() {
|
||||
if (!window.AOS || typeof window.AOS.init !== 'function') return;
|
||||
window.AOS.init({ duration: reducedMotion ? 0 : 700, once: true, disable: reducedMotion });
|
||||
}
|
||||
|
||||
function initVideoLightbox() {
|
||||
if (!$.fn || typeof $.fn.colorbox !== 'function') return;
|
||||
$('.youtube').colorbox({ iframe: true, innerWidth: 960, innerHeight: 585, maxWidth: '95%', maxHeight: '90%' });
|
||||
}
|
||||
|
||||
function initNavigation() {
|
||||
var panel = document.querySelector('#fragrance-navigation');
|
||||
if (!panel || !window.bootstrap || !window.bootstrap.Offcanvas) return;
|
||||
panel.querySelectorAll('a[href*="#"]').forEach(function (link) {
|
||||
link.addEventListener('click', function () {
|
||||
var instance = window.bootstrap.Offcanvas.getInstance(panel);
|
||||
if (instance) instance.hide();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initRfqPrefill() {
|
||||
var field = document.querySelector('[data-rfq-product-field]');
|
||||
if (!field) return;
|
||||
document.querySelectorAll('[data-rfq-product]').forEach(function (trigger) {
|
||||
trigger.addEventListener('click', function () {
|
||||
field.value = trigger.dataset.rfqProduct || '';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
initStickyHeader();
|
||||
initAnimations();
|
||||
initVideoLightbox();
|
||||
initNavigation();
|
||||
initRfqPrefill();
|
||||
});
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user