PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 2.2.8
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v2.2.8
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 / clear-cart / admin / preview.js

preview.js in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 2.2.8, at assets/js/modules/clear-cart/admin/preview.js

76 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2
3 ;
4 (function ($, window, document, undefined) {
5 var autoClearEnabledOnLoad = $('.merchant-field-enable_auto_clear input').is(':checked');
6
7 // Clear Cookie
8 $(document).on('save.merchant', function (e, module) {
9 if (module === 'clear-cart') {
10 var autoClearEnabledOnSave = $('.merchant-field-enable_auto_clear input').is(':checked');
11 if (autoClearEnabledOnLoad && !autoClearEnabledOnSave) {
12 document.cookie = 'merchant_clear_cart=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/';
13 }
14 }
15 });
16
17 // Page load
18 $(document).on('ready', function () {
19 initPreview();
20 });
21
22 // Change settings
23 $(document).on('change', function () {
24 initPreview();
25 });
26
27 // Change button style
28 $(document).on('change', '.merchant-field-style input', function () {
29 var val = $(this).val();
30 var color = "#ffffff";
31 if (val === 'outline' || val === 'text') {
32 color = "#212121";
33 }
34 $('.merchant-field-text_color input, .merchant-field-text_color_hover input').val(color).attr('value', color).trigger('change').trigger('input');
35 });
36 function initPreview() {
37 var $buttonPreview = $('.merchant-clear-cart-button');
38 var isCartPageEnabled = $('.merchant-field-enable_cart_page input').is(':checked');
39 var $cartPagePositionField = $('.merchant-field-cart_page_position select');
40 var cartPagePosition = $cartPagePositionField.val();
41
42 // If Cart Page is Disabled
43 $buttonPreview.toggleClass('hide', !isCartPageEnabled);
44 if (isCartPageEnabled) {
45 $buttonPreview.each(function () {
46 if ($(this).hasClass(cartPagePosition)) {
47 $(this).removeClass('hide');
48 } else {
49 $(this).addClass('hide');
50 }
51 });
52 }
53
54 // Style - Solid/Outline/Text
55 var $buttonStyleField = $('.merchant-field-style input');
56 $buttonStyleField.each(function () {
57 var value = $(this).val();
58 $buttonPreview.removeClass("merchant-clear-cart-button--".concat(value));
59 if ($(this).is(':checked')) {
60 $buttonPreview.addClass("merchant-clear-cart-button--".concat(value));
61 }
62 });
63 var $shopTableBottom = $('.shop_table-bottom');
64 $cartPagePositionField.find('option').each(function () {
65 var value = $(this).val();
66
67 // Remove the class corresponding to the value of each option
68 $shopTableBottom.removeClass(value);
69
70 // If the current option is selected, add the class
71 if ($(this).is(':selected')) {
72 $shopTableBottom.addClass(value);
73 }
74 });
75 }
76 })(jQuery, window, document);