PageSourceSearch

https://connectmebetter.com/assets/connectmebetter.com/wp-content/…/js/conditional_logic-30f71a4806.js

js connectmebetter.com collected 2026-10-08 16:32:02 UTC 25,288 bytes, 747 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opener = _____WB$wombat$assign$function_____("opener");
10
11var __gf_timeout_handle;
12
13gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
14	if( ! window.gf_form_conditional_logic ) {
15		return;
16	}
17	var dependentFieldIds = rgars( gf_form_conditional_logic, [ formId, 'fields', gformExtractFieldId( fieldId ) ].join( '/' ) );
18	if( dependentFieldIds ) {
19		gf_apply_rules( formId, dependentFieldIds );
20	}
21}, 10 );
22
23function gf_apply_rules(formId, fields, isInit){
24
25	jQuery(document).trigger( 'gform_pre_conditional_logic', [ formId, fields, isInit ] );
26	gform.utils.trigger( {
27		event: 'gform/conditionalLogic/applyRules/start',
28		native: false,
29		data: { formId: formId, fields: fields, isInit: isInit },
30	} );
31	for(var i=0; i < fields.length; i++){
32		gf_apply_field_rule(formId, fields[i], isInit, function(){
33			var is_last_field = ( i >= fields.length - 1 );
34			if( is_last_field ) {
35				jQuery(document).trigger('gform_post_conditional_logic', [formId, fields, isInit]);
36				gform.utils.trigger( {
37					event: 'gform/conditionalLogic/applyRules/end',
38					native: false,
39					data: { formId: formId, fields: fields, isInit: isInit },
40				} );
41				if( window.gformCalculateTotalPrice ) {
42					window.gformCalculateTotalPrice( formId );
43				}
44			}
45		});
46	}
47}
48
49function gf_check_field_rule(formId, fieldId, isInit, callback){
50
51	//if conditional logic is not specified for that field, it is supposed to be displayed
52	var conditionalLogic = gf_get_field_logic( formId, fieldId );
53	if ( ! conditionalLogic ) {
54		return 'show';
55	}
56
57	var action = gf_get_field_action(formId, conditionalLogic["section"]);
58
59	//If section is hidden, always hide field. If section is displayed, see if field is supposed to be displayed or hidden
60	if(action != "hide")
61		action = gf_get_field_action(formId, conditionalLogic["field"]);
62
63	return action;
64}
65
66/**
67 * Retrieves the conditional logic properties for the specified field.
68 *
69 * @since 2.4.16
70 *
71 * @param {(string|number)} formId  The ID of the current form.
72 * @param {(string|number)} fieldId The ID of the current field.
73 *
74 * @return {(boolean|object)} False or the field conditional logic properties.
75 */
76function gf_get_field_logic(formId, fieldId) {
77	var formConditionalLogic = rgars( window, 'gf_form_conditional_logic/' + formId );
78	if ( ! formConditionalLogic ) {
79		return false;
80	}
81
82	var conditionalLogic = rgars( formConditionalLogic, 'logic/' + fieldId );
83	if ( conditionalLogic ) {
84		return conditionalLogic;
85	}
86
87	var dependents = rgar( formConditionalLogic, 'dependents' );
88	if ( ! dependents ) {
89		return false;
90	}
91
92	// Attempting to get section field conditional logic instead.
93	for ( var key in dependents ) {
94		if ( dependents[key].indexOf( fieldId ) !== -1 ) {
95			return rgars( formConditionalLogic, 'logic/' + key );
96		}
97	}
98
99	return false;
100}
101
102function gf_apply_field_rule(formId, fieldId, isInit, callback){
103
104	var action = gf_check_field_rule(formId, fieldId, isInit, callback);
105
106	gf_do_field_action(formId, action, fieldId, isInit, callback);
107
108	var conditionalLogic = window["gf_form_conditional_logic"][formId]["logic"][fieldId];
109	//perform conditional logic for the next button
110	if(conditionalLogic["nextButton"]){
111		action = gf_get_field_action(formId, conditionalLogic["nextButton"]);
112		gf_do_next_button_action(formId, action, fieldId, isInit);
113	}
114
115}
116
117function gf_get_field_action(formId, conditionalLogic){
118	if(!conditionalLogic)
119		return "show";
120
121	var matches = 0;
122	for(var i = 0; i < conditionalLogic["rules"].length; i++){
123		/**
124		 * Filter the conditional logic rule before it is evaluated on the frontend.
125		 *
126		 * @param {object}          rule             The conditional logic rule about to be evaluated.
127		 * @param {(string|number)} formId           The current form ID.
128		 * @param {object}          conditionalLogic All details required to evaluate an objects conditional logic.
129		 *
130		 * @since 2.4.22
131		 */
132		var rule = gform.applyFilters( 'gform_rule_pre_evaluation', jQuery.extend( {}, conditionalLogic["rules"][i] ), formId, conditionalLogic );
133		if(gf_is_match(formId, rule))
134			matches++;
135	}
136
137	var action;
138	if( (conditionalLogic["logicType"] == "all" && matches == conditionalLogic["rules"].length) || (conditionalLogic["logicType"] == "any"  && matches > 0) )
139		action = conditionalLogic["actionType"];
140	else
141		action = conditionalLogic["actionType"] == "show" ? "hide" : "show";
142
143	return action;
144}
145
146function gf_is_match( formId, rule ) {
147
148	var $               = jQuery,
149		inputId         = rule['fieldId'],
150		fieldId         = gformExtractFieldId( inputId ),
151		inputIndex      = gformExtractInputIndex( inputId ),
152		isInputSpecific = inputIndex !== false,
153		$inputs;
154
155	if( isInputSpecific ) {
156		$inputs = $( '#input_{0}_{1}_{2}, #choice_{0}_{1}_{2}'.gformFormat( formId, fieldId, inputIndex ) );
157	} else {
158		$inputs = $( 'input[id="input_{0}_{1}"], input[id^="input_{0}_{1}_"], input[id^="choice_{0}_{1}_"], select#input_{0}_{1}, textarea#input_{0}_{1}'.gformFormat( formId, fieldId ) );
159	}
160
161	var isCheckable = $.inArray( $inputs.attr( 'type' ), [ 'checkbox', 'radio' ] ) !== -1;
162	var isMatch     = isCheckable ? gf_is_match_checkable( $inputs, rule, formId, fieldId ) : gf_is_match_default( $inputs.eq( 0 ), rule, formId, fieldId );
163
164	return gform.applyFilters( 'gform_is_value_match', isMatch, formId, rule );
165}
166
167function gf_is_match_checkable( $inputs, rule, formId, fieldId ) {
168
169	// Rule is checking if the checkable is/isn't blank. Return a specific check for that use-case.
170	if ( rule.value === '' ) {
171		return rule.operator === 'is' ? gf_is_checkable_empty( $inputs ) : ! gf_is_checkable_empty( $inputs );
172	}
173
174	var isMatch = false;
175
176	$inputs.each( function() {
177
178		var $input           = jQuery( this ),
179			fieldValue       = gf_get_value( $input.val() ),
180			isRangeOperator  = jQuery.inArray( rule.operator, [ '<', '>' ] ) !== -1,
181			isStringOperator = jQuery.inArray( rule.operator, [ 'contains', 'starts_with', 'ends_with' ] ) !== -1;
182
183		// if we are looking for a specific value and this is not it, skip
184		if( fieldValue != rule.value && ! isRangeOperator && ! isStringOperator ) {
185			return; // continue
186		}
187
188		// force an empty value for unchecked items
189		if( ! $input.is( ':checked' ) ) {
190			fieldValue = '';
191		}
192		// if the 'other' choice is selected, get the value from the 'other' text input
193		else if ( fieldValue == 'gf_other_choice' ) {
194			fieldValue = jQuery( '#input_{0}_{1}_other'.gformFormat( formId, fieldId ) ).val();
195		}
196
197		if( gf_matches_operation( fieldValue, rule.value, rule.operator ) ) {
198			isMatch = true;
199			return false; // break
200		}
201
202	} );
203
204	return isMatch;
205}
206
207/**
208 * Check if a collection of checkable inputs has any checked,
209 * or if they are all unchecked.
210 *
211 * @param {jQuery} $inputs A collection of inputs to check.
212 *
213 * @returns {boolean}
214 */
215function gf_is_checkable_empty( $inputs ) {
216	var isEmpty = true;
217
218	$inputs.each( function() {
219		if ( jQuery( this ).is( ':checked' ) ) {
220			isEmpty = false;
221		}
222	} );
223
224	return isEmpty;
225}
226
227function gf_is_match_default( $input, rule, formId, fieldId ) {
228
229	var val           = $input.val(),
230		values        = ( val instanceof Array ) ? val : [ val ], // transform regular value into array to support multi-select (which returns an array of selected items)
231		matchCount    = 0,
232		valuesLength  = Math.max( values.length, 1 ); // jQuery 3.0: Make sure our length is at least 1 so that the following loop fires.
233
234	for( var i = 0; i < valuesLength; i++ ) {
235
236		// fields with pipes in the value will use the label for conditional logic comparison
237		var hasLabel   = values[i] ? values[i].indexOf( '|' ) >= 0 : true,
238			fieldValue = gf_get_value( values[i] );
239
240		var fieldNumberFormat = gf_get_field_number_format( rule.fieldId, formId, 'value' );
241		if( fieldNumberFormat && ! hasLabel ) {
242			fieldValue = gf_format_number( fieldValue, fieldNumberFormat );
243		}
244
245		var ruleValue = rule.value;
246		//if ( fieldNumberFormat ) {
247		//	ruleValue = gf_format_number( ruleValue, fieldNumberFormat );
248		//}
249
250		if( gf_matches_operation( fieldValue, ruleValue, rule.operator ) ) {
251			matchCount++;
252		}
253
254	}
255
256	// if operator is 'isnot', none of the values can match
257	var isMatch = rule.operator == 'isnot' ? matchCount == valuesLength : matchCount > 0;
258
259	return isMatch;
260}
261
262function gf_format_number( value, fieldNumberFormat ) {
263
264	decimalSeparator = '.';
265
266	if( fieldNumberFormat == 'currency' ) {
267		decimalSeparator = gform.Currency.getDecimalSeparator( 'currency' );
268	} else if( fieldNumberFormat == 'decimal_comma' ) {
269		decimalSeparator = ',';
270	} else if( fieldNumberFormat == 'decimal_dot' ) {
271		decimalSeparator = '.';
272	}
273
274	// transform to a decimal dot number
275	value = gform.Currency.cleanNumber( value, '', '', decimalSeparator );
276
277	/**
278	 * Looking at format specified by wp locale creates issues. When performing conditional logic, all numbers will be formatted to decimal dot and then compared that way. AC
279	 */
280	// now transform to number specified by locale
281	// if( window['gf_number_format'] && window['gf_number_format'] == 'decimal_comma' ) {
282	//     value = gformFormatNumber( value, -1, ',', '.' );
283	// }
284
285	if( ! value ) {
286		value = 0;
287	}
288
289	number = value.toString();
290
291	return number;
292}
293
294function gf_try_convert_float(text){
295
296	/*
297	 * The only format that should matter is the field format. Attempting to do this by WP locale creates a lot of issues with consistency.
298	 * var format = window["gf_number_format"] == "decimal_comma" ? "decimal_comma" : "decimal_dot";
299	 */
300
301	var format = 'decimal_dot';
302	if( gformIsNumeric( text, format ) ) {
303		var decimal_separator = format == "decimal_comma" ? "," : ".";
304		return gform.Currency.cleanNumber( text, "", "", decimal_separator );
305	}
306
307	return text;
308}
309
310function gf_matches_operation(val1, val2, operation){
311	val1 = val1 ? val1.toLowerCase() : "";
312	val2 = val2 ? val2.toLowerCase() : "";
313
314	switch(operation){
315		case "is" :
316			return val1 == val2;
317			break;
318
319		case "isnot" :
320			return val1 != val2;
321			break;
322
323		case ">" :
324			val1 = gf_try_convert_float(val1);
325			val2 = gf_try_convert_float(val2);
326
327			return gform.utils.isNumber(val1) && gform.utils.isNumber(val2) ? val1 > val2 : false;
328			break;
329
330		case "<" :
331			val1 = gf_try_convert_float(val1);
332			val2 = gf_try_convert_float(val2);
333
334			return gform.utils.isNumber(val1) && gform.utils.isNumber(val2) ? val1 < val2 : false;
335			break;
336
337		case "contains" :
338			return val1.indexOf(val2) >=0;
339			break;
340
341		case "starts_with" :
342			return val1.indexOf(val2) ==0;
343			break;
344
345		case "ends_with" :
346			var start = val1.length - val2.length;
347			if(start < 0)
348				return false;
349
350			var tail = val1.substring(start);
351			return val2 == tail;
352			break;
353	}
354	return false;
355}
356
357function gf_get_value(val){
358	if(!val)
359		return "";
360
361	val = val.split("|");
362	return val[0];
363}
364
365function gf_do_field_action(formId, action, fieldId, isInit, callback){
366	var conditional_logic = window["gf_form_conditional_logic"][formId];
367	var dependent_fields = conditional_logic["dependents"][fieldId];
368
369	for(var i=0; i < dependent_fields.length; i++){
370		var targetId = fieldId == 0 ? "#gform_submit_button_" + formId : "#field_" + formId + "_" + dependent_fields[i];
371		var defaultValues = conditional_logic["defaults"][dependent_fields[i]];
372
373		//calling callback function on the last dependent field, to make sure it is only called once
374		do_callback = (i+1) == dependent_fields.length ? callback : null;
375
376		/**
377		 * Allow add-ons to abort gf_do_action() function.
378		 *
379		 * @since 2.6.2
380		 *
381		 * @param bool   $doAbort      The value being filtered. True to abort conditional logic action, false to continue. Defaults to false.
382		 * @param string $action       The conditional logic action that will be performed. Possible values: show or hide
383		 * @param string $targetId     HTML element id that will be the targed of the conditional logic action.
384		 * @param bool   $doAnimation  True to perform animation while showing/hiding field. False to hide/show field without animation.
385		 * @param array  $defaultValue Array containg default field values.
386		 * @param bool   $isInit       True if form is being initialized (i.e. before user has interacted with any input). False otherwise.
387		 * @param array  $formId       The current form ID.
388		 * @param func   $do_callback   Callback function to be executed after conditional logic is executed.
389		 */
390		let abort = gform.applyFilters( 'gform_abort_conditional_logic_do_action', false, action, targetId, conditional_logic[ "animation" ], defaultValues, isInit, formId, do_callback );
391		if ( ! abort ) {
392			gf_do_action( action, targetId, conditional_logic[ "animation" ], defaultValues, isInit, do_callback, formId );
393		} else if ( do_callback ) {
394			do_callback();
395		}
396
397		gform.doAction('gform_post_conditional_logic_field_action', formId, action, targetId, defaultValues, isInit);
398	}
399}
400
401function gf_do_next_button_action(formId, action, fieldId, isInit){
402	var conditional_logic = window["gf_form_conditional_logic"][formId];
403	var targetId = "#gform_next_button_" + formId + "_" + fieldId;
404
405	/**
406	 * Allow add-ons to abort gf_do_action() function.
407	 *
408	 * @since 2.6.2
409	 *
410	 * @param bool   $doAbort      The value being filtered. True to abort conditional logic action, false to continue. Defaults to false.
411	 * @param string $action       The conditional logic action that will be performed. Possible values: show or hide
412	 * @param string $targetId     HTML element id that will be the targed of the conditional logic action.
413	 * @param bool   $doAnimation  True to perform animation while showing/hiding field. False to hide/show field without animation.
414	 * @param array  $defaultValue Array containg default field values.
415	 * @param bool   $isInit       True if form is being initialized (i.e. before user has interacted with any input). False otherwise.
416	 * @param array  $formId       The current form ID.
417	 * @param func   $do_callback   Callback function to be executed after conditional logic is executed.
418	 */
419	let abort = gform.applyFilters( 'gform_abort_conditional_logic_do_action', false, action, targetId, conditional_logic[ "animation" ], null, isInit, formId, null );
420	if ( ! abort ) {
421		gf_do_action( action, targetId, conditional_logic[ "animation" ], null, isInit, null, formId );
422	}
423}
424
425function gf_do_action(action, targetId, useAnimation, defaultValues, isInit, callback, formId){
426	var $target = jQuery( targetId );
427
428	/**
429	 * Do not re-enable inputs that are disabled by default. Check if field's inputs have been assessed. If not, add
430	 * designator class so these inputs are exempted below.
431	 */
432	if( ! $target.data( 'gf-disabled-assessed' ) ) {
433		$target.find( ':input:disabled' ).addClass( 'gf-default-disabled' );
434		$target.data( 'gf-disabled-assessed', true );
435	}
436
437	// honeypot should not be impacted by conditional logic.
438	if( $target.hasClass( 'gfield--type-honeypot') ) {
439		return;
440	}
441
442	if(action == "show"){
443		// reset tabindex for selects
444		$target.find( 'select' ).each( function() {
445			var $select = jQuery( this );
446			$select.attr( 'tabindex', $select.data( 'tabindex' ) );
447		} );
448
449		if(useAnimation && !isInit){
450			if($target.length > 0){
451				$target.find(':input:hidden:not(.gf-default-disabled)').prop( 'disabled', false );
452				if ( $target.is( 'input[type="submit"]' ) || $target.hasClass( 'gform_next_button' ) ) {
453					gf_show_button( $target );
454				}
455				$target.slideDown(callback);
456				$target.attr( 'data-conditional-logic', 'visible' );
457			} else if(callback){
458				callback();
459			}
460		}
461		else{
462			var display = $target.data('gf_display');
463
464			// set display if previous (saved) display isn't set for any reason
465			if ( display == '' || display == 'none' ){
466				display = '1' === gf_legacy.is_legacy ? 'list-item' : 'block';
467			}
468			$target.find(':input:hidden:not(.gf-default-disabled)').prop( 'disabled', false ).attr( 'data-conditional-logic', 'visible' );
469
470			// Handle conditional submit and next buttons.
471			if ( $target.is( 'input[type="submit"]' ) || $target.hasClass( 'gform_next_button' ) ) {
472				gf_show_button( $target );
473			} else {
474				$target.css( 'display', display );
475				if( display == 'none' ) {
476					$target.attr( 'data-conditional-logic', 'hidden' );
477				} else {
478					$target.attr( 'data-conditional-logic', 'visible' );
479				}
480			}
481
482			if(callback){
483				callback();
484			}
485		}
486	}
487	else{
488
489		//if field is not already hidden, reset its values to the default
490		var child = $target.children().first();
491		if (child.length > 0){
492			var reset = gform.applyFilters('gform_reset_pre_conditional_logic_field_action', true, formId, targetId, defaultValues, isInit);
493
494			if(reset && !gformIsHidden(child)){
495				gf_reset_to_default(targetId, defaultValues);
496			}
497		}
498
499		// remove tabindex and stash as a data attr for selects
500		$target.find( 'select' ).each( function() {
501			var $select = jQuery( this );
502			$select.data( 'tabindex', $select.attr( 'tabindex' ) ).removeAttr( 'tabindex' );
503		} );
504
505		//Saving existing display so that it can be reset when showing the field
506		if( ! $target.data('gf_display') ){
507			$target.data('gf_display', $target.css('display'));
508		}
509
510		if(useAnimation && !isInit){
511			if( $target.is( 'input[type="submit"]' ) || $target.hasClass( 'gform_next_button' ) ) {
512				gf_hide_button( $target );
513			} else if ( $target.length > 0 && $target.is( ":visible" ) ) {
514				$target.slideUp( callback );
515				$target.attr( 'data-conditional-logic', 'hidden' );
516			} else if ( callback ) {
517				callback();
518			}
519		} else{
520
521			// Handle conditional submit and next buttons.
522			if ( $target.is( 'input[type="submit"]' ) || $target.hasClass( 'gform_next_button' ) ) {
523				gf_hide_button( $target );
524			} else {
525				$target.css( 'display', 'none' );
526				$target.attr( 'data-conditional-logic', 'hidden' );
527			}
528			$target.find(':input:hidden:not(.gf-default-disabled)').attr( 'disabled', 'disabled' );
529			if(callback){
530				callback();
531			}
532		}
533	}
534
535}
536
537function gf_show_button( $target ) {
538	$target.prop( 'disabled', false ).css( 'display', '' );
539	$target.attr( 'data-conditional-logic', 'visible' );
540	if ( '1' == gf_legacy.is_legacy ) {
541		// for legacy markup, remove screen reader class.
542		$target.removeClass( 'screen-reader-text' );
543	}
544
545	// Sometimes the next button is pretending to be a submit button, so it needs conditional logic too.
546	var fauxSubmitButton = jQuery( 'input.gform_next_button[type="button"][value="Submit"]' );
547	if ( fauxSubmitButton ) {
548		fauxSubmitButton.prop( 'disabled', false ).css( 'display', '' );
549		fauxSubmitButton.attr( 'data-conditional-logic', 'visible' );
550	}
551}
552
553function gf_hide_button( $target ) {
554	$target.attr( 'disabled', 'disabled' ).hide();
555	$target.attr( 'data-conditional-logic', 'hidden' );
556	if ( '1' === gf_legacy.is_legacy ) {
557		// for legacy markup, let screen readers read the button.
558		$target.addClass( 'screen-reader-text' );
559	}
560
561	// Sometimes the next button is pretending to be a submit button, so it needs conditional logic too.
562	var fauxSubmitButton = jQuery( 'input.gform_next_button[type="button"][value="Submit"]' );
563	if ( fauxSubmitButton ) {
564		fauxSubmitButton.attr( 'disabled', 'disabled' ).hide();
565		fauxSubmitButton.attr( 'data-conditional-logic', 'hidden' );
566	}
567}
568
569function gf_reset_to_default(targetId, defaultValue){
570
571	var dateFields = jQuery( targetId ).find( '.gfield_date_month input, .gfield_date_day input, .gfield_date_year input, .gfield_date_dropdown_month select, .gfield_date_dropdown_day select, .gfield_date_dropdown_year select' );
572	if( dateFields.length > 0 ) {
573
574		dateFields.each( function(){
575
576			var element = jQuery( this );
577
578			// defaultValue is associative array (i.e. [ m: 1, d: 13, y: 1987 ] )
579			if( defaultValue ) {
580
581				var key = 'd';
582				if (element.parents().hasClass('gfield_date_month') || element.parents().hasClass('gfield_date_dropdown_month') ){
583					key = 'm';
584				}
585				else if(element.parents().hasClass('gfield_date_year') || element.parents().hasClass('gfield_date_dropdown_year') ){
586					key = 'y';
587				}
588
589				val = defaultValue[ key ];
590
591			}
592			else{
593				val = "";
594			}
595
596			if(element.prop("tagName") == "SELECT" && val != '' )
597				val = parseInt(val, 10);
598
599
600			if(element.val() != val)
601				element.val(val).trigger("change");
602			else
603				element.val(val);
604
605		});
606
607		return;
608	}
609
610	//cascading down conditional logic to children to support nested conditions
611	//text fields and drop downs, filter out list field text fields name with "_shim"
612	var target = jQuery(targetId).find( 'select, input[type="text"]:not([id*="_shim"]), input[type="number"], input[type="hidden"], input[type="email"], input[type="tel"], input[type="url"], textarea' );
613	var target_index = 0;
614
615	// When a List field is hidden via conditional logic during a page submission, the markup 
615will be reduced to a
616	// single row. Add enough rows/inputs to satisfy the default value.
617	if( defaultValue && target.parents( '.ginput_list' ).length > 0 && target.length < defaultValue.length ) {
618		while( target.length < defaultValue.length ) {
619			gformAddListItem( target.eq( 0 ), 0 );
620			target = jQuery(targetId).find( 'select, input[type="text"]:not([id*="_shim"]), input[type="number"], textarea' );
621		}
622	}
623
624	target.each(function(){
625
626		var val = "";
627
628		var element = jQuery(this);
629
630		// Only reset Single Product and Shipping hidden inputs.
631		if( element.is( '[type="hidden"]' ) && ! gf_is_hidden_pricing_input( element ) ) {
632			return;
633		}
634
635		//get name of previous input field to see if it is the radio button which goes with the "Other" text box
636		//otherwise field is populated with input field name
637		var radio_button_name = element.prevAll("input").first().attr("value");
638		if(radio_button_name == "gf_other_choice"){
639			val = element.attr("value");
640		}
641		else if( Array.isArray( defaultValue ) && ! element.is( 'select[multiple]' ) ) {
642			val = defaultValue[target_index];
643		}
644		else if(jQuery.isPlainObject(defaultValue)){
645			val = defaultValue[element.attr("name")];
646			if( ! val && element.attr( 'id' ) ) {
647				// 'input_123_3_1' => '3.1'
648				var inputId = element.attr( 'id' ).split( '_' ).slice( 2 ).join( '.' );
649				val = defaultValue[ inputId ];
650			}
651			if( ! val && element.attr( 'name' ) ) {
652				var inputId = element.attr( 'name' ).split( '_' )[1];
653				val = defaultValue[ inputId ];
654			}
655		}
656		else if(defaultValue){
657			val = defaultValue;
658		}
659
660		if( element.is('select:not([multiple])') && ! val ) {
661			val = element.find( 'option' ).not( ':disabled' ).eq(0).val();
662		}
663
664		if(element.val() != val) {
665			element.val(val).trigger('change');
666			if (element.is('select') && element.next().hasClass('chosen-container')) {
667				element.trigger('chosen:updated');
668			}
669			// Check for Single Product & Shipping input and force visual price update.
670			if( gf_is_hidden_pricing_input( element ) ) {
671				var ids = gf_get_ids_by_html_id( element.parents( '.gfield' ).attr( 'id' ) );
672				jQuery( '#input_' + ids[0] + '_' + ids[1] ).text( gformFormatMoney( element.val() ) );
673				element.val( gformFormatMoney( element.val() ) );
674			}
675		}
676		else{
677			element.val(val);
678		}
679
680		target_index++;
681	});
682
683	//checkboxes and radio buttons
684	var elements = jQuery(targetId).find('input[type="radio"], input[type="checkbox"]:not(".copy_values_activated")');
685
686	elements.each(function(){
687
688		//is input currently checked?
689		var isChecked = jQuery(this).is(':checked') ? true : false;
690
691		//does input need to be marked as checked or unchecked?
692		var doCheck = defaultValue ? jQuery.inArray(jQuery(this).attr('id'), defaultValue) > -1 : false;
693
694		//if value changed, trigger click event
695		if(isChecked != doCheck){
696			//setting input as checked or unchecked appropriately
697
698			if(jQuery(this).attr("type") == "checkbox"){
699				jQuery(this).trigger('click');
700			}
701			else{
702				jQuery(this).prop('checked', doCheck).change();
703			}
704
705		}
706	});
707
708}
709
710function gf_is_hidden_pricing_input( element ) {
711
712	// Check for Single Product fields.
713	if( element.attr( 'id' ) && element.attr( 'id' ).indexOf( 'ginput_base_price' ) === 0 ) {
714		return true;
715	}
716
717	if( element.attr( 'type' ) !== 'hidden' ) {
718		return false;
719	}
720
721	// Check for Shipping fields.
722	return element.parents( '.gfield_shipping' ).length;
723}
724
725}
726
727/*
728     FILE ARCHIVED ON 05:53:11 Jul 11, 2025 AND RETRIEVED FROM THE
729     INTERNET ARCHIVE ON 08:43:59 Aug 06, 2026.
730     JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE.
731
732     ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C.
733     SECTION 108(a)(3)).
734*/
735/*
736playback timings (ms):
737  captures_list: 2.211
738  exclusion.robots: 0.125
739  exclusion.robots.policy: 0.111
740  esindex: 0.01
741  cdx.remote: 23.124
742  LoadShardBlock: 66.53 (3)
743  PetaboxLoader3.datanode: 136.613 (5)
744  PetaboxLoader3.resolve: 96.041 (2)
745  load_resource: 241.6
746  loaddict: 75.461
747*/

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.