PageSourceSearch

https://natickfarm.org/wp-content/plugins/addify-advanced-donation/assets/js/af_donat_front_js.js?ver=1.0.0

js natickfarm.org collected 2026-09-24 12:11:42 UTC 27,237 bytes, 808 lines download raw bytes

1jQuery(document).ready(function($){
2	
3	var ajaxurl = af_donat_prod_var.admin_url ;
4	
5	var nonce =  af_donat_prod_var.nonce;
6	
7	if(af_donat_prod_var.theme_name  == "Divi"){
8		$('.modal').css({
9			position: 'fixed',
10			zIndex: 999999,
11			top: 0,
12			left: 0,
13			width: '100%',
14			height: '100%'
15		  });
16		  
17		  $('.modal-content').css({
18			position: 'absolute',
19			zIndex: 1000000
20		  });
21	}
22	//for Astra theme
23	if(af_donat_prod_var.theme_name === "Astra" && window.location.href.indexOf('/cart/') > -1){
24		var modalContent = $('#myModal');
25		$('.site-content').append(modalContent);
26	}
27
28	//hide error message at clicking cross icon
29	$( document ).on( 'click','.wc-block-components-notice-banner__dismiss', function(){
30		$('.wc-block-store-notice').hide();
31	});
32	
33	if ($('.wc-block-checkout').length <= 0) {
34		var DonationPopupBtnCheckout = $('#myBtn');
35		DonationPopupBtnCheckout.show();
36	}
37	
38	af_show_amout_lbl();
39	$( document ).on( 'change', ".af_show_amout_lbl", af_show_amout_lbl );
40
41	function af_show_amout_lbl(){
42		if ( 'af_other_amount' == $('input[name="af_slct_lvl_optn"]:checked').val() ) {
43			$('.af_donat_other_optn').show();
44			$('.af_donat_other').css({
45				"position": "absolute",
46				"top": "16px",
47				"right": "5px"
48			});
49		} else {
50			if ( 'af_show_other_optn' == $('.af_show_optn').val() ) {
51				$('.af_donat_other_optn').show();
52				$('.af_donat_other').css({
53					"position": "absolute",
54					"top": "16px",
55					"right": "5px"
56				});
57			} else {
58				$('.af_donat_other_optn').hide();
59			}
60		}
61	}
62	
63	af_admin_recu_lnght();
64	$( document ).on( 'change', ".af_admin_recu_lnght", af_admin_recu_lnght );
65
66	function af_admin_recu_lnght(){
67		var slect_val        = $( ".af_admin_recu_lnght option:selected" ).val();
68		var slect_val_period = parseInt( $( ".af_dont_inter option:selected" ).val() );
69		if ('day' == slect_val ) {
70			$('#af_donat_sub_other').attr("min", slect_val_period);
71			$('#af_donat_sub_other').attr("max", 90);
72			$('#af_donat_sub_other').attr("placeholder", slect_val_period+'-90');
73			
74		} else if ('week' == slect_val ) {
75			$('#af_donat_sub_other').attr("min", slect_val_period);
76			$('#af_donat_sub_other').attr("max", 52);
77			$('#af_donat_sub_other').attr("placeholder", slect_val_period+'-52');
78			
79		} else if ('month' == slect_val ) {
80			$('#af_donat_sub_other').attr("min", slect_val_period);
81			$('#af_donat_sub_other').attr("max", 24);
82			$('#af_donat_sub_other').attr("placeholder", slect_val_period+'-24');
83			
84		} else if ('year' == slect_val ) {
85			$('#af_donat_sub_other').attr("min", slect_val_period);
86			$('#af_donat_sub_other').attr("max", 5);
87			$('#af_donat_sub_other').attr("placeholder", slect_val_period+'-5');
88			
89		}
90	}
91
92	af_donat_sub_other();
93	$( document ).on( 'change', ".af_donat_sub_other", af_donat_sub_other );
94
95	function af_donat_sub_other(){
96		var slect_val_period = parseInt( $( ".af_dont_inter option:selected" ).val() );
97		$('#af_donat_sub_other').attr("min", slect_val_period);
98		$( "#af_donat_sub_other" ).attr( "step",  slect_val_period);
99	}
100
101	af_dont_inter();
102	$( document ).on('change', ".af_dont_inter", af_dont_inter );
103
104	function af_dont_inter(){
105		var slect_val_period = parseInt( $( ".af_dont_inter option:selected" ).val() );
106		$('#af_donat_sub_other').attr("min", slect_val_period);
107		$( "#af_donat_sub_other" ).attr( "step",  slect_val_period);
108	}
109
110	af_donat_other();
111	
112
113	$( document ).on( 'change', ".af_donat_other", af_donat_other );
114
115	function af_donat_other(){
116
117		var element = $(".af_donat_amt_popup_selct").val();
118
119		//If it isn't "undefined" and it isn't "null", then it exists.
120		if (typeof(element) == 'undefined' && element == null) {
121			return;
122		} else {
123			var slect_val_period = parseInt( $( ".af_donat_amt_popup_selct option:selected" ).val() );
124		
125			$('.af_donat_other').attr("min", slect_val_period);
126			$( ".af_donat_other" ).attr( "step",  slect_val_period);
127		}
128	}
129	
130	$( document ).on( 'click', ".single_add_to_cart_button_ajax", function () {
131		
132		var modal = document.getElementById("af_donat_card_fee_Modal");
133		var myModal = document.getElementById("myModal");
134		
135		var af_max             = 0;
136		var af_min             = 0;
137		var rule_id            = $(this).data('rule_id');
138		var rule_title           = $(this).data('rule_title');
139		
140		var selected_input_amt = $('.af_donat_other_'+rule_id).val();
141		var selected_cause     = '';
142		var selected_amount    = '';
143		if ( selected_input_amt && selected_input_amt.length > 0 ) {
144			selected_amount = selected_input_amt;
145		}
146				
147		if ( $('.af_donat_amt_popup_selct'  + rule_id ) && 'af_dont_other' != $('.af_donat_amt_popup_selct'+rule_id).val()) {
148			
149			var selected_amount = $('.af_donat_amt_popup_selct'+rule_id).children('option:selected').val();
150		} else {	
151			
152			af_max = parseInt($('.af_donat_other_'+rule_id).attr('max'));
153			af_min = parseInt($('.af_donat_other_'+rule_id).attr('min'));
154		
155			if (typeof wc !== 'undefined' && wc.blocksCheckout && !(document.body.classList.contains('woocommerce-cart'))) {
156				if(selected_amount < af_min){
157					modal.style.display = "none";
158					myModal.style.display = "none";
159					$('#adf_abdc_donation-added-notice').remove();
160					$('#adf_abdc_donation-min-error').remove();
161					$('.wc-block-components-notices').remove();
162					$('<div id="adf_abdc_donation-min-error" class="wc-block-store-notice wc-block-components-notice-banner is-error is-dismissible"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
162<path d="M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"></path></svg><div class="wc-block-components-notice-banner__content"><div>Donation amount is less than '+ af_min +'.</div></div><button class="wc-block-components-button wp-element-button wc-block-components-notice-banner__dismiss contained" aria-label="Dismiss this notice" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button></div>').insertBefore('.wc-block-components-sidebar-layout');
163					$("html, body").animate({ scrollTop: 0 }, "slow");
164					
165					return;
166				} else if (selected_amount > af_max){
167					modal.style.display = "none";
168					myModal.style.display = "none";
169					$('#adf_abdc_donation-added-notice').remove();
170					$('#adf_abdc_donation-max-error').remove();
171					$('.wc-block-components-notices').remove();
172					$('<div id="adf_abdc_donation-max-error" class="wc-block-store-notice wc-block-components-notice-banner is-error is-dismissible"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"></path></svg><div class="wc-block-components-notice-banner__content"><div>Donation amount is greate than '+ af_max +'.</div></div><button class="wc-block-components-button wp-element-button wc-block-components-notice-banner__dismiss contained" aria-label="Dismiss this notice" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button></div>').insertBefore('.wc-block-components-sidebar-layout');
173					$("html, body").animate({ scrollTop: 0 }, "slow");
174					
175					return;
176				}
177			}
178
179		}
180
181		if ('Select Cause' != $('.af_donat_selectd_casue'+rule_id).val() ) {
182			selected_cause = $('.af_donat_selectd_casue'+rule_id).val();
183		}
184
185		
186		var subscription_period_interval = $('.af_donat_peri_popup_selct'+rule_id).children('option:selected').val();
187		var subscription_period          = $('.af_admin_recu_lnght'+rule_id).children('option:selected').val();
188		var subscription_length          = $('.af_donat_other_lngt'+rule_id).val();
189		
190		if( !selected_amount || selected_amount.length < 1 ) {
191			
192			selected_amount = $('.af_donat_fee_amount' + rule_id).val();
193		}
194
195		if (typeof wc !== 'undefined' && wc.blocksCheckout &&  !(document.body.classList.contains('woocommerce-cart'))) {
196			
197			const { extensionCartUpdate } = wc.blocksCheckout;
198		
199			extensionCartUpdate( {
200				namespace: 'extension-af-wc-daps-namespace',
201				data:{
202						'ruleId'      		: rule_id,
203						'donation_fee'	    : selected_amount,
204						'selected_cause' : selected_cause
205				}	
206			} );
207			
208			if(modal != null){
209				modal.style.display = "none";
210			}
211			if(myModal != null){
212				myModal.style.display = "none";
213			}
214			$("html, body").animate({ scrollTop: 0 }, "slow");
215			$('#adf_abdc_donation-added-notice').remove();
216			$('.wc-block-components-notices').remove();
217
218		
219			let notification_msg = af_donat_prod_var.success_messg.replace(/\{campaign_name\}/g, rule_title);
220
221			if(af_donat_prod_var.theme_name === 'Twenty Twenty-Five'){
222
223				jQuery('.woocommerce-notices-wrapper').html(
224					'<div class="wc-block-components-notice-banner is-success" id="adf_abdc_donation-added-notice" role="alert">' +
225						'<div class="wc-block-components-notice-banner__content">' +
226						notification_msg +
227						'</div></div>'
228					);
229					
230			} else {
231
232				jQuery('#main').before(
233					'<div class="wc-block-components-notice-banner is-success" id="adf_abdc_donation-added-notice" role="alert">
233' +
234						'<div class="wc-block-components-notice-banner__content">' +
235						notification_msg +
236						'</div></div>'
237					);
238			}
239			
240			
241			return;
242		}
243		var af_donat_amt_popup_selct_option = $('.af_donat_amt_popup_selct'+rule_id).val();
244		
245		$.ajax({
246			url: 		ajaxurl,
247			type:       'POST',
248			data:{
249				action : 'af_donat_add_to_card',
250				nonce: nonce,
251				af_donat_rule_id: 	rule_id,
252				af_donat_amt:  selected_amount,
253				af_amount_type_oth: af_donat_amt_popup_selct_option,
254				af_max		:  af_max,
255				af_min      :  af_min,
256				af_donat_cause:  selected_cause,
257				subscription_period:  subscription_period,
258				subscription_period_interval:  subscription_period_interval,
259				subscription_length:  subscription_length,
260			},
261			success: function(data){
262
263				if( $('form.woocommerce-checkout') && $('form.woocommerce-checkout').length ) {
264					
265					jQuery('#myModal').hide();
266					jQuery( document.body ).trigger( "update_checkout" );
267
268				} else if( $('form.wc-block-checkout__form') &&  $('form.wc-block-checkout__form').length) {
269					location.reload(true);
270				} else {
271					window.location.href = window.location.pathname + "?param=donation_added";
272				}
273			}
274		});
275
276	});
277
278	$( document ).on( 'click', ".single_add_fee_button_ajax", function () {
279		
280		var rule_title      = $(this).data('rule_title');
281		var current_button  = $(this);
282		var selected_amount = 0;
283		var rule_id         = $(this).data('rule_id');
284		var selected_amount = $('.af_donat_other_' + rule_id).val();
285		var af_max          = parseFloat($('.af_donat_other_'+rule_id).attr('max'));
286		var af_min          = parseFloat($('.af_donat_other_'+rule_id).attr('min'));
287		
288		var modal = document.getElementById("af_donat_card_fee_Modal");
289		var myModal = document.getElementById("myModal");
290		if( !selected_amount || selected_amount.length < 1 ) {
291			
292			selected_amount = $('.af_donat_fee_amount' + rule_id).val();
293		}
294
295		var selected_cause = $('.af_donat_selectd_casue'+rule_id).val();
296	
297		if ( ! selected_amount || selected_amount.length < 1 ) {
298
299			if ( $('.f_donat_amt_popup_selct' + rule_id ) && 'af_dont_other' != $('.af_donat_amt_popup_selct'+rule_id).val()) {
300				var selected_amount = $('.af_donat_amt_popup_selct'+rule_id).children('option:selected').val();
301			}
302		}
303
304	
305		if (typeof wc !== 'undefined' && wc.blocksCheckout && !(document.body.classList.contains('woocommerce-cart'))) {
306			if(selected_amount < af_min){
307				modal.style.display = "none";
308				$('#adf_abdc_donation-added-notice').remove();
309				$('#adf_abdc_donation-min-error').remove();
310				$('.wc-block-components-notices').remove();
311				$('<div id="adf_abdc_donation-min-error" class="wc-block-store-notice wc-block-components-notice-banner is-error is-dismissible"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"></path></svg><div class="wc-block-components-notice-banner__content"><div>Donation amount is less than '+ af_min +'.</div></div><button class="wc-block-components-button wp-element-button wc-block-components-notice-banner__dismiss contained" aria-label="Dismiss this notice" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button></div>').insertBefore('.wc-block-components-sidebar-layout');
312				$("html, body").animate({ scrollTop: 0 }, "slow");
313				
314				return;
315			} else if (selected_amount > af_max){
316				modal.style.display = "none";
317				$('#adf_abdc_donation-added-notice').remove();
318				$('#adf_abdc_donation-max-error').remove();
319				$('.wc-block-components-notices').remove();
320				$('<div id="adf_abdc_donation-max-error" class="wc-block-store-notice wc-block-components-notice-banner is-error is-dismissible"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false">
320<path d="M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"></path></svg><div class="wc-block-components-notice-banner__content"><div>Donation amount is greate than '+ af_max +'.</div></div><button class="wc-block-components-button wp-element-button wc-block-components-notice-banner__dismiss contained" aria-label="Dismiss this notice" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button></div>').insertBefore('.wc-block-components-sidebar-layout');
321				$("html, body").animate({ scrollTop: 0 }, "slow");
322				
323				return;
324			}
325
326
327			wc.blocksCheckout.extensionCartUpdate({
328				namespace: 'extension-af-wc-daps-namespace',
329				data: {
330					ruleId: rule_id,
331					donation_fee: selected_amount,
332					selected_cause: selected_cause
333				}
334			});
335			
336			if(modal != null){
337				modal.style.display = "none";
338			}
339			if(myModal != null){
340				myModal.style.display = "none";
341			}
342			
343			let notification_msg = af_donat_prod_var.success_messg.replace(/\{campaign_name\}/g, rule_title);
344			
345			$("html, body").animate({ scrollTop: 0 }, "slow");
346			$('#adf_abdc_donation-added-notice').remove();
347			$('.wc-block-components-notices').remove();
348
349			if(af_donat_prod_var.theme_name === 'Twenty Twenty-Five'){
350
351				jQuery('.woocommerce-notices-wrapper').html(
352					'<div class="wc-block-components-notice-banner is-success" id="adf_abdc_donation-added-notice" role="alert">' +
353					'<div class="wc-block-components-notice-banner__content">' +
354					notification_msg +
355					'</div></div>'
356				);	
357			} else {
358
359				jQuery('#main').before(
360					'<div class="wc-block-components-notice-banner is-success" id="adf_abdc_donation-added-notice" role="alert">' +
361					'<div class="wc-block-components-notice-banner__content">' +
362					notification_msg +
363					'</div></div>'
364				);
365			}
366
367
368			return;
369		}
370
371		var get_option_value = $('.af_donat_amt_popup_selct').val();
372	
373		$.ajax({
374			url: 		ajaxurl,
375			type:       'POST',
376			data:{
377				action : 'af_donat_add_fee_in_cart',
378				af_donat_rule_id: 	rule_id,
379				af_donat_amt:  selected_amount,
380				af_max		:  af_max,
381				af_min      :  af_min,
382				selected_cause : selected_cause,
383				get_option_value : get_option_value
384			
385			},
386			success: function(data){
387				
388				if( $('form.woocommerce-checkout') && $('form.woocommerce-checkout').length ) {
389					
390					jQuery( document.body ).trigger( "update_checkout" );
391					jQuery('#myModal').hide();
392
393					if( current_button.closest('div.af_donat_fee_payment_modal') ) {
394						current_button.closest('div.af_donat_fee_payment_modal').hide();
395					}
396
397				} else {
398					sessionStorage.setItem('hideDonationPopup', 'true');
399        			location.reload(true);
400
401				}
402			}
403		});
404	});
405
406	af_opn_card_donat();
407
408	// for donation with debit card
409	$(document).on('change', 'input[name="radio-control-wc-payment-method-options"], input[name="payment_method"]', handlePaymentMethodChange);
410	
411    setTimeout(function(){
412		handlePaymentMethodChange();
413		if ($('#radio-control-wc-payment-method-saved-tokens-1').is(':checked')){
414			handlePaymentMethodChange("alreadySelect");
415		}
416		$(document).on('change', 'input[name="radio-control-wc-payment-method-saved-tokens"]', function(){
417			handlePaymentMethodChange("alreadySelect");
418		});
419	}, 2000);
420	
421	
422	
423	function handlePaymentMethodChange(select = null) {
424		const selected = $('input[name="radio-control-wc-payment-method-options"]:checked, input[name="payment_method"]:checked');
425		const paymentMethod = selected.val();
426		const isCardDonationEnabled = $('.chek_if_card_donat').val() === 'true';
427		
428		if (isCardDonationEnabled && (paymentMethod === 'stripe' || paymentMethod === 'paypal' || select === 'alreadySelect')) {
429	
430			const modal = document.getElementById('af_donat_card_fee_Modal');
431			
432			if (!modal) {
433				console.warn('Modal element #af_donat_card_fee_Modal not found.');
434				return;
435			}
436	
437			modal.style.display = 'block';
438	
439			const closeBtn = modal.querySelector('.ad_donat_card_fee_close');
440			if (closeBtn) {
441				closeBtn.onclick = function () {
442					modal.style.display = 'none';
443				};
444			}
445	
446			window.onclick = function (event) {
447				if (event.target === modal) {
448					modal.style.display = 'none';
449				}
450			};
451		}
452	}
453	
454
455	function af_opn_card_donat(){
456	
457		var payment_method  = $('input[name="payment_method"]:checked').val();
458		var af_chek_if_card = $('.chek_if_card_donat').val();
459
460		if ( 'true' == af_chek_if_card ) {
461
462			if (  'stripe' == payment_method ) {
463
464				// var btn   = document.getElementById("payment_method_cheque");
465				var modal = document.getElementById("af_donat_card_fee_Modal");
466				var span  = document.getElementsByClassName("ad_donat_card_fee_close")[0];
467					
468				if(modal){
469					modal.style.display = "block";
470				}
471				
472				span.onclick = function() {
473					modal.style.display = "none";
474				}
475				window.onclick  = function(event) {
476					if (event.target == modal) {
477						modal.style.display = "none";
478					}
479				}
480			}
481		}
482	}
483
484	af_select_camp_on_chkt();
485
486	$( document ).on( 'change', ".af_select_camp_on_chkt", function () {
487		af_select_camp_on_chkt();
488		$('div.af_all_campaings_chkout').css('opacity', '0.5' );
489		
490	});
491
492	function af_select_camp_on_chkt(){
493		
494		var slect_val = $( ".af_select_camp_on_chkt option:selected" ).val();
495		
496		if ( 'multp_donate' == slect_val) {
497			
498			var modal = document.getElementById("myModal");
499			var span = document.getElementsByClassName("close")[0];
500			
501			if(modal){
502				modal.style.display = "block";
503			}
504			
505			if(span){
506				span.onclick = function() {
507					modal.style.display = "none";
508				}
509			}
510
511			window.onclick = function(event) {
512				if (event.target == modal) {
513					modal.style.display = "none";
514				}
515			}
516
517			$('.site-content').css('opacity', '1' );
518
519		} else {
520			$(".af_donat_optn_in_chkt").load(" .af_donat_optn_in_chkt");
521			var slect_val = $( ".af_select_camp_on_chkt option:selected" ).val();			
522			
523			$.ajax({
524				url: 		ajaxurl,
525				type:       'POST',
526				data:{
527					action : 'af_donat_show_amt_optn_chkt',
528					af_donat_rule_id: 	slect_val,
529				
530				},
531				success: function(data){
532					
533					if ( 0 == data ) {
534					
535					} else {
536
537						$('.af_refresh_opt').has('.af_donat_optn_in_chkt').filter(function () {
538							var $box = $(this).find('.af_donat_optn_in_chkt');
539							return $box.children().length === 0 && $.trim($box.text()) === '';
540						  }).remove();
541
542						$('div.af_all_campaings_chkout').css('opacity', '1' );
543						$(".af_donat_select_chk_div").after(data);
544						$('.af_donat_otr_amt_').hide();	
545					}
546				}
547			});
548		}
549	}
550
551	
552	
553	
554	$( document ).on( 'change', ".af_amt_optn_chkt", function(){
555			
556		var rule_id = $(this).data('rule_id');
557	
558		$('.af_donat_amt_optn_chekot').css('color','#007cba');
559		$('.af_donat_amt_optn_chekot').css('backgroundColor','#ffffff');
560
561		var element                   = document.getElementById('af_donat_amt_optn_chekot'+rule_id);
562		element.style.backgroundColor = "#007cba";
563	
564		$('#af_donat_amt_optn_chekot'+rule_id).css('color','#ffffff');
565	
566		
567		if ( 'af_other' == $('.af_amt_optn_chkt'+rule_id).val() ) {
568			$('.af_donat_otr_amt_').show();
569		} else {
570			$('.af_donat_otr_amt_').hide();
571		}
572	});
573
574
575	$('#adf_dn_cut_amt_chout').hide();
576
577	$( document ).on( 'click', ".af_amt_optn_chkt", function () {
578		var getSelectVal;
579		if ( $("input[type='radio'].af_amt_optn_chkt:checked").val() ) {
580			
581			getSelectVal =  $("input[type='radio'].af_amt_optn_chkt:checked").val();
582		}
583		if('af_other' == getSelectVal){
584			$('#adf_dn_cut_amt_chout').show();
585		} else {
586			$('#adf_dn_cut_amt_chout').hide();
587		}
588		
589	});
590	
591	$( document ).on( 'click', "#af_donat_btn_chk", function () {
592
593		var data_array      = [];
594		var selected_amount = '';
595		
596		var af_sub_period_interval = '';
597		var af_sub_period          = '';
598		var af_dont_lngt           = '';
599
600		if ( $("input[type='radio'].af_amt_optn_chkt:checked").val() ) {
601			
602			selected_amount =  $("input[type='radio'].af_amt_optn_chkt:checked").val();
603		} else {
604			
605			selected_amount =  $(".af_donat_otr_amt_btn").val();
606		}
607		
608		var af_max = parseInt($('.af_donat_otr_amt_btn').attr('max'));
609		var af_min = parseInt($('.af_donat_otr_amt_btn').attr('min'));
610		
611		if('af_other' === selected_amount){
612			var getCustomAmount = parseInt($('.af_donat_otr_amt_btn').val());
613			
614			if(typeof getCustomAmount !== 'undefined' && getCustomAmount > 0){
615				
616				if(getCustomAmount < af_min){
617					selected_amount = af_min;
618				} else if(getCustomAmount > af_max){
619					selected_amount = af_max;
620				} else {
621					selected_amount = getCustomAmount;
622				}
623			}
624		}
625
626
627		af_sub_period_interval =  $(".af_donat_inteval").val();
628
629		af_sub_period =  $(".af_donat_period").val();
630		
631		af_dont_lngt =  $(".af_donat_length").val();
632
633		var rule_id = $(".af_select_camp_on_chkt :selected").val();
634		
635
636		$.ajax({
637
638			url: ajaxurl,
639			type: 'POST',
640			data:{
641				action: 'af_donation_btn_chkout',
642				rule_id 		 	  : rule_id,
643				selected_amount 	  : selected_amount,
644				af_sub_period_interval: af_sub_period_interval,
645				af_sub_period 		  : af_sub_period,
646				af_dont_lngt 		  : af_dont_lngt,
647				af_max				  : af_max,
648				af_min				  : af_min,
649			},
650			success: function(data){
651				if (data.success && data.data.notices) {
652					$('.wc-block-components-notices').first().append("<div>"+ data.data.notices +"</div>");
653					window.scrollTo({ top: 0, behavior: 'smooth' });
654					setTimeout(function(){
655						location.reload(true);
656					}, 1000)
657					
658				} else if(!data.success && data.data.notices){
659					$('.wc-block-components-notices').first().html("<div>"+ data.data.notices +"</div>");
660					window.scrollTo({ top: 0, behavior: 'smooth' });
661				}
662			
663			}
664		});
665	});
666
667
668	var $select = $('#af_check_selet_optn');
669
670    if ($select.find('option').length === 1) {
671        $select.hide(); 
672        $('.af_donat_other_').show(); 
673    }
674
675    $(document).on('change', '#af_check_selet_optn', function () {
676        var selectedValue = $(this).val();
677
678        if (selectedValue === 'af_dont_other') {
679            $('.af_donat_other_').show();
680        } else {
681            $('.af_donat_other_').hide();
682        }
683    });
684
685	var themeName = af_donat_prod_var.theme_name;
686	if('Avada' == themeName) {
687		jQuery('.af_donat_main_div_in_popup table').css({
688			'border': '1px solid',
689			'margin-bottom': '20px'
690		});
691
692		$('.af_dont_btn_chk').css({
693			'background': '#198fd9',
694			'color': '#fff',
695			'padding': '5px 15px',
696			'line-height': '30px',
697			'font-size': '18px',
698			'font-weight': '600',
699			'border': '0px'
700		});
701	}
702
703	if('Twenty Twenty-Five' == themeName) {
704		jQuery('.af_donat_main_div_in_popup table').css({
705			'border': '1px solid',
706			'margin-bottom': '20px',
707			'border-collapse': 'collapse'
708		});
709
710		jQuery('.af_donat_main_div_in_popup table tr th').css({
711			'border': '1px solid #d3d2d2',
712		});
713
714		jQuery('.af_donat_main_div_in_popup table tr td').css({
715			'border': '1px solid #d3d2d2',
716		});
717
718		$('.af_dont_btn_chk').addClass('wp-element-button');
719	
720	}
721
722
723	if ($('.af_camp_bar_in_list .af_bar_main').length > 0) {
724        // Call your function
725        updateListTemp();
726    }
727
728    // Example function
729    function updateListTemp() {
730		$('.af_bar_main').closest('.af_disp_btn_list_div').css('padding','12px 0px 0px 0px');
731    
732    }
733
734
735wp.hooks.addAction( 'experimental__woocommerce_blocks-cart-set-item-quantity', 'your-plugin-namespace', function(item){
736
737
738
739setTimeout(() => {
740
741	
742
743	wp.apiFetch({ path: '/wc/store/cart' }).then(posts => {
744		
745		});
746
747		$.ajax({
748
749			url: ajaxurl,
750			type: 'POST',
751			data:{
752				action: 'af_block_cart_update',
753				posts : "ddd",
754			},
755			success: function(data){
756
757				for (var i = 0; i < data.af_rule_id.length; i++) {
758					
759					var ruleId = data.af_rule_id[i];
760					var amount = data.af_fix_amount[i];
761					var htmlUpdatedPrice = data.amount_html[i];
762					var selectTemp = data.selectTemp;
763					if(selectTemp === 'af_tbl_disp'){
764						$('input[class="af_donat_fee_amount' + ruleId + '"]').val(amount);
765						var input = $('input.af_donat_fee_amount' + ruleId);
766						input.val(amount);
767						input.closest('.af_donat_tbl_amt').find('h4').html(htmlUpdatedPrice);
768					} else if(selectTemp === 'af_flx_disp') {
769						$('input[class="af_donat_fee_amount' + ruleId + '"]').val(amount);
770						var input = $('input.af_donat_fee_amount' + ruleId);
771						input.val(amount);
772						input.closest('.af_donat_amt_opt_fles').find('h4').html(htmlUpdatedPrice);
773					} else if(selectTemp === 'af_list_disp') {
774						$('input[class="af_donat_fee_amount' + ruleId + '"]').val(amount);
775						var input = $('input.af_donat_fee_amount' + ruleId);
776						input.val(amount);
777						input.closest('.af_disp_data_list_div').find('h4').html(htmlUpdatedPrice);
778					}
779
780				}
781
782			}
783		});
784
785}, 2000);
786
787
788});
789
790$(document).on('input', '#adf_dn_cut_amt_chout', function () {
791    let min = parseInt($(this).attr('min')) || 0;
792    let max = parseInt($(this).attr('max')) || 10000;
793    let val = parseInt($(this).val());
794
795    if (val > max) {
796        $(this).val(max);
797    } else if (val < min) {
798        $(this).val(min);
799    }
800});
801
802var spanClose  = document.getElementsByClassName("close")[0];
803					
804spanClose.onclick        = function() {
805$('.modal-content').hide();
806}
807});
808

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.