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