init
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
<?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">
|
||||
<body>
|
||||
<referenceBlock name="attribute_edit_tabs">
|
||||
<action method="addTabAfter">
|
||||
<argument name="name" xsi:type="string">weltpixellayerednavigation</argument>
|
||||
<argument name="block" xsi:type="string">WeltPixel\LayeredNavigation\Block\Adminhtml\Product\Attribute\Edit\Tab\Options</argument>
|
||||
<argument name="after" xsi:type="string">front</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
</body>
|
||||
</page>
|
||||
@@ -0,0 +1,13 @@
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<referenceContainer name="before.body.end">
|
||||
<block
|
||||
ifconfig="weltpixel_layerednavigation/general/enable"
|
||||
class="WeltPixel\LayeredNavigation\Block\LayeredNavigationAdd"
|
||||
name="layerednavigationadd"
|
||||
template="WeltPixel_LayeredNavigation::layerednavigationadd.phtml"
|
||||
/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* @category WeltPixel
|
||||
* @package WeltPixel_LayeredNavigation
|
||||
* @copyright Copyright (c) 2018 Weltpixel
|
||||
* @author Weltpixel TEAM
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<attribute name="class" value="wp-ln-filter-page"/>
|
||||
<referenceBlock name="catalog.leftnav">
|
||||
<action method="setTemplate" ifconfig="weltpixel_layerednavigation/general/enable">
|
||||
<argument name="template" xsi:type="string">WeltPixel_LayeredNavigation::layer/view.phtml</argument>
|
||||
</action>
|
||||
<container name="layer.additional.info" as="layer_additional_info"/>
|
||||
<container name="layer.content.before" as="layer_content_before"/>
|
||||
</referenceBlock>
|
||||
<referenceBlock name="catalog.navigation.renderer">
|
||||
<action method="setTemplate" ifconfig="weltpixel_layerednavigation/general/enable">
|
||||
<argument name="template" xsi:type="string">WeltPixel_LayeredNavigation::layer/filter.phtml</argument>
|
||||
</action>
|
||||
</referenceBlock>
|
||||
|
||||
<referenceContainer name="content">
|
||||
<block class="Magento\Framework\View\Element\Template" name="layer.category.products" template="WeltPixel_LayeredNavigation::products.phtml" />
|
||||
</referenceContainer>
|
||||
|
||||
<move element="category.products" destination="layer.category.products"/>
|
||||
<referenceContainer name="before.body.end">
|
||||
<block
|
||||
ifconfig="weltpixel_layerednavigation/general/enable"
|
||||
class="WeltPixel\LayeredNavigation\Block\LayeredNavigationAdd"
|
||||
name="layerednavigationadd"
|
||||
template="WeltPixel_LayeredNavigation::layerednavigationadd.phtml"
|
||||
/>
|
||||
</referenceContainer>
|
||||
</body>
|
||||
</page>
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* @category WeltPixel
|
||||
* @package WeltPixel_LayeredNavigation
|
||||
* @copyright Copyright (c) 2018 Weltpixel
|
||||
* @author Weltpixel TEAM
|
||||
*/
|
||||
-->
|
||||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
|
||||
<body>
|
||||
<attribute name="class" value="page-products"/>
|
||||
|
||||
<referenceContainer name="sidebar.main">
|
||||
<block class="WeltPixel\LayeredNavigation\Block\Navigation\Search" name="catalogsearch.leftnav" before="-" template="WeltPixel_LayeredNavigation::layer/view.phtml">
|
||||
<block class="WeltPixel\LayeredNavigation\Block\Navigation\State" name="catalogsearch.navigation.state" as="state" />
|
||||
<block class="WeltPixel\LayeredNavigation\Block\Navigation\FilterRenderer" name="catalogsearch.navigation.renderer" as="renderer" template="WeltPixel_LayeredNavigation::layer/filter.phtml"/>
|
||||
</block>
|
||||
</referenceContainer>
|
||||
|
||||
<referenceContainer name="content">
|
||||
<block class="Magento\Framework\View\Element\Template" name="wp.layer.search.result" template="WeltPixel_LayeredNavigation::search_products.phtml" />
|
||||
</referenceContainer>
|
||||
<move element="search.result" destination="wp.layer.search.result"/>
|
||||
|
||||
<referenceContainer name="before.body.end">
|
||||
<block
|
||||
ifconfig="weltpixel_layerednavigation/general/enable"
|
||||
class="WeltPixel\LayeredNavigation\Block\LayeredNavigationAdd"
|
||||
name="layerednavigationadd"
|
||||
template="WeltPixel_LayeredNavigation::layerednavigationadd.phtml"
|
||||
/>
|
||||
</referenceContainer>
|
||||
|
||||
</body>
|
||||
</page>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
var config = {
|
||||
map: {
|
||||
'*': {
|
||||
wpFilterSelect: 'WeltPixel_LayeredNavigation/js/wpFilterSelect'
|
||||
}
|
||||
}
|
||||
};
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
/* @var $block WeltPixel\LayeredNavigation\Block\Navigation\FilterRenderer */
|
||||
$attributeCode = $this->getAttribute()->getAttributeCode();
|
||||
|
||||
$url = '';
|
||||
?>
|
||||
|
||||
<?php $attributeId = $block->getAttributeId()?>
|
||||
<?php $isMulti = $block->getIsMultiselect()?>
|
||||
<?php $canShowQty = (is_null($block->getShowQty())) ? $this->helper('\Magento\Catalog\Helper\Data')->shouldDisplayProductCountOnLayer() : $block->getShowQty();?>
|
||||
<ol class="items" id="<?= $attributeId ?>_items" >
|
||||
<?php foreach ($filterItems as $index => $filterItem): ?>
|
||||
<?php /* @var $filterItem \Magento\Catalog\Model\Layer\Filter\Item */ ?>
|
||||
|
||||
<?php $filterUrl = $filterItem->getUrl(); ?>
|
||||
<?php $requestVar = $filterItem->getFilter()->getRequestVar();?>
|
||||
<?php $filterItemVal = is_array($filterItem->getValue()) ? implode('-', $filterItem->getValue()) : $filterItem->getValue()?>
|
||||
|
||||
<?php if (!$url && $filterItem->getCount() && $attributeCode=='category_option') { $url=$filterUrl; } ?>
|
||||
<?php $dataOptPath = ($requestVar != 'cat') ? $filterItem->getFilter()->getAttributeModel()->getAttributeCode() . '='. $filterItemVal : 'cat='.$filterItemVal;?>
|
||||
<li class="item" style="display: none" id="wp_ln_attr_<?= $attributeId ?>_<?= /* @escapeNotVerified */ is_array($filterItem->getValue()) ? implode('-', $filterItem->getValue()) : $filterItem->getValue() ?>">
|
||||
<a href="<?= $block->escapeUrl($filterUrl) ?>"
|
||||
data-opt-path="<?= /* @escapeNotVerified */ $block->escapeHtmlAttr($dataOptPath) ?>"
|
||||
data-is-multi="<?= $isMulti?>">
|
||||
<?= /* @escapeNotVerified */ $filterItem->getLabel() ?>
|
||||
<?php if ($canShowQty): ?>
|
||||
<span class="count"><?= /* @escapeNotVerified */ $filterItem->getCount() ?></span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach ?>
|
||||
<div class="wp-ln-actions">
|
||||
<b id="loadMore_<?=$attributeId?>" class="wp-ln-action wp-ln-load-more icon-line-arrow-down">Show More</b>
|
||||
<b id="showLess_<?=$attributeId?>" class="wp-ln-action wp-ln-show-less icon-line-arrow-up">Show Less</b>
|
||||
</div>
|
||||
</ol>
|
||||
<?php
|
||||
if ($url && $attributeCode=='category_option' && !$this->getRequest()->getParam('category_option')) {
|
||||
$block->setRedirectUrl($url);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
require(['jquery'], function($){
|
||||
$(document).ready(function(){
|
||||
var visibleItems = "<?= $block->getVisibleItems()?>",
|
||||
visibleItemsStep = "<?= $block->getVisibleItemsStep()?>",
|
||||
attrId = "<?= $attributeId?>",
|
||||
elId = attrId + '_items',
|
||||
ulSize = $('#' + elId + ' li').length,
|
||||
loadMoreId = '#loadMore_' + attrId,
|
||||
showLessId = '#showLess_' + attrId,
|
||||
x = parseInt(visibleItems),
|
||||
initialX = x,
|
||||
xStep = parseInt(visibleItemsStep);
|
||||
if(visibleItems > 0 && visibleItems.length > 0 && visibleItems < 99 && ulSize > visibleItems) {
|
||||
$(loadMoreId).show();
|
||||
$("#"+ elId + " li:lt(" + visibleItems + ")").show();
|
||||
$(showLessId).hide();
|
||||
} else {
|
||||
$("#"+ elId + " li").show();
|
||||
$(loadMoreId).hide();
|
||||
$(showLessId).hide();
|
||||
}
|
||||
|
||||
$(loadMoreId).click(function () {
|
||||
if(xStep == 99) {
|
||||
$('#' + elId + ' li:lt(' + ulSize + ')').show();
|
||||
$(this).hide();
|
||||
$(showLessId).show();
|
||||
} else {
|
||||
x = ( x + xStep <= ulSize) ? x + xStep : ulSize;
|
||||
$('#' + elId + ' li:lt(' + x + ')').show();
|
||||
if(ulSize == x){
|
||||
$(this).hide();
|
||||
$(showLessId).show();
|
||||
}else{
|
||||
$(showLessId).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(showLessId).click(function () {
|
||||
if(xStep == 99) {
|
||||
$('#' + elId + ' li').not(':lt(' + xStep + ')').hide();
|
||||
$(this).hide();
|
||||
$(loadMoreId).show();
|
||||
} else {
|
||||
x = ( x - xStep < 0 || x == ulSize) ? initialX : x - xStep;
|
||||
$('#' + elId + ' li').not(':lt(' + x + ')').hide();
|
||||
if(x <= visibleItems){
|
||||
$(this).hide();
|
||||
$(loadMoreId).show();
|
||||
}else{
|
||||
$(loadMoreId).show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Category layered navigation state
|
||||
*
|
||||
* @var $block \WeltPixel\LayeredNavigation\Block\Navigation\State
|
||||
*/
|
||||
?>
|
||||
<?php $_filters = $block->getActiveFilters() ?>
|
||||
<?php if (!empty($_filters)): ?>
|
||||
<div class="filter-current" id="wp_ln_shopby">
|
||||
|
||||
<ol class="items" id="wp_ln_shopby_items" data-role="content">
|
||||
<?php foreach ($_filters as $_filter): ?>
|
||||
<?php
|
||||
$requestVar = $_filter->getFilter()->getRequestVar();
|
||||
$filterItemVal = (is_array($_filter->getValue())) ? implode('-', $_filter->getValue()) : $_filter->getValue();
|
||||
$dataAttrId = ($requestVar != 'cat') ? $_filter->getFilter()->getAttributeModel()->getAttributeId() . '_' . $filterItemVal : '0_'.$filterItemVal;
|
||||
?>
|
||||
<li class="item" data-attr-id="<?= /* @escapeNotVerified */ $block->escapeHtml($dataAttrId) ?>">
|
||||
<span class="filter-label"><?= $block->escapeHtml(__($_filter->getName())) ?></span>
|
||||
<span class="filter-value"><?= /* @escapeNotVerified */ $block->stripTags($_filter->getLabel()) ?></span>
|
||||
<?php
|
||||
$clearLinkUrl = $_filter->getClearLinkUrl();
|
||||
$currentFilterName = $block->escapeHtml(__($_filter->getName())) . " " . $block->stripTags($_filter->getLabel());
|
||||
if ($clearLinkUrl):
|
||||
?>
|
||||
<a class="action previous" href="<?= /* @escapeNotVerified */ $_filter->getRemoveUrl() ?>"
|
||||
title="<?= /* @escapeNotVerified */ __('Previous') ?>">
|
||||
<span><?= /* @escapeNotVerified */ __('Previous') ?></span>
|
||||
</a>
|
||||
<a class="action remove"
|
||||
title="<?= $block->escapeHtml($_filter->getFilter()->getClearLinkText()) ?>"
|
||||
href="<?= /* @escapeNotVerified */ $clearLinkUrl ?>">
|
||||
<span><?= $block->escapeHtml($_filter->getFilter()->getClearLinkText()) ?></span>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a class="action remove" href="<?= /* @escapeNotVerified */ $_filter->getRemoveUrl() ?>"
|
||||
title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Remove')) . " " . $currentFilterName ?>">
|
||||
<span><?= /* @escapeNotVerified */ __('Remove This Item') ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
// @codingStandardsIgnoreFile
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Category layered navigation
|
||||
*
|
||||
* @var $block WeltPixel\LayeredNavigation\Block\Navigation
|
||||
*/
|
||||
|
||||
$isAjaxMode = $block->isAjaxMode();
|
||||
$jsClass = ($isAjaxMode) ? 'WeltPixel_LayeredNavigation/js/product/list/toolbar' : false;
|
||||
?>
|
||||
<?php if ($block->canShowBlock()): ?>
|
||||
<div class="wp-filters <?php if ($isAjaxMode) echo 'wp-filters-ajax' ?>">
|
||||
<?= /* @escapeNotVerified */
|
||||
$block->getFilterButtonHtml() ?>
|
||||
</div>
|
||||
<div class="block filter" id="layered-filter-block"
|
||||
data-mage-init='{"collapsible":{"openedState": "active", "collapsible": true, "active": false, "collateral": { "openedState": "filter-active", "element": "body" } }}'>
|
||||
<?php $filtered = count($block->getLayer()->getState()->getFilters()) ?>
|
||||
<div class="block-title filter-title" data-count="<?= /* @escapeNotVerified */
|
||||
$filtered ?>">
|
||||
<strong data-role="title"><?= /* @escapeNotVerified */
|
||||
__('筛选结果') ?></strong>
|
||||
</div>
|
||||
<div class="block-content filter-content">
|
||||
<?= $block->getChildHtml('state') ?>
|
||||
|
||||
<?php if ($block->getLayer()->getState()->getFilters()): ?>
|
||||
<div class="block-actions filter-actions">
|
||||
<a href="<?= /* @escapeNotVerified */
|
||||
$block->getClearUrl() ?>" class="action clear filter-clear"><span><?= /* @escapeNotVerified */
|
||||
__('Clear All') ?></span></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php $activeFilters = $block->getActiveFilters() ?>
|
||||
<?php $wrapOptions = false; ?>
|
||||
<?php foreach ($block->getFilters() as $k => $filter): ?>
|
||||
|
||||
<?php $filterAttributeId = $filter->getData('attribute_model') ? $filter->getData('attribute_model')->getAttributeId() : 0; ?>
|
||||
<?php $attributeId = (!$block->isCategoryFilter($filter)) ? $filterAttributeId : 0; ?>
|
||||
<?php if ($filter->getItemsCount()): ?>
|
||||
<?php if (!$wrapOptions): ?>
|
||||
|
||||
<div class="filter-options" id="narrow-by-list" data-role="content"
|
||||
data-mage-init='{"accordion":{"openedState": "active", "collapsible": true, "active": "<?php echo $activeFilters; ?>", "multipleCollapsible": true}}'>
|
||||
<?php $wrapOptions = true; ?>
|
||||
<?php endif; ?>
|
||||
<div data-role="collapsible" class="filter-options-item">
|
||||
<?php $block->getChildBlock('renderer')->setAttributeId($filter) ?>
|
||||
<div data-role="title" class="filter-options-title">
|
||||
<?= /* @escapeNotVerified */ __($filter->getName()) ?></div>
|
||||
<div id="attr_<?php echo $attributeId ?>" data-role="content"
|
||||
class="filter-options-content"><?= /* @escapeNotVerified */
|
||||
$block->getChildBlock('renderer')->render($filter) ?></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($wrapOptions): ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<script>
|
||||
require([
|
||||
'jquery'
|
||||
], function ($) {
|
||||
$('#layered-filter-block').addClass('filter-no-options');
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="wp-ln-overlay"></div>
|
||||
<div class="wp-ln-slider-js" data-mage-init='<?= /* @escapeNotVerified */ $block->getWidgetOptionsJson() ?>'>
|
||||
<script>
|
||||
<?php if ($jsClass): ?>
|
||||
require.config({
|
||||
map: {
|
||||
'*': {
|
||||
"productListToolbarForm": "<?= $jsClass?>"
|
||||
}
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
require(['wpFilterSelect'], function(){
|
||||
wpFilterSelect.markSelected();
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
<?php $redirectUrl = $block->getRedirectUrl(); ?>
|
||||
<?php if ($redirectUrl): ?>
|
||||
<script>
|
||||
window.location.href = '<?= $redirectUrl ?>';
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<script>
|
||||
window.isLayeredNavigationEnabled = '<?= $this->isLnEnabled()?>';
|
||||
</script>
|
||||
Executable
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
/** @var $block \WeltPixel\LayeredNavigation\Block\LayeredNavigation\RenderLayered */
|
||||
?>
|
||||
<?php $swatchData = $block->getSwatchData(); ?>
|
||||
<?php $isMulti = $block->getIsMultiSelect($swatchData['attribute_id']) ?>
|
||||
<div class="swatch-attribute swatch-layered <?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
|
||||
attribute-code="<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>"
|
||||
attribute-id="<?= /* @escapeNotVerified */ $swatchData['attribute_id'] ?>">
|
||||
<div class="swatch-attribute-options clearfix" data-is-multi="<?= $block->getIsMultiSelect($swatchData['attribute_id'])?>">
|
||||
<?php foreach ($swatchData['options'] as $option => $label): ?>
|
||||
<a href="<?= /* @escapeNotVerified */ $label['link'] ?>"
|
||||
aria-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
|
||||
class="swatch-option-link-layered"
|
||||
data-is-multi="<?= $isMulti ?>"
|
||||
data-opt-path="<?=/* @escapeNotVerified */ $swatchData['attribute_code']?>=<?= /* @escapeNotVerified */ $option?>"
|
||||
id="wp_ln_swatch_attr_<?= /* @escapeNotVerified */ $swatchData['attribute_id']?>_<?= /* @escapeNotVerified */ $option?>">
|
||||
<?php if (isset($swatchData['swatches'][$option]['type'])) { ?>
|
||||
<?php switch ($swatchData['swatches'][$option]['type']) {
|
||||
case '3':
|
||||
?>
|
||||
<div class="swatch-option <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
|
||||
tabindex="-1"
|
||||
data-option-type="3"
|
||||
data-option-id="<?= /* @escapeNotVerified */ $option ?>"
|
||||
data-option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
|
||||
data-option-tooltip-thumb=""
|
||||
data-option-tooltip-value=""
|
||||
></div>
|
||||
<?php break;
|
||||
case '2':
|
||||
?>
|
||||
<?php $swatchThumbPath = $block->getSwatchPath('swatch_thumb',
|
||||
$swatchData['swatches'][$option]['value']); ?>
|
||||
<?php $swatchImagePath = $block->getSwatchPath('swatch_image',
|
||||
$swatchData['swatches'][$option]['value']); ?>
|
||||
<div class="swatch-option image <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
|
||||
tabindex="-1"
|
||||
data-option-type="2"
|
||||
data-option-id="<?= /* @escapeNotVerified */ $option ?>"
|
||||
data-option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
|
||||
data-option-tooltip-thumb="<?= /* @escapeNotVerified */ $swatchThumbPath ?>"
|
||||
data-option-tooltip-value=""
|
||||
style="background: url(<?= /* @escapeNotVerified */ $swatchImagePath ?>) no-repeat center; background-size: initial;"></div>
|
||||
<?php break;
|
||||
case '1':
|
||||
?>
|
||||
<div class="swatch-option color <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
|
||||
tabindex="-1"
|
||||
data-option-type="1"
|
||||
data-option-id="<?= /* @escapeNotVerified */ $option ?>"
|
||||
data-option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
|
||||
data-option-tooltip-thumb=""
|
||||
data-option-tooltip-value="<?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?>"
|
||||
style="background: <?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?> no-repeat center; background-size: initial;"></div>
|
||||
<?php break;
|
||||
case '0':
|
||||
default:
|
||||
?>
|
||||
<div class="swatch-option text <?= /* @escapeNotVerified */ $label['custom_style'] ?>"
|
||||
tabindex="-1"
|
||||
data-option-type="0"
|
||||
data-option-id="<?= /* @escapeNotVerified */ $option ?>"
|
||||
data-option-label="<?= /* @escapeNotVerified */ $label['label'] ?>"
|
||||
data-option-tooltip-thumb=""
|
||||
data-option-tooltip-value=""
|
||||
><?= /* @escapeNotVerified */ $swatchData['swatches'][$option]['value'] ?></div>
|
||||
<?php break;
|
||||
} ?>
|
||||
<?php } ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
require(["jquery", "Magento_Swatches/js/swatch-renderer"], function ($) {
|
||||
$('.swatch-layered.<?= /* @escapeNotVerified */ $swatchData['attribute_code'] ?>')
|
||||
.find('[data-option-type="1"], [data-option-type="2"], [data-option-type="0"], [data-option-type="3"]')
|
||||
.SwatchRendererTooltip();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="wp-ln-selected-js">
|
||||
<script>
|
||||
require(['wpFilterSelect'], function(){
|
||||
wpFilterSelect.markSelected();
|
||||
});
|
||||
</script>
|
||||
|
||||
</div>
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
|
||||
<?php
|
||||
/* @var $block \Magento\Framework\View\Element\Template */
|
||||
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
|
||||
$currentCategory = $objectManager->get(\Magento\Framework\Registry::class)->registry('current_category');
|
||||
|
||||
$scopeConfig = $objectManager->get(\Magento\Framework\App\Config\ScopeConfigInterface::class);
|
||||
|
||||
$samplePackCategoryId = $scopeConfig->getValue(
|
||||
'catalog/product_settings/sample_pack_category_id',
|
||||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
|
||||
);
|
||||
$productSheetIds = [154,247];
|
||||
if ($samplePackCategoryId){
|
||||
$productSheetIds[] = $samplePackCategoryId;
|
||||
}
|
||||
|
||||
if($currentCategory && in_array($currentCategory->getId(), $productSheetIds)):
|
||||
// 获取当前完整URL
|
||||
$currentUrl = $block->getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true]);
|
||||
$keyword = $block->getRequest()->getParam('keyword');
|
||||
?>
|
||||
<div class="search-technical-resources">
|
||||
<div class="search-technical-resources-form-wrapper">
|
||||
<label>输入产品号或产品名称搜索</label>
|
||||
<form action="<?= $currentUrl ?>" method="get">
|
||||
<input type="text" name="keyword" value="<?= $keyword ?>" placeholder="例如: 17858或EasySep™人CD14正选试剂盒II" class="input-text" maxlength="128" autocomplete="off">
|
||||
|
||||
<input type="hidden" name="product_list_mode" value="list" autocomplete="off">
|
||||
<button type="submit" class="sc-button orange">搜索</button>
|
||||
</form>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<div id="layer-product-list">
|
||||
<?php echo $block->getChildHtml() ?>
|
||||
</div>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<div id="layer-product-list">
|
||||
<?php echo $block->getChildHtml() ?>
|
||||
</div>
|
||||
@@ -0,0 +1,291 @@
|
||||
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
|
||||
|
||||
#wp_ln_shopby {
|
||||
&.filter-current {
|
||||
#wp_ln_shopby_items {
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.wp-ln-actions {
|
||||
color: #ef8200;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
font-weight: normal;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.wp-ln-action {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font-weight: normal;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.wp-ln-show-less {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar.sidebar-main {
|
||||
.wp-filters {
|
||||
display: none
|
||||
}
|
||||
}
|
||||
|
||||
body.slider-layer {
|
||||
.column.main {
|
||||
width: 100%;
|
||||
}
|
||||
.block.filter {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.toolbar-products {
|
||||
margin-left: 90px
|
||||
}
|
||||
|
||||
.sidebar.sidebar-main {
|
||||
.wp-filters {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
height: 20px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
.wp-filters-text {
|
||||
vertical-align: top;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
}
|
||||
.wp-ln-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: none;
|
||||
z-index: 99;
|
||||
background: rgba(0, 0, 0, .3);
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.sidebar.sidebar-main {
|
||||
|
||||
b.wp-slide-in {
|
||||
display: inline-block;
|
||||
background: url('../WeltPixel_LayeredNavigation/images/slide_icon.png') no-repeat;
|
||||
width: 20px;
|
||||
height: 23px;
|
||||
transition: scale 100ms ease;
|
||||
margin: 2px 8px 0 0;
|
||||
|
||||
}
|
||||
}
|
||||
.slide-in-filter {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 12%;
|
||||
min-width: 250px;
|
||||
background: #fff;
|
||||
height: 95%;
|
||||
padding: 25px;
|
||||
overflow: scroll;
|
||||
margin-bottom: 10px;
|
||||
z-index: 100;
|
||||
|
||||
.block-subtitle {
|
||||
font-size: 15px;
|
||||
text-align: center;
|
||||
padding: 10px 10px 30px
|
||||
}
|
||||
|
||||
.filter-options-item {
|
||||
padding: 15px 0;
|
||||
border-bottom: 1px solid #ecece7
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
b.wp-ln-load-more {
|
||||
&:before {
|
||||
font-family: FontAwesome;
|
||||
padding-right: 6px;
|
||||
margin-left: 2px;
|
||||
content: '\f055';
|
||||
}
|
||||
}
|
||||
|
||||
b.wp-ln-show-less {
|
||||
&:before {
|
||||
font-family: FontAwesome;
|
||||
padding-right: 6px;
|
||||
margin-left: 2px;
|
||||
content: '\f056';
|
||||
}
|
||||
}
|
||||
|
||||
#layered-filter-block {
|
||||
.wp-ln-selected {
|
||||
a{
|
||||
border-left: 5px solid red;
|
||||
padding-left: 11px;
|
||||
font-style: italic;
|
||||
color: #908f8f;
|
||||
}
|
||||
}
|
||||
.filter-options-item {
|
||||
.filter-options-content {
|
||||
display: none;
|
||||
}
|
||||
&.active {
|
||||
.filter-options-content {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#layered-filter-block {
|
||||
.wp-ln-selected {
|
||||
.swatch-option {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
outline: 2px solid #ee0000;
|
||||
border: 1px solid #fff;
|
||||
&:before {
|
||||
visibility: visible;
|
||||
border: 3px solid white !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#layer-product-list {
|
||||
.message.info.empty{
|
||||
margin-left: 90px !important;
|
||||
}
|
||||
}
|
||||
|
||||
body.theme-pearl{
|
||||
.slide-in-filter {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
b.wp-ln-load-more {
|
||||
&:before {
|
||||
font-family: FontAwesome;
|
||||
padding-right: 6px;
|
||||
margin-left: 2px;
|
||||
content: '\f055';
|
||||
}
|
||||
}
|
||||
|
||||
b.wp-ln-show-less {
|
||||
&:before {
|
||||
font-family: FontAwesome;
|
||||
padding-right: 6px;
|
||||
margin-left: 2px;
|
||||
content: '\f056';
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar.sidebar-main {
|
||||
.wp-filters {
|
||||
top: 16px !important;
|
||||
.wp-filters-text {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#layered-filter-block {
|
||||
.wp-ln-selected {
|
||||
a{
|
||||
text-decoration: none;
|
||||
font-weight: 900;
|
||||
border-left: 0 none;
|
||||
font-style:normal;
|
||||
color: inherit;
|
||||
&:before {
|
||||
background: #303030;
|
||||
border: 1px solid #303030 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.swatch-option {
|
||||
outline: 2px solid #ee0000;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
.swatch-option.text {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
border: 2px solid #999999 !important;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#layer-product-list {
|
||||
.message.info.empty{
|
||||
margin-left: 90px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
|
||||
#layered-filter-block {
|
||||
.wp-ln-selected {
|
||||
.swatch-option {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
outline: 2px solid #ee0000;
|
||||
border: 1px solid #fff;
|
||||
&:before {
|
||||
visibility: visible;
|
||||
border: 3px solid white !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.wp-ln-actions {
|
||||
color: #ef8200;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
font-weight: normal;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.wp-ln-action {
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
font-weight: normal;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.wp-ln-show-less {
|
||||
display: none;
|
||||
}
|
||||
b.wp-ln-load-more {
|
||||
&:before {
|
||||
font-family: FontAwesome;
|
||||
padding-right: 6px;
|
||||
margin-left: 2px;
|
||||
content: '\f055';
|
||||
}
|
||||
}
|
||||
|
||||
b.wp-ln-show-less {
|
||||
&:before {
|
||||
font-family: FontAwesome;
|
||||
padding-right: 6px;
|
||||
margin-left: 2px;
|
||||
content: '\f056';
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 177 B |
@@ -0,0 +1,696 @@
|
||||
define([
|
||||
"jquery",
|
||||
"loader",
|
||||
"jquery-ui-modules/widget",
|
||||
"jquery-ui-modules/effect-slide",
|
||||
"Magento_Catalog/js/product/list/toolbar",
|
||||
], function ($) {
|
||||
/**
|
||||
* ProductListToolbarForm Widget - this widget is setting cookie and submitting form according to toolbar controls
|
||||
*/
|
||||
$.widget('mage.productListToolbarForm', $.mage.productListToolbarForm, {
|
||||
|
||||
options:
|
||||
{
|
||||
modeControl: '[data-role="mode-switcher"]',
|
||||
directionControl: '[data-role="direction-switcher"]',
|
||||
orderControl: '[data-role="sorter"]',
|
||||
limitControl: '[data-role="limiter"]',
|
||||
pagerControl: '[data-role="pager"], .pages-items a',
|
||||
mode: 'product_list_mode',
|
||||
direction: 'product_list_dir',
|
||||
order: 'product_list_order',
|
||||
limit: 'product_list_limit',
|
||||
pager: 'p',
|
||||
modeDefault: 'grid',
|
||||
directionDefault: 'asc',
|
||||
orderDefault: 'position',
|
||||
limitDefault: '9',
|
||||
pagerDefault: '1',
|
||||
productsToolbarControl: '.toolbar.toolbar-products',
|
||||
productsListBlock: '#layer-product-list',
|
||||
layeredNavigationFilterBlock: '.block.filter',
|
||||
filterItemControl: '.block.filter .item a, .block.filter .filter-clear,.block.filter .swatch-option-link-layered, .wp-price-slider-a',
|
||||
url: ''
|
||||
},
|
||||
|
||||
_create: function () {
|
||||
this._super();
|
||||
this._bind($(this.options.pagerControl), this.options.pager, this.options.pagerDefault);
|
||||
$(this.options.filterItemControl)
|
||||
.off('click.' + this.namespace + 'productListToolbarForm')
|
||||
.on('click.' + this.namespace + 'productListToolbarForm', {}, $.proxy(this.applyFilterToProductsList, this))
|
||||
;
|
||||
|
||||
var that = this;
|
||||
|
||||
window.onpopstate = function(event) {
|
||||
var ignoredHashes = ['#search-mod'];
|
||||
if (event && !ignoredHashes.includes(window.location.hash) && window.location.href.slice(-1) != '#') {
|
||||
var backUrl = event.target.location.origin + event.target.location.pathname;
|
||||
var paramData = event.target.location.search.replace(/^\?/, '')
|
||||
that.makeAjaxCall(backUrl, paramData, false);
|
||||
}
|
||||
}
|
||||
|
||||
$('.item a.wp-filter-disabled').off('click');
|
||||
if (window.wp_ajax_useCustomPlaceholder == '1') {
|
||||
$('.page-wrapper').loader({
|
||||
icon: window.loadingImage,
|
||||
template: '<div class="loading-mask" data-role="loader">\n' +
|
||||
' <div class="loader">\n' +
|
||||
' <img alt="<%- data.texts.imgAlt %>" style="max-width: ' + window.wp_ajax_placeholderCustomWidth + '" src="<%- data.icon %>">\n' +
|
||||
' <p><%- data.texts.loaderText %></p>\n' +
|
||||
' </div>\n' +
|
||||
'</div>'
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @param {jQuery.Event} event
|
||||
* @private
|
||||
*/
|
||||
_processPagination: function (event) {
|
||||
event.preventDefault();
|
||||
var paginationUrl = event.currentTarget.href;
|
||||
var urlParams = this.getUrlParams(paginationUrl);
|
||||
this.changeUrl(
|
||||
event.data.paramName,
|
||||
urlParams[event.data.paramName],
|
||||
event.data.default
|
||||
);
|
||||
},
|
||||
_bind: function (element, paramName, defaultValue) {
|
||||
/**
|
||||
* Prevent double binding of these events because this component is being applied twice in the UIX
|
||||
*/
|
||||
if (paramName == this.options.pager) {
|
||||
element
|
||||
.off('click.' + this.namespace + 'productListToolbarForm')
|
||||
.on('click.' + this.namespace + 'productListToolbarForm', {
|
||||
paramName: paramName,
|
||||
default: defaultValue
|
||||
}, $.proxy(this._processPagination, this));
|
||||
} else if (element.is("select")) {
|
||||
element
|
||||
.off('change.' + this.namespace + 'productListToolbarForm')
|
||||
.on('change.' + this.namespace + 'productListToolbarForm', {
|
||||
paramName: paramName,
|
||||
default: defaultValue
|
||||
}, $.proxy(this._processSelect, this));
|
||||
} else {
|
||||
element
|
||||
.off('click.' + this.namespace + 'productListToolbarForm')
|
||||
.on('click.' + this.namespace + 'productListToolbarForm', {
|
||||
paramName: paramName,
|
||||
default: defaultValue
|
||||
}, $.proxy(this._processLink, this));
|
||||
}
|
||||
|
||||
},
|
||||
applyFilterToProductsList: function (evt) {
|
||||
var link = $(evt.currentTarget),
|
||||
linkA = link.attr('href'),
|
||||
urlParts = (typeof linkA !== 'undefined') ? linkA.split('?') : '',
|
||||
currentUrl = window.location.href,
|
||||
isMulti = (link.attr('data-is-multi')) ? link.data('is-multi') : 0,
|
||||
parentElem = link.parent(),
|
||||
clickOpt = (parentElem.attr('data-path-opt')) ? parentElem.data('opt-path') : link.data('opt-path'),
|
||||
c = currentUrl.split('?');
|
||||
window.isSorting = false;
|
||||
var reqeustParams = (typeof urlParts[1] === 'undefined') ? '' : urlParts[1];
|
||||
|
||||
var mergedPath = reqeustParams;
|
||||
|
||||
if (reqeustParams.length > 0 && typeof c[1] !== 'undefined') {
|
||||
mergedPath = this.compareMergeParams(c[1], reqeustParams, clickOpt, isMulti);
|
||||
}
|
||||
|
||||
self.elem = link;
|
||||
|
||||
this.makeAjaxCall(urlParts[0], mergedPath, true);
|
||||
evt.preventDefault();
|
||||
|
||||
},
|
||||
compareMergeParams: function (currentParamsStr, newParamsStr, clickOpt, isMulti) {
|
||||
var a = currentParamsStr.split('&');
|
||||
var b = newParamsStr.split('&');
|
||||
var c = (typeof clickOpt !== 'undefined') ? clickOpt.split('=') : '';
|
||||
var res = '';
|
||||
a.sort();
|
||||
b.sort();
|
||||
for (var i = 0; i < b.length; i++) {
|
||||
var paramStr = b[i].split('=')[0],
|
||||
paramVal = decodeURIComponent(b[i].split('=')[1]),
|
||||
paramArr = paramVal.split(',');
|
||||
for (var j = 0; j < a.length; j++) {
|
||||
|
||||
if (typeof a[j] === 'undefined') {
|
||||
continue;
|
||||
}
|
||||
|
||||
var existParamStr = a[j].split('=')[0],
|
||||
existParamVal = decodeURIComponent(a[j].split('=')[1]),
|
||||
existParamArr = existParamVal.split(','),
|
||||
matchParams = '';
|
||||
|
||||
if(paramStr == 'p' || paramStr == 'q' || paramStr == 'ajax') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (paramStr !== existParamStr) {
|
||||
//res += paramStr + '=' + paramVal + '&';
|
||||
continue;
|
||||
}
|
||||
for (var z = 0; z < existParamArr.length; z++) {
|
||||
if (paramArr.indexOf(existParamArr[z]) !== -1) {
|
||||
matchParams = (matchParams.length === 0) ? existParamArr[z] : matchParams + ',' + existParamArr[z];
|
||||
}
|
||||
}
|
||||
|
||||
if (paramStr === existParamStr && paramVal !== existParamVal && matchParams.length === 0 && isMulti != 0) {
|
||||
paramVal = existParamVal + ',' + paramVal;
|
||||
}
|
||||
else if( c[0] == paramStr && c[1] == matchParams ){
|
||||
var filteredArray = existParamArr.filter(function(e) { return e !== matchParams })
|
||||
paramVal = (filteredArray.length > 0) ? filteredArray.join(',') : '';
|
||||
}
|
||||
else {
|
||||
//paramVal = matchParams;
|
||||
}
|
||||
}
|
||||
|
||||
if(paramVal) {
|
||||
res += paramStr + '=' + paramVal + '&';
|
||||
}
|
||||
|
||||
}
|
||||
res = res.slice(0, -1);
|
||||
|
||||
return res;
|
||||
},
|
||||
updateUrl: function (url, paramData, pushState) {
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
if (paramData && paramData.length > 0) {
|
||||
url += '?' + paramData;
|
||||
}
|
||||
url = this.removeQueryStringParameter('ajax', url);
|
||||
url = this.removeQueryStringParameter('_', url);
|
||||
if (pushState && (typeof history.pushState === 'function')) {
|
||||
history.pushState({}, null, url);
|
||||
}
|
||||
},
|
||||
|
||||
getParams: function (urlParams, paramName, paramValue, defaultValue) {
|
||||
var decode = window.decodeURIComponent,
|
||||
paramData = {},
|
||||
parameters, i;
|
||||
|
||||
for (i = 0; i < urlParams.length; i++) {
|
||||
parameters = urlParams[i].split('=');
|
||||
paramData[decode(parameters[0])] = parameters[1] !== undefined ?
|
||||
decode(parameters[1].replace(/\+/g, '%20')) :
|
||||
'';
|
||||
}
|
||||
|
||||
/** get the real attr name from param */
|
||||
var paramValueArr = paramValue.split('~'),
|
||||
paramValueNew = paramValueArr[0];
|
||||
|
||||
paramData[paramName] = paramValueNew;
|
||||
|
||||
/** get the given direction from param */
|
||||
var directionName = this.options.direction;
|
||||
if (paramValueArr.length == 2 && paramName != directionName) {
|
||||
paramData[directionName] = paramValueArr[1];
|
||||
}
|
||||
|
||||
return $.param(paramData);
|
||||
},
|
||||
_updateContent: function (content) {
|
||||
window.shouldOpenMinicart = false;
|
||||
$(this.options.productsToolbarControl).remove();
|
||||
if (content.products_list) {
|
||||
$(this.options.productsListBlock).html(content.products_list);
|
||||
$(this.options.productsListBlock).trigger('contentUpdated');
|
||||
}
|
||||
|
||||
if (content.filters) {
|
||||
var isSlideIn = $('body').hasClass('slider-layer');
|
||||
var isSlideDown = $('body').hasClass('slider-down-layer');
|
||||
var isAutoClose = $('#layered-filter-block').hasClass('auto-close');
|
||||
var isViewL = $('body').hasClass('wp-device-l');
|
||||
var isViewXl = $('body').hasClass('wp-device-xl');
|
||||
$(this.options.layeredNavigationFilterBlock).replaceWith(content.filters);
|
||||
$(this.options.layeredNavigationFilterBlock).trigger('contentUpdated');
|
||||
|
||||
if(!isAutoClose && isSlideIn && !window.isSorting && (isViewL || isViewXl)) {
|
||||
$('body').addClass('wp-ln-open').css({'height': '100%', 'overflow': 'hidden'});
|
||||
$('.block-search, a.logo').css({'z-index': '1'});
|
||||
$('.wp-ln-overlay').fadeIn(100, 'swing', function () {
|
||||
$('#layered-filter-block').delay(150).show("slide", {direction: "left"});
|
||||
});
|
||||
}
|
||||
|
||||
if(!isAutoClose && isSlideDown && !window.isSorting) {
|
||||
var productWrapperMarginTop = $('body').attr('data-pwmt');
|
||||
$('.products.wrapper').animate({marginTop: productWrapperMarginTop},
|
||||
{
|
||||
duration:500,
|
||||
complete: function() {
|
||||
$('.wp-filters span.wp-slide-down-add').addClass('active');
|
||||
}
|
||||
|
||||
});
|
||||
$('.wp-slide-down-add:not(active)').off('click');
|
||||
$('.slide-down-filter').slideDown(500);
|
||||
$('body.slider-down-layer #layered-filter-block').show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (content.ga4ServerSideItemListHash) {
|
||||
window.wpGA4ServerSide.pushViewItemList(content.ga4ServerSideItemListHash);
|
||||
}
|
||||
|
||||
if (content.dataLayer) {
|
||||
var dlObjects = JSON.parse(content.dataLayer);
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
for (var i in dlObjects) {
|
||||
window.dataLayer.push({ecommerce: null});
|
||||
window.dataLayer.push(dlObjects[i]);
|
||||
}
|
||||
}
|
||||
if (content.dataLayerGA4) {
|
||||
var dl4Objects = JSON.parse(content.dataLayerGA4);
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
for (var i in dl4Objects) {
|
||||
window.dataLayer.push({ecommerce: null});
|
||||
window.dataLayer.push(dl4Objects[i]);
|
||||
}
|
||||
}
|
||||
$(document).trigger("wpproductlabels:init");
|
||||
$('li.product-item').trigger('contentUpdated');
|
||||
if (window.isSlCustomPopupUsed && parseInt(window.isSlCustomPopupUsed)) {
|
||||
$('li.product-item').find('.towishlist').each(function() {
|
||||
$(this).removeAttr('data-post');
|
||||
})
|
||||
}
|
||||
$('body').trigger('contentUpdated');
|
||||
|
||||
},
|
||||
lnSlideDown: function() {
|
||||
var productWrapperMarginTop = $('body').attr('data-pwmt');
|
||||
|
||||
$('.products.wrapper').animate({marginTop: productWrapperMarginTop},
|
||||
{
|
||||
duration:500,
|
||||
complete: function() {
|
||||
$('.wp-filters span.wp-slide-down-add').addClass('active');
|
||||
}
|
||||
|
||||
});
|
||||
$('.wp-slide-down-add:not(active)').off('click');
|
||||
$('.slide-down-filter').slideDown(500);
|
||||
$('.wp-filters').on('click', this.lnSlideUp);
|
||||
},
|
||||
lnSlideUp: function() {
|
||||
$('.wp-filters').off('click');
|
||||
$('.slide-down-filter').slideUp(
|
||||
{
|
||||
duration: 500,
|
||||
start: function(){
|
||||
$('.products.wrapper').animate(
|
||||
{
|
||||
marginTop: '0px'
|
||||
},
|
||||
{
|
||||
duration:500,
|
||||
complete: function() {
|
||||
$('.wp-filters span.wp-slide-down-add').removeClass('active');
|
||||
$('.wp-filters').on('click', this.lnSlideDown);
|
||||
},
|
||||
queue: false
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
queue: false
|
||||
});
|
||||
},
|
||||
reinitializeIas: function() {
|
||||
if(require.defined('ias') && window.ajaxCatalog == 'infiniteScroll') {
|
||||
jQuery.ias().destroy();
|
||||
jQuery(function($) {
|
||||
var config = {
|
||||
container: '.products.wrapper .product-items',
|
||||
item: '.product-item',
|
||||
pagination: '.toolbar .pages, .toolbar .limiter',
|
||||
next: '.pages .action.next',
|
||||
negativeMargin: window.negativeMargin
|
||||
};
|
||||
|
||||
var pagertext = jQuery(".toolbar-amount");
|
||||
pagertext.show();
|
||||
|
||||
/** added to prevent jquery to add extra "_" parameter to link */
|
||||
$.ajaxSetup({ cache: true });
|
||||
|
||||
/** add infinite-scroll class */
|
||||
$(config.container).closest('.column.main').addClass('infinite-scroll');
|
||||
/** load ias */
|
||||
var ias = $.ias(config);
|
||||
|
||||
ias.getNextUrl = function(container) {
|
||||
if (!container) {
|
||||
container = ias.$container;
|
||||
}
|
||||
/** always take the last matching item + fix to be protocol relative */
|
||||
var nexturl = $(ias.nextSelector, container).last().attr('href');
|
||||
if(typeof nexturl !== "undefined") {
|
||||
if (window.location.protocol == 'https:') {
|
||||
nexturl = nexturl.replace('http:', window.location.protocol);
|
||||
} else {
|
||||
nexturl = nexturl.replace('https:', window.location.protocol);
|
||||
}
|
||||
nexturl = window.ajaxInfiniteScroll.removeQueryStringParameter('_', nexturl);
|
||||
nexturl = window.ajaxInfiniteScroll.removeQueryStringParameter('ajax', nexturl);
|
||||
}
|
||||
|
||||
return nexturl;
|
||||
};
|
||||
|
||||
/** adds extra functionality to Infinite AJAX Scroll */
|
||||
ias.extension(new IASPagingExtension());
|
||||
ias.on('pageChange', function(pageNum, scrollOffset, url) {
|
||||
window.page = pageNum;
|
||||
});
|
||||
|
||||
/** added to prevent jquery to add extra "_" parameter to link */
|
||||
ias.on('load', function(event) {
|
||||
var url = event.url;
|
||||
event.ajaxOptions.cache = true;
|
||||
event.url = window.ajaxInfiniteScroll.removeQueryStringParameter('_', event.url);
|
||||
});
|
||||
|
||||
ias.on('loaded', function(data, items) {
|
||||
/** fix lazy load images */
|
||||
window.ajaxInfiniteScroll.reloadImages(items);
|
||||
window.ajaxInfiniteScroll.dataLayerUpdate(data);
|
||||
});
|
||||
/** fix ajax add to cart */
|
||||
ias.on('rendered', function(items) {
|
||||
window.ajaxInfiniteScroll.fixAddToCart();
|
||||
/** re-init Pearl related elements */
|
||||
window.ajaxInfiniteScroll.reloadQuickView();
|
||||
window.ajaxInfiniteScroll.reloadCategoryPage();
|
||||
/** update next/prev head links */
|
||||
if (window.showCanonical == 1) {
|
||||
window.ajaxInfiniteScroll.reloadCanonicalPrevNext();
|
||||
}
|
||||
$('.product-item-info a').each(function() {
|
||||
if( typeof $(this).attr('data-item-page') === 'undefined') {
|
||||
$(this).attr('data-item-page', window.page);
|
||||
}
|
||||
});
|
||||
$(document).trigger("wpproductlabels:init");
|
||||
$('li.product-item').trigger('contentUpdated');
|
||||
if (window.isSlCustomPopupUsed && parseInt(window.isSlCustomPopupUsed)) {
|
||||
$('li.product-item').find('.towishlist').each(function() {
|
||||
$(this).removeAttr('data-post');
|
||||
})
|
||||
}
|
||||
$.mage.formKey();
|
||||
});
|
||||
|
||||
|
||||
/** adds a text when there are no more pages to load */
|
||||
ias.extension(new IASNoneLeftExtension({
|
||||
html: '<span class="ias-no-more">' + window.textNoMore + '</span>'
|
||||
|
||||
}));
|
||||
/** displays a customizable loader image when loading a new page */
|
||||
var loadingHtml = '<div class="ias-spinner">';
|
||||
loadingHtml += '<img src="{src}"';
|
||||
if (window.wp_ajax_useCustomPlaceholder == '1') {
|
||||
loadingHtml += "style='max-width:" + window.wp_ajax_placeholderCustomWidth +"'";
|
||||
}
|
||||
loadingHtml += '/>';
|
||||
loadingHtml += '<span>' + window.textLoadingMore + '</span>';
|
||||
loadingHtml += '</div>';
|
||||
ias.extension(new IASSpinnerExtension({
|
||||
src: window.loadingImage,
|
||||
html: loadingHtml
|
||||
}));
|
||||
|
||||
/** adds "Load More" and "Load Previous" button */
|
||||
if (window.LoadMore > 0) {
|
||||
ias.extension(new IASTriggerExtension({
|
||||
text: window.textNext,
|
||||
html: '<button class="button action ias-load-more" type="button"><span>{text}</span></button>',
|
||||
textPrev: 'Load previous items',
|
||||
htmlPrev: '<button class="button action ias-load-prev" type="button"><span>{text}</span></button>',
|
||||
offset: window.LoadMore
|
||||
}));
|
||||
} else {
|
||||
ias.extension(new IASTriggerExtension({
|
||||
textPrev: 'Load previous items',
|
||||
htmlPrev: '<button class="button action ias-load-prev" type="button"><span>{text}</span></button>',
|
||||
offset: 1000
|
||||
}));
|
||||
}
|
||||
/** adds history support */
|
||||
ias.extension(new IASHistoryExtension({prev: '.previous'}));
|
||||
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
updateContent: function (content) {
|
||||
this._updateContent(content)
|
||||
},
|
||||
|
||||
|
||||
changeUrl: function (paramName, paramValue, defaultValue) {
|
||||
var urlPaths = this.options.url.split('?'),
|
||||
baseUrl = urlPaths[0],
|
||||
urlParams = urlPaths[1] ? urlPaths[1].split('&') : [],
|
||||
paramData = this.getParams(urlParams, paramName, paramValue, defaultValue);
|
||||
window.isSorting = (paramName == 'product_list_order' || paramName == 'product_list_limit' || paramName == 'p') ? true : false;
|
||||
if( paramName == 'product_list_mode') {// paramName == 'product_list_order' - to remove adavancedsorting by ajax
|
||||
var ajaxParam = false;
|
||||
for (var i = urlParams.length; i--;) {
|
||||
if (urlParams[i] === 'ajax=1') {
|
||||
urlParams.splice(i, 1);
|
||||
ajaxParam = true;
|
||||
}
|
||||
}
|
||||
if (ajaxParam) {
|
||||
paramData = this.getParams(urlParams, paramName, paramValue, defaultValue);
|
||||
}
|
||||
location.href = baseUrl + (paramData.length ? '?' + paramData : '');
|
||||
} else {
|
||||
this.makeAjaxCall(baseUrl, paramData, true);
|
||||
}
|
||||
},
|
||||
|
||||
backToTop: function()
|
||||
{
|
||||
var stickyHeader = $('.sticky-header, .sticky-header-mobile, .page-header.sticky'),
|
||||
stickyHeaderHeight = 0;
|
||||
if (stickyHeader.length) {
|
||||
stickyHeaderHeight = parseInt(stickyHeader.outerHeight());
|
||||
}
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: ($('.column.main').offset().top - stickyHeaderHeight)
|
||||
}, 'slow');
|
||||
},
|
||||
|
||||
makeAjaxCall: function (baseUrl, paramData, pushState) {
|
||||
var self = this;
|
||||
var isSlideIn = $('body').hasClass('slider-layer');
|
||||
if (!isSlideIn) {
|
||||
self.backToTop();
|
||||
}
|
||||
var showLoader = true;
|
||||
if (window.wp_ajax_useCustomPlaceholder == '1' && window.isSorting) {
|
||||
$('.page-wrapper').loader("show");
|
||||
showLoader = false;
|
||||
}
|
||||
var jqxhr = $.ajax({
|
||||
url: baseUrl,
|
||||
data: (paramData && paramData.length > 0) ? paramData + '&ajax=1' : 'ajax=1',
|
||||
type: 'get',
|
||||
global: false,
|
||||
dataType: 'json',
|
||||
cache: true,
|
||||
showLoader: showLoader,
|
||||
beforeSend: function (xhr){
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
if(typeof window.page === 'undefined') {
|
||||
window.page = $('.product-item-info a').last().attr('data-item-page');
|
||||
}
|
||||
}
|
||||
}).done(function (response) {
|
||||
if (response.success) {
|
||||
$('.swatch-option-tooltip').hide();
|
||||
self.updateUrl(baseUrl, paramData, pushState);
|
||||
self.updateContent(response.html);
|
||||
self.slidersUpdate();
|
||||
}
|
||||
});
|
||||
|
||||
jqxhr.always(function() {
|
||||
if (window.wp_ajax_useCustomPlaceholder == '1') {
|
||||
$('.page-wrapper').loader("hide");
|
||||
}
|
||||
/** fix lazy load image width */
|
||||
$("img.lazy").each(function() {
|
||||
$(this).css({'max-width':'100%'});
|
||||
});
|
||||
|
||||
self.reinitializeIas();
|
||||
$('.product.photo.product-item-photo').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var page = $(this).attr('data-item-page');
|
||||
var url = window.location.href;
|
||||
self.resetIasPagination(page, url);
|
||||
var href = $(this).attr('href');
|
||||
window.location.href = href;
|
||||
});
|
||||
$('.product-item-info a').each(function() {
|
||||
if( typeof $(this).attr('data-item-page') === 'undefined') {
|
||||
$(this).attr('data-item-page', window.page);
|
||||
}
|
||||
});
|
||||
if(require.defined('ias') && window.ajaxCatalog == 'nextPage') {
|
||||
window.ajaxInfiniteScroll.addPageSelector('.pages li.item a.page');
|
||||
}
|
||||
|
||||
if ($('body').hasClass('slider-layer')) self.resetPage();
|
||||
if ($('body').hasClass('slider-down-layer')) self.slideUpReset();
|
||||
|
||||
self.reloadQuickView();
|
||||
window.shouldOpenMinicart = '1';
|
||||
$.mage.formKey();
|
||||
});
|
||||
},
|
||||
resetIasPagination: function(page, url) {
|
||||
if(require.defined('ias') && window.ajaxCatalog == 'infiniteScroll') {
|
||||
jQuery.ias().destroy();
|
||||
var newUrl = url.replace(/(&p=|\?p=).*?(&|$)/,'$1' + page + '$2');
|
||||
window.history.replaceState("", "", newUrl);
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
reloadQuickView: function() {
|
||||
var quickView = $('.weltpixel-quickview');
|
||||
if (quickView.length) {
|
||||
$('.weltpixel-quickview').bind('click', function() {
|
||||
var prodUrl = $(this).attr('data-quickview-url');
|
||||
if (prodUrl.length) {
|
||||
window.quickview.displayContent(prodUrl);
|
||||
}
|
||||
});
|
||||
if (window.wpQwListMode == 'list') {
|
||||
quickView.each(function (key, item) {
|
||||
if (!$(item).hasClass('wp-qw-adjusted')) {
|
||||
var imageWrapper = $(item).closest('.product-item').find('.product-item-info').get(0);
|
||||
var imagePhotoLink = $(item).closest('.product-item-info').find('.product-item-photo').get(0);
|
||||
|
||||
$(imageWrapper).prepend('<div class="product photo product-item-photo product-image-list"></div>');
|
||||
var imageCustomDiv = $(item).closest('.product-item-info').find('.product-image-list').get(0);
|
||||
|
||||
$(imagePhotoLink).appendTo(imageCustomDiv)
|
||||
var imagePhoto = $(item).closest('.product-item-info').find('.product-image-list').get(0);
|
||||
$(item).show().appendTo(imagePhoto);
|
||||
$(item).addClass('wp-qw-adjusted');
|
||||
$(item).css('display', '');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
slidersUpdate: function () {
|
||||
$('.wp-slide-in').not(':first').remove();
|
||||
$('.wp-slide-out').not(':first').remove();
|
||||
$('.wp-filters').not(':first').remove();
|
||||
$('.wp-ln-overlay').not(':first').remove();
|
||||
$('.wp-ln-slider-js').not(':first').remove();
|
||||
$('.wp-ln-selected-js').not(':first').remove();
|
||||
},
|
||||
resetPage: function () {
|
||||
var slideInBlock = $('#layered-filter-block');
|
||||
if(slideInBlock.hasClass('auto-close')) {
|
||||
//$('.slide-in-filter').hide('slide', {direction: "left"}, 500, function () {
|
||||
$('body').removeClass('wp-ln-open').css({'height': 'auto', 'overflow': 'auto'});
|
||||
$('.wp-ln-overlay').hide();
|
||||
$('.block-search, a.logo').css({'z-index': '10'});
|
||||
//});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
slideUpReset: function () {
|
||||
var slideDownBlock = $('#layered-filter-block');
|
||||
if(slideDownBlock.hasClass('auto-close')) {
|
||||
//$('.wp-slide-down-add.active').off('click');
|
||||
//$('.wp-slide-down-add:not(active)').on('click', self.lnSlideDown());
|
||||
$('.wp-filters span.wp-slide-down-add').removeClass('active');
|
||||
$('.products.wrapper').animate({marginTop: '0px'}, 1000);
|
||||
$('.slide-down-filter').slideUp(1000);
|
||||
$('.wp-filters').off('click');
|
||||
} else {
|
||||
$('.wp-filters span.wp-slide-down-add').removeClass('active');
|
||||
$('.wp-filters').off('click');
|
||||
}
|
||||
},
|
||||
|
||||
markSelected: function () {
|
||||
var elem = self.elem.parent();
|
||||
if(elem.hasClass('wp-ln-selected')) {
|
||||
elem.removeClass('wp-ln-selected');
|
||||
|
||||
} else {
|
||||
elem.addClass('wp-ln-selected');
|
||||
}
|
||||
|
||||
},
|
||||
removeQueryStringParameter: function (key, url)
|
||||
{
|
||||
if (!url) url = window.location.href;
|
||||
var hashParts = url.split('#'),
|
||||
regex = new RegExp("([?&])" + key + "=.*?(&|#|$)", "i");
|
||||
|
||||
if (hashParts[0].match(regex)) {
|
||||
url = hashParts[0].replace(regex, '$1');
|
||||
url = url.replace(/([?&])$/, '');
|
||||
if (typeof hashParts[1] !== 'undefined' && hashParts[1] !== null)
|
||||
url += '#' + hashParts[1];
|
||||
}
|
||||
|
||||
return url;
|
||||
},
|
||||
getUrlParams: function (url) {
|
||||
var params = {
|
||||
p: "1"
|
||||
};
|
||||
var parser = document.createElement('a');
|
||||
parser.href = url;
|
||||
var query = parser.search.substring(1);
|
||||
var vars = query.split('&');
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
var pair = vars[i].split('=');
|
||||
params[pair[0]] = decodeURIComponent(pair[1]);
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return $.mage.productListToolbarForm;
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
define([
|
||||
"jquery"
|
||||
], function ($) {
|
||||
"use strict";
|
||||
|
||||
window.wpFilterSelect = {
|
||||
markSelected: function() {
|
||||
$.each($('#wp_ln_shopby_items li'), function() {
|
||||
var id = $(this).data('attr-id');
|
||||
if(id) {
|
||||
var filterElem = $('#wp_ln_attr_' + id);
|
||||
var filterSwatchElem = $('#wp_ln_swatch_attr_' + id);
|
||||
|
||||
if(filterElem.length) {
|
||||
filterElem.addClass('wp-ln-selected');
|
||||
}
|
||||
|
||||
if(filterSwatchElem.length) {
|
||||
filterSwatchElem.addClass('wp-ln-selected');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user