PageSourceSearch

https://www.csvtaranto.it/wp-content/plugins/bloom/js/custom.js?ver=1.2.4

js csvtaranto.it collected 2026-10-08 16:19:07 UTC 20,239 bytes, 483 lines download raw bytes

1(function($){
2	$(document).ready(function() {
3		var $locked_containers = [];
4
5		$( '.et_bloom_make_form_visible' ).removeAttr( 'style' );
6
7		$( '.et_bloom_custom_html_form input[type="radio"], .et_bloom_custom_html_form input[type="checkbox"]' ).uniform();
8
9		$( 'body' ).on( 'click', 'span.et_bloom_close_button', function(){
10			perform_popup_closing( $( this ).closest( '.et_bloom_optin' ) );
11
12			return false;
13		});
14
15		function perform_popup_closing( $popup_container ) {
16			$popup_container.addClass( 'et_bloom_exit_animation' );
17
18			setTimeout( function() {
19				if ( $popup_container.hasClass( 'et_bloom_trigger_click' ) ) {
20					$popup_container.removeClass( 'et_bloom_visible et_bloom_animated et_bloom_exit_animation' );
21				} else {
22					$popup_container.remove();
23				}
24			}, 400 );
25
26			$( 'body' ).removeClass( 'et_bloom_popup_active' );
27
28		}
29
30		function update_stats_table( $type, $this_button ) {
31			// do not update stats if visitor logged in
32			if ( 'logged' === bloomSettings.is_user_logged_in ) {
33				return;
34			}
35
36			var $optin_id = typeof $this_button.data( 'current_optin_id' ) !== 'undefined' ? $this_button.data( 'current_optin_id' ) : $this_button.data( 'optin_id' ),
37				$page_id = $this_button.data( 'page_id' ),
38				$list_id = $this_button.data( 'list_id' );
39
40			$stats_data = JSON.stringify({ 'type' : $type, 'optin_id' : $optin_id, 'page_id' : $page_id, 'list_id' : $list_id });
41			$.ajax({
42				type: 'POST',
43				url: bloomSettings.ajaxurl,
44				data: {
45					action : 'bloom_handle_stats_adding',
46					stats_data_array : $stats_data,
47					update_stats_nonce : bloomSettings.stats_nonce
48				}
49			});
50		}
51
52		function setCookieExpire( days ) {
53			var ms = days*24*60*60*1000;
54
55			var date = new Date();
56			date.setTime( date.getTime() + ms );
57
58			return "; expires=" + date.toUTCString();
59		}
60
61		function checkCookieValue( cookieName, value ) {
62			return parseCookies()[cookieName] == value;
63		}
64
65		function parseCookies() {
66			var cookies = document.cookie.split( '; ' );
67
68			var ret = {};
69			for ( var i = cookies.length - 1; i >= 0; i-- ) {
70			  var el = cookies[i].split( '=' );
71			  ret[el[0]] = el[1];
72			}
73			return ret;
74		}
75
76		function set_cookie( $expire, $cookie_content ) {
77			var $cookie_content = '' == $cookie_content ? 'etBloomCookie=true' : $cookie_content;
78			cookieExpire = setCookieExpire( $expire );
79			document.cookie = $cookie_content + cookieExpire + "; path=/";
80		}
81
82		function get_url_parameter( param_name ) {
83			var page_url = window.location.search.substring(1);
84			var url_variables = page_url.split('&');
85			for ( var i = 0; i < url_variables.length; i++ ) {
86					var curr_param_name = url_variables[i].split( '=' );
87				if ( curr_param_name[0] == param_name ) {
88					return curr_param_name[1];
89				}
90			}
91		}
92
93		//separate function for the setTimeout to make it work properly within the loop.
94		function make_popup_visible( $popup, $delay, $cookie_exp, $cookie_content ){
95			if ( ! $popup.hasClass( 'et_bloom_visible' ) ) {
96				setTimeout( function() {
97					$popup.addClass( 'et_bloom_visible et_bloom_animated' );
98					$stats_data_container = 0 != $popup.find( '.et_bloom_custom_html_form' ).length ? $popup.find( '.et_bloom_custom_html_form' ) : $popup.find( '.et_bloom_submit_subscription' );
99					update_stats_table( 'imp', $stats_data_container );
100
101					if ( '' != $cookie_exp ) {
102						set_cookie( $cookie_exp, $cookie_content );
103					}
104
105					if ( $( '.et_bloom_resize' ).length ) {
106						$( '.et_bloom_resize.et_bloom_visible' ).each( function() {
107							define_popup_position( $( this ), true, 0 );
108						});
109					}
110
111					display_image( $popup );
112
113				}, $delay );
114			}
115		}
116
117		function display_image( $popup ) {
118			setTimeout( function() {
119				$popup.find( '.et_bloom_image' ).addClass( 'et_bloom_visible_image' );
120			}, 500 );
121		}
122
123		function auto_popup( $current_popup_auto, $delay ) {
124			var $data_holder = $current_popup_auto.find( '.et_bloom_custom_html_form' ).length ? $current_popup_auto.find( '.et_bloom_custom_html_form' ) : $current_popup_auto.find( '.et_bloom_submit_subscription' ),
125				page_id = $data_holder.data( 'page_id' ),
126				optin_id = $data_holder.data( 'optin_id' ),
127				list_id = $data_holder.data( 'list_id' );
128
129			if ( ! $current_popup_auto.hasClass( 'et_bloom_animated' ) ) {
130				var $cookies_expire_auto = $current_popup_auto.data( 'cookie_duration' ) ? $current_popup_auto.data( 'cookie_duration' ) : false,
131					$already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' );
132
133				if ( ( ( false !== $cookies_expire_auto && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_auto ) && ! $already_subscribed ) {
134					if ( false !== $cookies_expire_auto ) {
135						make_popup_visible ( $current_popup_auto, $delay, $cookies_expire_auto, 'etBloomCookie_' + optin_id + '=true' );
136					} else {
137						make_popup_visible ( $current_popup_auto, $delay, '', '' );
138					}
139				}
140			}
141		}
142
143		function scroll_trigger( $current_popup_bottom, is_bottom_trigger ) {
144			var triggered = 0,
145				$data_holder = $current_popup_bottom.find( '.et_bloom_custom_html_form' ).length ? $current_popup_bottom.find( '.et_bloom_custom_html_form' ) : $current_popup_bottom.find( '.et_bloom_submit_subscription' ),
146				page_id = $data_holder.data( 'page_id' ),
147				optin_id = $data_holder.data( 'optin_id' );
148				list_id = $data_holder.data( 'list_id' );
149
150			if ( ! $current_popup_bottom.hasClass( 'et_bloom_animated' ) ) {
151				var	cookies_expire_bottom = $current_popup_bottom.data( 'cookie_duration' ) ? $current_popup_bottom.data( 'cookie_duration' ) : false,
152					$already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' );
153
154				if ( true == is_bottom_trigger ) {
155					var scroll_trigger = $( '.et_bloom_bottom_trigger' ).length ? $( '.et_bloom_bottom_trigger' ).offset().top : $( document ).height() - 500;
156				} else {
157					var scroll_pos = $current_popup_bottom.data( 'scroll_pos' ) > 100 ? 100 : $current_popup_bottom.data( 'scroll_pos' ),
158						scroll_trigger = 100 == scroll_pos ? $( document ).height() - 50 : $( document ).height() * scroll_pos / 100;
159				}
160
161				$( window ).scroll( function(){
162					if ( ( ( false !== cookies_expire_bottom && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == cookies_expire_bottom ) && ! $already_subscribed ) {
163						if( $( window ).scrollTop() + $( window ).height() > scroll_trigger ) {
164							if ( 0 == triggered ) {
165								if ( false !== cookies_expire_bottom ) {
166									make_popup_visible ( $current_popup_bottom, 0, cookies_expire_bottom, 'etBloomCookie_' + optin_id + '=true' );
167								} else {
168									make_popup_visible ( $current_popup_bottom, 0, '', '' );
169								}
170
171								triggered++;
172							}
173						}
174					}
175				});
176			}
177		}
178
179		 if( $( '.et_bloom_auto_popup' ).length ) {
180			$( '.et_bloom_auto_popup:not(.et_bloom_visible)' ).each( function() {
181				var this_el = $( this ),
182					delay = '' !== this_el.data( 'delay' ) ? this_el.data( 'delay' ) * 1000 : 0;
183				auto_popup( this_el, delay );
184			});
185		 }
186
187		if( $( '.et_bloom_trigger_bottom' ).length ) {
188
189			$( '.et_bloom_trigger_bottom:not(.et_bloom_visible)' ).each( function(){
190				scroll_trigger( $( this ), true );
191			});
192
193		}
194
195		if( $( '.et_bloom_scroll' ).length ) {
196
197			$( '.et_bloom_scroll:not(.et_bloom_visible)' ).each( function(){
198				scroll_trigger( $( this ), false );
199			});
200		}
201
202		if ( $( '.et_bloom_trigger_click' ).length ) {
203			$( '.et_bloom_trigger_click:not(.et_bloom_visible)' ).each( function() {
204				var $this_el = $( this ),
205					selector = $this_el.attr( 'data-trigger_click' );
206
207				if ( typeof selector !== 'undefined' ) {
208					$( 'body' ).on( 'click', selector, function() {
209						make_popup_visible ( $this_el, 0, '', '' );
210						return false;
211					});
212				}
213			});
214		}
215
216		if( $( '.et_bloom_trigger_idle' ).length ) {
217			$( '.et_bloom_trigger_idle:not(.et_bloom_visible)' ).each( function() {
218				var $this_el = $( this ),
219					$data_holder = $this_el.find( '.et_bloom_custom_html_form' ).length ? $this_el.find( '.et_bloom_custom_html_form' ) : $this_el.find( '.et_bloom_submit_subscription' ),
220					page_id = $data_holder.data( 'page_id' ),
221					optin_id = $data_holder.data( 'optin_id' ),
222					list_id = $data_holder.data( 'list_id' );
223
224				if ( ! $this_el.hasClass( 'et_bloom_animated' ) ) {
225					var $cookies_expire_idle = $this_el.data( 'cookie_duration' ) ? $this_el.data( 'cookie_duration' ) : false,
226						$already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' );
227						$idle_timeout = '' !== $this_el.data( 'idle_timeout' ) ? $this_el.data( 'idle_timeout' ) * 1000 : 30000,
228						$delay = 0;
229
230					if ( ( ( false !== $cookies_expire_idle && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_idle ) && ! $already_subscribed ) {
231						$( document ).idleTimer( $idle_timeout );
232
233						$( document ).on( 'idle.idleTimer', function() {
234							if ( false !== $cookies_expire_idle ) {
235								make_popup_visible ( $this_el, $delay, $cookies_expire_idle, 'etBloomCookie_' + optin_id + '=true' );
236							} else {
237								make_popup_visible ( $this_el, $delay, '', '' );
238							}
239						});
240					}
241				}
242			});
243		}
244
245		if ( 'true' == get_url_parameter( 'et_bloom_popup' ) ) {
246			$( '.et_bloom_after_comment' ).each( function() {
247				auto_popup( $( this ), 0 );
248			});
249		}
250
251		if ( $( '.et_bloom_after_order' ).length ) {
252			$( '.et_bloom_after_purchase' ).each( function() {
253				auto_popup( $( this ), 0 );
254			});
255		}
256
257		if( $( '.et_bloom_locked_container' ).length ) {
258			var $i = 0;
259
260			$( '.et_bloom_locked_container' ).each( function() {
261				var $this_el = $( this ),
262					content = $this_el.find( '.et_bloom_locked_content' ),
263					form = $this_el.find( '.et_bloom_locked_form' ),
264					page_id = $this_el.data( 'page_id' ),
265					optin_id = $this_el.data( 'optin_id' );
266
267				$this_el.data( 'container_id', $i );
268				$locked_containers.push( content );
269
270				if ( checkCookieValue( 'et_bloom_unlocked' + optin_id + page_id, 'true' ) ) {
271					content.css( {'display' : 'block'} );
272					form.remove();
273				} else {
274					content.remove();
275					update_stats_table( 'imp', $this_el );
276				}
277
278				$i++;
279			});
280		}
281
282		$( 'body' ).on( 'click', '.et_bloom_locked_container .et_bloom_submit_subscription', function(){
283			var $current_container = $( this ).closest( '.et_bloom_locked_container' ),
284				container_id = $current_container.data( 'container_id' ),
285				page_id = $current_container.data( 'page_id' ),
286				optin_id = typeof $current_container.data( 'current_optin_id' ) !== 'undefined' ? $current_container.data( 'current_optin_id' ) : $current_container.data( 'optin_id' );
287
288			perform_subscription( $( this ), $current_container, container_id, page_id, optin_id );
289
290			return false;
291		});
292
293		// unlock content immediately if custom HTML form is used.
294		$( 'body' ).on( 'click', '.et_bloom_locked_container .et_bloom_custom_html_form input[type="submit"], .et_bloom_locked_container .et_bloom_custom_html_form button[type="submit"]', function() {
295			var current_container = $( this ).closest( '.et_bloom_locked_container' ),
296				container_id = current_container.data( 'container_id' ),
297				page_id = current_container.data( 'page_id' ),
298				optin_id = current_container.data( 'optin_id' );
299
300			unlock_content( current_container, container_id, page_id, optin_id );
301		} );
302
303		function unlock_content( current_container, container_id, locked_page_id, locked_optin_id ) {
304			set_cookie( 365, 'et_bloom_unlocked' + locked_optin_id + locked_page_id + '=true' );
305			current_container.find( '.et_bloom_locked_form' ).replaceWith( $locked_containers[container_id] );
306			current_container.find( '.et_bloom_locked_content' ).css( { 'display' : 'block' } );
307		}
308
309		// Move inline forms into appropriate sections in Divi theme
310		if( $( '.et_bloom_below_post' ).length ) {
311			if ( $( 'body' ).hasClass( 'et_pb_pagebuilder_layout' ) ) {
312				var bottom_inline = $( '.et_bloom_below_post' ),
313					divi_container = '<div class="et_pb_row"><div class="et_pb_column et_pb_column_4_4"></div></div>';
314
315				if ( bottom_inline.length ) {
316					$( '.et_pb_section' ).not( '.et_pb_fullwidth_section' ).last().append( divi_container ).find( '.et_pb_row' ).last().find( '.et_pb_column' ).append( bottom_inline );
317				}
318			}
319		}
320
321		function define_popup_position( $this_popup, $just_loaded, $message_space ) {
322			var this_popup = $this_popup.find( '.et_bloom_form_container' ),
323				popup_max_height = this_popup.hasClass( 'et_bloom_popup_container' ) ? $( window ).height() - 40 : $( window ).height() - 20,
324				real_popup_height = 0,
325				percentage = this_popup.parent().hasClass( 'et_bloom_flyin' ) ? 0.03 : 0.05,
326				percentage = this_popup.hasClass( 'et_bloom_with_border' ) ? percentage + 0.03 : percentage,
327				breakout_offset = this_popup.hasClass( 'breakout_edge' ) ? 0.95 
327: 1,
328				dashed_offset = this_popup.hasClass( 'et_bloom_border_dashed' ) ? 4 : 0,
329				form_height = this_popup.find( 'form' ).innerHeight() + $message_space,
330				form_add = true == $just_loaded ? 5 : 0;
331
332			if ( this_popup.find( '.et_bloom_form_header' ).hasClass('split' ) ) {
333				var image_height = this_popup.find( '.et_bloom_form_header img' ).innerHeight(),
334					text_height = this_popup.find( '.et_bloom_form_header .et_bloom_form_text' ).innerHeight(),
335					header_height = image_height < text_height ? text_height + 30 : image_height + 30;
336			} else {
337				var header_height = this_popup.find( '.et_bloom_form_header img' ).innerHeight() + this_popup.find( '.et_bloom_form_header .et_bloom_form_text' ).innerHeight() + 30;
338			}
339
340			this_popup.css( { 'max-height' : popup_max_height } );
341
342			if ( this_popup.hasClass( 'et_bloom_popup_container' ) ) {
343				var top_position = $( window ).height() / 2 - this_popup.innerHeight() / 2;
344				this_popup.css( { 'top' : top_position + 'px' } );
345			}
346
347			this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'max-height' : popup_max_height - 20 } );
348
349
350			if ( ( 768 > $( 'body' ).outerWidth() + 15 ) || this_popup.hasClass( 'et_bloom_form_bottom' ) ) {
351				if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) {
352					this_popup.find( '.et_bloom_form_header' ).css( { 'height' : 'auto' } );
353				}
354
355				real_popup_height = this_popup.find( '.et_bloom_form_header' ).innerHeight() + this_popup.find( '.et_bloom_form_content' ).innerHeight() + 30 + form_add;
356
357				if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) {
358					this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'height' : real_popup_height - 30 + dashed_offset } );
359				}
360			} else {
361				if ( header_height < form_height ) {
362					real_popup_height = this_popup.find( 'form' ).innerHeight() + 30 + $message_space;
363				} else {
364					real_popup_height = header_height + 30;
365				}
366
367				if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) {
368					this_popup.find( '.et_bloom_form_header' ).css( { 'height' : real_popup_height * breakout_offset - dashed_offset } );
369					this_popup.find( '.et_bloom_form_content' ).css( { 'min-height' : real_popup_height - dashed_offset } );
370					this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'height' : real_popup_height } );
371				}
372			}
373
374			if ( real_popup_height > popup_max_height ) {
375				this_popup.find( '.et_bloom_form_container_wrapper' ).addClass( 'et_bloom_vertical_scroll' );
376			} else {
377				this_popup.find( '.et_bloom_form_container_wrapper' ).removeClass( 'et_bloom_vertical_scroll' );
378			}
379
380			if ( $this_popup.hasClass( 'et_bloom_popup' ) ) {
381				$( 'body' ).addClass( 'et_bloom_popup_active' );
382			}
383		}
384
385		$( 'body' ).on( 'click', '.et_bloom_submit_subscription:not(.et_bloom_submit_subscription_locked)', function() {
386			perform_subscription( $( this ), '', '', '', '' );
387			return false;
388		});
389
390		function perform_subscription( this_button, current_container, container_id, locked_page_id, locked_optin_id ) {
391			var this_form = this_button.parent(),
392				list_id = this_button.data( 'list_id' ),
393				account_name = this_button.data( 'account' ),
394				service = this_button.data( 'service' ),
395				name = this_form.find( '.et_bloom_subscribe_name input' ).val(),
396				last_name = undefined != this_form.find( '.et_bloom_subscribe_last input' ).val() ? this_form.find( '.et_bloom_subscribe_last input' ).val() : '',
397				email = this_form.find( '.et_bloom_subscribe_email input' ).val(),
398				page_id = this_button.data( 'page_id' ),
399				optin_id = this_button.data( 'optin_id' ),
400				disable_dbl_optin = this_button.data( 'disable_dbl_optin' ),
401				$popup_container = this_form.closest( '.et_bloom_optin' ),
402				is_popup = $popup_container.hasClass( 'et_bloom_popup' ) || $popup_container.hasClass( 'et_bloom_flyin' ),
403				$success_action_el = this_button.closest('.et_bloom_success_action'),
404				success_action_details = $success_action_el.length > 0 ? $success_action_el.parent().data( 'success_action_details' ).split( '|' ) : [],
405				success_action = 2 === success_action_details.length ? success_action_details[0] : '',
406				success_action_url = '' !== success_action ? success_action_details[1] : '';
407
408			this_form.find( '.et_bloom_subscribe_email input' ).removeClass( 'et_bloom_warn_field' );
409
410			if ( '' == email ) {
411				this_form.find( '.et_bloom_subscribe_email input' ).addClass( 'et_bloom_warn_field' );
412			} else {
413				$subscribe_data = JSON.stringify({ 'list_id' : list_id, 'account_name' : account_name, 'service' : service, 'name' : name, 'email' : email, 'page_id' : page_id, 'optin_id' : optin_id, 'last_name' : last_name, 'dbl_optin' : disable_dbl_optin });
414				$.ajax({
415					type: 'POST',
416					dataType: 'json',
417					url: bloomSettings.ajaxurl,
418					data: {
419						action : 'bloom_subscribe',
420						subscribe_data_array : $subscribe_data,
421						subscribe_nonce : bloomSettings.subscribe_nonce
422					},
423					beforeSend: function( data ) {
424						this_button.addClass( 'et_bloom_button_text_loading' );
425						this_button.find( '.et_bloom_subscribe_loader' ).css( { 'display' : 'block' } );
426					},
427					success: function( data ) {
428						this_button.removeClass( 'et_bloom_button_text_loading' );
429						this_button.find( '.et_bloom_subscribe_loader' ).css( { 'display' : 'none' } );
430						if ( data ) {
431							if ( '' != current_container && ( data.success || 'Invalid email' != data.error ) ) {
432								unlock_content( current_container, container_id, locked_page_id, locked_optin_id );
433							} else {
434								if ( data.error ) {
435									this_form.find( '.et_bloom_error_message' ).remove();
436									this_form.prepend( '<h2 class="et_bloom_error_message">' + data.error + '</h2>' );
437									this_form.parent().parent().find( '.et_bloom_form_header' ).addClass( 'et_bloom_with_error' );
438								}
439								if ( data.success && '' == current_container ) {
440									set_cookie( 365, 'et_bloom_subscribed_to_' + optin_id + list_id + '=true' );
441
442									if ( '' === success_action || '' === success_action_url ) {
443									  this_form.parent().find( '.et_bloom_success_message' ).addClass( 'et_bloom_animate_message' );
444									  this_form.parent().find( '.et_bloom_success_container' ).addClass( 'et_bloom_animate_success' );
445									  this_form.remove();
446									} else {
447										window.location = success_action_url;
448									}
449
450									// auto close popup if enabled
451									if ( is_popup && $popup_container.hasClass( 'et_bloom_auto_close' ) ) {
452										setTimeout( function() {
453											perform_popup_closing( $popup_container );
454										}, 1400 );
455									}
456								}
457							}
458
459							if ( is_popup ) {
460								define_popup_position( $popup_container, false, 50 );
461							}
462						}
463					}
464				});
465			}
466		}
467
468		$( 'body' ).on( 'click', '.et_bloom_custom_html_form input[type="submit"], .et_bloom_custom_html_form button[type="submit"]', function() {
469			var this_button = $( this ),
470				form_container = this_button.closest( '.et_bloom_custom_html_form' );
471
472			update_stats_table( 'con', form_container );
473		} );
474
475		$( window ).resize( function(){
476			if ( $( '.et_bloom_resize' ).length ) {
477				$( '.et_bloom_resize' ).each( function() {
478					define_popup_position( $( this ), false, 0 );
479				});
480			}
481		});
482	});
483})(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.