PageSourceSearch

https://africanphilanthropyconference.com/wp-content/plugins/bt_cost_calculator/cc.main.js?ver=7.1.2

js africanphilanthropyconference.com collected 2026-09-28 11:13:14 UTC 30,216 bytes, 966 lines download raw bytes

1
2(function( $ ) {
3	
4	var is_rtl = false;
5	var rtl_direction = 1;
6	
7	// ---------------
8	// Functions start
9	// ---------------
10	
11	// Base functions 
12	 
13	window.bt_parse_float = function( x ) {
14		r = parseFloat( x );
15		if ( isNaN( r ) ) r = 0;
16		return r;
17	}
18	
19	$.fn.bt_cc_lock = function(){
20		$(this).addClass( 'btCCLock' );
21		return $(this);
22	}
23	
24	$.fn.bt_cc_unlock = function(){
25		$(this).removeClass( 'btCCLock' );
26		return $(this);
27	}
28	
29	// function to be called from element conditions 
30
31	window.bt_cc_set_slider_value = function( elem, value, calc ){
32		if ( elem.slider( 'instance' ) ) { 
33			elem.slider( 'value', value );
34			elem.find('.btQuoteSliderValue').html( value );	
35			if ( calc ) {
36				bt_quote_total( elem.closest( '.btQuoteBooking' ) );
37				bt_paypal_items( elem.closest( '.btQuoteBooking' ) );
38			}
39		}
40
41	}
42	window.bt_cc_get_slider_value = function( elem ){
43		if ( elem.slider( 'instance' ) ) {
44			val = bt_parse_float( elem.find('.btQuoteSliderValue').html() );
45		} else {
46			val = bt_parse_float( elem.data( 'initial-value' ) );
47		}
48		return val;
49		
50	}
51	
52	$.fn.bt_cc_set_value = function( value ){
53		if ( value !== null && value !== 'undefined' && value !== undefined ) {
54			var initial_value = value;	
55		} else {
56			var initial_value = $( this ).find( '.btQuoteElement' ).data( 'initial-value' );	
57		}
58		if ( $( this ).find( '.btQuoteItemInput > .btQuoteSelect' ).length > 0 ) {
59			var oDropdown = $( this ).find( '.btQuoteSelect' ).data("dd");
60			if ( oDropdown !== undefined ) {
61				bt_cc_init_dropdown( oDropdown, "#"+$( this ).attr('id'), initial_value );	
62			}	
63		} else if ( $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ).length > 0 ) {
64			if ( $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ).slider( 'instance' ) ) {
65				bt_cc_set_slider_value( $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ), initial_value );
66			} else {
67				/* W3 Tiotal cache safe path */
68				setTimeout( bt_cc_set_slider_value, 2000, $( this ).find( '.btQuoteItemInput > .btQuoteSlider' ), initial_value, true );
69			}
70			
71		} else if ( $( this ).find( '.btQuoteItemInput > .btQuoteText' ).length > 0 ) {
72			$( this ).find( '.btQuoteText' ).val( initial_value );
73		} else if ( $( this ).find( '.btQuoteItemInput > .btQuoteSwitch' ).length > 0 ) {
74			if ( 
75			( $( this ).find( '.btQuoteSwitch' ).data('on') == initial_value && !$( this ).find( '.btQuoteSwitch' ).hasClass('on') ) || 
76			( $( this ).find( '.btQuoteSwitch' ).data('off') == initial_value && $( this ).find( '.btQuoteSwitch' ).hasClass('on') )
77			) {
78				$( this ).find( '.btQuoteSwitch' ).trigger('click');
79			}
80		}
81		bt_cc_eval_conditions( initial_value, $( this ).find( '.btQuoteElement' ).data( 'condition' ) );
82		bt_quote_total( $( this ).closest( '.btQuoteBooking' ) );
83		bt_paypal_items( $( this ).closest( '.btQuoteBooking' ) );
84		return $(this);
85	}
86	
87	window.bt_cc_eval_conditions = function( val, conditions ){
88		// alert(conditions);
89		if ( conditions == '' || conditions == undefined ) return false;
90		if ( val == '' ) val = 0;	
91
92		if ( conditions.indexOf(';') == -1 ) {
93			conditions = atob( conditions );
94			var bt_cc_conditions = conditions.split(/\r?\n/);
95		} else {
96			var bt_cc_conditions = conditions.split("#bt_cc_nl#");
97		}
98		$.each( bt_cc_conditions, function( index, value ) {
99			if ( bt_cc_conditions[index] != undefined ) {
100				var bt_cc_single_condition = bt_cc_conditions[index].split(";");
101				var eval_action  = bt_cc_single_condition[2];
102				if ( bt_cc_single_condition[3] == 'lock' ) {
103					eval_action += '.bt_cc_lock()';	
104				} else if ( bt_cc_single_condition[3] == 'unlock' ) {
105					eval_action += '.bt_cc_unlock()';	
106				}
107				if ( bt_cc_single_condition[0] != '' ) {
108					var eval_code =  'if ( ' + val + decodeURIComponent( bt_cc_single_condition[0] ) + ' ) { $(\'#' + bt_cc_single_condition[1] +  '\').' + eval_action + '; }' ;
109					eval( eval_code );	
110				}				
111			}
112
113		});
114		return false;
115	}
116
117	
118	// Paypal calculation
119	
120	window.bt_paypal_items = function( c ) {
121					
122		$( c ).each(function() {
123		
124			if ( $( this ).find( '.btPayPalButton' ).length > 0 ) {
125				
126				var form = $( this ).find( '.btPayPalButton' ).next();
127				form.find( '.btPayPalItem' ).remove();
128				
129				var x = 0;
130		
131				// items not in multiply and group
132				$( this ).find( '.btQuoteBookingForm' ).find( '.btQuoteItem' ).not( '.btQuoteMBlock .btQuoteItem' ).not( '.btQuoteGBlock .btQuoteItem' ).each(function() {
133					
134					var unit_price = 0;
135					var val = 0;
136					
137					var selected_name = '';
138
139					$( this ).find( '.btQuoteText' ).each(function() {
140						unit_price = bt_parse_float( $( this ).data( 'price' ) );
141						val = bt_parse_float( $( this ).val() );
142					});
143					
144					$( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {
145						unit_price = bt_parse_float( $( this ).data( 'value' ) );
146						val = 1;
147						selected_name = $( this ).find( '.ddlabel' )[0].innerHTML;
148						if ( $( this ).is( ':first-child' ) ) {
149							selected_name = '';
150						}
151					});
152					
153					var is_slider = false;
154					$( this ).find( '.btQuoteSlider' ).each(function() {
155						unit_price = bt_parse_float( $( this ).data( 'price' ) );
156						val = bt_cc_get_slider_value ( $( this ) );
157						is_slider = true;
158					});
159					
160					$( this ).find( '.btQuoteSwitch' ).each(function() {
161						if ( $( this ).hasClass( 'on' ) ) {
162							unit_price = bt_parse_float( $( this ).data( 'on' ) );
163						} else {
164							unit_price = bt_parse_float( $( this ).data( 'off' ) );
165						}
166						val = 1;
167					});
168
169					var label = $( this ).find( 'label' ).html();
170					
171					if ( is_slider ) {
172						label = label + ': ' + val;
173					}
174					
175					if ( selected_name != '' ) {
176						selected_name = selected_name.replace( '<span class="description">', '/' );
177						selected_name = selected_name.replace( '</span>', '' );
178						if ( label.endsWith( '?' ) || label.endsWith( ':' ) ) {
179							label = label + ' ' + selected_name;
180						} else {
181							label = label + ': ' + selected_name;
182						}
183						
184					}
185
186					val = val * unit_price;
187					
188		
189					if ( label !== undefined && val > 0 ) {
190						x++;
191						val = val.toFixed( 2 );
192						form.append( '<input type="hidden" name="item_name_' + x + '" value="' + label + '" class="btPayPalItem"><input type="hidden" name="amount_' + x + '" value="' + val + '" class="btPayPalItem">' );
193					}
194				});
195				
196				
197				// multiply
198				
199				$( this ).find( '.btQuoteBookingForm' ).find( '.btQuoteMBlock' ).each(function() {
200
201					var m_total = 1;
202					var m_first = true;
203					var m_val = 0;
204					var selected_name = '';
205					var label = '';
206					
207					$( this ).find( '.btQuoteItem' ).each(function() {
208				
209						$( this ).find( '.btQuoteText' ).each(function() {
210							var unit_price = bt_parse_float( $( this ).data( 'price' ) );
211							var val = bt_parse_float( $( this ).val() );
212							val = val * unit_price;
213							if ( m_first ) {
214								m_val = val;
215								label = $( this ).closest( '.btQuoteItem' ).find( 'label' ).html();
216							} else {
217								m_total *= val;
218							}
219							m_first = false;
220						});
221						
222						$( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {
223							var val = bt_parse_float( $( this ).data( 'value' ) );
224							if ( m_first ) {
225								m_val = val;
226								label = $( this ).closest( '.btQuoteItem' ).find( 'label' ).html();
227								selected_name = $( this ).find( '.ddlabel' )[0].innerHTML;
228								selected_name = selected_name.substring( 0, selected_name.indexOf( '<span' ) );
229								if ( $( this ).is( ':first-child' ) ) {
230									selected_name = '';
231								}
232								if ( selected_name != '' ) label = label + ': ' + selected_name;											
233							} else {
234								m_total *= val;
235							}
236							m_first = false;
237						});
238						
239						$( this ).find( '.btQuoteSlider' ).each(function() {
240							var unit_price = bt_parse_float( $( this ).data( 'price' ) );
241							// var val = bt_parse_float( $( this ).slider( 'value' ) );
242							var val = bt_cc_get_slider_value ( $( this ) );
243							val = val * unit_price;
244							if ( m_first ) {
245								m_val = val;
246								label = $( this ).closest( '.btQuoteItem' ).find( 'label' ).html();
247							} else {
248								m_total *= val;
249							}
250							m_first = false;
251						});
252						
253						$( this ).find( '.btQuoteSwitch' ).each(function() {
254							if ( $( this ).hasClass( 'on' ) ) {
255								var val = bt_parse_float( $( this ).data( 'on' ) );
256							} else {
257								var val = bt_parse_float( $( this ).data( 'off' ) );
258							}							
259							if ( m_first ) {
260								m_val = val;
261								label = $( this ).closest( '.btQuoteItem' ).find( 'label' ).html();
262							} else {
263								m_total *= val;
264							}
265							m_first = false;
266						});
267						
268						
269					});
270					
271					if ( m_total > 0 && m_val > 0 ) {
272						x++;
273						m_val = m_val.toFixed( 2 );
274						form.append( '<input type="hidden" name="item_name_' + x + '" value="' + label + '" class="btPayPalItem"><input type="hidden" name="amount_' + x + '" value="' + m_val + '" class="btPayPalItem"><input type="hidden" name="quantity_' + x + '" value="' + m_total + '" class="btPayPalItem">' );
275					}
276
277				});
278				
279				
280				// group
281				
282				$( this ).find( '.btQuoteBookingForm' ).find( '.btQuoteGBlock' ).each(function() {
283					
284					var eval_code = $( this ).data( 'eval' );
285					
286					var paypal_label = $( this ).data( 'paypal_label' );
287						
288					var group_array = [];
289					
290					$( this ).find( '.btQuoteItem' ).each(function() {
291						
292						var val;
293				
294						$( this ).find( '.btQuoteText' ).each(function() {
295							var unit_price = bt_parse_float( $( this ).data( 'price' ) );
296							val = bt_parse_float( $( this ).val() );
297							val = val * unit_price;
298						});
299						
300						$( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {
301							val = bt_parse_float( $( this ).data( 'value' ) );
302						});
303						
304						$( this ).find( '.btQuoteSlider' ).each(function() {
305							var unit_price = bt_parse_float( $( this ).data( 'price' ) );
306							// val = bt_parse_float( $( this ).slider( 'value' ) );
307							val = bt_cc_get_slider_value ( $( this ) );
308							val = val * unit_price;
309						});
310						
311						$( this ).find( '.btQuoteSwitch' ).each(function() {
312							if ( $( this ).hasClass( 'on' ) ) {
313								val = bt_parse_float( $( this ).data( 'on' ) );
314							} else {
315								val = bt_parse_float( $( this ).data( 'off' ) );
316							}
317						});
318						
319						group_array.push( val );
320						
321					});
322					
323					var patt = /\$\d+/igm;
324					var match = eval_code.match( patt );
325
326					if ( match === null ) {
327						eval_code = atob( eval_code );
328						match = eval_code.match( patt );
329					}
330
331					if ( match === null ) {
332						return;
333					}
334					
335					for ( var i = 0; i < match.length; i++ ) {
336						eval_code = eval_code.replace( match[ i ], group_array[ i ] );
337					}
338					var g_total = eval( '(function() {' + decodeURIComponent(eval_code) + '}())' );
339					
340					if ( paypal_label != '' && g_total > 0 ) {
341						x++;
342						g_total = g_total.toFixed( 2 );
343						form.append( '<input type="hidden" name="item_name_' + x + '" value="' + paypal_label + '" class="btPayPalItem"><input type="hidden" name="amount_' + x + '" value="' + g_total + '" class="btPayPalItem"><input type="hidden" name="quantity_' + x + '" value="1" class="btPayPalItem">' );
344					}
345
346				});
347			}
348		});
349	}
350	
351	// Currency format
352	
353	window.bt_cc_currency_format = function( c, n ) {
354		var regex = /(\d)(?=(\d{3})+\.)/g;
355		var regex_replace = '$1,';
356		
357		var format = c.data( 'total_format' );
358		var decimals = c.data( 'total_decimals' );
359
360		if ( format == 'currency_1' || format == 'currency_2' || format == 'currency_3' ) {
361			
362			n = n.toFixed( decimals );
363			
364			if ( format == 'currency_2' || format == 'currency_3' ) {
365				n = n.replace( '.', ',' );
366				regex = /(\d)(?=(\d{3})+\,)/g;
367				if ( format == 'currency_2' ) {
368					regex_replace = '$1.';
369				} else if ( format == 'currency_3' ) {
370					regex_replace = '$1 ';
371				}
372			}
373			
374			n = n.replace( regex, regex_replace );
375			
376		} else if ( format == 'decimal_1' || format == 'decimal_2' ) {
377			
378			n = parseFloat( n.toFixed( decimals ) ).toString();
379			if ( format == 'decimal_2' ) {
380				n = n.replace( '.', ',' );
381			}
382			
383		} else if ( format == 'rounded' ) {
384			
385			n = Math.round( n );
386			
387		}
388		
389		return n;
390	}
391	
392	// Total calculation
393	
394	window.bt_quote_total = function( c ) {
395		
396		var c = $( c );
397	
398		total = 0;
399		
400
401		c.find( '.btQuoteText' ).not( '.btQuoteMBlock .btQuoteText' ).not( '.btQuoteGBlock .btQuoteText' ).each(function() {
402			var unit_price = bt_parse_float( $( this ).data( 'price' ) );
403			var val = bt_parse_float( $( this ).val() );
404			val = val * unit_price;
405			total += val;
406		});
407		
408		c.find( '.btQuoteSelect' ).not( '.btQuoteMBlock .btQuoteSelect' ).not( '.btQuoteGBlock .btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {
409			var val = bt_parse_float( $( this ).data( 'value' ) );
410			total += val;
411		});
412		
413		c.find( '.btQuoteSlider' ).not( '.btQuoteMBlock .btQuoteSlider' ).not( '.btQuoteGBlock .btQuoteSlider' ).each(function() {
414			var unit_price = bt_parse_float( $( this ).data( 'price' ) );
415			var offset = bt_parse_float( $( this ).data( 'offset' ) );
416			var val = bt_cc_get_slider_value ( $( this ) );
417			val = val * unit_price;
418			total += val;
419			if ( ! $( this ).closest( '.btQuoteBooking' ).find( '.btPayPalButton' ).length > 0 ) {
420				total += offset;
421			}
422		});
423		
424		c.find( '.btQuoteSwitch' ).not( '.btQuoteMBlock .btQuoteSwitch' ).not( '.btQuoteGBlock .btQuoteSwitch' ).each(function() {
425			if ( $( this ).hasClass( 'on' ) ) {
426				total += bt_parse_float( $( this ).data( 'on' ) );
427			} else {
428				total += bt_parse_float( $( this ).data( 'off' ) );
429			}
430		});
431							
432		
433		// multiply
434		
435		c.find( '.btQuoteMBlock' ).each(function() {
436								
437			var m_total = 0;
438			var m_first = true;
439			$( this ).find( '.btQuoteText' ).each(function() {
440									   
441				var unit_price = bt_parse_float( $( this ).data( 'price' ) );
442				var val = bt_parse_float( $( this ).val() );
443				val = val * unit_price;
444				if ( m_first ) {
445					m_total = val;
446				} else {
447					m_total *= val;
448				}
449				m_first = false;
450											 
451			});
452			
453			$( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {
454										
455										  
456				var val = bt_parse_float( $( this ).data( 'value' ) );
457										   
458				if ( m_first ) {
459					m_total = val;
460				} else {
461					m_total *= val;
462				}
463				m_first = false;
464											
465			});
466			
467			$( this ).find( '.btQuoteSlider' ).each(function() {
468									   
469				var unit_price = bt_parse_float( $( this ).data( 'price' ) );
470				var offset = bt_parse_float( $( this ).data( 'offset' ) );
471				//var val = bt_parse_float( $( this ).slider( 'value' ) );
472				var val = bt_cc_get_slider_value ( $( this ) );
473				val = val * unit_price;
474				if ( m_first ) {
475					m_total = val;
476				} else {
477					m_total *= val;
478				}
479				m_total += offset;
480				m_first = false;
481										   
482			});
483			
484			$( this ).find( '.btQuoteSwitch' ).each(function() {
485									   
486				if ( $( this ).hasClass( 'on' ) ) {
487					var val = bt_parse_float( $( this ).data( 'on' ) );
488				} else {
489					var val = bt_parse_float( $( this ).data( 'off' ) );
490				}							
491				if ( m_first ) {
492					m_total = val;
493				} else {
494					m_total *= val;
495				}
496				m_first = false;
497											
498			});
499									
500			
501			total += m_total;
502			
503		});
504							
505						  
506		
507		// group
508		
509		c.find( '.btQuoteGBlock' ).each(function() {
510			
511			var eval_code = $( this ).data( 'eval' );
512			
513			var group_array = [];
514			
515			$( this ).find( '.btQuoteItem .btQuoteItemInput' ).each(function() {
516				
517				var val = 0;
518				
519				$( this ).find( '.btQuoteText' ).each(function() {
520					var unit_price = bt_parse_float( $( this ).data( 'price' ) );
521					val = bt_parse_float( $( this ).val() );
522					val = val * unit_price;
523				});
524				
525				$( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {							
526					val = bt_parse_float( $( this ).data( 'value' ) );	
527				});
528				
529				$( this ).find( '.btQuoteSlider' ).each(function() {
530					var unit_price = bt_parse_float( $( this ).data( 'price' ) );
531					var offset = bt_parse_float( $( this ).data( 'offset' ) );
532					val = bt_cc_get_slider_value( $( this ) );
533					val = val * unit_price;
534				});
535				
536				$( this ).find( '.btQuoteSwitch' ).each(function() {
537					if ( $( this ).hasClass( 'on' ) ) {
538						val = bt_parse_float( $( this ).data( 'on' ) );
539					} else {
540						val = bt_parse_float( $( this ).data( 'off' ) );
541					}
542				});
543				
544				group_array.push( val );
545
546			});
547
548			var patt = /\$\d+/igm;
549			var match = eval_code.match( patt );
550
551			if ( match === null ) {
552				eval_code = atob( eval_code );
553				match = eval_code.match( patt );
554			}
555
556			if ( match === null ) {
557				return;
558			}
559
560			for ( var i = 0; i < match.length; i++ ) {
561				eval_code = eval_code.replace( match[ i ], group_array[ i ] );
562			}
563			
564			var g_total = eval( '(function() {' + decodeURIComponent( eval_code ) + '}())' );
565			
566			total += g_total;
567			
568		});
569		
570		total = bt_cc_currency_format( c, total );
571
572		c.find( '.btQuoteTotalCalc' ).html( total );
573		c.data( 'total', total );
574	}
575
576	// Init functions
577	
578	// Dropdown init
579
580	window.bt_cc_init_dropdown = function( elem, id, index ) {
581		elem.set( "selectedIndex", index );
582		var ui2 = $( id ).find( '._msddli_.selected' );
583		var val = elem.getData().data.value;
584		ui2.data( 'value', val );
585		bt_cc_eval_conditions( val, ui2.closest( '.btQuoteSelect' ).data( 'condition' ) );
586		bt_quote_total( ui2.closest( '.btQuoteBooking' ) );
587		bt_paypal_items( ui2.closest( '.btQuoteBooking' ) );
588	}
589	
590	// Base init
591	
592	window.bt_cc_init = function( ) {
593		
594		$( ".btQuoteBooking" ).each(function( index ) {
595			var c = $( this );
596
597			
598			
599			// Init elements 
600			
601			c.find( '.btContactDate' ).datepicker({
602				prevText: window.bt_cc_translate['prev'],
603				nextText: window.bt_cc_translate['next'],
604				dateFormat: c.data( 'date_format' ),
605				dayNamesMin: [ window.bt_cc_translate['su'], window.bt_cc_translate['mo'], window.bt_cc_translate['tu'], window.bt_cc_translate['we'], window.bt_cc_translate['th'], window.bt_cc_translate['fr'], window.bt_cc_translate['sa'] ],
606				monthNames: [ window.bt_cc_translate['january'], window.bt_cc_translate['february'], window.bt_cc_translate['march'], window.bt_cc_translate['april'], window.bt_cc_translate['may'], window.bt_cc_translate['june'], window.bt_cc_translate['july'], window.bt_cc_translate['august'], window.bt_cc_translate['september'], window.bt_cc_translate['october'], window.bt_cc_translate['november'], window.bt_cc_translate['december'] ],
607				beforeShow: function( input, inst ) {
608					$( '.ui-datepicker' ).addClass( 'btDatePicker' );
609				}
610			});
611			c.find( '.btQuoteSlider' ).each(function() {
612				$( this ).slider({
613					min: ! window.is_rtl ? $( this ).data( 'min' ) : -$( this ).data( 'max' ),
614					max: ! window.is_rtl ? $( this ).data( 'max' ) : -$( this ).data( 'min' ),
615					step: $( this ).data( 'step' ),
616					value: ! window.is_rtl ? $( this ).data( 'value' ) : -$( this ).data( 'value' ),
617					change: function( event, ui ) { 
618						$( this ).find('.btQuoteSliderValue').html( window.rtl_direction * $( this ).slider( 'value' ) );
619						bt_cc_eval_conditions( window.rtl_direction * $( this ).slider( 'value' ), $( this ).data( 'condition' ) );
620					}
621				});
622				bt_cc_eval_conditions( window.rtl_direction * $( this ).data( 'value' ), $( this ).data( 'condition' ) );
623			});
624			
625			c.find( '.ui-slider-handle' ).each(function() {
626				$( this ).append( $( this ).closest( '.btQuoteItemInput' ).find( $( '.btQuoteSliderValue' ) ) );
627			});
628			
629
630			c.find( '.btQuoteSlider' ).each(function() {
631				var this_slider = $( this );
632				$( this ).slider({
633					slide: function( event, ui ) {
634						var val = window.rtl_direction * ui.value; 
635						this_slider.slider( 'value', val );
636						this_slider.find('.btQuoteSliderValue').html( val );
637						bt_quote_total( c );
638						bt_paypal_items( c );
639					}
640				});
641			});			
642
643			
644			c.find( '.btQuoteSwitch' ).on( 'click', function() {
645				if ( $( this ).hasClass( 'on' ) ) { 
646					$( this ).removeClass( 'on' );
647					bt_cc_eval_conditions( $( this ).data( 'off' ), $( this ).data( 'condition' ) );
648				} else {
649					$( this ).addClass( 'on' );
650					bt_cc_eval_conditions( $( this ).data( 'on' ), $( this ).data( 'condition' ) );
651				}
652				bt_quote_total( c );
653				bt_paypal_items( c );
654			});
655			
656			c.find( '.btQuoteSwitch' ).each( function() {
657				if ( $( this ).hasClass( 'on' ) ) { 
658					bt_cc_eval_conditions( $( this ).data( 'on' ), $( this ).data( 'condition' ) );
659				} else {
660					bt_cc_eval_conditions( $( this ).data( 'off' ), $( this ).data( 'condition' ) );
661				}
662			});
663			
664			c.find( '.btPayPalButton' ).on( 'click', function() {
665				$( this ).next().submit();
666			});
667			
668			c.find( '.btQuoteText' ).each(function() {
669				bt_cc_eval_conditions( $( this ).val(), $( this ).data( 'condition' ) );
670			});
671			
672			c.find( '.btQuoteText' ).keyup(function() {
673				bt_quote_total( c );
674				bt_paypal_items( c );
675				bt_cc_eval_conditions( $( this ).val(), $( this ).data( 'condition' ) );
676			});
677			
678			c.find( '.btContactNext' ).click(function() {
679				$( 'html, body' ).delay( 1000 ).animate({
680					scrollTop: ( $( this ).closest( '.btQuoteBooking' ).find( '.btTotalQuoteContactGroup' ).offset().top - 30 )
681				}, 400 );
682				
683				var contact_group = $( this ).closest( '.btQuoteBooking' ).find( '.btTotalQuoteContactGroup' );
684				
685				$( this ).closest( '.btQuoteBooking' ).find( '.btTotalQuoteContactGroup' ).addClass( 'btActive' );
686				$( this ).closest( '.btQuoteBooking' ).find( '.btQuoteBookingForm' ).removeClass( 'btActive' );
687			});
688
689			c.find( '.btContactSubmit' ).click(function() {
690
691				c.find( '.btContactFieldError' ).removeClass( 'btContactFieldError' );
692		
693				var val = true;
694				
695				c.find( '.btContactField' ).each(function() {
696					if ( $( this ).parent().hasClass( 'btContactFieldMandatory' ) 
697					&& ( ( $( this ).val() == '' && ! $( this ).hasClass( 'btContactTime' ) ) 
698					|| ( $( this ).hasClass( 'btContactTime' ) && $( this ).hasClass( 'btNotSelected' ) ) ) ) {
699						$( this ).parent().addClass( 'btContactFieldError' );
700						val = false;
701					}
702				});
703				
704				if ( ! val ) {
705					c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_mandatory' ) ).fadeIn();
706					return false;
707				}
708
709				var quote = '';
710				var back = 0;
711				var bt_is_odd = function( n ) {
712					return ( n % 2 ) == 1;
713				}
714
715				c.find( '.btQuoteItem' ).each(function() {
716					
717					back++;
718					var item_val = 0;
719					var selected_name = '';
720					
721					$( this ).find( '.btQuoteText' ).each(function() {
722						item_val = bt_parse_float( $( this ).val() );
723					});
724					
725					$( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {
726						selected_name = $( this ).find( '.ddlabel' )[0].innerHTML;
727						if ( $( this ).is( ':first-child' ) ) {
728							selected_name = '';
729						}
730						item_val = bt_parse_float( $( this ).data( 'value' ) );
731					});
732					
733					var is_slider = false;
734					var slider_val;
735					$( this ).find( '.btQuoteSlider' ).each(function() {
736						var unit_price = bt_parse_float( $( this ).data( 'price' ) );
737						// slider_val = bt_parse_float( $( this ).slider( 'value' ) );
738						slider_val = bt_cc_get_slider_value ( $( this ) );
739						item_val = slider_val * unit_price;
740						is_slider = true;
741					});
742
743					$( this ).find( '.btQuoteSwitch' ).each(function() {
744						if ( $( this ).hasClass( 'on' ) ) {
745							item_val = bt_parse_float( $( this ).data( 'on' ) );
746						} else {
747							item_val = bt_parse_float( $( this ).data( 'off' ) );
748						}
749					});
750					
751					var label = $( this ).find( 'label' ).html();
752					
753					if ( is_slider ) {
754						label = label + ': ' + slider_val;
755					}						
756					
757					if ( selected_name != '' ) {
758						selected_name = selected_name.replace( '<span class="description">', '/' );
759						selected_name = selected_name.replace( '</span>', '' );
760						label = label + ': ' + selected_name;
761					}
762					
763					var background = '';
764					if ( bt_is_odd( back ) ) background = ' ' + 'style="background:#eee;"';
765					
766					item_val = bt_cc_currency_format( c, item_val );
767					
768					if ( label !== undefined && label !== null ) {
769						quote += encodeURI( '<tr' + background + '>\r\n<td style="padding:.5em;">' + label + '</td>\r\n<td style="text-align:right;padding:.5em;">' + item_val + '</td>\r\n</tr>' ) + "\r\n";
770					}
771					
772				});
773				
774				var recaptcha_response = '';
775				if ( typeof grecaptcha !== 'undefined' ) {
776					var recaptcha_response = grecaptcha.getResponse( c.find( '.g-rec' ).data( 'widget_id' ) );
777					grecaptcha.reset( c.find( '.g-rec' ).data( 'widget_id' ) );
778				}
779				
780				var email_confirmation = 'no';
781				if ( c.find( '.bt_cc_email_confirmation' ).length ) {
782					if ( c.find( '.bt_cc_email_confirmation' ).prop( 'checked' ) ) {
783						email_confirmation = 'yes';
784					}
785				} else {
786					email_confirmation = 'yes';
787				}
788
789				var email_gdpr = 'no';
790				if ( c.find( '.bt_cc_email_gdpr' ).length ) {
791					if ( c.find( '.bt_cc_email_gdpr' ).prop( 'checked' ) ) {
792						email_gdpr = 'yes';
793					}
794				} else {
795					email_gdpr = 'yes';
796				}
797
798				if ( email_gdpr == 'no' ) {
799					c.find( '.btSubmitMessage' ).html(c.data( 'email_gdpr_not_text' ) );
800					return false;
801				}
802				
803
804				var data = {
805					'action': 'bt_cc',
806					'recaptcha_response': recaptcha_response,
807					'recaptcha_secret': c.data( 'rec_secret_key' ),
808					'admin_email': c.data( 'admin_email' ),
809					'email_client': c.data( 'email_client' ),
810					'currency': c.data( 'currency' ),
811					'currency_after': c.data( 'currency_after' ),
812					'currency_space': c.data( 'currency_space' ),
813					'email_confirmation': email_confirmation,
814					'url_confirmation': c.data( 'url_confirmation' ),
815					'subject': c.data( 'subject' ),
816					'email_header': c.data( 'email_header' ),
817					'email_footer': c.data( 'email_footer' ),
818					'quote' : quote,
819					'total' : c.data( 'total' ),
820					'total_text' : c.data( 'total_text' ),
821					'name' : c.find( '.btContactName' ).val(),
822					'email' : c.find( '.btContactEmail' ).val(),
823					'phone' : c.find( '.btContactPhone' ).val(),
824					'address' : c.find( '.btContactAddress' ).val(),
825					'date' : c.find( '.btContactDate' ).val(),
826					'time' : c.find( '.btContactTime option:selected' ).val(),
827					'date_text': c.data( 'date_text' ),
828					'time_text': c.data( 'time_text' ),
829					'message' : c.find( '.btContactMessage' ).val(),
830					'bt_cc_nonce': c.data( 'bt_cc_nonce' ),
831					'email_gdpr': c.data( 'email_gdpr' ),
832					'email_gdpr_text': c.data( 'email_gdpr_text' ),
833					'email_gdpr_not_text': c.data( 'email_gdpr_not_text' )
834				};
835				
836				c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_please_wait' ) ).fadeIn();
837
838				$.ajax({
839					type: 'POST',
840					url: c.data( 'url_ajax' ),
841					data: data,
842					async: true,
843					success: function( response ) {
844						response = $.trim( response );
845						if ( response == 'ok' ) {
846							if ( c.data( 'url_confirmation' ) == '' || c.data( 'url_confirmation' ) == null ) {
847								c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_success' ) ).fadeIn();
848							} else {
849								window.location = c.data( 'url_confirmation' );
850							}
851							
852						} else {
853							c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_error' ) ).fadeIn();
854						}
855					},
856					error: function( xhr, status, error ) {
857						c.find( '.btSubmitMessage' ).hide().html( c.data( 'message_error' ) ).fadeIn();
858					}
859				});
860				
861				return false;
862			
863			});
864			
865			// CF 7 support
866			
867			c.find( '.wpcf7-submit' ).click(function() {
868
869	
870				var val = true;
871				var quote = '';
872
873				c.find( '.btQuoteItem' ).each(function() {
874					var item_val = 0;
875					var selected_name = '';
876					
877					$( this ).find( '.btQuoteText' ).each(function() {
878						item_val = bt_parse_float( $( this ).val() );
879					});
880					
881					$( this ).find( '.btQuoteSelect' ).find( '._msddli_.selected' ).each(function() {
882						selected_name = $( this ).find( '.ddlabel' )[0].innerHTML;
883						if ( $( this ).is( ':first-child' ) ) {
884							selected_name = '';
885						}
886						item_val = bt_parse_float( $( this ).data( 'value' ) );
887					});
888					
889					var is_slider = false;
890					var slider_val;
891					$( this ).find( '.btQuoteSlider' ).each(function() {
892						var unit_price = bt_parse_float( $( this ).data( 'price' ) );
893						// slider_val = bt_parse_float( $( this ).slider( 'value' ) );
894						slider_val = bt_cc_get_slider_value ( $( this ) );
895						item_val = slider_val * unit_price;
896						is_slider = true;
897					});
898
899					$( this ).find( '.btQuoteSwitch' ).each(function() {
900						if ( $( this ).hasClass( 'on' ) ) {
901							item_val = bt_parse_float( $( this ).data( 'on' ) );
902						} else {
903							item_val = bt_parse_float( $( this ).data( 'off' ) );
904						}
905					});
906					
907					var label = $( this ).find( 'label' ).html();
908					
909					if ( is_slider ) {
910						label = label + ' (' + slider_val + ') ' ;
911					}						
912					
913					if ( selected_name != '' ) {
914						selected_name = selected_name.replace( '<span class="description">', '/' );
915						selected_name = selected_name.replace( '</span>', '' );
916						label = label + ' (' + selected_name + ') ';
917					}
918						
919					item_val = bt_cc_currency_format( c, item_val );
920					
921					if ( label !== undefined && label !== null ) {
922						quote += label + ': ' + item_val + "\r\n";
923					}
924					
925				});
926				
927				quote += c.data( 'total_text' ) + ': ' + c.data( 'total' ) + "\r\n";
928				
929				c.find( 'input[name=bt-cc-data]' ).val( quote );
930
931			});
932			
933				
934			
935			var total = 0;
936			total = total.toFixed( 2 );
937			bt_quote_total( c );
938			bt_paypal_items( c );
939		});	
940
941
942		
943	}
944	
945	// ---------------
946	// Functions end
947	// ---------------
948
949	// Init
950	
951	var bt_cc_init_finished = false;
952	
953	document.addEventListener( 'readystatechange', function() { 
954		if ( ! bt_cc_init_finished && ( document.readyState === 'interactive' || document.readyState === 'complete' ) ) {
955			
956			// base variables
957			window.is_rtl = $( 'body' ).hasClass( 'rtl' );
958			window.rtl_direction = !window.is_rtl ? 1 : -1;
959			
960			bt_cc_init();
961			bt_cc_init_finished = true;
962			
963		}
964	});
965	
966})( 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.