Commit 3e017a0c by liumengfei

Merge branch 'developer' into production

parents ae4fd322 2b5ac30b
......@@ -205,9 +205,13 @@ class Topmenu extends JoshineMenu
$columns = "11";
}
if ($childLevel == 0) {
$leftMargin = $child->getChildLeftMargin();
if ($leftMargin != "0" && empty($leftMargin)) {
$leftMargin = "1";
}
$html = "<div class=\"level{$childLevel} {$childrenWrapClass}\">";
$html .= "<div class=\"row \">
<ul class=\"subchildmenu joshine-col-lg-push-1 mega-columns joshine-clearfix joshine-col-lg-{$columns} {$child->getMenuImage()}\">
<ul class=\"subchildmenu joshine-col-lg-push-{$leftMargin} mega-columns joshine-clearfix joshine-col-lg-{$columns} {$child->getMenuImage()}\">
{$this->_getHtml($child, $childrenWrapClass, $limit, $colStops)}
</ul>";
$html .= $this->appendImage($child);
......@@ -228,7 +232,15 @@ class Topmenu extends JoshineMenu
}
if ($child->getMenuImage()) {
$html .= "<div class=\" pull-right joshine-col-lg-3 joshine-col-lg-push-1 joshine-hidden-xs joshine-hidden-sm joshine-hidden-md \">";
$imageLeftMargin = $child->getImageLeftMargin();
if (empty($imageLeftMargin)) {
$imageLeftMargin = "0";
}
$imageWidth = $child->getImageWidth();
if (empty($imageWidth)) {
$imageWidth = "3";
}
$html .= "<div class=\" pull-right joshine-col-lg-{$imageWidth} joshine-col-lg-push-{$imageLeftMargin} joshine-hidden-xs joshine-hidden-sm joshine-hidden-md \">";
$html .= "<img src='{$child->getMenuImage()}'/>";
$html .= "</div>";
}
......
......@@ -27,6 +27,7 @@ class Columns extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
if (!$this->_optionsData) {
$this->_optionsData = [
['value' => '', 'label' => '----'],
['value' => '0', 'label' => '0-columns'],
['value' => '1', 'label' => '1-columns'],
['value' => '2', 'label' => '2-columns'],
['value' => '3', 'label' => '3-columns'],
......
......@@ -147,6 +147,9 @@ class Topmenu extends Menu
'badge' => $category->getData('badge'),
'submenu_columns_total' => $category->getData('submenu_columns_total'),
'self_columns' => $category->getData('self_columns'),
'image_left_margin' => $category->getData('image_left_margin'),
'image_width' => $category->getData('image_width'),
'child_left_margin' => $category->getData('child_left_margin'),
'submenu_columns_single' => $category->getData('submenu_columns_single'),
'menu_image' => $category->getData('menu_image'),
'has_active' => in_array((string)$categoryId, explode('/', (string)$currentCategory->getPath()), true),
......@@ -176,6 +179,9 @@ class Topmenu extends Menu
$collection->addAttributeToSelect('submenu_columns_total');
$collection->addAttributeToSelect('submenu_columns_single');
$collection->addAttributeToSelect('self_columns');
$collection->addAttributeToSelect('image_left_margin');
$collection->addAttributeToSelect('image_width');
$collection->addAttributeToSelect('child_left_margin');
$collection->addAttributeToSelect('menu_image');
$collection->addFieldToFilter('path', ['like' => '1/' . $rootId . '/%']); //load only from store root
$collection->addAttributeToFilter('include_in_menu', 1);
......
......@@ -146,7 +146,49 @@ class UpgradeData implements UpgradeDataInterface
'required' => false,
'sort_order' => 100,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
]
],
'image_left_margin' => [
'type' => 'varchar',
'label' => 'image_left_margin',
'input' => 'select',
'sort_order' => 101,
'source' => '\Joshine\Category\Model\Category\Attribute\Source\Columns',
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'visible_on_front' => true,
'required' => false,
'user_defined' => false,
'default' => null,
'group' => 'image_left_margin',
'backend' => ''
],
'image_width' => [
'type' => 'varchar',
'label' => 'image_width',
'input' => 'select',
'sort_order' => 101,
'source' => '\Joshine\Category\Model\Category\Attribute\Source\Columns',
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'visible_on_front' => true,
'required' => false,
'user_defined' => false,
'default' => null,
'group' => 'image_width',
'backend' => ''
],
'child_left_margin' => [
'type' => 'varchar',
'label' => 'child_left_margin',
'input' => 'select',
'sort_order' => 101,
'source' => '\Joshine\Category\Model\Category\Attribute\Source\Columns',
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'visible_on_front' => true,
'required' => false,
'user_defined' => false,
'default' => null,
'group' => 'child_left_margin',
'backend' => ''
]
];
foreach($menu_attributes as $item => $data) {
......
......@@ -6,5 +6,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Joshine_Category" setup_version="1.1.7"/>
<module name="Joshine_Category" setup_version="1.1.8"/>
</config>
......@@ -39,6 +39,52 @@
</argument>
</field>
<field name="child_left_margin" sortOrder="300">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Joshine\Category\Model\Category\Attribute\Source\Columns</item>
<item name="config" xsi:type="array">
<item name="required" xsi:type="boolean">false</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" translate="false" xsi:type="string">Child left Margin(子类块左间距)</item>
</item>
</argument>
</field>
<field name="image_left_margin" sortOrder="300">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Joshine\Category\Model\Category\Attribute\Source\Columns</item>
<item name="config" xsi:type="array">
<item name="required" xsi:type="boolean">false</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" translate="false" xsi:type="string">image left margin(图片左间距)</item>
</item>
</argument>
</field>
<field name="image_width" sortOrder="300">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Joshine\Category\Model\Category\Attribute\Source\Columns</item>
<item name="config" xsi:type="array">
<item name="required" xsi:type="boolean">false</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" translate="false" xsi:type="string">image width(图片宽度)</item>
</item>
</argument>
</field>
<field name="submenu_columns_total" sortOrder="300">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Joshine\Category\Model\Category\Attribute\Source\Columns</item>
......@@ -49,7 +95,7 @@
</item>
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" translate="false" xsi:type="string">Submenu Columns Total</item>
<item name="label" translate="false" xsi:type="string">Submenu Columns Total(子类块总宽度)</item>
</item>
</argument>
</field>
......@@ -64,7 +110,7 @@
</item>
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" translate="false" xsi:type="string">Self Columns</item>
<item name="label" translate="false" xsi:type="string">Self Columns(自身宽度)</item>
</item>
</argument>
</field>
......@@ -79,7 +125,7 @@
</item>
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" translate="false" xsi:type="string">Submenu Columns Single(will overwrite by Self Columns)</item>
<item name="label" translate="false" xsi:type="string">Submenu Columns Single(子类自身宽度批量设置,如子类自身设置宽度,会被覆盖)</item>
</item>
</argument>
</field>
......
......@@ -120,9 +120,9 @@ $_helper = $block->getData('outputHelper');
<?php
$productImageRaw = $imageHelper->init($_product, $imageDisplayArea)->setImageFile($productImage->getFile())->resize($productImage->getWidth(),$productImage->getHeight())->getUrl();
?>
<img class="product-image-photo" style="background-color: #F0F0F0;border: none;" data-src="<?= $productImageRaw ?>" loading="lazy" width="<?= $productImage->getWidth() ?>px" height="<?= $productImage->getHeight() ?>px" />
<img class="product-image-photo" style="background-color: #F0F0F0;" src="<?= $productImageRaw ?>" loading="lazy" width="<?= $productImage->getWidth() ?>px" height="<?= $productImage->getHeight() ?>px" />
<?php if ($hoverImg): ?>
<img class="hoverImg" width="<?= $productImage->getWidth() ?>px" height="<?= $productImage->getHeight() ?>px" data-src="<?= $hoverImg ?>" loading="lazy" />
<img class="hoverImg" width="<?= $productImage->getWidth() ?>px" height="<?= $productImage->getHeight() ?>px" src="<?= $hoverImg ?>" loading="lazy" />
<?php endif; ?>
</a>
<div class="product details product-item-details">
......@@ -237,44 +237,4 @@ $_helper = $block->getData('outputHelper');
'item' : <?= json_encode($items, true) ?>
})
</script>
<script>
// 获取所有的图片标签
const imgs = document.getElementsByTagName("img");
// 获取可视区域的高度
const viewHeight =
window.innerHeight || document.documentElement.clientHeight;
// num用于统计当前显示到了哪一张图片,避免每次都从第一张图片开始检查是否露出
let num = 0;
function lazyload() {
for (let i = num; i < imgs.length; i++) {
// 用可视区域高度减去元素顶部距离可视区域顶部的高度
let distance = viewHeight - imgs[i].getBoundingClientRect().top;
// 如果可视区域高度大于等于元素顶部距离可视区域顶部的高度,说明元素露出
if (distance >= 0) {
// 给元素写入真实的src,展示图片
imgs[i].src = imgs[i].getAttribute("data-src");
// 前i张图片已经加载完毕,下次从第i+1张开始检查是否露出
num = i + 1;
}
}
}
// 防抖函数
function debounce(fn, delay = 500) {
let timer = null;
return function (...args) {
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
fn.call(this, args);
}, delay);
};
}
// 是的页面初始化是加载首屏图片
window.onload = lazyload;
// 监听Scroll事件,为了防止频繁调用,使用防抖函数优化一下
window.addEventListener("scroll", debounce(lazyload, 600), false);
</script>
<?php endif; ?>
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Product media data template
*
* @var $block \Magento\Catalog\Block\Product\View\Gallery
*/
?>
<style>
.gallery-placeholder__image{height: 1000px;width: 750px;background-color: #F0F0F0;}
@media (max-width: 1024px){ .gallery-placeholder__image{height: 500px;width: 400px;background-color: #F0F0F0;} }
</style>
<?php
$images = $block->getGalleryImages()->getItems();
$mainImage = current(array_filter($images, function ($img) use ($block) {
return $block->isMainImage($img);
}));
if (!empty($images) && empty($mainImage)) {
$mainImage = $block->getGalleryImages()->getFirstItem();
}
$helper = $block->getData('imageHelper');
$mainImageData = $mainImage ?
$mainImage->getData('medium_image_url') :
$helper->getDefaultPlaceholderUrl('image');
?>
<div class="gallery-placeholder _block-content-loading" data-gallery-role="gallery-placeholder">
<img
alt="main product photo"
class="gallery-placeholder__image"
data-src=="<?= /* @noEscape */ $mainImageData ?>"
/>
</div>
<script type="text/x-magento-init">
{
"[data-gallery-role=gallery-placeholder]": {
"mage/gallery/gallery": {
"mixins":["magnifier/magnify"],
"magnifierOpts": <?= /* @noEscape */ $block->getMagnifier() ?>,
"data": <?= /* @noEscape */ $block->getGalleryImagesJson() ?>,
"options": <?= /* @noEscape */ $block->getGalleryOptions()->getOptionsJson() ?>,
"fullscreen": <?= /* @noEscape */ $block->getGalleryOptions()->getFSOptionsJson() ?>,
"breakpoints": <?= /* @noEscape */ $block->getBreakpoints() ?>
}
}
}
</script>
......@@ -19,23 +19,18 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight()
? $logoSizeResolver->getHeight()
: $block->getLogoHeight();
?>
<style>
.secure-span{
display:none;
}
</style>
<span data-action="toggle-nav" class="action nav-toggle"><span><?= $block->escapeHtml(__('Toggle Nav')) ?></span></span>
<a
class="logo show-logo"
href="<?= $block->escapeUrl($block->getUrl('')) ?>"
title="<?= $block->escapeHtmlAttr($storeName) ?>"
aria-label="store logo">
<img class="site-logo" data-src="<?= $block->escapeUrl($block->getLogoSrc()) ?>" src="<?= $block->escapeUrl($block->getLogoSrc()) ?>"
<img class="site-logo" src="<?= $block->escapeUrl($block->getLogoSrc()) ?>"
title="<?= $block->escapeHtmlAttr($block->getLogoAlt()) ?>"
alt="<?= $block->escapeHtmlAttr($block->getLogoAlt()) ?>"
<?= $logoWidth ? 'width="' . $block->escapeHtmlAttr($logoWidth) . '"' : '' ?>
<?= $logoHeight ? 'height="' . $block->escapeHtmlAttr($logoHeight) . '"' : '' ?>
loading="lazy" />
<?= $logoHeight ? 'height="' . $block->escapeHtmlAttr($logoHeight) . '"' : '' ?> />
<?php if ($block->getRequest()->getModuleName() == "checkout") { ?>
<span class="secure-span">
<span class="cut-span" >
/
......@@ -43,4 +38,5 @@ $logoHeight = $logoSizeResolver !== null && $logoSizeResolver->getHeight()
<img class="logo-secure" src="/media/wysiwyg/logo-secure.png" />
<span class="cut-font"><?= __('SECURE CHECKOUT') ?></span>
</span>
<?php } ?>
</a>
......@@ -3335,7 +3335,6 @@ div#shipping-method-buttons-container {
@media(min-width: 1024px) {
div.product-item-info:hover {
background: #ffffff !important;
border: 1px solid #bbbbbb;
position: relative;
z-index: 9;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment