PageSourceSearch

https://garageshop.ro/wp-content/plugins/woo-save-abandoned-carts/public/js/cartbounty-public-exit-intent.js

js garageshop.ro collected 2026-09-24 14:27:25 UTC 4,685 bytes, 117 lines download raw bytes

1(function($){
2	'use strict';
3	 
4	jQuery(document).ready(function(){
5
6	 	var timer;
7
8	 	function showExitIntentForm(event){
9	 		var currentTime = new Date().getTime();
10			var timePeriod = cartbounty_ei.hours; //Time period in hours
11			var last_time_displayed = localStorage.getItem('cartbounty_ei_last_time');
12			var product_count = cartbounty_ei.product_count; //Products in the shopping cart
13
14			if(localStorage.getItem('cartbounty_product_count') !== null){
15				product_count = localStorage.getItem('cartbounty_product_count');
16			}
17
18			if(product_count == 0) return; //Exit if we have no products
19
20			if (event.clientY <= 0 && event.target.tagName.toLowerCase() != "select" && event.target.tagName.toLowerCase() != "option" && event.target.tagName.toLowerCase() != "input") { //Checking if mouse Y poosition goes beyond the top screen and that we haven't clicked on dropdown or autocomplete input field
21
22		        if(last_time_displayed == null || timePeriod == 0) { //If time period has passed or Exit Intent test mode is enabled
23		            $('#cartbounty-exit-intent-form').addClass('cartbounty-visible'); //Display form
24		        	$('#cartbounty-exit-intent-form-backdrop').css('opacity', '').addClass('cartbounty-visible'); //Show backdrop
25		        	if(timePeriod != 0){
26		        		localStorage.setItem('cartbounty_ei_last_time', currentTime);
27		        	}
28		        }else{
29		        	if(currentTime - last_time_displayed > timePeriod * 60 * 60 * 1000){ // If the time has expired, clear the cookie
30						localStorage.removeItem('cartbounty_ei_last_time');
31					}
32		        }
33		    }
34	 	}
35
36		function getExitIntentEmail() { //Reading email entered in exit intent
37			let email = jQuery('#cartbounty-exit-intent-email').val() || '';
38			
39			if(email.length > 0){				
40				clearTimeout(timer);
41				var emailValidation = cartbounty_co.email_validation; //Regex validation
42				var consent = cartbounty_co.consent_field;
43				
44				if( email.match(emailValidation) ){
45					var fields = {
46						email: 			email,
47					};
48
49					if( consent ){
50						fields[consent] = 1;
51					}
52
53					var data = {
54						action:			"cartbounty_save",
55						nonce:			cartbounty_co.nonce,
56						source:			"cartbounty_exit_intent",
57						customer:		fields,
58					}
59
60					timer = setTimeout(function(){
61						jQuery.post(cartbounty_co.ajaxurl, data,
62						function(response) {
63							if(response.success){ //If successfuly saved data
64								localStorage.setItem('cartbounty_contact_saved', true);
65							}
66						});
67					}, 600);
68				}
69			}
70		}
71
72		function increaseProductCount(){ //Increasing product count
73			if( localStorage.getItem( 'cartbounty_product_count' ) === null ){
74				localStorage.setItem( 'cartbounty_product_count', 1 );
75
76			}else{
77				localStorage.setItem( 'cartbounty_product_count', parseInt( localStorage.getItem( 'cartbounty_product_count' ) ) + 1 );
78			}
79		}
80
81		function decreaseProductCount(){ //Decreasing product count
82			if( localStorage.getItem( 'cartbounty_product_count' ) === null ) return;
83
84			localStorage.setItem( 'cartbounty_product_count', parseInt( localStorage.getItem( 'cartbounty_product_count' ) ) - 1 );
85		}
86
87		function closeExitIntentForm(){ //Close exit intent window
88			$('#cartbounty-exit-intent-form').addClass('cartbounty-fade-out');
89
90			setTimeout(function(){
91				$('#cartbounty-exit-intent-form').removeClass('cartbounty-visible cartbounty-fade-out');
92				$('#cartbounty-exit-intent-form-backdrop').removeClass('cartbounty-visible'); //Hide backdrop
93			}, 300);
94		}
95
96	 	//Handling Exit Intent form submit button. Making sure the page is not reloaded
97		function handleFormAfterSubmit(e){
98			e.preventDefault();
99
100			//If form is invalid, let browser show validation UI
101			if (!this.checkValidity()){
102				this.reportValidity(); //Triggers browser validation tooltip
103				return;
104			}
105
106			closeExitIntentForm();
107		}
108
109		jQuery(document).on("mouseleave", showExitIntentForm); //Displaying Exit intent if the mouse leaves the window
110		jQuery("#cartbounty-exit-intent-email").on("keyup keypress change", getExitIntentEmail ); //All action happens on or after changing Email field. Data saved to Database only after Email fields have been entered.
111		jQuery("#cartbounty-exit-intent-close, #cartbounty-exit-intent-form-backdrop").on("click", closeExitIntentForm ); //Close Exit intent window
112		jQuery('#cartbounty-exit-intent-form form').on('submit', handleFormAfterSubmit); //Closing Exit Intent form
113		jQuery(document).on("added_to_cart", increaseProductCount ); //Increasing product count if Ajax Add to Cart button pressed
114		jQuery(document).on("removed_from_cart", decreaseProductCount ); //Firing the function if item is removed from cart via Ajax 
115	});
116
117})(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.