PageSourceSearch

https://elneuropediatra.es/wp-content/plugins/convertpro/assets/modules/js/cp-submit-actions.js?ver=1.8.10

js elneuropediatra.es collected 2026-10-02 18:13:06 UTC 31,677 bytes, 848 lines download raw bytes

1(function ( $, window, undefined ) {
2
3	var is_form_validated = true;
4	var btn_data = '';
5	$(window).ready(function(){
6
7		var styleId = $('.cpro-form input[name="style_id"]').val();
8		styleIdSelctor = 'cp_popup_style_'+styleId;
9
10		/* Field Action on Click */
11		$(document).on('click', '.cp-target.cp-button-field', function() {
12			var self = $(this),
13			 action  = self.closest(".cp-field-html-data").data('action');
14			$('.cp-current-clicked-btn').removeClass('cp-current-clicked-btn');
15			self.closest(".cp-field-html-data").addClass('cp-current-clicked-btn');
16			btn_data = self.text();
17		});
18
19		/* Field Action on Click */
20		$(document).on('click', '.cp-field-html-data.cp-shapes-wrap', function() {
21			var self = $(this),
22			 action  = self.closest(".cp-field-html-data").data('action');
23
24			if ( action == 'submit' || action ==  'submit_n_close' || action ==  'submit_n_goto_step' || action == 'submit_n_goto_url' ) {
25			 	if( $('.cp_shape_submit_hidden').length == 0) {
26			 		self.find('.cp_shape_submit_label').append('<input type="submit" class="cp_shape_submit_hidden">');
27			 	}
28			}
29
30			$('.cp-current-clicked-shape').removeClass('cp-current-clicked-shape');
31			self.closest(".cp-field-html-data").addClass('cp-current-clicked-shape');
32		});
33
34		//handled form submission
35		jQuery( document ).on( "submit", "form.cpro-form" , function(e) {
36			e.preventDefault();
37			var is_success = false;
38			var invalid_email = false;
39			var thisForm = jQuery( this );
40			jQuery(document).trigger( "cp_before_form_submit", [jQuery(this)] );
41			
42			var checkboxFlag = true;
43
44			jQuery( this ).find( '.cpro-checkbox-required' ).each( function( index, elem ) {
45				var checkThis = jQuery(this);
46				setTimeout(function() { checkThis.find("input[type=checkbox]").prop( 'required', false ); }, 2000);
47				var checked = jQuery(this).find("input[type=checkbox]:checked").length;
48				if( checked == 0 ) {
49					jQuery(this).find("input[type=checkbox]:first").attr( 'required', 'required' );
50					thisForm[0].reportValidity();
51					checkboxFlag = false;
52					return false;
53				}
54			} );
55			
56			if( checkboxFlag ) {
57				is_form_validated = true;
58			} else {
59				is_form_validated = false;
60			}
61
62			if( is_form_validated ) {
63
64				var form         = jQuery(this),
65					style_id     = form.closest( ".cp-popup-container" ).data("style").replace( "cp_style_", "" ),
66					style_slug   = form.closest( ".cp-popup-container" ).data("styleslug"),
67					btn_old_text      = '';
68
69				var css_val = form.find( '.cp-form-input-field' ).css( 'text-transform' );
70				var form_field, attr_name, radio_attr_name, checkbox_attr_name, field_name, field_name_value, field_name_class, select_dropdown, selected_radio, selectedCheck;
71
72				if( 'uppercase' == css_val || 'lowercase' == css_val || 'capitalize' == css_val )
73				{
74					form_field = form.closest( ".cp-popup-container" ).find( '.cp-form-field' ).each(function() {
75					attr_name = jQuery(this).attr('name');
76
77					field_name = form.find( '[name="'+attr_name+'"]' );
78					field_name_class = field_name.attr( 'class' );
79
80					// Dropdown field section start.
81					if( undefined != field_name_class){
82						var isFound = field_name_class.indexOf( "cp-dropdown-field" ) !=-1? true: false;
83						if( isFound )
84						{
85							if( 'uppercase' == css_val ) {
86								select_dropdown = $( 'select[name="'+attr_name+'"] option:selected' ).val().toUpperCase();
87							} else if( 'lowercase' == css_val )	{
88								select_dropdown = $( 'select[name="'+attr_name+'"] option:selected' ).val().toLowerCase();
89							} else if ( 'capitalize' == css_val ) {
90								select_dropdown = $( 'select[name="'+attr_name+'"] option:selected' ).val().toLowerCase().replace(/\b[a-z]/g, function(letter) {
91									return letter.toUpperCase();
92								});;
93							}
94
95							$( 'select[name="'+attr_name+'"] option:selected' ).attr( 'value', select_dropdown );
96						}
97					}
98					// Dropdown field section end.
99					
100					// Radio and Checkbox field section start.
101					if( undefined == field_name_class )
102					{
103						var radio_length = $( ".cp-radio-field" ).length;
104						var checkbox_length = $( ".cp-checkbox-field" ).length;
105
106						if( radio_length > 0 ){
107							var each_radio = jQuery(this).find( 'input:radio' ).each(function() {
108							radio_attr_name = jQuery(this).attr( 'name' );
109
110							if( 'uppercase' == css_val ) {
111								selected_radio = $( 'input[name="'+radio_attr_name+'"]:checked' ).val().toUpperCase();
112							} else if( 'lowercase' == css_val ) {
113								selected_radio = $( 'input[name="'+radio_attr_name+'"]:checked' ).val().toLowerCase();
114							} else if ( 'capitalize' == css_val ) {
115								selected_radio = $( 'input[name="'+radio_attr_name+'"]:checked' ).val().toLowerCase().replace(/\b[a-z]/g, function(letter) {
116									return letter.toUpperCase();
117								});;
118							}
119								$( 'input[name="'+radio_attr_name+'"]:checked' ).attr( 'value', selected_radio );
120
121							});
122							;
123						}
124
125						if( checkbox_length > 0 ){
126							var each_checkbox = jQuery(this).find( 'input:checkbox' ).each(function() {
127							checkbox_attr_name = jQuery(this).attr( 'name' );
128								
129							var check = $( 'input[name="'+checkbox_attr_name+'"]' ).is( ":checked" );
130								
131							if( true == check ){
132								if( 'uppercase' == css_val ) {
133									selectedCheck = $( 'input[name="'+checkbox_attr_name+'"]:checked' ).val().toUpperCase();
134								} else if( 'lowercase' == css_val ) {
135									selectedCheck = $( 'input[name="'+checkbox_attr_name+'"]:checked' ).val().toLowerCase();
136								} else if ( 'capitalize' == css_val ) {
137									selectedCheck = $( 'input[name="'+checkbox_attr_name+'"]:checked' ).val().toLowerCase().replace(/\b[a-z]/g, function(letter) {
138										return letter.toUpperCase();
139									});;
140								}
141									$( 'input[name="'+checkbox_attr_name+'"]:checked' ).attr( 'value', selectedCheck );
142								}
143							});
144						}
145					}
146					// Radio checkbox field section end.
147
148					if( undefined != field_name_class)
149					{
150						if( 'param[email]' == attr_name )
151			            {
152			              field_name_value   = field_name.val().toLowerCase();
153			            }else{
154							if( 'uppercase' == css_val ) {
155								field_name_value   = field_name.val().toUpperCase();
156							} else if( 'lowercase' == css_val ) {
157								field_name_value   = field_name.val().toLowerCase();
158							} else if ( 'capitalize' == css_val ) {
159								field_name_value   = field_name.val().toLowerCase().replace(/\b[a-z]/g, function(letter) {
160									return letter.toUpperCase();
161								});;
162							}
163						}
164						jQuery(this).attr( 'value', field_name_value );
165					}
166				});
167				}
168				
169				var	data 				= form.serialize(),
170					form_container  	= form.closest(".cpro-form-container");
171					redirectdata 		= form.data("redirect-lead-data");
172					currentBtn 			= form.find('.cp-current-clicked-btn'),
173					currentShape		= form.find('.cp-current-clicked-shape'),
174					currentBtnAction	= currentBtn.closest('.cp-field-html-data').data('action'),
175					success_message		= currentBtn.find('.cp-button-field').data('success-message'),
176					currentShpAction	= currentShape.closest('.cp-field-html-data').data('action'),
177					success_message_shp	= currentShape.data('success-message'),
178					loader_style        = 'loader_1',
179					currObj 			= '',
180					btn_old_text        = currentBtn.find('.cp-button-field').html(),
181					shape_old_text      = currentShape.html();
182
183				var button_field = currentBtn.find('.cp-button-field');
184
185				var google_recaptcha = thisForm.find('.g-recaptcha');
186
187				if( google_recaptcha.length > 0 ) {
188
189
190					var client_side_response = thisForm.find( '[name="g-recaptcha-response"]' ).val();
191
192					if ( client_side_response.length === 0 ) {
193						thisForm.find( '.recaptcha-msg-error' ).text( "reCAPTCHA is Mandatory" );
194						if( !google_recaptcha.hasClass( "error" ) ){
195							google_recaptcha.addClass( "error" );
196						}
197						return;
198					} else {
199						thisForm.find('.recaptcha-msg-error' ).text('');
200						google_recaptcha.removeClass( "error" );
201					}
202				}
203
204				if( currentBtn.attr( 'data-type' ) == 'cp_button' || currentBtn.attr( 'data-type' ) == 'cp_gradient_button' ) {
205
206					currObj = currentBtn;
207					
208					button_field.removeClass('cp-tooltip cp-tooltip-top cp-tooltip-bottom cp-loader');
209					button_field.find('.cp_loader_container').removeClass('cp_success_loader_container');
210
211					// Loader Button
212					if( !currentBtn.hasClass( "cp-state-loading" ) && !currentBtn.hasClass( "cp-state-success" ) && !currentBtn.hasClass( "cp-state-error" ) ) {
213
214						currentBtn.addClass("cp-state-loading");
215						button_field.addClass('cp-loader cp-button-loading');
216						currentBtn.find('.cp-loader').css('text-align', 'center');
217
218						button_field.html("<div class='cp_loader_container'><i class='cp-button-loader-style draw " + loader_style + "'></i></div>");
219
220						if( currentBtnAction == 'submit_n_close' || currentBtnAction == 'submit' || currentBtnAction == 'submit_n_goto_url') {
221							if( '' != success_message.trim() && null != success_message.trim() )
222							{
223								button_field.addClass('cp-button-tooltip');
224								setTimeout(function(){
225								    button_field.removeClass('cp-button-tooltip');
226								},5000);
227							}
228						}
229					}
230				}
231
232				if( currentShape.attr( 'data-type' ) == 'cp_shape' ) {
233
234					currObj = currentShape;
235					
236					currentShape.find('.cp-shape-container').removeClass('cp-tooltip-top cp-tooltip-bottom');
237					currentShape.removeClass('cp-shape-submit-loading cp-state-success cp-error-tooltip');
238					if( !currentShape.hasClass( "cp-state-loading" ) && !currentShape.hasClass( "cp-state-success" ) && !currentShape.hasClass( "cp-state-error" ) ) {
239						
240						currentShape.addClass('cp-shape-submit-loading');
241
242						if( currentShpAction == 'submit_n_close' || currentShpAction == 'submit' || currentShpAction == 'submit_n_goto_url' ) {
243							currentShape.find('.cp-shape-submit-loading').addClass('cp-shapes-tooltip');
244						}
245					}
246				}
247
248				if( typeof cp_ajax.ajax_nonce !== 'undefined' ) {
249					data += '&_nonce='+  cp_ajax.ajax_nonce;
250				}
251
252				if( typeof cp_ajax.cpro_mx_valid !== 'undefined' ) {
253					data += '&mx_valid='+  cp_ajax.cpro_mx_valid;
254				}
255
256				close_span = '<span class="cp-tooltip-close">&times;</span>';
257
258				var email_field = thisForm.find( '[name="param[email]"]' );
259				var email_val   = email_field.val();
260
261				jQuery.ajax({
262					url: cp_ajax.url,
263					data: data,
264					type: 'POST',
265					dataType: 'json',
266					success: function( response ) {
267						var id      = currentBtn.closest(".cp-popup-wrapper").find('input[name=style_id]').val();
268						var modal   = $( '.cpro-onload[data-class-id=' + id + ']' );
269						var button_field = currentBtn.find('.cp-button-field');
270
271						button_field.find('.cp_loader_container').addClass('cp_success_loader_container');
272						button_field.find('.cp-button-loader-style').removeClass(loader_style).addClass('success-loader-style');
273						result = response.data;
274						error_msg = cp_ajax.not_connected_to_mailer;
275
276						if ( currentBtn.find('.cp-target').hasClass('cp-button-field') ) {
277
278							var curPos = currentBtn.find('.cp-button-field').offset().top - $( window ).scrollTop();
279							if( curPos > 90 ) {
280							currentBtn.find('.cp-button-field').addClass('cp-tooltip-top');
281							} else {
282								currentBtn.find('.cp-button-field').addClass('cp-tooltip-bottom');
283							} 
284							currentBtn.removeClass('cp-state-loading').addClass('cp-state-success').attr( 'style', 'z-index: 999 !important' );
285
286						} else if( currentShape.hasClass('cp-shapes-wrap') ) {
287
288							var curPos = currentShape.offset().top - $( window ).scrollTop();
289							if( curPos > 90 ) {
290								currentShape.find('.cp-shape-container').addClass('cp-tooltip-top');
291							} else {
292								currentShape.find('.cp-shape-container').addClass('cp-tooltip-bottom');
293							}
294							currentShape.removeClass('cp-state-loading').addClass('cp-state-success').attr( 'style', 'z-index: 999 !important' );
295						}
296
297						if( response === 0 ) {
298
299							is_success = false;
300
301							if( currentBtn.find('.cp-target').hasClass('cp-button') ) {
302								currentBtn.removeClass('cp-current-clicked-btn').addClass('cp-error-tooltip');
303								currentBtn.find( '.cp-btn-tooltip' ).html('<div class="cp-error-tip-content">' + error_msg + close_span + '</div>' );
304							} else if ( currentShape.hasClass('cp-shapes-wrap') ) {	
305								currentShape.removeClass('cp-current-clicked-shape').addClass('cp-error-tooltip');
306								currentShape.find('.cp-shape-tooltip').html('<div class="cp-error-tip-content">' + error_msg + close_span + '</div>' );
307							}
308
309						} else {
310
311							console.log( response );
312
313							if( false != result.error ) {
314
315								if( 'Invalid email address.' == result.error ) {
316									error_msg = cp_ajax.invalid_email_id;
317									invalid_email = true;
318								}
319
320								if( true == result.error ) {
321									error_msg = cp_ajax.recaptcha_error;
322								}
323
324								is_success = false;
325								if( currentBtn.find('.cp-target').hasClass('cp-button') ) {
326
327									currentBtn.removeClass('cp-current-clicked-btn').removeClass( 'cp-state-success' ).addClass('cp-error-tooltip');
328
329									currentBtn.find( '.cp-button-field' ).find( '.cp_success_loader_container' ).remove(); 
330
331									jQuery('<div/>', {
332									    addClass: 'cp_loader_container cp_error_loader_container',
333									}).appendTo( currentBtn.find( '.cp-button-field' ) );
334
335									currentBtn.find( '.cp_error_loader_container' ).append( "<i class='dashicons-no-alt dashicons'></i>" );
336
337									jQuery('<div/>', {
338									    class: 'cp-error-tip-content',
339									}).appendTo( currentBtn.find( '.cp-btn-tooltip' ) );
340
341									currentBtn.find( '.cp-error-tip-content' ).append( error_msg + close_span );
342
343
344								} else if ( currentShape.hasClass('cp-shapes-wrap') ) {
345
346									currentShape.removeClass('cp-current-clicked-shape').removeClass( 'cp-state-success' ).addClass('cp-error-tooltip');
347									currentShape.find('.cp-shape-tooltip').html('<div class="cp-error-tip-content">' + error_msg + close_span + '</div>' );
348									currentShape.find('.cp-button-field').html("<div class='cp_loader_container cp_error_loader_container'><i class='dashicons-no-alt dashicons'></i></div>");
349								}
350
351							} else {
352
353								is_success = true;
354								if( result.error == false ) {
355									if( currentBtn.find('.cp-target').hasClass('cp-button') ) {
356										currentBtn.removeClass('cp-error-tooltip').addClass('cp-state-success');
357										currentBtn.find('.cp-button-field').attr('data-content', success_message );
358										currentBtn.find('.cp-button-field').attr('disabled', true);
359										
360										switch( currentBtnAction ) {
361
362											case "submit_n_close": 
363		        								setTimeout(function() {
364													jQuery(document).trigger('closePopup',[modal,id]);
365												}, 1200 );
366											break;
367
368											case "submit_n_goto_step":
369
370												var step_number  = currentBtn.closest('.cp-field-html-data').data("step");
371												var current_step = currentBtn.closest('.cp-popup-content').data("step");
372												if( current_step != step_number ) {
373
374													setTimeout(function() {
375														cp_move_to_next_step( currentBtn, current_step, step_number );
376													}, 1200 );
377												}
378											break;
379
380											case "submit_n_goto_url":
381												var redirect_url  = currentBtn.closest('.cp-field-html-data').data("redirect");
382												var redirect_target = currentBtn.closest('.cp-field-html-data').data("redirect-target");
383												var get_param = currentBtn.find( '.cp-target' ).data( "get-param" );
384												var param = currentBtn.closest(".cpro-form").serializeArray();
385
386												redirect_url = cpro_generate_url( param, redirect_url, get_param );
387
388												setTimeout(function() {
389
390													if( typeof redirect_target == 'undefined' || redirect_target == ''){
391														redirect_target ='_self';
392													}
393													if( redirect_url !== '' ) {
394
395														if( '_self' !== redirect_target ) {
396															window.open( redirect_url, redirect_target );
397														} else {
398
399															if( redirect_url.indexOf( '.pdf' ) > 0 ) {
400																cpro_download_pdf( redirect_url );
401															} else {
402																window.location = redirect_url;
403															}
404														}
405														
406														/*
407														 * Close popup once submitted.
408														 * Reset the form data i.e. empty the form data fields.
409														 */
410														jQuery(document).trigger( 'closePopup', [modal,id] );
411														jQuery( '#cp_popup_id_' + id + ' .cpro-form' ).trigger("reset");
412														currentBtn.find('.cp-button-field').removeAttr('style data-content disabled');
413														currentBtn.find('.cp-target .cp_loader_container').remove();
414														currentBtn.find('.cp-button-field').html( btn_data ).removeClass('cp-button-loading cp-tooltip-top cp-tooltip-bottom');
415														currentBtn.removeClass( 'cp-state-success' );
416													}
417												}, 1200 );
418												
419											break;
420										}
421									} else if ( currentShape.hasClass('cp-shapes-wrap') ) {
422
423										currentShape.removeClass('cp-error-tooltip').removeClass('cp-shape-submit-loading').addClass('cp-state-success');
424										currentShape.attr( 'style', 'z-index: 35 !important' );
425										currentShape.find('.cp-shape-container').attr('data-content', success_message_shp );
426
427										switch( currentShpAction ) {
428
429											case "submit_n_close": 
430
431												var id      = currentShape.closest(".cp-popup-wrapper").find('input[name=style_id]').val();
432		        								var modal   = $( '.cpro-onload[data-class-id=' + id + ']' );
433
434		        								setTimeout(function() {
435													jQuery(document).trigger('closePopup',[modal,id]);
436												}, 1200 );
437											break;
438
439											case "submit_n_goto_step":
440
441												currentShape.find('.cp-shape-container').removeClass('cp-tooltip-top').removeClass('cp-tooltip-bottom');
442												var step_number  = currentShape.closest('.cp-field-html-data').data("step");
443												var current_step = currentShape.closest('.cp-popup-content').data("step");
444												if( current_step != step_number ) {
445
446													setTimeout(function() {
447														cp_move_to_next_step( currentShape, current_step, step_number );
448													}, 1200 );
449												}
450											break;
451
452											case 'submit_n_goto_url':
453												var redirect_url  = currentShape.closest('.cp-field-html-data').data("redirect");
454												var redirect_target = currentShape.closest('.cp-field-html-data').data("redirect-target");
455
456												var get_param = currentShape.closest( '.cp-field-html-data' ).data( "get-param" );
457												var param = currentShape.closest('.cpro-form').serializeArray();
458
459												redirect_url = cpro_generate_url( param, redirect_url, get_param );
460
461												setTimeout(function() {
462													if( typeof redirect_target == 'undefined' || redirect_target == ''){
463														redirect_target ='_self';
464													}
465													if( redirect_url !== '' ) {
466
467														if( '_self' !== redirect_target ) {
468															window.open( redirect_url, redirect_target );
469														} else {
470																
471															if( redirect_url.indexOf( '.pdf' ) > 0 ) {
472																cpro_download_pdf( redirect_url );
473															} else {
474																window.location = redirect_url;
475															}
476														}
477
478														// close popup once submitted.
479														jQuery(document).trigger( 'closePopup', [modal,id] );
480													}
481												}, 1200 );
482											break;
483										}
484									} else {
485										if( currentBtn.find('.cp-target').hasClass('cp-button') ) {
486											currentBtn.addClass('cp-error-tooltip');
487											currentBtn.find('.cp-button-field').attr('data-content', result.error );	
488										} else if ( currentShape.hasClass('cp-shapes-wrap') ) {
489											currentShape.removeClass('cp-current-clicked-shape').addClass('cp-error-tooltip');
490											currentShape.find('.cp-shape-container').attr('data-content', result.error );
491										}						
492									}
493								}
494
495								var convertPopupObj = new ConvertProPopup;
496								convertPopupObj._setCookie( currObj );
497							}
498						}
499
500						setTimeout(function() {
501							if( invalid_email ) {
502
503								if( currentBtn.length > 0 ) {
504									currentBtn.find('.cp-button-field').html( btn_old_text );
505									currentBtn.find('.cp-button-field').removeClass('cp-tooltip-top cp-tooltip-bottom');
506									currentBtn.closest('.cp-field-html-data').find( '.cp-error-tip-content' ).remove();
507								}
508
509								if( currentShape.length > 0 ) {
510									currentShape.find('.cp-shape-container').html( shape_old_text );
511									currentShape.find('.cp-shape-container').removeClass('cp-tooltip-top cp-tooltip-bottom');
512
513									currentShape.closest('.cp-field-html-data').find( '.cp-error-tip-content' ).remove();
514								}
515							}
516
517						}, 1500 );
518
519						setTimeout(function() {
520
521							if ( currentBtn.find('.cp-target .cp_loader_container').hasClass('cp_success_loader_container') ) {
522								currentBtn.find('.cp-button-field').removeClass('cp-tooltip-top cp-tooltip-bottom');
523							} else if( currentShape.hasClass('cp-shapes-wrap') && !currentShape.hasClass( 'cp-error-tooltip' ) ){
524								currentShape.find('.cp-shape-container').removeClass('cp-tooltip-top cp-tooltip-bottom');
525							}
526							
527						}, 5000 );
528
529						currentBtn.removeClass('cp-current-clicked-btn');
530						currentShape.removeClass('cp-current-clicked-shape');
531
532						if( ! invalid_email ) {
533							jQuery(document).trigger( "cp_after_form_submit", [jQuery(this), response, style_slug, email_val] );
534						}
535
536					},
537					error: function(data){
538						is_success = false;
539						currentBtn.find('.cp-button-field').attr('data-content', data );
540			        }
541				});
542			}
543
544			if( ! invalid_email ) {
545				jQuery(document).trigger( "cp_after_submit_action", [jQuery(this), style_id, is_success] );
546			}
547
548			e.preventDefault();
549
550		});
551
552		/**
553		 * Dynamic tags support START.
554		 * As per user selection set and send respective tags.
555		 * On the basis of Checkbox, Radio, and Dropdown elements.
556		*/
557		$( '.cp-checkbox-field input[type="checkbox"], .cp-radio-field input[type="radio"]' ).on( 'click', function( event ) {
558			var inputType         = $( this ).attr( 'type' );
559			var inputTypeField    = $( this ).closest( '.cp-' + inputType + '-field' );
560			var dynamicApiTagsValue = inputTypeField.find( '.cp-dynamic-api-tags' ).data( 'dynamic-api-tags' );
561			if ( 'undefined' !== typeof dynamicApiTagsValue ) {
562				var getApiTags          = $( this ).data( 'api-tags' );
563				var updatedValue        = [];
564				var tagsValue           = '';
565				if ( $( this ).is( ":checked" ) ) {
566					if ( '' === dynamicApiTagsValue ) {
567						updatedValue.push( getApiTags );
568					} else {
569						updatedValue = JSON.parse( dynamicApiTagsValue );
570						if ( ! updatedValue.includes( getApiTags ) ) {
571							updatedValue.push( getApiTags );
572						}
573					}
574
575					if ( 'radio' === inputType ) {
576						tagsValue = getApiTags;
577					} else {
578						tagsValue = updatedValue.join( '||' );
579					}
580					inputTypeField.find( '.cp-dynamic-api-tags' ).data( 'dynamic-api-tags', JSON.stringify( updatedValue ) ).val( tagsValue );
581				} else if ( $( this ).is( ":not(:checked)" ) && 'radio' !== inputType ) {
582					updatedValue   = JSON.parse( dynamicApiTagsValue );
583					var removeTags = updatedValue.indexOf( getApiTags );
584					if ( -1 !== removeTags ) {
585						updatedValue.splice( removeTags, 1 );
586					}
587					inputTypeField.find( '.cp-dynamic-api-tags' ).data( 'dynamic-api-tags', JSON.stringify( updatedValue ) ).val( updatedValue.join( '||' ) );
588				}
589			}
590		});
591
592		$( 'select.cp-dropdown-field' ).on( 'change', function( event ) {
593			var selectedValue = $( 'option:selected', this ).data( 'api-tags' );
594			$( this ).closest( '.cp-field-html-data' ).find( '.cp-dynamic-api-tags' ).val( selectedValue );
595		});
596		// Dynamic tags support END.
597
598		$( document ).on( 'click', '.cp-tooltip-close', function( event ) {
599				var $this       = $( this );
600				var form 		= $this.closest( 'form.cpro-form' ),
601				currentBtn 		= form.find('.cp-current-clicked-btn'),
602				currentShape 	= form.find('.cp-current-clicked-shape');
603
604				$this.closest( '.cp-error-tip-content' ).remove();
605				form.find('.cp-button-field').removeClass('cp-button-tooltip');
606				form.find('.cp-shape-container').removeClass('cp-tooltip-top')
607		} );
608
609		/* Button Scripts */
610		$(document).on( 'click', '.cp-field-html-data', function() {
611
612			var self = $(this),
613				dataAction = self.data( 'action' ),
614				formValidate = true;
615			
616			fieldActions( self, dataAction );
617
618			if( jQuery(this).data("type") !== 'cp_button' && jQuery(this).data("type") !== 'cp_gradient_button' ) {
619				self.removeClass('cp-current-clicked-btn');
620			}
621
622			if( jQuery(this).data("type") !== 'cp_shape' ) {
623				self.removeClass('cp-current-clicked-shape');
624			}
625		});
626
627		function cpro_generate_url( param, redirect_url, get_param ) {
628
629			for ( param_index = 0; param_index < param.length; ++param_index ) {
630
631				// Remove parameters with blank value
632				if( '' == param[param_index].value || 
633					'param[date]' == param[param_index].name || 
634					'action' == param[param_index].name ||
635					'style_id' == param[param_index].name ) {
636					delete param[param_index];
637				} else {
638
639					var new_name = param[param_index].name.replace( 'param[', '' );
640					new_name = new_name.substring( 0, new_name.length - 1 ); 
641					param[param_index].name = new_name;
642				}
643			}
644
645			// Remove empty paramters 
646			var param = param.filter(function(v){ return v !== '' } );
647			param = jQuery.param( param );
648
649			if( true == get_param ) {
650				var arr = redirect_url.split('?');
651				if( arr.length == 1 ) {
652				  	redirect_url = redirect_url + '?' + param
653				} else {
654					redirect_url = redirect_url + '&' + param
655				}
656			}
657
658			return redirect_url;
659		}
660
661		/**
662		 * Button Actions
663		 */
664		function fieldActions( btn, dataAction ) {
665
666			var current_step     = btn.closest('.cp-popup-content').data("step");
667			var id               = btn.closest(".cp-popup-wrapper").find('input[name=style_id]').val();
668            var modal            = $( '.cpro-onload[data-class-id=' + id + ']' );
669            var count_conversion = btn.hasClass('cpro_count_conversion');
670
671            $(document).trigger( 'cpro_before_field_actions', [btn, id] );
672
673            // count button click as conversion
674            if( count_conversion ) {
675            	// category name as per the plugin name is set.
676				var category = cp_ga_object.ga_category_name;
677			    var action   = 'conversion';
678			    var label    =  btn.closest( ".cp-popup-container" ).data("styleslug");
679
680			    if( 'function' === typeof cpCreateGoogleAnalyticEvent ) {
681			    	cpCreateGoogleAnalyticEvent( category, action, label );
682			    }
683
684			    var convertPopupObj = new ConvertProPopup;
685
686			    // Set conversion cookie
687				convertPopupObj._setCookie( btn );
688			}
689
690			/* Button Actions without Submit */
691			switch( dataAction ) {
692				case 'close':
693					$(document).trigger( 'closePopup', [modal,id] );
694					break;
695
696				case 'close_tab':
697					window.top.close();
698					break;
699
700				case 'goto_step':
701
702					var step_number  = btn.closest('.cp-field-html-data').data("step");
703					if( current_step != step_number ) {
704						var all_inputs = btn.closest('.cpro-form-container').find('input, select, textarea');
705
706						btn.closest('.cpro-form-container').find( '.cpro-checkbox-required' ).each( function( index, elem ) {
707
708							var checkThis = jQuery(this),
709								checked = jQuery(this).find("input[type=checkbox]:checked").length;
710
711							setTimeout( function( event ) {
712								checkThis.find("input[type=checkbox]").prop( 'required', false );
713								}, 2000 );
714
715							if( checked == 0 ) {
716								var firstcheckbox = jQuery(this).find("input[type=checkbox]:first");
717
718								if( 'undefined' != typeof firstcheckbox ) {
719									firstcheckbox.attr( 'required', 'required' );
720									firstcheckbox[0].reportValidity();
721									return false;
722								}
723							}
724						} );
725
726						// Google Recaptcha validate starts here.
727						var google_recaptcha = btn.closest('.cpro-form-container').find('.g-recaptcha');
728
729						if( google_recaptcha.length > 0) {
730
731							var client_side_response = btn.closest('.cpro-form-container').find('[name="g-recaptcha-response"]').val();
732							
733							if (client_side_response.length === 0) {
734							
735								btn.closest('.cpro-form-container').find('.recaptcha-msg-error').text( "reCAPTCHA is Mandatory" );
736							
737								if( !google_recaptcha.hasClass( "error" ) ){
738									google_recaptcha.addClass( "error" );
739								}
740								return false;
741							} else {
742								btn.closest('.cpro-form-container').find('.recaptcha-msg-error' ).text('');
743								google_recaptcha.removeClass( "error" );
744							}
745						}// Google Recaptcha validate ends here.
746
747						if( all_inputs.length > 0 ) {
748							var proceed_to_next_step = true;
749							if( current_step < step_number ) {
750								$.each( all_inputs, function( index, value ) {
751									if( ! value.checkValidity() ) {
752										proceed_to_next_step = false;
753										value.reportValidity();
754										return false;
755									}
756								} );
757							}
758							if( proceed_to_next_step ) {
759								cp_move_to_next_step( btn, current_step, step_number );
760							}
761						} else {
762							cp_move_to_next_step( btn, current_step, step_number );
763						}
764					}
765					
766				break;
767
768				case "goto_url":
769					var redirect_url = btn.data("redirect"),
770						target 		 = btn.data("redirect-target");
771					
772					if( typeof target == 'undefined' || target == '' ) {
773						target ='_self';
774					}
775
776					if( '' !== redirect_url ) {
777
778						if( '_self' !== target ) {
779							window.open( redirect_url, target );
780						} else {
781								
782							if( redirect_url.indexOf( '.pdf' ) > 0 ) {
783								cpro_download_pdf( redirect_url );
784							} else {
785								window.location = redirect_url;
786							}
787						}
788					}
789				break;
790				case "close_n_goto_url":
791					var redirect_url = btn.data("redirect"),
792						target 		 = btn.data("redirect-target");
793					
794					if( typeof target == 'undefined' || target == '' ) {
795						target ='_self';
796					}
797
798					if( '' !== redirect_url ) {
799
800						if( '_self' !== target ) {
801							window.open( redirect_url, target );
802						} else {
803								
804							if( redirect_url.indexOf( '.pdf' ) > 0 ) {
805								cpro_download_pdf( redirect_url );
806							} else {
807								window.location = redirect_url;
808							}
809						}
810						$(document).trigger( 'closePopup', [modal,id] );
811					}
812				break;
813			}
814		}
815
816		/**
817		 * Move to Next Step Funtion
818		 */
819		function cp_move_to_next_step( obj, step_id, step_number ) {
820			if( obj.closest( '.cp-popup' ).find( '.cp-popup-content.cp-panel-'+step_number ).length > 0 ) {
821				obj.closest( '.cp-popup' ).find( '.cp-popup-content.cp-panel-'+step_id ).removeClass('cpro-active-step');
822				obj.closest( '.cp-popup' ).find( '.cp-popup-content.cp-panel-'+step_number ).addClass('cpro-active-step');
823			}
824		}
825
826		function cpro_download_pdf( redirect_url ) {
827
828            var index = redirect_url.lastIndexOf("/") + 1;
829			var filename = redirect_url.substr(index);
830
831			var link = $("<a>");
832                link.attr( "href", redirect_url );
833                link.attr( "download", filename );
834                link.text( "cpro_anchor_link" );
835                link.addClass( "cpro_dummy_anchor" );
836
837            $('body').append(link);
838
839            $(".cpro_dummy_anchor")[0].click();
840
841            setTimeout(function() {
842				$(".cpro_dummy_anchor").remove();												                	
843            }, 500 );
844		}
845
846	});
847
848}(jQuery, window));

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.