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,15 @@
<?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_Wiki::css/download-center.css"/>
</head>
<body>
<referenceBlock name="esun.wiki.view">
<block class="Esun\Wiki\Block\Wiki\DownloadCenter"
name="esun.wiki.download.center"
as="download_center"
template="Esun_Wiki::wiki/download-center.phtml"/>
</referenceBlock>
</body>
</page>
@@ -0,0 +1,15 @@
<?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_Wiki::css/parameter-comparison.css"/>
</head>
<body>
<referenceBlock name="esun.wiki.view">
<block class="Esun\Wiki\Block\Wiki\ParameterComparison"
name="esun.wiki.parameter.comparison"
as="parameter_comparison"
template="Esun_Wiki::wiki/parameter-comparison.phtml"/>
</referenceBlock>
</body>
</page>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="esun_wiki_download_center"/>
<update handle="esun_wiki_parameter_comparison"/>
<head>
<css src="Esun_Wiki::css/wiki.css"/>
</head>
<body>
<referenceBlock name="page.main.title" remove="true"/>
<referenceContainer name="content">
<block class="Esun\Wiki\Block\Wiki\View"
name="esun.wiki.view"
template="Esun_Wiki::wiki/view.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="esun_wiki_download_center"/>
<update handle="esun_wiki_parameter_comparison"/>
<head>
<css src="Esun_Wiki::css/wiki.css"/>
</head>
<body>
<referenceBlock name="page.main.title" remove="true"/>
<referenceContainer name="content">
<block class="Esun\Wiki\Block\Wiki\View"
name="esun.wiki.view"
template="Esun_Wiki::wiki/view.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,39 @@
<?php
/** @var \Esun\Wiki\Block\Wiki\DownloadCenter $block */
if (!$block->hasSpecifications()) {
return;
}
?>
<section class="esun-wiki-download-center"
aria-label="<?= $block->escapeHtmlAttr(__('Download Specifications')) ?>">
<div class="esun-download-specifications"
data-mage-init='{"Esun_Wiki/js/download-center":<?= /* @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>
<nav class="esun-download-specifications__pagination"
data-role="spec-pagination"
aria-label="<?= $block->escapeHtmlAttr(__('Download list pagination')) ?>"></nav>
</div>
</section>
@@ -0,0 +1,87 @@
<?php
/** @var \Esun\Wiki\Block\Wiki\ParameterComparison $block */
if (!$block->hasComparisonData()) {
return;
}
$safeConfigJson = str_replace(
['<', '>', '&'],
['\\u003C', '\\u003E', '\\u0026'],
$block->getConfigJson()
);
$baseOptions = $block->getBaseOptions();
?>
<section class="esun-parameter-comparison"
aria-label="<?= $block->escapeHtmlAttr(__('Material Parameter Comparison')) ?>">
<div class="esun-parameter-comparison__app"
data-mage-init='{"Esun_Wiki/js/parameter-comparison":{}}'>
<script type="application/json" data-role="parameter-config"><?= /* @noEscape */ $safeConfigJson ?></script>
<div class="esun-parameter-comparison__selector">
<div class="esun-parameter-comparison__selector-row">
<header class="esun-parameter-comparison__row-title">
<strong>1 · <?= $block->escapeHtml(__('Base Materials')) ?></strong>
<span><?= $block->escapeHtml(__('Choose a material family')) ?></span>
</header>
<div class="esun-parameter-comparison__base-options">
<?php foreach ($baseOptions as $index => $option): ?>
<label>
<input type="radio" name="parameter_base_material" data-role="base-filter"
value="<?= $block->escapeHtmlAttr($option['value']) ?>"
<?= $index === 0 ? 'checked' : '' ?>>
<span class="esun-parameter-comparison__dot"></span>
<span><?= $block->escapeHtml($option['label']) ?></span>
<small><?= (int) $option['count'] ?></small>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="esun-parameter-comparison__selector-row esun-parameter-comparison__selector-row--series">
<header class="esun-parameter-comparison__row-title">
<strong>2 · <?= $block->escapeHtml(__('Application Series')) ?></strong>
<span><?= $block->escapeHtml(__('Select up to 6 materials from a series')) ?></span>
</header>
<div class="esun-parameter-comparison__series-area">
<div class="esun-parameter-comparison__series-summary">
<span><strong data-role="result-count">0</strong> <?= $block->escapeHtml(__('materials')) ?></span>
<span>·</span>
<span><strong data-role="selection-count">0</strong>/6 <?= $block->escapeHtml(__('selected')) ?></span>
</div>
<div class="esun-parameter-comparison__series-list" data-role="series-list"></div>
<p class="esun-parameter-comparison__notice" data-role="material-notice" aria-live="polite"></p>
<div class="esun-parameter-comparison__selected" data-role="selected-materials"></div>
</div>
</div>
</div>
<div class="esun-parameter-comparison__comparison">
<div class="esun-parameter-comparison__comparison-head">
<div>
<h2><?= $block->escapeHtml(__('Material Parameter Comparison')) ?></h2>
<p><span data-role="comparison-count">0</span> <?= $block->escapeHtml(__('selected materials.')) ?></p>
</div>
<div class="esun-parameter-comparison__modes" role="tablist"
aria-label="<?= $block->escapeHtmlAttr(__('Comparison display mode')) ?>">
<button type="button" class="is-active" data-role="comparison-mode" data-mode="key">
<?= $block->escapeHtml(__('Key Parameters')) ?>
</button>
<button type="button" data-role="comparison-mode" data-mode="all">
<?= $block->escapeHtml(__('All Parameters')) ?>
</button>
<button type="button" data-role="comparison-mode" data-mode="differences">
<?= $block->escapeHtml(__('Differences Only')) ?>
</button>
</div>
</div>
<div class="esun-parameter-comparison__placeholder" data-role="comparison-placeholder">
<?= $block->escapeHtml(__('Select a material above to view its parameters.')) ?>
</div>
<div class="esun-parameter-comparison__table-wrap" data-role="comparison-table-wrap">
<table>
<thead data-role="comparison-head"></thead>
<tbody data-role="comparison-body"></tbody>
</table>
</div>
</div>
</div>
</section>
@@ -0,0 +1,351 @@
<?php
/** @var \Esun\Wiki\Block\Wiki\View $block */
$currentCategory = $block->getCurrentCategory();
$isHomepage = $block->isHomepage();
$searchQuery = $block->getSearchQuery();
$anchors = $block->getAnchors();
$tooltips = $block->getTooltips();
$previousCategory = $block->getPreviousCategory();
$nextCategory = $block->getNextCategory();
$renderTree = function (array $nodes, int $level = 0) use (&$renderTree, $block): void {
if (!$nodes) {
return;
}
?>
<ul class="esun-wiki-tree esun-wiki-tree-level-<?= (int) $level ?>">
<?php foreach ($nodes as $node): ?>
<?php
$category = $node['category'];
$children = $node['children'];
$hasChildren = !empty($children);
$isCurrent = $block->isCurrent($category);
$isClickable = $block->isCategoryClickable($category);
$isOpen = $hasChildren && (
$isCurrent
|| $block->isInCurrentPath($category)
|| $block->isCategoryOpenByDefault($category)
);
$logoUrl = $block->getCategoryLogoUrl($category);
?>
<li class="esun-wiki-tree-item <?= $isCurrent ? 'is-active' : '' ?> <?= $isOpen ? 'is-open' : '' ?> <?= !$isClickable ? 'is-not-clickable' : '' ?>">
<div class="esun-wiki-tree-row">
<?php if ($isClickable): ?>
<a class="esun-wiki-tree-link"
href="<?= $block->escapeUrl($block->getCategoryUrl($category)) ?>">
<?php else: ?>
<span class="esun-wiki-tree-link is-disabled" aria-disabled="true">
<?php endif; ?>
<?php if ($logoUrl !== ''): ?>
<img class="esun-wiki-tree-logo"
src="<?= $block->escapeUrl($logoUrl) ?>"
alt=""
loading="lazy">
<?php endif; ?>
<span class="esun-wiki-tree-title">
<?= $block->escapeHtml((string) $category->getData('title')) ?>
</span>
<?php if ($isClickable): ?>
</a>
<?php else: ?>
</span>
<?php endif; ?>
<?php if ($hasChildren): ?>
<button class="esun-wiki-tree-toggle"
type="button"
aria-label="<?= $block->escapeHtmlAttr(__('Toggle category')) ?>"
aria-expanded="<?= $isOpen ? 'true' : 'false' ?>">
<span aria-hidden="true"></span>
</button>
<?php endif; ?>
</div>
<?php if ($hasChildren): ?>
<div class="esun-wiki-tree-children">
<?php $renderTree($children, $level + 1); ?>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php
};
?>
<div class="esun-wiki-page" data-mage-init='{"Esun_Wiki/js/wiki": {}}'>
<section class="esun-wiki-hero"
style="background-image:linear-gradient(90deg, rgba(14, 18, 22, .42), rgba(14, 18, 22, .12)), url('<?= $block->escapeUrl($block->getHeroBackgroundUrl()) ?>')">
<div class="esun-wiki-title"><?= $block->escapeHtml(__('eSUN Wiki')) ?></div>
<form class="esun-wiki-search" method="get" action="<?= $block->escapeUrl($block->getSearchUrl()) ?>">
<input type="search"
name="q"
value="<?= $block->escapeHtmlAttr($searchQuery) ?>"
placeholder="<?= $block->escapeHtmlAttr(__('Search......')) ?>"
aria-label="<?= $block->escapeHtmlAttr(__('Search wiki')) ?>">
<button class="esun-wiki-search-clear <?= $searchQuery !== '' ? 'is-visible' : '' ?>" type="button"
aria-label="<?= $block->escapeHtmlAttr(__('Clear search')) ?>"></button>
<button class="esun-wiki-search-submit" type="submit"
aria-label="<?= $block->escapeHtmlAttr(__('Search')) ?>">
<svg t="1785230095468" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="39389" width="30" height="30"><path d="M727.893457 795.690762a446.634481 446.634481 0 0 1-280.575883 98.901292C200.277677 894.592054 0.000427 694.314804 0.000427 447.317574a446.293147 446.293147 0 0 1 154.453269-338.133193A445.653148 445.653148 0 0 1 447.317574 0.000427c247.039897 0 447.27448 200.27725 447.27448 447.317147a446.165147 446.165147 0 0 1-98.901292 280.618549l212.650578 212.650578a47.914647 47.914647 0 1 1-67.754639 67.797306z m-280.575883 3.071999a351.573187 351.573187 0 0 0 333.397194-239.9999 351.445187 351.445187 0 0 0-333.397194-462.933141 349.866521 349.866521 0 0 0-230.058571 85.759964 351.445187 351.445187 0 0 0 230.058571 617.13041z m0-607.061081a47.914647 47.914647 0 1 1 0 95.829294 159.743933 159.743933 0 0 0-159.7866 159.7866 47.914647 47.914647 0 0 1-95.829294 0 255.573227 255.573227 0 0 1 255.573227-255.615894z" fill="#17a957" p-id="39390"></path></svg>
</button>
</form>
</section>
<div class="esun-wiki-drawer-backdrop"
data-wiki-drawer-close
aria-hidden="true"></div>
<div class="esun-wiki-shell <?= $anchors ? 'has-toc' : 'has-no-toc' ?>">
<div class="esun-wiki-mobile-actions" aria-label="<?= $block->escapeHtmlAttr(__('Wiki navigation')) ?>">
<button class="esun-wiki-mobile-trigger"
type="button"
data-wiki-drawer-open="categories"
aria-controls="esun-wiki-category-drawer"
aria-expanded="false"
aria-label="<?= $block->escapeHtmlAttr(__('Open wiki categories')) ?>"
title="<?= $block->escapeHtmlAttr(__('Wiki categories')) ?>">
<span class="esun-wiki-mobile-trigger-icon esun-wiki-mobile-trigger-icon--menu"
aria-hidden="true"></span>
</button>
<?= $block->escapeHtmlAttr(__('Wiki Menu')) ?>
</div>
<aside class="esun-wiki-sidebar esun-wiki-drawer esun-wiki-drawer--left"
id="esun-wiki-category-drawer"
data-wiki-drawer="categories"
aria-label="<?= $block->escapeHtmlAttr(__('Wiki categories')) ?>">
<div class="esun-wiki-drawer-header">
<strong><?= $block->escapeHtml(__('Wiki categories')) ?></strong>
<button class="esun-wiki-drawer-close"
type="button"
data-wiki-drawer-close
aria-label="<?= $block->escapeHtmlAttr(__('Close wiki categories')) ?>">
<span aria-hidden="true"></span>
</button>
</div>
<nav>
<?php $renderTree($block->getCategoryTree()); ?>
</nav>
</aside>
<main class="esun-wiki-main" id="wiki-top">
<?php if ($currentCategory && !$isHomepage): ?>
<div class="esun-wiki-breadcrumbs">
<a href="<?= $block->escapeUrl($block->getWikiHomeUrl()) ?>">
<?= $block->escapeHtml(__('esun wiki')) ?>
</a>
<?php foreach ($block->getBreadcrumbItems() as $breadcrumb): ?>
<span aria-hidden="true">/</span>
<?php if ($block->isCategoryClickable($breadcrumb)): ?>
<a href="<?= $block->escapeUrl($block->getCategoryUrl($breadcrumb)) ?>">
<?= $block->escapeHtml((string) $breadcrumb->getData('title')) ?>
</a>
<?php else: ?>
<span><?= $block->escapeHtml((string) $breadcrumb->getData('title')) ?></span>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($block->hasSearchQuery()): ?>
<section class="esun-wiki-search-results">
<h2><?= $block->escapeHtml(__('Search results for "%1"', $searchQuery)) ?></h2>
<?php $results = $block->getSearchResults(); ?>
<?php if (!$results): ?>
<p class="esun-wiki-empty">
<?= $block->escapeHtml(__('No wiki content matched your search.')) ?>
</p>
<?php endif; ?>
<?php foreach ($results as $result): ?>
<article class="esun-wiki-result">
<a href="<?= $block->escapeUrl($block->getCategoryUrl($result)) ?>">
<?= $block->escapeHtml((string) $result->getData('title')) ?>
</a>
<p><?= $block->escapeHtml($block->getSearchSnippet($result)) ?></p>
</article>
<?php endforeach; ?>
</section>
<?php elseif ($currentCategory): ?>
<article class="esun-wiki-article">
<h1<?= $isHomepage ? ' class="wiki-homepage-title"' : '' ?>>
<?= $block->escapeHtml((string) $currentCategory->getData('title')) ?>
</h1>
<div class="esun-wiki-content">
<?= /* @noEscape */ $block->getProcessedContent() ?>
</div>
<?php if (!$isHomepage): ?>
<?= /* @noEscape */ $block->getChildHtml('parameter_comparison') ?>
<?= /* @noEscape */ $block->getChildHtml('download_center') ?>
<?php endif; ?>
</article>
<?php if ($previousCategory || $nextCategory): ?>
<nav class="esun-wiki-bottom-nav" aria-label="<?= $block->escapeHtmlAttr(__('Wiki previous and next')) ?>">
<?php if ($previousCategory): ?>
<a class="esun-wiki-bottom-link esun-wiki-bottom-link-previous"
href="<?= $block->escapeUrl($block->getCategoryUrl($previousCategory)) ?>">
<span class="esun-wiki-bottom-arrow" aria-hidden="true"></span>
<span class="esun-wiki-bottom-text">
<strong><?= $block->escapeHtml(__('Previous')) ?></strong>
<span><?= $block->escapeHtml((string) $previousCategory->getData('title')) ?></span>
</span>
</a>
<?php else: ?>
<span class="esun-wiki-bottom-link esun-wiki-bottom-link-previous is-disabled"></span>
<?php endif; ?>
<?php if ($nextCategory): ?>
<a class="esun-wiki-bottom-link esun-wiki-bottom-link-next"
href="<?= $block->escapeUrl($block->getCategoryUrl($nextCategory)) ?>">
<span class="esun-wiki-bottom-text">
<strong><?= $block->escapeHtml(__('Next')) ?></strong>
<span><?= $block->escapeHtml((string) $nextCategory->getData('title')) ?></span>
</span>
<span class="esun-wiki-bottom-arrow esun-wiki-bottom-arrow-next" aria-hidden="true"></span>
</a>
<?php else: ?>
<span class="esun-wiki-bottom-link esun-wiki-bottom-link-next is-disabled"></span>
<?php endif; ?>
</nav>
<?php endif; ?>
<?php else: ?>
<div class="esun-wiki-empty">
<?= $block->escapeHtml(__('No wiki categories are available yet. Add content from the Magento admin.')) ?>
</div>
<?php endif; ?>
</main>
<?php if ($anchors): ?>
<aside class="esun-wiki-toc esun-wiki-drawer esun-wiki-drawer--right"
id="esun-wiki-anchor-drawer"
data-wiki-drawer="anchors"
aria-label="<?= $block->escapeHtmlAttr(__('Wiki content anchors')) ?>">
<div class="esun-wiki-drawer-header">
<strong><?= $block->escapeHtml(__('On this page')) ?></strong>
<button class="esun-wiki-drawer-close"
type="button"
data-wiki-drawer-close
aria-label="<?= $block->escapeHtmlAttr(__('Close content anchors')) ?>">
<span aria-hidden="true"></span>
</button>
</div>
<div class="esun-wiki-toc-card">
<ul>
<?php foreach ($anchors as $anchor): ?>
<li class="level-<?= (int) $anchor['level'] ?>">
<a href="#<?= $block->escapeHtmlAttr($anchor['id']) ?>">
<?= $block->escapeHtml($anchor['label']) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
</aside>
<?php endif; ?>
</div>
<?php if ($tooltips): ?>
<div class="esun-wiki-tooltip-layer" aria-live="polite">
<?php foreach ($tooltips as $tooltip): ?>
<div class="esun-wiki-tooltip esun-wiki-tooltip--<?= $block->escapeHtmlAttr($tooltip['type']) ?>"
id="<?= $block->escapeHtmlAttr($tooltip['id']) ?>"
data-wiki-tooltip-id="<?= $block->escapeHtmlAttr($tooltip['id']) ?>"
role="dialog"
aria-label="<?= $block->escapeHtmlAttr(
$tooltip['type'] === 'product' ? $tooltip['name'] : $tooltip['title']
) ?>"
aria-modal="false"
aria-hidden="true">
<?php if ($tooltip['type'] === 'product'): ?>
<div class="esun-wiki-product-tip__visual">
<a href="<?= $block->escapeUrl($tooltip['product_url']) ?>"
aria-label="<?= $block->escapeHtmlAttr($tooltip['name']) ?>">
<?php if ($tooltip['image_url'] !== ''): ?>
<img src="<?= $block->escapeUrl($tooltip['image_url']) ?>"
alt="<?= $block->escapeHtmlAttr($tooltip['name']) ?>"
loading="lazy">
<?php endif; ?>
</a>
<div class="esun-wiki-product-tip__price">
<strong><?= $block->escapeHtml($tooltip['final_price']) ?></strong>
<?php if ($tooltip['regular_price'] !== ''): ?>
<del><?= $block->escapeHtml($tooltip['regular_price']) ?></del>
<?php endif; ?>
</div>
<div class="esun-wiki-product-tip__action">
<?php if ($tooltip['can_add_to_cart']): ?>
<form data-role="tocart-form"
data-product-sku="<?= $block->escapeHtmlAttr($tooltip['sku']) ?>"
action="<?= $block->escapeUrl($tooltip['add_to_cart']['action']) ?>"
data-mage-init='{"catalogAddToCart": {}}'
method="post">
<input type="hidden" name="product"
value="<?= (int) $tooltip['add_to_cart']['product'] ?>">
<input type="hidden" name="uenc"
value="<?= $block->escapeHtmlAttr($tooltip['add_to_cart']['uenc']) ?>">
<?= $block->getBlockHtml('formkey') ?>
<button class="esun-wiki-product-tip__cart" type="submit"
title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
<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>
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
</button>
</form>
<?php elseif ($tooltip['is_saleable']): ?>
<a class="esun-wiki-product-tip__cart"
href="<?= $block->escapeUrl($tooltip['product_url']) ?>"
title="<?= $block->escapeHtmlAttr(__('Choose Options')) ?>">
<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>
<span><?= $block->escapeHtml(__('Choose Options')) ?></span>
</a>
<?php else: ?>
<button class="esun-wiki-product-tip__cart is-disabled" type="button" disabled
title="<?= $block->escapeHtmlAttr(__('Out of stock')) ?>">
<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>
<span><?= $block->escapeHtml(__('Out of stock')) ?></span>
</button>
<?php endif; ?>
</div>
</div>
<a class="esun-wiki-product-tip__name"
href="<?= $block->escapeUrl($tooltip['product_url']) ?>">
<?= $block->escapeHtml($tooltip['name']) ?>
</a>
<?php else: ?>
<?php if ($tooltip['image_url'] !== ''): ?>
<div class="esun-wiki-term-tip__image">
<img src="<?= $block->escapeUrl($tooltip['image_url']) ?>"
alt="<?= $block->escapeHtmlAttr($tooltip['image_alt']) ?>">
</div>
<?php endif; ?>
<?php if ($tooltip['link_label'] !== ''): ?>
<?php if ($tooltip['link_url'] !== ''): ?>
<a class="esun-wiki-term-tip__link"
href="<?= $block->escapeUrl($tooltip['link_url']) ?>">
<?= $block->escapeHtml($tooltip['link_label']) ?>
</a>
<?php else: ?>
<span class="esun-wiki-term-tip__link">
<?= $block->escapeHtml($tooltip['link_label']) ?>
</span>
<?php endif; ?>
<?php endif; ?>
<?php if ($tooltip['title'] !== ''): ?>
<strong class="esun-wiki-term-tip__title">
<?= $block->escapeHtml($tooltip['title']) ?>
</strong>
<?php endif; ?>
<?php if ($tooltip['description'] !== ''): ?>
<p class="esun-wiki-term-tip__description">
<?= $block->escapeHtml($tooltip['description']) ?>
</p>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
@@ -0,0 +1,329 @@
.esun-wiki-download-center {
margin-top: 48px;
}
.esun-wiki-download-center .esun-download-specifications__filters {
display: grid;
gap: 24px;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
margin: 0 0 46px;
}
.esun-wiki-download-center .esun-download-specifications__field {
color: #6c9b73;
display: grid;
font-size: 12px;
font-weight: 700;
gap: 8px;
letter-spacing: 2px;
text-transform: uppercase;
}
.esun-wiki-download-center .esun-download-specifications__field select {
background: #fbfffc;
border: 1px solid #dcefe4;
border-radius: 10px;
box-shadow: none;
color: #333;
font-size: 15px;
font-weight: 400;
height: 48px;
letter-spacing: 0;
padding: 0 18px;
text-transform: none;
width: 100%;
}
.esun-wiki-download-center .esun-download-specifications__count {
align-items: center;
color: #6c9b73;
display: flex;
font-size: 12px;
font-weight: 700;
gap: 8px;
letter-spacing: 2px;
margin: 0 0 22px;
text-transform: uppercase;
}
.esun-wiki-download-center .esun-download-specifications__count strong {
align-items: center;
background: #eef6f0;
border-radius: 8px;
color: #91a8bc;
display: inline-flex;
font-size: 12px;
height: 22px;
justify-content: center;
min-width: 22px;
padding: 0 7px;
}
.esun-wiki-download-center .esun-download-specifications__empty {
align-items: center;
border: 2px dashed #e4edf7;
border-radius: 16px;
color: #64748b;
display: flex;
flex-direction: column;
justify-content: center;
min-height: 220px;
padding: 44px 24px;
text-align: center;
}
.esun-wiki-download-center .esun-download-specifications__empty-icon {
border: 4px solid #e6eef7;
border-radius: 50%;
display: block;
height: 34px;
margin-bottom: 22px;
position: relative;
width: 34px;
}
.esun-wiki-download-center .esun-download-specifications__empty-icon::after {
background: #e6eef7;
content: "";
height: 14px;
position: absolute;
right: -8px;
top: 23px;
transform: rotate(-45deg);
width: 4px;
}
.esun-wiki-download-center .esun-download-specifications__empty strong {
color: #1f2937;
font-size: 20px;
margin-bottom: 12px;
}
.esun-wiki-download-center .esun-download-specifications__empty p {
line-height: 1.55;
margin: 0;
max-width: 420px;
}
.esun-wiki-download-center .esun-download-specifications__list {
display: grid;
gap: 18px;
}
.esun-wiki-download-center .esun-download-specifications__item {
align-items: center;
border: 1px solid #dcefe4;
border-radius: 12px;
color: #1f2937;
display: grid;
gap: 22px;
grid-template-columns: 48px minmax(0, 1fr) auto;
min-height: 110px;
padding: 22px 26px;
text-decoration: none;
}
.esun-wiki-download-center .esun-download-specifications__item:hover,
.esun-wiki-download-center .esun-download-specifications__item:focus {
border-color: #18a957;
color: #1f2937;
text-decoration: none;
}
.esun-wiki-download-center .esun-download-specifications__logo {
align-items: center;
background: #effaf3;
border-radius: 8px;
display: inline-flex;
height: 48px;
justify-content: center;
width: 48px;
}
.esun-wiki-download-center .esun-download-specifications__logo img {
max-height: 34px;
max-width: 34px;
object-fit: contain;
}
.esun-wiki-download-center .esun-download-specifications__body {
display: grid;
gap: 10px;
min-width: 0;
}
.esun-wiki-download-center .esun-download-specifications__meta {
align-items: center;
color: #75a67a;
display: flex;
flex-wrap: wrap;
font-size: 12px;
gap: 8px;
}
.esun-wiki-download-center .esun-download-specifications__brand {
border: 1px solid #9fe4b8;
border-radius: 5px;
color: #18a957;
font-size: 11px;
font-weight: 700;
padding: 2px 8px;
text-transform: uppercase;
}
.esun-wiki-download-center .esun-download-specifications__model::before {
content: "\2022";
margin-right: 8px;
}
.esun-wiki-download-center .esun-download-specifications__body strong {
color: #111827;
font-size: 22px;
line-height: 1.2;
}
.esun-wiki-download-center .esun-download-specifications__info {
color: #8db694;
display: flex;
font-size: 12px;
gap: 18px;
}
.esun-wiki-download-center .esun-download-specifications__action {
align-items: center;
display: inline-flex;
gap: 18px;
}
.esun-wiki-download-center .esun-download-specifications__download-text {
color: #333;
font-size: 16px;
}
.esun-wiki-download-center .esun-download-specifications__download-icon {
align-items: center;
background: #18a957;
border-radius: 50%;
display: inline-flex;
height: 48px;
justify-content: center;
position: relative;
width: 48px;
}
.esun-wiki-download-center .esun-download-specifications__download-icon::before {
border-bottom: 2px solid #fff;
border-left: 2px solid #fff;
content: "";
height: 10px;
margin-top: -4px;
transform: rotate(-45deg);
width: 10px;
}
.esun-wiki-download-center .esun-download-specifications__download-icon::after {
background: #fff;
content: "";
height: 16px;
left: 50%;
position: absolute;
top: 14px;
transform: translateX(-50%);
width: 2px;
}
.esun-wiki-download-center .esun-download-specifications__pagination {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
margin-top: 32px;
}
.esun-wiki-download-center .esun-download-specifications__pagination:empty {
display: none;
}
.esun-wiki-download-center .esun-download-specifications__page {
align-items: center;
background: #fff;
border: 1px solid #dcefe4;
border-radius: 8px;
color: #334155;
cursor: pointer;
display: inline-flex;
font-size: 14px;
height: 38px;
justify-content: center;
min-width: 38px;
padding: 0 12px;
}
.esun-wiki-download-center .esun-download-specifications__page:hover,
.esun-wiki-download-center .esun-download-specifications__page:focus-visible {
border-color: #18a957;
color: #18a957;
}
.esun-wiki-download-center .esun-download-specifications__page.is-active {
background: #18a957;
border-color: #18a957;
color: #fff;
font-weight: 700;
}
.esun-wiki-download-center .esun-download-specifications__page:disabled {
background: #f8fafc;
border-color: #e5e7eb;
color: #94a3b8;
cursor: default;
}
.esun-wiki-download-center .esun-download-specifications__ellipsis {
color: #94a3b8;
min-width: 24px;
text-align: center;
}
@media (max-width: 767px) {
.esun-wiki-download-center {
margin-top: 32px;
}
.esun-wiki-download-center .esun-download-specifications__filters {
grid-template-columns: 1fr;
margin-bottom: 32px;
}
.esun-wiki-download-center .esun-download-specifications__item {
gap: 16px;
grid-template-columns: 42px minmax(0, 1fr);
padding: 20px;
}
.esun-wiki-download-center .esun-download-specifications__logo {
height: 42px;
width: 42px;
}
.esun-wiki-download-center .esun-download-specifications__body strong {
font-size: 18px;
overflow-wrap: anywhere;
}
.esun-wiki-download-center .esun-download-specifications__action {
grid-column: 2;
justify-content: space-between;
}
.esun-wiki-download-center .esun-download-specifications__pagination {
margin-top: 24px;
}
.esun-wiki-download-center .esun-download-specifications__page {
height: 36px;
min-width: 36px;
padding: 0 10px;
}
}
@@ -0,0 +1,438 @@
.esun-parameter-comparison {
--pc-green: #17a957;
--pc-dark: #303631;
--pc-muted: #8a928d;
--pc-line: #d9eadf;
margin: 45px 0 55px;
color: var(--pc-dark);
font-size: 14px;
}
.esun-parameter-comparison__app {
width: 100%;
}
.esun-parameter-comparison__selector {
border: 1px solid var(--pc-line);
border-radius: 18px;
background: #fff;
overflow: hidden;
}
.esun-parameter-comparison__selector-row {
display: block;
padding: 28px 30px;
}
.esun-parameter-comparison__selector-row + .esun-parameter-comparison__selector-row {
border-top: 1px solid var(--pc-line);
}
.esun-parameter-comparison__row-title strong {
display: block;
color: #4d735e;
font-size: 13px;
font-weight: 700;
letter-spacing: .12em;
text-transform: uppercase;
}
.esun-parameter-comparison__row-title span {
display: block;
margin-top: 7px;
color: var(--pc-muted);
font-size: 13px;
}
.esun-parameter-comparison__row-title {
margin-bottom: 20px;
}
.esun-parameter-comparison__base-options {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.esun-parameter-comparison__base-options label {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 42px;
box-sizing: border-box;
padding: 0 15px;
border: 2px solid #cfe4d7;
border-radius: 999px;
color: #657069;
font-size: 13px;
cursor: pointer;
transition: .2s ease;
}
.esun-parameter-comparison__base-options input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.esun-parameter-comparison__dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: #afbeb5;
}
.esun-parameter-comparison__base-options small {
color: #8d9891;
}
.esun-parameter-comparison__base-options label:has(input:checked) {
border-color: var(--pc-green);
background: #f2fbf6;
color: var(--pc-green);
}
.esun-parameter-comparison__base-options label:has(input:checked) .esun-parameter-comparison__dot {
background: var(--pc-green);
}
.esun-parameter-comparison__series-area {
min-width: 0;
}
.esun-parameter-comparison__series-summary {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-bottom: 14px;
color: #747d77;
font-size: 13px;
}
.esun-parameter-comparison__series-summary strong {
color: var(--pc-green);
}
.esun-parameter-comparison__series-list {
column-count: 3;
column-gap: 12px;
}
.esun-parameter-comparison__series-row {
display: inline-block;
box-sizing: border-box;
width: 100%;
min-width: 0;
margin: 0 0 12px;
padding: 15px;
border: 1px solid #dcebe1;
border-radius: 12px;
background: #fbfdfc;
break-inside: avoid;
vertical-align: top;
}
.esun-parameter-comparison__series-name {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 8px;
padding: 0 0 11px;
}
.esun-parameter-comparison__series-name strong {
font-size: 14px;
}
.esun-parameter-comparison__series-name span {
min-width: 27px;
padding: 2px 7px;
border: 1px solid #cce6d6;
border-radius: 999px;
background: #f2faf5;
color: #55976f;
text-align: center;
}
.esun-parameter-comparison__series-products {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.esun-parameter-comparison__product {
min-height: 36px;
max-width: 100%;
padding: 0 12px;
border: 1px solid #cfe1d5;
border-radius: 999px;
background: #fff;
color: #68726c;
font-size: 13px;
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.esun-parameter-comparison__product:hover,
.esun-parameter-comparison__product.is-selected {
border-color: var(--pc-green);
background: var(--pc-green);
color: #fff;
}
.esun-parameter-comparison__product:disabled {
opacity: .45;
cursor: not-allowed;
}
.esun-parameter-comparison__notice {
min-height: 20px;
margin: 7px 0 0;
color: #b43e32;
}
.esun-parameter-comparison__selected {
display: flex;
flex-wrap: wrap;
gap: 9px;
min-height: 40px;
margin-top: 5px;
}
.esun-parameter-comparison__selected-pill {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 7px 9px 7px 14px;
border: 1px solid #b9dfc8;
border-radius: 999px;
background: #f0faf4;
color: #315e43;
font-size: 13px;
}
.esun-parameter-comparison__selected-pill button,
.esun-parameter-comparison thead button {
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
padding: 0;
border: 0;
border-radius: 50%;
background: #dcefe3;
color: #4c7a5e;
}
.esun-parameter-comparison__comparison {
margin-top: 36px;
}
.esun-parameter-comparison__comparison-head {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 24px;
margin-bottom: 16px;
}
.esun-parameter-comparison__comparison-head h2 {
margin: 0 0 4px;
font-size: 23px;
}
.esun-parameter-comparison__comparison-head p {
margin: 0;
color: var(--pc-muted);
font-size: 13px;
}
.esun-parameter-comparison__modes {
display: inline-flex;
padding: 4px;
border: 1px solid var(--pc-line);
border-radius: 10px;
background: #fff;
}
.esun-parameter-comparison__modes button {
padding: 9px 16px;
border: 0;
border-radius: 7px;
background: transparent;
color: #929a95;
font-size: 13px;
}
.esun-parameter-comparison__modes button.is-active {
background: var(--pc-green);
color: #fff;
}
.esun-parameter-comparison__placeholder {
padding: 52px 25px;
border: 1px solid var(--pc-line);
border-radius: 14px;
color: var(--pc-muted);
text-align: center;
}
.esun-parameter-comparison__table-wrap {
display: none;
max-height: 720px;
border: 1px solid var(--pc-line);
border-radius: 14px;
overflow: auto;
}
.esun-parameter-comparison table {
width: 100%;
min-width: 780px;
margin: 0;
border-collapse: separate;
border-spacing: 0;
font-size: 13px;
}
.esun-parameter-comparison__table-wrap.is-single table {
min-width: 0;
}
.esun-parameter-comparison__table-wrap.is-single th:first-child {
width: 46%;
min-width: 0;
}
.esun-parameter-comparison th,
.esun-parameter-comparison td {
padding: 15px 18px;
border-right: 1px solid #e3eee7;
border-bottom: 1px solid #e3eee7;
background: #fff;
color: var(--pc-dark);
vertical-align: top;
white-space: pre-line;
}
.esun-parameter-comparison thead th {
position: sticky;
top: 0;
z-index: 3;
background: #f4faf6;
color: var(--pc-dark) !important;
text-align: left;
}
.esun-parameter-comparison thead th span {
margin-right: 9px;
color: var(--pc-dark) !important;
}
.esun-parameter-comparison th:first-child {
position: sticky;
left: 0;
z-index: 2;
width: 29%;
min-width: 245px;
}
.esun-parameter-comparison thead th:first-child {
z-index: 4;
}
.esun-parameter-comparison__group-row th {
left: 0;
z-index: 2;
background: #eff9f3;
color: var(--pc-green);
font-size: 13px;
letter-spacing: .09em;
text-transform: uppercase;
}
@media (max-width: 900px) {
.esun-parameter-comparison__selector-row {
padding: 24px 22px;
}
.esun-parameter-comparison__series-list {
column-count: 2;
}
}
@media (max-width: 640px) {
.esun-parameter-comparison {
margin: 28px 0 40px;
}
.esun-parameter-comparison__selector-row {
padding: 18px 14px;
}
.esun-parameter-comparison__row-title {
margin-bottom: 15px;
}
.esun-parameter-comparison__base-options {
flex-wrap: nowrap;
padding-bottom: 5px;
overflow-x: auto;
}
.esun-parameter-comparison__base-options label {
flex: 0 0 auto;
min-height: 36px;
padding: 0 11px;
font-size: 12px;
}
.esun-parameter-comparison__base-options label:has(input:checked) {
padding: 0 11px;
}
.esun-parameter-comparison__series-row {
padding: 13px;
}
.esun-parameter-comparison__series-name {
justify-content: flex-start;
padding-top: 2px;
}
.esun-parameter-comparison__series-products {
gap: 7px;
}
.esun-parameter-comparison__series-list {
column-count: 1;
}
.esun-parameter-comparison__product {
min-height: 33px;
padding: 0 11px;
font-size: 12px;
}
.esun-parameter-comparison__comparison-head {
align-items: stretch;
flex-direction: column;
}
.esun-parameter-comparison__comparison-head h2 {
font-size: 20px;
}
.esun-parameter-comparison__modes {
overflow-x: auto;
}
.esun-parameter-comparison__modes button {
flex: 0 0 auto;
padding: 8px 11px;
font-size: 12px;
}
.esun-parameter-comparison th,
.esun-parameter-comparison td {
padding: 11px 12px;
font-size: 12px;
}
.esun-parameter-comparison__table-wrap:not(.is-single) table {
min-width: 680px;
}
.esun-parameter-comparison__table-wrap.is-single table {
width: 100%;
table-layout: fixed;
}
.esun-parameter-comparison__table-wrap.is-single th,
.esun-parameter-comparison__table-wrap.is-single td {
overflow-wrap: anywhere;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,211 @@
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 || {},
pageSize = 20,
currentPage = 1,
$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"]'),
$pagination = $root.find('[data-role="spec-pagination"]');
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] || []).slice() : [];
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 createPageButton(label, page, options) {
var settings = options || {},
$button = $('<button/>', {
'class': 'esun-download-specifications__page' + (settings.active ? ' is-active' : ''),
type: 'button',
text: label,
disabled: settings.disabled || false,
'aria-label': settings.ariaLabel || null,
'aria-current': settings.active ? 'page' : null
});
if (!settings.disabled && !settings.active) {
$button.on('click', function () {
currentPage = page;
renderList();
$root.get(0).scrollIntoView({behavior: 'smooth', block: 'start'});
});
}
return $button;
}
function renderPagination(totalPages) {
var pages = [],
previousPage = 0;
$pagination.empty();
if (totalPages <= 1) {
return;
}
$pagination.append(createPageButton($t('Previous'), currentPage - 1, {
disabled: currentPage === 1,
ariaLabel: $t('Previous page')
}));
for (var page = 1; page <= totalPages; page++) {
if (page === 1 || page === totalPages || Math.abs(page - currentPage) <= 2) {
pages.push(page);
}
}
$.each(pages, function (_, page) {
if (previousPage && page - previousPage > 1) {
$('<span/>', {
'class': 'esun-download-specifications__ellipsis',
text: '…',
'aria-hidden': 'true'
}).appendTo($pagination);
}
$pagination.append(createPageButton(String(page), page, {
active: page === currentPage,
ariaLabel: $t('Page %1').replace('%1', page)
}));
previousPage = page;
});
$pagination.append(createPageButton($t('Next'), currentPage + 1, {
disabled: currentPage === totalPages,
ariaLabel: $t('Next page')
}));
}
function renderItem(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);
}
function renderList() {
var results = filterItems(),
totalPages = Math.ceil(results.length / pageSize),
start;
if (totalPages > 0 && currentPage > totalPages) {
currentPage = totalPages;
}
$count.text(results.length);
$list.empty();
$empty.toggle(results.length === 0);
$list.toggle(results.length > 0);
start = (currentPage - 1) * pageSize;
$.each(results.slice(start, start + pageSize), function (_, item) {
renderItem(item);
});
renderPagination(totalPages);
}
renderBrands();
renderModels();
renderList();
$brand.on('change', function () {
currentPage = 1;
renderModels();
renderList();
});
$model.on('change', function () {
currentPage = 1;
renderList();
});
};
});
@@ -0,0 +1,236 @@
define(['jquery', 'mage/translate'], function ($, $t) {
'use strict';
return function (config, element) {
var $root = $(element),
rawConfig = $root.find('[data-role="parameter-config"]').text(),
data = rawConfig ? JSON.parse(rawConfig) : {},
products = data.products || [],
applicationOptions = data.applicationOptions || [],
messages = data.messages || {},
maximum = 6,
selected = [],
mode = 'key',
keyParameters = [
'Density(g/cm3) (unit to be confirmed)',
'Heat Distortion Temperature(°C)',
'Tensile Strength (XY) (MPa)',
'Elongation at Break (XY) (%)',
'Flexural Strength (XY) (MPa)',
'Flexural Modulus (XY) (MPa)',
'IZOD Impact Strength (XY) (kJ/m²)',
'Extruder Temperature(°C)',
'Bed Temperature(°C)',
'Fan Speed(%)',
'Printing Speed(mm/s) (high-speed printing parameter)',
'Printing Recommendation',
'Drying'
],
$seriesList = $root.find('[data-role="series-list"]'),
$selectedMaterials = $root.find('[data-role="selected-materials"]'),
$notice = $root.find('[data-role="material-notice"]'),
$selectionCount = $root.find('[data-role="selection-count"]'),
$comparisonCount = $root.find('[data-role="comparison-count"]'),
$resultCount = $root.find('[data-role="result-count"]'),
$placeholder = $root.find('[data-role="comparison-placeholder"]'),
$tableWrap = $root.find('[data-role="comparison-table-wrap"]'),
$head = $root.find('[data-role="comparison-head"]'),
$body = $root.find('[data-role="comparison-body"]');
function selectedBase() {
return $root.find('[data-role="base-filter"]:checked').val() || '';
}
function productsForBase() {
var base = selectedBase();
return $.grep(products, function (product) { return product.base === base; });
}
function primaryApplication(product) {
return product.applications && product.applications.length ? product.applications[0] : 'other';
}
function applicationLabel(value) {
var option = applicationOptions.find(function (item) { return item.value === value; });
return option ? option.label : $t('Other Series');
}
function isSelected(id) {
return $.inArray(id, selected) !== -1;
}
function findProduct(id) {
return products.find(function (product) { return product.id === id; });
}
function renderSeries() {
var baseProducts = productsForBase(), groups = {};
$.each(baseProducts, function (_, product) {
var application = primaryApplication(product);
groups[application] = groups[application] || [];
groups[application].push(product);
});
$seriesList.empty();
$.each(applicationOptions, function (_, option) {
var groupProducts = groups[option.value] || [];
if (!groupProducts.length) {
return;
}
renderSeriesRow(option.label, groupProducts);
delete groups[option.value];
});
$.each(groups, function (application, groupProducts) {
renderSeriesRow(applicationLabel(application), groupProducts);
});
$resultCount.text(baseProducts.length);
updateSelection();
}
function renderSeriesRow(label, groupProducts) {
var $row = $('<div/>', {'class': 'esun-parameter-comparison__series-row'}),
$label = $('<div/>', {'class': 'esun-parameter-comparison__series-name'}),
$products = $('<div/>', {'class': 'esun-parameter-comparison__series-products'});
$label.append($('<strong/>', {text: label}), $('<span/>', {text: groupProducts.length}));
$.each(groupProducts, function (_, product) {
$('<button/>', {
type: 'button',
'class': 'esun-parameter-comparison__product' + (isSelected(product.id) ? ' is-selected' : ''),
text: product.name,
title: product.name,
disabled: !isSelected(product.id) && selected.length >= maximum,
'data-role': 'material-option',
'data-id': product.id
}).appendTo($products);
});
$row.append($label, $products).appendTo($seriesList);
}
function updateSelection() {
$selectionCount.text(selected.length);
$comparisonCount.text(selected.length);
$selectedMaterials.empty();
$.each(selected, function (_, id) {
var product = findProduct(id), $pill;
if (!product) {
return;
}
$pill = $('<span/>', {'class': 'esun-parameter-comparison__selected-pill'});
$pill.append(
$('<span/>', {text: product.name}),
$('<button/>', {
type: 'button',
text: '×',
'aria-label': $t('Remove %1').replace('%1', product.name),
'data-role': 'remove-material',
'data-id': id
})
).appendTo($selectedMaterials);
});
renderComparison();
}
function removeMaterial(id) {
selected = $.grep(selected, function (selectedId) { return selectedId !== id; });
$notice.text('');
renderSeries();
}
function parameterIsVisible(name, values) {
if (mode === 'key' && $.inArray(name, keyParameters) === -1) {
return false;
}
if (mode === 'differences') {
return values.filter(function (value, index, array) {
return array.indexOf(value) === index;
}).length > 1;
}
return true;
}
function renderComparison() {
var selectedProducts = $.map(selected, findProduct),
groups = data.parameterGroups || {};
$head.empty();
$body.empty();
if (selectedProducts.length < 1) {
$placeholder.show();
$tableWrap.hide();
return;
}
$tableWrap.toggleClass('is-single', selectedProducts.length === 1);
var $headerRow = $('<tr/>').append($('<th/>', {text: $t('Parameter')}));
$.each(selectedProducts, function (_, product) {
var $name = $('<span/>', {text: product.name}),
$remove = $('<button/>', {
type: 'button', text: '×',
'aria-label': $t('Remove %1').replace('%1', product.name),
'data-role': 'remove-material', 'data-id': product.id
});
$headerRow.append($('<th/>').append($name, $remove));
});
$head.append($headerRow);
$.each(groups, function (groupName, parameters) {
var rows = [];
$.each(parameters, function (_, parameterName) {
var values = $.map(selectedProducts, function (product) {
var value = product.groups[groupName] && product.groups[groupName][parameterName];
return value === undefined || value === null || value === ''
? (messages.missingValue || '—') : String(value);
});
if (!parameterIsVisible(parameterName, values)) {
return;
}
var $row = $('<tr/>').append($('<th/>', {scope: 'row', text: parameterName}));
$.each(values, function (_, value) { $row.append($('<td/>').text(value)); });
rows.push($row);
});
if (rows.length) {
$body.append($('<tr/>', {'class': 'esun-parameter-comparison__group-row'})
.append($('<th/>', {colspan: selectedProducts.length + 1, text: groupName})));
$.each(rows, function (_, row) { $body.append(row); });
}
});
$placeholder.hide();
$tableWrap.show();
}
$root.on('change', '[data-role="base-filter"]', function () {
selected = [];
$notice.text('');
renderSeries();
});
$root.on('click', '[data-role="material-option"]', function () {
var id = $(this).data('id');
if (isSelected(id)) {
removeMaterial(id);
return;
}
if (selected.length >= maximum) {
$notice.text($t('You can compare up to 6 materials.'));
return;
}
selected.push(id);
$notice.text('');
renderSeries();
});
$root.on('click', '[data-role="remove-material"]', function () {
removeMaterial($(this).data('id'));
});
$root.on('click', '[data-role="comparison-mode"]', function () {
mode = $(this).data('mode');
$root.find('[data-role="comparison-mode"]').removeClass('is-active');
$(this).addClass('is-active');
renderComparison();
});
renderSeries();
};
});
@@ -0,0 +1,296 @@
define([
'jquery'
], function ($) {
'use strict';
return function (config, element) {
var $root = $(element),
$activeTrigger = $(),
$activeTooltip = $(),
$drawers = $root.find('[data-wiki-drawer]'),
$drawerBackdrop = $root.find('.esun-wiki-drawer-backdrop'),
$activeDrawer = $(),
$activeDrawerTrigger = $(),
drawerMedia = window.matchMedia('(max-width: 860px)'),
hideTimer = null;
function syncSearchClear($input) {
var hasValue = $.trim($input.val()).length > 0;
$input.closest('form').find('.esun-wiki-search-clear').toggleClass('is-visible', hasValue);
}
function cancelTooltipHide() {
if (hideTimer) {
window.clearTimeout(hideTimer);
hideTimer = null;
}
}
function positionTooltip($trigger, $tooltip) {
var triggerRect = $trigger[0].getBoundingClientRect(),
viewportWidth = window.innerWidth || document.documentElement.clientWidth,
viewportHeight = window.innerHeight || document.documentElement.clientHeight,
gutter = 14,
gap = 18,
tooltipWidth,
tooltipHeight,
left,
top,
arrowLeft,
showBelow;
$tooltip
.addClass('is-active')
.css({left: 0, top: 0, visibility: 'hidden'});
tooltipWidth = $tooltip.outerWidth();
tooltipHeight = $tooltip.outerHeight();
left = triggerRect.left + (triggerRect.width / 2) - (tooltipWidth / 2);
left = Math.max(gutter, Math.min(left, viewportWidth - tooltipWidth - gutter));
top = triggerRect.top - tooltipHeight - gap;
showBelow = top < gutter;
if (showBelow) {
top = triggerRect.bottom + gap;
}
top = Math.max(gutter, Math.min(top, viewportHeight - tooltipHeight - gutter));
arrowLeft = triggerRect.left + (triggerRect.width / 2) - left;
arrowLeft = Math.max(26, Math.min(arrowLeft, tooltipWidth - 26));
$tooltip
.toggleClass('is-below', showBelow)
.css({
left: Math.round(left),
top: Math.round(top),
visibility: 'visible',
'--esun-wiki-tip-arrow-left': Math.round(arrowLeft) + 'px'
});
}
function closeTooltip(restoreFocus) {
cancelTooltipHide();
if ($activeTooltip.length) {
$activeTooltip
.removeClass('is-active is-below')
.attr('aria-hidden', 'true')
.removeAttr('style');
}
if ($activeTrigger.length) {
$activeTrigger.attr('aria-expanded', 'false');
if (restoreFocus) {
$activeTrigger.trigger('focus');
}
}
$activeTrigger = $();
$activeTooltip = $();
}
function showTooltip($trigger) {
var tooltipId = $trigger.attr('data-wiki-tip'),
$tooltip = $root.find('[data-wiki-tooltip-id="' + tooltipId + '"]');
if (!$tooltip.length) {
return;
}
cancelTooltipHide();
if ($activeTooltip.length && $activeTooltip[0] !== $tooltip[0]) {
closeTooltip(false);
}
$activeTrigger = $trigger;
$activeTooltip = $tooltip;
$trigger.attr('aria-expanded', 'true');
$tooltip.attr('aria-hidden', 'false');
positionTooltip($trigger, $tooltip);
}
function scheduleTooltipHide() {
cancelTooltipHide();
hideTimer = window.setTimeout(function () {
closeTooltip(false);
}, 140);
}
function closeDrawer(restoreFocus) {
var $trigger = $activeDrawerTrigger;
$drawers.removeClass('is-open');
$root.find('[data-wiki-drawer-open]').attr('aria-expanded', 'false');
$drawerBackdrop.removeClass('is-visible').attr('aria-hidden', 'true');
$('html, body').removeClass('esun-wiki-drawer-lock');
if (restoreFocus && $trigger.length) {
$trigger.trigger('focus');
}
if (drawerMedia.matches) {
$drawers.attr('aria-hidden', 'true');
} else {
$drawers.removeAttr('aria-hidden');
}
$activeDrawer = $();
$activeDrawerTrigger = $();
}
function openDrawer(name, $trigger) {
var $drawer;
if (!drawerMedia.matches) {
return;
}
$drawer = $drawers.filter('[data-wiki-drawer="' + name + '"]');
if (!$drawer.length) {
return;
}
closeTooltip(false);
closeDrawer(false);
$activeDrawer = $drawer;
$activeDrawerTrigger = $trigger;
$drawer.addClass('is-open').attr('aria-hidden', 'false');
$trigger.attr('aria-expanded', 'true');
$drawerBackdrop.addClass('is-visible').attr('aria-hidden', 'false');
$('html, body').addClass('esun-wiki-drawer-lock');
window.setTimeout(function () {
if ($drawer.hasClass('is-open')) {
$drawer.find('.esun-wiki-drawer-close').first().trigger('focus');
}
}, 220);
}
function syncDrawerMode() {
closeDrawer(false);
}
function trapDrawerFocus(event) {
var $focusable,
first,
last;
if (event.key !== 'Tab' || !$activeDrawer.length) {
return;
}
$focusable = $activeDrawer
.find('a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])')
.filter(':visible');
if (!$focusable.length) {
event.preventDefault();
return;
}
first = $focusable[0];
last = $focusable[$focusable.length - 1];
if (event.shiftKey && document.activeElement === first) {
event.preventDefault();
$(last).trigger('focus');
} else if (!event.shiftKey && document.activeElement === last) {
event.preventDefault();
$(first).trigger('focus');
}
}
$root.find('.esun-wiki-search input[type="search"]').each(function () {
syncSearchClear($(this));
});
$root.on('click', '.esun-wiki-tree-toggle', function () {
var $button = $(this),
$item = $button.closest('.esun-wiki-tree-item'),
isOpen = !$item.hasClass('is-open');
$item.toggleClass('is-open', isOpen);
$button.attr('aria-expanded', isOpen ? 'true' : 'false');
});
$root.on('input change', '.esun-wiki-search input[type="search"]', function () {
syncSearchClear($(this));
});
$root.on('click', '.esun-wiki-search-clear', function () {
var $form = $(this).closest('form'),
$input = $form.find('input[type="search"]');
$input.val('').trigger('focus');
syncSearchClear($input);
if (window.location.search.indexOf('q=') !== -1) {
window.location.href = $form.attr('action');
}
});
$root.on('click', '[data-wiki-drawer-open]', function () {
openDrawer($(this).attr('data-wiki-drawer-open'), $(this));
});
$root.on('click', '[data-wiki-drawer-close]', function () {
closeDrawer(true);
});
$root.on('click', '.esun-wiki-toc a, .esun-wiki-sidebar a.esun-wiki-tree-link', function () {
if (drawerMedia.matches) {
closeDrawer(false);
}
});
$root.on('mouseenter focusin', '.esun-wiki-tip-trigger', function () {
showTooltip($(this));
});
$root.on('mouseleave focusout', '.esun-wiki-tip-trigger', scheduleTooltipHide);
$root.on('click', '.esun-wiki-tip-trigger', function (event) {
event.preventDefault();
showTooltip($(this));
});
$root.on('mouseenter focusin', '.esun-wiki-tooltip', cancelTooltipHide);
$root.on('mouseleave focusout', '.esun-wiki-tooltip', scheduleTooltipHide);
$(window).on('resize.esunWikiTooltip', function () {
if ($activeTrigger.length && $activeTooltip.length) {
positionTooltip($activeTrigger, $activeTooltip);
}
});
$(window).on('scroll.esunWikiTooltip', function () {
if ($activeTrigger.length && $activeTooltip.length) {
positionTooltip($activeTrigger, $activeTooltip);
}
});
$(document).on('mousedown.esunWikiTooltip touchstart.esunWikiTooltip', function (event) {
if (!$(event.target).closest('.esun-wiki-tip-trigger, .esun-wiki-tooltip').length) {
closeTooltip(false);
}
});
$(document).on('keydown.esunWikiTooltip', function (event) {
if (event.key === 'Escape' && $activeDrawer.length) {
closeDrawer(true);
} else if (event.key === 'Escape' && $activeTooltip.length) {
closeTooltip(true);
}
trapDrawerFocus(event);
});
if (drawerMedia.addEventListener) {
drawerMedia.addEventListener('change', syncDrawerMode);
} else {
drawerMedia.addListener(syncDrawerMode);
}
syncDrawerMode();
};
});