-
Notifications
You must be signed in to change notification settings - Fork 600
/
quick-view.js
38 lines (27 loc) · 1.22 KB
/
quick-view.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import 'foundation-sites/js/foundation/foundation';
import 'foundation-sites/js/foundation/foundation.dropdown';
import utils from '@bigcommerce/stencil-utils';
import ProductDetails from '../common/product-details';
import { defaultModal } from './modal';
import 'slick-carousel';
import { onCarouselChange } from '../common/carousel';
export default function (context) {
const modal = defaultModal();
$('body').on('click', '.quickview', event => {
event.preventDefault();
const productId = $(event.currentTarget).data('productId');
modal.open({ size: 'large' });
utils.api.product.getById(productId, { template: 'products/quick-view' }, (err, response) => {
modal.updateContent(response);
modal.$content.find('.productView').addClass('productView--quickView');
const $carousel = modal.$content.find('[data-slick]');
if ($carousel.length) {
$carousel.on('init', onCarouselChange);
$carousel.on('afterChange', onCarouselChange);
$carousel.slick();
}
modal.setupFocusTrap();
return new ProductDetails(modal.$content.find('.quickView'), context);
});
});
}