Skip to content

Commit

Permalink
Merge pull request #138 from Voog/137-product-multi-assets
Browse files Browse the repository at this point in the history
Add multi-assets support to auto-rendered product page
  • Loading branch information
PeeterPaal authored Nov 27, 2023
2 parents 9223db9 + bfd6397 commit 0b66d20
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 39 deletions.
9 changes: 0 additions & 9 deletions javascripts/editmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,6 @@
});
};

// Opens product admin view on product image click

var handleProductImageClick = function(product_id) {
$('.product-content .product-image').click(function() {
window.open('/admin/ecommerce/products/' + product_id, '_blank').focus();
});
};

var init = function() {
bindCustomDataItem();
handleDocument();
Expand All @@ -719,7 +711,6 @@
bindProductListeners: bindProductListeners,
initProductPageSettings: initProductPageSettings,
initSettingsEditorBtn: initSettingsEditorBtn,
handleProductImageClick: handleProductImageClick
});

// Initiates site wide functions.
Expand Down
2 changes: 1 addition & 1 deletion javascripts/editmode.min.js

Large diffs are not rendered by default.

21 changes: 9 additions & 12 deletions layouts/auto_generated_product.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@
<div class="flex_row flex_row-2 reverse-col-tablet mar_0-32-neg">
<div class="flex_row-2--item-60">
<div class="mar_0-32 p-rel js-product-page-image-wrap">
{%- if product.image != blank %}
{% assign item_image_state = "with-image" %}
{%- if product.photos != blank %}
{% assign item_image_state = "with-images" %}
{% else %}
{% assign item_image_state = "without-image" %}
{% assign item_image_state = "without-images" %}
{% endif -%}

<div class="js-product-page-image mar_b-32">
<div class="content-item-box {{ item_image_state }} js-content-item-box not-loaded">
<div class="item-top product-image">
<div class="content-item-box {{ item_image_state }}">
<div class="item-top without-pointer">
<div class="top-inner of-hidden">
{%- if product.image != blank -%}
<div class="loader js-loader"></div>
{%- assign imageClass = "item-image " | append: "not-cropped " | append: "js-lazyload" -%}
{% image_data product.image target_width="600" class: imageClass %}
{%- if product.photos != blank -%}
<div class="item-image">
{% gallery product layout="product_slider" %}
</div>
{%- endif -%}
</div>
</div>
Expand Down Expand Up @@ -185,9 +185,6 @@
<script>
if (site) {
site.handleProductPageContent();
{%- if product and editmode %}
site.handleProductImageClick({{ product.id }});
{% endif -%}
}
</script>
{% include "settings-popover" %}
Expand Down
9 changes: 0 additions & 9 deletions sources/javascripts/concat/editmode/editmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,14 +695,6 @@
});
};

// Opens product admin view on product image click

var handleProductImageClick = function(product_id) {
$('.product-content .product-image').click(function() {
window.open('/admin/ecommerce/products/' + product_id, '_blank').focus();
});
};

var init = function() {
bindCustomDataItem();
handleDocument();
Expand All @@ -719,7 +711,6 @@
bindProductListeners: bindProductListeners,
initProductPageSettings: initProductPageSettings,
initSettingsEditorBtn: initSettingsEditorBtn,
handleProductImageClick: handleProductImageClick
});

// Initiates site wide functions.
Expand Down
13 changes: 9 additions & 4 deletions sources/stylesheets/components/_image-drop-area.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
justify-content: center;
overflow: hidden;

.editmode & {
cursor: pointer;
&:not(.without-pointer) {
.editmode & {
cursor: pointer;
}
}

article & {
Expand Down Expand Up @@ -60,13 +62,15 @@
}
}

.without-image & {
.without-image &,
.without-images & {
background-color: $white;
background-image: url('../assets/ico-placeholder.svg');
background-size: 40px;
background-repeat: no-repeat;
background-position: center;
}

.top-inner {
// scss-lint:disable ImportantRule
display: flex !important;
Expand All @@ -80,7 +84,8 @@
width: 100%;
background: transparent;

.without-image .editmode & {
.without-image .editmode &,
.without-images .editmode & {
border: none;
}

Expand Down
8 changes: 5 additions & 3 deletions stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4970,7 +4970,7 @@ body .edy-tick-checkbox-btn .edy-tick-checkbox-label-padded:hover {
left: 0;
}

.editmode .item-top {
.editmode .item-top:not(.without-pointer) {
cursor: pointer;
}

Expand Down Expand Up @@ -5042,7 +5042,8 @@ article .item-top > .aspect-ratio-inner {
display: none;
}

.without-image .item-top {
.without-image .item-top,
.without-images .item-top {
background-color: #ffffff;
background-image: url("../assets/ico-placeholder.svg");
background-size: 40px;
Expand All @@ -5068,7 +5069,8 @@ article .item-top > .aspect-ratio-inner {
background: transparent;
}

.without-image .editmode .item-top .top-inner {
.without-image .editmode .item-top .top-inner,
.without-images .editmode .item-top .top-inner {
border: none;
}

Expand Down
2 changes: 1 addition & 1 deletion stylesheets/main.min.css

Large diffs are not rendered by default.

0 comments on commit 0b66d20

Please sign in to comment.