PageSourceSearch

https://nebulum.one/wp-content/plugins/bloom/js/custom.js?ver=1.3.12

js nebulum.one collected 2026-09-29 11:23:21 UTC 29,063 bytes, 729 lines download raw bytes

1(function($){
2	$( 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 toggle_checkbox(element, value) {
16			$(element).children('i').toggleClass('et_bloom_icon et_bloom_icon_check');
17		}
18
19		$('body .et_bloom_custom_field_checkbox input[type=checkbox]:checked').each(function() {
20			toggle_checkbox($(this).next('label'));
21		});
22
23		$('body').on('click', '.et_bloom_custom_field_checkbox label', function() {
24			toggle_checkbox(this);
25		});
26
27		function perform_popup_closing( $popup_container ) {
28			$popup_container.addClass( 'et_bloom_exit_animation' );
29
30			setTimeout( function() {
31				if ( $popup_container.hasClass( 'et_bloom_trigger_click' ) ) {
32					$popup_container.removeClass( 'et_bloom_visible et_bloom_animated et_bloom_exit_animation' );
33				} else {
34					$popup_container.remove();
35				}
36			}, 400 );
37
38			$( 'body' ).removeClass( 'et_bloom_popup_active' );
39
40		}
41
42		function update_stats_table( type, $this_button ) {
43			// do not update stats if visitor logged in
44			if ( 'logged' === bloomSettings.is_user_logged_in ) {
45				return;
46			}
47
48			var $optin_id = typeof $this_button.data( 'current_optin_id' ) !== 'undefined' ? $this_button.data( 'current_optin_id' ) : $this_button.data( 'optin_id' ),
49				$page_id = $this_button.data( 'page_id' ),
50				$list_id = $this_button.data( 'list_id' );
51
52			var cookie = 'et_bloom_optin_'.concat( $optin_id, '_', $list_id, '_', type );
53
54			if ( cookieExists( cookie ) ) {
55				return;
56			}
57
58			$stats_data = JSON.stringify({ 'type' : type, 'optin_id' : $optin_id, 'page_id' : $page_id, 'list_id' : $list_id });
59
60			$.ajax({
61				type: 'POST',
62				url: bloomSettings.ajaxurl,
63				data: {
64					action : 'bloom_handle_stats_adding',
65					stats_data_array : $stats_data,
66					update_stats_nonce : bloomSettings.stats_nonce
67				}
68			}).done( function() {
69				set_cookie( 365, cookie.concat( '=true' ) );
70			});
71		}
72
73		function setCookieExpire( days ) {
74			var ms = days*24*60*60*1000;
75
76			var date = new Date();
77			date.setTime( date.getTime() + ms );
78
79			return "; expires=" + date.toUTCString();
80		}
81
82		function checkCookieValue( cookieName, value ) {
83			return parseCookies()[cookieName] == value;
84		}
85
86		function cookieExists( cookie_name ) {
87			return 'undefined' !== typeof parseCookies()[cookie_name];
88		}
89
90		function parseCookies() {
91			var cookies = document.cookie.split( '; ' );
92
93			var ret = {};
94			for ( var i = cookies.length - 1; i >= 0; i-- ) {
95			  var el = cookies[i].split( '=' );
96			  ret[el[0]] = el[1];
97			}
98			return ret;
99		}
100
101		function set_cookie( $expire, $cookie_content ) {
102			var $cookie_content = '' == $cookie_content ? 'etBloomCookie=true' : $cookie_content;
103			cookieExpire = setCookieExpire( $expire );
104			document.cookie = $cookie_content + cookieExpire + "; path=/";
105		}
106
107		function get_url_parameter( param_name ) {
108			var page_url = window.location.search.substring(1);
109			var url_variables = page_url.split('&');
110			for ( var i = 0; i < url_variables.length; i++ ) {
111					var curr_param_name = url_variables[i].split( '=' );
112				if ( curr_param_name[0] == param_name ) {
113					return curr_param_name[1];
114				}
115			}
116		}
117
118		//separate function for the setTimeout to make it work properly within the loop.
119		function make_popup_visible( $popup, $delay, $cookie_exp, $cookie_content ){
120			if ( ! $popup.hasClass( 'et_bloom_visible' ) ) {
121				setTimeout( function() {
122					$popup.addClass( 'et_bloom_visible et_bloom_animated' );
123					$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' );
124					update_stats_table( 'imp', $stats_data_container );
125
126					if ( '' != $cookie_exp ) {
127						set_cookie( $cookie_exp, $cookie_content );
128					}
129
130					if ( $( '.et_bloom_resize' ).length ) {
131						$( '.et_bloom_resize.et_bloom_visible' ).each( function() {
132							define_popup_position( $( this ), true, 0 );
133						});
134					}
135
136					display_image( $popup );
137
138				}, $delay );
139			}
140		}
141
142		function display_image( $popup ) {
143			setTimeout( function() {
144				$popup.find( '.et_bloom_image' ).addClass( 'et_bloom_visible_image' );
145			}, 500 );
146		}
147
148		function auto_popup( $current_popup_auto, $delay ) {
149			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' ),
150				page_id = $data_holder.data( 'page_id' ),
151				optin_id = $data_holder.data( 'optin_id' ),
152				list_id = $data_holder.data( 'list_id' );
153
154			if ( ! $current_popup_auto.hasClass( 'et_bloom_animated' ) ) {
155				var $cookies_expire_auto = $current_popup_auto.data( 'cookie_duration' ) ? $current_popup_auto.data( 'cookie_duration' ) : false,
156					$already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' );
157
158				if ( ( ( false !== $cookies_expire_auto && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_auto ) && ! $already_subscribed ) {
159					if ( false !== $cookies_expire_auto ) {
160						make_popup_visible ( $current_popup_auto, $delay, $cookies_expire_auto, 'etBloomCookie_' + optin_id + '=true' );
161					} else {
162						make_popup_visible ( $current_popup_auto, $delay, '', '' );
163					}
164				}
165			}
166		}
167
168		function scroll_trigger( $current_popup_bottom, is_bottom_trigger ) {
169			var triggered = 0,
170				$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' ),
171				page_id = $data_holder.data( 'page_id' ),
172				optin_id = $data_holder.data( 'optin_id' );
173				list_id = $data_holder.data( 'list_id' );
174
175			if ( ! $current_popup_bottom.hasClass( 'et_bloom_animated' ) ) {
176				var	cookies_expire_bottom = $current_popup_bottom.data( 'cookie_duration' ) ? $current_popup_bottom.data( 'cookie_duration' ) : false,
177					$already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' );
178
179				if ( true == is_bottom_trigger ) {
180					var scroll_trigger = $( '.et_bloom_bottom_trigger' ).length ? $( '.et_bloom_bottom_trigger' ).offset().top : $( document ).height() - 500;
181				} else {
182					var scroll_pos = $current_popup_bottom.data( 'scroll_pos' ) > 100 ? 100 : $current_popup_bottom.data( 'scroll_pos' ),
183						scroll_trigger = 100 == scroll_pos ? $( document ).height() - 50 : $( document ).height() * scroll_pos / 100;
184				}
185
186				$( window ).on( 'scroll', function(){
187					if ( ( ( false !== cookies_expire_bottom && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == cookies_expire_bottom ) && ! $already_subscribed ) {
188						if( $( window ).scrollTop() + $( window ).height() > scroll_trigger ) {
189							if ( 0 == triggered ) {
190								if ( false !== cookies_expire_bottom ) {
191									make_popup_visible ( $current_popup_bottom, 0, cookies_expire_bottom, 'etBloomCookie_' + optin_id + '=true' );
192								} else {
193									make_popup_visible ( $current_popup_bottom, 0, '', '' );
194								}
195
196								triggered++;
197							}
198						}
199					}
200				});
201			}
202		}
203
204		$.fn.isInViewport = function() {
205			var elementTop     = $( this ).offset().top;
206			var elementBottom  = elementTop + $( this ).outerHeight() || 0;
207			var viewportTop    = $( window ).scrollTop();
208			var viewportBottom = viewportTop + $( window ).height();
209
210			return elementBottom > viewportTop && elementTop < viewportBottom;
211		};
212
213		var $inline_optins = $( '.et_bloom_inline_form .et_bloom_submit_subscription, .et_bloom_widget_content .et_bloom_submit_subscription, .et_bloom_custom_html_form' );
214
215		if ( $inline_optins.length > 0 ) {
216			var imp_recorded_count = 0;
217
218			$(window).on( 'scroll.et_bloom_impressions', function() {
219				$inline_optins.each( function() {
220					if ( ! $(this).hasClass( 'et_bloom_impression_recorded' ) && $(this).isInViewport() ) {
221						$( this ).addClass( 'et_bloom_impression_recorded' );
222
223						imp_recorded_count++;
224
225						update_stats_table( 'imp', $(this) );
226					}
227				} );
228
229				if ( imp_recorded_count >= $inline_optins.length ) {
230					$(window).off( 'scroll.et_bloom_impressions' );
231				}
232			} );
233		}
234
235		 if( $( '.et_bloom_auto_popup' ).length ) {
236			$( '.et_bloom_auto_popup:not(.et_bloom_visible)' ).each( function() {
237				var this_el = $( this ),
238					delay = '' !== this_el.data( 'delay' ) ? this_el.data( 'delay' ) * 1000 : 0;
239				auto_popup( this_el, delay );
240			});
241		 }
242
243		if( $( '.et_bloom_trigger_bottom' ).length ) {
244
245			$( '.et_bloom_trigger_bottom:not(.et_bloom_visible)' ).each( function(){
246				scroll_trigger( $( this ), true );
247			});
248
249		}
250
251		if( $( '.et_bloom_scroll' ).length ) {
252
253			$( '.et_bloom_scroll:not(.et_bloom_visible)' ).each( function(){
254				scroll_trigger( $( this ), false );
255			});
256		}
257
258		if ( $( '.et_bloom_trigger_click' ).length ) {
259			$( '.et_bloom_trigger_click:not(.et_bloom_visible)' ).each( function() {
260				var $this_el = $( this ),
261					selector = $this_el.attr( 'data-trigger_click' );
262
263				if ( typeof selector !== 'undefined' ) {
264					$( 'body' ).on( 'click', selector, function() {
265						make_popup_visible ( $this_el, 0, '', '' );
266						return false;
267					});
268				}
269			});
270		}
271
272		if( $( '.et_bloom_trigger_idle' ).length ) {
273			$( '.et_bloom_trigger_idle:not(.et_bloom_visible)' ).each( function() {
274				var $this_el = $( this ),
275					$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' ),
276					page_id = $data_holder.data( 'page_id' ),
277					optin_id = $data_holder.data( 'optin_id' ),
278					list_id = $data_holder.data( 'list_id' );
279
280				if ( ! $this_el.hasClass( 'et_bloom_animated' ) ) {
281					var $cookies_expire_idle = $this_el.data( 'cookie_duration' ) ? $this_el.data( 'cookie_duration' ) : false,
282						$already_subscribed = checkCookieValue( 'et_bloom_subscribed_to_' + optin_id + list_id, 'true' );
283						$idle_timeout = '' !== $this_el.data( 'idle_timeout' ) ? $this_el.data( 'idle_timeout' ) * 1000 : 30000,
284						$delay = 0;
285
286					if ( ( ( false !== $cookies_expire_idle && ! checkCookieValue( 'etBloomCookie_' + optin_id, 'true' ) ) || false == $cookies_expire_idle ) && ! $already_subscribed ) {
287						$( document ).idleTimer( $idle_timeout );
288
289						$( document ).on( 'idle.idleTimer', function() {
290							if ( false !== $cookies_expire_idle ) {
291								make_popup_visible ( $this_el, $delay, $cookies_expire_idle, 'etBloomCookie_' + optin_id + '=true' );
292							} else {
293								make_popup_visible ( $this_el, $delay, '', '' );
294							}
295						});
296					}
297				}
298			});
299		}
300
301		if ( 'true' == get_url_parameter( 'et_bloom_popup' ) ) {
302			$( '.et_bloom_after_comment' ).each( function() {
303				auto_popup( $( this ), 0 );
304			});
305		}
306
307		if ( $( '.et_bloom_after_order' ).length ) {
308			$( '.et_bloom_after_purchase' ).each( function() {
309				auto_popup( $( this ), 0 );
310			});
311		}
312
313		if( $( '.et_bloom_locked_container' ).length ) {
314			var $i = 0;
315
316			$( '.et_bloom_locked_container' ).each( function() {
317				var $this_el = $( this ),
318					content = $this_el.find( '.et_bloom_locked_content' ),
319					form = $this_el.find( '.et_bloom_locked_form' ),
320					page_id = $this_el.data( 'page_id' ),
321					optin_id = $this_el.data( 'optin_id' );
322
323				$this_el.data( 'container_id', $i );
324				$locked_containers.push( content );
325
326				if ( checkCookieValue( 'et_bloom_unlocked' + optin_id + page_id, 'true' ) ) {
327					content.css( {'display' : 'block'} );
328					form.remove();
329				} else {
330					content.remove();
331					update_stats_table( 'imp', $this_el );
332				}
333
334				$i++;
335			});
336		}
337
338		$( 'body' ).on( 'click', '.et_bloom_locked_container .et_bloom_submit_subscription', function(){
339			var $current_container = $( this ).closest( '.et_bloom_locked_container' ),
340				container_id = $current_container.data( 'container_id' ),
341				page_id = $current_container.data( 'page_id' ),
342				optin_id = typeof $current_container.data( 'current_optin_id' ) !== 'undefined' ? $current_container.data( 'current_optin_id' ) : $current_container.data( 'optin_id' );
343
344			perform_subscription( $( this ), $current_container, container_id, page_id, optin_id );
345
346			return false;
347		});
348
349		// unlock content immediately if custom HTML form is used.
350		$( '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() {
351			var current_container = $( this ).closest( '.et_bloom_locked_container' ),
352				container_id = current_container.data( 'container_id' ),
353				page_id = current_container.data( 'page_id' ),
354				optin_id = current_container.data( 'optin_id' );
355
356			unlock_content( current_container, container_id, page_id, optin_id );
357		} );
358
359		function unlock_content( current_container, container_id, locked_page_id, locked_optin_id ) {
360			set_cookie( 365, 'et_bloom_unlocked' + locked_optin_id + locked_page_id + '=true' );
361			current_container.find( '.et_bloom_locked_form' ).replaceWith( $locked_containers[container_id] );
362			current_container.find( '.et_bloom_locked_content' ).css( { 'display' : 'block' } );
363		}
364
365		// Move inline forms into appropriate sections in Divi theme
366		if( $( '.et_bloom_below_post' ).length ) {
367			if ( $( 'body' ).hasClass( 'et_pb_pagebuilder_layout' ) ) {
368				var bottom_inline = $( '.et_bloom_below_post' ),
369					divi_container = '<div class="et_pb_row"><div class="et_pb_column et_pb_column_4_4"></div></div>';
370
371				if ( bottom_inline.length ) {
372					var $sections = $( '.et_pb_post_content .et_pb_section, .et_pb_fullwidth_post_content .et_pb_section' ).not( '.et_pb_fullwidth_section' );
373
374					if ($sections.length === 0) {
375						$sections = $( '.et-l--body .et_pb_section' ).not( '.et_pb_fullwidth_section' );
376					}
377
378					if ($sections.length === 0) {
379						$sections = $( '.et_pb_section' )
380							.not( '.et-l--header .et_pb_section' )
381							.not( '.et-l--footer .et_pb_section' )
382							.not( '.et_pb_fullwidth_section' );
383					}
384
385					$sections.last().append( divi_container ).find( '.et_pb_row' ).last().find( '.et_pb_column' ).append( bottom_inline );
386				}
387			}
388		}
389
390		function define_popup_position( $this_popup, $just_loaded, $message_space ) {
391			var this_popup = $this_popup.find( '.et_bloom_form_container' ),
392				popup_max_height = this_popup.hasClass( 'et_bloom_popup_container' ) ? $( window ).height() - 40 : $( window ).height() - 20,
393				real_popup_height = 0,
394				percentage = this_popup.parent().hasClass( 'et_bloom_flyin' ) ? 0.03 : 0.05,
395				percentage = this_popup.hasClass( 'et_bloom_with_border' ) ? percentage + 0.03 : percentage,
396				breakout_offset = this_popup.hasClass( 'breakout_edge' ) ? 0.95 
396: 1,
397				dashed_offset = this_popup.hasClass( 'et_bloom_border_dashed' ) ? 4 : 0,
398				form_height = this_popup.find( 'form' ).innerHeight() + $message_space,
399				form_add = true == $just_loaded ? 5 : 0,
400				is_form_sidebar = false;
401
402			var previous_css,
403				popup_parent = this_popup.parent(),
404				is_visible = popup_parent.hasClass('et_bloom_visible');
405
406			// Make parent visible for the browser to correctly calculate children(form wrapper) element height
407			// but the parent element is not visible to a web user
408			if (!is_visible) {
409				previous_css = popup_parent.attr('style');
410				popup_parent.css({ visibility: 'hidden', display: 'block' });
411			}
412
413			// Remove all existing height, min-height and max-height to correctly calculate wrapper height.
414			this_popup.find('.et_bloom_form_header').css({ 'height': '' });
415			this_popup.find('.et_bloom_form_content').css({ 'min-height': '' });
416			this_popup.find('.et_bloom_form_container_wrapper').css({ 'height': '', 'max-height': '' });
417
418			var form_container_wrapper_height = this_popup.find('.et_bloom_form_container_wrapper').height();
419
420			// Restore the previous style on parent element after getting height of the children(form wrapper) element.
421			if (!is_visible) {
422				popup_parent.attr('style', previous_css ? previous_css : '');
423			}
424
425			this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'max-height' : ( popup_max_height - 20 ) + 'px' } );
426
427			if ( ( 768 > $( 'body' ).outerWidth() + 15 ) || this_popup.hasClass( 'et_bloom_form_bottom' ) ) {
428				if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) {
429					this_popup.find( '.et_bloom_form_header' ).css( { 'height' : 'auto' } );
430				}
431
432				real_popup_height = form_container_wrapper_height + 30 + form_add;
433
434				if ( this_popup.hasClass( 'et_bloom_form_right' ) || this_popup.hasClass( 'et_bloom_form_left' ) ) {
435					this_popup.find( '.et_bloom_form_container_wrapper' ).css( { 'height' : ( real_popup_height - 30 + dashed_offset ) + 'px' } );
436					this_popup.find( '.et_bloom_form_content' ).css( { 'min-height' : '' } );
437				}
438			} else {
439				real_popup_height = form_container_wrapper_height + 30 + $message_space;
440
441				// A. Update popup height if current form is located on the sidebar.
442				// Sometimes real_popup_height return 0 because the current page is not
443				// loaded fully yet. So, we should not set height of the container as 0
444				// because it will break the layout.
445				if ((this_popup.hasClass('et_bloom_form_right') || this_popup.hasClass('et_bloom_form_left')) && 0 !== parseInt(real_popup_height)) {
446
447					is_form_sidebar = true;
448
449					// A.1. Check maybe the text content area is taller than the container.
450					var text_height = get_popup_text_height(this_popup);
451					if (text_height > real_popup_height) {
452						// A.1.a. In this case, use the text content area height instead.
453						real_popup_height = text_height;
454					}
455
456					// A.2. Update popup elements height with the latest real popup height.
457					update_popup_elements_height(this_popup, real_popup_height, breakout_offset, dashed_offset);
458				}
459			}
460
461			if ( this_popup.hasClass( 'et_bloom_popup_container' ) ) {
462				var top_position = $( window ).height() / 2 - this_popup.innerHeight() / 2;
463				if (0 < top_position) {
464					this_popup.css({ 'top' : top_position + 'px' });
465				}
466			}
467
468			if ( real_popup_height > popup_max_height ) {
469				this_popup.find( '.et_bloom_form_container_wrapper' ).addClass( 'et_bloom_vertical_scroll' );
470
471				// B. If current form is located on sidebar, we need to check it again just
472				// in case the text height changed again after vertical scroll added.
473				if (is_form_sidebar) {
474					var new_text_height = get_popup_text_height(this_popup);
475					if (new_text_height > real_popup_height) {
476						update_popup_elements_height(this_popup, new_text_height, breakout_offset, dashed_offset);
477					}
478				}
479			} else {
480				this_popup.find( '.et_bloom_form_container_wrapper' ).removeClass( 'et_bloom_vertical_scroll' );
481			}
482
483			if ( $this_popup.hasClass( 'et_bloom_popup' ) ) {
484				$( 'body' ).addClass( 'et_bloom_popup_active' );
485			}
486		}
487
488		/**
489		 * Get text content are height of the popup.
490		 *
491		 * @param {jQuery} $popup Popup jQuery instance.
492		 *
493		 * @return {string}
494		 */
495		function get_popup_text_height($popup) {
496			var $header = $popup.find('.et_bloom_form_header');
497			var height  = $popup.find('.et_bloom_form_text').innerHeight() + ($header.innerHe
497ight() - $header.height());
498			return height;
499		}
500
501		/**
502		 * Update popup elements height such as container, header, and content.
503		 *
504		 * @param {jQuery}  $popup   Popup jQuery instance.
505		 * @param {integer} height   New popup height.
506		 * @param {integer} breakout Breakout edge.
507		 * @param {integer} dashed   Border dashed width.
508		 */
509		function update_popup_elements_height($popup, height, breakout = 1, dashed = 0) {
510			$popup.find('.et_bloom_form_container_wrapper').css({ 'height': height });
511			$popup.find('.et_bloom_form_header').css({ 'height': height * breakout - dashed });
512			$popup.find('.et_bloom_form_content').css({ 'min-height': height - dashed });
513		}
514
515		$( 'body' ).on( 'click', '.et_bloom_submit_subscription:not(.et_bloom_submit_subscription_locked)', function() {
516			perform_subscription( $( this ), '', '', '', '' );
517			return false;
518		});
519
520		function perform_subscription(this_button, current_container, container_id, locked_page_id, locked_optin_id) {
521			var this_form = this_button.parents('form');
522			var list_id = this_button.data('list_id');
523			var account_name = this_button.data('account');
524			var service = this_button.data('service');
525			var name = this_form.find('.et_bloom_subscribe_name input').val();
526			var last_name = undefined !== this_form.find('.et_bloom_subscribe_last input').val() ? this_form.find('.et_bloom_subscribe_last input').val() : '';
527			var email = this_form.find('.et_bloom_subscribe_email input').val();
528			var page_id = this_button.data('page_id');
529			var optin_id = this_button.data('optin_id');
530			var $popup_container = this_form.closest('.et_bloom_optin');
531			var is_popup = $popup_container.hasClass('et_bloom_popup') || $popup_container.hasClass('et_bloom_flyin');
532			var $success_action_el = this_button.closest('.et_bloom_success_action');
533			var success_action_details = $success_action_el.length > 0 ? $success_action_el.parent().data('success_action_details').split('|') : [];
534			var success_action = 2 === success_action_details.length ? success_action_details[0] : '';
535			var success_action_url = '' !== success_action ? success_action_details[1] : '';
536
537			var ip_address        = this_button.data('ip_address');
538			var $fields_container = this_form.find('.et_bloom_fields');
539			var $custom_fields    = $fields_container.find('.et_bloom_custom_field input[type=text], .et_bloom_checkbox_handle, [data-field_type="radio"], textarea, select');
540			var custom_fields     = {};
541			var is_valid          = true;
542
543			// Email Validation
544			// Use the regex defined in the HTML5 spec for input[type=email] validation
545			// (see https://www.w3.org/TR/2016/REC-html51-20161101/sec-forms.html#email-state-typeemail)
546			var et_email_reg_html5 = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
547
548			this_form.find('.et_bloom_warn_field').removeClass('et_bloom_warn_field');
549
550			if (this_form.length > 0 && typeof this_form[0].reportValidity === 'function') {
551				// Checks HTML5 validation constraints
552				is_valid = this_form[0].reportValidity();
553			}
554
555			$custom_fields.each( function() {
556				var $this_el      = $(this);
557				var $this_wrapper = false;
558				var this_id       = $this_el.attr('data-id');
559				var field_type    = typeof $this_el.data( 'field_type' ) !== 'undefined' ? $this_el.data( 'field_type' ) : 'text';
560
561				if ('checkbox' === field_type || 'radio' === field_type) {
562					$this_wrapper = $this_el.closest('.et_bloom_custom_field');
563				}
564
565				var this_val      = $this_el.val();
566				var required_mark = typeof $this_el.data('required_mark') !== 'undefined' ? $this_el.data('required_mark') : 'not_required';
567				var original_id   = typeof $this_el.data('original_id') !== 'undefined' ? $this_el.data('original_id') : '';
568				var unchecked     = false;
569				var default_value;
570
571				// radio field properties adjustment
572				if ('radio' === field_type) {
573					if (0 !== $this_wrapper.find('input[type="radio"]').length) {
574						var $firstRadio = $this_wrapper.find('input[type="radio"]').first();
575
576						required_mark = typeof $firstRadio.data('required_mark') !== 'undefined' ? $firstRadio.data('required_mark') : 'not_required';
577
578						this_val = '';
579
580						if ($this_wrapper.find('input[type="radio"]:checked')) {
581							this_val = $this_wrapper.find('input[type="radio"]:checked').val();
582						}
583					}
584
585					if (!$.isEmptyObject(this_val)) {
586						custom_fields[this_id] = this_val;
587					}
588
589					if (0 === $this_wrapper.find('input[type="radio"]:checked').length) {
590						unchecked = true;
591					}
592
593					if (this_val) {
594						custom_fields[this_id] = this_val;
595					}
596				} else if ('checkbox' === field_type) {
597					this_val = {};
598
599					if ( 0 !== $this_wrapper.find('input[type="checkbox"]').length) {
600						var $checkboxHandle = $this_wrapper.find('.et_bloom_checkbox_handle');
601
602						required_mark = typeof $checkboxHandle.data('required_mark') !== 'undefined' ? $checkboxHandle.data('required_mark') : 'not_required';
603
604						if ($this_wrapper.find('input[type="checkbox"]:checked').length > 0) {
605							$this_wrapper.find('input[type="checkbox"]:checked').each(function() {
606								var field_id       = $(this).data('id');
607								this_val[field_id] = $(this).val();
608							} );
609						}
610					}
611
612					if (!$.isEmptyObject(this_val)) {
613						custom_fields[this_id] = this_val;
614					}
615
616					if (0 === $this_wrapper.find('input[type="checkbox"]:checked').length) {
617						unchecked = true;
618					}
619				} else if ('ontraport' === service && 'select' === field_type) {
620					// Need to pass option ID as a value for dropdown menu in Ontraport
621					var $selected_option   = $this_el.find(':selected');
622					custom_fields[this_id] = $selected_option.length > 0 ? $selected_option.data('id') : this_val;
623				} else {
624					custom_fields[this_id] = this_val;
625				}
626
627				// add error message for the field if it is required and empty
628				if ('required' === required_mark && ('' === this_val || true === unchecked)) {
629					if (false === $this_wrapper) {
630						$this_el.addClass('et_bloom_warn_field');
631					} else {
632						$this_wrapper.addClass('et_bloom_warn_field');
633					}
634
635					is_valid = false;
636				}
637
638				if ('email' === field_type) {
639					// remove trailing/leading spaces and convert email to lowercase
640					var processed_email = this_val.trim().toLowerCase();
641					var is_valid_email = et_email_reg_html5.test(processed_email);
642
643					if ('' !== processed_email && !is_valid_email) {
644						$this_el.addClass('et_bloom_warn_field');
645						is_valid = false;
646					}
647				}
648			} );
649
650			if (! is_valid) {
651				return;
652			}
653
654			if ('' == email) {
655				this_form.find('.et_bloom_subscribe_email input').addClass('et_bloom_warn_field');
656			} else {
657				ip_address = ip_address ? 'true' : 'false';
658				$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, 'ip_address': ip_address });
659				$.ajax({
660					type: 'POST',
661					dataType: 'json',
662					url: bloomSettings.ajaxurl,
663					data: {
664						action : 'bloom_subscribe',
665						subscribe_data_array : $subscribe_data,
666						custom_fields: custom_fields,
667						subscribe_nonce : bloomSettings.subscribe_nonce
668					},
669					beforeSend: function(data) {
670						this_button.addClass('et_bloom_button_text_loading');
671						this_button.find('.et_bloom_subscribe_loader').css({ 'display' : 'block' });
672					},
673					success: function(data) {
674						this_button.removeClass('et_bloom_button_text_loading');
675						this_button.find('.et_bloom_subscribe_loader').css({ 'display' : 'none' });
676						if (data) {
677							if ('' !== current_container && (data.success || 'Invalid email' !== data.error)) {
678								unlock_content(current_container, container_id, locked_page_id, locked_optin_id);
679							} else {
680								if (data.error) {
681									this_form.find('.et_bloom_error_message').remove();
682									this_form.prepend('<h2 class="et_bloom_error_message">' + data.error + '</h2>');
683									this_form.parent().parent().find('.et_bloom_form_header').addClass('et_bloom_with_error');
684								}
685								if (data.success && '' == current_container) {
686									set_cookie(365, 'et_bloom_subscribed_to_' + optin_id + list_id + '=true');
687
688									if ('' === success_action || '' === success_action_url) {
689									  this_form.parent().find('.et_bloom_success_message').addClass('et_bloom_animate_message');
690									  this_form.parent().find('.et_bloom_success_container').addClass('et_bloom_animate_success');
691									  this_form.remove();
692									} else {
693										window.location = success_action_url;
694									}
695
696									// auto close popup if enabled
697									if (is_popup && $popup_container.hasClass('et_bloom_auto_close')) {
698										setTimeout(function() {
699											perform_popup_closing($popup_container);
700										},1400);
701									}
702								}
703							}
704
705							if (is_popup) {
706								define_popup_position($popup_container, false, 50);
707							}
708						}
709					}
710				});
711			}
712		}
713
714		$( 'body' ).on( 'click', '.et_bloom_custom_html_form input[type="submit"], .et_bloom_custom_html_form button[type="submit"]', function() {
715			var this_button = $( this ),
716				form_container = this_button.closest( '.et_bloom_custom_html_form' );
717
718			update_stats_table( 'con', form_container );
719		} );
720
721		$( window ).on( 'resize', function(){
722			if ( $( '.et_bloom_resize' ).length ) {
723				$( '.et_bloom_resize' ).each( function() {
724					define_popup_position( $( this ), false, 0 );
725				});
726			}
727		});
728	});
729})(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.