PageSourceSearch

https://parisandco.fr/wp-content/plugins/bt_cost_calculator/cc.main.js?ver=3.0.4

js parisandco.fr collected 2026-10-04 13:26:14 UTC 33,868 bytes, 1,064 lines download raw bytes

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

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.