This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,50 @@
define([], function () {
'use strict';
return function (config, element) {
var activeItem = null;
var interactiveItems = element.querySelectorAll(
'.esun-application__item--interactive'
);
function activate(item) {
if (activeItem && activeItem !== item) {
activeItem.classList.remove('is-active');
}
activeItem = item;
element.classList.add('has-active-item');
item.classList.add('is-active');
}
function deactivate(item) {
if (activeItem !== item) {
return;
}
item.classList.remove('is-active');
element.classList.remove('has-active-item');
activeItem = null;
}
interactiveItems.forEach(function (item) {
item.addEventListener('mouseenter', function () {
activate(item);
});
item.addEventListener('mouseleave', function () {
deactivate(item);
});
item.addEventListener('focusin', function () {
activate(item);
});
item.addEventListener('focusout', function (event) {
if (!item.contains(event.relatedTarget)) {
deactivate(item);
}
});
});
};
});
@@ -0,0 +1,36 @@
define([
'Swiper'
], function (Swiper) {
'use strict';
return function (config, element) {
var hasNavigation = element.getAttribute('data-has-navigation') === 'true';
new Swiper(element, {
centeredSlides: true,
initialSlide: 0,
loop: hasNavigation,
slidesPerView: 1.12,
spaceBetween: 0,
observer: true,
observeParents: true,
watchOverflow: true,
breakpoints: {
640: {
slidesPerView: 1.35,
spaceBetween: 0
},
1024: {
slidesPerView: 1.72,
spaceBetween: 0
}
},
navigation: hasNavigation ? {
nextEl: element.closest('.esun-awards-reviews')
.querySelector('.esun-awards-reviews__next'),
prevEl: element.closest('.esun-awards-reviews')
.querySelector('.esun-awards-reviews__previous')
} : {}
});
};
});
@@ -0,0 +1,35 @@
define([], function () {
'use strict';
return function (config, element) {
var end = new Date(element.getAttribute('data-end')).getTime();
var timer;
function setValue(unit, value) {
var target = element.querySelector('[data-time="' + unit + '"]');
if (target) {
target.textContent = String(Math.max(0, value)).padStart(2, '0');
}
}
function update() {
var distance = Math.max(0, end - Date.now());
setValue('days', Math.floor(distance / 86400000));
setValue('hours', Math.floor((distance % 86400000) / 3600000));
setValue('minutes', Math.floor((distance % 3600000) / 60000));
setValue('seconds', Math.floor((distance % 60000) / 1000));
if (distance === 0 && timer) {
window.clearInterval(timer);
}
}
if (!Number.isFinite(end)) {
return;
}
update();
timer = window.setInterval(update, 1000);
};
});
@@ -0,0 +1,39 @@
define([
'Swiper'
], function (Swiper) {
'use strict';
return function (config, element) {
var hasNavigation = element.getAttribute('data-has-navigation') === 'true';
if (window.matchMedia('(max-width: 639px)').matches) {
return;
}
new Swiper(element, {
slidesPerView: 1.26,
spaceBetween: 12,
observer: true,
observeParents: true,
watchOverflow: true,
breakpoints: {
768: {
slidesPerView: 2,
spaceBetween: 20
},
1024: {
slidesPerView: 4,
spaceBetween: 28
}
},
navigation: hasNavigation ? {
nextEl: element.querySelector('.esun-create-anything__next'),
prevEl: element.querySelector('.esun-create-anything__previous')
} : {},
pagination: hasNavigation ? {
el: element.querySelector('.esun-create-anything__pagination'),
clickable: true
} : {}
});
};
});
@@ -0,0 +1,22 @@
define([
'Swiper'
], function (Swiper) {
'use strict';
return function (config, element) {
if (element.getAttribute('data-has-pagination') !== 'true') {
return;
}
new Swiper(element, {
autoHeight: true,
allowTouchMove: true,
observer: true,
observeParents: true,
pagination: {
el: element.querySelector('.esun-hot-sale__pagination'),
clickable: true
}
});
};
});
@@ -0,0 +1,50 @@
define([], function () {
'use strict';
return function (config, element) {
var activeItem = null;
var interactiveItems = element.querySelectorAll(
'.esun-innovative-materials__item--interactive'
);
function activate(item) {
if (activeItem && activeItem !== item) {
activeItem.classList.remove('is-active');
}
activeItem = item;
element.classList.add('has-active-item');
item.classList.add('is-active');
}
function deactivate(item) {
if (activeItem !== item) {
return;
}
item.classList.remove('is-active');
element.classList.remove('has-active-item');
activeItem = null;
}
interactiveItems.forEach(function (item) {
item.addEventListener('mouseenter', function () {
activate(item);
});
item.addEventListener('mouseleave', function () {
deactivate(item);
});
item.addEventListener('focusin', function () {
activate(item);
});
item.addEventListener('focusout', function (event) {
if (!item.contains(event.relatedTarget)) {
deactivate(item);
}
});
});
};
});
@@ -0,0 +1,40 @@
define([], function () {
'use strict';
return function (config, element) {
var video = element.querySelector('video');
if (!video) {
return;
}
function playVideo() {
try {
video.currentTime = 0;
} catch (error) {}
element.classList.add('is-playing');
video.play().catch(function () {});
}
function stopVideo() {
video.pause();
element.classList.remove('is-playing');
}
element.addEventListener('mouseenter', playVideo);
element.addEventListener('mouseleave', stopVideo);
element.addEventListener('click', function (event) {
if (event.target.closest('a')) {
return;
}
if (video.paused) {
playVideo();
} else {
stopVideo();
}
});
};
});
@@ -0,0 +1,22 @@
define([
'Swiper'
], function (Swiper) {
'use strict';
return function (config, element) {
new Swiper(element, {
autoHeight: true,
loop: element.querySelectorAll('.swiper-slide').length > 1,
observer: true,
observeParents: true,
navigation: {
nextEl: element.querySelector('.esun-new-product__next'),
prevEl: element.querySelector('.esun-new-product__previous')
},
pagination: {
el: element.querySelector('.esun-new-product__pagination'),
clickable: true
}
});
};
});
@@ -0,0 +1,27 @@
define([
'Swiper'
], function (Swiper) {
'use strict';
return function (config, element) {
var hasNavigation = element.getAttribute('data-has-navigation') === 'true';
var container = element.closest('.esun-news-room');
new Swiper(element, {
slidesPerView: 1,
slidesPerGroup: 1,
spaceBetween: 36,
observer: true,
observeParents: true,
watchOverflow: true,
navigation: hasNavigation ? {
nextEl: container.querySelector('.esun-news-room__next'),
prevEl: container.querySelector('.esun-news-room__previous')
} : {},
pagination: hasNavigation ? {
el: element.querySelector('.esun-news-room__pagination'),
clickable: true
} : {}
});
};
});
@@ -0,0 +1,125 @@
define([], function () {
'use strict';
function getImage(card) {
var imageWrap = card.querySelector('[data-role=esun-product-image]');
return imageWrap ? imageWrap.querySelector('img') : null;
}
function rememberDefaultImage(image) {
if (!image || image.getAttribute('data-default-src')) {
return;
}
image.setAttribute('data-default-src', image.getAttribute('src') || '');
image.setAttribute('data-default-srcset', image.getAttribute('srcset') || '');
}
function setImage(image, url) {
if (!image || !url) {
return;
}
rememberDefaultImage(image);
image.setAttribute('src', url);
image.removeAttribute('srcset');
}
function restoreImage(image) {
var defaultSrc;
var defaultSrcset;
if (!image) {
return;
}
defaultSrc = image.getAttribute('data-default-src') || '';
defaultSrcset = image.getAttribute('data-default-srcset') || '';
if (defaultSrc) {
image.setAttribute('src', defaultSrc);
}
if (defaultSrcset) {
image.setAttribute('srcset', defaultSrcset);
} else {
image.removeAttribute('srcset');
}
}
return function (config, element) {
element.querySelectorAll('[data-role=esun-product-card]').forEach(function (card) {
var image = getImage(card);
var handledSwatches = new WeakSet();
if (!image) {
return;
}
rememberDefaultImage(image);
card.querySelectorAll('[data-role=esun-product-swatches]').forEach(function (swatches) {
swatches.querySelectorAll('[data-child-image], [data-product-image]').forEach(function (swatch) {
handledSwatches.add(swatch);
swatch.addEventListener('mouseenter', function () {
setImage(
image,
swatch.getAttribute('data-child-image') ||
swatch.getAttribute('data-product-image')
);
});
swatch.addEventListener('focus', function () {
setImage(
image,
swatch.getAttribute('data-child-image') ||
swatch.getAttribute('data-product-image')
);
});
});
swatches.addEventListener('mouseleave', function () {
restoreImage(image);
});
swatches.addEventListener('focusout', function (event) {
if (!event.relatedTarget || !swatches.contains(event.relatedTarget)) {
restoreImage(image);
}
});
});
card.querySelectorAll('[data-child-image], [data-product-image]').forEach(function (swatch) {
if (handledSwatches.has(swatch)) {
return;
}
swatch.addEventListener('mouseenter', function () {
setImage(
image,
swatch.getAttribute('data-child-image') ||
swatch.getAttribute('data-product-image')
);
});
swatch.addEventListener('focus', function () {
setImage(
image,
swatch.getAttribute('data-child-image') ||
swatch.getAttribute('data-product-image')
);
});
swatch.addEventListener('mouseleave', function () {
restoreImage(image);
});
swatch.addEventListener('blur', function () {
restoreImage(image);
});
});
});
};
});
@@ -0,0 +1,74 @@
define([], function () {
'use strict';
return function (config, element) {
var video = element.querySelector('video');
var isPlaying = false;
if (!video || element.getAttribute('data-video-hover-bound') === 'true') {
return;
}
element.setAttribute('data-video-hover-bound', 'true');
video.muted = true;
video.playsInline = true;
video.setAttribute('muted', 'muted');
video.setAttribute('playsinline', 'playsinline');
function playVideo() {
if (isPlaying) {
return;
}
isPlaying = true;
try {
video.currentTime = 0;
} catch (error) {}
element.classList.add('is-playing');
video.play().catch(function () {
isPlaying = false;
element.classList.remove('is-playing');
});
}
function stopVideo() {
isPlaying = false;
video.pause();
try {
video.currentTime = 0;
} catch (error) {}
element.classList.remove('is-playing');
}
element.addEventListener('mouseover', function (event) {
if (element.contains(event.relatedTarget)) {
return;
}
playVideo();
});
element.addEventListener('mouseout', function (event) {
if (element.contains(event.relatedTarget)) {
return;
}
stopVideo();
});
element.addEventListener('pointerenter', playVideo);
element.addEventListener('pointerleave', stopVideo);
element.addEventListener('touchstart', function (event) {
if (event.target.closest('a')) {
return;
}
playVideo();
}, {passive: true});
};
});