PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.10.1
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.10.1
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / assets / js / modules / quick-view / quick-view.js

quick-view.js in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 1.10.1, at assets/js/modules/quick-view/quick-view.js

86 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 'use strict';
2
3 var merchant = merchant || {};
4 merchant.modules = merchant.modules || {};
5 (function ($) {
6 merchant.modules.quickView = {
7 init: function init() {
8 var self = this;
9 var $modals = $('.merchant-quick-view-modal');
10 if (!$modals.length) {
11 return;
12 }
13 $modals.each(function () {
14 var $modal = $(this);
15 var $openButton = $('.merchant-quick-view-button');
16 var $closeButton = $modal.find('.merchant-quick-view-close-button');
17 var $inner = $modal.find('.merchant-quick-view-inner');
18 var $content = $modal.find('.merchant-quick-view-content');
19 var $overlay = $modal.find('.merchant-quick-view-overlay');
20 var isOpen = false;
21 $openButton.on('click', function (e) {
22 e.preventDefault();
23 $content.empty();
24 $modal.addClass('merchant-show');
25 $modal.addClass('merchant-loading');
26 isOpen = true;
27 $.post(window.merchant.setting.ajax_url, {
28 action: 'merchant_quick_view_content',
29 nonce: window.merchant.setting.nonce,
30 product_id: $(this).data('product-id')
31 }, function (response) {
32 if (response.success && isOpen) {
33 $content.html(response.data);
34 $inner.addClass('merchant-show');
35 $modal.removeClass('merchant-loading');
36 var $gallery = $content.find('.woocommerce-product-gallery');
37 wc_single_product_params.zoom_enabled = window.merchant.setting.quick_view_zoom;
38 if (typeof $.fn.wc_product_gallery === 'function' && $gallery.length) {
39 $gallery.trigger('wc-product-gallery-before-init', [$gallery.get(0), wc_single_product_params]);
40
41 // Force-enable the gallery slider in case the theme/plugin has removed it using `remove_theme_support( 'wc-product-gallery-slider' )`
42 wc_single_product_params['flexslider_enabled'] = '1';
43 $gallery.wc_product_gallery(wc_single_product_params);
44 $gallery.trigger('wc-product-gallery-after-init', [$gallery.get(0), wc_single_product_params]);
45 }
46 var $variations = $content.find('.variations_form');
47 if (typeof $.fn.wc_variation_form === 'function' && $variations.length) {
48 $variations.each(function () {
49 $(this).wc_variation_form();
50 });
51 }
52 if (window.botiga && window.botiga.productSwatch) {
53 window.botiga.productSwatch.init();
54 }
55 if (window.botiga && window.botiga.qtyButton) {
56 window.botiga.qtyButton.init('quick-view');
57 }
58 } else {
59 $content.html(response.data);
60 $inner.addClass('merchant-show');
61 $modal.removeClass('merchant-loading');
62 }
63 window.dispatchEvent(new Event('merchant.quickview.ajax.loaded'));
64 }).fail(function (xhr, textStatus) {
65 $content.html(textStatus);
66 $inner.addClass('merchant-show');
67 $modal.removeClass('merchant-loading');
68 });
69 });
70 $overlay.on('click', function (e) {
71 e.preventDefault();
72 $closeButton.trigger('click');
73 });
74 $closeButton.on('click', function (e) {
75 e.preventDefault();
76 isOpen = false;
77 $modal.removeClass('merchant-show');
78 $inner.removeClass('merchant-show');
79 });
80 });
81 }
82 };
83 $(document).ready(function () {
84 merchant.modules.quickView.init();
85 });
86 })(jQuery);