PageSourceSearch

https://shipprimus.com/v2/wp-content/plugins/bt_cost_calculator/cc.main.js?ver=6.0.16

js shipprimus.com collected 2026-09-26 00:11:26 UTC 28,296 bytes, 885 lines download raw bytes

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