PageSourceSearch

https://genesis-forex.com/wp-content/plugins/add-to-cart-direct-ch…/public/js/pi-dcw-public.js?ver=2.1.73.77

js genesis-forex.com collected 2026-10-07 21:17:36 UTC 4,195 bytes, 149 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	/**
5	 * All of the code for your public-facing JavaScript source
6	 * should reside in this file.
7	 *
8	 * Note: It has been assumed you will write jQuery code here, so the
9	 * $ function reference has been prepared for usage within the scope
10	 * of this function.
11	 *
12	 * This enables you to define handlers, for when the DOM is ready:
13	 *
14	 * $(function() {
15	 *
16	 * });
17	 *
18	 * When the window is loaded:
19	 *
20	 * $( window ).load(function() {
21	 *
22	 * });
23	 *
24	 * ...and/or other possibilities.
25	 *
26	 * Ideally, it is not considered best practise to attach more than a
27	 * single DOM-ready or window-load handler for a particular page.
28	 * Although scripts in the WordPress core, Plugins and Themes may be
29	 * practising this, we should strive to set a better example in our own work.
30	 */
31
32	jQuery(document).ready(function ($) {
33
34		var variation_obj = new variation()
35		variation_obj.init();
36		function variation() {
37			this.is_variable = false;
38
39			this.init = function () {
40				this.is_variable = this.checkIfVariable();
41				this.checkAddToCart();
42				this.variationChange();
43				this.buttonChange();
44				this.addHidden();
45				this.buttonChange();
46			}
47
48			this.checkIfVariable = function () {
49				var $ = jQuery;
50				if ($("input[name='variation_id']").length) {
51					return true;
52				}
53				return false;
54			}
55
56			this.variationChange = function () {
57				var parent = this;
58				jQuery("body").on('change', "input[name='variation_id']", function () {
59					parent.checkAddToCart();
60				});
61			}
62
63			this.checkAddToCart = function () {
64				if (this.is_variable) {
65					var id = parseInt($("input[name='variation_id']").val());
66					var parentForm = $("input[name='variation_id']").closest("form.variations_form");
67					if(parentForm.length > 0){
68						var button = parentForm.find(".pisol_single_buy_now"); 
69					}else{
70						var button = $("button.pisol_single_buy_now");
71					}
72					if (id > 0 && id != "") {
73						this.statusBuyNow(button, true);
74					} else {
75						this.statusBuyNow(button, false);
76					}
77				}
78			}
79
80			this.buttonChange = function () {
81				var parent = this;
82
83				$(".single_variation_wrap").on("show_variation", function (event, variation) {
84					var button = jQuery(".pisol_single_buy_now", this);
85					if (variation['is_in_stock']) {
86						parent.statusBuyNow(button, true);
87					} else {
88						parent.statusBuyNow(button, false, true);
89					}
90				});
91			}
92
93			this.statusBuyNow = function (button, status, out_of_stock = false) {
94				var $ = jQuery;
95				if (status) {
96					//$(".pisol_single_buy_now").attr("disabled", false);
97					$(".pisol_single_buy_now").removeClass('disabled');
98					button.removeAttr('data-message');
99				} else {
100					//$(".pisol_single_buy_now").attr("disabled", true);
101					$(".pisol_single_buy_now").addClass('disabled');
102
103					var message  = '';
104					if(out_of_stock){
105						if(typeof wc_add_to_cart_variation_params != 'undefined'){
106							message = wc_add_to_cart_variation_params.i18n_unavailable_text ?? '';
107						}
108					}else{
109						if(typeof wc_add_to_cart_variation_params != 'undefined'){
110							message = wc_add_to_cart_variation_params.i18n_make_a_selection_text ?? '';
111						}
112					}
113					button.attr('data-message', message);
114				}
115			}
116
117			this.addHidden = function () {
118				var $ = jQuery;
119				var parent = this;
120				$(document).on("click", ".pisol_single_buy_now", function (e) {
121					/*
122					$(this).after('<input type="hidden" name="pi_quick_checkout" value="true"/>');
123					*/
124					if($(this).hasClass('disabled')){
125						e.preventDefault();
126						parent.showWarning($(this));
127						return;
128					}
129
130					$(this).off('click', function () {
131						$(this).trigger('click');
132					});
133
134					/** this prevents ajax add to cart added by other plugins */
135					$(document).trigger('pisol_dtt_buy_now_clicked', [this]);
136					jQuery(document.body).off('submit', 'form.cart');
137				});
138			}
139
140			this.showWarning = function (button) {
141				var message = button.attr("data-message");
142				if(message){
143					alert(message);
144				}
145			}
146		}
147	});
148
149})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.