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,86 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Esun_Customer::css/iconfont.css"/>
<css src="Esun_Catalog::css/product-wishlist.css"/>
<css src="Esun_Catalog::css/special-campaign.css"/>
<css src="Esun_Catalog::css/product-recommendations-slider.css"/>
<css src="Esun_Catalog::css/product-recommendations-card-v4.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="Esun\Catalog\Block\Product\SpecialCampaign"
name="product.info.special.campaign"
template="Esun_Catalog::product/special-campaign.phtml"/>
<block class="Magento\Framework\View\Element\Template"
name="esun.catalog.configurable.price.state"
template="Esun_Catalog::product/configurable-price-state.phtml"/>
</referenceContainer>
<referenceContainer name="product.info.stock.sku" remove="true"/>
<referenceBlock name="page.main.title" remove="true"/>
<referenceBlock name="product.info.overview" remove="true"/>
<referenceBlock name="product.info.description" remove="true"/>
<referenceBlock name="product.attributes" remove="true"/>
<referenceBlock name="reviews.tab" remove="true"/>
<referenceBlock name="product.attributes.wrapper" remove="true"/>
<referenceBlock name="product.attributes.exclude.pagebuilder" remove="true"/>
<referenceBlock name="product.reviews.wrapper" remove="true"/>
<referenceBlock name="product.info.product_additional_data.wrapper" remove="true"/>
<referenceBlock name="catalog.product.related" remove="true"/>
<referenceBlock name="product.info.details" template="Esun_Catalog::product/details.phtml">
<block class="Magento\Catalog\Block\Product\View\Description"
name="esun.product.info.product.overview"
as="product_overview"
template="Magento_Catalog::product/view/attribute.phtml"
group="detailed_info">
<arguments>
<argument name="at_call" xsi:type="string">getProductOverview</argument>
<argument name="at_code" xsi:type="string">product_overview</argument>
<argument name="css_class" xsi:type="string">product-overview</argument>
<argument name="at_label" xsi:type="string">none</argument>
<argument name="title" translate="true" xsi:type="string">Product Overview</argument>
<argument name="sort_order" xsi:type="string">10</argument>
</arguments>
</block>
<block class="Magento\Cms\Block\Block"
name="esun.product.info.delivery.shipping"
as="delivery_shipping"
group="detailed_info">
<arguments>
<argument name="block_id" xsi:type="string">esun_product_delivery_shipping</argument>
<argument name="title" translate="true" xsi:type="string">Delivery and Shipping</argument>
<argument name="sort_order" xsi:type="string">20</argument>
</arguments>
</block>
<block class="Magento\Cms\Block\Block"
name="esun.product.info.payment.security"
as="payment_security"
group="detailed_info">
<arguments>
<argument name="block_id" xsi:type="string">esun_product_payment_security</argument>
<argument name="title" translate="true" xsi:type="string">Payment &amp; Security</argument>
<argument name="sort_order" xsi:type="string">30</argument>
</arguments>
</block>
</referenceBlock>
<move element="product.info.special.campaign" destination="product.info.main" before="-"/>
<referenceContainer name="content.aside">
<block class="Esun\Catalog\Block\Product\DetailContent"
name="esun.product.detail.content"
template="Esun_Catalog::product/detail/content.phtml"
before="esun.product.reviews">
<block class="Esun\Catalog\Block\Product\DownloadSpecifications"
name="esun.product.detail.download.specifications"
as="download_specifications"
template="Esun_Catalog::product/detail/download-specifications.phtml"/>
<block class="Esun\Catalog\Block\Product\AvailableColors"
name="esun.product.detail.available.colors"
as="available_colors"
template="Esun_Catalog::product/detail/available-colors.phtml"/>
</block>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,7 @@
<script type="text/x-magento-init">
{
"*": {
"Esun_Catalog/js/configurable-price-state": {}
}
}
</script>
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
/** @var \Magento\Framework\View\Element\Template $block */
?>
<div class="esun-product-service esun-product-service--delivery">
<ul>
<li><?= $block->escapeHtml(__('Shipping: $ 5.99, Free Shipping Over $ 99.00')) ?></li>
<li><a href="<?= $block->escapeUrl($block->getUrl('shipping-policy')) ?>"><?= $block->escapeHtml(__('To United States Via FedEX/USPS')) ?></a></li>
<li><?= $block->escapeHtml(__('Estimated Delivery Time: Standard Shipping')) ?></li>
</ul>
</div>
@@ -0,0 +1,60 @@
<?php
/** @var \Esun\Catalog\Block\Product\AvailableColors $block */
$availableColorOptions = $block->getColorOptions();
?>
<?php if ($availableColorOptions): ?>
<section class="esun-product-detail-section available-colors"
id="available-colors"
data-mage-init='{"Esun_Catalog/js/product-color-options":<?= /* @noEscape */ $block->getColorSwatchConfigJson($availableColorOptions) ?>}'>
<h2 class="product-section-title"><?= $block->escapeHtml(__('Available Colors')) ?></h2>
<div class="esun-available-colors-layout">
<div class="esun-available-colors">
<?php foreach ($availableColorOptions as $colorOption): ?>
<?php
$ballImageUrl = (string)($colorOption['ball_image_url'] ?? '');
$swatchColors = is_array($colorOption['swatch_colors'] ?? null) ? $colorOption['swatch_colors'] : [];
$gradientStops = [];
if ($swatchColors) {
$step = 100 / count($swatchColors);
foreach (array_values($swatchColors) as $index => $color) {
$gradientStops[] = $color . ' ' . round($index * $step, 4) . '% ' . round(($index + 1) * $step, 4) . '%';
}
}
?>
<figure class="esun-available-colors__item">
<span class="esun-available-colors__visual" tabindex="0">
<?php if ($ballImageUrl !== ''): ?>
<img src="<?= $block->escapeUrl($ballImageUrl) ?>"
alt="<?= $block->escapeHtmlAttr((string)$colorOption['label']) ?>">
<?php else: ?>
<span class="esun-available-colors__fallback"
style="<?= $gradientStops ? 'background: conic-gradient(' . $block->escapeHtmlAttr(implode(',', $gradientStops)) . ');' : '' ?>"></span>
<?php endif; ?>
<span class="esun-available-colors__overlay" aria-hidden="true"></span>
<span class="esun-available-colors__tooltip">
<?= $block->escapeHtml((string)$colorOption['label']) ?>
</span>
</span>
</figure>
<?php endforeach; ?>
</div>
<div class="esun-available-colors-list">
<?php foreach ($availableColorOptions as $colorOption): ?>
<?php foreach (($colorOption['colors'] ?? []) as $color): ?>
<?php $hexValue = strtoupper((string)($color['hex'] ?? '')); ?>
<div class="esun-available-colors-list__row">
<span class="esun-available-colors-list__swatch"
style="background: <?= $block->escapeHtmlAttr($hexValue) ?>"></span>
<span class="esun-available-colors-list__name">
<?= $block->escapeHtml((string)($color['name'] ?? '')) ?>
</span>
<span class="esun-available-colors-list__hex">
<?= $block->escapeHtml($hexValue) ?>
</span>
</div>
<?php endforeach; ?>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endif; ?>
@@ -0,0 +1,202 @@
<?php
/** @var \Esun\Catalog\Block\Product\DetailContent $block */
$descriptionHtml = trim($block->getDescriptionHtml());
$industryItems = $block->getIndustryApplications();
$galleryImages = $block->getDetailGalleryImages();
$creativeVideos = $block->getCreativeVideos();
$printingParameters = $block->getPrintingParameters();
$certificationDownloads = $block->getCertificationDownloads();
$downloadSpecificationsHtml = trim($block->getChildHtml('download_specifications'));
$availableColorsHtml = trim($block->getChildHtml('available_colors'));
$faqs = $block->getFaqs();
$hasDownload = $certificationDownloads || $downloadSpecificationsHtml !== '';
?>
<?php if ($descriptionHtml || $industryItems || $galleryImages || $creativeVideos || $printingParameters || $hasDownload || $availableColorsHtml || $faqs): ?>
<div class="esun-product-detail-content">
<?php if ($descriptionHtml): ?>
<section class="esun-product-detail-section product-overview-content" id="overview">
<?= /* @noEscape */ $descriptionHtml ?>
</section>
<?php endif; ?>
<?php if ($industryItems || $galleryImages || $creativeVideos || $printingParameters || $hasDownload || $availableColorsHtml || $faqs): ?>
<div class="esun-product-dynamic-sections">
<?php if ($industryItems): ?>
<section class="esun-product-detail-section industry-applications" id="industry-applications">
<?php $firstIndustryItem = $industryItems[0] ?? []; ?>
<div class="esun-industry-applications"
data-mage-init='{"Esun_Catalog/js/industry-applications":{}}'>
<div class="esun-industry-applications__stage">
<?php if (!empty($firstIndustryItem['image'])): ?>
<img class="esun-industry-applications__image"
src="<?= $block->escapeUrl($block->getMediaUrl((string)$firstIndustryItem['image'])) ?>"
alt="<?= $block->escapeHtmlAttr((string)($firstIndustryItem['label'] ?? '')) ?>"
data-role="industry-large-image">
<?php endif; ?>
<h2 class="product-section-title esun-industry-applications__title">
<?= $block->escapeHtml(__('Industry Applications')) ?>
</h2>
<div class="esun-industry-applications__nav" role="tablist">
<?php foreach ($industryItems as $index => $item): ?>
<?php
$largeImage = !empty($item['image']) ? $block->getMediaUrl((string)$item['image']) : '';
$label = (string)($item['label'] ?? '');
?>
<button class="esun-industry-applications__trigger<?= $index === 0 ? ' is-active' : '' ?>"
type="button"
role="tab"
aria-selected="<?= $index === 0 ? 'true' : 'false' ?>"
data-large-image="<?= $block->escapeUrl($largeImage) ?>"
data-large-alt="<?= $block->escapeHtmlAttr($label) ?>">
<?php if (!empty($item['icon'])): ?>
<img class="esun-industry-applications__icon"
src="<?= $block->escapeUrl($block->getMediaUrl((string)$item['icon'])) ?>"
alt="">
<?php endif; ?>
<?php if ($label !== ''): ?>
<span><?= $block->escapeHtml($label) ?></span>
<?php endif; ?>
</button>
<?php endforeach; ?>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?php if ($galleryImages): ?>
<section class="esun-product-detail-section detail-gallery" id="detail-gallery">
<h2 class="product-section-title"><?= $block->escapeHtml(__('Gallery')) ?></h2>
<div class="esun-detail-gallery" data-mage-init='{"Esun_Catalog/js/drag-scroll":{}}'>
<?php foreach ($galleryImages as $image): ?>
<img src="<?= $block->escapeUrl($image['url']) ?>"
alt="<?= $block->escapeHtmlAttr($image['label']) ?>">
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
<?php if ($creativeVideos): ?>
<section class="esun-product-detail-section creative-videos" id="creative-videos">
<h2 class="product-section-title"><?= $block->escapeHtml(__('Create Anything You Imagining')) ?></h2>
<div class="esun-creative-videos" data-mage-init='{"Esun_Catalog/js/creative-videos":{}}'>
<?php foreach ($creativeVideos as $video): ?>
<div class="esun-creative-videos__item">
<img src="<?= $block->escapeUrl($video['cover_url']) ?>" alt="">
<video muted playsinline preload="metadata" src="<?= $block->escapeUrl($video['video_url']) ?>"></video>
</div>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
<?php if ($printingParameters): ?>
<section class="esun-product-detail-section printing-parameter" id="printing-parameter">
<h2 class="product-section-title"><?= $block->escapeHtml(__('Printing Parameter')) ?></h2>
<div class="esun-printing-parameter">
<?php foreach ($printingParameters as $groupName => $group): ?>
<?php
$items = is_array($group['items'] ?? null) ? $group['items'] : [];
$iconUrl = $block->getPrintingParameterIconUrl((string)($group['icon'] ?? ''));
if (!$items) {
continue;
}
?>
<div class="esun-printing-parameter__group">
<h3 class="esun-printing-parameter__group-title">
<?php if ($iconUrl): ?>
<img src="<?= $block->escapeUrl($iconUrl) ?>" alt="">
<?php endif; ?>
<span><?= $block->escapeHtml((string)$groupName) ?></span>
</h3>
<div class="esun-printing-parameter__items esun-printing-parameter__items--count-<?= (int)min(count($items), 4) ?>">
<?php foreach ($items as $label => $value): ?>
<div class="esun-printing-parameter__item">
<div class="esun-printing-parameter__label"><?= $block->escapeHtml((string)$label) ?></div>
<div class="esun-printing-parameter__value"><?= /* @noEscape */ nl2br($block->escapeHtml((string)$value)) ?></div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
<?php if ($hasDownload): ?>
<?php $defaultDownloadTab = $certificationDownloads ? 'certification' : 'specifications'; ?>
<section class="esun-product-detail-section download" id="download"
data-mage-init='{"Esun_Catalog/js/download-tabs":{}}'>
<div class="esun-download__head">
<h2 class="product-section-title"><?= $block->escapeHtml(__('Download')) ?></h2>
<div class="esun-download__tabs" role="tablist" aria-label="<?= $block->escapeHtmlAttr(__('Download')) ?>">
<?php if ($certificationDownloads): ?>
<button class="esun-download__tab<?= $defaultDownloadTab === 'certification' ? ' is-active' : '' ?>"
type="button"
data-download-tab="certification">
<?= $block->escapeHtml(__('Certification')) ?>
</button>
<?php endif; ?>
<?php if ($downloadSpecificationsHtml !== ''): ?>
<button class="esun-download__tab<?= $defaultDownloadTab === 'specifications' ? ' is-active' : '' ?>"
type="button"
data-download-tab="specifications">
<?= $block->escapeHtml(__('Download Specifications')) ?>
</button>
<?php endif; ?>
</div>
</div>
<?php if ($certificationDownloads): ?>
<div class="esun-download__panel<?= $defaultDownloadTab === 'certification' ? ' is-active' : '' ?>"
data-download-panel="certification">
<div class="esun-certification-downloads">
<?php foreach ($certificationDownloads as $download): ?>
<a class="esun-certification-downloads__item"
href="<?= $block->escapeUrl($download['file_url']) ?>"
download="<?= $block->escapeHtmlAttr($download['file_name']) ?>">
<?php if (!empty($download['icon_url'])): ?>
<span class="esun-certification-downloads__icon">
<img src="<?= $block->escapeUrl($download['icon_url']) ?>"
alt="">
</span>
<?php endif; ?>
<span class="esun-certification-downloads__name">
<?= $block->escapeHtml($download['name']) ?>
</span>
<span class="esun-certification-downloads__text">
<?= $block->escapeHtml(__('Download')) ?>
</span>
<span class="esun-certification-downloads__button" aria-hidden="true"></span>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if ($downloadSpecificationsHtml !== ''): ?>
<div class="esun-download__panel<?= $defaultDownloadTab === 'specifications' ? ' is-active' : '' ?>"
data-download-panel="specifications">
<?= /* @noEscape */ $downloadSpecificationsHtml ?>
</div>
<?php endif; ?>
</section>
<?php endif; ?>
<?= /* @noEscape */ $availableColorsHtml ?>
<?php if ($faqs): ?>
<section class="esun-product-detail-section faq" id="faq">
<h2 class="product-section-title"><?= $block->escapeHtml(__('FAQ')) ?></h2>
<div class="esun-product-faq">
<?php foreach ($faqs as $faq): ?>
<details class="esun-product-faq__item">
<summary><?= $block->escapeHtml($faq['title']) ?></summary>
<div class="esun-product-faq__content"><?= /* @noEscape */ $faq['content'] ?></div>
</details>
<?php endforeach; ?>
</div>
</section>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
@@ -0,0 +1,33 @@
<?php
/** @var \Esun\Catalog\Block\Product\DownloadSpecifications $block */
if (!$block->hasSpecifications()) {
return;
}
?>
<div class="esun-download-specifications"
data-mage-init='{"Esun_Catalog/js/download-specifications":<?= /* @noEscape */ $block->getConfigJson() ?>}'>
<div class="esun-download-specifications__filters">
<label class="esun-download-specifications__field">
<span><?= $block->escapeHtml(__('Brand')) ?></span>
<select data-role="spec-brand">
<option value=""><?= $block->escapeHtml(__('All Brands')) ?></option>
</select>
</label>
<label class="esun-download-specifications__field">
<span><?= $block->escapeHtml(__('Model')) ?></span>
<select data-role="spec-model">
<option value=""><?= $block->escapeHtml(__('All Models')) ?></option>
</select>
</label>
</div>
<div class="esun-download-specifications__count">
<span><?= $block->escapeHtml(__('Download List')) ?></span>
<strong data-role="spec-count">0</strong>
</div>
<div class="esun-download-specifications__empty" data-role="spec-empty">
<span class="esun-download-specifications__empty-icon"></span>
<strong><?= $block->escapeHtml(__('Find your printer driver')) ?></strong>
<p><?= $block->escapeHtml(__('Select a brand or printer model to browse available downloads.')) ?></p>
</div>
<div class="esun-download-specifications__list" data-role="spec-list"></div>
</div>
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
/** @var \Magento\Catalog\Block\Product\View\Details $block */
?>
<?php if ($detailedInfoGroup = $block->getGroupSortedChildNames('detailed_info', 'getChildHtml')): ?>
<div class="product info detailed esun-product-details">
<?php $layout = $block->getLayout(); ?>
<div class="esun-product-accordion">
<?php foreach ($detailedInfoGroup as $name): ?>
<?php
$html = $layout->renderElement($name);
if (!$html || !trim($html)) {
continue;
}
$alias = $layout->getElementAlias($name);
if (in_array($alias, ['additional', 'reviews'], true)) {
continue;
}
$label = $block->getChildData($alias, 'title');
$isOpen = $alias !== 'product_overview';
?>
<details class="esun-product-accordion__item"<?= $isOpen ? ' open' : '' ?>>
<summary class="esun-product-accordion__summary">
<span><?= $block->escapeHtml($label) ?></span>
</summary>
<div class="esun-product-accordion__content" id="<?= $block->escapeHtmlAttr($alias) ?>">
<?= /* @noEscape */ $html ?>
</div>
</details>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
/** @var \Magento\Framework\View\Element\Template $block */
?>
<div class="esun-product-service esun-product-service--payment">
<div class="esun-payment-methods__label"><?= $block->escapeHtml(__('Payment Methods')) ?></div>
<div class="esun-payment-methods" aria-label="<?= $block->escapeHtmlAttr(__('Payment Methods')) ?>">
<span>PayPal</span>
<span>Apple Pay</span>
<span>Google Pay</span>
<span>Klarna</span>
<span>VISA</span>
<span>Mastercard</span>
<span>Maestro</span>
<span>JCB</span>
<span>AmEx</span>
<span>Diners Club</span>
<span>Discover</span>
</div>
<p><?= $block->escapeHtml(__('Your Payment Information Is Processed Securely. We Do Not Store Credit Card Details Nor Have Access To Your Credit Card Information.')) ?></p>
</div>
ITEM DIAMETER
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
/** @var \Esun\Catalog\Block\Product\PurchaseProgress $block */
$config = $block->getConfig();
$mixEnabled = !empty($config['mixEnabled']);
$mixConfig = is_array($config['mix'] ?? null) ? $config['mix'] : [];
$initialProductConfig = $block->getInitialProductConfig($config);
$initialMilestones = $mixEnabled ? [] : ($initialProductConfig ? $block->getInitialMilestones($initialProductConfig) : []);
$initialQty = max(1, (int)$block->getData('initial_qty'));
$initialProgressPercent = $block->getInitialProgressPercent($initialMilestones, $initialQty);
?>
<?php if (!empty($config['products'])): ?>
<div class="esun-purchase-progress" data-role="esun-purchase-progress">
<?php if ($mixEnabled): ?>
<div class="esun-purchase-progress__heading">
<strong><?= $block->escapeHtml(__('Mix variants, save more')) ?></strong>
<span data-role="mix-message"><?= $block->escapeHtml(__('Choose quantities below to unlock a mix price.')) ?></span>
</div>
<?php endif; ?>
<div class="esun-purchase-progress__graph">
<div class="esun-purchase-progress__track"
data-role="progress-track"
style="--esun-progress-width: <?= $block->escapeHtmlAttr((string)$initialProgressPercent) ?>%"></div>
<div class="esun-purchase-progress__steps" data-role="progress-steps">
<?php foreach ($initialMilestones as $milestone): ?>
<?php
$qty = (int)($milestone['qty'] ?? 0);
$percentage = $milestone['percentage'] ?? null;
?>
<div class="esun-purchase-progress__step">
<span class="esun-purchase-progress__marker"></span>
<span class="esun-purchase-progress__value">
<?= $block->escapeHtml($block->formatAmount((float)($milestone['price'] ?? 0))) ?>
</span>
<span class="esun-purchase-progress__label">
<?= $block->escapeHtml(__('%1 pcs', $qty)) ?><?= $percentage ? $block->escapeHtml(' ' . (float)$percentage . '% off') : '' ?>
</span>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php if ($mixEnabled): ?>
<?php $mixItems = is_array($mixConfig['items'] ?? null) ? $mixConfig['items'] : []; ?>
<section class="esun-mix-builder" data-role="esun-mix-builder">
<input type="hidden" name="mix_mode" value="add" data-role="mix-mode"/>
<div class="esun-mix-builder__items" data-role="mix-items" hidden>
<?php foreach ($mixItems as $item): ?>
<input type="hidden"
name="mix_items[<?= $block->escapeHtmlAttr((string)$item['id']) ?>]"
value="0"
data-role="mix-item-qty"
data-configured="0"
data-child-id="<?= $block->escapeHtmlAttr((string)$item['id']) ?>"
data-options="<?= $block->escapeHtmlAttr((string)json_encode($item['options'] ?? [])) ?>"
data-base-price="<?= $block->escapeHtmlAttr((string)$item['basePrice']) ?>"/>
<?php endforeach; ?>
</div>
<div class="esun-mix-builder__summary" aria-live="polite">
<span>
<strong><?= $block->escapeHtml(__('Mix selection')) ?></strong>
<small data-role="mix-selection-summary"><?= $block->escapeHtml(__('Choose a color, then set its quantity.')) ?></small>
</span>
<span>
<del data-role="mix-base-total"></del>
<strong data-role="mix-final-total"><?= $block->escapeHtml($block->formatAmount(0)) ?></strong>
</span>
</div>
</section>
<?php endif; ?>
<script type="text/x-magento-init">
{
"[data-role=esun-purchase-progress]": {
"Esun_Catalog/js/purchase-progress": <?= /* @noEscape */ $block->getJsonConfig() ?>
}
}
</script>
<?php endif; ?>
@@ -0,0 +1,69 @@
<?php
/** @var \Esun\Catalog\Block\Product\RecommendedProducts $block */
$items = $block->getRecommendedItems();
?>
<?php if ($items): ?>
<section class="esun-recommended-products" id="recommended-products"
data-mage-init='{"Esun_Catalog/js/recommendations-carousel":{}}'>
<div class="esun-recommended-products__heading">
<h2 class="product-section-title"><?= $block->escapeHtml(__('You may need-Cost Savings:')) ?></h2>
<div class="esun-recommended-products__navigation" aria-label="<?= $block->escapeHtmlAttr(__('Recommendation navigation')) ?>">
<button class="esun-recommended-products__previous" type="button" aria-label="<?= $block->escapeHtmlAttr(__('Previous products')) ?>">&#8249;</button>
<button class="esun-recommended-products__next" type="button" aria-label="<?= $block->escapeHtmlAttr(__('Next products')) ?>">&#8250;</button>
</div>
</div>
<div class="esun-recommended-products__slider" tabindex="0">
<div class="esun-recommended-products__wrapper">
<?php foreach ($items as $item): ?>
<?php
$productUrl = $block->getProductUrl($item);
$discountPercent = $block->getDiscountPercent($item);
?>
<article class="esun-recommended-products__item">
<a class="esun-recommended-products__image"
href="<?= $block->escapeUrl($productUrl) ?>"
aria-label="<?= $block->escapeHtmlAttr($item->getName()) ?>">
<?= /* @noEscape */ $block->getImage($item, 'recommended_products_list')->toHtml() ?>
</a>
<div class="esun-recommended-products__body">
<h3 class="esun-recommended-products__name">
<a href="<?= $block->escapeUrl($productUrl) ?>">
<?= $block->escapeHtml($item->getName()) ?>
</a>
</h3>
<div class="esun-recommended-products__footer">
<div class="esun-recommended-products__summary">
<div class="esun-recommended-products__prices">
<span class="esun-recommended-products__final-price">
<?= $block->escapeHtml($block->getFormattedFinalPrice($item)) ?>
</span>
<?php if ($block->hasOldPrice($item)): ?>
<span class="esun-recommended-products__old-price">
<?= $block->escapeHtml($block->getFormattedRegularPrice($item)) ?>
</span>
<?php endif; ?>
</div>
<?php if ($discountPercent !== null): ?>
<span class="esun-recommended-products__discount">
<?= (int)$discountPercent ?>% <?= $block->escapeHtml(__('OFF')) ?>
</span>
<?php endif; ?>
</div>
<div class="esun-recommended-products__actions">
<a class="esun-recommended-products__cart"
href="<?= $block->escapeUrl($productUrl) ?>"
aria-label="<?= $block->escapeHtmlAttr(__('View product')) ?>">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L20 8H7M10 20a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm8 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" />
</svg>
</a>
</div>
</div>
</div>
</article>
<?php endforeach; ?>
</div>
</div>
</section>
<?php endif; ?>
@@ -0,0 +1,60 @@
<?php
/**
* @var $block \Esun\Catalog\Block\Product\SpecialCampaign
*/
?>
<?php
$campaignItems = $block->getCampaignConfig();
$defaultItem = $campaignItems ? reset($campaignItems) : null;
$productName = $block->getProductName();
$shortDescriptionHtml = $block->getShortDescriptionHtml();
?>
<div class="product-campaign-summary">
<?php if ($defaultItem): ?>
<div class="product-special-campaign" data-role="product-special-campaign">
<img
class="product-special-campaign__icon"
src="<?= $block->escapeUrl($block->getViewFileUrl('Esun_Catalog::images/spring-sale-tag.png')) ?>"
alt=""
aria-hidden="true"
/>
<div class="product-special-campaign__title">
<?= $block->escapeHtml(__('Stock Up For Spring')) ?>
</div>
<div class="product-special-campaign__countdown" data-role="campaign-countdown">
<span><strong data-role="campaign-days">0</strong><?= $block->escapeHtml(__('Days')) ?></span>
<span><strong data-role="campaign-hours">0</strong><?= $block->escapeHtml(__('Hours')) ?></span>
<span><strong data-role="campaign-minutes">0</strong><?= $block->escapeHtml(__('Minutes')) ?></span>
<span><strong data-role="campaign-seconds">0</strong><?= $block->escapeHtml(__('Second')) ?></span>
</div>
</div>
<?php endif; ?>
<?php if ($productName !== ''): ?>
<div class="page-title-wrapper product product-campaign-summary__title-wrapper">
<h1 class="page-title">
<span class="base" data-ui-id="page-title-wrapper" itemprop="name">
<?= $block->escapeHtml($productName) ?>
</span>
</h1>
</div>
<?php endif; ?>
<?php if ($shortDescriptionHtml !== ''): ?>
<div class="product attribute overview product-campaign-summary__overview">
<div class="value" itemprop="description"><?= /* @noEscape */ $shortDescriptionHtml ?></div>
</div>
<?php endif; ?>
</div>
<?php if ($defaultItem): ?>
<script type="text/x-magento-init">
{
"[data-role=product-special-campaign]": {
"Esun_Catalog/js/product-special-campaign": {
"items": <?= /* @noEscape */ json_encode($campaignItems) ?>
}
}
}
</script>
<?php endif; ?>
@@ -0,0 +1,37 @@
<?php
/**
* Product-page AJAX wishlist action.
*
* @var \Magento\Wishlist\Block\Catalog\Product\View\AddTo\Wishlist $block
*/
$product = $block->getProduct();
$buttonId = 'esun-product-wishlist-' . (int) $product->getId();
?>
<?php if ($block->isWishListAllowed()) : ?>
<button type="button"
id="<?= $block->escapeHtmlAttr($buttonId) ?>"
class="esun-product-wishlist"
data-post='<?= /* @noEscape */ $block->getWishlistParams() ?>'
data-action="add-to-wishlist"
aria-label="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>"
aria-pressed="false"
title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>">
<i class="iconfont icon-favorite6" aria-hidden="true"></i>
<span class="esun-product-wishlist__label"><?= $block->escapeHtml(__('Add to Wish List')) ?></span>
</button>
<script type="text/x-magento-init">
{
"body": {
"addToWishlist": <?= /* @noEscape */ $block->getWishlistOptionsJson() ?>
},
"#<?= $block->escapeJs($buttonId) ?>": {
"Esun_Catalog/js/product-wishlist": {
"loginUrl": "<?= $block->escapeUrl($block->getUrl('customer/account/login')) ?>",
"statusUrl": "<?= $block->escapeUrl($block->getUrl('wishlist/status/index')) ?>",
"productId": <?= (int) $product->getId() ?>
}
}
}
</script>
<?php endif; ?>
@@ -0,0 +1,73 @@
.catalog-product-view .esun-recommended-products__body {
box-sizing: border-box;
max-width: 100%;
overflow: hidden;
}
.catalog-product-view .esun-recommended-products__summary {
align-items: center;
column-gap: 32px;
display: grid;
grid-template-columns: minmax(0, 1fr) max-content;
justify-content: normal;
min-width: 0;
}
.catalog-product-view .esun-recommended-products__prices {
flex: none;
min-width: 0;
}
.catalog-product-view .esun-recommended-products__final-price,
.catalog-product-view .esun-recommended-products__old-price,
.catalog-product-view .esun-recommended-products__discount {
white-space: nowrap;
}
.catalog-product-view .esun-recommended-products__discount {
justify-self: end;
margin-left: 0;
max-width: 100%;
}
@media (min-width: 1200px) {
.catalog-product-view .esun-recommended-products__item {
flex: 0 0 56% !important;
max-width: 56%;
width: 56% !important;
grid-template-columns: minmax(180px, 40%) minmax(0, 1fr);
}
}
@media (min-width: 768px) and (max-width: 1199px) {
.catalog-product-view .esun-recommended-products__item {
flex: 0 0 68% !important;
max-width: 68%;
width: 68% !important;
grid-template-columns: minmax(160px, 38%) minmax(0, 1fr);
}
}
@media (max-width: 767px) {
.catalog-product-view .esun-recommended-products__item {
flex: 0 0 86% !important;
max-width: 86%;
width: 86% !important;
}
.catalog-product-view .esun-recommended-products__summary {
column-gap: 24px;
}
}
@media (max-width: 479px) {
.catalog-product-view .esun-recommended-products__item {
flex-basis: 92% !important;
max-width: 92%;
width: 92% !important;
}
.catalog-product-view .esun-recommended-products__summary {
column-gap: 20px;
}
}
@@ -0,0 +1,75 @@
.catalog-product-view .esun-recommended-products__slider {
cursor: grab;
min-width: 0;
overflow-x: auto !important;
overflow-y: hidden;
overscroll-behavior-x: contain;
scrollbar-width: none;
scroll-behavior: smooth;
scroll-snap-type: x mandatory;
touch-action: pan-x pan-y;
width: 100%;
}
.catalog-product-view .esun-recommended-products__slider::-webkit-scrollbar {
display: none;
}
.catalog-product-view .esun-recommended-products__slider.is-dragging {
cursor: grabbing;
scroll-behavior: auto;
user-select: none;
}
.catalog-product-view .esun-recommended-products__wrapper {
align-items: stretch;
display: flex;
flex-wrap: nowrap;
gap: 24px;
transform: none !important;
width: 100% !important;
}
.catalog-product-view .esun-recommended-products__item {
flex: 0 0 calc((100% - 24px) / 2);
scroll-snap-align: start;
}
.catalog-product-view .esun-recommended-products__previous.is-disabled,
.catalog-product-view .esun-recommended-products__next.is-disabled,
.catalog-product-view .esun-recommended-products__previous:disabled,
.catalog-product-view .esun-recommended-products__next:disabled {
cursor: default;
opacity: .35;
}
@media (max-width: 1199px) {
.catalog-product-view .esun-recommended-products__wrapper {
gap: 20px;
}
.catalog-product-view .esun-recommended-products__item {
flex-basis: 61%;
}
}
@media (max-width: 767px) {
.catalog-product-view .esun-recommended-products__wrapper {
gap: 16px;
}
.catalog-product-view .esun-recommended-products__item {
flex-basis: 74%;
}
}
@media (max-width: 479px) {
.catalog-product-view .esun-recommended-products__wrapper {
gap: 14px;
}
.catalog-product-view .esun-recommended-products__item {
flex-basis: 92%;
}
}
@@ -0,0 +1,62 @@
.catalog-product-view .esun-product-review-actions {
align-items: center;
display: flex;
gap: 14px;
margin: 0 0 18px;
}
.catalog-product-view .esun-product-review-actions .product-reviews-summary.esun-review-summary {
margin-bottom: 0;
}
.catalog-product-view .esun-product-wishlist {
align-items: center;
background: transparent;
border: 0;
box-shadow: none;
color: #333;
cursor: pointer;
display: inline-flex;
flex: 0 0 auto;
justify-content: center;
line-height: 1;
padding: 2px;
position: relative;
margin-top: -20px;
transition: color .2s ease;
}
.catalog-product-view .esun-product-wishlist:hover,
.catalog-product-view .esun-product-wishlist:focus {
background: transparent;
border: 0;
box-shadow: none;
color: #e53935;
}
.catalog-product-view .esun-product-wishlist.is-active {
color: #e53935;
}
.catalog-product-view .esun-product-wishlist.is-loading {
cursor: wait;
opacity: .6;
}
.catalog-product-view .esun-product-wishlist .iconfont {
display: block;
font-size: 20px;
height: 20px;
line-height: 20px;
width: 20px;
}
.catalog-product-view .esun-product-wishlist__label {
clip: rect(0, 0, 0, 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
<circle cx="12" cy="12" r="9"/>
<path d="M12 8h.01"/>
<path d="M11 12h1v5h1"/>
<path d="M4.5 12h2"/>
<path d="M17.5 12h2"/>
</svg>

After

Width:  |  Height:  |  Size: 320 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
<path d="M12 3 21 8v8l-9 5-9-5V8l9-5Z"/>
<path d="M12 3v18"/>
<path d="m3 8 9 5 9-5"/>
<path d="m6.5 17.9 11-12"/>
</svg>

After

Width:  |  Height:  |  Size: 309 B

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
<path d="M8 3h8"/>
<path d="M10 3v5l-5 9a3 3 0 0 0 2.6 4.5h8.8A3 3 0 0 0 19 17l-5-9V3"/>
<path d="M8 15h8"/>
<path d="M9 19h6"/>
</svg>

After

Width:  |  Height:  |  Size: 323 B

@@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#18A957" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24">
<path d="M7 8h10"/>
<path d="M7 14h10"/>
<path d="M9 20h6"/>
<path d="M6 4h12v4H6z"/>
<path d="M6 8 4 20h16L18 8"/>
<path d="M10 17h4"/>
</svg>

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

@@ -0,0 +1,37 @@
define([
'jquery',
'mage/translate'
], function ($, $t) {
'use strict';
return function (config, element) {
var $button = $(element),
$form = $(config.formSelector || '#product_addtocart_form'),
checkoutUrl = config.checkoutUrl || '/checkout',
defaultText = $.trim($button.text()) || $t('Buy Now');
if (!$form.length) {
return;
}
$button.on('click', function () {
if ($button.prop('disabled')) {
return;
}
if (typeof $form.validation === 'function') {
$form.validation();
if (!$form.validation('isValid')) {
return;
}
}
$button.addClass('disabled').prop('disabled', true).find('span').text($t('Adding...'));
$form.find('input[name="return_url"]').val(checkoutUrl);
$form.trigger('submit');
setTimeout(function () {
$button.removeClass('disabled').prop('disabled', false).find('span').text(defaultText);
}, 3000);
});
};
});
@@ -0,0 +1,304 @@
define([
'jquery'
], function ($) {
'use strict';
return function () {
var priceBoxSelector = '.product-info-main [data-role="priceBox"]',
oldPriceSelector = '.product-info-main .sly-old-price',
discountBadgeSelector = '.product-info-main .esun-price-discount-badge',
swatchSelector = '.swatch-opt',
isSyncing = false,
isApplyingDefaultSelection = false;
function selectFirstAvailableOptions() {
var $productInfo = $('.product-info-main'),
foundControls = false;
if (!$productInfo.length || isApplyingDefaultSelection) {
return false;
}
isApplyingDefaultSelection = true;
$productInfo.find('.swatch-attribute').each(function () {
var $attribute = $(this),
$selected = $attribute.find('.swatch-option.selected').first(),
$firstAvailable;
foundControls = true;
if ($selected.length || $attribute.find('.super-attribute-select').val()) {
return;
}
$firstAvailable = $attribute.find('.swatch-option')
.not('.disabled, [aria-disabled="true"], .esun-out-of-stock-option')
.filter(':visible')
.first();
if (!$firstAvailable.length) {
$firstAvailable = $attribute.find('.swatch-option')
.not('.disabled, [aria-disabled="true"], [data-option-empty="true"]')
.filter(':visible')
.first();
}
if ($firstAvailable.length) {
$firstAvailable.trigger('click');
}
});
$productInfo.find('.super-attribute-select').each(function () {
var $select = $(this),
$firstAvailable;
foundControls = true;
if ($select.closest('.swatch-attribute').length || $select.val()) {
return;
}
$firstAvailable = $select.find('option')
.filter(function () {
return this.value && !this.disabled && !$(this).hasClass('esun-out-of-stock-option');
})
.first();
if (!$firstAvailable.length) {
$firstAvailable = $select.find('option')
.filter(function () {
return this.value && !this.disabled;
})
.first();
}
if ($firstAvailable.length) {
$select.val($firstAvailable.val()).trigger('change');
}
});
isApplyingDefaultSelection = false;
return foundControls;
}
function initializeDefaultSelection() {
[0, 100, 300, 700].forEach(function (delay) {
window.setTimeout(selectFirstAvailableOptions, delay);
});
}
function getSwatchWidget() {
var $swatch = $(swatchSelector);
return $swatch.data('mageSwatchRenderer') || $swatch.data('mage-SwatchRenderer');
}
function getJsonConfig() {
var swatchWidget = getSwatchWidget();
return swatchWidget && swatchWidget.options && swatchWidget.options.jsonConfig;
}
function getSelectedProductIdFromSwatches() {
var jsonConfig = getJsonConfig(),
selectedOptions = {},
matchedProductId = null;
if (!jsonConfig || !jsonConfig.index) {
return null;
}
$('.swatch-attribute').each(function () {
var $attribute = $(this),
attributeId = $attribute.attr('attribute-id') || $attribute.data('attribute-id'),
optionId = $attribute.find('.swatch-option.selected').attr('option-id') ||
$attribute.find('.swatch-option.selected').data('option-id') ||
$attribute.find('.super-attribute-select').val();
if (attributeId && optionId) {
selectedOptions[attributeId] = String(optionId);
}
});
$.each(jsonConfig.index, function (productId, productOptions) {
var isMatch = true;
$.each(selectedOptions, function (attributeId, optionId) {
if (String(productOptions[attributeId]) !== optionId) {
isMatch = false;
return false;
}
});
if (isMatch && Object.keys(selectedOptions).length) {
matchedProductId = productId;
return false;
}
});
return matchedProductId;
}
function getSelectedProductId() {
var selectedProduct = $('[name="selected_configurable_option"]').val(),
swatchWidget;
if (selectedProduct) {
return selectedProduct;
}
swatchWidget = getSwatchWidget();
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
selectedProduct = swatchWidget.getProductId();
if (selectedProduct) {
return selectedProduct;
}
}
return getSelectedProductIdFromSwatches();
}
function hasCompleteSwatchSelection() {
var $attributes = $('.swatch-attribute');
if (!$attributes.length) {
return false;
}
return $attributes.filter(function () {
return $(this).find('.swatch-option.selected').length ||
$(this).find('.super-attribute-select').val();
}).length === $attributes.length;
}
function shouldShowOldPrice() {
return Boolean(getSelectedProductId() || hasCompleteSwatchSelection());
}
function getSelectedPrices() {
var selectedProductId = getSelectedProductId(),
jsonConfig = getJsonConfig();
if (!selectedProductId || !jsonConfig || !jsonConfig.optionPrices) {
return null;
}
return jsonConfig.optionPrices[selectedProductId] || null;
}
function getDiscountPercent() {
var prices = getSelectedPrices(),
oldPrice = prices && prices.oldPrice && Number(prices.oldPrice.amount),
finalPrice = prices && prices.finalPrice && Number(prices.finalPrice.amount);
if (!oldPrice || !finalPrice || finalPrice >= oldPrice) {
return null;
}
return Math.round((oldPrice - finalPrice) / oldPrice * 100);
}
function getDiscountBadge($oldPrice) {
var $badge = $(discountBadgeSelector);
if (!$badge.length && $oldPrice.length) {
$badge = $('<span/>', {
'class': 'esun-price-discount-badge',
'aria-hidden': 'true'
});
$oldPrice.after($badge);
}
return $badge;
}
function showDiscountBadge($badge, text) {
if ($badge.text() !== text) {
$badge.text(text);
}
$badge.css('display', 'inline-flex').show();
}
function syncOldPriceState() {
var $oldPrice = $(oldPriceSelector),
$badge = getDiscountBadge($oldPrice),
discountPercent = getDiscountPercent();
if (isSyncing) {
return;
}
isSyncing = true;
if (shouldShowOldPrice()) {
$oldPrice.removeClass('no-display').css('display', 'inline-block').show();
if (discountPercent) {
showDiscountBadge($badge, discountPercent + '% OFF');
} else {
$badge.hide();
}
isSyncing = false;
return;
}
$oldPrice.hide().addClass('no-display').css('display', 'none');
$badge.hide();
isSyncing = false;
}
function refresh() {
window.setTimeout(syncOldPriceState, 80);
window.setTimeout(syncOldPriceState, 250);
window.setTimeout(syncOldPriceState, 500);
}
function watchPriceBox() {
var productInfo = document.querySelector('.product-info-main'),
observer;
if (!productInfo || !window.MutationObserver) {
return;
}
observer = new MutationObserver(function (mutations) {
var ignoreMutation = Array.prototype.every.call(mutations || [], function (mutation) {
var target = mutation.target;
return target && (
$(target).closest(discountBadgeSelector).length ||
$(target).is(discountBadgeSelector)
);
});
if (ignoreMutation) {
return;
}
if (!isSyncing) {
refresh();
}
});
observer.observe(productInfo, {
attributes: true,
attributeFilter: ['class', 'style'],
childList: true,
subtree: true
});
}
refresh();
watchPriceBox();
initializeDefaultSelection();
$(document).on(
'configurable.initialized.esunDefaultOption swatch.initialized.esunDefaultOption',
initializeDefaultSelection
);
$(document).on(
'click change updatePrice priceUpdated configurable.initialized swatch.initialized',
'.swatch-option, .super-attribute-select, [name="selected_configurable_option"], .price-box, ' + priceBoxSelector,
refresh
);
};
});
@@ -0,0 +1,33 @@
define(['jquery'], function ($) {
'use strict';
return function (config, element) {
$(element).find('.esun-creative-videos__item').each(function () {
var item = this,
video = item.querySelector('video');
if (!video) {
return;
}
item.addEventListener('mouseenter', function () {
video.currentTime = 0;
video.play().catch(function () {});
item.classList.add('is-playing');
});
item.addEventListener('mouseleave', function () {
video.pause();
item.classList.remove('is-playing');
});
item.addEventListener('click', function () {
if (video.paused) {
video.play().catch(function () {});
item.classList.add('is-playing');
} else {
video.pause();
item.classList.remove('is-playing');
}
});
});
};
});
@@ -0,0 +1,129 @@
define(['jquery', 'mage/translate'], function ($, $t) {
'use strict';
return function (config, element) {
var $root = $(element),
items = config.items || [],
archives = config.archives || [],
brands = config.brands || [],
modelsByBrand = config.modelsByBrand || {},
$brand = $root.find('[data-role="spec-brand"]'),
$model = $root.find('[data-role="spec-model"]'),
$count = $root.find('[data-role="spec-count"]'),
$empty = $root.find('[data-role="spec-empty"]'),
$list = $root.find('[data-role="spec-list"]');
function renderBrands() {
$.each(brands, function (_, brandItem) {
$('<option/>', {
value: brandItem.id,
text: brandItem.name
}).appendTo($brand);
});
}
function renderModels() {
var brandId = $brand.val(),
models = brandId ? (modelsByBrand[brandId] || []) : [];
if (!brandId) {
$.each(modelsByBrand, function (_, brandModels) {
$.each(brandModels, function (_, modelName) {
if ($.inArray(modelName, models) === -1) {
models.push(modelName);
}
});
});
models.sort();
}
$model.empty().append($('<option/>', {
value: '',
text: $t('All Models')
}));
$.each(models, function (_, modelName) {
$('<option/>', {
value: modelName,
text: modelName
}).appendTo($model);
});
}
function filterItems() {
var brandId = $brand.val(),
modelName = $model.val(),
results;
if (!brandId && !modelName) {
return archives.slice();
}
results = $.grep(items, function (item) {
return (!brandId || String(item.brand_id) === String(brandId)) &&
(!modelName || item.model_name === modelName);
});
if (brandId) {
results = $.grep(archives, function (archive) {
return String(archive.brand_id) === String(brandId);
}).concat(results);
}
return results;
}
function renderList() {
var results = filterItems();
$count.text(results.length);
$list.empty();
$empty.toggle(results.length === 0);
$list.toggle(results.length > 0);
$.each(results, function (_, item) {
var $item = $('<a/>', {
'class': 'esun-download-specifications__item',
href: item.file_url,
download: item.file_name
}),
$logo = $('<span/>', {'class': 'esun-download-specifications__logo'}),
$body = $('<span/>', {'class': 'esun-download-specifications__body'}),
$meta = $('<span/>', {'class': 'esun-download-specifications__meta'}),
$info = $('<span/>', {'class': 'esun-download-specifications__info'}),
$action = $('<span/>', {'class': 'esun-download-specifications__action'});
if (item.brand_logo_url) {
$('<img/>', {src: item.brand_logo_url, alt: ''}).appendTo($logo);
}
$('<span/>', {'class': 'esun-download-specifications__brand', text: item.brand_name}).appendTo($meta);
if (item.model_name) {
$('<span/>', {'class': 'esun-download-specifications__model', text: item.model_name}).appendTo($meta);
}
$('<strong/>', {text: item.file_name}).appendTo($body);
$('<span/>', {text: item.file_size_label}).appendTo($info);
if (item.file_date) {
$('<span/>', {text: item.file_date}).appendTo($info);
}
$('<span/>', {
'class': 'esun-download-specifications__download-text',
text: $t('Download')
}).appendTo($action);
$('<span/>', {'class': 'esun-download-specifications__download-icon'}).appendTo($action);
$body.prepend($meta).append($info);
$item.append($logo, $body, $action).appendTo($list);
});
}
renderBrands();
renderModels();
renderList();
$brand.on('change', function () {
renderModels();
renderList();
});
$model.on('change', renderList);
};
});
@@ -0,0 +1,16 @@
define(['jquery'], function ($) {
'use strict';
return function (config, element) {
var $root = $(element);
$root.on('click', '[data-download-tab]', function () {
var tab = $(this).data('download-tab');
$root.find('[data-download-tab]').removeClass('is-active');
$(this).addClass('is-active');
$root.find('[data-download-panel]').removeClass('is-active');
$root.find('[data-download-panel="' + tab + '"]').addClass('is-active');
});
};
});
@@ -0,0 +1,55 @@
define(['jquery'], function ($) {
'use strict';
return function (config, element) {
var $scroller = $(element),
isDown = false,
didDrag = false,
startX = 0,
scrollLeft = 0;
$scroller.on('mousedown', function (event) {
isDown = true;
didDrag = false;
startX = event.pageX - $scroller.offset().left;
scrollLeft = $scroller.scrollLeft();
$scroller.addClass('is-dragging');
});
$(document).on('mouseup.esunDragScroll', function () {
isDown = false;
$scroller.removeClass('is-dragging');
});
$scroller.on('mouseleave', function () {
isDown = false;
$scroller.removeClass('is-dragging');
});
$scroller.on('mousemove', function (event) {
var x,
walk;
if (!isDown) {
return;
}
event.preventDefault();
x = event.pageX - $scroller.offset().left;
walk = x - startX;
if (Math.abs(walk) > 4) {
didDrag = true;
}
$scroller.scrollLeft(scrollLeft - walk);
});
$scroller.on('click', 'a, img', function (event) {
if (didDrag) {
event.preventDefault();
event.stopImmediatePropagation();
}
});
};
});
@@ -0,0 +1,28 @@
define(['jquery'], function ($) {
'use strict';
return function (config, element) {
var $root = $(element),
$image = $root.find('[data-role="industry-large-image"]').first();
$root.on('click', '.esun-industry-applications__trigger', function () {
var $trigger = $(this),
imageUrl = $trigger.data('large-image'),
imageAlt = $trigger.data('large-alt') || '';
if (!imageUrl || !$image.length) {
return;
}
$image.attr({
src: imageUrl,
alt: imageAlt
});
$root.find('.esun-industry-applications__trigger')
.removeClass('is-active')
.attr('aria-selected', 'false');
$trigger.addClass('is-active').attr('aria-selected', 'true');
});
};
});
@@ -0,0 +1,50 @@
define(['jquery'], function ($) {
'use strict';
return function (config) {
var options = config.options || {};
function buildGradient(colors) {
var step;
if (!colors || !colors.length) {
return '';
}
if (colors.length === 1) {
return colors[0];
}
step = 100 / colors.length;
return 'conic-gradient(' + $.map(colors, function (color, index) {
return color + ' ' + (index * step) + '% ' + ((index + 1) * step) + '%';
}).join(',') + ')';
}
function applySwatches() {
$.each(options, function (optionId, item) {
var gradient = buildGradient(item.colors || []),
$swatch;
if (!gradient) {
return;
}
$swatch = $('.swatch-attribute.color .swatch-option[option-id="' + optionId + '"], ' +
'.swatch-attribute.color .swatch-option[data-option-id="' + optionId + '"]');
$swatch
.addClass('esun-multi-color-swatch')
.css({
'background': gradient,
'background-image': gradient
});
});
}
applySwatches();
$(document).on('swatch.initialized configurable.initialized contentUpdated', applySwatches);
setTimeout(applySwatches, 300);
};
});
@@ -0,0 +1,79 @@
define([
'jquery',
'Magento_Catalog/product/view/validation',
'Magento_Customer/js/customer-data'
], function ($, validation, customerData) {
'use strict';
return function (config, element) {
var $form = $(element),
submitting = false,
isMixForm = Boolean($form.find('[data-role="esun-mix-builder"]').length);
if (!$form.length) {
return;
}
function getQtyInput() {
return $form.find('input[name="qty"].input-text.qty, input[name="qty"]').first();
}
function normalizeQty() {
var $input = getQtyInput(),
min = parseFloat($input.attr('min')) || 1,
val = parseFloat($input.val());
if ($input.length && (isNaN(val) || val < min)) {
$input.val(min).trigger('change');
}
}
if (!isMixForm) {
$form.on('input keyup change blur', 'input[name="qty"]', normalizeQty);
normalizeQty();
}
$form.validation({
radioCheckboxClosest: config.radioCheckboxClosest || '.nested',
submitHandler: function (form) {
var cartData;
if (submitting) {
return true;
}
if (!isMixForm) {
normalizeQty();
}
try {
window.sessionStorage.setItem('esunGtmPendingAddToCart', '1');
} catch (error) {
// The add-to-cart submission must still work when storage is unavailable.
}
try {
cartData = customerData.get('cart')();
if (cartData && typeof cartData.summary_count !== 'undefined') {
window.sessionStorage.setItem('esunOpenMinicartAfterAdd', '1');
window.sessionStorage.setItem(
'esunCartCountBeforeAdd',
String(Number(cartData.summary_count) || 0)
);
} else {
window.sessionStorage.removeItem('esunOpenMinicartAfterAdd');
window.sessionStorage.removeItem('esunCartCountBeforeAdd');
}
} catch (error) {
// The add-to-cart submission must still work when storage is unavailable.
}
submitting = true;
form.submit();
return false;
}
});
if (!isMixForm) {
$(config.addToCartButtonSelector || '.action.tocart').attr('disabled', false);
}
};
});
@@ -0,0 +1,117 @@
define([], function () {
'use strict';
return function (config, element) {
var slider = element.querySelector('.esun-recommended-products__slider'),
wrapper = element.querySelector('.esun-recommended-products__wrapper'),
previous = element.querySelector('.esun-recommended-products__previous'),
next = element.querySelector('.esun-recommended-products__next'),
pointerId = null,
startX = 0,
startScrollLeft = 0,
dragged = false,
pointerNavigation = null;
if (!slider || !wrapper || !previous || !next) {
return;
}
function getMaxScroll() {
return Math.max(0, slider.scrollWidth - slider.clientWidth);
}
function getStep() {
var firstItem = wrapper.querySelector('.esun-recommended-products__item'),
styles = window.getComputedStyle(wrapper),
gap = parseFloat(styles.columnGap || styles.gap) || 0;
return firstItem ? firstItem.getBoundingClientRect().width + gap : slider.clientWidth;
}
function updateNavigation() {
var maxScroll = getMaxScroll(),
atStart = slider.scrollLeft <= 1,
atEnd = slider.scrollLeft >= maxScroll - 1;
previous.disabled = atStart;
next.disabled = atEnd;
previous.classList.toggle('is-disabled', atStart);
next.classList.toggle('is-disabled', atEnd);
element.classList.toggle('has-overflow', maxScroll > 1);
}
function scroll(direction) {
slider.scrollBy({
left: direction * getStep(),
behavior: 'smooth'
});
}
function bindNavigation(button, direction) {
button.addEventListener('pointerdown', function (event) {
if (event.button !== 0) {
return;
}
pointerNavigation = button;
scroll(direction);
}, true);
button.addEventListener('click', function () {
if (pointerNavigation === button) {
pointerNavigation = null;
return;
}
scroll(direction);
});
}
bindNavigation(previous, -1);
bindNavigation(next, 1);
slider.addEventListener('scroll', updateNavigation, {passive: true});
slider.addEventListener('keydown', function (event) {
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
event.preventDefault();
scroll(event.key === 'ArrowLeft' ? -1 : 1);
}
});
slider.addEventListener('pointerdown', function (event) {
if (event.pointerType === 'touch' || event.button !== 0 ||
event.target.closest('button, input, select, textarea')) {
return;
}
pointerId = event.pointerId;
startX = event.clientX;
startScrollLeft = slider.scrollLeft;
dragged = false;
slider.setPointerCapture(pointerId);
slider.classList.add('is-dragging');
});
slider.addEventListener('pointermove', function (event) {
if (event.pointerId !== pointerId) {
return;
}
if (Math.abs(event.clientX - startX) > 4) {
dragged = true;
}
slider.scrollLeft = startScrollLeft - (event.clientX - startX);
});
slider.addEventListener('pointerup', function (event) {
if (event.pointerId === pointerId) {
slider.releasePointerCapture(pointerId);
pointerId = null;
slider.classList.remove('is-dragging');
}
});
slider.addEventListener('click', function (event) {
if (dragged) {
event.preventDefault();
event.stopPropagation();
dragged = false;
}
}, true);
window.addEventListener('resize', updateNavigation);
window.requestAnimationFrame(updateNavigation);
};
});
@@ -0,0 +1,88 @@
define([
'jquery'
], function ($) {
'use strict';
return function (config, element) {
var $campaign = $(element),
items = config.items || {},
activeItem = null,
activeStartedAt = Date.now(),
timer = null;
function getFirstItem() {
var firstKey = Object.keys(items)[0];
return firstKey ? items[firstKey] : null;
}
function getSelectedProductId() {
var selectedId = $('[name="selected_configurable_option"]').val(),
swatchWidget;
if (selectedId && items[selectedId]) {
return selectedId;
}
swatchWidget = $('.swatch-opt').data('mageSwatchRenderer');
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
selectedId = swatchWidget.getProductId();
if (selectedId && items[selectedId]) {
return selectedId;
}
}
return null;
}
function pad(value) {
return value < 10 ? '0' + value : value;
}
function renderCountdown() {
var distance;
if (!activeItem || typeof activeItem.remainingMs === 'undefined') {
return;
}
distance = Math.max(0, activeItem.remainingMs - (Date.now() - activeStartedAt));
$campaign.find('[data-role="campaign-days"]').text(Math.floor(distance / 86400000));
$campaign.find('[data-role="campaign-hours"]').text(pad(Math.floor((distance % 86400000) / 3600000)));
$campaign.find('[data-role="campaign-minutes"]').text(pad(Math.floor((distance % 3600000) / 60000)));
$campaign.find('[data-role="campaign-seconds"]').text(pad(Math.floor((distance % 60000) / 1000)));
}
function renderItem(item) {
if (!item) {
$campaign.hide();
activeItem = null;
return;
}
activeItem = item;
activeStartedAt = Date.now();
$campaign.show();
renderCountdown();
}
function refresh() {
var selectedId = getSelectedProductId();
renderItem(selectedId ? items[selectedId] : getFirstItem());
}
refresh();
timer = window.setInterval(renderCountdown, 1000);
$(document).on('change click updatePrice configurable.initialized', '.super-attribute-select, .swatch-option, [name="selected_configurable_option"], .price-box', function () {
window.setTimeout(refresh, 50);
});
$campaign.on('remove', function () {
if (timer) {
window.clearInterval(timer);
}
});
};
});
@@ -0,0 +1,479 @@
define(["jquery", "mage/translate"], function ($, $t) {
"use strict";
return function (config) {
var sourceSelector = config.sourceSelector || ".box-tocart",
priceSelector =
config.priceSelector || '[data-role="purchase-final-total"]',
addToCartSelector =
config.addToCartSelector || "#product-addtocart-button",
buyNowSelector =
config.buyNowSelector || '[data-role="esun-buy-now"]',
anchorScopeSelector = config.anchorScopeSelector || ".column.main",
detailContentSelector =
config.detailContentSelector || ".esun-product-detail-content",
anchorsConfig = config.anchors || [],
activeClass = "esun-sticky-product-bar--active",
bodyActiveClass = "esun-sticky-product-bar-active",
$source = $(sourceSelector).first(),
hasPurchaseActions = $source.length > 0,
$window = $(window),
$body = $("body"),
$bar = $(),
$inlineBar = $(),
$nav = $(),
$inlineNav = $(),
$topBar = $(), // <-- 新增
$bottomBar = $(), // <-- 新增
sourceTop = 0,
sourceTopBottom = 0, // 新增:底部栏触发点
ticking = false,
resizeTimer;
function normalizeText(text) {
return $.trim(
String(text || "").replace(/\s+/g, " "),
).toLowerCase();
}
function slugify(text) {
return (
normalizeText(text)
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-|-$/g, "") || "section"
);
}
function getTriggerTop() {
var $trigger = $inlineBar.length ? $inlineBar : $source;
if (!$trigger.length) {
return 0;
}
return Math.max(0, $trigger.offset().top);
}
function isUsableTarget($target) {
return (
$target.length &&
!$target.closest('[data-role="esun-sticky-product-bar"]')
.length &&
!$target.closest('[data-role="esun-detail-product-bar"]')
.length &&
$.trim($target.text()).length > 0 &&
($target.outerHeight() > 0 ||
$target.find("img, video, iframe").length > 0)
);
}
function findBySelectors(selectors) {
var i, $target;
for (i = 0; i < selectors.length; i++) {
$target = $(selectors[i]).first();
if (isUsableTarget($target)) {
return $target;
}
}
return $();
}
function findByHeading(aliases) {
var normalizedAliases = $.map(aliases || [], normalizeText),
$scope = $(anchorScopeSelector).first(),
$match = $();
if (!$scope.length || !normalizedAliases.length) {
return $match;
}
$scope
.find(
'h1, h2, h3, h4, .product-section-title, [data-content-type="heading"]',
)
.each(function () {
var $heading = $(this),
text = normalizeText($heading.text()),
$section;
if (
$match.length ||
$.inArray(text, normalizedAliases) === -1
) {
return;
}
$section = $heading.closest(
'[data-content-type="row"], section, .block, .product-info-detailed, .product.attribute',
);
$match = $section.length ? $section : $heading;
});
return $match;
}
function ensureTargetId($target, label, index) {
var id = $target.attr("id");
if (!id) {
id = "esun-product-section-" + slugify(label) + "-" + index;
$target.attr("id", id);
}
$target.addClass("esun-product-anchor-target");
return id;
}
function buildAnchors() {
var found = [];
var excludeLabels = ["Industry Applications"];
$.each(anchorsConfig, function (index, item) {
if (excludeLabels.indexOf(item.label) !== -1) {
return;
}
var $target = findBySelectors(item.selectors || []);
if (!isUsableTarget($target)) {
$target = findByHeading(item.aliases || [item.label]);
}
if (!isUsableTarget($target)) {
return;
}
found.push({
label: item.label,
id: ensureTargetId($target, item.label, index),
});
});
$nav.add($inlineNav).empty();
$.each(found, function (index, item) {
var $link = $("<a/>", {
class: "esun-product-anchor-nav__link",
href: "#" + item.id,
text: item.label,
});
$link.clone().appendTo($nav);
$link.appendTo($inlineNav);
});
$bar.add($inlineBar).toggleClass(
"esun-sticky-product-bar--no-anchors",
!found.length,
);
}
function syncPrice() {
var price = $.trim($(priceSelector).first().text()),
$prices = $bar
.add($inlineBar)
.find('[data-role="esun-sticky-product-price"]');
if (!price) {
price = $.trim(
$(
".product-info-main .price-box .special-price .price, .product-info-main .price-box .price",
)
.first()
.text(),
);
}
$prices.each(function () {
var $price = $(this);
if ($price.text() !== price) {
$price.text(price);
}
});
}
function syncButtonState() {
var $addToCart = $(addToCartSelector).first(),
disabled =
$addToCart.prop("disabled") ||
$addToCart.hasClass("disabled"),
$stickyAddToCart = $bar
.add($inlineBar)
.find('[data-role="esun-sticky-add-to-cart"]');
if ($stickyAddToCart.prop("disabled") !== disabled) {
$stickyAddToCart.prop("disabled", disabled);
}
if ($stickyAddToCart.hasClass("disabled") !== disabled) {
$stickyAddToCart.toggleClass("disabled", disabled);
}
}
function syncActiveAnchor() {
var stickyHeight = $bar.outerHeight() || 0,
scrollTop = $window.scrollTop(),
activeId = "";
$nav.find("a").each(function () {
var id = $(this).attr("href").replace("#", ""),
$target = $("#" + $.escapeSelector(id));
if (
$target.length &&
$target.offset().top - stickyHeight - 20 <= scrollTop
) {
activeId = id;
}
});
$nav.add($inlineNav).find("a").removeClass("is-active");
if (activeId) {
$nav.add($inlineNav)
.find('a[href="#' + activeId + '"]')
.addClass("is-active");
}
}
function updateSticky() {
var scrollTop = $window.scrollTop();
var shouldStickTop = scrollTop >= sourceTop;
var shouldStickBottom = scrollTop >= sourceTopBottom;
// 分别控制顶部和底部
$topBar.toggleClass(activeClass, shouldStickTop);
$bottomBar.toggleClass(activeClass, shouldStickBottom);
// body 类:只要有一个显示就添加(用于全局样式调整)
$body.toggleClass(
bodyActiveClass,
shouldStickTop || shouldStickBottom,
);
// 顶部锚点高亮(依然基于顶部导航)
syncActiveAnchor();
ticking = false;
}
function requestUpdate() {
if (!ticking) {
ticking = true;
window.requestAnimationFrame(updateSticky);
}
}
function refreshOffsets() {
sourceTop = getTriggerTop();
// 底部触发点:基于 .esun-product-details
var $customTrigger = $(".esun-product-details").first();
if ($customTrigger.length) {
sourceTopBottom = Math.max(0, $customTrigger.offset().top);
} else {
// 如果没找到该元素,则回退到顶部触发点或 0(根据需求可改为 0)
sourceTopBottom = sourceTop;
}
//sourceTop = getTriggerTop();
var bottomHeight = $bottomBar.length ? $bottomBar.outerHeight() : 0;
$body.css("padding-bottom", bottomHeight + "px");
$body.css(
"--esun-sticky-product-bar-height",
($topBar.outerHeight() || 0) + "px",
);
requestUpdate();
}
function createProductBar(className, role) {
var $productBar = $("<div/>", {
class: className,
"data-role": role,
});
// $('<div/>', {'class': 'esun-sticky-product-bar__actions'})
// .append($('<strong/>', {
// 'class': 'esun-sticky-product-bar__price',
// 'data-role': 'esun-sticky-product-price'
// }))
// .append($('<button/>', {
// 'type': 'button',
// 'class': 'action primary tocart esun-sticky-product-bar__add',
// 'data-role': 'esun-sticky-add-to-cart',
// 'text': $t('Add to Cart')
// }))
// .append($('<button/>', {
// 'type': 'button',
// 'class': 'action primary esun-buy-now esun-sticky-product-bar__buy',
// 'data-role': 'esun-sticky-buy-now',
// 'text': $t('Buy Now')
// }))
// .appendTo($productBar);
$("<nav/>", {
class: "esun-product-anchor-nav",
"data-role": "esun-product-anchor-nav",
"aria-label": $t("Product detail sections"),
}).appendTo($productBar);
return $productBar;
}
function createStickyBar() {
// ----- 顶部 Bar(仅导航)-----
$topBar = $("<div/>", {
class: "esun-sticky-product-bar esun-sticky-product-bar--top",
"data-role": "esun-sticky-product-bar-top",
});
$nav = $("<nav/>", {
class: "esun-product-anchor-nav",
"data-role": "esun-product-anchor-nav",
"aria-label": $t("Product detail sections"),
}).appendTo($topBar);
$topBar.appendTo(document.body);
if (!hasPurchaseActions) {
$bar = $topBar;
return;
}
// ----- 底部 Bar(仅操作按钮)-----
$bottomBar = $("<div/>", {
class: "esun-sticky-product-bar esun-sticky-product-bar--bottom",
"data-role": "esun-sticky-product-bar-bottom",
});
var $actions = $("<div/>", {
class: "esun-sticky-product-bar__actions",
});
$actions
.append(
$("<strong/>", {
class: "esun-sticky-product-bar__price",
"data-role": "esun-sticky-product-price",
}),
)
.append(
$("<button/>", {
type: "button",
class: "action primary tocart esun-sticky-product-bar__add",
"data-role": "esun-sticky-add-to-cart",
text: $t("Add to Cart"),
}),
)
.append(
$("<button/>", {
type: "button",
class: "action primary esun-buy-now esun-sticky-product-bar__buy",
"data-role": "esun-sticky-buy-now",
text: $t("Buy Now"),
}),
);
$bottomBar.append($actions).appendTo(document.body);
$bar = $topBar.add($bottomBar);
}
function createInlineBar() {
var $detailContent = $(detailContentSelector).first();
if (!$detailContent.length) {
return;
}
$inlineBar = createProductBar(
"esun-detail-product-bar",
"esun-detail-product-bar",
);
$inlineNav = $inlineBar.find(
'[data-role="esun-product-anchor-nav"]',
);
$inlineBar.prependTo($detailContent);
}
createStickyBar();
createInlineBar();
buildAnchors();
syncPrice();
syncButtonState();
refreshOffsets();
$bar.add($inlineBar).on(
"click",
'[data-role="esun-sticky-add-to-cart"]',
function () {
$(addToCartSelector).first().trigger("click");
},
);
$bar.add($inlineBar).on(
"click",
'[data-role="esun-sticky-buy-now"]',
function () {
$(buyNowSelector).first().trigger("click");
},
);
$bar.add($inlineBar).on(
"click",
".esun-product-anchor-nav__link",
function (event) {
var id = $(this).attr("href").replace("#", ""),
$target = $("#" + $.escapeSelector(id)),
top;
if (!$target.length) {
return;
}
event.preventDefault();
top = Math.max(
0,
$target.offset().top - ($bar.outerHeight() || 0) - 16,
);
$("html, body").animate({ scrollTop: top }, 240);
},
);
$window.on("scroll", requestUpdate);
$window.on("resize", function () {
window.clearTimeout(resizeTimer);
resizeTimer = window.setTimeout(function () {
refreshOffsets();
buildAnchors();
}, 120);
});
$(document).on(
"input change",
'#qty, .super-attribute-select, [name="selected_configurable_option"]',
function () {
window.setTimeout(function () {
syncPrice();
syncButtonState();
refreshOffsets();
}, 80);
},
);
if (window.MutationObserver) {
new window.MutationObserver(function () {
syncPrice();
syncButtonState();
}).observe(document.body, {
childList: true,
subtree: true,
characterData: true,
attributes: true,
attributeFilter: ["disabled", "class"],
});
}
window.setTimeout(function () {
buildAnchors();
refreshOffsets();
}, 800);
};
});
@@ -0,0 +1,122 @@
define([
'jquery',
'Magento_Customer/js/customer-data',
'mage/translate',
'mage/cookies'
], function ($, customerData, $t) {
'use strict';
return function (config, element) {
var $button = $(element),
pending = false;
function setActive(active) {
var label = active ? $t('Added to Wish List') : $t('Add to Wish List');
$button
.toggleClass('is-active', active)
.attr({
'aria-label': label,
'aria-pressed': active ? 'true' : 'false',
title: label
});
$button.find('.iconfont')
.toggleClass('icon-favorite5', active)
.toggleClass('icon-favorite6', !active);
$button.find('.esun-product-wishlist__label').text(label);
}
function showError(message) {
customerData.set('messages', {
messages: [{
type: 'error',
text: message
}]
});
}
function refreshActiveState() {
if (!config.statusUrl || !config.productId) {
return;
}
$.getJSON(config.statusUrl, {
product_id: config.productId,
_: Date.now()
}).done(function (response) {
setActive(response && response.active === true);
});
}
function addToWishlist(event) {
var params,
requestData;
event.preventDefault();
event.stopImmediatePropagation();
if (pending || $button.hasClass('is-active')) {
return;
}
// Magento's addToWishlist widget keeps data-post in sync with the
// selected configurable, bundle, custom-option and quantity values.
params = $button.data('post');
if (!params || !params.action || !params.data) {
showError($t('Unable to add this product to your wish list.'));
return;
}
requestData = $.extend({}, params.data, {
form_key: $.mage.cookies.get('form_key')
});
// The mix builder intentionally keeps the cart quantity at zero
// until variants are selected. Wishlist quantity is independent
// and must never submit that zero value.
requestData.qty = Math.max(1, parseInt(requestData.qty, 10) || 1);
pending = true;
$button.addClass('is-loading').attr('aria-busy', 'true');
$.ajax({
url: params.action,
type: 'POST',
data: requestData,
dataType: 'json'
}).done(function () {
$button
.removeClass('is-loading')
.attr('aria-busy', 'false');
setActive(true);
customerData.invalidate(['wishlist']);
customerData.reload(['wishlist'], true);
refreshActiveState();
}).fail(function (xhr) {
var responseUrl = xhr.responseURL || '';
$button.removeClass('is-loading').attr('aria-busy', 'false');
// A guest AJAX request follows Magento's login redirect and then
// fails JSON parsing with a final HTTP 200 response.
if (xhr.status === 200 || xhr.status === 401 ||
responseUrl.indexOf('/customer/account/login') !== -1) {
window.location.href = config.loginUrl;
return;
}
showError($t('Unable to add this product to your wish list. Please try again.'));
}).always(function () {
pending = false;
});
}
// Capture the click before Magento's data-post handler can turn it into
// a normal form submission. Option-change handlers still update data-post.
// The product-specific endpoint is authoritative. Customer-data can be
// stale during page initialization and must not turn an active heart
// back into an outline.
refreshActiveState();
element.addEventListener('click', addToWishlist, true);
};
});
@@ -0,0 +1,660 @@
define([
'jquery',
'Magento_Catalog/js/price-utils',
'Magento_Customer/js/customer-data',
'mage/translate'
], function ($, priceUtils, customerData) {
'use strict';
return function (config, element) {
var $progress = $(element),
products = config.products || {},
priceFormat = config.priceFormat || {},
activeProductId = config.defaultProductId,
swatchSelector = '.swatch-opt',
qtySelector = '#qty',
totalSelector = '.esun-purchase-total',
cartState = customerData.get('cart')() || {},
mixCartHydrated = false,
mixUserEdited = false,
hasExistingMixItems = false;
function getMixMilestones() {
var mix = config.mix || {},
milestones = [];
$.each(mix.tiers || [], function (_, tier) {
milestones.push({
type: tier.price_type === 'fixed' ? 'fixed' : 'percent',
qty: parseInt(tier.qty, 10),
value: Number(tier.value),
displayValue: Number(tier.display_value)
});
});
milestones.sort(function (left, right) {
return left.qty - right.qty;
});
return milestones;
}
function getActiveMixTier(quantity) {
var active = null;
$.each((config.mix || {}).tiers || [], function (_, tier) {
if (quantity >= parseInt(tier.qty, 10)) {
active = tier;
}
});
return active;
}
function getMixUnitPrice(basePrice, tier) {
if (!tier) {
return basePrice;
}
if (tier.price_type === 'fixed') {
return Math.min(basePrice, Number(tier.display_value));
}
return basePrice * (1 - Number(tier.value) / 100);
}
function getMixTierLabel(tier) {
if (!tier) {
return '';
}
return tier.price_type === 'fixed'
? formatPrice(Number(tier.display_value))
: Number(tier.value) + '% ' + $.mage.__('off');
}
function renderMixMilestones(quantity) {
var milestones = getMixMilestones(),
$steps = $progress.find('[data-role="progress-steps"]'),
percent = getProgressPercent(milestones, quantity);
$progress.find('[data-role="progress-track"]').css('--esun-progress-width', percent + '%');
$steps.empty();
$.each(milestones, function (_, milestone) {
var active = quantity >= milestone.qty,
$step = $('<div/>', {
'class': 'esun-purchase-progress__step' + (active ? ' is-active' : '')
}),
value = milestone.type === 'fixed'
? formatPrice(milestone.displayValue)
: milestone.value + '% ' + $.mage.__('off');
$step.append(
$('<span/>', {'class': 'esun-purchase-progress__marker'}),
$('<span/>', {'class': 'esun-purchase-progress__value'}).text(value),
$('<span/>', {'class': 'esun-purchase-progress__label'}).text(
milestone.qty + ' ' + $.mage.__('pcs')
)
);
$steps.append($step);
});
}
function renderMix() {
var quantity = 0,
selectedVariants = 0,
baseTotal = 0,
finalTotal = 0,
activeTier,
nextTier = null,
$builder = $('[data-role="esun-mix-builder"]'),
$button = $('#product-addtocart-button');
$builder.find('[data-role="mix-item-qty"]').each(function () {
var $input = $(this),
itemQuantity = Math.max(0, parseInt($input.val(), 10) || 0),
basePrice = Number($input.attr('data-base-price'));
$input.val(itemQuantity);
quantity += itemQuantity;
selectedVariants += itemQuantity > 0 ? 1 : 0;
baseTotal += basePrice * itemQuantity;
});
activeTier = getActiveMixTier(quantity);
$builder.find('[data-role="mix-item-qty"]').each(function () {
var $input = $(this),
itemQuantity = parseInt($input.val(), 10) || 0,
basePrice = Number($input.attr('data-base-price')),
unitPrice = getMixUnitPrice(basePrice, activeTier);
finalTotal += unitPrice * itemQuantity;
});
$.each((config.mix || {}).tiers || [], function (_, tier) {
if (nextTier === null && quantity < parseInt(tier.qty, 10)) {
nextTier = tier;
}
});
renderMixMilestones(quantity);
if (nextTier) {
$progress.find('[data-role="mix-message"]').text(
$.mage.__('Add') + ' ' + (parseInt(nextTier.qty, 10) - quantity) + ' ' +
$.mage.__('more to unlock') + ' ' + getMixTierLabel(nextTier)
);
} else if (activeTier) {
$progress.find('[data-role="mix-message"]').text(
$.mage.__('Unlocked:') + ' ' + getMixTierLabel(activeTier)
);
}
$builder.find('[data-role="mix-selection-summary"]').text(
quantity > 0
? selectedVariants + ' ' + $.mage.__('colors') + ' · ' + quantity + ' ' + $.mage.__('items')
: $.mage.__('Choose a color, then set its quantity.')
);
$builder.find('[data-role="mix-final-total"]').text(formatPrice(finalTotal));
$builder.find('[data-role="mix-base-total"]')
.text(baseTotal > finalTotal + 0.0001 ? formatPrice(baseTotal) : '')
.toggle(baseTotal > finalTotal + 0.0001);
$button.prop('disabled', quantity <= 0).find('span').text(
quantity > 0
? (hasExistingMixItems ? $.mage.__('Update') : $.mage.__('Add')) + ' ' +
selectedVariants + ' ' + $.mage.__('variants') +
' (' + quantity + ' ' + $.mage.__('items') + ')'
: $.mage.__('Add Mix to Cart')
);
renderMixQuantityBadges();
}
function initializeMixBuilder() {
var $form = $progress.closest('form'),
$builder = $('[data-role="esun-mix-builder"]'),
$qty = $form.find(qtySelector);
$form.attr('action', config.mixAddUrl).attr('data-esun-mix-form', '1');
$('.product-info-main').addClass('is-mix-pricing');
function updateSelectedColorQuantity() {
var productId = getSelectedMixProductId(),
quantity = Math.max(0, parseInt($qty.val(), 10) || 0),
$input;
if (!productId) {
$qty.val(0);
return;
}
mixUserEdited = true;
$input = getMixQuantityInput(productId);
$qty.val(quantity);
$input.val(quantity).attr('data-configured', '1');
renderMix();
}
function refreshSelectedColor() {
window.setTimeout(syncSharedMixQuantity, 0);
window.setTimeout(syncSharedMixQuantity, 100);
window.setTimeout(syncSharedMixQuantity, 250);
}
$qty.on('input.esunMix change.esunMix', updateSelectedColorQuantity);
customerData.get('cart').subscribe(function (cart) {
cartState = cart || {};
syncMixBuilderFromCart();
});
$(document).on('esun:cartUpdated.esunMixProgress', function (_, cart) {
cartState = cart || {};
syncMixBuilderFromCart();
});
$form.on(
'click.esunMix change.esunMix configurable.initialized.esunMix swatch.initialized.esunMix',
'.swatch-option, .super-attribute-select, [name="selected_configurable_option"]',
refreshSelectedColor
);
syncMixBuilderFromCart();
refreshSelectedColor();
}
function syncMixBuilderFromCart() {
var cartQuantities,
$builder;
if (mixUserEdited) {
renderMixQuantityBadges();
return;
}
cartQuantities = getCartMixQuantities();
$builder = $('[data-role="esun-mix-builder"]');
hasExistingMixItems = Object.keys(cartQuantities).length > 0;
mixCartHydrated = true;
$builder.find('[data-role="mix-mode"]').val('sync');
$builder.find('[data-role="mix-item-qty"]').each(function () {
var $input = $(this),
productId = String($input.attr('data-child-id'));
$input.val(cartQuantities[productId] || 0).attr('data-configured', '1');
});
renderMix();
window.setTimeout(syncSharedMixQuantity, 0);
}
function getMixQuantityInput(productId) {
return $('[data-role="esun-mix-builder"] [data-role="mix-item-qty"][data-child-id="' +
String(productId) + '"]');
}
function getSelectedMixProductId() {
var selectedProduct = $progress.closest('form').find('[name="selected_configurable_option"]').val(),
swatchWidget = getSwatchWidget(),
widgetProductId;
if (selectedProduct && getMixQuantityInput(selectedProduct).length) {
return String(selectedProduct);
}
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
widgetProductId = swatchWidget.getProductId();
if (widgetProductId && getMixQuantityInput(widgetProductId).length) {
return String(widgetProductId);
}
}
return getExactProductIdFromOptions();
}
function getExactProductIdFromOptions() {
var jsonConfig = getJsonConfig(),
selectedOptions = {},
attributeCount = 0,
matchedProductId = null;
if (!jsonConfig || !jsonConfig.index) {
return null;
}
$progress.closest('form')
.find('.swatch-attribute[data-attribute-id], .swatch-attribute[attribute-id]')
.each(function () {
var $attribute = $(this),
attributeId = String(
$attribute.attr('data-attribute-id') || $attribute.attr('attribute-id') || ''
),
optionId = $attribute.find('.swatch-option.selected').attr('data-option-id') ||
$attribute.find('.swatch-option.selected').attr('option-id') ||
$attribute.find('.super-attribute-select').val();
attributeCount += 1;
if (optionId) {
selectedOptions[attributeId] = String(optionId);
}
});
if (!attributeCount || Object.keys(selectedOptions).length !== attributeCount) {
return null;
}
$.each(jsonConfig.index, function (productId, productOptions) {
var isMatch = true;
$.each(selectedOptions, function (attributeId, optionId) {
if (String(productOptions[attributeId]) !== optionId) {
isMatch = false;
return false;
}
});
if (isMatch && getMixQuantityInput(productId).length) {
matchedProductId = String(productId);
return false;
}
});
return matchedProductId;
}
function syncSharedMixQuantity() {
var productId = getSelectedMixProductId(),
$qty = $progress.closest('form').find(qtySelector),
$input = productId ? getMixQuantityInput(productId) : $(),
quantity = 0;
if ($input.length) {
if ($input.attr('data-configured') !== '1') {
$input.val(0).attr('data-configured', '1');
renderMix();
}
quantity = Math.max(0, parseInt($input.val(), 10) || 0);
}
$qty.prop('disabled', !$input.length).val(quantity);
$progress.closest('form').find('.box-tocart .field.qty')
.toggleClass('is-awaiting-color', !$input.length);
renderMixQuantityBadges();
}
function renderMixQuantityBadges() {
var jsonConfig = getJsonConfig(),
$colorAttribute = $progress.closest('form').find('.swatch-attribute.color').first(),
attributeId = String(
$colorAttribute.attr('data-attribute-id') || $colorAttribute.attr('attribute-id') || ''
),
quantitiesByOption = {},
cartQuantities = getCartMixQuantities();
if (!$colorAttribute.length || !attributeId) {
return;
}
$('[data-role="esun-mix-builder"] [data-role="mix-item-qty"]').each(function () {
var $input = $(this),
productId = String($input.attr('data-child-id')),
quantity = Math.max(0, parseInt($input.val(), 10) || 0) +
(mixCartHydrated ? 0 : (cartQuantities[productId] || 0)),
productOptions = $input.data('options') ||
(jsonConfig && jsonConfig.index ? jsonConfig.index[productId] : {}) || {},
optionId = productOptions[attributeId];
if (quantity > 0 && typeof optionId !== 'undefined') {
optionId = String(optionId);
quantitiesByOption[optionId] = (quantitiesByOption[optionId] || 0) + quantity;
}
});
$colorAttribute.find('.swatch-option').each(function () {
var $option = $(this),
optionId = String(
$option.attr('data-option-id') || $option.attr('option-id') || ''
),
quantity = quantitiesByOption[optionId] || 0;
$option.find('.esun-mix-qty-badge').remove();
if (!quantity) {
$option.removeAttr('data-mix-qty');
return;
}
$option.attr('data-mix-qty', quantity);
});
}
function getCartMixQuantities() {
var cart = cartState,
parentId = Number((config.mix || {}).parentId || 0),
quantities = {};
$.each(cart.items || [], function (_, item) {
var itemParentId = Number(item.parent_product_id || item.product_id || 0),
childId = String(item.child_product_id || ''),
quantity = Math.max(0, Number(item.qty) || 0);
if (itemParentId === parentId && childId && quantity > 0) {
quantities[childId] = (quantities[childId] || 0) + quantity;
}
});
return quantities;
}
function getSwatchWidget() {
var $swatch = $progress.closest('form').find(swatchSelector);
return $swatch.data('mageSwatchRenderer') || $swatch.data('mage-SwatchRenderer');
}
function getJsonConfig() {
var swatchWidget = getSwatchWidget();
return swatchWidget && swatchWidget.options && swatchWidget.options.jsonConfig;
}
function getSelectedProductIdFromSwatches() {
var jsonConfig = getJsonConfig(),
selectedOptions = {},
matchedProductId = null;
if (!jsonConfig || !jsonConfig.index) {
return null;
}
$progress.closest('form').find('.swatch-attribute').each(function () {
var $attribute = $(this),
attributeId = $attribute.attr('data-attribute-id') ||
$attribute.attr('attribute-id') || $attribute.data('attribute-id'),
optionId = $attribute.find('.swatch-option.selected').attr('data-option-id') ||
$attribute.find('.swatch-option.selected').attr('option-id') ||
$attribute.find('.swatch-option.selected').data('option-id') ||
$attribute.find('.super-attribute-select').val();
if (attributeId && optionId) {
selectedOptions[attributeId] = String(optionId);
}
});
$.each(jsonConfig.index, function (productId, productOptions) {
var isMatch = true;
$.each(selectedOptions, function (attributeId, optionId) {
if (String(productOptions[attributeId]) !== optionId) {
isMatch = false;
return false;
}
});
if (isMatch && Object.keys(selectedOptions).length) {
matchedProductId = productId;
return false;
}
});
return matchedProductId;
}
function getSelectedProductId() {
var selectedProduct = $progress.closest('form').find('[name="selected_configurable_option"]').val(),
swatchWidget;
if (selectedProduct && products[selectedProduct]) {
return selectedProduct;
}
swatchWidget = getSwatchWidget();
if (swatchWidget && typeof swatchWidget.getProductId === 'function') {
selectedProduct = swatchWidget.getProductId();
if (selectedProduct && products[selectedProduct]) {
return selectedProduct;
}
}
selectedProduct = getSelectedProductIdFromSwatches();
if (selectedProduct && products[selectedProduct]) {
return selectedProduct;
}
return activeProductId;
}
function getQty() {
var $qty = $(qtySelector),
min = parseInt($qty.attr('min'), 10) || 1,
qty = parseInt($qty.val(), 10);
if (!qty || qty < min) {
qty = min;
$qty.val(qty);
}
return qty;
}
function formatPrice(amount) {
return priceUtils.formatPrice(amount, priceFormat);
}
function getMilestones(productConfig) {
var milestones = [];
$.each(productConfig.tiers || [], function (_, tier) {
milestones.push({
type: 'tier',
qty: parseInt(tier.qty, 10),
price: Number(tier.price),
percentage: tier.percentage !== null && typeof tier.percentage !== 'undefined'
? Number(tier.percentage)
: null
});
});
milestones = milestones.filter(function (milestone) {
return milestone.qty > 1;
});
milestones.sort(function (a, b) {
return a.qty - b.qty;
});
return milestones;
}
function getActiveTier(productConfig, qty) {
var activeTier = null;
$.each(productConfig.tiers || [], function (_, tier) {
if (qty >= parseInt(tier.qty, 10)) {
activeTier = tier;
}
});
return activeTier;
}
function getUnitFinalPrice(productConfig, qty) {
return Number(productConfig.finalPrice);
}
function getProgressPercent(milestones, qty) {
var count = milestones.length,
firstQty,
firstPosition,
previous,
current,
previousPosition,
currentPosition,
index,
ratio;
if (!count) {
return 0;
}
firstQty = milestones[0].qty;
firstPosition = 50 / count;
if (qty <= firstQty) {
return Math.max(0, Math.min(firstPosition, qty / firstQty * firstPosition));
}
for (index = 1; index < count; index += 1) {
previous = milestones[index - 1];
current = milestones[index];
if (qty <= current.qty) {
previousPosition = (index - 0.5) / count * 100;
currentPosition = (index + 0.5) / count * 100;
ratio = (qty - previous.qty) / (current.qty - previous.qty);
return previousPosition + ratio * (currentPosition - previousPosition);
}
}
return qty === milestones[count - 1].qty
? (count - 0.5) / count * 100
: 100;
}
function getTotalElement() {
var $total = $(totalSelector),
$qty = $('.box-tocart .field.qty');
if (!$total.length && $qty.length) {
$total = $('<div/>', {
'class': 'esun-purchase-total',
'aria-live': 'polite'
}).append(
$('<strong/>', {'data-role': 'purchase-final-total'}),
$('<span/>', {'data-role': 'purchase-base-total'})
);
$qty.after($total);
}
return $total;
}
function renderMilestones(productConfig, qty) {
var milestones = getMilestones(productConfig),
$steps = $progress.find('[data-role="progress-steps"]'),
percent = getProgressPercent(milestones, qty);
$progress.find('[data-role="progress-track"]').css('--esun-progress-width', percent + '%');
$steps.empty();
$.each(milestones, function (_, milestone) {
var active = qty >= milestone.qty,
$step = $('<div/>', {
'class': 'esun-purchase-progress__step' + (active ? ' is-active' : '')
}),
$marker = $('<span/>', {'class': 'esun-purchase-progress__marker'}),
$value = $('<span/>', {'class': 'esun-purchase-progress__value'}),
$label = $('<span/>', {'class': 'esun-purchase-progress__label'});
$value.text(formatPrice(milestone.price));
$label.text(milestone.qty + ' pcs' +
(milestone.percentage ? ' ' + milestone.percentage + '% off' : ''));
$step.append($marker, $value, $label);
$steps.append($step);
});
$progress.toggle(milestones.length > 0);
}
function renderTotals(productConfig, qty) {
var $total = getTotalElement(),
finalTotal = getUnitFinalPrice(productConfig, qty) * qty,
baseTotal = Number(productConfig.basePrice) * qty;
$total.find('[data-role="purchase-final-total"]').text(formatPrice(finalTotal));
$total.find('[data-role="purchase-base-total"]').text(formatPrice(baseTotal));
$total.toggle(baseTotal > 0);
}
function render() {
var productId = getSelectedProductId(),
productConfig = products[productId] || products[activeProductId],
qty = getQty();
if (!productConfig) {
$progress.hide();
return;
}
activeProductId = productId;
renderMilestones(productConfig, qty);
renderTotals(productConfig, qty);
}
function refresh() {
window.setTimeout(render, 50);
window.setTimeout(render, 250);
}
if (config.mixEnabled && config.mix && (config.mix.items || []).length) {
initializeMixBuilder();
return;
}
render();
$(document).on(
'click change input updatePrice priceUpdated configurable.initialized swatch.initialized',
'.swatch-option, .super-attribute-select, [name="selected_configurable_option"], ' + qtySelector + ', .price-box',
refresh
);
};
});
@@ -0,0 +1,54 @@
define(["jquery"], function ($) {
"use strict";
return function (config, element) {
var $input = $(element),
$form = $input.closest("form");
function getMin() {
var min = parseFloat($input.attr("min"));
return isNaN(min) ? 1 : min;
}
function normalizeQty() {
var min = getMin();
var val = parseFloat($input.val());
if (isNaN(val) || val < min) {
val = min;
}
$input.val(val);
return val;
}
if (!$input.length || !$form.length) {
return;
}
$form.off(".esunQtyStepper", '[data-role="qty-minus"], [data-role="qty-plus"]');
$input.off(".esunQtyStepper");
$form.on("click.esunQtyStepper", '[data-role="qty-minus"]', function () {
var min = getMin();
var val = normalizeQty();
if (val > min) {
$input.val(val - 1).trigger("change");
}
});
$form.on("click.esunQtyStepper", '[data-role="qty-plus"]', function () {
var val = normalizeQty();
$input.val(val + 1).trigger("change");
});
$input.on("input.esunQtyStepper keyup.esunQtyStepper change.esunQtyStepper blur.esunQtyStepper", function () {
normalizeQty();
});
normalizeQty();
};
});
@@ -0,0 +1,121 @@
define([], function () {
'use strict';
return function (config, element) {
var slider = element.querySelector('.esun-recommended-products__slider'),
wrapper = element.querySelector('.esun-recommended-products__wrapper'),
previous = element.querySelector('.esun-recommended-products__previous'),
next = element.querySelector('.esun-recommended-products__next'),
pointerId = null,
startX = 0,
startScrollLeft = 0,
dragged = false,
lastPointerNavigation = 0;
if (!slider || !wrapper || !previous || !next) {
return;
}
function getMaxScroll() {
return Math.max(0, slider.scrollWidth - slider.clientWidth);
}
function getStep() {
var item = wrapper.querySelector('.esun-recommended-products__item'),
styles = window.getComputedStyle(wrapper),
gap = parseFloat(styles.columnGap || styles.gap) || 0;
return item ? item.getBoundingClientRect().width + gap : slider.clientWidth;
}
function updateNavigation() {
var maxScroll = getMaxScroll(),
atStart = slider.scrollLeft <= 1,
atEnd = slider.scrollLeft >= maxScroll - 1;
previous.disabled = atStart;
next.disabled = atEnd;
previous.classList.toggle('is-disabled', atStart);
next.classList.toggle('is-disabled', atEnd);
element.classList.toggle('has-overflow', maxScroll > 1);
}
function move(direction) {
var target = Math.max(0, Math.min(getMaxScroll(), slider.scrollLeft + direction * getStep()));
if (typeof slider.scrollTo === 'function') {
slider.scrollTo({left: target, behavior: 'smooth'});
} else {
slider.scrollLeft = target;
}
}
function bindButton(button, direction) {
button.addEventListener('pointerdown', function (event) {
if (event.button !== 0) {
return;
}
event.preventDefault();
event.stopPropagation();
lastPointerNavigation = Date.now();
move(direction);
}, true);
button.addEventListener('click', function (event) {
event.preventDefault();
event.stopPropagation();
if (Date.now() - lastPointerNavigation > 400) {
move(direction);
}
}, true);
}
bindButton(previous, -1);
bindButton(next, 1);
slider.addEventListener('scroll', updateNavigation, {passive: true});
slider.addEventListener('keydown', function (event) {
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
event.preventDefault();
move(event.key === 'ArrowLeft' ? -1 : 1);
}
});
slider.addEventListener('pointerdown', function (event) {
if (event.pointerType === 'touch' || event.button !== 0 ||
event.target.closest('button, input, select, textarea')) {
return;
}
pointerId = event.pointerId;
startX = event.clientX;
startScrollLeft = slider.scrollLeft;
dragged = false;
slider.setPointerCapture(pointerId);
slider.classList.add('is-dragging');
});
slider.addEventListener('pointermove', function (event) {
if (event.pointerId !== pointerId) {
return;
}
dragged = dragged || Math.abs(event.clientX - startX) > 4;
slider.scrollLeft = startScrollLeft - (event.clientX - startX);
});
slider.addEventListener('pointerup', function (event) {
if (event.pointerId === pointerId) {
slider.releasePointerCapture(pointerId);
pointerId = null;
slider.classList.remove('is-dragging');
}
});
slider.addEventListener('click', function (event) {
if (dragged) {
event.preventDefault();
event.stopPropagation();
dragged = false;
}
}, true);
window.addEventListener('resize', updateNavigation);
window.requestAnimationFrame(updateNavigation);
};
});
@@ -0,0 +1,47 @@
define(['Swiper'], function (Swiper) {
'use strict';
return function (config, element) {
var slider = element.querySelector('.esun-recommended-products__slider');
if (!slider) {
return;
}
new Swiper(slider, {
slidesPerView: 1.08,
spaceBetween: 14,
allowTouchMove: true,
simulateTouch: true,
grabCursor: true,
slidesPerGroup: 1,
speed: 450,
roundLengths: true,
watchOverflow: true,
observer: true,
observeParents: true,
resizeObserver: true,
keyboard: {
enabled: true
},
navigation: {
prevEl: element.querySelector('.esun-recommended-products__previous'),
nextEl: element.querySelector('.esun-recommended-products__next')
},
breakpoints: {
480: {
slidesPerView: 1.35,
spaceBetween: 16
},
768: {
slidesPerView: 1.65,
spaceBetween: 20
},
1200: {
slidesPerView: 2,
spaceBetween: 24
}
}
});
};
});