Skip to content

Commit 6400b36

Browse files
release: fixes
- Fixed issue with single product page gallery layout - Fixed issue with social icons component
2 parents 2ffa75a + f84850c commit 6400b36

File tree

6 files changed

+119
-280
lines changed

6 files changed

+119
-280
lines changed

assets/apps/customizer-controls/src/repeater/Repeater.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Repeater = ({
4444
for (const [field] of Object.entries(itemFields)) {
4545
newItem.visibility = 'yes';
4646

47-
if (typeof value[0][field] === 'boolean') {
47+
if (typeof value[0]?.[field] === 'boolean') {
4848
newItem[field] = true;
4949
if (field === 'hide_on_mobile') {
5050
newItem[field] = false;

assets/apps/customizer-controls/src/repeater/RepeaterItemContent.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,40 @@ const RepeaterItemContent = ({
169169
/>
170170
);
171171
case 'switcher':
172-
return <Switcher fieldId={key} currentField={currentField} />;
172+
const selectedOption =
173+
value[index][key] || Object.keys(currentField.options)[0];
174+
175+
return (
176+
<>
177+
<ButtonGroup className="neve-background-type-control">
178+
{Object.entries(currentField.options).map(
179+
([optionKey, option]) => {
180+
return (
181+
<Button
182+
key={optionKey}
183+
isPrimary={
184+
optionKey === selectedOption
185+
}
186+
isSecondary={
187+
optionKey !== selectedOption
188+
}
189+
onClick={() => {
190+
changeContent(key, optionKey);
191+
}}
192+
>
193+
{option.label}
194+
</Button>
195+
);
196+
}
197+
)}
198+
</ButtonGroup>
199+
{currentField.options?.[selectedOption]?.fields.map(
200+
(componentId) => {
201+
return toComponent(componentId, value[index]);
202+
}
203+
)}
204+
</>
205+
);
173206
case 'media':
174207
return (
175208
<Placeholder
@@ -217,39 +250,6 @@ const RepeaterItemContent = ({
217250
}
218251
};
219252

220-
const Switcher = ({ fieldId, currentField }) => {
221-
const selectedOption =
222-
value[index][fieldId] || Object.keys(currentField.options)[0];
223-
224-
return (
225-
<>
226-
<ButtonGroup className="neve-background-type-control">
227-
{Object.entries(currentField.options).map(
228-
([optionKey, option]) => {
229-
return (
230-
<Button
231-
key={optionKey}
232-
isPrimary={optionKey === selectedOption}
233-
isSecondary={optionKey !== selectedOption}
234-
onClick={() => {
235-
changeContent(fieldId, optionKey);
236-
}}
237-
>
238-
{option.label}
239-
</Button>
240-
);
241-
}
242-
)}
243-
</ButtonGroup>
244-
{currentField.options?.[selectedOption]?.fields.map(
245-
(componentId) => {
246-
return toComponent(componentId, value[index]);
247-
}
248-
)}
249-
</>
250-
);
251-
};
252-
253253
return (
254254
<div
255255
className={classNames('sortable-subcontrols', {

assets/js/src/shop/app.js

Lines changed: 82 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,95 @@
11
/* jshint esversion: 6 */
2-
/* global jQuery, CustomEvent */
3-
/* global neveShopSlider */
2+
/* global CustomEvent */
43
import { tns } from 'tiny-slider/src/tiny-slider';
54

6-
(function ($) {
7-
/**
8-
* Init shop.
9-
*/
10-
function initShop() {
11-
const $body = $('body');
12-
if ($body.hasClass('woocommerce')) {
13-
handleShopSidebar();
14-
}
15-
16-
const countExclusive = $('.exclusive-products li.product').length;
17-
18-
if ($body.hasClass('nv-exclusive') && countExclusive > 4) {
19-
handleExclusiveSlider();
20-
}
21-
22-
if (
23-
'1' !== neveShopSlider.isSparkActive &&
24-
$body.hasClass('single-product')
25-
) {
26-
handleGallerySlider();
27-
}
5+
/**
6+
* Init shop.
7+
*/
8+
function initShop() {
9+
if (document.body.classList.contains('woocommerce')) {
10+
handleShopSidebar();
2811
}
2912

30-
/**
31-
* Add prev and next
32-
*
33-
* @param {Node} targetNode
34-
* @param {Node} slider
35-
* @param {string} vertical
36-
*/
37-
function addNextPrev(targetNode, slider, vertical = false) {
38-
const $next = $('<span/>')
39-
.addClass('next dashicons')
40-
.addClass(
41-
'dashicons-arrow-' + (vertical ? 'down' : 'right') + '-alt2'
42-
);
43-
const $prev = $('<span/>')
44-
.addClass('prev dashicons')
45-
.addClass(
46-
'dashicons-arrow-' + (vertical ? 'up' : 'left') + '-alt2'
47-
);
48-
49-
$prev.on('click', () => slider.goTo('prev'));
13+
const countExclusive = document.querySelectorAll(
14+
'.exclusive-products li.product'
15+
).length;
5016

51-
$next.on('click', () => slider.goTo('next'));
52-
53-
const $target = $(targetNode);
54-
$prev.insertBefore($target);
55-
$next.insertAfter($target);
17+
if (
18+
document.body.classList.contains('nv-exclusive') &&
19+
countExclusive > 4
20+
) {
21+
handleExclusiveSlider();
5622
}
57-
58-
/**
59-
* Handle the shop sidebar.
60-
*/
61-
function handleShopSidebar() {
62-
const $sidebar = $('.shop-sidebar');
63-
if (0 === $sidebar.length) {
64-
return;
65-
}
66-
const $html = $('html');
67-
const $toggles = $('.nv-sidebar-toggle');
68-
$toggles.each(function () {
69-
$(this).on('click', function (e) {
70-
e.preventDefault();
71-
$sidebar.toggleClass('sidebar-open');
72-
$html.toggleClass('menu-openend');
73-
});
74-
});
23+
}
24+
25+
/**
26+
* Handle the shop sidebar.
27+
*/
28+
function handleShopSidebar() {
29+
const sidebar = document.querySelector('.shop-sidebar');
30+
if (sidebar === null) {
31+
return;
7532
}
76-
77-
/**
78-
* Handle Exclusive Products Slider
79-
*/
80-
function handleExclusiveSlider() {
81-
const $items = $('ul.exclusive-products');
82-
83-
if (0 === $items.length) return;
84-
85-
const responsive = {
86-
0: { items: 2, gutter: 21 },
87-
768: { items: 4, gutter: 27 },
88-
1200: { items: 4, gutter: 30 },
89-
};
90-
91-
const slider = tns({
92-
container: 'ul.exclusive-products',
93-
slideBy: 1,
94-
arrowKeys: true,
95-
loop: true,
96-
autoplay: true,
97-
items: 4,
98-
edgePadding: 0,
99-
autoplayButtonOutput: false,
100-
autoplayHoverPause: true,
101-
speed: 1000,
102-
autoplayTimeout: 3000,
103-
autoplayButton: false,
104-
controls: false,
105-
navPosition: 'bottom',
106-
navContainer: '.dots-nav',
107-
navAsThumbnails: true,
108-
responsive,
33+
const html = document.querySelector('html');
34+
const toggles = document.querySelectorAll('.nv-sidebar-toggle') || [];
35+
toggles.forEach((toggle) => {
36+
toggle.addEventListener('click', function (e) {
37+
e.preventDefault();
38+
sidebar.classList.toggle('sidebar-open');
39+
html.classList.toggle('menu-openend');
10940
});
41+
});
42+
}
43+
44+
/**
45+
* Handle Exclusive Products Slider
46+
*/
47+
function handleExclusiveSlider() {
48+
const items = document.querySelector('ul.exclusive-products');
49+
50+
if (items === null) return false;
51+
52+
const responsive = {
53+
0: { items: 2, gutter: 21 },
54+
768: { items: 4, gutter: 27 },
55+
1200: { items: 4, gutter: 30 },
56+
};
57+
58+
const slider = tns({
59+
container: 'ul.exclusive-products',
60+
slideBy: 1,
61+
arrowKeys: true,
62+
loop: true,
63+
autoplay: true,
64+
items: 4,
65+
edgePadding: 0,
66+
autoplayButtonOutput: false,
67+
autoplayHoverPause: true,
68+
speed: 1000,
69+
autoplayTimeout: 3000,
70+
autoplayButton: false,
71+
controls: false,
72+
navPosition: 'bottom',
73+
navContainer: '.dots-nav',
74+
navAsThumbnails: true,
75+
responsive,
76+
});
11077

111-
// [If Sparks Variation Swatches is enabled and ] Initialize Sparks Variation Swatches for cloned products.
112-
if ($('body').hasClass('sparks-vs-shop-attribute')) {
113-
slider.events.on('transitionEnd', () => {
114-
document.dispatchEvent(
115-
new CustomEvent('sparksVSNeedsInit', {
116-
detail: { container: '.products.exclusive' },
117-
})
118-
);
119-
});
120-
}
121-
}
122-
123-
/**
124-
* Handle Gallery Image Slider
125-
*/
126-
function handleGallerySlider() {
127-
const $galleryNav = $('ol.flex-control-nav');
128-
129-
if (0 === $galleryNav.length) return;
130-
131-
const isDesktop = window.innerWidth >= 992;
132-
133-
const slider = tns({
134-
container: 'ol.flex-control-nav',
135-
items: 4,
136-
axis: isDesktop ? 'vertical' : 'horizontal',
137-
slideBy: 'page',
138-
rewind: true,
139-
loop: false,
140-
nav: false,
141-
controls: false,
142-
mouseDrag: true,
78+
// [If Sparks Variation Swatches is enabled and ] Initialize Sparks Variation Swatches for cloned products.
79+
if (document.body.classList.contains('sparks-vs-shop-attribute')) {
80+
slider.events.on('transitionEnd', () => {
81+
document.dispatchEvent(
82+
new CustomEvent('sparksVSNeedsInit', {
83+
detail: {
84+
container: '.products.exclusive',
85+
},
86+
})
87+
);
14388
});
144-
145-
addNextPrev(
146-
$('.woocommerce-product-gallery .tns-inner')[0],
147-
slider,
148-
isDesktop
149-
);
15089
}
90+
}
15191

152-
/**
153-
* Run JS on load.
154-
*/
155-
$(function () {
156-
initShop();
157-
});
158-
})(jQuery);
92+
/**
93+
* Run JS on load.
94+
*/
95+
window.addEventListener('load', initShop);

0 commit comments

Comments
 (0)