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