1(function($) { 2 "use strict"; 3 4 var lfb_lastStepID = 0; 5 var lfb_lastSteps = new Array(); 6 var lfb_plannedSteps; 7 var lfb_gmapMatrixService = false; 8 var lfb_tld_selectionMode = false; 9 var lfb_calendars = new Array(); 10 var lfb_stripe; 11 var lfb_mapStyles = new Array(); 12 13 lfb_initMapStyles(); 14 15 $(document).ready(function() { 16 17 initComboBox(); 18 lfb_initDocReady(); 19 20 $('body').on('lfb_initDocReady', function(e) { 21 lfb_initDocReady(); 22 }); 23 $('body').on('lfb_initWinReady', function(e) { 24 lfb_initWinReady(); 25 }); 26 $('body').on('lfb_resize', function(e) { 27 lfb_onResize(); 28 }); 29 if ($('#lfb_signature').length > 0) { 30 document.addEventListener("touchstart", touchHandler, true); 31 document.addEventListener("touchmove", touchHandler, true); 32 document.addEventListener("touchend", touchHandler, true); 33 document.addEventListener("touchcancel", touchHandler, true); 34 } 35 }); 36 $(window).on('load', function() { 37 lfb_initWinReady(); 38 }); 39 40 function touchHandler(event) { 41 var touch = event.changedTouches[0]; 42 43 var simulatedEvent = document.createEvent("MouseEvent"); 44 simulatedEvent.initMouseEvent({ 45 touchstart: "mousedown", 46 touchmove: "mousemove", 47 touchend: "mouseup" 48 }[event.type], true, true, window, 1, 49 touch.screenX, touch.screenY, 50 touch.clientX, touch.clientY, false, 51 false, false, false, 0, null); 52 53 touch.target.dispatchEvent(simulatedEvent); 54 } 55 56 function initComboBox() { 57 $.widget("custom.combobox", { 58 _create: function() { 59 this.wrapper = $("<span>") 60 .addClass("custom-combobox lfb_comboboxContainer") 61 .insertAfter(this.element); 62 63 this.element.hide(); 64 this._createAutocomplete(); 65 this._createShowAllButton(); 66 }, 67 68 _createAutocomplete: function() { 69 var selected = this.element.children(":selected"), 70 value = selected.val() ? selected.text() : ""; 71 72 this.input = $("<input>") 73 .appendTo(this.wrapper) 74 .val(value) 75 .attr("title", "") 76 .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left form-control") 77 .autocomplete({ 78 classes: { 79 "ui-autocomplete": "lfb_dropdownAutocompleteMenu" 80 }, 81 delay: 0, 82 minLength: 0, 83 appendTo: $('#lfb_form'), 84 source: this._source.bind(this), 85 change: function(event, ui) { 86 $(this).closest('.lfb_itemBloc').find('select').trigger('change'); 87 }, 88 select: function(event, ui) { 89 $(this).closest('.lfb_itemBloc').find('select').trigger('change'); 90 }, 91 open: function(event, ui) { 92 $('.lfb_dropdownAutocompleteMenu').css({ 93 width: $(this).outerWidth(), 94 }); 95 $(this).closest('.lfb_itemBloc').find('.fa-solid').addClass('fa-caret-up'); 96 $(this).closest('.lfb_itemBloc').find('.fa-solid').removeClass('fa-caret-down'); 97 }, 98 close: function(event, ui) { 99 $(this).closest('.lfb_itemBloc').find('.fa-solid').removeClass('fa-caret-up'); 100 $(this).closest('.lfb_itemBloc').find('.fa-solid').addClass('fa-caret-down'); 101 } 102 }); 103 104 this._on(this.input, { 105 autocompleteselect: function(event, ui) { 106 ui.item.option.selected = true; 107 this._trigger("select", event, { 108 item: ui.item.option 109 }); 110 }, 111 112 autocompletechange: "_removeIfInvalid" 113 }); 114 }, 115 116 _createShowAllButton: function() { 117 var input = this.input, 118 wasOpen = false;
119 $("<a>") 120 .attr("tabIndex", -1) 121 .attr("title", "Show All Items") 122 .appendTo(this.wrapper) 123 .append('<i class="fa-solid fa-caret-down"></i>') 124 .removeClass("ui-corner-all") 125 .addClass("custom-combobox-toggle ui-corner-right lfb_dropdownAutocompleteBtn") 126 .on("mousedown", function() { 127 wasOpen = input.autocomplete("widget").is(":visible"); 128 }) 129 .on("click", function() { 130 input.trigger("focus"); 131 if (wasOpen) { 132 return; 133 } 134 input.autocomplete("search", ""); 135 }); 136 }, 137 138 _source: function(request, response) { 139 var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); 140 response(this.element.children("option").map(function() { 141 var text = $(this).text(); 142 if (this.value && (!request.term || matcher.test(text))) 143 return { 144 label: text, 145 value: text, 146 option: this 147 }; 148 })); 149 }, 150 151 _removeIfInvalid: function(event, ui) { 152 if (ui.item) { 153 return; 154 } 155 var value = this.input.val(), 156 valueLowerCase = value.toLowerCase(), 157 valid = false; 158 this.element.children("option").each(function() { 159 if ($(this).text().toLowerCase() === valueLowerCase) { 160 this.selected = valid = true; 161 return false; 162 } 163 }); 164 if (valid) { 165 return; 166 } 167 this.input 168 .val("") 169 .attr("title", value + " didn't match any item"); 170 this.element.val(""); 171 this.input.autocomplete("instance").term = ""; 172 }, 173 174 _destroy: function() { 175 this.wrapper.remove(); 176 this.element.show(); 177 } 178 }); 179 180 $("#lfb_form .lfb_combobox").combobox(); 181 } 182 183 function lfb_initDocReady() { 184 185 $('.lfb_dynamicHide').hide().removeClass('lfb_dynamicHide'); 186 if ($('#lfb_form').length > 0) { 187 if (document.location.href.indexOf('lfb_action=preview') > -1) { 188 $('#lfb_form:not(.lfb_fullscreen)').remove(); 189 } 190 initFlatUI(); 191 window.Dropzone.autoDiscover = false; 192 lfb_initForms(); 193 jQuery.each(lfb_forms, function() { 194 var form = this; 195 lfb_checkItems(form.formID); 196 lfb_initListeners(form.formID); 197 }); 198 } 199 } 200 201 function lfb_initWinReady() { 202 if ($('#lfb_form').length > 0) { 203 lfb_onResize(); 204 $(window).resize(lfb_onResize); 205 206 $(window).on("popstate", function(e) { 207 if (e.originalEvent.state !== null) { 208 e.preventDefault(); 209 lfb_previousStep(lfb_forms[0].formID); 210 } 211 }); 212 213 } 214 $(document).on('scroll', function() { 215 $('#lfb_form .lfb_datepicker').trigger('blur'); 216 }); 217 $('body,html,#lfb_form').on('scroll', function() { 218 $('#lfb_form .lfb_datepicker').trigger('blur'); 219 }); 220 $('#ajax-loading-screen').fadeOut(); 221 $('#ajax-content-wrap >.container-wrap').css({ 222 opacity: 1, 223 display: 'block' 224 }); 225 $('#lfb_form').on('lfb_getForm', function(e, formID) { 226 return lfb_getForm(formID); 227 }); 228 $('#lfb_form').on('lfb_updatePrice', function(e, formID) { 229 lfb_updatePrice(formID); 230 }); 231 $('#lfb_form').on('lfb_order', function(e, formID) { 232 lfb_order(formID); 233 }); 234 $('#lfb_form').on('lfb_nextStep', function(e, formID) { 235 lfb_nextStep(formID); 236 }); 237 $('#lfb_form').on('lfb_checkStepItemsValid', function(e, stepID, formID) { 238 return lfb_checkStepItemsValid(stepID, formID); 239 }); 240 241 $('#lfb_form').on('lfb_changeStep', function(e, stepID, formID) { 242 lfb_changeStep(stepID, formID); 243 }); 244 $('#lfb_form').on('lfb_getUrlVariablesByFormID', function(e, formID) { 245 return lfb_getUrlVariablesByFormID(formID); 246 }); 247 $('#lfb_form').on('lfb_itemClick', function(e, $item, action, formID) { 248 lfb_itemClick($($item), action, formID); 249 }); 250 $('#lfb_form').on('lfb_getVariableByID', function(e, formID, variableID) { 251 const form = lfb_getForm(formID); 252 return lfb_getVariableByID(form, variableID); 253 }); 254 $('#lfb_form').on('lfb_setVariableByID', function(e, formID, variableID, value) { 255 const form = lfb_getForm(formID); 256 var variable = lfb_getVariableByID(form, variableID); 257 if (variable) { 258 variable.value = value; 259 } 260 }); 261 262 263 $('#lfb_form canvas.img').each(function() { 264 265 $(this).parent().children('img').css('opacity', 0); 266 $(this).parent().children('img').show(); 267 $(this).css({ 268 width: $(this).parent().children('img').get(0).width, 269 height: $(this).parent().children('img').get(0).height 270 }); 271 $(this).parent().children('img').hide(); 272 273 }); 274 jQuery.each(lfb_forms, function() { 275 var form = this; 276 if (form.useCaptcha == 1 && form.recaptcha3Key != '') { 277 if ($('.grecaptcha-badge').length > 0 && $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide .grecaptcha-badge').length == 0) { 278 var captchaImg = $('.grecaptcha-badge').clone(); 279 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide .lfb_genContentSlide').append(captchaImg); 280 } 281 } 282 283 }); 284 285 } 286 287 function lfb_initMapStyles() { 288 lfb_mapStyles.push({ name: 'default', styles: [] }); 289 lfb_mapStyles.push({ 290 name: 'aubergine', 291 styles: [{ 292 "elementType": "geometry", 293 "stylers": [{ 294 "color": "#1d2c4d" 295 }] 296 }, 297 { 298 "elementType": "labels.text.fill", 299 "stylers": [{ 300 "color": "#8ec3b9" 301 }] 302 }, 303 { 304 "elementType": "labels.text.stroke", 305 "stylers": [{ 306 "color": "#1a3646" 307 }] 308 }, 309 { 310 "featureType": "administrative.country", 311 "elementType": "geometry.stroke", 312 "stylers": [{ 313 "color": "#4b6878" 314 }] 315 }, 316 { 317 "featureType": "administrative.land_parcel", 318 "elementType": "labels.text.fill", 319 "stylers": [{ 320 "color": "#64779e" 321 }] 322 }, 323 { 324 "featureType": "administrative.province", 325 "elementType": "geometry.stroke", 326 "stylers": [{ 327 "color": "#4b6878" 328 }] 329 }, 330 { 331 "featureType": "landscape.man_made", 332 "elementType": "geometry.stroke", 333 "stylers": [{ 334 "color": "#334e87" 335 }] 336 }, 337 { 338 "featureType": "landscape.natural", 339 "elementType": "geometry", 340 "stylers": [{ 341 "color": "#023e58" 342 }] 343 }, 344 { 345 "featureType": "poi", 346 "elementType": "geometry", 347 "stylers": [{ 348 "color": "#283d6a"
349 }] 350 }, 351 { 352 "featureType": "poi", 353 "elementType": "labels.text.fill", 354 "stylers": [{ 355 "color": "#6f9ba5" 356 }] 357 }, 358 { 359 "featureType": "poi", 360 "elementType": "labels.text.stroke", 361 "stylers": [{ 362 "color": "#1d2c4d" 363 }] 364 }, 365 { 366 "featureType": "poi.park", 367 "elementType": "geometry.fill", 368 "stylers": [{ 369 "color": "#023e58" 370 }] 371 }, 372 { 373 "featureType": "poi.park", 374 "elementType": "labels.text.fill", 375 "stylers": [{ 376 "color": "#3C7680" 377 }] 378 }, 379 { 380 "featureType": "road", 381 "elementType": "geometry", 382 "stylers": [{ 383 "color": "#304a7d" 384 }] 385 }, 386 { 387 "featureType": "road", 388 "elementType": "labels.text.fill", 389 "stylers": [{ 390 "color": "#98a5be" 391 }] 392 }, 393 { 394 "featureType": "road", 395 "elementType": "labels.text.stroke", 396 "stylers": [{ 397 "color": "#1d2c4d" 398 }] 399 }, 400 { 401 "featureType": "road.highway", 402 "elementType": "geometry", 403 "stylers": [{ 404 "color": "#2c6675" 405 }] 406 }, 407 { 408 "featureType": "road.highway", 409 "elementType": "geometry.stroke", 410 "stylers": [{ 411 "color": "#255763" 412 }] 413 }, 414 { 415 "featureType": "road.highway", 416 "elementType": "labels.text.fill", 417 "stylers": [{ 418 "color": "#b0d5ce" 419 }] 420 }, 421 { 422 "featureType": "road.highway", 423 "elementType": "labels.text.stroke", 424 "stylers": [{ 425 "color": "#023e58" 426 }] 427 }, 428 { 429 "featureType": "transit", 430 "elementType": "labels.text.fill", 431 "stylers": [{ 432 "color": "#98a5be" 433 }] 434 }, 435 { 436 "featureType": "transit", 437 "elementType": "labels.text.stroke", 438 "stylers": [{ 439 "color": "#1d2c4d" 440 }] 441 }, 442 { 443 "featureType": "transit.line", 444 "elementType": "geometry.fill", 445 "stylers": [{ 446 "color": "#283d6a" 447 }] 448 }, 449 { 450 "featureType": "transit.station", 451 "elementType": "geometry", 452 "stylers": [{ 453 "color": "#3a4762" 454 }] 455 }, 456 { 457 "featureType": "water", 458 "elementType": "geometry", 459 "stylers": [{ 460 "color": "#0e1626" 461 }] 462 }, 463 { 464 "featureType": "water", 465 "elementType": "labels.text.fill", 466 "stylers": [{ 467 "color": "#4e6d70" 468 }] 469 } 470 ] 471 }); 472 lfb_mapStyles.push({ 473 name: 'retro', 474 styles: [{ 475 "elementType": "geometry", 476 "stylers": [{ 477 "color": "#ebe3cd" 478 }] 479 }, 480 { 481 "elementType": "labels.text.fill", 482 "stylers": [{ 483 "color": "#523735" 484 }] 485 }, 486 { 487 "elementType": "labels.text.stroke", 488 "stylers": [{ 489 "color": "#f5f1e6" 490 }] 491 }, 492 { 493 "featureType": "administrative", 494 "elementType": "geometry.stroke", 495 "stylers": [{ 496 "color": "#c9b2a6" 497 }] 498 }, 499 { 500 "featureType": "administrative.land_parcel", 501 "elementType": "geometry.stroke", 502 "stylers": [{ 503 "color": "#dcd2be" 504 }] 505 }, 506 { 507 "featureType": "administrative.land_parcel", 508 "elementType": "labels.text.fill", 509 "stylers": [{ 510 "color": "#ae9e90" 511 }] 512 }, 513 { 514 "featureType": "landscape.natural", 515 "elementType": "geometry", 516 "stylers": [{ 517 "color": "#dfd2ae" 518 }] 519 }, 520 { 521 "featureType": "poi", 522 "elementType": "geometry", 523 "stylers": [{ 524 "color": "#dfd2ae" 525 }] 526 }, 527 { 528 "featureType": "poi", 529 "elementType": "labels.text.fill", 530 "stylers": [{ 531 "color": "#93817c" 532 }] 533 }, 534 { 535 "featureType": "poi.park", 536 "elementType": "geometry.fill", 537 "stylers": [{ 538 "color": "#a5b076" 539 }] 540 }, 541 { 542 "featureType": "poi.park", 543 "elementType": "labels.text.fill", 544 "stylers": [{ 545 "color": "#447530" 546 }] 547 }, 548 { 549 "featureType": "road", 550 "elementType": "geometry", 551 "stylers": [{ 552 "color": "#f5f1e6" 553 }] 554 }, 555 { 556 "featureType": "road.arterial", 557 "elementType": "geometry", 558 "stylers": [{ 559 "color": "#fdfcf8" 560 }] 561 }, 562 { 563 "featureType": "road.highway", 564 "elementType": "geometry", 565 "stylers": [{ 566 "color": "#f8c967" 567 }] 568 }, 569 { 570 "featureType": "road.highway", 571 "elementType": "geometry.stroke", 572 "stylers": [{ 573 "color": "#e9bc62" 574 }] 575 }, 576 { 577 "featureType": "road.highway.controlled_access", 578 "elementType": "geometry", 579 "stylers": [{ 580 "color": "#e98d58" 581 }] 582 }, 583 { 584 "featureType": "road.highway.controlled_access", 585 "elementType": "geometry.stroke", 586 "stylers": [{ 587 "color": "#db8555" 588 }] 589 }, 590 { 591 "featureType": "road.local", 592 "elementType": "labels.text.fill", 593 "stylers": [{ 594 "color": "#806b63" 595 }] 596 }, 597 { 598 "featureType": "transit.line", 599 "elementType": "geometry", 600 "stylers": [{ 601 "color": "#dfd2ae" 602 }] 603 }, 604 { 605 "featureType": "transit.line", 606 "elementType": "labels.text.fill", 607 "stylers": [{ 608 "color": "#8f7d77" 609 }] 610 }, 611 { 612 "featureType": "transit.line", 613 "elementType": "labels.text.stroke", 614 "stylers": [{ 615 "color": "#ebe3cd" 616 }] 617 }, 618 { 619 "featureType": "transit.station", 620 "elementType": "geometry", 621 "stylers": [{ 622 "color": "#dfd2ae" 623 }] 624 }, 625 { 626 "featureType": "water", 627 "elementType": "geometry.fill", 628 "stylers": [{ 629 "color": "#b9d3c2" 630 }] 631 }, 632 { 633 "featureType": "water", 634 "elementType": "labels.text.fill", 635 "stylers": [{ 636 "color": "#92998d" 637 }] 638 } 639 ] 640 }); 641 lfb_mapStyles.push({ 642 name: 'night', 643 styles: [ 644 { elementType: "geometry", stylers: [{ color: "#242f3e" }] }, 645 { elementType: "labels.text.stroke", stylers: [{ color: "#242f3e" }] }, 646 { elementType: "labels.text.fill", stylers: [{ color: "#746855" }] }, 647 { 648 featureType: "administrative.locality", 649 elementType: "labels.text.fill", 650 stylers: [{ color: "#d59563" }], 651 }, 652 { 653 featureType: "poi", 654 elementType: "labels.text.fill", 655 stylers: [{ color: "#d59563" }], 656 }, 657 { 658 featureType: "poi.park", 659 elementType: "geometry", 660 stylers: [{ color: "#263c3f" }], 661 }, 662 { 663 featureType: "poi.park", 664 elementType: "labels.text.fill", 665 stylers: [{ color: "#6b9a76" }], 666 }, 667 { 668 featureType: "road", 669 elementType: "geometry", 670 stylers: [{ color: "#38414e" }], 671 }, 672 { 673 featureType: "road", 674 elementType: "geometry.stroke", 675 stylers: [{ color: "#212a37" }], 676 }, 677 { 678 featureType: "road", 679 elementType: "labels.text.fill", 680 stylers: [{ color: "#9ca5b3" }], 681 }, 682 { 683 featureType: "road.highway", 684 elementType: "geometry", 685 stylers: [{ color: "#746855" }], 686 }, 687 { 688 featureType: "road.highway", 689 elementType: "geometry.stroke", 690 stylers: [{ color: "#1f2835" }], 691 }, 692 { 693 featureType: "road.highway", 694 elementType: "labels.text.fill", 695 stylers: [{ color: "#f3d19c" }], 696 }, 697 { 698 featureType: "transit", 699 elementType: "geometry", 700 stylers: [{ color: "#2f3948" }], 701 }, 702 { 703 featureType: "transit.station", 704 elementType: "labels.text.fill", 705 stylers: [{ color: "#d59563" }], 706 }, 707 { 708 featureType: "water", 709 elementType: "geometry", 710 stylers: [{ color: "#17263c" }], 711 }, 712 { 713 featureType: "water", 714 elementType: "labels.text.fill", 715 stylers: [{ color: "#515c6d" }], 716 }, 717 { 718 featureType: "water", 719 elementType: "labels.text.stroke", 720 stylers: [{ color: "#17263c" }], 721 }, 722 ] 723 }); 724 } 725 726 function lfb_clearFixedElements() { 727 $('*:not(#lfb_bootstraped)').each(function() { 728 if ($(this).closest('#lfb_bootstraped').length == 0 && $(this).css('position') != 'static') { 729 $(this).css('position', 'static'); 730 } 731 if ($(this).closest('#lfb_bootstraped').length == 0) { 732 $(this).css('will-change', 'unset'); 733 } 734 }); 735 } 736 737 function lfb_getForm(formID) { 738 var rep = false;
739 for (var i = 0; i < lfb_forms.length; i++) { 740 if (lfb_forms[i].formID == formID) { 741 rep = lfb_forms[i]; 742 break; 743 } 744 } 745 return rep; 746 } 747 748 function lfb_onResize() { 749 $('#lfb_form.lfb_fullscreen:not(.lfb_visualEditing)').css({ 750 minHeight: $(window).height() 751 }); 752 753 if ($(window).width() <= 768) { 754 var stepDesHeight = 0; 755 756 $('#lfb_form .lfb_stepDescription').each(function() { 757 $(this).css({ 758 top: $(this).closest('.lfb_genSlide').find('.lfb_stepTitle').height() + 48 759 }); 760 }); 761 $('#lfb_form .lfb_genContent ').each(function() { 762 var stepDesHeight = 0; 763 if ($(this).closest('.lfb_genSlide').find('.lfb_stepDescription').length > 0) { 764 stepDesHeight = lfb_zeroIfNan($(this).closest('.lfb_genSlide').find('.lfb_stepDescription').height()); 765 } 766 $(this).css({ 767 paddingTop: $(this).closest('.lfb_genSlide').find('.lfb_stepTitle').height() + stepDesHeight + 90 768 }); 769 }); 770 } else { 771 $('#lfb_form .lfb_stepDescription').each(function() { 772 $(this).css({ 773 top: $(this).closest('.lfb_genSlide').find('.lfb_stepTitle').height() + 28 774 }); 775 }); 776 $('#lfb_form .lfb_genContent ').each(function() { 777 var stepDesHeight = 0; 778 if ($(this).closest('.lfb_genSlide').find('.lfb_stepDescription').length > 0) { 779 stepDesHeight = lfb_zeroIfNan($(this).closest('.lfb_genSlide').find('.lfb_stepDescription').height()); 780 } 781 $(this).css({ 782 paddingTop: $(this).closest('.lfb_genSlide').find('.lfb_stepTitle').height() + stepDesHeight + 70 783 }); 784 }); 785 } 786 } 787 788 function lfb_updatePlannedSteps(formID) { 789 var startStepID = parseInt($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-start="1"]').attr('data-stepid')); 790 lfb_plannedSteps = new Array(); 791 lfb_plannedSteps.push(startStepID); 792 lfb_plannedSteps = lfb_scanPlannedSteps(startStepID, formID); 793 } 794 795 function lfb_scanPlannedSteps(stepID, formID) { 796 var plannedSteps = new Array(); 797 var potentialSteps = lfb_findPotentialsSteps(stepID, formID); 798 if (potentialSteps.length > 0 && potentialSteps[0] != 'final') { 799 lfb_plannedSteps.push(potentialSteps[0]); 800 lfb_scanPlannedSteps(potentialSteps[0], formID); 801 } else { 802 return lfb_plannedSteps; 803 } 804 return lfb_plannedSteps; 805 } 806 807 function lfb_getStepQuantities(formID, stepID, itemID) { 808 var form = lfb_getForm(formID); 809 var quantities = 0; 810 if (jQuery.inArray(parseInt(stepID), lfb_lastSteps) > -1 || stepID == form.step) { 811 812 var formContent = lfb_getFormContent(formID, true, stepID); 813 var items = formContent[2]; 814 jQuery.each(items, function() { 815 if (this.itemid != itemID && this.type != 'row' && this.type != 'column') { 816 var item = this; 817 if (isNaN(item.quantity)) { 818 quantities++; 819 } else { 820 quantities += parseInt(item.quantity); 821 } 822 } 823 }); 824 } 825 return quantities; 826 } 827 828 function lfb_getTotalQuantities(formID, stepID, itemID) { 829 var form = lfb_getForm(formID); 830 var formContent = lfb_getFormContent(formID, true); 831 var items = formContent[2]; 832 var quantities = 0; 833 834 var mustChkPosition = true; 835 if (isNaN(stepID) || stepID == 0) { 836 mustChkPosition = false; 837 } 838 var chkStep = false; 839 840 jQuery.each(items, function() { 841 if (this.itemid != itemID) { 842 var item = this; 843 if (mustChkPosition && !chkStep && item.stepid == stepID) { 844 chkStep = true; 845 } 846 if (!chkStep || item.stepid == stepID) { 847 if (isNaN(item.quantity)) { 848 quantities++; 849 } else { 850 quantities += parseInt(item.quantity); 851 } 852 } 853 } 854 }); 855 return quantities; 856 } 857 858 function lfb_itemClick($item, action, formID) { 859 var form = lfb_getForm(formID); 860 var chkGrpReq = false;
861 var $this = $item; 862 var isChecked = false; 863 864 865 if (action) { 866 $('#lfb_form[data-form="' + form.formID + '"] .quantityBtns').removeClass('open'); 867 $('#lfb_form[data-form="' + form.formID + '"] .quantityBtns').fadeOut(250); 868 var deviceAgent = navigator.userAgent.toLowerCase(); 869 var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i); 870 if (agentID) { 871 $('body :not(.ui-slider-handle) > .tooltip').remove(); 872 $('body > .tooltip').remove(); 873 $('#lfb_form[data-form="' + form.formID + '"] > .tooltip').remove(); 874 } 875 876 } 877 if (action) { 878 $this.addClass('action'); 879 } 880 if ((action) || (!$this.is('.action'))) { 881 if (form.imgIconStyle != 'zoom') { 882 883 $this.find('span.icon_select').animate({ 884 bottom: 160, 885 opacity: 0 886 }, 200); 887 } 888 if ($this.is('.checked')) { 889 if ((action) && ($this.data('required'))) {} else { 890 if (form.imgIconStyle == 'zoom') { 891 $this.delay(200).css('transition-delay', '0.2s'); 892 $this.find('span.icon_select').css('transition-delay', '0s'); 893 } else { 894 $this.css('transition-delay', '0s'); 895 } 896 var unChkDelay = 220; 897 if (form.imgIconStyle == 'zoom') { 898 unChkDelay = 0; 899 } 900 $this.delay(unChkDelay).removeClass('checked'); 901 if (form.imgIconStyle != 'zoom') { 902 $this.delay(220).find('span.icon_select').removeClass('fa-check').addClass('fa-times'); 903 } else { 904 $this.find('span.icon_select').css('transition-delay', '0s'); 905 } 906 $this.delay(400).css('transition-delay', '0s'); 907 $this.find('.icon_quantity').delay(300).fadeOut(200); 908 909 } 910 } else { 911 $this.css('transition-delay', '0s'); 912 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 913 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 914 $item.tooltip('show'); 915 } 916 } 917 isChecked = true; 918 if (form.imgIconStyle == 'zoom') { 919 $this.find('span.icon_select').css('transition-delay', '.5s'); 920 } 921 if (!$this.is('[type="checkbox"][data-checkboxstyle="checkbox"]')) { 922 $this.delay(220).addClass('checked'); 923 } 924 if (form.imgIconStyle != 'zoom') { 925 $this.delay(220).find('span.icon_select').removeClass('fa-times').addClass('fa-check'); 926 } 927 if ($this.find('.quantityBtns').length > 0 && !$this.is('[data-distanceqt]')) { 928 $this.find('.icon_quantity').delay(300).fadeIn(200); 929 $this.find('.quantityBtns').delay(500).addClass('open'); 930 $this.find('.quantityBtns').delay(500).fadeIn('200'); 931 932 if ($item.find('.lfb_sliderQt').length > 0) { 933 setTimeout(function() { 934 lfb_updatePrice(form.formID, $item.attr('data-itemid')); 935 }, 50); 936 } 937 } 938 if ($this.data('urltarget') && $this.data('urltarget') != "") { 939 var method = $this.data('urltargetmode'); 940 if (method != '_self' && method != '_blank') { 941 method = '_blank'; 942 } 943 var win = window.open($this.data('urltarget'), method); 944 if (typeof(win) !== 'null' && win != null) { 945 win.focus(); 946 } 947 } 948 } 949 if (form.imgIconStyle != 'zoom') { 950 $this.find('span.icon_select').delay(300).animate({ 951 bottom: 0, 952 opacity: 1 953 }, 200); 954 }; 955 if ((action) && ($this.data('group'))) { 956 $this.closest('.lfb_genSlide').find('div.lfb_selectable.checked[data-group="' + $this.data('group') + '"]:not([data-itemid="' + $this.attr('data-itemid') + '"])').each(function() { 957 lfb_itemClick($(this), false, formID); 958 $(this).removeClass('checked'); 959 }); 960 $this.closest('.lfb_genSlide').find('input[type=checkbox][data-group="' + $this.data('group') + '"]:checked:not([data-itemid="' + $this.attr('data-itemid') + '"])').trigger('click.auto'); 961 962 963 $this.closest('.lfb_genSlide').find('a.lfb_button.checked[data-group="' + $this.data('group') + '"]:not([data-itemid="' + $this.attr('data-itemid') + '"])').each(function() { 964 965 lfb_itemClick($(this), false, formID); 966 $(this).removeClass('checked'); 967 }); 968 if (form.groupAutoClick == '1' && $this.is('.checked') && $this.closest('.lfb_genSlide').is('[data-required=true]')) { 969 setTimeout(function() { 970 if ($this.closest('.lfb_genSlide').find('[data-itemid]').not('[data-itemtype="separator"]').not('.lfb_richtext').not('[data-group="' + $this.data('group') + '"]').not('.lfb_disabled').length == 0 && 971 $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .quantityBtns').length == 0 && $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .lfb_qtfield').length == 0) { 972 lfb_nextStep(form.formID); 973 } 974 }, 500); 975 } 976 } 977 978 setTimeout(function() { 979 lfb_updatePrice(formID); 980 $this.removeClass('action'); 981 }, 420); 982 } 983 984 setTimeout(function() { 985 if ($this.is('[data-usedistance="true"]')) { 986 lfb_removeDistanceError($this.attr('data-itemid'), formID); 987 } 988 }, 200); 989 } 990 991 function lfb_nl2br(str, is_xhtml) { 992 str = str.replace(/\n\n/g, '\n'); 993 var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>'; 994 return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); 995 } 996 997 function lfb_findGetParameter(parameterName) { 998 var result = null, 999 tmp = []; 1000 location.search 1001 .substr(1) 1002 .split("&") 1003 .forEach(function(item) { 1004 tmp = item.split("="); 1005 if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]); 1006 }); 1007 return result; 1008 } 1009 1010 function lfb_initForms() { 1011 jQuery.each(lfb_forms, function() { 1012 var form = this; 1013 form.price = 0; 1014 form.priceSingle = 0; 1015 form.priceMax = 0;
1016 form.step = 0; 1017 form.gFormDesignCheck = 0; 1018 form.timer_gFormSubmit = null; 1019 form.timer_gFormDesign = null; 1020 form.animationsSpeed = 400; 1021 form.reductionResult = 0; 1022 form.reduction = 0; 1023 form.discountCode = ""; 1024 form.discountCodeDisplayed = false; 1025 form.initialPrice = parseFloat(form.initialPrice); 1026 form.contactSent = 0; 1027 form.gravitySent = false; 1028 form.shineFxIndex = 0; 1029 form.subscriptionText = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').html(); 1030 form.richtextsContent = new Array(); 1031 form.emailSent = false; 1032 form.autoStart = false; 1033 form.urlVariables = ''; 1034 form.useRazorpay = false; 1035 form.razorpayReady = false; 1036 form.stripeToken = ''; 1037 form.itemsData = new Array(); 1038 form.signature = false; 1039 $('#lfb_form[data-form="' + form.formID + '"]').data('lfb_form', form); 1040 1041 lfb_initVerificationCodeModal(form); 1042 1043 setTimeout(function(){ 1044 $('#lfb_form[data-form="' + form.formID + '"] [data-toggle="tooltip"][data-tooltiptext]:not([title])').each(function() { 1045 $(this).attr('title', $(this).attr('data-tooltiptext')); 1046 }); 1047 },400); 1048 1049 var darkBgColor = false; 1050 1051 if (form.stepsColorBackground) { 1052 var c = form.stepsColorBackground.substring(1); 1053 var rgb = parseInt(c, 16); 1054 var r = (rgb >> 16) & 0xff; 1055 var g = (rgb >> 8) & 0xff;
1056 var b = (rgb >> 0) & 0xff; 1057 var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; 1058 if (luma < 40) { 1059 darkBgColor = true; 1060 } 1061 } 1062 if (darkBgColor) { 1063 $('#lfb_form[data-form="' + form.formID + '"]').addClass('lfb_darkStepBg'); 1064 } 1065 1066 if ($('#lfb_form[data-form="' + form.formID + '"] #lfb_btnStart').length > 0) { 1067 $('#lfb_form[data-form="' + form.formID + '"] #lfb_btnStart').on('click', function() { 1068 lfb_startFormIntro(form.formID); 1069 }); 1070 } 1071 1072 if ($('#lfb_form[data-form="' + form.formID + '"] #lfb_couponBtn').length > 0) { 1073 $('#lfb_form[data-form="' + form.formID + '"] #lfb_couponBtn').on('click', function() { 1074 lfb_applyCouponCode(form.formID); 1075 }); 1076 } 1077 if ($('#lfb_form[data-form="' + form.formID + '"] a.lfb_btnSaveForm').length > 0) { 1078 $('#lfb_form[data-form="' + form.formID + '"] a.lfb_btnSaveForm').on('click', function() { 1079 lfb_saveForLater(form.formID); 1080 }); 1081 } 1082 if ($('#lfb_form[data-form="' + form.formID + '"] a.lfb_btnFloatingSummary').length > 0) { 1083 $('#lfb_form[data-form="' + form.formID + '"] a.lfb_btnFloatingSummary').on('click', function() { 1084 lfb_toggleFloatingSummary(form.formID); 1085 }); 1086 } 1087 1088 1089 if ($('#lfb_form[data-form="' + form.formID + '"]').is('.lfb_visualEditing')) { 1090 lfb_clearFixedElements(); 1091 } 1092 1093 if ($('#lfb_form[data-form="' + form.formID + '"]').is('.lfb_fullscreen')) { 1094 $('#lfb_form[data-form="' + form.formID + '"]').closest('#lfb_bootstraped').parents().css({ position: 'static', display: 'block' }); 1095 } 1096 1097 if (form.useSignature == 1) { 1098 form.signature = $('#lfb_form[data-form="' + form.formID + '"] #lfb_signature').signature({ 1099 thickness: 4, 1100 guideline: false, 1101 guidelineOffset: 26, 1102 background: '#fff' 1103 }); 1104 $('#lfb_form[data-form="' + form.formID + '"] #lfb_resetSignature').on('click', function() { 1105 form.signature.signature('clear'); 1106 }); 1107 setTimeout(function() { 1108 $('#lfb_form[data-form="' + form.formID + '"] #lfb_signature canvas').attr('width', $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_signature').width()); 1109 $('#lfb_form[data-form="' + form.formID + '"] #lfb_signature canvas').css('width', $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_signature').width()); 1110 }, 500); 1111 1112 } 1113 for (var i = 0; i < form.variables.length; i++) { 1114 form.variables[i].value = form.variables.defaultValue; 1115 } 1116 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').on('click', function() { 1117 lfb_showWinStripePayment(form); 1118 }); 1119 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_richtext[data-itemid]').each(function() { 1120 form.richtextsContent[$(this).attr('data-itemid').toString()] = $(this).html(); 1121 }); 1122 setTimeout(() => { 1123 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-prefill]').each(function() { 1124 if ($(this).attr('data-prefill').length > 0) { 1125 var value = lfb_findGetParameter($(this).attr('data-prefill')); 1126 if (value !== null) { 1127 $(this).val(value).trigger('change'); 1128 } 1129 } 1130 }); 1131 }, 200); 1132 1133 1134 1135 1136 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-tooltiptext][data-tooltipimg!=""]').each(function() { 1137 $(this).attr('data-tooltiptext', $(this).attr('data-tooltiptext') + "<br/><img src='" + $(this).attr('data-tooltipimg') + "' alt='" + $(this).attr('data-tooltiptext') + "'/>"); 1138 }); 1139 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-type="numberfield"]:not([value])').each(function() { 1140 var min = 0; 1141 if ($(this).is('[min]')) { 1142 min = parseInt($(this).attr('min')); 1143 } 1144 $(this).val(min); 1145 }); 1146 var formID = form.formID; 1147 if (form.save_to_cart == 1) { 1148 form.save_to_cart = true; 1149 } else { 1150 form.save_to_cart = false;
1151 } 1152 if (form.save_to_cart_edd == 1) { 1153 form.save_to_cart_edd = true; 1154 } else { 1155 form.save_to_cart_edd = false; 1156 } 1157 1158 if (form.gravityFormID > 0) { 1159 jQuery.ajax({ 1160 url: form.ajaxurl, 1161 type: 'post', 1162 data: { 1163 action: 'get_currentRef', 1164 formID: formID 1165 }, 1166 success: function(currentRef) { 1167 form.current_ref = currentRef; 1168 } 1169 }); 1170 } 1171 1172 var calendarsToCheck = new Array(); 1173 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide .lfb_timepicker').each(function() { 1174 $(this).timepicker({ 1175 showMeridian: parseInt(form.timeModeAM), 1176 appendWidgetTo: '#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]' 1177 }); 1178 $(this).on('click', function() { 1179 $(this).timepicker('showWidget'); 1180 }); 1181 $(this).timepicker().on('changeTime.timepicker', function(e) { 1182 var minTime = $(this).attr('data-mintime'); 1183 var maxTime = $(this).attr('data-maxtime'); 1184 if (minTime != "" && minTime.indexOf(':') > 0) { 1185 var minHour = parseInt(minTime.substr(0, minTime.indexOf(':'))); 1186 var minMins = parseInt(minTime.substr(minTime.indexOf(':') + 1, 2)); 1187 if (minTime.indexOf('PM') > 0 && minHour != 12) { 1188 minHour += 12; 1189 } 1190 var hours = e.time.hours; 1191 if (e.time.meridian == "PM") { 1192 hours += 12; 1193 } 1194 if (hours < minHour || (hours == minHour && e.time.minutes < minMins)) { 1195 $(this).val(''); 1196 } 1197 } 1198 if (maxTime != "" && maxTime.indexOf(':') > 0) { 1199 var maxHour = parseInt(maxTime.substr(0, maxTime.indexOf(':'))); 1200 var maxMins = parseInt(maxTime.substr(maxTime.indexOf(':') + 1, 2)); 1201 if (maxTime.indexOf('PM') > 0 && maxHour != 12) { 1202 maxHour += 12; 1203 } 1204 var hours = e.time.hours; 1205 if (e.time.meridian == "PM") { 1206 hours += 12; 1207 } 1208 if (hours > maxHour || (hours == maxHour && e.time.minutes > maxMins)) { 1209 $(this).val(''); 1210 } 1211 } 1212 }); 1213 }); 1214 var dateFormat = lfb_forms[0].dateFormat; 1215 dateFormat = dateFormat.replace(/\\\//g, "/"); 1216 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide .lfb_datepicker:not(.lfb_datepickerReady)').each(function() { 1217 var minDate = new Date(); 1218 $(this).addClass('lfb_datepickerReady'); 1219 if ($(this).is('[data-allowpast="1"]') || $(this).is('[data-datetype="time"]')) { 1220 minDate = null; 1221 } else if ($(this).is('[data-allowpast="0"]') && parseInt($(this).attr('data-startdays')) > 0) { 1222 var nbDays = parseInt($(this).attr('data-startdays')); 1223 minDate.setDate(minDate.getDate() + nbDays); 1224 } 1225 var maxView = ''; 1226 var daysWeekDisabled = new Array(); 1227 if ($(this).is('[data-daysweek]') && $(this).attr('data-daysweek') != '') { 1228 jQuery.each($(this).attr('data-daysweek').split(','), function() { 1229 daysWeekDisabled.push(parseInt(this)); 1230 }); 1231 } 1232 var datepickerData = { 1233 daysOfWeekDisabled: daysWeekDisabled, 1234 language: form.datePickerLanguage, 1235 fontAwesome: true, 1236 timeZone: '', 1237 startDate: minDate, 1238 showMeridian: parseInt(form.timeModeAM), 1239 container: '.lfb_itemContainer_' + $(this).attr('data-itemid') 1240 }; 1241 var dateType = $(this).attr('data-datetype'); 1242 if (dateType == 'date') { 1243 datepickerData.format = dateFormat; 1244 datepickerData.minView = 2; 1245 if (minDate) { 1246 minDate.setHours(0); 1247 minDate.setMinutes(0); 1248 } 1249 $(this).attr('data-disableminutes', '0'); 1250 } else if (dateType == 'time') { 1251 if (parseInt(form.timeModeAM) == 1) { 1252 datepickerData.format = 'H:ii P'; 1253 } else { 1254 datepickerData.format = 'hh:ii'; 1255 } 1256 datepickerData.startView = 1; 1257 if ($(this).is('[data-disableminutes="1"]')) { 1258 datepickerData.minView = 1; 1259 if (minDate) { 1260 minDate.setMinutes(0); 1261 } 1262 } 1263 } else { 1264 if (parseInt(form.timeModeAM) == 1) { 1265 datepickerData.format = dateFormat + ' H:ii P'; 1266 } else { 1267 datepickerData.format = dateFormat + ' hh:ii'; 1268 } 1269 if ($(this).is('[data-disableminutes="1"]')) { 1270 datepickerData.minView = 1; 1271 } 1272 } 1273 1274 $(this).datetimepicker(datepickerData) 1275 .on('show', function(ev) { 1276 $(this).data('lastdate', $(this).val()); 1277 $(this).val(''); 1278 }).on('hide', function(ev) { 1279 if ($(this).val() == '' && $(this).data('lastdate') != '') { 1280 $(this).val($(this).data('lastdate')); 1281 } 1282 }).on('changeDay', function(ev) { 1283 $(this).val(''); 1284 var day = moment.utc(ev.date).format('YYYY-MM-DD'); 1285 var eventDuration = $(this).attr('data-eventduration'); 1286 var eventDurationType = $(this).attr('data-eventdurationtype'); 1287 var disabledHours = lfb_getDisabledHours($(this).attr('data-calendarid'), day, eventDuration, eventDurationType); 1288 1289 var dayWeek = ev.date.getDay(); 1290 if ($(this).attr('data-daysweek').indexOf(dayWeek.toString()) > -1) { 1291 disabledHours = new Array(); 1292 for (var i = 0; i < 24; i++) { 1293 disabledHours.push(parseInt(i)); 1294 } 1295 } 1296 $(this).data('date', day); 1297 $(this).datetimepicker('setHoursDisabled', disabledHours); 1298 $(this).addClass('checked'); 1299 1300 var form = lfb_getForm($(this).closest('#lfb_form').attr('data-form')); 1301 1302 if ($(this).is('[data-datetype="date"]') && form.autocloseDatepicker == '1') { 1303 var $this = $(this); 1304 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .datetimepicker').hide(); 1305 1306 if (form.groupAutoClick == '1' && $this.closest('.lfb_genSlide').is('[data-required=true]')) { 1307 setTimeout(function() { 1308 if ($this.closest('.lfb_genSlide').find('[data-itemid]').not('[data-itemid="' + $this.attr('data-itemid') + '"]').not('[data-itemtype="separator"]').not('.lfb_richtext').not('[data-group="' + $this.data('group') + '"]').not('.lfb_disabled').length == 0 && 1309 $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .quantityBtns').length == 0 && $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .lfb_qtfield').length == 0) { 1310 lfb_nextStep(form.formID); 1311 } 1312 }, 500); 1313 } 1314 } 1315 1316 }) 1317 .on('changeMinute', function(ev) { 1318 var $this = $(this); 1319 $(this).addClass('checked'); 1320 if (form.autocloseDatepicker == 1) { 1321 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .datetimepicker').hide(); 1322 1323 if (form.groupAutoClick == '1' && $this.closest('.lfb_genSlide').is('[data-required=true]')) { 1324 setTimeout(function() { 1325 if ($this.closest('.lfb_genSlide').find('[data-itemid]').not('[data-itemid="' + $this.attr('data-itemid') + '"]').not('[data-itemtype="separator"]').not('.lfb_richtext').not('[data-group="' + $this.data('group') + '"]').not('.lfb_disabled').length == 0 && 1326 $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .quantityBtns').length == 0 && $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .lfb_qtfield').length == 0) { 1327 lfb_nextStep(form.formID); 1328 } 1329 }, 500); 1330 } 1331 } 1332 }) 1333 .on('changeHour', function(ev) { 1334 var $this = $(this); 1335 1336 $(this).addClass('checked'); 1337 if ($(this).is('[data-datetype="dateTime"]') && form.autocloseDatepicker == '1' && $(this).is('[data-disableminutes="1"]')) { 1338 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .datetimepicker').hide(); 1339 1340 if (form.groupAutoClick == '1' && $this.closest('.lfb_genSlide').is('[data-required=true]')) { 1341 setTimeout(function() { 1342 if ($this.closest('.lfb_genSlide').find('[data-itemid]').not('[data-itemid="' + $this.attr('data-itemid') + '"]').not('[data-itemtype="separator"]').not('.lfb_richtext').not('[data-group="' + $this.data('group') + '"]').not('.lfb_disabled').length == 0 && 1343 $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .quantityBtns').length == 0 && $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .lfb_qtfield').length == 0) { 1344 lfb_nextStep(form.formID); 1345 } 1346 }, 500); 1347 } 1348 } 1349 if ($(this).is('[data-datetype="time"]') && $(this).is('[data-disableminutes="1"]')) { 1350 var date = moment(ev.date).utc(); 1351 date.subtract(moment(ev.date).minutes(), 'minutes'); 1352 var datepicker = this; 1353 setTimeout(function() { 1354 $(datepicker).datetimepicker('setDate', new Date(date.format('YYYY-MM-DD HH:00'))); 1355 }, 1); 1356 1357 if (form.autocloseDatepicker == 1) { 1358 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .datetimepicker').hide(); 1359 1360 if (form.groupAutoClick == '1' && $this.closest('.lfb_genSlide').is('[data-required=true]')) { 1361 setTimeout(function() { 1362 if ($this.closest('.lfb_genSlide').find('[data-itemid]').not('[data-itemid="' + $this.attr('data-itemid') + '"]').not('[data-itemtype="separator"]').not('.lfb_richtext').not('[data-group="' + $this.data('group') + '"]').not('.lfb_disabled').length == 0 && 1363 $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .quantityBtns').length == 0 && $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .lfb_qtfield').length == 0) { 1364 lfb_nextStep(form.formID); 1365 } 1366 }, 500); 1367 } 1368 } 1369 } else { 1370 var day = moment.utc(ev.date).format('YYYY-MM-DD'); 1371 var hour = moment.utc(ev.date).format('HH'); 1372 var eventDuration = $(this).attr('data-eventduration'); 1373 var eventDurationType = $(this).attr('data-eventdurationtype'); 1374 var disabledMinutes = lfb_getDisabledMinutes($(this).attr('data-calendarid'), day, hour, eventDuration, eventDurationType); 1375 $(this).data('date', moment.utc(ev.date).format('YYYY-MM-DD HH:00')); 1376 if ($(this).is('[data-disableminutes="1"]')) { 1377 var newDate = moment.utc(ev.date).format('YYYY-MM-DD HH:00'); 1378 1379 $(this).data('date', newDate); 1380 $(this).addClass('checked'); 1381 var _this = this; 1382 setTimeout(function() { 1383 var date = moment(newDate); 1384 date.subtract(moment(date).minutes(), 'minutes'); 1385 $(this).data('date', date.toDate()); 1386 $(_this).datetimepicker('setDate', new Date()); 1387 $(_this).datetimepicker('setDate', date.toDate()); 1388 var postText = ''; 1389 if ($(_this).val().indexOf('PM') > $(_this).val().indexOf(':')) { 1390 postText = ' PM'; 1391 } else if ($(_this).val().indexOf('AM') > $(_this).val().indexOf(':')) { 1392 postText = ' AM'; 1393 } 1394 $(_this).val($(_this).val().split(':')[0] + ':00' + postText); 1395 1396 }, 50); 1397 } 1398 $(this).datetimepicker('setMinutesDisabled', disabledMinutes); 1399 1400 1401 } 1402 }); 1403 1404 var _this = this; 1405 1406 $(this).closest('.form-group').next('.datetimepicker').find('.datetimepicker-hours thead tr:first-child th').on('click', function() { 1407 var link = this; 1408 setTimeout(function() { 1409 var datepicker = $(link).closest('.datetimepicker').prev('.form-group').find('.lfb_datepicker'); 1410 var date = $(_this).datetimepicker('getViewDate'); 1411 datepicker.val(''); 1412 var day = moment(date).format('YYYY-MM-DD'); 1413 var eventDuration = datepicker.attr('data-eventduration'); 1414 var eventDurationType = datepicker.attr('data-eventdurationtype'); 1415 var disabledHours = lfb_getDisabledHours(datepicker.attr('data-calendarid'), day, eventDuration, eventDurationType); 1416 1417 datepicker.data('date', day); 1418 1419 1420 if (datepicker.is('[data-daysweek]') && typeof($(this).attr('data-daysweek')) != 'undefined') { 1421 jQuery.each(datepicker.attr('data-daysweek').split(','), function() { 1422
1422 if (this == date.getDay()) { 1423 disabledHours = new Array(); 1424 for (var i = 0; i < 24; i++) { 1425 disabledHours.push(i); 1426 } 1427 } 1428 }); 1429 } 1430 datepicker.datetimepicker('setHoursDisabled', disabledHours); 1431 1432 }, 10); 1433 }); 1434 if (dateType == 'date') { 1435 $(this).on('show', function() { 1436 $('.datetimepicker .table-condensed .prev').show(); 1437 $('.datetimepicker .table-condensed .switch').show(); 1438 $('.datetimepicker .table-condensed .next').show(); 1439 }); 1440 } else if (dateType == 'time') { 1441 $(this).on('show', function() { 1442 $('.datetimepicker .table-condensed .prev').hide(); 1443 $('.datetimepicker .table-condensed .switch').hide(); 1444 $('.datetimepicker .table-condensed .next').hide(); 1445 }); 1446 } else { 1447 $(this).on('show', function() { 1448 $('.datetimepicker .table-condensed .prev').show(); 1449 $('.datetimepicker .table-condensed .switch').show(); 1450 $('.datetimepicker .table-condensed .next').show(); 1451 });; 1452 } 1453 if ($(this).attr('data-calendarid') != 0 && parseInt($(this).attr('data-calendarid')) > 0) { 1454 if (jQuery.inArray($(this).attr('data-calendarid'), calendarsToCheck) == -1) { 1455 calendarsToCheck.push($(this).attr('data-calendarid')); 1456 } 1457 } 1458 if ($(this).attr('placeholder').length == 0 && $(this).val().length == 0) { 1459 if ($(this).is('[data-disableminutes="1"]') || $(this).attr('data-calendarid') != '0') {} else { 1460 $(this).datetimepicker('setDate', new Date()); 1461 } 1462 } 1463 $(this).on('keypress', function(e) { 1464 e.preventDefault(); 1465 }); 1466 1467 if (!$(this).is('[data-mindatepicker="0"]') && !$(this).is('[data-datetype="time"]')) { 1468 var originalDatepicker = $(this); 1469 var minDatepicker = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-itemid="' + $(this).attr('data-mindatepicker') + '"]'); 1470 1471 1472 minDatepicker.on('changeDate', function() { 1473 var currentDate = moment(originalDatepicker.datetimepicker('getDate')).format('YYYY-MM-DD HH:mm'); 1474 1475 var day = moment(minDatepicker.datetimepicker('getDate')); 1476 var newDay = day.add(parseInt(originalDatepicker.attr('data-startdays')), 'day'); 1477 1478 newDay = newDay.add(parseInt(minDatepicker.attr('data-eventduration')), minDatepicker.attr('data-eventdurationtype')); 1479 1480 if (newDay.format('YYYY-MM-DD HH:mm') > currentDate) { 1481 originalDatepicker.datetimepicker('setDate', newDay.toDate()); 1482 } 1483 }); 1484 originalDatepicker.on('changeDate', function() { 1485 var currentDate = moment(originalDatepicker.datetimepicker('getDate')).format('YYYY-MM-DD HH:mm'); 1486 var day = moment(minDatepicker.datetimepicker('getDate')); 1487 var newDay = moment(minDatepicker.datetimepicker('getDate')).add(parseInt(minDatepicker.attr('data-startdays')), 'day'); 1488 newDay = newDay.add(parseInt(minDatepicker.attr('data-eventduration')), minDatepicker.attr('data-eventdurationtype')); 1489 1490 if (newDay.format('YYYY-MM-DD HH:mm') > currentDate) { 1491 var newDate = moment(originalDatepicker.datetimepicker('getDate')).subtract(parseInt(originalDatepicker.attr('data-startdays')), 'day'); 1492 newDate = newDate.subtract(parseInt(minDatepicker.attr('data-eventduration')), minDatepicker.attr('data-eventdurationtype')); 1493 minDatepicker.datetimepicker('setDate', newDate.toDate()); 1494 } 1495 }); 1496 } 1497 }); 1498 if (calendarsToCheck.length > 0) { 1499 lfb_getBusyDates(form.formID, calendarsToCheck); 1500 } 1501 1502 var deviceAgent = navigator.userAgent.toLowerCase(); 1503 var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i); 1504 if (agentID) { 1505 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-flipfx="1"]').removeAttr('data-flipfx'); 1506 } 1507 1508 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-emaillaststep="1"]')) { 1509 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide .linkPrevious').addClass('lfb-hidden'); 1510 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnOrder').addClass('lfb-hidden'); 1511 } 1512 if (form.hideFinalbtn == 1) { 1513 $('#lfb_form[data-form="' + form.formID + '"] #lfb_btnOrder').addClass('lfb-hidden'); 1514 } 1515 1516 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .form-control').on('focus', function() { 1517 if (form.disableTipMobile == 0 && lfb_is_touch_device()
1517) { 1518 $(this).tooltip('show'); 1519 } 1520 }).on('focusout', function() { 1521 if (form.disableTipMobile == 0 && lfb_is_touch_device()) { 1522 $('#lfb_form :not(.ui-slider-handle) > .tooltip').remove(); 1523 $('body > .tooltip').remove(); 1524 $('#lfb_form[data-form="' + form.formID + '"] > .tooltip').remove(); 1525 } 1526 }); 1527 1528 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide .lfb_genContent div.lfb_selectable span.icon_select.lfb_fxZoom').css({ 1529 textShadow: '-2px 0px ' + $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel').css('background-color') 1530 }); 1531 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_popup') && !$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').closest('#lfb_bootstraped').parent().is('body')) { 1532 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').closest('#lfb_bootstraped').detach().appendTo('body'); 1533 } 1534 if ($('#lfb_form[data-form="' + form.formID + '"]').is('.lfb_fullscreen')) { 1535 $('html,body').css('overflow-y', 'hidden'); 1536 } 1537 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length > 0) { 1538 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').attr('target', '_self'); 1539 } 1540 1541 if (typeof(google) != 'undefined') { 1542 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_gmap').each(function() { 1543 $(this).css('height', $(this).attr('data-height')); 1544 var $item = $(this); 1545 var centerMap = { lat: 0, lng: 0 }; 1546 var styles = lfb_getMapStyle($(this).attr('data-mapstyle')); 1547 1548 var map = new google.maps.Map(document.getElementById('lfb_mapCt_' + $item.attr('data-itemid')), { 1549 zoom: parseInt($item.attr('data-mapzoom')), 1550 controlSize: 32, 1551 center: centerMap, 1552 styles: styles 1553 }); 1554 $(this).data('gmap', map); 1555 1556 if ($(this).attr('data-maptype') == 'marker') { 1557 var address = $item.attr('data-address'); 1558 if (address.length > 3) { 1559 var geocoder = new google.maps.Geocoder(); 1560 geocoder.geocode({ 'address': address }, function(results, status) { 1561 if (typeof(results[0]) != 'undefined') { 1562 1563 centerMap = results[0].geometry.location; 1564 map.setCenter(centerMap); 1565 var marker = new google.maps.Marker({ 1566 position: results[0].geometry.location, 1567 map: map 1568 }); 1569 1570 $(this).data('mapMarker', marker); 1571 } 1572 }); 1573 } 1574 } else if ($(this).is('[data-itinerary]')) { 1575 var directionRenderer = new google.maps.DirectionsRenderer(); 1576 directionRenderer.setMap(map); 1577 $(this).data('directionRenderer', directionRenderer); 1578 1579 1580 1581 lfb_updateGmapItinerary($(this), form.formID); 1582 1583 } 1584 }); 1585 } 1586 1587 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-lazy-src]').each(function() { 1588 $(this).parent().on('click', function(e) { 1589 lfb_itemClick($(this), true, form.formID); 1590 }); 1591 }); 1592 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns').length > 0) { 1593 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns [data-payment="paypal"]').on('click', function(e) { 1594 e.preventDefault(); 1595 form.stripeToken = ''; 1596 form.useRazorpay = false;
1597 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_razorPayCt').slideUp(); 1598 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnOrderPaypal').trigger('click'); 1599 }); 1600 1601 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns [data-payment="razorpay"]').on('click', function() { 1602 1603 var isOK = lfb_checkStepItemsValid('final', form.formID); 1604 if (isOK) { 1605 1606 lfb_checkCaptcha(form, function() { 1607 setTimeout(function() { 1608 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen')) { 1609 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 1610 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_razorPayCt').offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 1611 }, form.animationsSpeed * 2); 1612 } else { 1613 $('body,html').animate({ 1614 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_razorPayCt').offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 1615 }, form.animationsSpeed * 2); 1616 } 1617 1618 }, 350); 1619 1620 if (lfb_lastSteps.length > 0) { 1621 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel #lfb_razorPayCt .linkPrevious').fadeIn(); 1622 } 1623 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #btnOrderRazorpay').length > 0) { 1624 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #btnOrderRazorpay').trigger('click'); 1625 } 1626 }); 1627 1628 } 1629 }); 1630 1631 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns [data-payment="stripe"]').on('click', function() { 1632 form.useRazorpay = false; 1633 form.useStripePayment = true; 1634 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_razorPayCt').slideUp(); 1635 var isOK = lfb_checkStepItemsValid('final', form.formID); 1636 if (isOK) { 1637 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_captcha').length > 0) { 1638 jQuery.ajax({ 1639 url: form.ajaxurl, 1640 type: 'post', 1641 data: { 1642 action: 'lfb_checkCaptcha', 1643 formID: formID, 1644 captcha: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_captchaField').val() 1645 }, 1646 success: function(rep) { 1647 if (rep == '1') { 1648 1649 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_captchaPanel').slideUp(100); 1650 lfb_showWinStripePayment(form); 1651 } else { 1652 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_captchaField').closest('.form-group').addClass('has-error'); 1653 1654 } 1655 } 1656 }); 1657 } else { 1658 1659 1660 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_captchaPanel').slideUp(100); 1661 lfb_showWinStripePayment(form); 1662 } 1663 } 1664 }); 1665 } 1666 1667 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #btnOrderRazorpay').on('click', function() { 1668 form.useRazorpay = true; 1669 lfb_order(formID); 1670 }); 1671 1672 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] input:not([type=checkbox])').on('change', function() { 1673 lfb_updatePrice(formID, $(this).attr('data-itemid')); 1674 }); 1675 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] textarea').on('change', function() { 1676 lfb_updatePrice(formID, $(this).attr('data-itemid')); 1677 }); 1678 if (form.enableShineFxBtn == 1) { 1679 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('a.btn-primary').append('<canvas class="lfb_shineCanvas"></canvas>'); 1680 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('a.btn-primary').on('mouseover', function() { 1681 if (form.shineFxIndex == 0) { 1682 lfb_shineBtn(formID, $(this).find('.lfb_shineCanvas')); 1683 } 1684 }); 1685 } 1686 1687 1688 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_dropzone').each(function() { 1689 var maxSize = null; 1690 if ($(this).attr('data-maxfiles') > 0) { 1691 maxSize = $(this).attr('data-maxfiles'); 1692 } 1693 var dropzone = $(this); 1694 $(this).dropzone({ 1695 url: form.ajaxurl + '?form=' + formID, 1696 paramName: 'file', 1697 maxFilesize: $(this).attr('data-filesize'), 1698 maxFiles: maxSize, 1699 addRemoveLinks: true, 1700 dictRemoveFile: '', 1701 dictCancelUpload: '', 1702 acceptedFiles: $(this).attr('data-allowedfiles'), 1703 dictDefaultMessage: form.filesUpload_text, 1704 dictFileTooBig: form.filesUploadSize_text, 1705 dictInvalidFileType: form.filesUploadType_text, 1706 dictMaxFilesExceeded: form.filesUploadLimit_text, 1707 init: function() { 1708 this.on("thumbnail", function(file, dataUrl) { 1709 var thumb = $(file.previewElement); 1710 var fileName = file.name.replace(/\//g, ''); 1711 fileName = fileName.replace(/ /g, '_'); 1712 fileName = fileName.replace(/'/g, '_'); 1713 fileName = fileName.replace(/"/g, '_'); 1714 fileName = fileName.replace(/[^a-zA-Z0-9._-]/g, ''); 1715 1716 thumb.attr('data-file', fileName + '_' + dropzone.data('currentFileIndex')); 1717 }); 1718 this.on("sending", function(file, xhr, formData) { 1719 dropzone.closest('.lfb_genSlide').find('.lfb_btn-next').fadeOut(); 1720 dropzone.closest('.lfb_genSlide').find('.btn-primary').fadeOut(); 1721 formData.append("action", 'lfb_upload_form'); 1722 formData.append("formSession", $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-formsession')); 1723 formData.append('itemID', dropzone.attr('data-itemid')); 1724 }), 1725 this.on("complete", function(file, xhr) { 1726 if (dropzone.find('.dz-preview:not(.dz-complete)').length == 0 || dropzone.find('.dz-preview').length == 0) { 1727 dropzone.closest('.lfb_genSlide').find('.lfb_btn-next').fadeIn(); 1728 dropzone.closest('.lfb_genSlide').find('.btn-primary').fadeIn(); 1729 } 1730 lfb_updatePrice(form.formID); 1731 }); 1732 this.on("success", function(file, rep) { 1733 var thumb = $(file.previewElement); 1734 var fileName = file.name.replace(/\//g, ''); 1735 fileName = fileName.replace(/ /g, '_'); 1736 fileName = fileName.replace(/'/g, '_'); 1737 fileName = fileName.replace(/"/g, '_'); 1738 fileName = fileName.replace(/[^a-zA-Z0-9._-]/g, ''); 1739 if (form.emailCustomerLinks == 1) { 1740 var reps = rep.split('||'); 1741 var url = reps[0]; 1742 thumb.attr('data-url', url); 1743 rep = reps[1]; 1744 } 1745 if (typeof(rep) == 'undefined' || rep == undefined || rep == 'undefined') { 1746 thumb.addClass('dz-error'); 1747 thumb.find('[data-dz-errormessage]').html('There is an error, please try again'); 1748 } else { 1749 thumb.attr('data-file', rep + '_' + fileName); 1750 } 1751 }); 1752 this.on("removedfile", function(file, xhr) { 1753 lfb_updatePrice(form.formID); 1754 }); 1755 } 1756 }); 1757 }); 1758 1759 1760 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('.lfb_rate').each(function() { 1761 1762 var max = parseInt($(this).closest('.lfb_itemBloc').attr('data-max')); 1763 var initialValue = parseInt($(this).closest('.lfb_itemBloc').attr('data-value')); 1764 if (isNaN(initialValue)) { 1765 initialValue = 5; 1766 } 1767 var color = '#bdc3c7'; 1768 if ($(this).closest('.lfb_itemBloc').attr('data-color') != '') { 1769 color = $(this).closest('.lfb_itemBloc').attr('data-color'); 1770 } 1771 if (color.indexOf('#') == -1) { 1772 color = '#' + color; 1773 } 1774 var stepSize = $(this).closest('.lfb_itemBloc').attr('data-interval'); 1775 $(this).rate({ 1776 initial_value: initialValue, 1777 max_value: max, 1778 step_size: 1, 1779 cursor: 'pointer' 1780 }).on("change", function(ev, data) { 1781 $(this).closest('.lfb_itemBloc').addClass('checked'); 1782 $(this).closest('.lfb_itemBloc').addClass('lfb_changed'); 1783 lfb_updatePrice(formID, $(this).closest('.lfb_itemBloc').attr('data-itemid')); 1784 }).css({ 1785 color: color 1786 }); 1787 }); 1788 1789 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('.form-control[data-validation="mask"][data-mask]').each(function() { 1790 if ($(this).attr('data-mask').trim().length > 0) { 1791 $(this).mask($(this).attr('data-mask'), { clearIfNotMatch: true }); 1792 } 1793 }); 1794 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('input[type="text"][data-itemid],textarea[data-itemid]').each(function() { 1795 $(this).attr('data-initialvalue', $(this).val()); 1796 }); 1797 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-itemid][data-type="slider"]').each(function() { 1798 var min = parseInt($(this).attr('data-min')); 1799 if (isNaN(min)) { 1800 min = 0; 1801 } 1802 var max = parseInt($(this).attr('data-max')); 1803 if (max == 0) { 1804 max = 30; 1805 } 1806 var dataDefaultValue = parseFloat($(this).attr('data-value')); 1807 if($(this).is('[data-qtdefault]')){ 1808 dataDefaultValue = parseFloat($(this).attr('data-qtdefault')); 1809 } 1810 var defaultValue = min; 1811 if (!isNaN(dataDefaultValue) && dataDefaultValue >= min && dataDefaultValue <= max) { 1812 defaultValue = dataDefaultValue; 1813 } 1814 1815 var tooltip = $('<div class="tooltip bs-tooltip-top" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner">' + defaultValue + '</div></div>').css({ 1816 position: 'absolute', 1817 top: -55, 1818 left: -20, 1819 opacity: 1 1820 }).hide(); 1821 var step = 1; 1822 if ($(this).is('[data-stepslider]') && parseFloat($(this).attr('data-stepslider')) > 0) { 1823 step = parseFloat($(this).attr('data-stepslider')); 1824 } 1825 var isRange = 'min'; 1826 if ($(this).is('.lfb_range')) { 1827 isRange = true; 1828 } 1829 var isDisabled = false;
1830 $(this).slider({ 1831 min: min, 1832 max: max, 1833 value: defaultValue, 1834 step: step, 1835 range: isRange, 1836 disabled: isDisabled, 1837 orientation: "horizontal", 1838 change: function(event, ui) { 1839 if (!lfb_isSelectionMode(form.formID)) { 1840 if (Number.isInteger(ui.value)) { 1841 $(ui.handle).find('.tooltip-inner').html(lfb_formatPrice(ui.value, form.formID)); 1842 } else { 1843 $(ui.handle).find('.tooltip-inner').html(ui.value); 1844 } 1845 if (event.originalEvent) { 1846 lfb_updatePrice(formID, $(this).attr('data-itemid')); 1847 } 1848 } 1849 }, 1850 start: function(event, ui) { 1851 if (lfb_isSelectionMode(form.formID)) { 1852 return false; 1853 } 1854 }, 1855 slide: function(event, ui) { 1856 if (lfb_isSelectionMode(form.formID)) { 1857 return false; 1858 } 1859 if (Number.isInteger(ui.value)) { 1860 $(ui.handle).find('.tooltip-inner').html(lfb_formatPrice(ui.value, form.formID)); 1861 } else { 1862 $(ui.handle).find('.tooltip-inner').html(ui.value); 1863 } 1864 var _self = this; 1865 if (event.originalEvent) { 1866 setTimeout(function() { 1867 lfb_updatePrice(formID, $(_self).attr('data-itemid')); 1868 $(_self).addClass('lfb_changed'); 1869 }, 30); 1870 $(ui.handle).find('.tooltip').show(); 1871 } 1872 lfb_updatePrice(formID, $(_self).attr('data-itemid')); 1873 }, 1874 stop: function(event, ui) { 1875 if (Number.isInteger(ui.value)) { 1876 $(ui.handle).find('.tooltip-inner').html(lfb_formatPrice(ui.value, form.formID)); 1877 } else { 1878 $(ui.handle).find('.tooltip-inner').html(ui.value); 1879 } 1880 lfb_updatePrice(formID, $(this).attr('data-itemid')); 1881 $(ui.handle).find('.tooltip').hide(); 1882 if (isRange === true) { 1883 var prefix = ''; 1884 var sufix = ''; 1885 if ($(this).find('.ui-slider-range').is('[data-tooltipprefix]')) { 1886 prefix = $(this).find('.ui-slider-range').attr('data-tooltipprefix'); 1887 } 1888 if ($(this).find('.ui-slider-range').is('[data-tooltipsufix]')) { 1889 sufix = $(this).find('.ui-slider-range').attr('data-tooltipsufix'); 1890 } 1891 $(this).find('.ui-slider-range').attr('title', prefix + ui.values[0] + ' - ' + ui.values[1] + sufix); 1892 $(this).find('.ui-slider-range').attr('data-bs-original-title', prefix + ui.values[0] + ' - ' + ui.values[1] + sufix); 1893 } 1894 } 1895 1896 }).find(".ui-slider-handle").append(tooltip).on('mouseenter', function() { 1897 if (!lfb_isSelectionMode(form.formID)) { 1898 $(this).find('.tooltip').show(); 1899 } 1900 }).on('mouseleave', function() { 1901 $(this).find('.tooltip').hide(); 1902 }); 1903 if (isRange === true) { 1904 $(this).find('.ui-slider-range').attr('title', min + ' - ' + max).tooltip({ 1905 html: true, 1906 container: '#lfb_form[data-form="' + form.formID + '"]' 1907 }); 1908 var _slider = $(this); 1909 $(this).find('.ui-slider-range').on('mouseenter', function() { 1910 var prefix = ''; 1911 var sufix = ''; 1912 if ($(this).is('[data-tooltipprefix]')) { 1913 prefix = $(this).attr('data-tooltipprefix'); 1914 } 1915 if ($(this).is('[data-tooltipsufix]')) { 1916 sufix = $(this).attr('data-tooltipsufix'); 1917 } 1918 $(this).attr('title', prefix + ' ' + _slider.slider('values')[0] + ' - ' + _slider.slider('values')[1] + sufix); 1919 $(this).attr('data-bs-original-title', prefix + ' ' + _slider.slider('values')[0] + ' - ' + _slider.slider('values')[1] + sufix); 1920 }); 1921 } 1922 }); 1923 1924 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_colorpicker').each(function() { 1925 var $this = $(this); 1926 $(this).prev('.lfb_colorPreview').on('click', function() { 1927 if (!lfb_isSelectionMode(form.formID)) { 1928 $(this).next('.lfb_colorpicker').trigger('click'); 1929 } 1930 }); 1931 $(this).prev('.lfb_colorPreview').css({ 1932 backgroundColor: form.colorA 1933 }); 1934 $(this).colpick({ 1935 color: form.colorA, 1936 layout: 'hex', 1937 onSubmit: function() { 1938 $('body > .colpick').fadeOut(); 1939 }, 1940 onChange: function(hsb, hex, rgb, el, bySetColor) { 1941 $(el).val('#' + hex); 1942 $(el).prev('.lfb_colorPreview').css({ 1943 backgroundColor: '#' + hex 1944 }); 1945 } 1946 }); 1947 }); 1948 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('.lfb_colorPreview[data-urltarget],input[type="text"][data-itemid]:not(.lfb_colorpicker)[data-urltarget],textarea[data-itemid][data-urltarget],select[data-itemid][data-urltarget],input[type="number"][data-urltarget]').each(function() { 1949 $(this).on('click', function() { 1950 if (!lfb_isSelectionMode(form.formID)) { 1951 var win = window.open($(this).attr('data-urltarget'), '_blank'); 1952 if (typeof(win) !== 'null' && win != null) { 1953 win.focus(); 1954 } 1955 } 1956 }); 1957 }); 1958 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('[data-fieldtype]').each(function() { 1959 $(this).attr('name', $(this).attr('data-fieldtype')); 1960 }); 1961 1962 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('[data-autocomplete="1"]').each(function() { 1963 var options = {}; 1964 if ($(this).attr('data-fieldtype') == 'city') { 1965 options.types = ['(cities)']; 1966 } else if ($(this).attr('data-fieldtype') == 'address') { 1967 if ($(this).closest('.lfb_genContent').find('[data-fieldtype="city"]').length > 0) { 1968 options.types = ['address']; 1969 } 1970 } else if ($(this).attr('data-fieldtype') == 'country') { 1971 options.types = ['(regions)']; 1972 } else if ($(this).attr('data-fieldtype') == 'zip') { 1973 options.types = ['(regions)']; 1974 } 1975 var autocomplete = new google.maps.places.Autocomplete($(this).get(0), options); 1976 autocomplete.field = $(this); 1977 if ($(this).attr('data-fieldtype') == 'zip') { 1978 google.maps.event.addListener(autocomplete, 'place_changed', function() { 1979 var place = autocomplete.getPlace(); 1980 for (var i = 0; i < place.address_components.length; i++) { 1981 for (var j = 0; j < place.address_components[i].types.length; j++) { 1982 if (place.address_components[i].types[j] == "postal_code") { 1983 autocomplete.field.val(place.address_components[i].long_name); 1984 1985 } 1986 } 1987 } 1988 }); 1989 } else if ($(this).attr('data-fieldtype') == 'country') { 1990 google.maps.event.addListener(autocomplete, 'place_changed', function() { 1991 var place = autocomplete.getPlace(); 1992 for (var i = 0; i < place.address_components.length; i++) { 1993 for (var j = 0; j < place.address_components[i].types.length; j++) { 1994 if (place.address_components[i].types[j] == "country") { 1995 autocomplete.field.val(place.address_components[i].long_name); 1996 1997 } 1998 } 1999 } 2000 }); 2001 } 2002 }); 2003 2004 2005 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide [data-group]').each(function() { 2006 var $this = $(this); 2007 if (form.groupAutoClick == '1' && $this.prop('data-group') != "" && $this.closest('.lfb_genSlide').is('[data-required=true]')) { 2008 if ($this.closest('.lfb_genSlide').find('[data-itemid]:not(.lfb_disabled)').not('.lfb_richtext').not('[data-group="' + $this.data('group') + '"]').not('.lfb_disabled').length == 0 && 2009 $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .quantityBtns').length == 0 && $this.closest('.lfb_genSlide').find('[data-group="' + $this.data('group') + '"] .lfb_qtfield').length == 0) { 2010 $this.closest('.lfb_genSlide').find('.lfb_btn-next').addClass('lfb-hidden'); 2011 } 2012 } 2013 2014 }); 2015 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide div.lfb_selectable.prechecked,#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide a.lfb_button.prechecked,#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide input[type=checkbox][data-price].prechecked').each(function() { 2016 lfb_itemClick($(this), false, formID); 2017 }); 2018 lfb_initPrice(formID); 2019 lfb_updatePrice(formID); 2020 /* $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnStart').on('click', function () {
2021 if (!lfb_isSelectionMode(formID)) { 2022 lfb_openGenerator(formID); 2023 } 2024 });*/ 2025 lfb_initGform(formID); 2026 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length > 0) { 2027 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').attr('target', '_self'); 2028 } 2029 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .quantityBtns > a').on('click', function() { 2030 if (!lfb_isSelectionMode(form.formID)) { 2031 if ($(this).attr('data-btn') == 'less') { 2032 2033 if (typeof($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .quantityBtns > a[data-btn="more"]').data('incrementInterval')) != 'undefined') { 2034 clearInterval($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .quantityBtns > a[data-btn="more"]').data('incrementInterval')); 2035 } 2036 lfb_quantity_less(this, formID); 2037 } else { 2038 if (typeof($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .quantityBtns > a[data-btn="less"]').data('incrementInterval')) != 'undefined') { 2039 clearInterval($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .quantityBtns > a[data-btn="less"]').data('incrementInterval')); 2040 } 2041 lfb_quantity_more(this, formID); 2042 } 2043 } 2044 }); 2045 2046 2047 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .linkPrevious').on('click', function() { 2048 if (!lfb_isSelectionMode(form.formID)) { 2049 lfb_previousStep(formID); 2050 } 2051 }); 2052 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_btn-next').on('click', function() { 2053 if (!lfb_isSelectionMode(form.formID)) { 2054 lfb_nextStep(formID); 2055 } 2056 }); 2057 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnOrderPaypal').on('click', function() { 2058 if (!lfb_isSelectionMode(form.formID)) { 2059 lfb_order(formID); 2060 } 2061 }); 2062 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide [data-toggle="switch"]').on('change', function() { 2063 var fieldID = $(this).attr('data-fieldid'); 2064 lfb_toggleField(fieldID, formID); 2065 }); 2066 2067 var chkGrav = false; 2068 $('.gform_wrapper').each(function() { 2069 var gravID = $(this).attr('id').substr($(this).attr('id').lastIndexOf('_') + 1, $(this).attr('id').length); 2070 if (gravID == form.gravityFormID) { 2071 if (!chkGrav) { 2072 chkGrav = true; 2073 $(this).detach().insertAfter('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice'); 2074 } else { 2075 $(this).remove(); 2076 } 2077 } 2078 }); 2079 setTimeout(function() { 2080 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide .gform_wrapper').length > 1) { 2081 var chkGravA = false; 2082 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide .gform_wrapper').each(function() { 2083 if (!chkGravA) { 2084 chkGravA = true; 2085 } else { 2086 $(this).remove(); 2087 } 2088 }); 2089 } 2090 }, 500); 2091 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_qtfield').attr('type', 'number'); 2092 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_qtfield').on('focusout', function() { 2093 if ($(this).val().indexOf('-') > -1 && (!$(this).is('[min]') || $(this).attr('min').indexOf('-') < 0)) { 2094 $(this).val(parseInt($(this).attr('min'))); 2095 } 2096 if (parseFloat($(this).val()) < parseInt($(this).attr('min'))) { 2097 $(this).val($(this).attr('min')); 2098 } 2099 if (parseFloat($(this).val()) > parseInt($(this).attr('max'))) { 2100 $(this).val($(this).attr('max')); 2101 } 2102 lfb_updatePrice(form.formID); 2103 lfb_updateSummary(form.formID); 2104 }); 2105 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] input[type="number"][data-itemid]').on('keydown', function(event) { 2106 return event.keyCode == 69 ? false : true; 2107 }); 2108 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] input[type="number"][data-itemid]').on('focusin', function() { 2109 if ($(this).val() == 0) { 2110 $(this).val(''); 2111 } 2112 }); 2113 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] input[type="number"][data-itemid]').on('keyup change', function() { 2114 lfb_updatePrice(form.formID); 2115 lfb_updateSummary(form.formID); 2116 2117 }); 2118 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] input[type="number"][data-itemid]').on('focusout', function(e) { 2119 2120 if ($(this).val() == '') { 2121 $(this).val(0); 2122 } 2123 if ($(this).val() == 0 && !$(this).is('[data-required="true"]')) { 2124 2125 } else { 2126 if ($(this).val().indexOf('-') > -1 && (!$(this).is('[min]') || $(this).attr('min').indexOf('-') < 0)) { 2127 $(this).val(parseInt($(this).attr('min'))); 2128 } 2129 if (parseFloat($(this).val()) < parseFloat($(this).attr('min'))) { 2130 $(this).val($(this).attr('min')); 2131 } 2132 if (parseFloat($(this).val()) > parseFloat($(this).attr('max'))) { 2133 $(this).val($(this).attr('max')); 2134 } 2135 2136 if ($(this).val() == '' || isNaN(parseInt($(this).val()))) { 2137 $(this).val(0); 2138 } 2139 if ($(this).val() != '' && ($(this).is('[data-valueasqt="0"]') || $(this).val() > 0)) { 2140 $(this).addClass('checked'); 2141 } else { 2142 $(this).removeClass('checked'); 2143 } 2144 } 2145 if (e.originalEvent !== undefined) { 2146 lfb_updatePrice(form.formID); 2147 lfb_updateSummary(form.formID); 2148 2149 } 2150 }); 2151 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_sliderQt').each(function() { 2152 var min = parseInt($(this).closest('.quantityBtns').attr('data-min')); 2153 if (min == 0) { 2154 min = 1; 2155 } 2156 var tooltip = $('<div class="tooltip top" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner">' + min + '</div></div>').css({ 2157 position: 'absolute', 2158 top: -55, 2159 left: -20, 2160 opacity: 1 2161 }).hide(); 2162 var step = 1; 2163 if ($(this).closest('.quantityBtns').is('[data-stepslider]') && parseInt($(this).closest('.quantityBtns').attr('data-stepslider')) > 0) { 2164 step = parseInt($(this).closest('.quantityBtns').attr('data-stepslider')); 2165 } 2166 var isDisabled = false;
2167 $(this).slider({ 2168 min: min, 2169 max: parseInt($(this).closest('.quantityBtns').attr('data-max')), 2170 value: parseInt($(this).closest('.quantityBtns').next('.icon_quantity').html()), 2171 orientation: "horizontal", 2172 range: "min", 2173 disabled: isDisabled, 2174 step: step, 2175 change: function(event, ui) { 2176 tooltip.find('.tooltip-inner').html(ui.value); 2177 $(this).closest('.quantityBtns').next('.icon_quantity').html(ui.value); 2178 if (event.originalEvent) { 2179 lfb_updatePrice(formID, $(this).attr('data-itemid')); 2180 } 2181 }, 2182 slide: function(event, ui) { 2183 $(this).closest('.quantityBtns').next('.icon_quantity').html(ui.value); 2184 tooltip.find('.tooltip-inner').html(ui.value); 2185 if (event.originalEvent) { 2186 lfb_updatePrice(formID, $(this).attr('data-itemid')); 2187 } 2188 } 2189 }).find(".ui-slider-handle").append(tooltip).on('mouseenter', function() { 2190 tooltip.show(); 2191 }).on('mouseleave', function() { 2192 tooltip.hide(); 2193 }); 2194 }); 2195 if (!$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_visualEditing')) { 2196 lfb_loadStoredForm(form.formID); 2197 } 2198 lfb_initRichTextValues(form.formID); 2199 if (!$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_visualEditing')) { 2200 if (form.intro_enabled == '0') { 2201 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_btnFloatingSummary').css({ 2202 display: 'inline-block' 2203 }); 2204 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_btnSaveForm').css({ 2205 display: 'inline-block' 2206 }); 2207 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnStart,#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #startInfos').hide(); 2208 2209 if (form.showSteps != '2') { 2210 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice').fadeIn(500); 2211 } else { 2212 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice').hide(); 2213 } 2214 if (form.showSteps == 3) { 2215 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stepper').fadeIn(500); 2216 } 2217 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel').fadeIn(form.animationsSpeed, function() { 2218 if (!form.autoStart) { 2219 if (!$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_visualEditing')) { 2220 lfb_nextStep(form.formID); 2221 } 2222 } 2223 }); 2224 } 2225 } 2226 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_loader').fadeOut(); 2227 }); 2228 } 2229 2230 function lfb_replaceAllBackSlash(targetStr) { 2231 var index = targetStr.indexOf("\\"); 2232 while (index >= 0) { 2233 targetStr = targetStr.replace("\\", ""); 2234 index = targetStr.indexOf("\\"); 2235 } 2236 return targetStr; 2237 } 2238 2239 function lfb_shineBtn(formID, $canvas) { 2240 var form = lfb_getForm(formID); 2241 $canvas.attr({ 2242 width: $canvas.width(), 2243 height: $canvas.height() 2244 }); 2245 $canvas.css({ 2246 borderRadius: $canvas.parent().css('border-radius') 2247 }); 2248 var ctx = $canvas.get(0).getContext('2d'); 2249 ctx.clearRect(0, 0, $canvas.width(), $canvas.height()); 2250 var grd = ctx.createLinearGradient(0, 0, $canvas.width(), $canvas.height()); 2251 form.shineFxIndex += 0.08; 2252 if (form.shineFxIndex > 1) { 2253 ctx.clearRect(0, 0, $canvas.width(), $canvas.height()); 2254 form.shineFxIndex = 0; 2255 } else { 2256 var pos = form.shineFxIndex; 2257 var prevPos = pos - 0.1; 2258 if (prevPos < 0) { 2259 prevPos = 0; 2260 } 2261 var nextPos = pos + 0.1; 2262 if (nextPos > 1) { 2263 nextPos = 1; 2264 } 2265 grd.addColorStop(0, "transparent"); 2266 grd.addColorStop(prevPos, "rgba(255,255,255,0)"); 2267 grd.addColorStop(pos, "rgba(255,255,255,0.3)"); 2268 grd.addColorStop(nextPos, "rgba(255,255,255,0)"); 2269 grd.addColorStop(1, "rgba(255,255,255,0)"); 2270 ctx.fillStyle = grd; 2271 ctx.fillRect(0, 0, $canvas.width(), $canvas.height()); 2272 setTimeout(function() { 2273 lfb_shineBtn(formID, $canvas); 2274 }, 30); 2275 } 2276 } 2277 2278 function lfb_updateLayerImages(formID) { 2279 var form = lfb_getForm(formID); 2280 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_layeredImage').each(function() { 2281 var stepID = $(this).closest('.lfb_genSlide').attr('data-stepid'); 2282 var _stepID = parseInt(stepID); 2283 if (isNaN(_stepID)) { 2284 _stepID = 0; 2285 } 2286 2287 2288 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 2289 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 2290 lastAndCurrentSteps.push(parseInt(form.step)); 2291 }
2291 else if (form.step == 'final') { 2292 lastAndCurrentSteps.push('final'); 2293 } 2294 2295 $(this).find('img:not(.lfb_baseLayer)').each(function() { 2296 var conditions = lfb_replaceAllBackSlash($(this).attr('data-showconditions')); 2297 conditions = conditions.replace(/'/g, '"'); 2298 if (conditions.length > 0) { 2299 try { 2300 conditions = JSON.parse(conditions); 2301 var errors = lfb_checkConditions(conditions, formID, _stepID); 2302 var operator = $(this).attr('data-showconditionsoperator'); 2303 2304 2305 if ((operator == 'OR' && !errors.errorOR) || (operator != 'OR' && !errors.error)) { 2306 $(this).fadeIn(); 2307 } else { 2308 $(this).fadeOut(); 2309 } 2310 2311 } catch (e) { 2312 $(this).fadeIn(); 2313 } 2314 } else { 2315 $(this).fadeIn(); 2316 } 2317 }); 2318 }); 2319 } 2320 2321 function lfb_updateShowSteps(formID) { 2322 for (var i = 0; i < lfb_plannedSteps.length; i++) { 2323 var stepEl = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + lfb_plannedSteps[i] + '"]'); 2324 if (stepEl.is('[data-useshowconditions]')) { 2325 var conditions = lfb_replaceAllBackSlash(stepEl.attr('data-showconditions')); 2326 conditions = conditions.replace(/'/g, '"'); 2327 if (conditions != '') { 2328 try { 2329 conditions = JSON.parse(conditions); 2330 var errors = lfb_checkConditions(conditions, formID, parseInt(stepEl.attr('data-stepid'))); 2331 var operator = stepEl.attr('data-showconditionsoperator'); 2332 if ((operator == 'OR' && !errors.errorOR) || (operator != 'OR' && !errors.error)) { 2333 if (stepEl.is('.lfb_disabled')) { 2334 stepEl.css({ 2335 opacity: 0 2336 }); 2337 stepEl.removeClass('lfb_disabled'); 2338 } 2339 } else { 2340 if (!stepEl.is('.lfb_disabled')) { 2341 stepEl.addClass('lfb_disabled'); 2342 } 2343 } 2344 } catch (e) {} 2345 } 2346 } 2347 } 2348 2349 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-useshowconditions]').each(function() { 2350 2351 }); 2352 } 2353 2354 function lfb_updateShowItems(formID) { 2355 var form = lfb_getForm(formID); 2356 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 2357 var pricePreviousStep = 0; 2358 var singlePricePreviousStep = 0; 2359 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 2360 lastAndCurrentSteps.push(parseInt(form.step)); 2361 } else if (form.step == 'final') { 2362 lastAndCurrentSteps.push('final'); 2363 } 2364 2365 for (var o = 0; o < lastAndCurrentSteps.length; o++) { 2366 2367 var _stepID = lastAndCurrentSteps[o]; 2368 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + _stepID + '"] [data-useshowconditions]').each(function() { 2369 var conditions = lfb_replaceAllBackSlash($(this).attr('data-showconditions')); 2370 conditions = conditions.replace(/'/g, '"'); 2371 if (conditions != '') { 2372 try { 2373 conditions = JSON.parse(conditions); 2374 var errors = lfb_checkConditions(conditions, formID, _stepID); 2375 var operator = $(this).attr('data-showconditionsoperator'); 2376 if ((operator == 'OR' && !errors.errorOR) || (operator != 'OR' && !errors.error)) { 2377 if (($(this).is('.lfb_itemBloc') && $(this).is('.lfb_disabled')) || $(this).closest('.lfb_itemBloc').length > 0 && $(this).closest('.lfb_itemBloc').is('.lfb_disabled')) { 2378 2379 $(this).removeClass('lfb_disabled'); 2380 $(this).closest('.lfb_itemBloc').removeClass('lfb_disabled'); 2381 $(this).stop().animate({ 2382 opacity: 1 2383 }, 300); 2384 if ($(this).is('input.prechecked') && !$(this).is(':checked')) { 2385 lfb_itemClick($(this), false, formID); 2386 } 2387 if ($(this).is('.lfb_selectable.prechecked') && !$(this).is('.checked')) { 2388 lfb_itemClick($(this), false, formID); 2389 } 2390 if ($(this).is('.lfb_button.prechecked') && !$(this).is('.checked')) { 2391 lfb_itemClick($(this), false, formID); 2392 } 2393 if ($(this).is('input[type="text"]') || $(this).is('textarea')) { 2394 if ($(this).is('[data-initialvalue]')) { 2395 $(this).val($(this).attr('data-initialvalue')); 2396 } 2397 } 2398 2399 $(this).closest('.lfb_itemBloc').stop().fadeIn(100); 2400 } 2401 } else { 2402 if (!$(this).is('.lfb_disabled')) { 2403 $(this).css({ 2404 opacity: 1 2405 }); 2406 if ($(this).is(':checked')) { 2407 lfb_itemClick($(this), false, formID); 2408 } 2409 if ($(this).is('.checked')) { 2410 lfb_itemClick($(this), false, formID); 2411 } 2412 if ($(this).is('.lfb_dropzone')) { 2413 $(this).find('.dz-preview').remove(); 2414 } 2415 2416 $(this).addClass('lfb_disabled'); 2417 $(this).closest('.lfb_itemBloc').addClass('lfb_disabled'); 2418 $(this).stop().animate({ 2419 opacity: 0 2420 }, 300); 2421 $(this).closest('.lfb_itemBloc').stop().fadeOut(300); 2422 } 2423 } 2424 } catch (e) {} 2425 } 2426 }); 2427 } 2428 2429 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]:not(.lfb_visualEditing) .lfb_genSlide.lfb_activeStep:not(#finalSlide) .lfb_row').each(function() { 2430 var row = $(this); 2431 var chkColumns = false;
2432 $(this).find('.lfb_column').each(function() { 2433 var chkItem = false; 2434 if ($(this).find('.lfb_item:not(.lfb_disabled):not(.lfb-hidden)').length > 0) { 2435 chkItem = true; 2436 chkColumns = true; 2437 } 2438 if (!chkItem) { 2439 $(this).addClass('lfb-hidden'); 2440 } else { 2441 $(this).removeClass('lfb-hidden'); 2442 } 2443 }); 2444 if ($(this).children('.lfb_item:not(.lfb_disabled):not(.lfb-hidden)').length > 0) { 2445 chkColumns = true; 2446 } 2447 2448 if (!chkColumns) { 2449 $(this).addClass('lfb-hidden'); 2450 } else { 2451 $(this).removeClass('lfb-hidden'); 2452 2453 } 2454 }); 2455 setTimeout(function() { 2456 lfb_resize(form); 2457 2458 }, 200); 2459 } 2460 2461 function lfb_removeFile(formID, file) { 2462 var form = lfb_getForm(formID); 2463 jQuery.ajax({ 2464 url: form.ajaxurl, 2465 type: 'post', 2466 data: { 2467 action: 'lfb_removeFile', 2468 formSession: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-formsession'), 2469 file: file 2470 } 2471 }); 2472 } 2473 2474 function lfb_disablesThemeScripts() { 2475 var scriptsCheck = false; 2476 $('script').each(function() { 2477 if ((scriptsCheck)) { 2478 if ($(this).attr("src") && $(this).attr("src").indexOf("WP_Helper_Creator") > 0) {} else if ($(this).attr("src") && $(this).attr("src").indexOf("VisitorsTracker") > 0) {} else if ($(this).attr("src") && $(this).attr("src").indexOf("WP_Visual_Chat") > 0) {} else if ($(this).attr("src") && $(this).attr("src").indexOf("gravityforms") > 0) {} else { 2479 var scriptCt = this.innerText || this.textContent; 2480 if (scriptCt.indexOf('analytics') < 0 && $(this).parents('.gform_wrapper').length == 0) { 2481 $(this).attr("disabled", "disabled"); 2482 } 2483 } 2484 } 2485 if ($(this).attr("src") && $(this).attr("src").indexOf("lfb_form") > 0) { 2486 scriptsCheck = true; 2487 } 2488 2489 }); 2490 } 2491 2492 2493 function lfb_initGform(formID) { 2494 var form = lfb_getForm(formID); 2495 if (form.gravityFormID > 0) { 2496 form.gravitySent = false; 2497 form.gFormDesignCheck++; 2498 if (form.timer_gFormDesign) { 2499 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide').delay(100).animate({ 2500 opacity: 1 2501 }, 1000); 2502 } 2503 $('#gform_wrapper_' + form.gravityFormID + ' input[type=radio]').not('[data-toggle="radio"]').attr('data-toggle', 'radio'); 2504 $('#gform_wrapper_' + form.gravityFormID + ' .ginput_container input,#gform_wrapper_' + form.gravityFormID + ' .ginput_container select,#gform_wrapper_' + form.gravityFormID + ' .ginput_container textarea').attr('title', 'control'); 2505 $('#gform_wrapper_' + form.gravityFormID + ' .ginput_container input,#gform_wrapper_' + form.gravityFormID + ' .ginput_container textarea, #gform_wrapper_' + form.gravityFormID + ' .ginput_container select').not('[type=checkbox]').not('[type=radio]').not('[type=submit]').addClass('form-control'); 2506 $('#gform_wrapper_' + form.gravityFormID + ' .ginput_container').addClass('form-group'); 2507 $('#gform_wrapper_' + form.gravityFormID + ' .gform_button').attr('class', 'btn btn-wide btn-primary'); 2508 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper input[type="radio"]:not(.ready)').each(function() { 2509 $(this).addClass('ready'); 2510 var label = $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').html(); 2511 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').parent('li').css('display', 'inline-block'); 2512 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').append($(this)); 2513 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').addClass('radio'); 2514 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').prepend('<span class="icons"><span class="first-icon far fa-square"></span><span class="second-icon far fa-check-square"></span></span>'); 2515 if (!$('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').parent('li').next().is('br')) { 2516 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').parent('li').after('<br/>'); 2517 } 2518 if ($(this).is(':checked')) { 2519 $(this).trigger('click'); 2520 } 2521 }); 2522 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper input[type="checkbox"]:not(.ready)').each(function() { 2523 $(this).addClass('ready'); 2524 var label = $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').html(); 2525 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').parent('li').css('display', 'inline-block'); 2526 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').append($(this)); 2527 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').addClass('checkbox'); 2528 $(this).before('<span class="icons"><span class="first-icon far fa-square"></span><span class="second-icon far fa-check-square"></span></span>'); 2529 if (!$('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').parent('li').next().is('br')) { 2530 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label[for="' + $(this).attr('id') + '"]').parent('li').after('<br/>'); 2531 } 2532 2533 }); 2534 $('#gform_wrapper_' + form.gravityFormID + ' .gform_wrapper label.checkbox').each(function() { 2535 if ($(this).find('[type=checkbox]').length > 0) { 2536 $(this).find('[type=checkbox]').eq(1).remove(); 2537 } 2538 if ($(this).find('[type=checkbox]').is(':checked')) { 2539 $(this).find('[type=checkbox]').trigger('click'); 2540 } 2541 }); 2542 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length > 0) { 2543 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm #lfb_btnOrderPaypal').hide(); 2544 } 2545 $(' #gform_submit_button_' + form.gravityFormID).on('click', function(e) { 2546 if (!lfb_isSelectionMode(form.formID)) { 2547 if (!form.gravitySent) { 2548 form.gravitySent = true; 2549 $(this).addClass('anim'); 2550 form.gFormDesignCheck = 0; 2551 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide').delay(1000).animate({ 2552 opacity: 0 2553 }, 1000); 2554 var $this = $(this); 2555 setTimeout(function() {
2556 form.timer_gFormDesign = setTimeout(function() { 2557 lfb_initGform(formID); 2558 }, 2000); 2559 }, 1000); 2560 } 2561 } 2562 }); 2563 } 2564 } 2565 2566 2567 function lfb_initPrice(formID) { 2568 var form = lfb_getForm(formID); 2569 if (form.max_price > 0) { 2570 form.priceMax = form.max_price; 2571 } else { 2572 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide [data-price]').each(function() { 2573 if ($(this).data('price') && $(this).data('price') > 0) { 2574 if ($(this).find('.icon_quantity').length > 0) { 2575 var max = parseFloat($(this).find('.icon_quantity').html()); 2576 if (max > 10 && parseFloat($(this).data('price')) > 100) { 2577 max = 10; 2578 } else if (max > 30) { 2579 max = 30; 2580 } else { 2581 max = parseFloat($(this).find('.quantityBtns').data('max')); 2582 } 2583 if ($(this).data('operation') == '-' || $(this).data('operation') == '/') {} else { 2584 form.priceMax += parseFloat($(this).data('price')) * max; 2585 } 2586 } else if ($(this).find('.lfb_qtfield').length > 0) { 2587 var max = parseFloat($(this).find('.lfb_qtfield').val()); 2588 if (max > 10 && parseFloat($(this).data('price')) > 100) { 2589 max = 10; 2590 } else if (max > 30) { 2591 max = 30; 2592 } else { 2593 if (parseFloat($(this).find('.lfb_qtfield').attr('max').length > 0)) { 2594 max = parseFloat($(this).find('.lfb_qtfield').attr('max')); 2595 } else { 2596 max = 30; 2597 } 2598 } 2599 if ($(this).data('operation') == '-' || $(this).data('operation') == '/') {} else { 2600 form.priceMax += parseFloat($(this).data('price')) * max; 2601 } 2602 } else { 2603 if ($(this).data('operation') == '+') { 2604 form.priceMax += parseFloat($(this).data('price')); 2605 } 2606 } 2607 } 2608 }); 2609 form.priceMax += form.initialPrice; 2610 $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide [data-price][data-operation="x"]').each(function() { 2611 if ($(this).find('.icon_quantity').length > 0) { 2612 for (var i = 0; i < parseFloat($(this).find('.icon_quantity').html()); i++) { 2613 form.priceMax = form.priceMax + (form.priceMax * parseFloat($(this).data('price')) / 100); 2614 } 2615 } else { 2616 form.priceMax = form.priceMax + (form.priceMax * parseFloat($(this).data('price')) / 100); 2617 } 2618 }); 2619 } 2620 } 2621 2622 2623 function initFlatUI() { 2624 $('#lfb_form.lfb_bootstraped .input-group').on('focus', '.form-control', function() { 2625 $(this).closest('.input-group, .form-group').addClass('focus'); 2626 }).on('blur', '.form-control', function() { 2627 $(this).closest('.input-group, .form-group').removeClass('focus'); 2628 }); 2629 $("#lfb_form.lfb_bootstraped .pagination").on('click', "a", function() { 2630 $(this).parent().siblings("li").removeClass("active").end().addClass("active"); 2631 }); 2632 $("#lfb_form.lfb_bootstraped .btn-group").on('click', "a", function() { 2633 $(this).siblings().removeClass("active").end().addClass("active"); 2634 }); 2635 2636 $('#lfb_form.lfb_bootstraped [data-toggle="switch"][data-checkboxstyle="switch"]').wrap('<div class="switch" data-on-label="<i class=\'fas fa-check\'></i>" data-off-label="<i class=\'fas fa-times\'></i>" />').parent().bootstrapSwitch(); 2637 2638 $('#lfb_form.lfb_bootstraped [data-toggle="switch"][data-checkboxstyle="switch"]').on('change', function() { 2639 if (!$(this).is(':checked')) { 2640 $(this).removeClass('checked'); 2641 } 2642 }); 2643 $("#lfb_form.lfb_bootstraped input[type=checkbox][data-urltarget]").each(function() { 2644 $(this).on('change', function() { 2645 if (!lfb_isSelectionMode(0)) { 2646 if ($(this).is(':checked')) { 2647 if ($(this).is('[data-urltargetmode="_self"]')) { 2648 document.location.href = $(this).attr('data-urltarget'); 2649 } else { 2650 var win = window.open($(this).attr('data-urltarget'), '_blank'); 2651 if (typeof(win) !== 'null' && win != null) { 2652 win.focus(); 2653 } 2654 } 2655 } 2656 } 2657 }); 2658 }); 2659 if ($("#lfb_form.lfb_bootstraped .lfb_selectpicker").length > 0) { 2660 $("#lfb_form.lfb_bootstraped .lfb_selectpicker").selectpicker(); 2661 $("#lfb_form.lfb_bootstraped .lfb_selectpicker").each(function() { 2662 $(this).closest('.lfb_itemBloc').find('.btn-group.lfb_bootstrap-select').attr('data-originaltitle', $(this).attr('data-originaltitle')); 2663 $(this).closest('.lfb_itemBloc').find('.btn-group.lfb_bootstrap-select').attr('data-bs-original-title', $(this).attr('data-bs-original-title')); 2664 $(this).closest('.lfb_itemBloc').find('.btn-group.lfb_bootstrap-select').attr('data-tooltiptext', $(this).attr('data-tooltiptext')); 2665 $(this).closest('.lfb_itemBloc').find('.btn-group.lfb_bootstrap-select').attr('data-tooltipimg', $(this).attr('data-tooltipimg')); 2666 $(this).closest('.lfb_itemBloc').find('.btn-group.lfb_bootstrap-select').attr('data-toggle', $(this).attr('data-toggle')); 2667 $(this).closest('.lfb_itemBloc').find('.btn-group.lfb_bootstrap-select').attr('data-placement', $(this).attr('data-placement')); 2668 }); 2669 } 2670 2671 $('#lfb_form .input-group-addon').on('click', function() { 2672 $(this).next('input').trigger('focus'); 2673 }); 2674 2675 $('#lfb_form .form-control.lfb_customQtSelector').each(function() {
2676 const $container = $('<div class="lfb_numberFieldQtSelectorContainer"></div>'); 2677 $(this).wrap($container); 2678 const btnLess = $('<a href="javascript:" class="lfb_numberFieldQtSelector" data-lfbdirection="-">-</a>'); 2679 btnLess.insertBefore($(this)); 2680 const btnPlus = $('<a href="javascript:" class="lfb_numberFieldQtSelector" data-lfbdirection="+">+</a>'); 2681 btnPlus.insertAfter($(this)); 2682 2683 btnPlus.on('click', function() { 2684 var formID = $(this).closest('#lfb_form').attr('data-form'); 2685 if (typeof(btnLess.data('incrementInterval')) != 'undefined') { 2686 clearInterval(btnLess.data('incrementInterval')); 2687 } 2688 if (typeof(btnPlus.data('incrementInterval')) != 'undefined') { 2689 clearInterval(btnPlus.data('incrementInterval')); 2690 } 2691 var newValue = parseFloat($(this).parent().find('input').val()) + 1; 2692 if ($(this).parent().find('input').attr('max') && newValue > parseFloat($(this).parent().find('input').attr('max'))) { 2693 newValue = parseFloat($(this).parent().find('input').attr('max')); 2694 } 2695 if ($(this).parent().find('input').attr('min') && newValue < parseFloat($(this).parent().find('input').attr('min'))) { 2696 newValue = parseFloat($(this).parent().find('input').attr('min')); 2697 } 2698 $(this).parent().find('input').val(newValue); 2699 lfb_updatePrice(formID); 2700 }); 2701 2702 btnLess.on('click', function() { 2703 var formID = $(this).closest('#lfb_form').attr('data-form'); 2704 2705 if (typeof(btnLess.data('incrementInterval')) != 'undefined') { 2706 clearInterval(btnLess.data('incrementInterval')); 2707 } 2708 if (typeof(btnPlus.data('incrementInterval')) != 'undefined') { 2709 clearInterval(btnPlus.data('incrementInterval')); 2710 } 2711 var newValue = parseFloat($(this).parent().find('input').val()) - 1; 2712 if ($(this).parent().find('input').attr('max') && newValue > parseFloat($(this).parent().find('input').attr('max'))) { 2713 newValue = parseFloat($(this).parent().find('input').attr('max')); 2714 } 2715 if ($(this).parent().find('input').attr('min') && newValue < parseFloat($(this).parent().find('input').attr('min'))) { 2716 newValue = parseFloat($(this).parent().find('input').attr('min')); 2717 } 2718 $(this).parent().find('input').val(newValue); 2719 lfb_updatePrice(formID); 2720 }); 2721 }); 2722 2723 } 2724 2725 function lfb_getItemDataFromItem(form, itemID) { 2726 var itemData = false; 2727 var checkedItems = new Array(); 2728 var $itembloc = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_itemContainer_' + itemID); 2729 var stepID = $itembloc.closest('.lfb_genSlide').attr('data-stepid'); 2730 var $panel = $itembloc.closest('.lfb_genSlide'); 2731 var showSummary = true; 2732 if ($itembloc.is('.lfb_disabled')) { 2733 2734 var itemID = $itembloc.find('[data-itemid]').attr('data-itemid'); 2735 form.itemsData = jQuery.grep(form.itemsData, function(exItem) { 2736 return exItem.itemid != itemID; 2737 }); 2738 2739 2740 } else { 2741 if ($itembloc.find('div.lfb_selectable.checked').length > 0) { 2742 var itemSelf = $itembloc.find('div.lfb_selectable.checked').get(0); 2743 var quantityText = ''; 2744 if ($(itemSelf).is('[data-resqt]')) { 2745 $(itemSelf).data('resqt', $(itemSelf).attr('data-resqt')); 2746 } 2747 if ($(itemSelf).is('[data-resprice]')) { 2748 $(itemSelf).data('resprice', $(itemSelf).attr('data-resprice')); 2749 } 2750 2751 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 2752 showSummary = false;
2753 } 2754 2755 var quantity = parseFloat($(itemSelf).data('resqt')); 2756 var priceItem = parseFloat($(itemSelf).data('resprice')); 2757 if (quantity == 0) { 2758 quantity = 1; 2759 } 2760 if (quantity > 1) { 2761 quantityText = quantity + 'x '; 2762 } 2763 if ($(itemSelf).data('price')) { 2764 if ($(itemSelf).data('operation') == "+") { 2765 if (form.currencyPosition == 'left') { 2766 priceItem = form.currency + priceItem; 2767 } else { 2768 priceItem += form.currency; 2769 } 2770 } else if ($(itemSelf).data('operation') == "-") { 2771 if (form.currencyPosition == 'left') { 2772 priceItem = '-' + form.currency + priceItem; 2773 } else { 2774 priceItem += '-' + form.currency; 2775 } 2776 } else if ($(itemSelf).data('operation') == "/") { 2777 priceItem = '-' + $(itemSelf).data('price') + '%'; 2778 } else { 2779 priceItem = '+' + $(itemSelf).data('price') + '%'; 2780 } 2781 2782 } 2783 var itemPriceS = parseFloat($(itemSelf).data('resprice')); 2784 if (isNaN(itemPriceS)) { 2785 itemPriceS = parseFloat($(itemSelf).data('price')); 2786 } 2787 var isSinglePrice = false; 2788 if ($(itemSelf).is('[data-singleprice="true"]')) { 2789 isSinglePrice = true; 2790 } 2791 2792 2793 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 2794 showSummary = false; 2795 } 2796 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 2797 checkedItems.push($(itemSelf).attr('data-itemid')); 2798 var label = $(itemSelf).attr('data-title'); 2799 if ($(itemSelf).is('[data-bs-original-title]') && $(itemSelf).is('[data-reducqt]')) { 2800 label = $(itemSelf).attr('data-bs-original-title'); 2801 } 2802 if ($(itemSelf).is('[data-originaltitle]') && $(itemSelf).is('[data-showprice="1"]')) { 2803 label = $(itemSelf).attr('data-originaltitle'); 2804 } 2805 if ($(itemSelf).is('[data-originallabel]')) { 2806 label = $(itemSelf).attr('data-originallabel'); 2807 } 2808 2809 itemData = { 2810 label: label, 2811 type: $itembloc.attr('data-itemtype'), 2812 itemid: $(itemSelf).attr('data-itemid'), 2813 price: itemPriceS, 2814 quantity: quantity, 2815 step: $panel.attr('data-title'), 2816 stepid: stepID, 2817 showInSummary: showSummary, 2818 isSinglePrice: isSinglePrice, 2819 image: $(itemSelf).find('.img').attr('src') 2820 }; 2821 } 2822 } 2823 if ($itembloc.find('a.lfb_button.checked').length > 0) { 2824 var itemSelf = $itembloc.find('a.lfb_button.checked').get(0); 2825 var priceItem = parseFloat($(itemSelf).data('price')); 2826 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 2827 showSummary = false; 2828 } 2829 if ($(itemSelf).data('price')) { 2830 2831 if ($(itemSelf).data('operation') == "+") { 2832 if (form.currencyPosition == 'left') { 2833 priceItem = form.currency + priceItem; 2834 } else { 2835 priceItem += form.currency; 2836 } 2837 } else if ($(itemSelf).data('operation') == "-") { 2838 if (form.currencyPosition == 'left') { 2839 priceItem = '-' + form.currency + priceItem; 2840 } else { 2841 priceItem += '-' + form.currency; 2842 } 2843 } else if ($(itemSelf).data('operation') == "/") { 2844 priceItem = '-' + priceItem + '%'; 2845 } else { 2846 priceItem = '+' + priceItem + '%'; 2847 } 2848 var title = $(itemSelf).attr('data-originaltitle'); 2849 if ($(itemSelf).is('select')) { 2850 title += ' (' + $(itemSelf).val() + ')'; 2851 } 2852 2853 } else { 2854 var title = $(itemSelf).attr('data-originaltitle'); 2855 if ($(itemSelf).is('select')) { 2856 title += ' : ' + $(itemSelf).val() + ''; 2857 } 2858 2859 } 2860 var label = $(itemSelf).attr('data-title'); 2861 if ($(itemSelf).is('[data-originaltitle]') && $(itemSelf).is('[data-showprice="1"]')) { 2862 label = $(itemSelf).attr('data-originaltitle'); 2863 } 2864 if ($(itemSelf).is('[data-originallabel]')) { 2865 label = $(itemSelf).attr('data-originallabel'); 2866 } 2867 if ($(itemSelf).is('select')) { 2868 label += ' : ' + $(itemSelf).val(); 2869 } 2870 2871 var isSinglePrice = false;
2872 if ($(itemSelf).is('[data-singleprice="true"]')) { 2873 isSinglePrice = true; 2874 } 2875 2876 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 2877 showSummary = false; 2878 } 2879 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 2880 checkedItems.push($(itemSelf).attr('data-itemid')); 2881 itemData = { 2882 label: label, 2883 itemid: $(itemSelf).attr('data-itemid'), 2884 type: $itembloc.attr('data-itemtype'), 2885 price: parseFloat($(itemSelf).data('resprice')), 2886 quantity: 1, 2887 step: $panel.attr('data-title'), 2888 stepid: stepID, 2889 showInSummary: showSummary, 2890 isSinglePrice: isSinglePrice 2891 }; 2892 } 2893 } 2894 if ($itembloc.find('input[type=checkbox]:checked').length > 0) { 2895 var itemSelf = $itembloc.find('input[type=checkbox]:checked').get(0); 2896 var priceItem = parseFloat($(itemSelf).data('price')); 2897 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 2898 showSummary = false; 2899 } 2900 if ($(itemSelf).data('price')) { 2901 2902 if ($(itemSelf).data('operation') == "+") { 2903 if (form.currencyPosition == 'left') { 2904 priceItem = form.currency + priceItem; 2905 } else { 2906 priceItem += form.currency; 2907 } 2908 } else if ($(itemSelf).data('operation') == "-") { 2909 if (form.currencyPosition == 'left') { 2910 priceItem = '-' + form.currency + priceItem; 2911 } else { 2912 priceItem += '-' + form.currency; 2913 } 2914 } else if ($(itemSelf).data('operation') == "/") { 2915 priceItem = '-' + priceItem + '%'; 2916 } else { 2917 priceItem = '+' + priceItem + '%'; 2918 } 2919 var title = $(itemSelf).attr('data-originaltitle'); 2920 if ($(itemSelf).is('select')) { 2921 title += ' (' + $(itemSelf).val() + ')'; 2922 } 2923 2924 } else { 2925 var title = $(itemSelf).attr('data-originaltitle'); 2926 if ($(itemSelf).is('select')) { 2927 title += ' : ' + $(itemSelf).val() + ''; 2928 } 2929 2930 } 2931 var label = $(itemSelf).attr('data-title'); 2932 if ($(itemSelf).is('[data-originaltitle]') && $(itemSelf).is('[data-showprice="1"]')) { 2933 label = $(itemSelf).attr('data-originaltitle'); 2934 } 2935 if ($(itemSelf).is('[data-originallabel]')) { 2936 label = $(itemSelf).attr('data-originallabel'); 2937 } 2938 if ($(itemSelf).is('select')) { 2939 label += ' : ' + $(itemSelf).val(); 2940 } 2941 2942 var isSinglePrice = false; 2943 if ($(itemSelf).is('[data-singleprice="true"]')) { 2944 isSinglePrice = true; 2945 } 2946 2947 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 2948 showSummary = false; 2949 } 2950 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 2951 checkedItems.push($(itemSelf).attr('data-itemid')); 2952 itemData = { 2953 label: label, 2954 itemid: $(itemSelf).attr('data-itemid'), 2955 type: $itembloc.attr('data-itemtype'), 2956 price: parseFloat($(itemSelf).data('resprice')), 2957 quantity: 1, 2958 step: $panel.attr('data-title'), 2959 stepid: stepID, 2960 showInSummary: showSummary, 2961 isSinglePrice: isSinglePrice 2962 }; 2963 } 2964 } 2965 if ($itembloc.is('.lfb_richtext') && !$itembloc.is('.lfb_shortcode')) { 2966 var itemSelf = $itembloc.get(0); 2967 2968 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 2969 showSummary = false;
2970 } 2971 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 2972 checkedItems.push($(itemSelf).attr('data-itemid')); 2973 itemData = { 2974 label: $(itemSelf).attr('data-title'), 2975 itemid: $(itemSelf).attr('data-itemid'), 2976 type: $itembloc.attr('data-itemtype'), 2977 value: $(itemSelf).html(), 2978 step: $panel.attr('data-title'), 2979 stepid: stepID, 2980 showInSummary: showSummary 2981 }; 2982 } 2983 2984 } 2985 if ($itembloc.find('div[data-type="slider"][data-itemid].lfb_range').length > 0) { 2986 var itemSelf = $itembloc.find('div[data-type="slider"]').get(0); 2987 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 2988 showSummary = false; 2989 } 2990 var minValue = parseFloat($(itemSelf).slider("values")[0]); 2991 var maxValue = parseFloat($(itemSelf).slider("values")[1]); 2992 2993 var label = $(itemSelf).attr('data-title'); 2994 if ($(itemSelf).is('[data-originaltitle]') && $(itemSelf).is('[data-showprice="1"]')) { 2995 label = $(itemSelf).attr('data-originaltitle'); 2996 } 2997 if ($(itemSelf).is('[data-originallabel]')) { 2998 label = $(itemSelf).attr('data-originallabel'); 2999 } 3000 3001 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 3002 showSummary = false; 3003 } 3004 3005 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3006 checkedItems.push($(itemSelf).attr('data-itemid')); 3007 itemData = { 3008 label: label, 3009 itemid: $(itemSelf).attr('data-itemid'), 3010 type: $itembloc.attr('data-itemtype'), 3011 price: 0, 3012 quantity: 0, 3013 step: $panel.attr('data-title'), 3014 stepid: stepID, 3015 showInSummary: showSummary, 3016 isSinglePrice: false, 3017 value: minValue + ' - ' + maxValue, 3018 minValue: minValue, 3019 maxValue: maxValue 3020 }; 3021 } 3022 } 3023 if ($itembloc.find('div[data-type="slider"][data-itemid]:not(.lfb_range)').length > 0) { 3024 var itemSelf = $itembloc.find('div[data-type="slider"]').get(0); 3025 var priceItem = parseFloat($(itemSelf).data('price')); 3026 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3027 showSummary = false; 3028 } 3029 3030 var quantity = parseFloat($(itemSelf).slider('value')); 3031 if (quantity == 0) { 3032 quantity = 1; 3033 } 3034 if (quantity > 1) { 3035 quantityText = quantity + 'x '; 3036 } 3037 3038 if ($(itemSelf).data('price')) { 3039 if ($(itemSelf).data('operation') == "+") { 3040 if (form.currencyPosition == 'left') { 3041 priceItem = form.currency + priceItem; 3042 } else { 3043 priceItem += form.currency; 3044 } 3045 } else if ($(itemSelf).data('operation') == "-") { 3046 if (form.currencyPosition == 'left') { 3047 priceItem = '-' + form.currency + priceItem; 3048 } else { 3049 priceItem += '-' + form.currency; 3050 } 3051 } else if ($(itemSelf).data('operation') == "/") { 3052 priceItem = '-' + priceItem + '%'; 3053 } else { 3054 priceItem = '+' + priceItem + '%'; 3055 } 3056 var title = $(itemSelf).attr('data-originaltitle'); 3057 if ($(itemSelf).is('select')) { 3058 title += ' (' + $(itemSelf).val() + ')'; 3059 } 3060 3061 3062 } else { 3063 var title = $(itemSelf).attr('data-originaltitle'); 3064 if ($(itemSelf).is('select')) { 3065 title += ' : ' + $(itemSelf).val() + ''; 3066 } 3067 3068 } 3069 var label = $(itemSelf).attr('data-title'); 3070 if ($(itemSelf).is('[data-originaltitle]') && $(itemSelf).is('[data-showprice="1"]')) { 3071 label = $(itemSelf).attr('data-originaltitle'); 3072 } 3073 if ($(itemSelf).is('[data-originallabel]')) { 3074 label = $(itemSelf).attr('data-originallabel'); 3075 } 3076 if ($(itemSelf).is('select')) { 3077 label += ' : ' + $(itemSelf).val(); 3078 } 3079 3080 var isSinglePrice = false;
3081 if ($(itemSelf).is('[data-singleprice="true"]')) { 3082 isSinglePrice = true; 3083 } 3084 3085 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 3086 showSummary = false; 3087 } 3088 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3089 checkedItems.push($(itemSelf).attr('data-itemid')); 3090 itemData = { 3091 label: label, 3092 itemid: $(itemSelf).attr('data-itemid'), 3093 type: $itembloc.attr('data-itemtype'), 3094 price: parseFloat($(itemSelf).data('resprice')), 3095 quantity: parseFloat($(itemSelf).slider('value')), 3096 step: $panel.attr('data-title'), 3097 stepid: stepID, 3098 showInSummary: showSummary, 3099 isSinglePrice: isSinglePrice 3100 }; 3101 } 3102 } 3103 if ($itembloc.find('select[data-itemid]').length > 0) { 3104 var itemSelf = $itembloc.find('select[data-itemid]').get(0); 3105 var priceItem = parseFloat($(itemSelf).data('price')); 3106 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3107 showSummary = false; 3108 } 3109 if ($(itemSelf).data('price') && $(itemSelf).data('price') > 0) { 3110 if ($(itemSelf).data('operation') == "+") { 3111 if (form.currencyPosition == 'left') { 3112 priceItem = form.currency + priceItem; 3113 } else { 3114 priceItem += form.currency; 3115 } 3116 } else if ($(itemSelf).data('operation') == "-") { 3117 if (form.currencyPosition == 'left') { 3118 priceItem = '-' + form.currency + priceItem; 3119 } else { 3120 priceItem += '-' + form.currency; 3121 } 3122 } else if ($(itemSelf).data('operation') == "/") { 3123 priceItem = '-' + priceItem + '%'; 3124 } else { 3125 priceItem = '+' + priceItem + '%'; 3126 } 3127 var title = $(itemSelf).attr('data-originaltitle'); 3128 if ($(itemSelf).is('select')) { 3129 title += ' (' + $(itemSelf).val() + ')'; 3130 } 3131 3132 } else { 3133 var title = $(itemSelf).attr('data-originaltitle'); 3134 if ($(itemSelf).is('select')) { 3135 title += ' : ' + $(itemSelf).val() + ''; 3136 } 3137 3138 } 3139 var label = $(itemSelf).attr('data-title'); 3140 3141 if ($(itemSelf).is('[data-originallabel]')) { 3142 label = $(itemSelf).attr('data-originallabel'); 3143 } 3144 var isSinglePrice = false; 3145 if ($(itemSelf).is('[data-singleprice="true"]')) { 3146 isSinglePrice = true; 3147 } 3148 3149 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 3150 showSummary = false; 3151 } 3152 var valueSelect = $(itemSelf).val(); 3153 if (valueSelect == null) { 3154 valueSelect = ''; 3155 } 3156 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3157 checkedItems.push($(itemSelf).attr('data-itemid')); 3158 itemData = { 3159 label: label, 3160 itemid: $(itemSelf).attr('data-itemid'), 3161 type: $itembloc.attr('data-itemtype'), 3162 price: parseFloat($(itemSelf).data('resprice')), 3163 value: valueSelect, 3164 quantity: 1, 3165 step: $panel.attr('data-title'), 3166 stepid: stepID, 3167 showInSummary: showSummary, 3168 isSinglePrice: isSinglePrice 3169 }; 3170 } 3171 } 3172 if ($itembloc.find('input[type=file]').length > 0) { 3173 var itemSelf = $itembloc.find('input[type=file]').get(0); 3174 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3175 showSummary = false;
3176 } 3177 3178 var label = $(itemSelf).data("title"); 3179 if ($(itemSelf).is('[data-originallabel]')) { 3180 label = $(itemSelf).attr('data-originallabel'); 3181 } 3182 3183 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 3184 showSummary = false; 3185 } 3186 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3187 checkedItems.push($(itemSelf).attr('data-itemid')); 3188 itemData = { 3189 label: label, 3190 itemid: $(itemSelf).attr('data-itemid'), 3191 type: $itembloc.attr('data-itemtype'), 3192 value: $(itemSelf).val(), 3193 step: $panel.attr('data-title'), 3194 stepid: stepID, 3195 showInSummary: showSummary, 3196 isFile: true 3197 }; 3198 } 3199 3200 } 3201 if ($itembloc.find('.lfb_dropzone').length > 0) { 3202 var itemSelf = $itembloc.find('.lfb_dropzone').get(0); 3203 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3204 showSummary = false; 3205 } 3206 var filesValue = ''; 3207 var filesValueG = ''; 3208 var files = new Array(); 3209 $(itemSelf).find('.dz-preview[data-file]:not(.dz-error)').each(function() { 3210 files.push($(this).attr('data-file').replace(/ /g, '_')); 3211 3212 if (form.emailCustomerLinks == 1) { 3213 filesValue += ' - <a href="' + $(this).attr('data-url') + '">' + $(this).attr('data-file').replace(/ /g, '_') + '</a><br/>'; 3214 filesValueG += ' - ' + $(this).attr('data-url') + '\n'; 3215 } else { 3216 filesValue += ' - <span class="lfb_file">' + $(this).attr('data-file').replace(/ /g, '_') + '</span>' + "<br/>"; 3217 filesValueG += ' - ' + $(this).attr('data-file').replace(/ /g, '_') + '\n'; 3218 } 3219 }); 3220 3221 var label = $(itemSelf).data("title"); 3222 if ($(itemSelf).is('[data-originallabel]')) { 3223 label = $(itemSelf).attr('data-originallabel'); 3224 } 3225 if (files.length > 0) { 3226 3227 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 3228 showSummary = false; 3229 } 3230 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3231 checkedItems.push($(itemSelf).attr('data-itemid')); 3232 itemData = { 3233 label: label, 3234 itemid: $(itemSelf).attr('data-itemid'), 3235 type: $itembloc.attr('data-itemtype'), 3236 value: filesValue, 3237 step: $panel.attr('data-title'), 3238 stepid: stepID, 3239 showInSummary: showSummary, 3240 isFile: true, 3241 files: files 3242 }; 3243 } 3244 } 3245 3246 } 3247 if ($itembloc.find('input[type=text][data-itemid]:not(.lfb_colorpicker)').length > 0) { 3248 var itemSelf = $itembloc.find('input[type=text]:not(.lfb_colorpicker)').get(0); 3249 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3250 showSummary = false; 3251 } 3252 3253 3254 var label = $(itemSelf).data("title"); 3255 if ($(itemSelf).is('[data-originallabel]')) { 3256 label = $(itemSelf).attr('data-originallabel'); 3257 } 3258 3259 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 3260 showSummary = false; 3261 } 3262 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3263 checkedItems.push($(itemSelf).attr('data-itemid')); 3264 itemData = { 3265 label: label, 3266 itemid: $(itemSelf).attr('data-itemid'), 3267 type: $itembloc.attr('data-itemtype'), 3268 value: $(itemSelf).val(), 3269 step: $panel.attr('data-title'), 3270 stepid: stepID, 3271 showInSummary: showSummary 3272 }; 3273 } 3274 } 3275 if ($itembloc.find('input[type=number][data-itemid]:not(.lfb_colorpicker)').length > 0) { 3276 var itemSelf = $itembloc.find('input[type=number]:not(.lfb_colorpicker)').get(0); 3277 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3278 showSummary = false;
3279 } 3280 var quantity = parseFloat($(itemSelf).val()); 3281 quantityText = quantity + 'x '; 3282 3283 3284 3285 var fieldVal = $(itemSelf).val(); 3286 var fieldQt = undefined; 3287 var itemPriceS = undefined; 3288 if ($(itemSelf).is('[data-valueasqt="1"]')) { 3289 fieldVal = undefined; 3290 fieldQt = parseFloat($(itemSelf).val()); 3291 itemPriceS = parseFloat($(itemSelf).data('resprice')); 3292 if (isNaN(itemPriceS)) { 3293 itemPriceS = parseFloat($(itemSelf).data('price')); 3294 } 3295 } 3296 var isSinglePrice = false; 3297 if ($(itemSelf).is('[data-singleprice="true"]')) { 3298 isSinglePrice = true; 3299 } 3300 var label = $(itemSelf).data("title"); 3301 if ($(itemSelf).is('[data-originallabel]')) { 3302 label = $(itemSelf).attr('data-originallabel'); 3303 } 3304 3305 if ($(itemSelf).is('[data-hidezeropricesum="true"]') && itemPriceS == 0) { 3306 showSummary = false; 3307 } 3308 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3309 checkedItems.push($(itemSelf).attr('data-itemid')); 3310 itemData = { 3311 label: label, 3312 itemid: $(itemSelf).attr('data-itemid'), 3313 type: $itembloc.attr('data-itemtype'), 3314 value: fieldVal, 3315 quantity: fieldQt, 3316 price: itemPriceS, 3317 step: $panel.attr('data-title'), 3318 stepid: stepID, 3319 showInSummary: showSummary, 3320 isSinglePrice: isSinglePrice 3321 }; 3322 } 3323 } 3324 if ($itembloc.find('.lfb_colorPreview').length > 0) { 3325 var itemSelf = $itembloc.find('.lfb_colorPreview').get(0); 3326 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3327 showSummary = false; 3328 } 3329 3330 var label = $(itemSelf).data("title"); 3331 if ($(itemSelf).is('[data-originallabel]')) { 3332 label = $(itemSelf).attr('data-originallabel'); 3333 } 3334 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3335 checkedItems.push($(itemSelf).attr('data-itemid')); 3336 itemData = { 3337 label: label, 3338 itemid: $(itemSelf).attr('data-itemid'), 3339 type: $itembloc.attr('data-itemtype'), 3340 value: $(itemSelf).next('.lfb_colorpicker').val(), 3341 step: $panel.attr('data-title'), 3342 stepid: stepID, 3343 showInSummary: showSummary 3344 }; 3345 } 3346 } 3347 if ($itembloc.find('textarea').length > 0) { 3348 var itemSelf = $itembloc.find('textarea').get(0); 3349 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3350 showSummary = false; 3351 } 3352 3353 var label = $(itemSelf).data("title"); 3354 if ($(itemSelf).is('[data-originallabel]')) { 3355 label = $(itemSelf).attr('data-originallabel'); 3356 } 3357 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3358 checkedItems.push($(itemSelf).attr('data-itemid')); 3359 itemData = { 3360 label: label, 3361 itemid: $(itemSelf).attr('data-itemid'), 3362 type: $itembloc.attr('data-itemtype'), 3363 value: lfb_nl2br($(itemSelf).val()), 3364 step: $panel.attr('data-title'), 3365 stepid: stepID, 3366 showInSummary: showSummary 3367 }; 3368 } 3369 } 3370 if ($itembloc.find('.lfb_rate').length > 0) { 3371 var itemSelf = $itembloc.get(0); 3372 if ($panel.is('[data-showstepsum="0"]') || !$(itemSelf).is('[data-showinsummary="true"]')) { 3373 showSummary = false;
3374 } 3375 var label = $(itemSelf).data("title"); 3376 if ($(itemSelf).is('[data-originallabel]')) { 3377 label = $(itemSelf).attr('data-originallabel'); 3378 } 3379 if (jQuery.inArray($(itemSelf).attr('data-itemid'), checkedItems) == -1) { 3380 checkedItems.push($(itemSelf).attr('data-itemid')); 3381 itemData = { 3382 label: label, 3383 itemid: $(itemSelf).attr('data-itemid'), 3384 type: $itembloc.attr('data-itemtype'), 3385 value: $itembloc.find('.lfb_rate').rate('getValue'), 3386 step: $panel.attr('data-title'), 3387 stepid: stepID, 3388 showInSummary: showSummary 3389 }; 3390 } 3391 } 3392 3393 if (itemData) { 3394 if ($itembloc.find('[data-showprice="0"]').length > 0) { 3395 itemData.showPrice = false; 3396 } else { 3397 itemData.showPrice = true; 3398 } 3399 } 3400 } 3401 return itemData; 3402 } 3403 3404 function lfb_updateItemData(form, itemID) { 3405 var exItemData = false; 3406 var exItemIndex = -1; 3407 for (var i = 0; i < form.itemsData.length; i++) { 3408 if (form.itemsData[i].itemid == itemID) { 3409 exItemData = form.itemsData[i]; 3410 exItemIndex = i; 3411 break; 3412 } 3413 } 3414 3415 var $itembloc = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_itemContainer_' + itemID); 3416 if ($itembloc.is('.lfb_disabled')) { 3417 if (exItemData) { 3418 form.itemsData = jQuery.grep(form.itemsData, function(exItem) { 3419 return exItem.itemid != itemID; 3420 }); 3421 } 3422 } else { 3423 var itemData = lfb_getItemDataFromItem(form, itemID); 3424 if (exItemData) { 3425 form.itemsData[exItemIndex] = itemData; 3426 } else { 3427 form.itemsData.push(itemData); 3428 } 3429 } 3430 } 3431 3432 3433 function lfb_getItemData(form, itemID) { 3434 var rep = false; 3435 for (var i = 0; i < form.itemsData.length; i++) { 3436 if (form.itemsData[i].itemid == itemID) { 3437 rep = form.itemsData[i]; 3438 if (rep && rep.stepid == form.step) { 3439 rep = lfb_getItemDataFromItem(form, itemID); 3440 } 3441 break; 3442 } 3443 } 3444 if (!rep) { 3445 rep = lfb_getItemDataFromItem(form, itemID); 3446 } 3447 return rep; 3448 } 3449 3450 function lfb_getFormContent(formID, useCurrent, onlyStepID) { 3451 var form = lfb_getForm(formID); 3452 var content = ""; 3453 var contentGform = ""; 3454 var totalTxt = ""; 3455 var items = new Array(); 3456 contentGform += "Ref : " + form.current_ref + " \n"; 3457 var lastStepTitle = ""; 3458 var cloneSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 3459 if (useCurrent) { 3460 if (form.step != 'final') { 3461 cloneSteps.push(form.step); 3462 } 3463 } 3464 if (form.step == 'final') { 3465 cloneSteps.push('final'); 3466 } 3467 if (typeof(onlyStepID) != 'undefined' && onlyStepID != 0) { 3468 cloneSteps = new Array(); 3469 cloneSteps.push(onlyStepID); 3470 } 3471 var checkedItems = new Array(); 3472 for (var o = 0; o < cloneSteps.length; o++) { 3473 var _stepID = cloneSteps[o]; 3474 var $panel = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + _stepID + '"]'); 3475 if (($panel.attr('data-stepid') == 'final' || jQuery.inArray(parseInt($panel.attr('data-stepid')), lfb_plannedSteps) >= 0) && !$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-title][data-stepid="' + _stepID + '"]').is('.lfb_disabled')) { 3476 var stepID = $panel.attr('data-stepid'); 3477 if (stepID != 'final') { 3478 stepID = parseInt(stepID); 3479 } 3480 3481 3482 if (!$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('[data-sumhidesteps="1"]')) { 3483 content += "<br/><p><u><b>
3483" + $panel.attr("data-title") + " :</b></u></p><br/>"; 3484 contentGform += "\n\n---------" + $panel.attr("data-title") + " :---------\n"; 3485 } 3486 var stepsItemsData = new Array(); 3487 $panel.find('.lfb_itemBloc:not(.lfb_disabled)').each(function() { 3488 var _itemID = 0; 3489 if ($(this).find('[data-itemid]').length > 0) { 3490 _itemID = $(this).find('[data-itemid]').attr('data-itemid'); 3491 } else { 3492 _itemID = $(this).attr('data-itemid'); 3493 } 3494 if (checkedItems.indexOf(_itemID) == -1) { 3495 checkedItems.push(_itemID); 3496 var itemData = lfb_getItemData(form, _itemID); 3497 if (itemData) { 3498 items.push(itemData); 3499 stepsItemsData.push(itemData); 3500 } 3501 } 3502 }); 3503 3504 3505 for (var j = 0; j < stepsItemsData.length; j++) { 3506 3507 if (stepsItemsData[j].type != 'richtext' && stepsItemsData[j].showInSummary) { 3508 if (typeof(stepsItemsData[j].label) != 'undefined') { 3509 if (typeof(stepsItemsData[j].price) != 'undefined' && stepsItemsData[j].price != 0 && stepsItemsData[j].showPrice) { 3510 var itemPrice = lfb_formatPrice(parseFloat(stepsItemsData[j].price).toFixed(2), formID) + form.currency; 3511 if (form.currencyPosition == 'left') { 3512 itemPrice = form.currency + lfb_formatPrice(parseFloat(stepsItemsData[j].price).toFixed(2), formID); 3513 } 3514 3515 3516 if (typeof(stepsItemsData[j].value) != 'undefined') { 3517 3518 content += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].value + ' (' + itemPrice + ')<br/>'; 3519 contentGform += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].value + ' (' + itemPrice + ')\n'; 3520 } else 3521 if (typeof(stepsItemsData[j].quantity) != 'undefined' && stepsItemsData[j].quantity > 1) { 3522 content += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].quantity + ' (' + itemPrice + ')<br/>'; 3523 contentGform += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].quantity + ' (' + itemPrice + ')\n'; 3524 } else { 3525 content += ' - ' + stepsItemsData[j].label + ': ' + itemPrice + '<br/>'; 3526 contentGform += ' - ' + stepsItemsData[j].label + ': ' + itemPrice + '\n'; 3527 3528 } 3529 } else if (typeof(stepsItemsData[j].value) != 'undefined') { 3530 if (stepsItemsData[j].value != '') { 3531 content += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].value + '<br/>'; 3532 contentGform += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].value + '\n'; 3533 } 3534 } else if (typeof(stepsItemsData[j].quantity) != 'undefined' && stepsItemsData[j].quantity > 1) { 3535 content += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].quantity + '<br/>'; 3536 contentGform += ' - ' + stepsItemsData[j].label + ': ' + stepsItemsData[j].quantity + '\n'; 3537 } else { 3538 content += ' - ' + stepsItemsData[j].label + '<br/>'; 3539 contentGform += ' - ' + stepsItemsData[j].label + '\n'; 3540 3541 } 3542 } 3543 } 3544 } 3545 3546 } 3547 } 3548 if (!form.price || form.price < 0) { 3549 form.price = 0; 3550 } 3551 var pattern = /^\d+(\.\d{2})?$/; 3552 if (!pattern.test(form.price)) { 3553 form.price = parseFloat(form.price).toFixed(2); 3554 } 3555 if (form.discountCode != '') { 3556 if (form.reductionResult > 0) { 3557 var reduction = parseFloat(form.reductionResult).toFixed(2) + form.currency; 3558 if (form.currencyPosition == 'left') { 3559 reduction = form.currency + parseFloat(form.reductionResult).toFixed(2); 3560 } 3561 content += '<br/> Coupon : ' + form.discountCode + ' (' + reduction + ')'; 3562 3563 } else { 3564 3565 content += '<br/> Coupon : ' + form.discountCode; 3566 } 3567 } 3568 if (form.currencyPosition == 'left') { 3569 3570 totalTxt += form.currency + lfb_formatPrice(parseFloat(form.price).toFixed(2), formID); 3571 contentGform += '\n\nTotal : ' + form.currency + lfb_formatPrice(parseFloat(form.price).toFixed(2), formID); 3572 } else { 3573 totalTxt += lfb_formatPrice(parseFloat(form.price).toFixed(2), formID) + form.currency; 3574 contentGform += '\n\nTotal : ' + lfb_formatPrice(parseFloat(form.price).toFixed(2), formID) + form.currency; 3575 } 3576 return new Array(content, totalTxt, items, contentGform); 3577 } 3578 3579 function lfb_check_gform_response(formID) { 3580 var form = lfb_getForm(formID); 3581 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #gforms_confirmation_message').length > 0) { 3582 clearInterval(form.timer_gFormSubmit); 3583 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length > 0 && form.price > 0) { 3584 3585 var payPrice = form.price; 3586 if (form.payMode == 'percent') { 3587 payPrice = parseFloat(payPrice) * (parseFloat(form.percentToPay) / 100); 3588 } else if (form.payMode == 'fixed') { 3589 payPrice = parseFloat(form.fixedToPay); 3590 } 3591 payPrice = parseFloat(payPrice).toFixed(2); 3592 if (form.priceSingle > 0) { 3593 var payPriceSingle = form.priceSingle; 3594 if (form.payMode == 'percent') { 3595 payPriceSingle = parseFloat(payPriceSingle) * (parseFloat(form.percentToPay) / 100); 3596 } else if (form.payMode == 'fixed') { 3597 payPriceSingle = parseFloat(form.fixedToPay); 3598 } 3599 3600 3601 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a1]').length == 0) { 3602 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').append('<input type="hidden" name="a1" value="
36020">'); 3603 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').append('<input type="hidden" name="p1" value="1">'); 3604 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').append('<input type="hidden" name="t1" value="M">'); 3605 } 3606 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a1]').val(payPriceSingle); 3607 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p1]').val($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p3]').val()); 3608 } else { 3609 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a1]').remove(); 3610 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=t1]').remove(); 3611 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p1]').remove(); 3612 } 3613 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=amount]').val(payPrice); 3614 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a3]').val(payPrice); 3615 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=item_number]').val(form.current_ref); 3616 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=item_name]').val($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=item_name]').val() + ' - ' + form.current_ref); 3617 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [type="submit"]').trigger('click'); 3618 } else { 3619 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .gfield_error').length > 0) { 3620 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .gform_footer').show(); 3621 } 3622 $('#finalText').html($('#gform_wrapper_' + form.gravityFormID + ' .gforms_confirmation_message').html()); 3623 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide #gforms_confirmation_message').fadeIn(); 3624 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide #lfb_summary').fadeOut(); 3625 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide #lfb_couponContainer').fadeOut(); 3626 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide #lfb_legalNoticeContent').fadeOut(); 3627 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide .linkPrevious').fadeOut(); 3628 lfb_finalStep(formID); 3629 } 3630 } 3631 } 3632 3633 function lfb_quantity_less(btn, formID) { 3634 var $target = $(btn).parent().parent().find('.icon_quantity'); 3635 var min = parseFloat($(btn).parent().data('min')); 3636 var quantity = parseInt($target.html()); 3637 if (quantity > 1 && quantity > min) { 3638 quantity--; 3639 $target.html(quantity); 3640 lfb_updatePrice(formID); 3641 } 3642 } 3643 3644 function lfb_quantity_more(btn, formID) { 3645 var $target = $(btn).parent().parent().find('.icon_quantity'); 3646 var max = parseFloat($(btn).parent().data('max')); 3647 var quantity = parseFloat($target.html()); 3648 if (quantity < max || max == 0) { 3649 quantity++; 3650 $target.html(quantity); 3651 lfb_updatePrice(formID); 3652 } 3653 } 3654 3655 3656 function lfb_checkEmail(email) { 3657 return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) 3658 } 3659 3660 function lfb_isIframe() { 3661 try { 3662 return window.self !== window.top; 3663 } catch (e) { 3664 return true; 3665 } 3666 } 3667 3668 function lfb_cloneSummary(mode, formID) { 3669 var form = lfb_getForm(formID); 3670 var $summaryClone = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary').clone(); 3671 3672 const fieldsStyle = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').attr('data-stylefields'); 3673 3674 if ($summaryClone.find('#lfb_summaryDiscountTr').css('display') != 'table-row') { 3675 $summaryClone.find('#lfb_summaryDiscountTr').remove(); 3676 } 3677 if ($('body').is('.rtl')) { 3678 $summaryClone.css({ 3679 textAlign: 'right', 3680 direction: 'rtl' 3681 }); 3682 $summaryClone.find('table').css({ 3683 textAlign: 'right', 3684 direction: 'rtl' 3685 }); 3686 } 3687 $summaryClone.addClass('lfb-hidden'); 3688 $summaryClone.uniqueId(); 3689 var nbCols = 4; 3690 if (form.summary_showAllPricesEmail == '1') { 3691 $summaryClone.find('.lfb_hidePrice').removeClass('lfb_hidePrice').removeClass('lfb-hidden'); 3692 } 3693 3694 $summaryClone.find('thead th').each(function() { 3695 if ($(this).is('.lfb-hidden')) { 3696 nbCols--; 3697 } 3698 }); 3699 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary').after($summaryClone); 3700 $summaryClone.children('h4').remove(); 3701 $summaryClone.find('*:not(.lfb_value)').each(function() { 3702 $(this).css({ 3703 fontSize: $(this).css('font-size'), 3704 padding: $(this).css('padding'), 3705 textAlign: $(this).css('text-align'), 3706 lineHeight: $(this).css('line-height') 3707 }); 3708 }); 3709 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table thead > tr > th:eq(1)').is('.lfb-hidden')) { 3710 $summaryClone.find('table thead > tr > th:eq(1)').remove(); 3711 $summaryClone.find('table tbody td.lfb_valueTd').remove(); 3712 } 3713 $summaryClone.find('th.lfb_summaryStep').attr('align', 'center'); 3714 $summaryClone.find('table').attr('width', '90%'); 3715 $summaryClone.find('table').css('width', '90%'); 3716 $summaryClone.find('table').attr('border', '1'); 3717 $summaryClone.find('table').attr('bordercolor', lfb_rgb2hex($summaryClone.find('table').css('border-color'))); 3718 $summaryClone.find('table').attr('style', 'width:90%;margin:0 auto;'); 3719 $summaryClone.find('thead td, thead th').each(function() { 3720 if (fieldsStyle == 'glassmorphic') { 3721 $(this).attr('bgcolor', form.color_summaryTheadBg); 3722 $(this).css('background', form.color_summaryTheadBg); 3723 $(this).css('color', form.color_summaryTheadTxt); 3724 $(this).attr('color', form.color_summaryTheadTxt); 3725 } else { 3726 $(this).attr('bgcolor', lfb_rgb2hex($summaryClone.find('thead').css('background-color'))); 3727 $(this).css('background', lfb_rgb2hex($summaryClone.find('thead').css('background-color'))); 3728 } 3729 }); 3730 $summaryClone.find('tbody th').each(function() { 3731 if (fieldsStyle == 'glassmorphic') { 3732 $(this).attr('bgcolor', form.color_summaryStepBg); 3733 $(this).css('color', form.color_summaryStepTxt); 3734 $(this).attr('color', form.color_summaryStepTxt); 3735 } 3736 }); 3737 $summaryClone.find('th').each(function() { 3738 if (fieldsStyle != 'glassmorphic') { 3739 $(this).attr('bgcolor', lfb_rgb2hex($(this).css('background-color'))); 3740 } 3741 }); 3742 $summaryClone.find('td').each(function() { 3743 if (fieldsStyle == 'glassmorphic') { 3744 $(this).attr('bgcolor', form.color_summaryTbodyBg); 3745 $(this).css('color', form.color_summaryTbodyTxt); 3746 $(this).attr('color', form.color_summaryTbodyTxt); 3747 3748 } else { 3749 if ($(this).attr('style').indexOf('background-color') > -1 || $(this).attr('style').indexOf('background') > -1) { 3750 $(this).attr('bgcolor', lfb_rgb2hex($(this).css('background-color'))); 3751 } else { 3752 $(this).attr('bgcolor', lfb_rgb2hex($(this).closest('table').css('background-color'))); 3753 } 3754 } 3755 }); 3756 3757 if (fieldsStyle == 'glassmorphic') { 3758 $summaryClone.find('td,th').each(function() { 3759 $(this).html('<span style="color: ' + lfb_rgb2hex($(this).css('color')) + '; font-size: ' + $(this).css('font-size') + '">' + $(this).html() + '</span>'); 3760 }); 3761 } else { 3762 $summaryClone.find('td,th').each(function() { 3763 $(this).attr('color', lfb_rgb2hex($(this).css('color'))); 3764 $(this).html('<span style="color: ' + lfb_rgb2hex($(this).css('color')) + '; font-size: ' + $(this).css('font-size') + '">' + $(this).html() + '</span>'); 3765 }); 3766 } 3767 $summaryClone.find('table .lfb-hidden').remove(); 3768 $summaryClone.find('table').attr('cellspacing', '0'); 3769 $summaryClone.find('table').attr('cellpadding', '8'); 3770 $summaryClone.find('table').attr('bgcolor', '#FFFFFF'); 3771 $summaryClone.find('td,th').each(function() { 3772 $(this).attr('align', $(this).css('text-align')); 3773 $(this).css('padding', $(this).css('padding')); 3774 }); 3775 if (form.summary_showAllPricesEmail == '1') { 3776 $summaryClone.find('.lfb_summaryStep').attr('colspan', nbCols); 3777 $summaryClone.find('#lfb_summaryDiscountTr>th:eq(0),#lfb_summaryTotalTr>th:eq(0)').attr('colspan', nbCols - 1); 3778 } 3779 if (nbCols == 3) { 3780 $summaryClone.find('td:not(:first-child)').each(function() { 3781 $(this).attr('width', '164'); 3782 }); 3783 $summaryClone.find('th:not(:first-child)').each(function() { 3784 $(this).attr('width', '164'); 3785 }); 3786 $summaryClone.find('tr>td:first-child').each(function() { 3787 $(this).attr('width', '340'); 3788 }); 3789 $summaryClone.find('tr>th:first-child').each(function() { 3790 $(this).attr('width', '340'); 3791 }); 3792 } else if (nbCols == 2) { 3793 $summaryClone.find('td:not(:first-child)').each(function() { 3794 $(this).attr('width', '50%'); 3795 }); 3796 $summaryClone.find('th:not(:first-child)').each(function() { 3797 $(this).attr('width', '50%'); 3798 }); 3799 $summaryClone.find('tr>td:first-child').each(function() { 3800 $(this).attr('width', '50%'); 3801 }); 3802 $summaryClone.find('tr>th:first-child').each(function() { 3803 $(this).attr('width', '50%'); 3804 }); 3805 } else { 3806 3807 $summaryClone.find('td:not(:first-child)').each(function() { 3808 $(this).attr('width', '103'); 3809 }); 3810 $summaryClone.find('th:not(:first-child)').each(function() { 3811 $(this).attr('width', '103'); 3812 }); 3813 $summaryClone.find('tr>td:first-child').each(function() { 3814 $(this).attr('width', '332'); 3815 }); 3816 $summaryClone.find('tr>th:first-child').each(function() { 3817 $(this).attr('width', '332'); 3818 }); 3819 } 3820 $summaryClone.find('*:not(.lfb_value)').each(function() { 3821 var color = lfb_rgb2hex($(this).css('color')); 3822 $(this).css({ 3823 color: '' 3824 }); 3825 $(this).attr('style', $(this).attr('style') + ';color:' + color); 3826 if ($(this).attr('style').length > 0) { 3827 $(this).attr('style', $(this).attr('style') + ';color:' + color); 3828 } else { 3829 $(this).attr('style', 'color:' + color); 3830 } 3831 3832 }); 3833 3834 3835 $summaryClone.find('[data-tldinit]').removeAttr('data-tldinit'); 3836 $summaryClone.find('.lfb_file').each(function() { 3837 $(this).removeAttr('style'); 3838 $(this).removeAttr('data-tldinit'); 3839 }); 3840 $summaryClone.html('<div id="lfb_summaryCt" style="padding-top: 24px;padding-bottom: 24px; text-align: center;">' + $summaryClone.html() + '</div>'); 3841 return $summaryClone; 3842 } 3843 3844 function lfb_getContactInformations(formID, useJson) { 3845 if (useJson) { 3846 var rep = { 3847 email: '', 3848 phone: '', 3849 firstName: '', 3850 lastName: '', 3851 address: '', 3852 city: '', 3853 state: '', 3854 zip: '', 3855 country: '', 3856 job: '', 3857 phoneJob: '', 3858 url: '', 3859 company: '' 3860 }; 3861 } else { 3862 var rep = new Array(); 3863 rep['email'] = ''; 3864 rep['phone'] = ''; 3865 rep['firstName'] = ''; 3866 rep['lastName'] = '';
3867 rep['address'] = ''; 3868 rep['city'] = ''; 3869 rep['state'] = ''; 3870 rep['zip'] = ''; 3871 rep['country'] = ''; 3872 rep['job'] = ''; 3873 rep['phoneJob'] = ''; 3874 rep['url'] = ''; 3875 rep['company'] = ''; 3876 3877 } 3878 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="email"]').each(function() { 3879 if ($(this).val().length > 0 && lfb_checkEmail($(this).val())) { 3880 if (useJson) { 3881 rep.email = $(this).val(); 3882 } else { 3883 rep['email'] = $(this).val(); 3884 } 3885 } 3886 }); 3887 var phone = ''; 3888 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="phone"]').each(function() { 3889 if ($(this).val().length > 3) { 3890 if (useJson) { 3891 rep.phone = $(this).val(); 3892 } else { 3893 rep['phone'] = $(this).val(); 3894 } 3895 } 3896 }); 3897 var firstName = ''; 3898 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="firstName"]').each(function() { 3899 if ($(this).val().length > 0) { 3900 if (useJson) { 3901 rep.firstName = $(this).val(); 3902 } else { 3903 rep['firstName'] = $(this).val(); 3904 } 3905 } 3906 }); 3907 var lastName = ''; 3908 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="lastName"]').each(function() { 3909 if ($(this).val().length > 0) { 3910 if (useJson) { 3911 rep.lastName = $(this).val(); 3912 } else { 3913 rep['lastName'] = $(this).val(); 3914 } 3915 } 3916 }); 3917 var address = ''; 3918 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="address"]').each(function() { 3919 if ($(this).val().length > 0) { 3920 if (useJson) { 3921 rep.address = $(this).val(); 3922 } else { 3923 rep['address'] = $(this).val(); 3924 } 3925 } 3926 }); 3927 var city = ''; 3928 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="city"]').each(function() { 3929 if ($(this).val().length > 0) { 3930 if (useJson) { 3931 rep.city = $(this).val(); 3932 } else { 3933 rep['city'] = $(this).val(); 3934 } 3935 } 3936 }); 3937 var state = ''; 3938 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="state"]').each(function() { 3939 if ($(this).val().length > 0) { 3940 if (useJson) { 3941 rep.state = $(this).val(); 3942 } else { 3943 rep['state'] = $(this).val(); 3944 } 3945 } 3946 }); 3947 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="zip"]').each(function() { 3948 if ($(this).val().length > 0) { 3949 if (useJson) { 3950 rep.zip = $(this).val(); 3951 } else { 3952 rep['zip'] = $(this).val(); 3953 } 3954 } 3955 }); 3956 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="country"]').each(function() { 3957 if ($(this).val().length > 0) { 3958 if (useJson) { 3959 rep.country = $(this).val(); 3960 } else { 3961 rep['country'] = $(this).val(); 3962 } 3963 } 3964 }); 3965 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="job"]').each(function() { 3966 if ($(this).val().length > 0) { 3967 if (useJson) { 3968 rep.job = $(this).val(); 3969 } else { 3970 rep['job'] = $(this).val(); 3971 } 3972 } 3973 }); 3974 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="phoneJob"]').each(function() { 3975 if ($(this).val().length > 0) { 3976 if (useJson) { 3977 rep.phoneJob = $(this).val(); 3978 } else { 3979 rep['phoneJob'] = $(this).val(); 3980 } 3981 } 3982 }); 3983 3984 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="url"]').each(function() { 3985 if ($(this).val().length > 0) { 3986 if (useJson) { 3987 rep.url = $(this).val(); 3988 } else { 3989 rep['url'] = $(this).val(); 3990 } 3991 } 3992 }); 3993 3994 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="company"]').each(function() { 3995 if ($(this).val().length > 0) { 3996 if (useJson) { 3997 rep.company = $(this).val(); 3998 } else { 3999 rep['company'] = $(this).val(); 4000 } 4001 } 4002 }); 4003 4004 4005 return rep; 4006 } 4007 4008 function lfb_getUrlVariablesByFormID(formID) { 4009 var form = lfb_getForm(formID); 4010 var contentForm = lfb_getFormContent(formID); 4011 var urlVariables = lfb_getUrlVariables(formID, contentForm[2], true); 4012 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').data('lfb_urlVariables', urlVariables); 4013 return urlVariables; 4014 4015 } 4016 4017 function lfb_getUrlVariables(formID, items) { 4018 var form = lfb_getForm(formID); 4019 var variablesText = ''; 4020 var checkedVariables = new Array(); 4021 jQuery.each(items, function() { 4022 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + this.itemid + '"]').length > 0) { 4023 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + this.itemid + '"]'); 4024 if ($item.is('[data-urlvariable="1"]')) { 4025 var value = '0'; 4026 4027 if ($item.attr('data-sentattribute') == 'quantity') { 4028 if ($item.is('.lfb_dropzone')) { 4029 value = ''; 4030 value = value.replace(/<span class="lfb_file">/g, ""); 4031 value = value.replace(/<\/span>/g, ""); 4032 value = value.substr(3, value.length); 4033 if (form.emailCustomerLinks == 1) { 4034 value = ''; 4035 $item.find('.dz-success.dz-complete').each(function() { 4036 value += $(this).attr('data-url') + ','; 4037 }); 4038 if (value.length > 0) { 4039 value = value.substr(0, value.length - 1); 4040 } 4041 } 4042 } else if (typeof(this.value) != 'undefined') { 4043 value = this.value.replace(/\+/g, "%2b"); 4044 } else if (typeof(this.quantity) != 'undefined') { 4045 value = this.quantity; 4046 } 4047 4048 } else if ($item.attr('data-sentattribute') == 'title') { 4049 value = $item.attr('data-originallabel'); 4050 } else { 4051 if (typeof(this.price) != 'undefined') { 4052 value = this.price; 4053 } 4054 } 4055 4056 var title = $item.attr('data-variablename'); 4057 if (title.length > 0 && title.replace(/ /g, "").length > 0) { 4058 title = lfb_formatForUrl(title); 4059 } else { 4060 title = lfb_formatForUrl(this.label); 4061 } 4062 if (typeof(value) == 'string') { 4063 value = value.replace(/<br\s*[\/]?>/gi, "\n"); 4064 } 4065 if (checkedVariables.indexOf(title) == -1) { 4066 checkedVariables.push(title); 4067 variablesText += '&' + encodeURIComponent(title) + '=' + encodeURIComponent(value); 4068 } 4069 } 4070 } 4071 }); 4072 4073 for (var i = 0; i < form.variables.length; i++) { 4074 if (form.variables[i].sendAsGet == 1 && typeof(form.variables[i].value) != 'undefined' && typeof(form.variables[i].value.replace) == 'function') { 4075 variablesText += '&' + encodeURIComponent(lfb_formatForUrl(form.variables[i].title)) + '=' + encodeURIComponent(form.variables[i].value.replace(/\+/g, "%2b")); 4076 } 4077 } 4078 4079 if (variablesText.length > 0) { 4080 variablesText = '?' + variablesText.substr(1, variablesText.length); 4081 if (typeof(form.orderRef) != 'undefined') { 4082 var refName = form.refVarName; 4083 variablesText += '&' + encodeURIComponent(refName) + '=' + encodeURIComponent(form.orderRef); 4084 } 4085 if (form.discountCode != '') { 4086 variablesText += '&coupon=' + encodeURIComponent(form.discountCode) + '&discount=' + encodeURIComponent(form.reductionResult); 4087 } 4088 } else { 4089 if (typeof(form.orderRef) != 'undefined') { 4090 var refName = form.refVarName; 4091 variablesText += '?' + encodeURIComponent(refName) + '=' + encodeURIComponent(form.orderRef); 4092 if (form.discountCode != '') { 4093 variablesText += '&coupon=' + encodeURIComponent(form.discountCode) + '&discount=' + encodeURIComponent(form.reductionResult); 4094 } 4095 } else { 4096 if (form.discountCode != '') { 4097 variablesText += '?coupon=' + encodeURIComponent(form.discountCode) + '&discount=' + encodeURIComponent(form.reductionResult); 4098 } 4099 } 4100 } 4101 return variablesText; 4102 } 4103 4104 function lfb_formatForUrl(text) { 4105 text = text.replace(/ /g, "_"); 4106 text = text.replace(/[^\w\s]/gi, ''); 4107 return text; 4108 } 4109 4110 function lfb_orderSend(formID, informations, email, fields) { 4111 4112 var form = lfb_getForm(formID); 4113 var contentForm = lfb_getFormContent(formID); 4114 var content = contentForm[0]; 4115 content = content.replace(/<br\/>/g, '[n]'); 4116 var totalTxt = contentForm[1]; 4117 var items = contentForm[2]; 4118 form.urlVariables = ''; 4119 if (form.sendUrlVariables == 1) { 4120 form.urlVariables = lfb_getUrlVariables(formID, contentForm[2], true); 4121 4122 } 4123 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('[data-subs]')) { 4124 totalTxt += $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').attr('data-subs'); 4125 } 4126 var usePaypalIpn = 0; 4127 var activatePaypal = true; 4128 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-activatePaypal="true"]:not(:checked):not(.checked)').each(function() { 4129 var cStepID = $(this).closest('.lfb_genSlide').attr('data-stepid'); 4130 if (cStepID != 'final') { 4131 cStepID = parseInt(cStepID); 4132 } 4133 if (jQuery.inArray(cStepID, lfb_lastSteps) == -1) {} else { 4134 activatePaypal = false;
4135 } 4136 }); 4137 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').find('[data-dontactivatepaypal="true"].checked,[data-dontactivatepaypal="true"]:checked').length > 0) { 4138 activatePaypal = false; 4139 } 4140 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_paypalForm').is('[data-useipn="1"]')) { 4141 usePaypalIpn = 1; 4142 } 4143 var $summaryClone = lfb_cloneSummary(false, formID); 4144 var summaryData = $summaryClone.html(); 4145 $summaryClone.remove(); 4146 4147 var infosCt = lfb_getContactInformations(formID); 4148 email = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .emailField').val(); 4149 if (lfb_checkEmail(infosCt['email'])) { 4150 email = infosCt['email']; 4151 } 4152 4153 var total = parseFloat(form.price); 4154 var totalSub = 0; 4155 var subFrequency = ''; 4156 var formTitle = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-formtitle'); 4157 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-isSubs="true"]')) { 4158 total = parseFloat(form.priceSingle); 4159 totalSub = parseFloat(form.price); 4160 subFrequency = form.subscriptionText; 4161 } 4162 var fieldsLast = new Array(); 4163 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide input[type=text],#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide input[type=email], #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide textarea').each(function() { 4164 if ($(this).closest('#lfb_paypalForm').length == 0) { 4165 fieldsLast.push({ 4166 fieldID: $(this).prop('id').substr(6, 9), 4167 value: lfb_nl2br($(this).val()) 4168 }); 4169 } 4170 }); 4171 var activatePaypal = true; 4172 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-activatePaypal="true"]:not(:checked):not(.checked)').each(function() { 4173 var cStepID = $(this).closest('.lfb_genSlide').attr('data-stepid'); 4174 if (cStepID != 'final') { 4175 cStepID = parseInt(cStepID); 4176 } 4177 if (jQuery.inArray(cStepID, lfb_lastSteps) == -1) {} else { 4178 activatePaypal = false; 4179 } 4180 }); 4181 4182 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').find('[data-dontactivatepaypal="true"].checked,[data-dontactivatepaypal="true"]:checked').length > 0) { 4183 activatePaypal = false; 4184 } 4185 var captcha = ''; 4186 if (typeof ga !== 'undefined') { 4187 try { 4188 ga('set', 'page', location.pathname + "#" + "Form+sent"); 4189 ga('send', 'pageview'); 4190 } catch (e) {} 4191 } 4192 if (typeof gtag !== 'undefined') { 4193 try { 4194 gtag('event', 'page_view', { 4195 page_location: window.location.href, 4196 page_path: location.pathname + "#Form+sent", 4197 page_title: document.title + " Form sent", 4198 }); 4199 4200 } catch (e) {} 4201 } 4202 form.emailSent = true; 4203 if (localStorage.getItem('lfb_savedFormID') !== null && parseInt(localStorage.getItem('lfb_savedFormID')) == formID && localStorage.getItem('lfb_savedForm') !== null) { 4204 localStorage.removeItem('lfb_savedFormID'); 4205 localStorage.removeItem('lfb_formsession'); 4206 localStorage.removeItem('lfb_savedForm'); 4207 localStorage.removeItem('lfb_savedFormPastSteps'); 4208 localStorage.removeItem('lfb_savedFormStep'); 4209 } 4210 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').fadeOut(); 4211 var eventsData = new Array(); 4212 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_datepicker[data-calendarid!="0"][data-registerevent="1"]').each(function() { 4213 if ($(this).val() != '') { 4214 var eventData = {}; 4215 eventData.calendarID = parseInt($(this).attr('data-calendarid')); 4216 eventData.duration = parseInt($(this).attr('data-eventduration')); 4217 eventData.durationType = $(this).attr('data-eventdurationtype'); 4218 if (eventData.durationType == 'mins') { 4219 eventData.durationType = 'minutes'; 4220 } 4221 eventData.isBusy = parseInt($(this).attr('data-eventbusy')); 4222 eventData.categoryID = parseInt($(this).attr('data-eventcategory')); 4223 eventData.startDate = moment($(this).datetimepicker("getDate")).format('YYYY-MM-DD HH:mm'); 4224 eventData.endDate = moment($(this).datetimepicker("getDate")).add(eventData.duration, eventData.durationType).format('YYYY-MM-DD HH:mm'); 4225 eventData.title = $(this).attr('data-eventtitle'); 4226 if ($(this).attr('data-datetype') == 'date') { 4227 var startDateMoment = moment($(this).datetimepicker("getDate")); 4228 eventData.startDate = startDateMoment.format('YYYY-MM-DD'); 4229 var endDateMoment = moment($(this).datetimepicker("getDate")).add(eventData.duration, eventData.durationType); 4230 eventData.endDate = endDateMoment.format('YYYY-MM-DD'); 4231 if (eventData.startDate == eventData.endDate || endDateMoment.diff(startDateMoment, 'hours') == 24) { 4232 eventData.fullDay = 1; 4233 } 4234 4235 } else { 4236 eventData.fullDay = 0; 4237 } 4238 if ($(this).attr('data-useasdaterange') == '1') { 4239 var endDatepickerID = $(this).attr('data-enddaterangeid'); 4240 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + endDatepickerID + '"]').length > 0) { 4241 eventData.fullDay = 0; 4242 if ($(this).attr('data-datetype') == 'date') { 4243 eventData.endDate = moment($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + endDatepickerID + '"]').datetimepicker("getDate")).format('YYYY-MM-DD'); 4244 } else { 4245 eventData.endDate = moment($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + endDatepickerID + '"]').datetimepicker("getDate")).format('YYYY-MM-DD HH:mm'); 4246 } 4247 } 4248 } 4249 eventsData.push(eventData); 4250 } 4251 }); 4252 if (typeof(form.verifiedEmail) == 'undefined' || !form.verifiedEmail) { 4253 form.verifiedEmail = ''; 4254 } else { 4255 email = form.verifiedEmail; 4256 } 4257 var signature = ''; 4258 if (form.useSignature == 1) { 4259 signature = form.signature.signature('toDataURL', 'image/png'); 4260 } 4261 var $totalText = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice').clone(); 4262 var totalIndexToRemove = -1; 4263 $totalText.find('span').each(function(i) { 4264 if ($(this).css('display') == 'none') { 4265 totalIndexToRemove = i; 4266 } 4267 }); 4268 if (totalIndexToRemove > -1) { 4269 $totalText.children('span')[totalIndexToRemove].remove(); 4270 } 4271 var totalText = $totalText.text(); 4272 4273 4274 jQuery.ajax({ 4275 url: form.ajaxurl, 4276 type: 'post', 4277 data: { 4278 action: 'send_email', 4279 formID: form.formID, 4280 informations: informations, 4281 email: email, 4282 customerInfos: lfb_getContactInformations(form.formID, true), 4283 summary: summaryData,
4284 stripeCustomerID: form.stripeCustomerID, 4285 stripeToken: form.stripeToken, 4286 stripeSrc: form.stripeSrc, 4287 totalTxt: totalTxt, 4288 email_toUser: form.email_toUser, 4289 usePaypalIpn: usePaypalIpn, 4290 discountCode: form.discountCode, 4291 formSession: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_formSession').val(), 4292 totalText: totalText, 4293 total: total, 4294 totalSub: totalSub, 4295 subFrequency: subFrequency, 4296 formTitle: formTitle, 4297 contactSent: form.contactSent, 4298 contentTxt: content, 4299 items: items, 4300 fieldsLast: fieldsLast, 4301 activatePaypal: activatePaypal, 4302 captcha: form.captcha, 4303 useRtl: $('body').is('.rtl'), 4304 finalUrl: lfb_getRedirectionURL(form.formID), 4305 eventsData: JSON.stringify(eventsData), 4306 razorpayReady: form.razorpayReady, 4307 variables: JSON.stringify(form.variables), 4308 verifiedEmail: form.verifiedEmail, 4309 signature: signature, 4310 vatPrice: form.vatPrice, 4311 vatLabel: form.vatLabel,
4312 vatAmount: form.vatAmount 4313 }, 4314 success: function(current_ref) { 4315 4316 var dontCallFinalStep = false; 4317 form.orderRef = current_ref; 4318 if (form.sendUrlVariables == 1) { 4319 form.urlVariables = lfb_getUrlVariables(formID, contentForm[2]); 4320 } 4321 if (form.enableZapier == '1' && form.zapierWebHook.length > 0) { 4322 var dataVariables = lfb_getUrlVariables(formID, contentForm[2]); 4323 if (dataVariables.length > 1) { 4324 dontCallFinalStep = true; 4325 dataVariables = dataVariables.substr(1, dataVariables.length); 4326 jQuery.ajax({ 4327 url: form.zapierWebHook, 4328 type: 'get', 4329 data: dataVariables, 4330 success: function() { 4331 lfb_finalStep(formID); 4332 }, 4333 error: function() { 4334 lfb_finalStep(formID); 4335 } 4336 }); 4337 } 4338 4339 4340 } 4341 $summaryClone.remove(); 4342 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_loader').delay(1000).fadeOut(); 4343 if (activatePaypal && (typeof(form.stripePaid) == 'undefined') && $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length > 0 && (form.price > 0 || form.priceSingle > 0)) { 4344 var payPrice = form.price; 4345 if (form.payMode == 'percent') { 4346 payPrice = parseFloat(payPrice) * (parseFloat(form.percentToPay) / 100); 4347 } else if (form.payMode == 'fixed') { 4348 payPrice = parseFloat(form.fixedToPay); 4349 } 4350 payPrice = parseFloat(payPrice).toFixed(2); 4351 if (form.priceSingle > 0) { 4352 var payPriceSingle = form.priceSingle; 4353 if (form.payMode == 'percent') { 4354 payPriceSingle = parseFloat(payPriceSingle) * (parseFloat(form.percentToPay) / 100); 4355 } else if (form.payMode == 'fixed') { 4356 payPriceSingle = parseFloat(form.fixedToPay); 4357 } 4358 payPriceSingle = parseFloat(payPriceSingle).toFixed(2); 4359 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a1]').length == 0) { 4360 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').append('<input type="hidden" name="a1" value="0"/>'); 4361 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').append('<input type="hidden" name="p1" value="1"/>'); 4362 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').append('<input type="hidden" name="t1" value="M"/>'); 4363 } 4364 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a1]').val(payPriceSingle); 4365 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p1]').val($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p3]').val()); 4366 if (payPrice <= 0) { 4367 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=cmd]').val('_xclick'); 4368 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a3]').remove(); 4369 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=t3]').remove(); 4370 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p3]').remove(); 4371 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=bn]').remove(); 4372 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=no_note]').remove(); 4373 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=src]').remove(); 4374 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a1]').remove(); 4375 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=t1]').remove(); 4376 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p1]').remove(); 4377 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').append('<input type="hidden" name="amount" value="' + payPriceSingle + '"/>'); 4378 } 4379 } else { 4380 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a1]').remove(); 4381 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=t1]').remove(); 4382 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=p1]').remove(); 4383 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=amount]').val(payPrice); 4384 } 4385 4386 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name="return"]').val(lfb_getRedirectionURL(formID)); 4387 4388 var redirUrl = lfb_getRedirectionURL(formID); 4389 if (redirUrl != "" && redirUrl != "#" && redirUrl != " ") { 4390 if (form.save_to_cart && form.cartPage != '') { 4391 redirUrl = form.cartPage; 4392 } 4393 } 4394 if (redirUrl != "" && redirUrl != "#" && redirUrl != " ") { 4395 if (form.urlVariables != '') { 4396 if (redirUrl.indexOf('?') > -1) { 4397 form.urlVariables.replace('?', '&'); 4398 } 4399 } 4400 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_paypalForm input[name="return"]').val(redirUrl + form.urlVariables); 4401 } 4402 4403 4404 4405 4406 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=a3]').val(payPrice); 4407 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=custom]').val(current_ref); 4408 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=item_number]').val(current_ref); 4409 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=item_name]').val($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [name=item_name]').val() + ' - ' + current_ref); 4410 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm [type="submit"]').trigger('click'); 4411 } 4412 4413 4414 if (activatePaypal && $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length > 0 && (form.price > 0 || form.priceSingle > 0) && typeof(form.stripePaid) == 'undefined') {} else if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeForm').length > 0 && form.price > 0) {} else if (!form.save_to_cart && !form.save_to_cart_edd && !dontCallFinalStep) { 4415 lfb_finalStep(formID); 4416 } 4417 4418 if (form.save_to_cart_edd) { 4419 var products = new Array(); 4420 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 4421 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 4422 lastAndCurrentSteps.push(parseInt(form.step)); 4423 }
4423 else if (form.step == 'final' && jQuery.inArray('final', lastAndCurrentSteps) == -1) { 4424 lastAndCurrentSteps.push('final'); 4425 } 4426 4427 jQuery.each(lastAndCurrentSteps, function() { 4428 var $panel = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"]'); 4429 $panel.find('div.lfb_selectable.checked:not(.lfb_disabled),a.lfb_button.checked:not(.lfb_disabled),input[type=checkbox]:checked:not(.lfb_disabled),[data-type="slider"]:not(.lfb_disabled)').each(function() { 4430 var quantity = 1; 4431 if (parseInt($(this).data('resqt')) > 0) { 4432 quantity = parseInt($(this).data('resqt')); 4433 } 4434 if ($(this).is('[data-type="slider"]')) { 4435 quantity = parseInt($(this).slider('value')); 4436 if (!isNaN(parseInt($(this).find('.tooltip-inner').html()))) { 4437 quantity = parseInt($(this).find('.tooltip-inner').html()); 4438 } 4439 } 4440 if (parseInt($(this).data('prodid')) > 0) { 4441 products.push({ 4442 quantity: quantity, 4443 product_id: parseInt($(this).data('prodid')), 4444 variation: parseInt($(this).data('eddvar')) 4445 }); 4446 } 4447 }); 4448 }); 4449 jQuery.ajax({ 4450 url: form.ajaxurl, 4451 type: 'post', 4452 data: { 4453 action: 'lfb_cartdd_save', 4454 products: products 4455 }, 4456 success: function() { 4457 lfb_finalStep(formID); 4458 } 4459 }); 4460 } 4461 4462 if (form.save_to_cart) { 4463 var products = new Array(); 4464 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 4465 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 4466 lastAndCurrentSteps.push(parseInt(form.step)); 4467 } else if (form.step == 'final' && jQuery.inArray('final', lastAndCurrentSteps) == -1) { 4468 lastAndCurrentSteps.push('final'); 4469 } 4470 4471 jQuery.each(lastAndCurrentSteps, function() { 4472 var $panel = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"]'); 4473 $panel.find('div.lfb_selectable.checked:not(.lfb_disabled),a.lfb_button.checked:not(.lfb_disabled),input[type=checkbox]:checked:not(.lfb_disabled),[data-type="numberfield"]:not(.lfb_disabled),[data-type="slider"]:not(.lfb_disabled),select[data-itemid]:not(.lfb_disabled)').each(function() { 4474 var quantity = 1; 4475 if (parseInt($(this).data('resqt')) > 0) { 4476 quantity = parseInt($(this).data('resqt')); 4477 } 4478 if ($(this).is('[data-type="slider"]')) { 4479 quantity = parseInt($(this).slider('value')); 4480 4481 } 4482 if ($(this).is('[data-type="numberfield"]')) { 4483 quantity = $(this).val(); 4484 } 4485 4486 if (parseInt($(this).data('prodid')) > 0) { 4487 var title = $(this).attr('data-originaltitle'); 4488 if ($(this).is('[data-originallabel]')) { 4489 title = $(this).attr('data-originallabel') 4490 } 4491 4492 var productData = { 4493 quantity: quantity, 4494 title: title, 4495 product_id: parseInt($(this).data('prodid')), 4496 variation: parseInt($(this).attr('data-woovar')), 4497 price: parseFloat($(this).data('resprice') / quantity).toFixed(2) 4498 }; 4499 if (typeof($(this).data('imageProduct')) != 'undefined' && $(this).data('imageProduct') != '') { 4500 productData.imageProduct = $(this).data('imageProduct'); 4501 } 4502 4503 products.push(productData); 4504 } 4505 }); 4506 }); 4507 jQuery.ajax({ 4508 url: form.ajaxurl, 4509 type: 'post', 4510 data: { 4511 action: 'lfb_cart_save', 4512 formID: formID, 4513 ref: current_ref, 4514 emptyWooCart: form.emptyWooCart, 4515 products: products, 4516 contentTxt: content 4517 }, 4518 success: function() { 4519 lfb_finalStep(formID); 4520 } 4521 }); 4522 } 4523 } 4524 4525 }); 4526 } 4527 4528 function lfb_checkLastStepFields(formID) { 4529 var form = lfb_getForm(formID); 4530 var isOK = true; 4531 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide input[type=text],#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide input[type=email], #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide textarea').each(function() { 4532 if ($(this).closest('#lfb_paypalForm').length == 0) { 4533 if (!$(this).is('.lfb_disabled')) { 4534 if ($(this).attr('data-required') && $(this).attr('data-required') == 'true' && $(this).val().length < 1) { 4535 isOK = false;
4536 $(this).closest('.form-group').addClass('has-error'); 4537 if (!$(this).is('#lfb_captchaField')) { 4538 if (form.disableScroll != 1) { 4539 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen') || $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_popup')) { 4540 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 4541 scrollTop: $(this).parent().offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 4542 }, form.animationsSpeed * 2); 4543 } else { 4544 if (form.scrollTopPage == '1') { 4545 $('body,html').animate({ 4546 scrollTop: 0 4547 }, form.animationsSpeed * 2); 4548 } else { 4549 $('body,html').animate({ 4550 scrollTop: $(this).parent().offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 4551 }, form.animationsSpeed * 2); 4552 } 4553 } 4554 } 4555 } 4556 } 4557 if ($(this).is('.emailField') && !lfb_checkEmail($(this).val())) { 4558 isOK = false; 4559 $(this).closest('.form-group').addClass('has-error'); 4560 if (form.disableScroll != 1) { 4561 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen') || $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_popup')) { 4562 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 4563 scrollTop: $(this).parent().offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 4564 }, form.animationsSpeed * 2); 4565 } else { 4566 if (form.scrollTopPage == '1') { 4567 $('body,html').animate({ 4568 scrollTop: 0 4569 }, form.animationsSpeed * 2); 4570 } else { 4571 $('body,html').animate({ 4572 scrollTop: $(this).parent().offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 4573 }, form.animationsSpeed * 2); 4574 } 4575 } 4576 } 4577 } 4578 } 4579 } 4580 }); 4581 4582 return isOK; 4583 } 4584 4585 function lfb_order(formID) { 4586 var form = lfb_getForm(formID); 4587 var isOK = true; 4588 var informations = ''; 4589 var email = ''; 4590 4591 var fields = new Array(); 4592 4593 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide .form-group').removeClass('has-error'); 4594 4595 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide').find('.lfb_item input:not([type="checkbox"])[data-itemid],.lfb_item textarea[data-itemid],.lfb_item select[data-itemid]').each(function() { 4596 if ($(this).closest('#lfb_paypalForm').length == 0) { 4597 if ($(this).is('.lfb_disabled')) {} else { 4598 if ($(this).is('#lfb_couponField')) {} else if ($(this).is('#lfb_captchaField')) {} else { 4599 var dbpoints = ':'; 4600 if ($(this).closest('.lfb_item').find('label').html().lastIndexOf(':') == $(this).closest('.lfb_item').find('label').html().length - 1) { 4601 dbpoints = ''; 4602 } 4603 if ($('body').is('.rtl')) { 4604 informations += '<p><b><span class="lfb_value">' + $(this).val() + '</span></b>' + dbpoints + ' ' + $(this).closest('.lfb_item').find('label').html() + '</p>'; 4605 } else { 4606 informations += '<p>' + $(this).closest('.lfb_item').find('label').html() + ' ' + dbpoints + ' <b><span class="lfb_value">' + $(this).val() + '</span></b></p>'; 4607 } 4608 4609 } 4610 } 4611 } 4612 }); 4613 isOK = lfb_checkStepItemsValid('final', formID); 4614
4615 if (form.legalNoticeEnable == 1) { 4616 if (!$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_legalCheckbox').is(':checked')) { 4617 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_legalCheckbox').closest('.form-group').addClass('has-error'); 4618 isOK = false; 4619 } 4620 } 4621 4622 4623 4624 if (isOK == true && lfb_checkUserEmail(form)) { 4625 lfb_checkCaptcha(form, function() { 4626 var emailField = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"]').last(); 4627 var email = emailField.val(); 4628 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide').find('#lfb_btnOrder,.linkPrevious').fadeOut(250); 4629 lfb_uploadFiles(form.formID, informations, email, fields); 4630 }); 4631 } 4632 } 4633 4634 function lfb_getPreviousEnabledStep(formID, lastSteps) { 4635 var rep = -1; 4636 var stepID = lastSteps[lastSteps.length - 1]; 4637 4638 if (!$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').is('.lfb_disabled') && 4639 ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_item:not(.lfb_row ):not(.lfb-hidden)').length > 0 || 4640 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_distanceError').length > 0)) { 4641 rep = stepID; 4642 } else { 4643 lastSteps.pop(); 4644 if (lastSteps.length > 0) { 4645 rep = lfb_getPreviousEnabledStep(formID, lastSteps); 4646 } else { 4647 rep = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-start="1"]').attr('data-stepid'); 4648 } 4649 } 4650 4651 lfb_lastSteps = lastSteps; 4652 4653 return rep; 4654 } 4655 4656 function lfb_previousStep(formID) { 4657 var form = lfb_getForm(formID); 4658 var deviceAgent = navigator.userAgent.toLowerCase(); 4659 var posTop = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').offset().top - 100; 4660 4661 if (form.disableScroll != 1) { 4662 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_fullscreen') || 4663 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_popup')) { 4664 posTop = 0; 4665 if (form.intro_enabled > 0) { 4666 posTop = lfb_zeroIfNan($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #startInfos').height()) + 100 4667 } 4668 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').animate({ 4669 scrollTop: posTop 4670 }, 250); 4671 } else { 4672 if ($('header').length > 0 && lfb_isAnyParentFixed($('header'))) { 4673 posTop -= lfb_zeroIfNan($('header').height()); 4674 } 4675 posTop -= (48 + parseInt(lfb_getScrollTopMargin(form))); 4676 if (form.scrollTopPage == '1') { 4677 $('body,html').animate({ 4678 scrollTop: 0 4679 }, form.animationsSpeed * 2); 4680 } else { 4681 $('body,html').animate({ 4682 scrollTop: posTop 4683 }, 250); 4684 } 4685 } 4686 } 4687 4688 var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i); 4689 if (agentID) { 4690 $('#lfb_form :not(.ui-slider-handle) > .tooltip').remove(); 4691 $('body > .tooltip').remove(); 4692 $('#lfb_form[data-form="' + form.formID + '"] > .tooltip').remove(); 4693 } 4694 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_errorMsg').hide(); 4695 4696 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('a.lfb_button.checked:not(.prechecked)').each(function() { 4697 lfb_itemClick($(this), false, formID); 4698 }); 4699 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('div.lfb_selectable.checked:not(.prechecked)').each(function() { 4700 lfb_itemClick($(this), false, formID); 4701 }); 4702 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('input[data-toggle="switch"]:checked:not(.prechecked)').each(function() { 4703 $(this).trigger('click.auto'); 4704 }); 4705 4706 var chkCurrentStep = false;
4707 var lastStepID = 0; 4708 var lastStepIndex = 0; 4709 jQuery.each(lfb_lastSteps, function(i) { 4710 var stepID = this; 4711 if (parseInt(stepID) == parseInt(form.step)) { 4712 chkCurrentStep = true; 4713 } 4714 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_executed').removeClass('lfb_executed'); 4715 if (!chkCurrentStep) { 4716 if (($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_item:not(.lfb-hidden)').length > 0 || 4717 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_distanceError').length > 0) && 4718 !$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').is('.lfb_disabled')) { 4719 lastStepID = stepID; 4720 lastStepIndex = i; 4721 } 4722 } 4723 }); 4724 lfb_lastSteps = jQuery.grep(lfb_lastSteps, function(value, i) { 4725 if (i <= lastStepIndex) 4726 return (value); 4727 }); 4728 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide.lfb_activeStep').hide(); 4729 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + lastStepID + '"] .lfb_genContent').css('opacity', 0); 4730 lfb_changeStep(lastStepID, formID); 4731 } 4732 4733 4734 4735 function lfb_returnToStep(stepID, formID) { 4736 var form = lfb_getForm(formID); 4737 if (stepID != form.step) { 4738 var deviceAgent = navigator.userAgent.toLowerCase(); 4739 var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i); 4740 if (agentID) { 4741 $('#lfb_form :not(.ui-slider-handle) > .tooltip').remove(); 4742 $('body > .tooltip').remove(); 4743 $('#lfb_form[data-form="' + form.formID + '"] > .tooltip').remove(); 4744 } 4745 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_errorMsg').hide(); 4746 4747 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('a.lfb_button.checked:not(.prechecked)').each(function() { 4748 lfb_itemClick($(this), false, formID); 4749 }); 4750 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('div.lfb_selectable.checked:not(.prechecked)').each(function() { 4751 lfb_itemClick($(this), false, formID); 4752 }); 4753 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('input[data-toggle="switch"]:checked:not(.prechecked)').each(function() { 4754 $(this).trigger('click.auto'); 4755 }); 4756 4757 4758 var stepIndex = lfb_lastSteps.indexOf(stepID); 4759 var removedSteps = []; 4760 for (var i = stepIndex + 1; i < lfb_lastSteps.length; i++) { 4761 removedSteps.push(lfb_lastSteps[i]); 4762 } 4763 form.itemsData = jQuery.grep(form.itemsData, function(value, i) { 4764 if (removedSteps.indexOf(parseInt(value.stepid)) == -1) 4765 return (value); 4766 }); 4767 4768 lfb_lastSteps = jQuery.grep(lfb_lastSteps, function(value, i) { 4769 if (i <= stepIndex) 4770 return (value); 4771 }); 4772 lfb_changeStep(stepID, formID); 4773 setTimeout(function() { 4774 lfb_updateSummary(formID, true); 4775 }, 350); 4776 setTimeout(function() { 4777 lfb_updateStep(formID); 4778 }, 2000); 4779 4780 } 4781 } 4782 4783 function lfb_uploadFiles(formID, informations, email, fields) { 4784 var mustSend = true; 4785 var form = lfb_getForm(formID); 4786 if (form.useRazorpay && !form.razorpayReady) { 4787 mustSend = false;
4788 var singleCost = form.price; 4789 var subCost = 0; 4790 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-isSubs="true"]')) { 4791 subCost = form.price; 4792 singleCost = 0; 4793 if (form.priceSingle > 0) { 4794 singleCost = form.priceSingle; 4795 } 4796 } 4797 jQuery.ajax({ 4798 url: form.ajaxurl, 4799 type: 'post', 4800 data: { 4801 action: 'lfb_makeRazorPayment', 4802 formID: formID, 4803 singleCost: singleCost, 4804 subCost: subCost, 4805 ref: form.current_ref, 4806 email: email 4807 }, 4808 success: function(rep) { 4809 if (rep.trim().indexOf('error') == -1) { 4810 var orderID = rep.trim(); 4811 4812 4813 var customerName = ''; 4814 var firstName = ''; 4815 var lastName = ''; 4816 var email = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .emailField').val(); 4817 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="firstName"]').length > 0) { 4818 firstName = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="firstName"]').val(); 4819 } 4820 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="lastName"]').length > 0) { 4821 lastName = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-fieldtype="lastName"]').val(); 4822 } 4823 customerName = firstName + ' ' + lastName; 4824 var options = { 4825 "key": form.razorpay_publishKey, 4826 "name": form.title, 4827 "description": "", 4828 "image": form.razorpay_logoImg, 4829 "handler": function(response) { 4830 form.razorpayReady = true; 4831 lfb_uploadFiles(formID, informations, email, fields); 4832 }, 4833 "prefill": { 4834 "name": customerName, 4835 "email": email 4836 }, 4837 "theme": { 4838 "color": form.colorA 4839 } 4840 }; 4841 if (orderID.indexOf('sub_') == 0) { 4842 options.subscription_id = orderID; 4843 } else { 4844 options.order_id = orderID; 4845 } 4846 var rzp1 = new Razorpay(options); 4847 rzp1.open(); 4848 4849 } else { 4850 alert(rep); 4851 } 4852 } 4853 }); 4854 4855 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-emaillaststep="1"]')) { 4856 4857 } else { 4858 4859 if (form.disableScroll != 1) { 4860 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_fullscreen')) { 4861 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').css('overflow-y', 'hidden'); 4862 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').animate({ 4863 scrollTop: 0 4864 }, form.animationsSpeed * 2); 4865 } else { 4866 if (form.scrollTopPage == '1') { 4867 $('body,html').animate({ 4868 scrollTop: 0 4869 }, form.animationsSpeed * 2); 4870 } else { 4871 $('body,html').animate({ 4872 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 4873 }, form.animationsSpeed * 2); 4874 } 4875 } 4876 } 4877 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnFloatingSummary').fadeOut(form.animationsSpeed); 4878 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').fadeOut(form.animationsSpeed); 4879 4880 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_loader').fadeIn(form.animationsSpeed * 2); 4881 setTimeout(function() { 4882 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').fadeOut(form.animationsSpeed * 2); 4883 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #startInfos').fadeOut(form.animationsSpeed * 2); 4884 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #genPrice').fadeOut(form.animationsSpeed * 2); 4885 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_stepper').fadeOut(form.animationsSpeed * 2); 4886 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide').fadeOut(form.animationsSpeed * 2); 4887 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_btn-next').fadeOut(form.animationsSpeed); 4888 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_btnNextContainer').fadeOut(form.animationsSpeed); 4889 4890 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalText').css({ 4891 opacity: 0, 4892 display: 'block' 4893 }); 4894 setTimeout(function() { 4895 4896 if (form.disableScroll != 1) { 4897 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_fullscreen')) { 4898 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').animate({ 4899 scrollTop: 0 4900 }, form.animationsSpeed * 2); 4901 } else { 4902 if (form.scrollTopPage == '1') { 4903 $('body,html').animate({ 4904 scrollTop: 0 4905 }, form.animationsSpeed * 2); 4906 } else { 4907 $('body,html').animate({ 4908 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 4909 }, form.animationsSpeed * 2); 4910 } 4911 } 4912 } 4913 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalText').animate({ opacity: 1 }, form.animationsSpeed * 2); 4914 }, form.animationsSpeed * 4 + 50); 4915 }, form.animationsSpeed * 2 + 50); 4916 } 4917 if (mustSend) { 4918 lfb_orderSend(formID, informations, email, fields); 4919 } 4920 4921 } 4922 4923 function lfb_isAnyParentFixed($el, rep) { 4924 if (!rep) { 4925 var rep = false;
4926 } 4927 try { 4928 if ($el.parent().length > 0 && $el.parent().css('position') == "fixed") { 4929 rep = true; 4930 } 4931 } catch (e) {} 4932 if (!rep && $el.parent().length > 0) { 4933 rep = lfb_isAnyParentFixed($el.parent(), rep); 4934 } 4935 return rep; 4936 } 4937 4938 function lfb_is_touch_device() { 4939 return (('ontouchstart' in window) || 4940 (navigator.MaxTouchPoints > 0) || 4941 (navigator.msMaxTouchPoints > 0)); 4942 } 4943 4944 function lfb_toggleFloatingSummary(formID) { 4945 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').is('.lfb_open')) { 4946 lfb_closeFloatingSummary(formID); 4947 } else { 4948 lfb_showFloatingSummary(formID); 4949 } 4950 } 4951 4952 function lfb_closeFloatingSummary(formID) { 4953 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').removeClass('lfb_open'); 4954 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').stop().slideUp(); 4955 } 4956 4957 function lfb_showFloatingSummary(formID) { 4958 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').addClass('lfb_open'); 4959 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').stop().slideDown(); 4960 } 4961 4962 function lfb_updateOtherSummary(formID) { 4963 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemtype="summary"]').each(function() { 4964 var $summaryClone = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalSlide >.lfb_genContent > .lfb_genContentSlide > #lfb_summary').first().clone(); 4965 $summaryClone.removeAttr('id'); 4966 $summaryClone.removeClass('lfb-hidden'); 4967 4968 $summaryClone.find('h3').html($(this).attr('data-title')); 4969 4970 if ($(this).attr('data-hideinfo') == '1') { 4971 $summaryClone.find('.lfb_valueTh').addClass('lfb-hidden'); 4972 $summaryClone.find('.lfb_valueTd').addClass('lfb-hidden'); 4973 } 4974 4975 var $item = $(this); 4976 var nbCol = 4; 4977 if ($summaryClone.find('.lfb_valueTh').is('.lfb-hidden') || $summaryClone.find('.lfb_valueTh').css('display') == 'none') { 4978 nbCol--; 4979 } 4980 if ($summaryClone.find('thead .lfb_quantityTh').is('.lfb-hidden')) { 4981 nbCol--; 4982 } 4983 if ($summaryClone.find('thead .lfb_priceTh').is('.lfb-hidden')) { 4984 nbCol--; 4985 } 4986 $summaryClone.find('.lfb_summaryStep').attr('colspan', nbCol); 4987 $summaryClone.find('.lfb_static [colspan]').attr('colspan', nbCol - 1); 4988 $item.find('.lfb_summaryItemContent').html($summaryClone); 4989 4990 }); 4991 4992 } 4993 4994 function lfb_updateFloatingSummary(formID) { 4995 var form = lfb_getForm(formID); 4996 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').length > 0) { 4997 var $summaryClone = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary').clone(); 4998 4999 var useInfos = false; 5000 if (form.floatSummary_showInfo == '1') { 5001 useInfos = true; 5002 } 5003 5004 if ($summaryClone.find('tbody').children(':not(.lfb_static)').length == 0 && $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').is('[data-numberstep="1"]')) { 5005 lfb_closeFloatingSummary(formID); 5006 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnFloatingSummary:not(.disabled)').addClass('disabled'); 5007 } else { 5008 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnFloatingSummary').removeClass('disabled'); 5009 $summaryClone.find('h4').remove(); 5010 $summaryClone.attr('id', 'lfb_floatingSummaryContent'); 5011 $summaryClone.removeClass('lfb-hidden'); 5012 if (!useInfos) { 5013 $summaryClone.find('.lfb_valueTd,.lfb_valueTh').addClass('lfb-hidden'); 5014 } 5015 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').is('[data-hideprices="1"]')) { 5016 $summaryClone.find('.lfb_priceTd,.lfb_priceTh').addClass('lfb-hidden'); 5017 $summaryClone.find('#lfb_summaryDiscountTr,#lfb_summaryTotalTr').addClass('lfb-hidden'); 5018 } 5019 $summaryClone.find('.lfb_summaryStep').attr('colspan', $summaryClone.find('thead th:not(.lfb-hidden)').length); 5020 if (!useInfos) { 5021 $summaryClone.find('tr.lfb_noPriceRow').remove(); 5022 } 5023 $summaryClone.find('#lfb_vatRow>th:eq(0),#lfb_summaryDiscountTr>th:eq(0),#lfb_summaryTotalTr>th:eq(0)').attr('colspan', $summaryClone.find('thead th:not(.lfb-hidden)').length - 1); 5024 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary #lfb_floatingSummaryInner').html($summaryClone); 5025 $summaryClone.find('.lfb_summaryStep').on('click', function() { 5026 var formID = $(this).closest('#lfb_form').attr('data-form'); 5027 var form = lfb_getForm(formID); 5028 var stepID = parseInt($(this).attr('data-step')); 5029 if (typeof(form.canGoprevious) == 'undefined' || form.canGoprevious) { 5030 lfb_returnToStep(stepID, formID); 5031 } 5032 }); 5033 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').is('[data-numberstep="1"]')) { 5034 $summaryClone.find('.lfb_summaryStep').each(function(i) { 5035 var stepIndex = i + 1; 5036 $(this).find('strong').html(stepIndex + '. ' + $(this).find('strong').html()); 5037 }); 5038 } 5039 } 5040 } 5041 } 5042 5043 function lfb_updateSummary(formID, dontUseCurrent) { 5044 var form = lfb_getForm(formID); 5045 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary').length > 0 || $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary').length > 0) { 5046 var useCurrent = true; 5047 if (dontUseCurrent) { 5048 useCurrent = false;
5049 } 5050 var formContent = lfb_getFormContent(formID, useCurrent); 5051 var items = formContent[2]; 5052 var step = -1; 5053 var hasValues = false; 5054 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr:not(.lfb_static)').remove(); 5055 var priceClass = ''; 5056 if (form.summary_hidePrices == 1) { 5057 priceClass = 'lfb-hidden lfb_hidePrice'; 5058 } 5059 jQuery.each(items, function() { 5060 var item = this; 5061 if (item.label != undefined && item.label != "" && item.label != "undefined" && item.type != 'summary') { 5062 if (!$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + item.itemid + '"]').is('.lfb_disabled') && $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + item.itemid + '"]').closest('.lfb_disabled').length == 0) { 5063 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr[data-item="' + item.itemid + '"]').length == 0) { 5064 if (isNaN(item.stepid)) { 5065 item.stepid = 'final'; 5066 } 5067 if (item.stepid != 'final' || form.summary_hideFinalStep != '1') { 5068 if (item.stepid != step && !$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('[data-sumhidesteps="1"]')) { 5069 var stepTitle = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + item.stepid + '"]').attr('data-title'); 5070 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody #lfb_summaryDiscountTr').before('<tr><th colspan="4" class="lfb_summaryStep" data-step="' + item.stepid + '">' + stepTitle + '</th>'); 5071 } 5072 step = item.stepid; 5073 5074 if (isNaN(item.quantity)) { 5075 item.quantity = 1; 5076 } 5077 var itemClass = ""; 5078 if (isNaN(item.price)) { 5079 itemClass = 'lfb_noPriceRow'; 5080 item.price = 0; 5081 } 5082 var value = item.value; 5083 if (item.value === undefined) { 5084 value = ""; 5085 } else { 5086 itemClass += ' lfb_infoRow'; 5087 } 5088 5089 5090 if (value != "" && item.showInSummary) { 5091 hasValues = true; 5092 } 5093 var itemPrice = item.price; 5094 var itemQt = lfb_formatPrice(item.quantity, formID); 5095 if (value != "" && itemPrice == 0 && itemQt == 1) { 5096 itemQt = ''; 5097 itemPrice = ''; 5098 } else { 5099 var isNegative = false; 5100 if (parseFloat(itemPrice) < 0) { 5101 isNegative = true; 5102 itemPrice *= -1; 5103 } 5104 if (form.currencyPosition == 'left') { 5105 if (form.summary_hideZeroDecimals == 1 && Number.isInteger(itemPrice)) { 5106 itemPrice = form.currency + '' + lfb_formatPrice(parseInt(itemPrice), formID); 5107 5108 } else { 5109 itemPrice = form.currency + '' + lfb_formatPrice(parseFloat(itemPrice).toFixed(2), formID); 5110 } 5111 } else { 5112 if (form.summary_hideZeroDecimals == 1 && Number.isInteger(itemPrice)) { 5113 itemPrice = lfb_formatPrice(parseInt(itemPrice), formID) + '' + form.currency; 5114 5115 } else { 5116 itemPrice = lfb_formatPrice(parseFloat(itemPrice).toFixed(2), formID) + '' + form.currency; 5117 5118 } 5119 } 5120 if (isNegative) { 5121 itemPrice = '- ' + itemPrice; 5122 } 5123 } 5124 var classIsFile = ''; 5125 if (item.isFile) {} 5126 var cssQt = ''; 5127 if (form.summary_hideQt == 1) { 5128 cssQt = 'lfb-hidden'; 5129 } 5130 if (form.summary_hideZero == 1 && item.price == 0) { 5131 itemPrice = ''; 5132 } 5133 if (form.summary_hideZeroQt == 1 && item.quantity == 0) { 5134 itemQt = ''; 5135 } 5136 5137 var hideClass = ''; 5138 if (!item.showInSummary) { 5139 hideClass = 'lfb-hidden'; 5140 } 5141 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + item.itemid + '"]').is('[data-hideqtsum="true"]')) { 5142 itemQt = ''; 5143 } 5144 5145 if (form.priceSingle > 0 && !item.isSinglePrice && (itemPrice != "" || itemPrice > 0)) { 5146 itemPrice += ' ' + form.subscriptionText; 5147 } 5148 if (form.price <= 0) { 5149 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary .lfb_subTxt').addClass('lfb-hidden'); 5150 } else { 5151 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary .lfb_subTxt').removeClass('lfb-hidden'); 5152 } 5153 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + item.itemid + '"]').is('[data-hidepricesum="true"]')) { 5154 itemPrice = ''; 5155 } 5156 5157 var itemDes = ''; 5158 if (form.summary_showDescriptions == 1) { 5159 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_itemContainer_' + item.itemid + ' .lfb_itemDes').length > 0 && $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_itemContainer_' + item.itemid + ' .lfb_itemDes').html() != '') { 5160 itemDes = '<br/><span class="lfb_sumItemDes" style="font-size:12px;">' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_itemContainer_' + item.itemid + ' .lfb_itemDes').html() + '</span>'; 5161 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_itemContainer_' + item.itemid + ' .lfb_imageButtonDescription').length > 0) { 5162 itemDes = '<br/><span class="lfb_sumItemDes">' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_itemContainer_' + item.itemid + ' .lfb_imageButtonDescription').html() + '</span>'; 5163 5164 } 5165 } 5166 var mustShow = true; 5167 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + item.itemid + '"]').is('[data-hidezero
5167pricesum="true"]') && item.price == 0) { 5168 mustShow = false; 5169 } 5170 5171 if (mustShow) { 5172 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_itemContainer_' + item.itemid + '').is('[data-itemtype="filefield"]')) { 5173 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody #lfb_summaryDiscountTr').before('<tr data-item="' + item.itemid + '" data-itemstep="' + item.stepid + '" class="' + itemClass + ' ' + hideClass + '"><td>' + item.label + itemDes + '</td><td class="lfb_valueTd ' + classIsFile + '">' + value + '</td><td class="lfb_quantityTd ' + cssQt + '">' + itemQt + '</td><td class="lfb_priceTd ' + priceClass + '">' + itemPrice + '</td></tr>'); 5174 } else { 5175 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody #lfb_summaryDiscountTr').before('<tr data-item="' + item.itemid + '" data-itemstep="' + item.stepid + '" class="' + itemClass + ' ' + hideClass + '"><td>' + item.label + itemDes + '</td><td class="lfb_valueTd ' + classIsFile + '"><span class="lfb_value">' + value + '</span></td><td class="lfb_quantityTd ' + cssQt + '">' + itemQt + '</td><td class="lfb_priceTd ' + priceClass + '">' + itemPrice + '</td></tr>'); 5176 5177 } 5178 } 5179 } 5180 } 5181 } 5182 } 5183 }); 5184 5185 if (form.reductionResult > 0) { 5186 var reduction = parseFloat(form.reductionResult).toFixed(2) + form.currency; 5187 if (form.currencyPosition == 'left') { 5188 reduction = form.currency + parseFloat(form.reductionResult).toFixed(2); 5189 } 5190 reduction = '-' + reduction; 5191 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscount>span').html(reduction); 5192 if (!form.discountCodeDisplayed) { 5193 var discLabel = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr th[colspan]').html(); 5194 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr th[colspan] i').length == 0) { 5195 if (discLabel.substr(discLabel.length - 1, 1) == ':') { 5196 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr th[colspan]').html(discLabel.substr(0, discLabel.length - 1) + ' <i>(' + form.discountCode + ')</i> :'); 5197 } else { 5198 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr th[colspan]').html(discLabel + ' <i>(' + form.discountCode + ')</i>'); 5199 } 5200 } 5201 } 5202 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr').css('display', 'table-row'); 5203 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_floatingSummary #lfb_summaryDiscountTr').css('display', 'table-row'); 5204 } 5205 5206 if (form.useVAT == 1) { 5207 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_vatRow').length == 0) { 5208 var $vatRow = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr').clone(); 5209 $vatRow.attr('id', 'lfb_vatRow'); 5210 $vatRow.find('#lfb_summaryDiscount').attr('id', 'lfb_summaryVat'); 5211 $vatRow.children('th').first().html(form.vatLabel + ' ' + form.vatAmount + '% :'); 5212 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr').after($vatRow); 5213 } 5214 5215 5216 5217 var vatText = form.currency + lfb_formatPrice(parseFloat(form.vatPrice).toFixed(2), formID); 5218 if (form.summary_hideZeroDecimals == 1 && Number.isInteger(form.price)) { 5219 vatText = form.currency + lfb_formatPrice(parseInt(form.vatPrice), formID); 5220 } 5221 if (form.currencyPosition != 'left') { 5222 vatText = lfb_formatPrice(parseFloat(form.vatPrice).toFixed(2), formID) + form.currency; 5223 if (form.summary_hideZeroDecimals == 1 && Number.isInteger(form.price)) { 5224 vatText = lfb_formatPrice(parseInt(form.vatPrice), formID) + form.currency; 5225 } 5226 } 5227 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryVat').html(vatText); 5228 } 5229 5230 if (!form.price || form.price < 0) { 5231 form.price = 0; 5232 } 5233 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tr th.lfb_summaryStep').each(function() { 5234 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tr[data-itemstep="' + $(this).attr('data-step') + '"]:not(.lfb-hidden)').length == 0) { 5235 $(this).parent().addClass('lfb-hidden'); 5236 } 5237 }); 5238 var summaryPrice = form.currency + '' + lfb_formatPrice(parseFloat(form.price).toFixed(2), formID); 5239 var summaryPriceSingle = form.currency + '' + lfb_formatPrice(parseFloat(form.priceSingle).toFixed(2), formID); 5240 5241 if (form.summary_hideZeroDecimals == 1 && Number.isInteger(form.price)) { 5242 summaryPrice = form.currency + '' + lfb_formatPrice(parseInt(form.price), formID); 5243 summaryPriceSingle = form.currency + '' + lfb_formatPrice(parseInt(form.priceSingle), formID); 5244 } 5245 if (form.currencyPosition != 'left') { 5246 if (form.summary_hideZeroDecimals == 1 && Number.isInteger(form.price)) { 5247 summaryPrice = lfb_formatPrice(parseInt(form.price), formID) + '' + form.currency; 5248 summaryPriceSingle = lfb_formatPrice(parseInt(form.priceSingle), formID) + '' + form.currency; 5249 } else { 5250 summaryPrice = lfb_formatPrice(parseFloat(form.price).toFixed(2), formID) + '' + form.currency; 5251 summaryPriceSingle = lfb_formatPrice(parseFloat(form.priceSingle).toFixed(2), formID) + '' + form.currency; 5252 } 5253 } 5254 5255 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table #lfb_summaryTotal>span:eq(0)').html(summaryPrice); 5256 5257 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-totalrange]') && parseFloat(form.price) > 0) { 5258 var labelA = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-rangelabelbetween'); 5259 var labelB = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-rangelabeland'); 5260 var range = parseFloat($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-totalrange')); 5261 var rangeMin = (parseFloat(form.price) - range / 2); 5262 5263 var rangeMax = parseFloat(form.price) + range / 2; 5264 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-rangemode="percent"]')) { 5265 rangeMin = parseFloat(form.price) - ((parseFloat(form.price) * range) / 100); 5266 rangeMax = parseFloat(form.price) + ((parseFloat(form.price) * range) / 100); 5267 } 5268 if (rangeMin < 0) { 5269 rangeMin = 0; 5270 } 5271 if (rangeMax < 0) { 5272 rangeMax = 0; 5273 } 5274 5275 var formatedPrice = labelA + ' <strong>' + form.currency + '' + lfb_formatPrice(rangeMin, formID) + '</strong> ' + labelB + ' <strong>' + form.currency + '' + lfb_formatPrice(rangeMax, formID) + '</strong>'; 5276 5277 if (form.currencyPosition != 'left') { 5278 var range = parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-totalrange')); 5279 formatedPrice = labelA + ' <strong>' + lfb_formatPrice(rangeMin, formID) + form.currency + '</strong> ' + labelB + ' <strong>' + lfb_formatPrice(rangeMax, formID) + form.currency + '</strong>'; 5280 } 5281 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table #lfb_summaryTotal>span:eq(0)').html(formatedPrice); 5282 5283 } 5284 var colspan = 4; 5285 if (form.summary_hideQt == 1) { 5286 colspan -= 1; 5287 } 5288 if (form.summary_hidePrices == 1) { 5289 colspan -= 1; 5290 } 5291 if (!hasValues) { 5292 colspan -= 1; 5293 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table td.lfb_valueTd').hide(); 5294 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table thead th:eq(1)').hide().addClass('lfb-hidden'); 5295 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr#lfb_summaryTotalTr th[colspan]').attr('colspan', colspan - 1); 5296 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr#lfb_summaryDiscountTr th[colspan]').attr('colspan', colspan - 1); 5297 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr th.lfb_summaryStep').attr('colspan', colspan); 5298 } else { 5299 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table thead th:eq(1)').show().removeClass('lfb-hidden'); 5300 5301 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr:eq(1)').show(); 5302 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody td.lfb_valueTd').show(); 5303 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr#lfb_summaryTotalTr th[colspan]').attr('colspan', colspan - 1); 5304 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr#lfb_summaryDiscountTr th[colspan]').attr('colspan', colspan - 1); 5305 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tbody tr th.lfb_summaryStep').attr('colspan', colspan); 5306 } 5307 } 5308 5309 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_vatRow').length > 0) { 5310 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_vatRow').children('th').first().attr('colspan', $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary #lfb_summaryDiscountTr').children('th').first().attr('colspan')); 5311 } 5312 5313 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('[data-sumstepsclick="1"]')) { 5314 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary .lfb_summaryStep:not([data-step="final"])').each(function() { 5315 $(this).css('cursor', 'pointer'); 5316 $(this).on('click', function() { 5317 var formID = $(this).closest('#lfb_form').attr('data-form'); 5318 var form = lfb_getForm(formID); 5319 var stepID = parseInt($(this).attr('data-step')); 5320 if (typeof(form.canGoprevious) == 'undefined' || form.canGoprevious) { 5321 lfb_returnToStep(stepID, formID); 5322 } 5323 }); 5324 }); 5325 } 5326 setTimeout(function() { 5327 lfb_updateFloatingSummary(formID); 5328 lfb_updateOtherSummary(formID); 5329 }, 300); 5330 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').trigger('summaryUpdated'); 5331 } 5332 5333 5334 function lfb_changeStep(stepID, formID) { 5335 var form = lfb_getForm(formID); 5336 5337 // if (stepID != form.step) { 5338 5339 $('#lfb_form :not(.ui-slider-handle) > .tooltip').remove(); 5340 $('body > .tooltip').remove(); 5341 $('#lfb_form[data-form="' + form.formID + '"] > .tooltip').remove(); 5342 $('#lfb_form[data-form="' + form.formID + '"] .datetimepicker ').hide(); 5343 5344 if (form.intro_enabled > 0 || form.step > 0) { 5345 var posTop = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').offset().top - 100; 5346 5347 5348 if (form.disableScroll != 1) { 5349 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_fullscreen') || 5350 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_popup')) { 5351 posTop = 0; 5352 if (form.intro_enabled > 0) { 5353 posTop = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #startInfos').height() + 100 5354 } 5355 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').animate({ 5356 scrollTop: posTop 5357 }, 250); 5358 } else { 5359 if ($('header').length > 0 && lfb_isAnyParentFixed($('header'))) { 5360 posTop -= $('header').height(); 5361 } 5362 posTop -= (48 + parseInt(lfb_getScrollTopMargin(form))); 5363 if (form.scrollTopPage == '1') { 5364 $('body,html').animate({ 5365 scrollTop: 0 5366 }, form.animationsSpeed * 2); 5367 } else { 5368 $('body,html').animate({ 5369 scrollTop: posTop 5370 }, 250); 5371 } 5372 } 5373 } 5374 } 5375 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .quantityBtns').removeClass('open'); 5376 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .quantityBtns').fadeOut(form.animationsSpeed / 4); 5377 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide').fadeOut(form.animationsSpeed * 2); 5378 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_btn-next').fadeOut(form.animationsSpeed / 2); 5379 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_btnNextContainer').fadeOut(form.animationsSpeed / 2); 5380 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_linkPreviousCt').fadeOut(form.animationsSpeed / 2); 5381 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_distanceError').fadeOut(form.animationsSpeed / 2); 5382 5383 5384 5385 var activatePaypal = true; 5386 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').length == 0 && 5387 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length == 0 && 5388 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_razorPayCt').length == 0) { 5389 activatePaypal = false;
5390 } 5391 if (stepID == 'final') { 5392 lfb_updateSummary(formID); 5393 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-activatePaypal="true"]:not(:checked):not(.checked)').each(function() { 5394 var cStepID = $(this).closest('.lfb_genSlide').attr('data-stepid'); 5395 if (cStepID != 'final') { 5396 cStepID = parseInt(cStepID); 5397 } 5398 if (jQuery.inArray(cStepID, lfb_lastSteps) == -1) {} else { 5399 activatePaypal = false; 5400 } 5401 }); 5402 5403 5404 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').find('[data-dontactivatepaypal="true"].checked,[data-dontactivatepaypal="true"]:checked').length > 0) { 5405 activatePaypal = false; 5406 } 5407 if (activatePaypal) { 5408 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns').show(); 5409 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns').length > 0) { 5410 5411 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_razorPayCt').hide(); 5412 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').hide(); 5413 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').closest('.lfb_btnNextContainer').hide(); 5414 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').hide(); 5415 } else { 5416 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').length > 0) { 5417 5418 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').show(); 5419 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_btnNextContainerStripe').show(); 5420 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnOrder').closest('.lfb_btnNextContainer').hide(); 5421 5422 } 5423 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_razorPayCt').show(); 5424 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').length > 0) { 5425 5426 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').show(); 5427 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnOrder').closest('.lfb_btnNextContainer').hide(); 5428 setTimeout(function() { 5429 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm .lfb_btnNextContainer').fadeIn(); 5430 }, form.animationsSpeed * 2); 5431 } 5432 } 5433 } else { 5434 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns').hide(); 5435 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_razorPayCt').hide(); 5436 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').hide(); 5437 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paypalForm').hide(); 5438 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_btnNextContainerStripe').hide(); 5439 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnPayStripe').closest('.lfb_btnNextContainer').hide(); 5440 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnOrder').closest('.lfb_btnNextContainer').show(); 5441 5442 } 5443 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-emaillaststep="1"]') && !form.emailSent) { 5444 setTimeout(function() { 5445 lfb_updatePrice(formID); 5446 setTimeout(function() { 5447 lfb_order(formID); 5448 }, 1000); 5449 }, 1200); 5450 } 5451 } 5452 5453 var $title = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.lfb_stepTitle'); 5454 var $des = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('p.lfb_stepDescription'); 5455 var $content = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.lfb_genContent'); 5456 var totalBottom = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.lfb_totalBottomContainer'); 5457 $content.find('.lfb_genContentSlide').removeClass('active'); 5458 $content.find('.lfb_genContentSlide').eq(0).addClass('active'); 5459 5460 5461 $content.animate({ 5462 opacity: 0 5463 }, form.animationsSpeed); 5464 $des.animate({ 5465 opacity: 0 5466 }, form.animationsSpeed); 5467 $title.removeClass('positioned'); 5468 $title.css({ 5469 "-webkit-transition": "none", 5470 "transition": "none" 5471 }); 5472 totalBottom.animate({ 5473 opacity: 0 5474 }, form.animationsSpeed); 5475 if (typeof ga !== 'undefined') { 5476 try { 5477 ga('set', 'page', location.pathname + "#" + encodeURIComponent($title.html()).replace(/%20/g, '+')); 5478 ga('send', 'pageview'); 5479 } catch (e) {} 5480 } 5481 if (typeof gtag !== 'undefined') { 5482 try { 5483 gtag('event', 'page_view', { 5484 page_location: window.location.href, 5485 page_path: location.pathname + "#" + encodeURIComponent($title.html()).replace(/%20/g, '+'), 5486 page_title: document.title + " " + $title.html(), 5487 }); 5488 5489 gtag('set', 'page', location.pathname + "#" + encodeURIComponent($title.html()).replace(/%20/g, '+')); 5490 gtag('send', 'pageview'); 5491 } catch (e) {} 5492 } 5493 5494 5495 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').css('opacity', 0).show(); 5496 5497 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').hide().css('opacity', 1); 5498 var animSpeed = form.animationsSpeed * 4.5; 5499 5500 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').is('[data-start="1"]')) { 5501 lfb_initPanelResize(formID); 5502 animSpeed = form.animationsSpeed * 2.5; 5503 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').fadeIn(form.animationsSpeed * 2); 5504 } else { 5505 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').delay(form.animationsSpeed * 2).fadeIn(form.animationsSpeed * 2); 5506 } 5507 5508 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalSlide .estimation_project').length > 0) { 5509 var contentForm = lfb_getFormContent(formID); 5510 var content = contentForm[3]; 5511 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalSlide .estimation_project textarea').val(content); 5512 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalSlide .estimation_total:not(.gfield_price) input').val(form.price); 5513 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalSlide .estimation_total.gfield_price .ginput_product_price').html(form.price); 5514 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalSlide .estimation_total.gfield_price input[id^="ginput_base_price"]').val(form.price); 5515 5516 5517 } 5518 if (animSpeed == 0) { 5519 animSpeed = 100; 5520 } 5521 5522 setTimeout(function() { 5523 $title.css({ 5524 "-webkit-transition": "all 0.3s ease-out", 5525 "transition": "all 0.3s ease-out" 5526 }).addClass('positioned'); 5527 5528 5529 $content.css({ 5530 paddingTop: lfb_zeroIfNan($des.height()) + lfb_zeroIfNan($title.height()) + 70 5531 }); 5532 $content.delay(form.animationsSpeed * 2).animate({ 5533 opacity: 1 5534 }, form.animationsSpeed); 5535 $des.delay(form.animationsSpeed).animate({ 5536 opacity: 1, 5537 top: $des.closest('.lfb_genSlide').find('.lfb_stepTitle').height() + 48 5538 }, form.animationsSpeed); 5539 5540 totalBottom.delay(form.animationsSpeed * 2).animate({ 5541 opacity: 1 5542 }, form.animationsSpeed); 5543 5544 5545 setTimeout(function() { 5546 var titleHeight = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_stepTitle').height(); 5547 5548 var heightP = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_genContent').outerHeight() + parseInt($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').css('padding-bottom')) + 102 + titleHeight; 5549 5550 if (stepID == 'final') { 5551 heightP -= 80; 5552 } 5553 5554 var animMainPanelSpeed = 300; 5555 if (form.animationsSpeed == 0) { 5556 animMainPanelSpeed = 0; 5557 } 5558 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').animate({ minHeight: heightP }, animMainPanelSpeed); 5559 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').css('max-height', 'none'); 5560 }, form.animationsSpeed * 2); 5561 5562 5563 5564 if (!$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btn-next').is('.lfb_disabledBtn')) { 5565 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btn-next').css('display', 'inline-block').hide(); 5566 setTimeout(function() { 5567 if (!$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btn-next').is('.lfb_disabledBtn')) { 5568 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btn-next').fadeIn(500); 5569 setTimeout(function() { 5570 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btn-next').is('.lfb_disabledBtn')) { 5571 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btn-next').hide(); 5572 } 5573 }, 550); 5574 } 5575 }, form.animationsSpeed * 2); 5576 } else { 5577 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btn-next').hide(); 5578 } 5579 5580 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .datetimepicker').hide(); 5581 5582 if (stepID == 'final') { 5583 if (activatePaypal) { 5584 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns').length == 0) { 5585 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_razorPayCt').length > 0) { 5586 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_genContentSlide > .lfb_btnNextContainer').hide(); 5587 5588 } 5589 } 5590 } else { 5591 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btnNextContainer').fadeIn(500); 5592 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btnNextContainerStripe').hide(); 5593 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_paymentMethodBtns').hide(); 5594 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeForm .lfb_stripeContainer').hide(); 5595 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeForm .lfb_btnNextContainer').hide(); 5596 5597 } 5598 5599 if (form.useSignature == 1) { 5600 $('#lfb_form[data-form="' + form.formID + '"] #lfb_signature canvas').attr('width', $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_signature').width()); 5601 $('#lfb_form[data-form="' + form.formID + '"] #lfb_signature canvas').css('width', $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_signature').width()); 5602 form.signature.signature('clear'); 5603 } 5604 } else { 5605 if (form.animationsSpeed == 0) { 5606 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btnNextContainer').show(); 5607 5608 } else { 5609 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_btnNextContainer').fadeIn(500); 5610 } 5611 } 5612 5613 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-previousstepbtn="true"]') && stepID == 'final') { 5614 5615 setTimeout(function() { 5616 var chkBtn = false;
5617 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + stepID + '"] ').find('.lfb_btn-next,#lfb_btnOrderPaypal,#lfb_btnPayStripe,#lfb_btnOrder,#btnOrderRazorpay').each(function() { 5618 if ($(this).css('display') != 'none' && $(this).closest('.lfb_btnNextContainer').css('display') != 'none') { 5619 chkBtn = true; 5620 } 5621 }); 5622 if (chkBtn) { 5623 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + stepID + '"] ').find('.linkPrevious').css({ 5624 marginTop: -15 5625 }); 5626 } else { 5627 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + stepID + '"] ').find('.linkPrevious').css({ 5628 marginTop: 24 5629 }); 5630 } 5631 if (lfb_lastSteps.length > 0) { 5632 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"][data-previousstepbtn="true"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_linkPreviousCt').delay(form.animationsSpeed * 3).fadeIn(500); 5633 5634 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"]:not([data-previousstepbtn="true"]) #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_linkPreviousCt').delay(form.animationsSpeed * 3).css({ opacity: 0, display: 'inline-block' }).animate({ opacity: 1 }, 600); 5635 } 5636 }, 1000); 5637 5638 } else { 5639 if (lfb_lastSteps.length > 0) { 5640 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"][data-previousstepbtn="true"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_linkPreviousCt').delay(form.animationsSpeed * 3).fadeIn(500); 5641 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"]:not([data-previousstepbtn="true"]) #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_linkPreviousCt').delay(form.animationsSpeed * 3).css({ opacity: 0, display: 'inline-block' }).animate({ opacity: 1 }, 600); 5642 5643 } 5644 } 5645 5646 5647 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_distanceError').delay(form.animationsSpeed * 3).fadeIn(500); 5648 5649 5650 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 5651 var deviceAgent = navigator.userAgent.toLowerCase(); 5652 var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i); 5653 if (agentID) { 5654 $content.delay(750).find('[data-toggle="tooltip"]').tooltip({ 5655 html: true, 5656 container: '#lfb_form[data-form="' + formID + '"]', 5657 trigger: 'manual' 5658 }).on('show.bs.tooltip', function() { 5659 $(this).find('.tooltip-inner').css({ 5660 maxWidth: $(window).width() 5661 }); 5662 }); 5663 } else { 5664 $content.delay(750).find('[data-toggle="tooltip"]').tooltip({ 5665 html: true, 5666 container: '#lfb_form[data-form="' + formID + '"]' 5667 }).on('show.bs.tooltip', function(t, a) { 5668 $('#lfb_form[data-form="' + formID + '"] .tooltip-inner').css({ 5669 maxWidth: $(window).width() + 'px' 5670 }); 5671 }); 5672 } 5673 $content.on('enter', function() { 5674 if (this.options.trigger == 'hover' && 'ontouchstart' in document.documentElement) { 5675 return; 5676 } 5677 }); 5678 } 5679 5680 5681 setTimeout(function() { 5682 5683 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide.lfb_activeStep').removeClass('lfb_activeStep'); 5684 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').addClass('lfb_activeStep'); 5685 $content.find('.lfb_itemQtField').each(function() { 5686 if ($(this).parent().next().is('.lfb_itemDes')) { 5687 $(this).css({ 5688 marginTop: 20 + $(this).parent().next().outerHeight() 5689 }); 5690 } 5691 });
5692 form.step = stepID; 5693 setTimeout(function() { 5694 lfb_updateStep(formID); 5695 5696 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('[data-usedistance="true"]').each(function() { 5697 lfb_removeDistanceError($(this).attr('data-itemid'), formID); 5698 }, 100); 5699 $('#lfb_form :not(.ui-slider-handle) > .tooltip').remove(); 5700 $('body > .tooltip').remove(); 5701 $('#lfb_form[data-form="' + formID + '"] > .tooltip').remove(); 5702 5703 5704 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').attr('data-currentstep', stepID); 5705 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').trigger('stepChanged'); 5706 5707 5708 }, (form.animationsSpeed * 2) + 550); 5709 lfb_updatePrice(formID); 5710 if (form.backFomFinal) { 5711 form.backFomFinal = false;
5712 } 5713 5714 }, 300); 5715 5716 }, animSpeed); 5717 5718 if (form.animationsSpeed == 0) { 5719 setTimeout(lfb_resizeAll, 500); 5720 } 5721 5722 5723 $('#lfb_form :not(.ui-slider-handle) > .tooltip').remove(); 5724 $('body > .tooltip').remove(); 5725 $('#lfb_form[data-form="' + formID + '"] > .tooltip').remove(); 5726 lfb_updatePrice(formID); 5727 // } 5728 } 5729 5730 function lfb_zeroIfNan(value) { 5731 if (isNaN(value)) { 5732 return 0; 5733 } else { 5734 return value; 5735 } 5736 } 5737 5738 function lfb_findPotentialsSteps(originStepID, formID) { 5739 var form = lfb_getForm(formID); 5740 var potentialSteps = new Array(); 5741 var conditionsArray = new Array(); 5742 var noConditionsSteps = new Array(); 5743 var maxConditions = 0; 5744 jQuery.each(form.links, function() { 5745 var link = this; 5746 5747 if (link.originID == originStepID) { 5748 var error = false; 5749 var errorOR = true; 5750 if (link.conditions && link.conditions != "[]") { 5751 link.conditionsO = JSON.parse(link.conditions); 5752 var errors = lfb_checkConditions(link.conditionsO, formID, originStepID); 5753 error = errors.error; 5754 errorOR = errors.errorOR; 5755 } else { 5756 noConditionsSteps.push(link.destinationID); 5757 errorOR = false; 5758 } 5759 if ((link.operator == 'OR' && !errorOR) || (link.operator != 'OR' && !error)) { 5760 link.conditionsO = JSON.parse(link.conditions); 5761 conditionsArray.push({ 5762 stepID: parseInt(link.destinationID), 5763 nbConditions: link.conditionsO.length 5764 }); 5765 if (link.conditionsO.length > maxConditions) { 5766 maxConditions = link.conditionsO.length; 5767 } 5768 potentialSteps.push(parseInt(link.destinationID)); 5769 5770 } 5771 } 5772 }); 5773 if (originStepID == 0) { 5774 potentialSteps.push(parseInt($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-start="1"]').attr('data-stepid'))); 5775 } 5776 if (potentialSteps.length == 0) { 5777 potentialSteps.push('final'); 5778 } else if (noConditionsSteps.length > 0 && noConditionsSteps.length < potentialSteps.length) { 5779 jQuery.each(noConditionsSteps, function() { 5780 var removeItem = this; 5781 potentialSteps = jQuery.grep(potentialSteps, function(value) { 5782 return value != removeItem; 5783 }); 5784 }); 5785 if (maxConditions > 0) { 5786 jQuery.each(potentialSteps, function(stepID) { 5787 jQuery.each(conditionsArray, function(condition) { 5788 if (condition.stepID == stepID && condition.nbConditions < maxConditions) { 5789 potentialSteps = jQuery.grep(potentialSteps, function(value) { 5790 return value != stepID; 5791 }); 5792 } 5793 }); 5794 }); 5795 } 5796 } 5797 return potentialSteps; 5798 } 5799 5800 function lfb_checkConditions(conditions, formID, _stepID, onlyPastSteps) { 5801 var error = false; 5802 var form = lfb_getForm(formID); 5803 var errorOR = true; 5804 if (typeof(onlyPastSteps) == 'undefined') { 5805 onlyPastSteps = false; 5806 } 5807 5808 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 5809 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 5810 lastAndCurrentSteps.push(parseInt(form.step)); 5811 } else if (form.step == 'final' && jQuery.inArray('final', lastAndCurrentSteps) == -1) { 5812 lastAndCurrentSteps.push('final'); 5813 } 5814 5815 5816 jQuery.each(conditions, function() { 5817 var condition = this; 5818 if (condition.interaction.substr(0, 1) != '_' && condition.interaction.substr(0, 2) != 'v_') { 5819 var stepID = condition.interaction.substr(0, condition.interaction.indexOf('_')); 5820 if (stepID == 0) { 5821 stepID = 'final'; 5822 } 5823 var chkStep = true; 5824 if (onlyPastSteps) { 5825 if (lastAndCurrentSteps.indexOf(parseInt(stepID)) == -1 /*|| stepID == form.step*/ ) { 5826 if (condition.action && condition.action == "unclicked") { 5827 error = false;
5828 } else { 5829 error = true; 5830 } 5831 chkStep = false; 5832 } 5833 } 5834 if (condition.value && typeof(condition.value) == 'string') { 5835 condition.value = condition.value.replace(/</g, "<"); 5836 condition.value = condition.value.replace(/>/g, ">"); 5837 } 5838 5839 if (chkStep) { 5840 5841 var itemID = condition.interaction.substr(condition.interaction.indexOf('_') + 1, condition.interaction.length); 5842 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_genContent [data-itemid="' + itemID + '"]').length > 0) { 5843 5844 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_genContent [data-itemid="' + itemID + '"]'); 5845 5846 if ($item.is('.lfb_disabled') || $item.closest('.lfb_genSlide').is('.lfb_disabled')) { 5847 if (condition.action != "unclicked") { 5848 error = true; 5849 } else { 5850 errorOR = false; 5851 } 5852 } else { 5853 if (condition.value && condition.value.indexOf('_') > -1) { 5854 if (condition.value.substr(0, 1) != '_') { 5855 var valueStepID = condition.value.substr(0, condition.value.indexOf('_')); 5856 var attribute = condition.value.substr(condition.value.indexOf('-') + 1, condition.value.length); 5857 if (valueStepID == 0) { 5858 valueStepID = 'final'; 5859 } 5860 var valueItemID = condition.value.substr(condition.value.indexOf('_') + 1, condition.value.indexOf('-') - (condition.value.indexOf('_') + 1)); 5861 if (valueStepID == 'v') { 5862 condition.value = parseFloat(lfb_getVariableByID(form, valueItemID).value); 5863 } else if (attribute == 'stepqt') { 5864 condition.value = lfb_getStepQuantities(stepID, formID, itemID); 5865 } else { 5866 var $valueItem = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + valueStepID + '"] .lfb_genContent [data-itemid="' + valueItemID + '"]'); 5867 5868 if ($valueItem.length > 0) { 5869 if (attribute == '') { 5870 if (typeof($valueItem.data('resprice')) != 'undefined') { 5871 condition.value = parseFloat($valueItem.data('resprice')); 5872 } else if ($valueItem.is('[data-resqt]')) { 5873 condition.value = parseFloat($valueItem.attr('data-resqt')); 5874 } 5875 } else if (attribute == 'quantity') { 5876 if ($valueItem.is('.lfb_disabled')) { 5877 condition.value = 0; 5878 } else { 5879 if ($valueItem.is('input[type="number"]')) { 5880 condition.value = $valueItem.val(); 5881 } else { 5882 if ($valueItem.find('.lfb_qtfield').length > 0) { 5883 condition.value = parseInt($valueItem.find('.lfb_qtfield').val()); 5884 } else { 5885 condition.value = parseInt($valueItem.find('.icon_quantity').html()); 5886 } 5887 5888 } 5889 } 5890 } else if (attribute == 'value') { 5891 if ($valueItem.is('.lfb_disabled')) { 5892 condition.value = ''; 5893 } else { 5894 5895 condition.value = $valueItem.val(); 5896 5897 if ($valueItem.is('.lfb_datepicker')) { 5898 condition.value = moment.utc($valueItem.datetimepicker("getDate")).format('YYYY-MM-DD'); 5899 } 5900 condition.value = condition.value.replace(/\`/g, "'"); 5901 } 5902 } 5903 } 5904 } 5905 } else { 5906 5907 if (condition.value == '_total' || condition.value == '_total-') { 5908 condition.value = form.price; 5909 } else if (condition.value == '_total_qt') { 5910 condition.value = lfb_getTotalQuantities(formID, _stepID, itemID); 5911 } 5912 } 5913 5914 } else if (condition.value) { 5915 condition.value = condition.value.replace(/\`/g, "'"); 5916 } 5917 switch (condition.action) { 5918 case "clicked": 5919 if ($item.closest('.lfb_itemBloc').is('.lfb_disabled')) { 5920 error = true; 5921 } else { 5922 5923 if ($item.is('[type="checkbox"]')) { 5924 if (!$item.is(':checked')) { 5925 error = true; 5926 } 5927 if ($item.is(':checked')) { 5928 errorOR = false;
5929 } 5930 } else { 5931 if (!$item.is('.checked') && !$item.is(':checked')) { 5932 error = true; 5933 } 5934 if ($item.is('.checked') || $item.is(':checked')) { 5935 errorOR = false; 5936 } 5937 } 5938 } 5939 break; 5940 case "unclicked": 5941 if ($item.closest('.lfb_itemBloc').is('.lfb_disabled')) { 5942 errorOR = false; 5943 error = false; 5944 } else { 5945 if ($item.is(':not([type="checkbox"]).checked') || $item.is(':checked')) { 5946 error = true; 5947 } 5948 if (!$item.is(':not([type="checkbox"]).checked') && !$item.is(':checked')) { 5949 errorOR = false; 5950 } 5951 } 5952 break; 5953 case "filled": 5954 if ($item.is('.lfb_dropzone')) { 5955 if ($item.find('.dz-preview[data-file].dz-success.dz-complete').length == 0) { 5956 error = true; 5957 } else { 5958 errorOR = false; 5959 } 5960 } else { 5961 if ($item.val().length == 0) { 5962 error = true; 5963 } else { 5964 errorOR = false; 5965 } 5966 } 5967 5968 break; 5969 case "equal": 5970 if ($item.is('.lfb_datepicker')) { 5971 if ($item.is('[data-datetype="date"]')) { 5972 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') != condition.value) { 5973 error = true; 5974 } 5975 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') == condition.value) { 5976 errorOR = false; 5977 } 5978 } else if ($item.is('[data-datetype="time"]')) { 5979 if (moment($item.datetimepicker("getDate")).format('HH:mm') != condition.value) { 5980 error = true; 5981 } 5982 if (moment($item.datetimepicker("getDate")).format('HH:mm') == condition.value) { 5983 errorOR = false; 5984 } 5985 } else { 5986 if (!moment.utc($item.datetimepicker("getDate")).isSame(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 5987 error = true; 5988 } 5989 if (moment.utc($item.datetimepicker("getDate")).isSame(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 5990 errorOR = false; 5991 } 5992 } 5993 } else { 5994 if ($item.val() != condition.value) { 5995 error = true; 5996 } else { 5997 errorOR = false;
5998 } 5999 } 6000 break; 6001 case "different": 6002 if ($item.val() == condition.value) { 6003 error = true; 6004 } else { 6005 errorOR = false; 6006 } 6007 break; 6008 case "PriceSuperior": 6009 var price = parseFloat($item.data('resprice')); 6010 if ($item.is('.lfb_button:not(.checked)') || $item.is('.lfb_selectable:not(.checked)') || $item.is('input[type=checkbox]:not(:checked)') || price <= condition.value) { 6011 error = true; 6012 } 6013 if (($item.is('.checked') || $item.is(':checked')) && price > condition.value) { 6014 errorOR = false; 6015 } 6016 break; 6017 case "PriceInferior": 6018 var price = parseFloat($item.data('resprice')); 6019 if ($item.is('.lfb_button:not(.checked)') || $item.is('.lfb_selectable:not(.checked)') || $item.is('input[type=checkbox]:not(:checked)') || price >= condition.value) { 6020 error = true; 6021 } 6022 if (($item.is('.checked') || $item.is(':checked')) && price < condition.value) { 6023 errorOR = false; 6024 } 6025 break; 6026 case "PriceEqual": 6027 var price = parseFloat($item.data('resprice')); 6028 if ($item.is('.lfb_button:not(.checked)') || $item.is('.lfb_selectable:not(.checked)') || $item.is('input[type=checkbox]:not(:checked)') || price != condition.value) { 6029 error = true; 6030 } 6031 if (($item.is('.checked') || $item.is(':checked')) && price == condition.value) { 6032 errorOR = false; 6033 } 6034 break; 6035 case "PriceDifferent": 6036 var price = parseFloat($item.data('resprice')); 6037 if ($item.is('.lfb_button:not(.checked)') || $item.is('.lfb_selectable:not(.checked)') || $item.is('input[type=checkbox]:not(:checked)') || price == condition.value) { 6038 error = true; 6039 } 6040 if (($item.is('.checked') || $item.is(':checked')) && price != condition.value) { 6041 errorOR = false; 6042 } 6043 break; 6044 case "QtSuperior": 6045 if ($item.is('.lfb_selectable:not(.checked)') || ($item.find('.icon_quantity').length > 0 && parseInt($item.find('.icon_quantity').html()) <= condition.value) || ($item.find('.lfb_qtfield').length > 0 && parseInt($item.find('.lfb_qtfield').val()) <= condition.value) || ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) <= condition.value)) { 6046 6047 error = true; 6048 } 6049 if ($item.is('.lfb_selectable')) { 6050 if ($item.is('.lfb_selectable.checked') && (parseInt($item.find('.icon_quantity').html()) > condition.value) || (parseInt($item.find('.lfb_qtfield').val()) > condition.value)) { 6051 errorOR = false;
6052 } 6053 } else if ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) > condition.value) { 6054 errorOR = false; 6055 } 6056 if ($item.is('input')) { 6057 if (parseInt($item.val()) <= condition.value) { 6058 error = true; 6059 } 6060 if (parseInt($item.val()) > condition.value) { 6061 errorOR = false; 6062 } 6063 } 6064 6065 break; 6066 case "QtInferior": 6067 if ($item.is('.lfb_selectable:not(.checked)') || ($item.find('.icon_quantity').length > 0 && parseInt($item.find('.icon_quantity').html()) >= condition.value) || ($item.find('.lfb_qtfield').length > 0 && parseInt($item.find('.lfb_qtfield').val()) >= condition.value) || ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) >= condition.value)) { 6068 error = true; 6069 } 6070 if ($item.is('.lfb_selectable')) { 6071 if ($item.is('.lfb_selectable.checked') && (parseInt($item.find('.icon_quantity').html()) < condition.value) || (parseInt($item.find('.lfb_qtfield').val()) < condition.value)) { 6072 errorOR = false; 6073 } 6074 } else if ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) < condition.value) { 6075 errorOR = false; 6076 } 6077 if ($item.is('input')) { 6078 if (parseInt($item.val()) >= condition.value) { 6079 error = true; 6080 } 6081 if (parseInt($item.val()) < condition.value) { 6082 errorOR = false; 6083 } 6084 } 6085 break; 6086 case "QtEqual": 6087 if ($item.is('.lfb_selectable:not(.checked)') || ($item.find('.icon_quantity').length > 0 && parseInt($item.find('.icon_quantity').html()) != condition.value) || ($item.find('.lfb_qtfield').length > 0 && parseInt($item.find('.lfb_qtfield').val()) != condition.value) || ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) != condition.value)) { 6088 error = true; 6089 } 6090 if ($item.is('.lfb_selectable')) { 6091 if ($item.is('.lfb_selectable.checked') && (parseInt($item.find('.icon_quantity').html()) == condition.value) || (parseInt($item.find('.lfb_qtfield').val()) == condition.value)) { 6092 errorOR = false; 6093 } 6094 } else if ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) == condition.value) { 6095 errorOR = false; 6096 } 6097 if ($item.is('input')) { 6098 if (parseInt($item.val()) != condition.value) { 6099 error = true; 6100 } 6101 if (parseInt($item.val()) == condition.value) { 6102 errorOR = false;
6103 } 6104 } 6105 break; 6106 case "QtDifferent": 6107 if ($item.is('.lfb_selectable:not(.checked)') || ($item.find('.icon_quantity').length > 0 && parseInt($item.find('.icon_quantity').html()) == condition.value) || ($item.find('.lfb_qtfield').length > 0 && parseInt($item.find('.lfb_qtfield').val()) == condition.value) || ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) == condition.value)) { 6108 error = true; 6109 } 6110 if ($item.is('.lfb_selectable')) { 6111 if ($item.is('.lfb_selectable.checked') && (parseInt($item.find('.icon_quantity').html()) != condition.value) || (parseInt($item.find('.lfb_qtfield').val()) != condition.value)) { 6112 errorOR = false; 6113 } 6114 } else if ($item.is('[data-type="slider"]') && $item.is('.ui-slider') && parseInt($item.slider("value")) != condition.value) { 6115 errorOR = false; 6116 } 6117 if ($item.is('input')) { 6118 if (parseInt($item.val()) == condition.value) { 6119 error = true; 6120 } 6121 if (parseInt($item.val()) != condition.value) { 6122 errorOR = false; 6123 } 6124 } 6125 break; 6126 case "superior": 6127 if ($item.is('.lfb_datepicker')) { 6128 if ($item.is('[data-datetype="date"]')) { 6129 if (moment($item.datetimepicker("getDate")).format('YYYY-MM-DD 00:00') <= moment(condition.value).format('YYYY-MM-DD 00:00')) { 6130 error = true; 6131 } 6132 if (moment($item.datetimepicker("getDate")).format('YYYY-MM-DD 00:00') > moment(condition.value).format('YYYY-MM-DD 00:00')) { 6133 errorOR = false; 6134 } 6135 } else if ($item.is('[data-datetype="time"]')) { 6136 if (moment($item.datetimepicker("getDate")).format('HH:mm') <= condition.value) { 6137 error = true; 6138 } 6139 if (moment.utc($item.datetimepicker("getDate")).format('HH:mm') > condition.value) { 6140 errorOR = false; 6141 } 6142 } else { 6143 if (moment.utc($item.datetimepicker("getDate")).isSameOrBefore(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6144 error = true; 6145 } 6146 if (moment.utc($item.datetimepicker("getDate")).isAfter(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6147 errorOR = false; 6148 } 6149 } 6150 } else if ($item.is('.lfb_timepicker')) { 6151 var valueHour = parseInt(condition.value.substr(0, condition.value.indexOf(':'))); 6152 var valueMins = parseInt(condition.value.substr(condition.value.indexOf(':') + 1, 2)); 6153 if (condition.value.indexOf('PM') > 0 && valueHour != 12) { 6154 valueHour += 12; 6155 } 6156 var itemHour = parseInt($item.val().substr(0, $item.val().indexOf(':'))); 6157 var itemMins = parseInt($item.val().substr($item.val().indexOf(':') + 1, 2)); 6158 if ($item.val().indexOf('PM') > 0 && itemHour != 12) { 6159 itemHour += 12; 6160 } 6161 if (itemHour < valueHour || (itemHour == valueHour && itemMins <= valueMins)) { 6162 error = true; 6163 } 6164 if (itemHour > valueHour || (itemHour == valueHour && itemMins > valueMins)) { 6165 errorOR = false;
6166 } 6167 6168 } else if ($item.is('input[type="number"]')) { 6169 if (parseFloat($item.val()) <= parseFloat(condition.value)) { 6170 error = true; 6171 } 6172 if (parseFloat($item.val()) > parseFloat(condition.value)) { 6173 errorOR = false; 6174 } 6175 } else if ($item.is('[data-itemtype="rate"]')) { 6176 if (parseFloat($item.find('.lfb_rate').rate('getValue')) <= parseFloat(condition.value)) { 6177 error = true; 6178 } 6179 if (parseFloat($item.find('.lfb_rate').rate('getValue')) > parseFloat(condition.value)) { 6180 errorOR = false; 6181 } 6182 } 6183 break; 6184 case "inferior": 6185 if ($item.is('.lfb_datepicker')) { 6186 if ($item.is('[data-datetype="date"]')) { 6187 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') >= condition.value) { 6188 error = true; 6189 } 6190 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') < condition.value) { 6191 errorOR = false; 6192 } 6193 } else if ($item.is('[data-datetype="time"]')) { 6194 if (moment.utc($item.datetimepicker("getDate")).format('HH:mm') >= condition.value) { 6195 error = true; 6196 } 6197 if (moment.utc($item.datetimepicker("getDate")).format('HH:mm') < condition.value) { 6198 errorOR = false; 6199 } 6200 } else { 6201 /* if (moment.utc($item.datetimepicker("getDate")).isSameOrAfter(moment.utc(condition.value).toDate().getTime())) { 6202 error = true; 6203 } 6204 if (moment.utc($item.datetimepicker("getDate")).isBefore(moment.utc(condition.value).toDate().getTime())) { 6205 errorOR = false; 6206 }*/ 6207 if (moment.utc($item.datetimepicker("getDate")).isSameOrAfter(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6208 error = true; 6209 } 6210 if (moment.utc($item.datetimepicker("getDate")).isBefore(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6211 errorOR = false; 6212 } 6213 } 6214 } else if ($item.is('.lfb_timepicker')) { 6215 var valueHour = parseInt(condition.value.substr(0, condition.value.indexOf(':'))); 6216 var valueMins = parseInt(condition.value.substr(condition.value.indexOf(':') + 1, 2)); 6217 if (condition.value.indexOf('PM') > 0 && valueHour != 12) { 6218 valueHour += 12; 6219 } 6220 var itemHour = parseInt($item.val().substr(0, $item.val().indexOf(':'))); 6221 var itemMins = parseInt($item.val().substr($item.val().indexOf(':') + 1, 2)); 6222 if ($item.val().indexOf('PM') > 0 && itemHour != 12) { 6223 itemHour += 12; 6224 } 6225 if (itemHour > valueHour || (itemHour == valueHour && itemMins >= valueMins)) { 6226 error = true; 6227 } 6228 if (itemHour < valueHour || (itemHour == valueHour && itemMins < valueMins)) { 6229 errorOR = false;
6230 } 6231 6232 } else if ($item.is('input[type="number"]')) { 6233 if (parseFloat($item.val()) >= parseFloat(condition.value)) { 6234 error = true; 6235 } 6236 if (parseFloat($item.val()) < parseFloat(condition.value)) { 6237 errorOR = false; 6238 } 6239 } else if ($item.is('[data-itemtype="rate"]')) { 6240 if (parseFloat($item.find('.lfb_rate').rate('getValue')) >= parseFloat(condition.value)) { 6241 error = true; 6242 } 6243 if (parseFloat($item.find('.lfb_rate').rate('getValue')) < parseFloat(condition.value)) { 6244 errorOR = false; 6245 } 6246 } 6247 break; 6248 case "equal": 6249 if ($item.is('.lfb_datepicker')) { 6250 if ($item.is('[data-datetype="date"]')) { 6251 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') != condition.value) { 6252 error = true; 6253 } 6254 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') == condition.value) { 6255 errorOR = false; 6256 } 6257 } else if ($item.is('[data-datetype="time"]')) { 6258 if (moment.utc($item.datetimepicker("getDate")).format('HH:mm') != condition.value) { 6259 error = true; 6260 } 6261 if (moment.utc($item.datetimepicker("getDate")).format('HH:mm') == condition.value) { 6262 errorOR = false; 6263 } 6264 } else { 6265 if (!moment.utc($item.datetimepicker("getDate")).isSame(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6266 error = true; 6267 } 6268 if (moment.utc($item.datetimepicker("getDate")).isSame(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6269 errorOR = false; 6270 } 6271 } 6272 } else if ($item.is('.lfb_timepicker')) { 6273 var valueHour = parseInt(condition.value.substr(0, condition.value.indexOf(':'))); 6274 var valueMins = parseInt(condition.value.substr(condition.value.indexOf(':') + 1, 2)); 6275 if (condition.value.indexOf('PM') > 0 && valueHour != 12) { 6276 valueHour += 12; 6277 } 6278 var itemHour = parseInt($item.val().substr(0, $item.val().indexOf(':'))); 6279 var itemMins = parseInt($item.val().substr($item.val().indexOf(':') + 1, 2)); 6280 if ($item.val().indexOf('PM') > 0 && itemHour != 12) { 6281 itemHour += 12; 6282 } 6283 if (itemHour != valueHour) { 6284 error = true; 6285 } 6286 if (itemHour == valueHour) { 6287 errorOR = false;
6288 } 6289 6290 } else if ($item.is('input[type="number"]')) { 6291 if (parseFloat($item.val()) != parseFloat(condition.value)) { 6292 error = true; 6293 } 6294 if (parseFloat($item.val()) == parseFloat(condition.value)) { 6295 errorOR = false; 6296 } 6297 } else if ($item.is('[data-itemtype="rate"]')) { 6298 if (parseFloat($item.find('.lfb_rate').rate('getValue')) != parseFloat(condition.value)) { 6299 error = true; 6300 } 6301 if (parseFloat($item.find('.lfb_rate').rate('getValue')) == parseFloat(condition.value)) { 6302 errorOR = false; 6303 } 6304 } 6305 break; 6306 case "different": 6307 if ($item.is('.lfb_datepicker')) { 6308 if ($item.is('[data-datetype="date"]')) { 6309 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') == condition.value) { 6310 error = true; 6311 } 6312 if (moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD') != condition.value) { 6313 errorOR = false; 6314 } 6315 } else if ($item.is('[data-datetype="time"]')) { 6316 if (moment.utc($item.datetimepicker("getDate")).format('HH:mm') == condition.value) { 6317 error = true; 6318 } 6319 if (moment.utc($item.datetimepicker("getDate")).format('HH:mm') != condition.value) { 6320 errorOR = false; 6321 } 6322 } else { 6323 if (moment.utc($item.datetimepicker("getDate")).isSame(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6324 error = true; 6325 } 6326 if (!moment.utc($item.datetimepicker("getDate")).isSame(moment.utc(condition.value).format('YYYY-MM-DD HH:mm'))) { 6327 errorOR = false; 6328 } 6329 } 6330 } else if ($item.is('.lfb_timepicker')) { 6331 var valueHour = parseInt(condition.value.substr(0, condition.value.indexOf(':'))); 6332 var valueMins = parseInt(condition.value.substr(condition.value.indexOf(':') + 1, 2)); 6333 if (condition.value.indexOf('PM') > 0 && valueHour != 12) { 6334 valueHour += 12; 6335 } 6336 var itemHour = parseInt($item.val().substr(0, $item.val().indexOf(':'))); 6337 var itemMins = parseInt($item.val().substr($item.val().indexOf(':') + 1, 2)); 6338 if ($item.val().indexOf('PM') > 0 && itemHour != 12) { 6339 itemHour += 12; 6340 } 6341 if (itemHour == valueHour) { 6342 error = true; 6343 } 6344 if (itemHour != valueHour) { 6345 errorOR = false;
6346 } 6347 6348 } else if ($item.is('input[type="number"]')) { 6349 if (parseFloat($item.val()) == parseFloat(condition.value)) { 6350 error = true; 6351 } 6352 if (parseFloat($item.val()) != parseFloat(condition.value)) { 6353 errorOR = false; 6354 } 6355 } else if ($item.is('[data-itemtype="rate"]')) { 6356 if (parseFloat($item.find('.lfb_rate').rate('getValue')) == parseFloat(condition.value)) { 6357 error = true; 6358 } 6359 if (parseFloat($item.find('.lfb_rate').rate('getValue')) != parseFloat(condition.value)) { 6360 errorOR = false; 6361 } 6362 } 6363 break; 6364 } 6365 } 6366 } 6367 } 6368 } else { 6369 if (condition.interaction.substr(0, 2) == 'v_') { 6370 var valueItemID = condition.interaction.substr(condition.interaction.indexOf('_') + 1, condition.interaction.length - (condition.interaction.indexOf('_') + 1)); 6371 var variableValue = parseFloat(lfb_getVariableByID(form, valueItemID).value); 6372 if (lfb_getVariableByID(form, valueItemID).type == 'text') { 6373 variableValue = lfb_getVariableByID(form, valueItemID).value; 6374 } 6375 6376 6377 if (condition.value && condition.value.indexOf('_') > -1) { 6378 if (condition.value.substr(0, 1) != '_') { 6379 var valueStepID = condition.value.substr(0, condition.value.indexOf('_')); 6380 var attribute = condition.value.substr(condition.value.indexOf('-') + 1, condition.value.length); 6381 if (valueStepID == 0) { 6382 valueStepID = 'final'; 6383 } 6384 var valueItemID = condition.value.substr(condition.value.indexOf('_') + 1, condition.value.indexOf('-') - (condition.value.indexOf('_') + 1)); 6385 if (valueStepID == 'v') { 6386 condition.value = parseFloat(lfb_getVariableByID(form, valueItemID).value); 6387 } else if (attribute == 'stepqt') { 6388 condition.value = lfb_getStepQuantities(stepID, formID, itemID); 6389 } else { 6390 var $valueItem = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + valueStepID + '"] .lfb_genContent [data-itemid="' + valueItemID + '"]'); 6391 6392 if ($valueItem.length > 0) { 6393 if (attribute == '') { 6394 if (typeof($valueItem.data('resprice')) != 'undefined') { 6395 condition.value = parseFloat($valueItem.data('resprice')); 6396 } else if ($valueItem.is('[data-resqt]')) { 6397 condition.value = parseFloat($valueItem.attr('data-resqt')); 6398 } 6399 } else if (attribute == 'quantity') { 6400 if ($valueItem.is('.lfb_disabled')) { 6401 condition.value = 0; 6402 } else { 6403 if ($valueItem.is('input[type="number"]')) { 6404 condition.value = $valueItem.val(); 6405 } else { 6406 if ($valueItem.find('.lfb_qtfield').length > 0) { 6407 condition.value = parseInt($valueItem.find('.lfb_qtfield').val()); 6408 } else { 6409 condition.value = parseInt($valueItem.find('.icon_quantity').html()); 6410 } 6411 6412 } 6413 } 6414 } else if (attribute == 'value') { 6415 if ($valueItem.is('.lfb_disabled')) { 6416 condition.value = ''; 6417 } else { 6418 6419 condition.value = $valueItem.val(); 6420 6421 if ($valueItem.is('.lfb_datepicker')) { 6422 condition.value = moment.utc($valueItem.datetimepicker("getDate")).format('YYYY-MM-DD'); 6423 } 6424 condition.value = condition.value.replace(/\`/g, "'"); 6425 } 6426 } 6427 } 6428 } 6429 } else { 6430 6431 if (condition.value == '_total' || condition.value == '_total-') { 6432 condition.value = form.price; 6433 } else if (condition.value == '_total_qt') { 6434 condition.value = lfb_getTotalQuantities(formID, _stepID, itemID); 6435 } 6436 } 6437 6438 } else if (condition.value) { 6439 condition.value = condition.value.replace(/\`/g, "'"); 6440 } 6441 6442 6443 6444 switch (condition.action) { 6445 case "superior": 6446 if (variableValue <= condition.value) { 6447 error = true; 6448 } 6449 if (variableValue > condition.value) { 6450 errorOR = false;
6451 } 6452 break; 6453 case "inferior": 6454 if (variableValue >= condition.value) { 6455 error = true; 6456 } 6457 if (variableValue < condition.value) { 6458 errorOR = false; 6459 } 6460 break; 6461 case "equal": 6462 if (variableValue != condition.value) { 6463 error = true; 6464 } 6465 if (variableValue == condition.value) { 6466 errorOR = false; 6467 } 6468 break; 6469 case "different": 6470 if (variableValue == condition.value) { 6471 error = true; 6472 } 6473 if (variableValue != condition.value) { 6474 errorOR = false; 6475 } 6476 break; 6477 } 6478 6479 } else if (condition.interaction && condition.interaction.length > 6 && condition.interaction.substr(0, 6) == '_step-') { 6480 var stepID = condition.interaction.substr(6, condition.interaction.length); 6481 if (stepID == 0) { 6482 stepID = 'final'; 6483 } 6484 var totalQt = lfb_getStepQuantities(formID, stepID, itemID); 6485 6486 switch (condition.action) { 6487 case "superior": 6488 if (totalQt <= condition.value) { 6489 error = true; 6490 } 6491 if (totalQt > condition.value) { 6492 errorOR = false; 6493 } 6494 break; 6495 case "inferior": 6496 if (totalQt >= condition.value) { 6497 error = true; 6498 } 6499 if (totalQt < condition.value) { 6500 errorOR = false; 6501 } 6502 break; 6503 case "equal": 6504 if (totalQt != condition.value) { 6505 error = true; 6506 } 6507 if (totalQt == condition.value) { 6508 errorOR = false; 6509 } 6510 break; 6511 case "different": 6512 if (totalQt == condition.value) { 6513 error = true; 6514 } 6515 if (totalQt != condition.value) { 6516 errorOR = false; 6517 } 6518 break; 6519 } 6520 6521 } 6522 if (condition.interaction == "_total") { 6523 switch (condition.action) { 6524 case "superior": 6525 if (parseFloat(form.price) <= parseFloat(condition.value)) { 6526 error = true; 6527 } 6528 if (parseFloat(form.price) > parseFloat(condition.value)) { 6529 errorOR = false; 6530 } 6531 break; 6532 case "inferior": 6533 if (parseFloat(form.price) >= parseFloat(condition.value)) { 6534 error = true; 6535 } 6536 if (parseFloat(form.price) < parseFloat(condition.value)) { 6537 errorOR = false; 6538 } 6539 break; 6540 case "equal": 6541 if (parseFloat(form.price) != parseFloat(condition.value)) { 6542 error = true; 6543 } 6544 if (parseFloat(form.price) == parseFloat(condition.value)) { 6545 errorOR = false;
6546 } 6547 break; 6548 case "different": 6549 if (parseFloat(form.price) == condition.value) { 6550 error = true; 6551 } 6552 if (parseFloat(form.price) != condition.value) { 6553 errorOR = false; 6554 } 6555 break; 6556 } 6557 } else if (condition.interaction == "_total_qt") { 6558 var totalQt = lfb_getTotalQuantities(formID, _stepID); 6559 switch (condition.action) { 6560 case "superior": 6561 if (totalQt <= condition.value) { 6562 error = true; 6563 } 6564 if (totalQt > condition.value) { 6565 errorOR = false; 6566 } 6567 break; 6568 case "inferior": 6569 if (totalQt >= condition.value) { 6570 error = true; 6571 } 6572 if (totalQt < condition.value) { 6573 errorOR = false; 6574 } 6575 break; 6576 case "equal": 6577 if (totalQt != condition.value) { 6578 error = true; 6579 } 6580 if (totalQt == condition.value) { 6581 errorOR = false; 6582 } 6583 break; 6584 case "different": 6585 if (totalQt == condition.value) { 6586 error = true; 6587 } 6588 if (totalQt != condition.value) { 6589 errorOR = false; 6590 } 6591 break; 6592 } 6593 } 6594 } 6595 }); 6596 6597 if (conditions.length == 0) { 6598 errorOR = false; 6599 } 6600 return { 6601 error: error, 6602 errorOR: errorOR 6603 }; 6604 } 6605 6606 function lfb_scrollToItem($item, stepID, formID) { 6607 6608 //if (stepID == 'final') { 6609 var form = lfb_getForm(formID); 6610 if (form.disableScroll != 1) { 6611 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen') || $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_popup')) { 6612 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 6613 scrollTop: $item.parent().offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 6614 }, form.animationsSpeed * 2); 6615 } else { 6616 if (form.scrollTopPage == '1') { 6617 $('body,html').animate({ 6618 scrollTop: 0 6619 }, form.animationsSpeed * 2); 6620 } else { 6621 $('body,html').animate({ 6622 scrollTop: $item.parent().offset().top - (80 + parseInt(lfb_getScrollTopMargin(form))) 6623 }, form.animationsSpeed * 2); 6624 } 6625 } 6626 } 6627 6628 // } 6629 } 6630 6631 function lfb_checkStepItemsValid(stepID, formID) { 6632 var chkSelectionitem = true; 6633 var chkError = false; 6634 var form = lfb_getForm(formID); 6635 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.has-error').removeClass('has-error'); 6636 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.icon_select.lfb_error').removeClass('lfb_error'); 6637 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('input[type=text]:not(.lfb_disabled),input[type=password]:not(.lfb_disabled),select').each(function() { 6638 if ($(this).closest('.lfb_itemBloc.lfb_disabled').length == 0) { 6639 if ($(this).closest('#lfb_stripeForm').length == 0 && $(this).closest('#lfb_paypalForm').length == 0) { 6640 if ($(this).is('[data-required="true"]') && $(this).val().length < 1) { 6641 6642 chkSelectionitem = false;
6643 $(this).closest('.form-group').addClass('has-error'); 6644 if (!chkError) { 6645 lfb_scrollToItem($(this), stepID, formID); 6646 } 6647 chkError = true; 6648 } 6649 if ($(this).is('[data-validation="phone"]') && $(this).val().length > 0 && ($(this).val().length < 5 || /^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$/i.test($(this).val()) == false)) { 6650 chkSelectionitem = false; 6651 $(this).closest('.form-group').addClass('has-error'); 6652 if (!chkError) { 6653 lfb_scrollToItem($(this), stepID, formID); 6654 } 6655 chkError = true; 6656 } else if ($(this).is('[data-validation="number"]') && /^\d+$/.test($(this).val()) == false) { 6657 chkSelectionitem = false; 6658 $(this).closest('.form-group').addClass('has-error'); 6659 if (!chkError) { 6660 lfb_scrollToItem($(this), stepID, formID); 6661 } 6662 chkError = true; 6663 } else if ($(this).is('[data-validation="email"]') && $(this).val().length > 0 && !lfb_checkEmail($(this).val())) { 6664 chkSelectionitem = false; 6665 $(this).closest('.form-group').addClass('has-error'); 6666 if (!chkError) { 6667 lfb_scrollToItem($(this), stepID, formID); 6668 } 6669 chkError = true; 6670 } else if ($(this).is('[data-validation="fill"]') && $(this).val().length == 0) { 6671 chkSelectionitem = false; 6672 $(this).closest('.form-group').addClass('has-error'); 6673 if (!chkError) { 6674 lfb_scrollToItem($(this), stepID, formID); 6675 } 6676 chkError = true; 6677 } else if ($(this).is('[data-validation="custom"]') && $(this).val().length > 0) { 6678 var error = false; 6679 if (parseInt($(this).attr('data-validmin')) > 0 && $(this).val().length < parseInt($(this).attr('data-validmin'))) { 6680 error = true; 6681 } 6682 if (parseInt($(this).attr('data-validmax')) > 0 && $(this).val().length > parseInt($(this).attr('data-validmax'))) { 6683 error = true; 6684 } 6685 if ($(this).is('[data-validcar]') && $(this).attr('data-validcar') != "") { 6686 var field = $(this); 6687 if ($(this).attr('data-validcar').indexOf(',') > -1) { 6688 var chars = $(this).attr('data-validcar').split(','); 6689 jQuery.each(chars, function() { 6690 if (field.val().indexOf(this) == -1) { 6691 error = true; 6692 } 6693 }); 6694 } else { 6695 if (field.val().indexOf($(this).attr('data-validcar')) == -1) { 6696 error = true; 6697 } 6698 } 6699 } 6700 if (error) { 6701 chkSelectionitem = false; 6702 $(this).closest('.form-group').addClass('has-error'); 6703 if (!chkError) { 6704 lfb_scrollToItem($(this), stepID, formID); 6705 } 6706 chkError = true; 6707 } 6708 } 6709 } 6710 } 6711 }); 6712 6713 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('input[type=text][minlength]:not(.lfb_disabled)').each(function() { 6714 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6715 if ($(this).val().length < $(this).attr('minlength')) { 6716 chkSelectionitem = false;
6717 $(this).closest('.form-group').addClass('has-error'); 6718 if (!chkError) { 6719 lfb_scrollToItem($(this), stepID, formID); 6720 } 6721 } 6722 } 6723 }); 6724 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('select[data-required="true"]:not(.lfb_disabled)').each(function() { 6725 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6726 if ($(this).is('[data-firstvaluedisabled="true"]') && ((!$(this).is('.lfb_selectpicker') && $(this).find("option:selected").index() == 0) || (($(this).is('.lfb_selectpicker') && $(this).val() == $(this).find("option").first().attr('value'))))) { 6727 chkSelectionitem = false; 6728 $(this).closest('.form-group').addClass('has-error'); 6729 if (!chkError) { 6730 lfb_scrollToItem($(this), stepID, formID); 6731 } 6732 } 6733 } 6734 }); 6735 6736 6737 6738 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('input[type=text][minlength]:not(.lfb_disabled)').each(function() { 6739 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6740 if ($(this).val().length < $(this).attr('minlength')) { 6741 chkSelectionitem = false; 6742 $(this).closest('.form-group').addClass('has-error'); 6743 if (!chkError) { 6744 lfb_scrollToItem($(this), stepID, formID); 6745 } 6746 } 6747 } 6748 }); 6749 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('input[type=number][data-required="true"]:not(.lfb_disabled)').each(function() { 6750 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6751 if ($(this).val() == '' || $(this).val() == 0) { 6752 chkSelectionitem = false; 6753 $(this).closest('.form-group').addClass('has-error'); 6754 if (!chkError) { 6755 lfb_scrollToItem($(this), stepID, formID); 6756 } 6757 } 6758 } 6759 }); 6760 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.lfb_dropzone:not(.lfb_disabled)').each(function() { 6761 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6762 if ($(this).is('[data-required="true"]') && $(this).find('.dz-preview[data-file].dz-success.dz-complete').length == 0) { 6763 chkSelectionitem = false; 6764 $(this).parent().addClass('has-error'); 6765 if (!chkError) { 6766 lfb_scrollToItem($(this), stepID, formID); 6767 } 6768 } else if ($(this).find('.dz-preview[data-file].dz-complete').length > parseInt($(this).attr('data-maxfiles'))) { 6769 chkSelectionitem = false; 6770 $(this).parent().addClass('has-error'); 6771 if (!chkError) { 6772 lfb_scrollToItem($(this), stepID, formID); 6773 } 6774 } 6775 } 6776 6777 }); 6778 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('textarea[data-required="true"]:not(.lfb_disabled)').each(function() { 6779 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6780 if ($(this).closest('#lfb_stripeForm').length == 0 && $(this).closest('#lfb_paypalForm').length == 0) { 6781 if ($(this).val().length < 1) { 6782 chkSelectionitem = false; 6783 $(this).closest('.form-group').addClass('has-error'); 6784 if (!chkError) { 6785 lfb_scrollToItem($(this), stepID, formID); 6786 } 6787 } 6788 } 6789 } 6790 }); 6791 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('input[type=checkbox][data-required="true"]:not(.lfb_disabled)').each(function() { 6792 if (!$(this).is(':checked')) { 6793 6794 if (!$(this).is('[data-group]') || ($(this).attr('data-group') != '' && 6795 $(' #lfb_form[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] [data-group="' + $(this).attr('data-group') + '"]:checked').length == 0)) { 6796 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6797 chkSelectionitem = false;
6798 $(this).closest('.form-group,p,.lfb_itemBloc').addClass('has-error'); 6799 if (!chkError) { 6800 lfb_scrollToItem($(this), stepID, formID); 6801 } 6802 } 6803 } 6804 } 6805 }); 6806 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.lfb_selectable[data-required="true"]:not(.lfb_disabled)').each(function() { 6807 if (!$(this).is('.checked')) { 6808 6809 6810 if (!$(this).is('[data-group]') || ($(this).attr('data-group') != '' && 6811 $(' #lfb_form[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] [data-group="' + $(this).attr('data-group') + '"].checked').length == 0)) { 6812 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6813 chkSelectionitem = false; 6814 $(this).find('.icon_select').addClass('lfb_error'); 6815 if (!chkError) { 6816 lfb_scrollToItem($(this), stepID, formID); 6817 } 6818 } 6819 } 6820 } 6821 }); 6822 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').find('.lfb_button[data-required="true"]:not(.lfb_disabled)').each(function() { 6823 if (!$(this).is('.checked')) { 6824 if (!$(this).is('[data-group]') || ($(this).attr('data-group') != '' && 6825 $(' #lfb_form[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] [data-group="' + $(this).attr('data-group') + '"].checked').length == 0)) { 6826 if ($(this).closest('.lfb_row.lfb_disabled').length == 0) { 6827 chkSelectionitem = false; 6828 $(this).find('.icon_select').addClass('lfb_error'); 6829 if (!chkError) { 6830 lfb_scrollToItem($(this), stepID, formID); 6831 } 6832 } 6833 } 6834 } 6835 }); 6836 if (stepID == 'final' && form.useSignature == 1) { 6837 var jsonSign = JSON.parse(form.signature.signature('toJSON')); 6838 if (jsonSign.lines.length == 0) { 6839 chkSelectionitem = false; 6840 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_signature').addClass('has-error'); 6841 if (!chkError) { 6842 lfb_scrollToItem($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_signature'), stepID, formID); 6843 } 6844 chkError = true; 6845 } 6846 } 6847 return chkSelectionitem; 6848 } 6849 6850 function lfb_nextStep(formID) { 6851 var form = lfb_getForm(formID); 6852 $('#lfb_bootstraped :not(.ui-slider-handle) > .tooltip').remove(); 6853 $('#lfb_form[data-form="' + form.formID + '"] > .tooltip').remove(); 6854 var deviceAgent = navigator.userAgent.toLowerCase(); 6855 var agentID = deviceAgent.match(/(iPad|iPhone|iPod)/i); 6856 if (agentID) { 6857 setTimeout(function() { 6858 $('#lfb_bootstraped :not(.ui-slider-handle) > .tooltip').remove(); 6859 }, 500); 6860 } 6861 6862 lfb_updateShowSteps(formID); 6863 $('.lfb_errorMsg').hide(); 6864 var chkSelection = true; 6865 var chkSelectionitem = true; 6866 var maxConditions = 0; 6867 6868 var potentialSteps = lfb_findPotentialsSteps(form.step, formID); 6869 6870 if (form.step > 0) { 6871 if ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').data('required') == true) { 6872 chkSelection = false; 6873 if (($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('select:not(.lfb_disabled):not([data-firstvaluedisabled="true"])').length > 0) || 6874 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('div.lfb_selectable.checked:not(.lfb_disabled)').length > 0) || 6875 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('a.lfb_button.checked:not(.lfb_disabled)').length > 0) || 6876 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('input[data-toggle="switch"]:checked:not(.lfb_disabled)').length > 0) || 6877 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('input[type=text][data-title].checked:not(.lfb_disabled)').length > 0) || 6878 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('[data-itemtype="rate"][data-title].checked:not(.lfb_disabled)').length > 0) || 6879 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('input[type=number][data-itemid].checked:not(.lfb_disabled)').length > 0) || 6880 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('input[type=file].checked:not(.lfb_disabled)').length > 0) || 6881 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_colorPreview:not(.lfb_disabled)').length > 0) || 6882 ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.dz-preview[data-file].dz-success.dz-complete').length > 0)) { 6883 chkSelection = true; 6884 } 6885 6886 6887 if (!chkSelection) { 6888 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('select:not(.lfb_disabled)[data-firstvaluedisabled="true"]').each(function() { 6889 if (((!$(this).is('.lfb_selectpicker') && $(this).find("option:selected").index() > 0) || (($(this).is('.lfb_selectpicker') && $(this).find("option:selected").index() > 1)))) { 6890 chkSelection = true; 6891 } 6892 }); 6893 } 6894 } 6895 chkSelectionitem = lfb_checkStepItemsValid(form.step, formID); 6896 } 6897 6898 if (chkSelection && chkSelectionitem && lfb_checkUserEmail(form)) { 6899 6900 lfb_lastStepID = form.step; 6901 if ((parseFloat(lfb_lastStepID) == parseInt(lfb_lastStepID)) && !isNaN(lfb_lastStepID)) { 6902 if (jQuery.inArray(parseInt(form.step), lfb_lastSteps) == -1) { 6903 lfb_lastSteps.push(parseInt(form.step)); 6904 } 6905 } 6906 var title = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + lfb_lastStepID + '"] .lfb_stepTitle').html(); 6907 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_fullscreen') && !$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_popup')) { 6908 history.pushState({ id: lfb_lastStepID }, '', ''); 6909 } 6910 var nextStepID = potentialSteps[0]; 6911 if (nextStepID != 'final') { 6912 nextStepID = lfb_getNextEnabledStep(formID, potentialSteps); 6913 if (nextStepID == -1) { 6914 nextStepID = 'final'; 6915 } 6916 } 6917 if (form.sendContactASAP == 1 && $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"]').length > 0 && 6918 lfb_checkEmail($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"]').val())) { 6919 form.contactSent = 1; 6920 var infosCt = lfb_getContactInformations(formID); 6921 jQuery.ajax({ 6922 url: form.ajaxurl, 6923 type: 'post', 6924 data: { 6925 action: 'lfb_sendCt', 6926 formID: formID, 6927 email: infosCt['email'], 6928 lastName: infosCt['lastName'], 6929 firstName: infosCt['firstName'], 6930 phone: infosCt['phone'], 6931 country: infosCt['country'], 6932 zip: infosCt['zip'], 6933 state: infosCt['state'], 6934 city: infosCt['city'], 6935 address: infosCt['address'] 6936 }, 6937 success: function(rep) {} 6938 }); 6939 } 6940 lfb_changeStep(nextStepID, formID); 6941 } else if (!chkSelection) { 6942 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_errorMsg').slideDown(); 6943 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').trigger('stepError'); 6944 } 6945 } 6946 6947 function lfb_getNextEnabledStep(formID, potentialSteps) { 6948 var rep = -1; 6949 var stepID = potentialSteps[0]; 6950 if (stepID != 'final') { 6951 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_visualEditing')) { 6952 rep = stepID; 6953 } else { 6954 if (!$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"]').is('.lfb_disabled') && 6955 ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_item:not(.lfb_row ):not(.lfb-hidden)').length > 0 || 6956 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + stepID + '"] .lfb_distanceError').length > 0)) { 6957 rep = stepID; 6958 } else { 6959 lfb_lastSteps.push(parseInt(stepID)); 6960 lfb_updatePrice(formID); 6961 rep = lfb_getNextEnabledStep(formID, lfb_findPotentialsSteps(parseInt(stepID), formID)); 6962 } 6963 } 6964 } 6965 6966 return rep; 6967 } 6968 6969 function lfb_openGenerator(formID) { 6970 var form = lfb_getForm(formID); 6971 6972 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #startInfos').addClass('lfb_loaded'); 6973 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #startInfos > p').slideDown(); 6974 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnFloatingSummary').css({ 6975 display: 'inline-block' 6976 }); 6977 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').css({ 6978 display: 'inline-block' 6979 }); 6980 6981 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnStart').parent().fadeOut(form.animationsSpeed); 6982 setTimeout(function() { 6983 if (form.showSteps != '2') { 6984 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').find('.genPrice,#lfb_stepper').fadeIn(form.animationsSpeed); 6985 } 6986 if (!form.autoStart) { 6987 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').show(); 6988 setTimeout(function() { 6989 lfb_nextStep(formID); 6990 }, form.animationsSpeed + form.animationsSpeed / 2); 6991 } 6992 }, form.animationsSpeed); 6993 } 6994 6995 function lfb_initListeners(formID) { 6996 var form = lfb_getForm(formID); 6997 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').on('lfb_setAnimImmediate', lfb_setAnimImmediate); 6998 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').on('lfb_resizeAll', lfb_resizeAll); 6999 7000 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide div.lfb_selectable .img, #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide div.lfb_selectable .icon_select').on('click', function() {
7001 if (!lfb_isSelectionMode(formID)) { 7002 lfb_itemClick($(this).parent(), true, formID); 7003 } 7004 }); 7005 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide a.lfb_button').on('click', function() { 7006 if (!lfb_isSelectionMode(formID)) { 7007 lfb_itemClick($(this), true, formID); 7008 } 7009 }); 7010 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-callnextstep="1"]').on('click', function() { 7011 if (!lfb_isSelectionMode(formID) && $(this).is('.checked')) { 7012 lfb_nextStep(formID); 7013 } 7014 }); 7015 7016 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel input[type=checkbox][data-price]').on('change', function() { 7017 if ($(this).is('[data-usedistance="true"]')) { 7018 lfb_removeDistanceError($(this).attr('data-itemid'), formID); 7019 } 7020 var $this = $(this); 7021 if ($this.data('group')) { 7022 7023 $this.closest('.lfb_genSlide').find('a.lfb_button.checked[data-group="' + $this.data('group') + '"]:not([data-itemid="' + $this.attr('data-itemid') + '"])').each(function() { 7024 7025 lfb_itemClick($(this), false, formID); 7026 $(this).removeClass('checked'); 7027 }); 7028 7029 } 7030 7031 lfb_updatePrice(formID, $(this).attr('data-itemid')); 7032 7033 7034 7035 }); 7036 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel input[type=checkbox][data-group]').on('change', function(e) { 7037 var clickedInput = $(this); 7038 if (clickedInput.is(':checked')) { 7039 $(this).closest('.lfb_genSlide').find('div.lfb_selectable.checked[data-group="' + clickedInput.data('group') + '"]').each(function() { 7040 lfb_itemClick($(this), false, formID); 7041 }); 7042 $(this).closest('.lfb_genSlide').find('input[type=checkbox][data-group="' + clickedInput.data('group') + '"]:checked').each(function() { 7043 if (!$(this).is(clickedInput)) { 7044 $(this).trigger('click.auto'); 7045 } 7046 }); 7047 7048 if ($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('[data-autoclick="1"]') && clickedInput.closest('.lfb_genSlide').find('[data-itemid]').not('[data-group="' + clickedInput.data('group') + '"]').not('.lfb_richtext').not('.lfb_disabled').length == 0) { 7049 var form = lfb_getForm(formID); 7050 lfb_nextStep(form.formID); 7051 } 7052 } 7053 7054 }); 7055 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide select[data-itemid]').on('change', function() { 7056 var value = $(this).val(); 7057 var price = 0; 7058 $(this).find('option').each(function() { 7059 if ($(this).attr('value') == value) { 7060 price = $(this).attr('data-price'); 7061 } 7062 }); 7063 $(this).attr('data-price', price); 7064 $(this).data('price', price); 7065 lfb_updatePrice(formID); 7066 }); 7067 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide select[data-itemid]').trigger('change'); 7068 7069 $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel input[type=checkbox][data-price]').on('change', function() { 7070 7071 }); 7072 $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide input.lfb_qtfield').on('change', function() { 7073 lfb_updatePrice(formID, $(this).attr('data-itemid')); 7074 }); 7075 $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide').find('input[type=text][data-title],textarea[data-title],input[type=file][data-title],input[type=number][data-title]').on('change', function() { 7076 if ($(this).val().length > 0) { 7077 $(this).addClass('checked'); 7078 $(this).addClass('lfb_changed'); 7079 } else { 7080 $(this).removeClass('checked'); 7081 } 7082 }); 7083 $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide div.lfb_selectable .icon_quantity').on('click', function() {
7084 if (!lfb_isSelectionMode(formID)) { 7085 $('.quantityBtns').not($(this).parent().find('.quantityBtns')).removeClass('open'); 7086 $('.quantityBtns').not($(this).parent().find('.quantityBtns')).fadeOut(250); 7087 7088 if (!$(this).parent().find('.quantityBtns').is('.open') && $(this).parent().is('.checked')) { 7089 if ($(this).parent().find('.quantityBtns .tooltip-inner').length > 0) { 7090 $(this).parent().find('.quantityBtns .tooltip-inner').html(parseInt($(this).parent().find('.icon_quantity').html())); 7091 } 7092 $(this).parent().find('.quantityBtns').addClass('open'); 7093 $(this).parent().find('.quantityBtns').fadeIn(250); 7094 } else { 7095 $(this).parent().find('.quantityBtns').removeClass('open'); 7096 $(this).parent().find('.quantityBtns').fadeOut(250); 7097 } 7098 } 7099 }); 7100 7101 $('#lfb_orderMessageCheck').on('change', function() { 7102 if ($(this).is(':checked')) { 7103 $('#lfb_orderMessage').slideDown(250); 7104 } else { 7105 $('#lfb_orderMessage').slideUp(250); 7106 } 7107 }); 7108 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnOrder').on('click', function() { 7109 if (!lfb_isSelectionMode(formID)) { 7110 lfb_order(formID); 7111 } 7112 }); 7113 7114 $('#gform_wrapper_' + form.gravityFormID + ' form').on('submit', function(e) { 7115 var $this = $(this); 7116 if (!$(this).is('.submit')) { 7117 e.preventDefault(); 7118 $(this).addClass('submit'); 7119 7120 7121 if (form.save_to_cart) { 7122 var products = new Array(); 7123 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 7124 7125 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 7126 lastAndCurrentSteps.push(parseInt(form.step)); 7127 } else if (form.step == 'final' && jQuery.inArray('final', lastAndCurrentSteps) == -1) { 7128 lastAndCurrentSteps.push('final'); 7129 } 7130 7131 jQuery.each(lastAndCurrentSteps, function() { 7132 var $panel = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"]'); 7133 $panel.find('div.lfb_selectable.checked:not(.lfb_disabled),a.lfb_button.checked:not(.lfb_disabled),input[type=checkbox]:checked:not(.lfb_disabled),[data-type="slider"]:not(.lfb_disabled)').each(function() { 7134 var quantity = 1; 7135 if (parseInt($(this).data('resqt')) > 0) { 7136 quantity = parseInt($(this).data('resqt')); 7137 } 7138 if ($(this).is('[data-type="slider"]')) { 7139 quantity = parseInt($(this).slider('value')); 7140 if (!isNaN(parseInt($(this).find('.tooltip-inner').html()))) { 7141 quantity = parseInt($(this).find('.tooltip-inner').html()); 7142 } 7143 } 7144 if (parseInt($(this).data('prodid')) > 0) { 7145 products.push({ 7146 quantity: quantity, 7147 product_id: parseInt($(this).data('prodid')), 7148 variation: parseInt($(this).attr('data-woovar')) 7149 }); 7150 } 7151 }); 7152 }); 7153 jQuery.ajax({ 7154 url: form.ajaxurl, 7155 type: 'post', 7156 data: { 7157 action: 'lfb_cart_save', 7158 ref: form.current_ref, 7159 emptyWooCart: form.emptyWooCart, 7160 products: products 7161 }, 7162 success: function() {
7163 form.timer_gFormSubmit = setInterval(function() { 7164 lfb_check_gform_response(form.formID); 7165 }, 300); 7166 setTimeout(function() { 7167 $this.submit(); 7168 }, 700); 7169 } 7170 }); 7171 } else { 7172 form.timer_gFormSubmit = setInterval(function() { 7173 lfb_check_gform_response(form.formID); 7174 }, 300); 7175 setTimeout(function() { 7176 $this.submit(); 7177 }, 700); 7178 } 7179 } else { 7180 $(this).removeClass('submit'); 7181 } 7182 }); 7183 7184 7185 } 7186 7187 function lfb_checkItems(formID) { 7188 var form = lfb_getForm(formID); 7189 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide div.lfb_selectable img[data-tint="true"]').each(function() { 7190 $(this).css('opacity', 0); 7191 $(this).show(); 7192 var $canvas = $('<canvas class="img"></canvas>'); 7193 $canvas.css({ 7194 width: $(this).get(0).width, 7195 height: $(this).get(0).height 7196 }); 7197 $(this).hide(); 7198 $(this).after($canvas); 7199 var ctx = $canvas.get(0).getContext('2d'); 7200 var img = new Image(); 7201 img.onload = function() { 7202 ctx.fillStyle = form.colorA; 7203 ctx.fillRect(0, 0, $canvas.get(0).width, $canvas.get(0).height); 7204 ctx.fill(); 7205 ctx.globalCompositeOperation = 'destination-in'; 7206 ctx.drawImage(img, 0, 0, $canvas.get(0).width, $canvas.get(0).height); 7207 }; 7208 if ($(this).is('[data-lazy-src]')) { 7209 img.src = $(this).attr('data-lazy-src'); 7210 } else { 7211 img.src = $(this).attr('src'); 7212 } 7213 }); 7214 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide div.lfb_selectable img[data-tint="false"]').each(function() { 7215 if ($(this).is('[data-src]')) { 7216 $(this).attr('src', $(this).attr('data-src')); 7217 } 7218 }); 7219 7220 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide div.lfb_selectable.checked , #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide input[type=checkbox]:checked').on('mouseenter', function() { 7221 $(this).addClass('lfb_hover'); 7222 }).on('mouseleave', function() { 7223 $(this).removeClass('lfb_hover'); 7224 }); 7225 } 7226 7227 function lfb_getDistanceCalc(distanceCode, formID, itemID, depart, arrival, distanceType) { 7228 var rep = 0; 7229 var distanceMode = google.maps.UnitSystem.METRIC; 7230 var form = lfb_getForm(formID); 7231 if (form.distancesMode == 'route') { 7232 lfb_gmapMatrixService = new google.maps.DistanceMatrixService(); 7233 lfb_gmapMatrixService.getDistanceMatrix({ 7234 origins: [depart], 7235 destinations: [arrival], 7236 travelMode: google.maps.TravelMode.DRIVING, 7237 unitSystem: google.maps.UnitSystem.METRIC, 7238 avoidHighways: false, 7239 avoidTolls: false, 7240 }, function(response, status) { 7241 var error = false; 7242 if (status == google.maps.DistanceMatrixStatus.OK) { 7243 var distance = 0; 7244 var duration = 0; 7245 if (response.rows[0].elements[0].distance) { 7246 distance = response.rows[0].elements[0].distance.value; 7247 distance = distance / 1000; 7248 if (distanceType == 'miles') { 7249 distance = distance * 0.62; 7250 } else if (distanceType == 'mins') { 7251 distance = Math.round(parseInt(response.rows[0].elements[0].duration.value) / 60); 7252 } else if (distanceType == 'hours') { 7253 distance = Math.round(parseInt(response.rows[0].elements[0].duration.value) / 60 / 60); 7254 } 7255 } else { 7256 error = true; 7257 } 7258 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + itemID + '"]'); 7259 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + itemID + '"]').attr('data-distance', distance); 7260 7261 lfb_updateSummary(formID); 7262 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tr[data-itemstep="' + itemID + '"] td:eq(2)').html(distance); 7263 lfb_updatePrice(formID); 7264 lfb_removeDistanceError(itemID, formID); 7265 } else { 7266 error = true; 7267 } 7268 if (error) { 7269 lfb_showDistanceError(itemID, formID); 7270 } 7271 }); 7272 } else { 7273 var geocoder = new google.maps.Geocoder(); 7274 geocoder.geocode({ 'address': depart }, function(results, status) { 7275 if (typeof(results[0]) != 'undefined') { 7276 var pointA = results[0].geometry.location;
7277 geocoder.geocode({ 'address': arrival }, function(results, status) { 7278 if (typeof(results[0]) != 'undefined') { 7279 var pointB = results[0].geometry.location; 7280 7281 var distance = google.maps.geometry.spherical.computeDistanceBetween(pointA, pointB); 7282 distance = distance / 1000; 7283 if (distanceType == 'miles') { 7284 distance = distance * 0.62; 7285 } 7286 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + itemID + '"]'); 7287 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + itemID + '"]').attr('data-distance', distance); 7288 7289 lfb_updateSummary(formID); 7290 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table tr[data-itemstep="' + itemID + '"] td:eq(2)').html(distance); 7291 lfb_updatePrice(formID); 7292 lfb_removeDistanceError(itemID, formID); 7293 } else { 7294 lfb_showDistanceError(itemID, formID); 7295 7296 } 7297 7298 }); 7299 } else { 7300 lfb_showDistanceError(itemID, formID); 7301 7302 } 7303 }); 7304 } 7305 7306 return rep; 7307 } 7308 7309 function lfb_executeCalculation(calculation, formID, targetID) { 7310 calculation = calculation.replace(/\\/g, ''); 7311 var form = lfb_getForm(formID); 7312 var price = 0; 7313 var i = 0; 7314 var elementsToReplace = new Array(); 7315 var itemData = lfb_getItemData(form, targetID); 7316 var _stepID = itemData.stepid; 7317 var isVariable = false; 7318 if (calculation.indexOf('[variable]') > -1) { 7319 isVariable = true; 7320 } 7321 calculation = calculation.replace(/\[variable\]/g, '[price]'); 7322 calculation = calculation.replace(/\[quantity\]/g, '[price]'); 7323 calculation = calculation.replace(/\[value\]/g, '[price]'); 7324 7325 while ((i = calculation.indexOf('variable-', i + 1)) != -1) { 7326 var variableID = calculation.substr(i + 9, calculation.indexOf(']', i) - (i + 9)); 7327 var value = 0; 7328 var variable = lfb_getVariableByID(form, variableID); 7329 if (variable) { 7330 value = variable.value; 7331 if (variable.type == 'text') { 7332 value = '"' + variable.value + '"'; 7333 } else { 7334 if (isNaN(value)) { 7335 value = 0; 7336 } 7337 } 7338 } 7339 elementsToReplace.push({ 7340 oldValue: calculation.substr(i - 1, (calculation.indexOf(']', i) + 1) - (i - 1)), 7341 newValue: value 7342 }); 7343 } 7344 while ((i = calculation.indexOf('item-', i + 1)) != -1) { 7345 var itemID = calculation.substr(i + 5, calculation.indexOf('_', i) - (i + 5)); 7346 var action = calculation.substr(calculation.indexOf('_', i) + 1, (calculation.indexOf(']', i) - 1) - (calculation.indexOf('_', i))); 7347 var value = 0; 7348 var calItemData = lfb_getItemData(form, itemID); 7349 if (typeof(calItemData) != 'undefined' && calItemData) { 7350 7351 if (action == 'isChecked') { 7352 if (calItemData) { 7353 value = '1==1'; 7354 } else { 7355 value = '1==0' 7356 } 7357 } 7358 if (action == 'isUnchecked') { 7359 if (!calItemData) { 7360 value = '1==1'; 7361 } else { 7362 value = '1==0' 7363 } 7364 } 7365 if (action == 'isFilled') { 7366 if (calItemData.type == 'filefield') { 7367 7368 if (calItemData.files.length > 0) { 7369 value = '1==1'; 7370 } else { 7371 value = '1==0'; 7372 } 7373 } else { 7374 var value = 0; 7375 if (typeof(calItemData.value) == 'undefined') { 7376 if (typeof(calItemData.quantity) != 'undefined') { 7377 value = calItemData.quantity; 7378 } 7379 7380 } else { 7381 value = calItemData.value; 7382 } 7383 if (value.length > 0) { 7384 value = '1==1'; 7385 } else { 7386 value = '1==0'; 7387 } 7388 } 7389 } 7390 if (action == 'price') { 7391 value = 0; 7392 if (itemID == 'total') { 7393 value = form.price; 7394 } else { 7395 value = 0; 7396 if (typeof(calItemData.price) != 'undefined') { 7397 value = calItemData.price; 7398 } 7399 } 7400 } 7401 if (action == 'quantity') { 7402 value = 0; 7403 if (typeof(calItemData.quantity) != 'undefined') { 7404 value = calItemData.quantity; 7405 } 7406 7407 } 7408 if (action == 'min') { 7409 value = 0; 7410 if (calItemData.type == 'range') { 7411 if (typeof(calItemData.minValue) != 'undefined') { 7412 value = calItemData.minValue; 7413 } 7414 } 7415 } 7416 if (action == 'max') { 7417 value = 0; 7418 if (calItemData.type == 'range') { 7419 if (typeof(calItemData.maxValue) != 'undefined') { 7420 value = calItemData.maxValue; 7421 } 7422 } 7423 } 7424 if (action == 'value') { 7425 value = 0; 7426 if (calItemData.type == 'numberfield') { 7427 if (typeof(calItemData.quantity) != 'undefined') { 7428 value = calItemData.quantity; 7429 } else if (typeof(calItemData.value) != 'undefined') { 7430 value = calItemData.value; 7431 } 7432 if (isNaN(value)) { 7433 value = 0; 7434 } 7435 } else { 7436 value = "'" + calItemData.value + "'"; 7437 } 7438 7439 7440 7441 } 7442 if (action == 'date') { 7443 7444 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]'); 7445 if ($item.is('.lfb_datepicker') && $item.datetimepicker("getDate") != null) { 7446 value = "'" + moment($item.datetimepicker("getDate")).format('YYYY-MM-DD') + "'"; 7447 } else { 7448 value = "null"; 7449 } 7450 } 7451 } else { 7452 if (action == 'isUnchecked') { 7453 value = '1==1'; 7454 } 7455 } 7456 7457 if (typeof(value) == 'undefined') { 7458 value = 0; 7459 } 7460 elementsToReplace.push({ 7461 oldValue: calculation.substr(i - 1, (calculation.indexOf(']', i) + 1) - (i - 1)), 7462 newValue: value 7463 }); 7464 } 7465 7466 while ((i = calculation.indexOf('step-', i + 1)) != -1) { 7467 var stepID = calculation.substr(i + 5, calculation.indexOf('_', i)
7467- (i + 5)); 7468 var action = calculation.substr(calculation.indexOf('_', i) + 1, (calculation.indexOf(']', i) - 1) - (calculation.indexOf('_', i))); 7469 7470 if (action == 'quantity') { 7471 value = lfb_getStepQuantities(formID, stepID, targetID); 7472 } 7473 elementsToReplace.push({ 7474 oldValue: calculation.substr(i - 1, (calculation.indexOf(']', i) + 1) - (i - 1)), 7475 newValue: value 7476 }); 7477 } 7478 7479 var todayDate = new Date(); 7480 var month = todayDate.getMonth() + 1; 7481 if (month < 10) { 7482 month = '0' + month; 7483 } 7484 var today = todayDate.getFullYear().toString() + month.toString() + todayDate.getDate().toString(); 7485 calculation = calculation.replace(/\[currentDate\]/g, today); 7486 7487 if (calculation.indexOf('dateDifference-') > -1) { 7488 7489 while ((i = calculation.indexOf('dateDifference-', i + 1)) != -1) { 7490 var startDateAdPosEnd = calculation.indexOf('_', i + 15) + 1; 7491 var startDate = calculation.substr(i + 15, calculation.indexOf('_', i) - (i + 15)); 7492 var endDate = calculation.substr(startDateAdPosEnd, calculation.indexOf(']', startDateAdPosEnd) - (startDateAdPosEnd)); 7493 7494 if (startDate == 'currentDate') { 7495 startDate = todayDate; 7496 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + startDate + '"]').length > 0 && 7497 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + startDate + '"]').val().length > 0) { 7498 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + startDate + '"]'); 7499 startDate = $item.datetimepicker("getDate"); 7500 } else { 7501 startDate = todayDate; 7502 } 7503 if (endDate == 'currentDate') { 7504 endDate = todayDate; 7505 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + endDate + '"]').length > 0 && 7506 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + endDate + '"]').val().length > 0) { 7507 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + endDate + '"]'); 7508 endDate = $item.datetimepicker("getDate"); 7509 } else { 7510 endDate = todayDate; 7511 } 7512 7513 startDate.setMinutes(0); 7514 startDate.setHours(0); 7515 endDate.setMinutes(0); 7516 endDate.setHours(0); 7517 var timeDiff = Math.abs(endDate.getTime() - startDate.getTime()); 7518 var result = Math.round(timeDiff / (1000 * 3600 * 24)); 7519 if (result < 0) { 7520 result = 0; 7521 } 7522 7523 elementsToReplace.push({ 7524 oldValue: calculation.substr(i - 1, (calculation.indexOf(']', i) + 1) - (i - 1)), 7525 newValue: result 7526 }); 7527 7528 } 7529 } 7530 7531 7532 if (calculation.indexOf('distance_') > -1) { 7533 var $target = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + targetID + '"]'); 7534 $target.attr('data-usedistance', 'true'); 7535 while ((i = calculation.indexOf('distance_', i + 1)) != -1) { 7536 7537 var distanceType = 'km'; 7538 7539 var departAdPosEnd = calculation.indexOf('-', i + 9) + 1; 7540 var departAdress = calculation.substr(i + 9, calculation.indexOf('-', i) - (i + 9)); 7541 7542 var departCityPosEnd = calculation.indexOf('-', departAdPosEnd) + 1; 7543 var departCity = calculation.substr(departAdPosEnd, calculation.indexOf('-', departAdPosEnd) - (departAdPosEnd)); 7544 7545 var departZipPosEnd = calculation.indexOf('-', departCityPosEnd) + 1; 7546 var departZip = calculation.substr(departCityPosEnd, calculation.indexOf('-', departCityPosEnd) - (departCityPosEnd)
7546); 7547 7548 var departCountryPosEnd = calculation.indexOf('_', departZipPosEnd) + 1; 7549 var departCountry = calculation.substr(departZipPosEnd, calculation.indexOf('_', departZipPosEnd) - (departZipPosEnd)); 7550 7551 var arrivalAdPosEnd = calculation.indexOf('-', departCountryPosEnd) + 1; 7552 var arrivalAdress = calculation.substr(departCountryPosEnd, calculation.indexOf('-', departCountryPosEnd) - (departCountryPosEnd)); 7553 7554 var arrivalCityPosEnd = calculation.indexOf('-', arrivalAdPosEnd) + 1; 7555 var arrivalCity = calculation.substr(arrivalAdPosEnd, calculation.indexOf('-', arrivalAdPosEnd) - (arrivalAdPosEnd)); 7556 7557 var arrivalZipPosEnd = calculation.indexOf('-', arrivalCityPosEnd) + 1; 7558 var arrivalZip = calculation.substr(arrivalCityPosEnd, calculation.indexOf('-', arrivalCityPosEnd) - (arrivalCityPosEnd)); 7559 7560 var arrivalCountryPosEnd = calculation.indexOf('_', arrivalZipPosEnd) + 1; 7561 var arrivalCountry = calculation.substr(arrivalZipPosEnd, calculation.indexOf('_', arrivalZipPosEnd) - (arrivalZipPosEnd)
7561); 7562 7563 distanceType = calculation.substr(arrivalCountryPosEnd, calculation.indexOf(']', arrivalCountryPosEnd) - (arrivalCountryPosEnd)); 7564 7565 7566 if (departAdress != "") { 7567 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departAdress + '"]').length > 0) { 7568 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departAdress + '"]'); 7569 departAdress = $item.val(); 7570 } else { 7571 departAdress = 0; 7572 } 7573 } 7574 if (departCity != "") { 7575 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCity + '"]').length > 0) { 7576 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCity + '"]'); 7577 departCity = $item.val(); 7578 } else { 7579 departCity = 0; 7580 } 7581 } 7582 if (departZip != "") { 7583 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departZip + '"]').length > 0) { 7584 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departZip + '"]'); 7585 departZip = $item.val(); 7586 } else { 7587 departZip = 0; 7588 } 7589 } 7590 if (departCountry != "") { 7591 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCountry + '"]').length > 0) { 7592 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCountry + '"]'); 7593 departCountry = $item.val(); 7594 } else { 7595 departCountry = 0; 7596 } 7597 } 7598 if (arrivalAdress != "") { 7599 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalAdress + '"]').length > 0) { 7600 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalAdress + '"]'); 7601 arrivalAdress = $item.val(); 7602 } else { 7603 arrivalAdress = 0; 7604 } 7605 } 7606 if (arrivalCity != "") { 7607 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCity + '"]').length > 0) { 7608 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCity + '"]'); 7609 arrivalCity = $item.val(); 7610 } else { 7611 arrivalCity = 0; 7612 } 7613 } 7614 if (arrivalZip != "") { 7615 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalZip + '"]').length > 0) { 7616 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalZip + '"]'); 7617 arrivalZip = $item.val(); 7618 } else { 7619 arrivalZip = 0; 7620 } 7621 } 7622 if (arrivalCountry != "") { 7623 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCountry + '"]').length > 0) { 7624 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCountry + '"]'); 7625 arrivalCountry = $item.val(); 7626 } else { 7627 arrivalCountry = 0; 7628 } 7629 } 7630 if ($target.closest('.lfb_genSlide').find('.lfb_distanceError').length > 0) { 7631 lfb_removeDistanceError(targetID, formID); 7632 } 7633 var distanceCode = calculation.substr(i - 1, (calculation.indexOf(']', i) + 1) - (i - 1)); 7634 var distance = 0; 7635 if ($target.attr('data-distance') != "") { 7636 distance = parseFloat($target.attr('data-distance')); 7637 } 7638 if (departAdress == "" && departCity == "" && departCountry == "" && arrivalAdress == "" && arrivalCity == "" && arrivalCountry == "" && departZip == "" && arrivalZip == "") { 7639 lfb_showDistanceError(targetID, formID); 7640 } else { 7641 if (form.gmap_key == "") { 7642 lfb_showDistanceError(targetID, formID); 7643 console.log("invalid gmap api key"); 7644 } else { 7645 var depart = departAdress + ' ' + departZip + ' ' + departCity + ' ' + departCountry; 7646 var arrival = arrivalAdress + ' ' + arrivalZip + ' ' + arrivalCity + ' ' + arrivalCountry; 7647 if ($target.attr('data-departure') != depart || arrival != $target.attr('data-arrival')) { 7648 $target.attr('data-departure', depart); 7649 $target.attr('data-arrival', arrival); 7650 lfb_getDistanceCalc(distanceCode, formID, targetID, depart, arrival, distanceType); 7651 } 7652 } 7653 } 7654 elementsToReplace.push({ 7655 oldValue: calculation.substr(i - 1, (calculation.indexOf(']', i) + 1) - (i - 1)), 7656 newValue: distance 7657 }); 7658 } 7659 } 7660 jQuery.each(elementsToReplace, function() { 7661 calculation = calculation.replace(this.oldValue, this.newValue); 7662 }); 7663 calculation = calculation.replace(/\[total_single\]/g, form.priceSingle); 7664 calculation = calculation.replace(/\[total_default\]/g, form.price); 7665 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('[data-isSubs]') && ((itemData && itemData.isSinglePrice) || $('[data-itemid="' + targetID + '"]').is('[data-singleprice="true"]'))) { 7666 calculation = calculation.replace(/\[total\]/g, form.priceSingle); 7667 } else { 7668 calculation = calculation.replace(/\[total\]/g, form.price); 7669 } 7670 if (calculation.indexOf('[total_quantity]') > -1) { 7671 calculation = calculation.replace(/\[total_quantity\]/g, lfb_getTotalQuantities(formID, _stepID, targetID)); 7672 } 7673 7674 if (calculation.indexOf('[price]') == -1) { 7675 i = 0; 7676 while ((i = calculation.indexOf('{', i + 1)) != -1) { 7677 var charsToEnd = calculation.substr(i + 1, (calculation.indexOf('}', i + 1) - (i + 1))); 7678 if (/\S/.test(charsToEnd)) { 7679 calculation = calculation.substr(0, i + 1) + ' price =' + calculation.substr(i + 1, calculation.length); 7680 i += 8; 7681 } 7682 } 7683 if (calculation.indexOf('if') < 0) { 7684 calculation = 'price = ' + calculation; 7685 } else { 7686 var charsToStart = calculation.substr(0, calculation.indexOf('if')); 7687 if (/\S/.test(charsToStart)) { 7688 calculation = 'price = ' + calculation; 7689 } 7690 } 7691 calculation = lfb_removeDoubleSpaces(calculation); 7692 calculation = calculation.replace(/price =\n if/g, "\nif"); 7693 calculation = calculation.replace(/price = if/g, "if"); 7694 calculation = calculation.replace(/price = \nif/g, "\nif"); 7695 calculation = calculation.replace(/price = \n if/g, "\n if"); 7696 } else { 7697 calculation = calculation.replace(/\[price\]/g, "price"); 7698 calculation = calculation.replace(/\[quantity\]/g, "price"); 7699 calculation = calculation.replace(/\[variable\]/g, "price"); 7700 7701 calculation = lfb_removeDoubleSpaces(calculation); 7702 } 7703 if (calculation.trim() != 'price =') { 7704 try { 7705 eval(calculation); 7706 } catch (e) { 7707 console.log('wrong calculation : ' + calculation); 7708 } 7709 } 7710 if (isVariable) { 7711 return price; 7712 } else { 7713 return parseFloat(price); 7714 } 7715 } 7716 7717 function lfb_parseDate(input) { 7718 var rep = input; 7719 if (typeof input == 'string') { 7720 var parts = input.match(/(\d+)/g); 7721 rep = new Date(parts[0], parts[1] - 1, parts[2]); 7722 } 7723 return rep; 7724 } 7725 7726 function lfb_removeDoubleSpaces(string) {
7727 string = string.replace(/\t/g, ''); 7728 string = string.replace(/ /g, ' '); 7729 if (string.indexOf(' ') > -1) { 7730 lfb_removeDoubleSpaces(string); 7731 } 7732 return string; 7733 } 7734 7735 function lfb_removeDistanceError(itemID, formID) { 7736 var $target = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]'); 7737 7738 if ($target.closest('.lfb_genSlide').find('[data-itemid][data-usedistance="true"]:not([data-distance]):not([type="checkbox"]).checked,[data-itemid][data-usedistance="true"]:not([data-distance]):checked,[data-itemid][data-usedistance="true"]:not([data-distance])[data-type="slider"]').length == 0 && 7739 $target.closest('.lfb_genSlide').find('[data-itemid][data-usedistance="true"][data-distance="0"]:not([type="checkbox"]).checked,[data-itemid][data-usedistance="true"][data-distance="0"]:checked,[data-itemid][data-usedistance="true"][data-distance="0"][data-type="slider"]').length == 0) { 7740 $target.closest('.lfb_genSlide').find('.lfb_btn-next').fadeIn(); 7741 $target.closest('.lfb_genSlide').find('.lfb_btnNextContainer').fadeIn(); 7742 $target.closest('.lfb_genSlide').find('.lfb_btn-next').removeClass('lfb_disabledBtn'); 7743 var errorMsg = $target.closest('.lfb_genSlide').find('.lfb_distanceError'); 7744 errorMsg.fadeOut(); 7745 setTimeout(function() { 7746 errorMsg.remove(); 7747 }, 300); 7748 } 7749 } 7750 7751 function lfb_showDistanceError(itemID, formID) { 7752 var form = lfb_getForm(formID); 7753 var $target = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]'); 7754 $target.closest('.lfb_genSlide').find('.lfb_btn-next').addClass('lfb_disabledBtn'); 7755 $target.closest('.lfb_genSlide').find('.lfb_btn-next').hide(); 7756 if ($target.closest('.lfb_genSlide').find('.lfb_distanceError').length == 0) { 7757 $target.closest('.lfb_genSlide').find('.lfb_btnNextContainer').before('<div class="lfb_distanceError alert alert-danger"><p>' + form.txtDistanceError + '</p></div>'); 7758 7759 } 7760 var stepID = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-itemid="' + itemID + '"]').closest('.lfb_genSlide').attr('data-stepid'); 7761 if (form.step == 'final' && !form.backFomFinal) { 7762 form.backFomFinal = true; 7763 lfb_changeStep(stepID, formID); 7764 } 7765 7766 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').trigger('lfb_distanceError'); 7767 7768 7769 } 7770 7771 function lfb_updateLabelItem($item, formID) { 7772 var form = lfb_getForm(formID); 7773 if (!$item.is('.dropzone')) { 7774 $item.closest('.lfb_itemBloc').find("label").each(function() { 7775 if ($(this).html().indexOf(":") > -1 && $(this).closest('.switch').length == 0) { 7776 $(this).html($item.attr('data-original-label')); 7777 } 7778 }); 7779 7780 if ($item.parent().children('.lfb_imgTitle').length > 0 && $item.is('[data-bs-original-title]')) { 7781 $item.parent().children('.lfb_imgTitle').html($item.attr('data-bs-original-title')); 7782 } 7783 if ($item.is('[type="checkbox"]')) { 7784 $item.closest('.lfb_itemBloc').find('div > label').first().html($item.attr('data-original-label')); 7785 } 7786 7787 if ($item.find('.lfb_buttonTitle').length > 0 && $item.is('[data-bs-original-title]')) { 7788 $item.find('.lfb_buttonTitle').html($item.attr('data-bs-original-title')); 7789 } 7790 7791 } 7792 } 7793 7794 function getItemCalculation(form, itemID, calculationType) { 7795 var rep = ''; 7796 if (form.debugCalculations == 1) { 7797 var attribute = 'calculation'; 7798 if (calculationType == 'calculationQt') { 7799 attribute = 'calculationqt'; 7800 } else if (calculationType == 'variableCalculation') { 7801 attribute = 'calculationvar'; 7802 } else if (calculationType == 'distanceQt') { 7803 attribute = 'distanceqt'; 7804 } 7805 7806 rep = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').attr('data-' + attribute); 7807 } else {
7808 form.usingCalculationItems.forEach(item => { 7809 if (item.id == itemID) { 7810 rep = item[calculationType]; 7811 } 7812 }); 7813 } 7814 return rep; 7815 } 7816 7817 function lfb_updatePrice(formID, fromItemID) { 7818 var hasSinglePrice = false; 7819 7820 var form = lfb_getForm(formID); 7821 lfb_updatePlannedSteps(formID); 7822 lfb_updateStep(formID); 7823 lfb_updateShowItems(formID); 7824 form.lastPrice = form.price; 7825 form.price = form.initialPrice; 7826 form.priceSingle = 0; 7827 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 7828 var pricePreviousStep = 0; 7829 var singlePricePreviousStep = 0; 7830 7831 for (var i = 0; i < form.variables.length; i++) { 7832 form.variables[i].value = form.variables[i].defaultValue; 7833 } 7834 7835 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 7836 lastAndCurrentSteps.push(parseInt(form.step)); 7837 } else if (form.step == 'final' && jQuery.inArray('final', lastAndCurrentSteps) == -1) { 7838 lastAndCurrentSteps.push('final'); 7839 } 7840 for (var i = 0; i < lastAndCurrentSteps.length; i++) { 7841 var step = lastAndCurrentSteps[i]; 7842 if ((step == 'final' || parseInt(step) != 0) && !$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + step + '"]').is('.lfb_disabled')) { 7843 var $panel = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + step + '"]'); 7844 7845 7846 $panel.find('[data-itemid]').each(function() { 7847 if ($(this).is('div.lfb_selectable.checked') || 7848 $(this).is('div[data-type="slider"]') || 7849 $(this).is('a.lfb_button.checked') || 7850 $(this).is('input[type=checkbox]:checked') || 7851 $(this).is('select[data-itemid][data-price]') || 7852 $(this).is('input[type=number][data-valueasqt="1"]') 7853 ) { 7854 if (!$(this).is('.lfb_disabled') && $(this).closest('.lfb_itemBloc.lfb_disabled').length == 0) { 7855 if (!$(this).is('.lfb_disabled')) { 7856 if ($(this).is('[data-singleprice="true"]')) { 7857 hasSinglePrice = true; 7858 } 7859 if (!$(this).is('[data-usecalculation]')) { 7860 $(this).data('price', $(this).attr('data-price')); 7861 } 7862 if ($(this).is('[data-usecalculation]')) { 7863 if (step == form.step || !$(this).is('.lfb_executed')) { 7864 7865 // $(this).data('price', lfb_executeCalculation($(this).attr('data-calculation'), formID, $(this).attr('data-itemid'))); 7866 $(this).data('price', lfb_executeCalculation(getItemCalculation(form, $(this).attr('data-itemid'), 'calculation'), formID, $(this).attr('data-itemid'))); 7867 7868 7869 } else { 7870 $(this).attr('data-price', $(this).data('price')); 7871 } 7872 } 7873 if ($(this).find('.icon_quantity').length > 0 || $(this).find('.lfb_qtfield').length > 0 || $(this).is('[data-type="slider"]') || $(this).is('input[type=number][data-valueasqt="1"]')) { 7874 var quantityA = ''; 7875 var min = 0; 7876 var max = 99999999999999; 7877 if ($(this).find('.icon_quantity').length > 0) { 7878 quantityA = $(this).find('.icon_quantity').html(); 7879 min = parseFloat($(this).find('.quantityBtns').attr('data-min')); 7880 max = parseFloat($(this).find('.quantityBtns').attr('data-max')); 7881 7882 7883 } else if ($(this).find('.lfb_qtfield').length > 0) { 7884 quantityA = $(this).find('.lfb_qtfield').val(); 7885 min = $(this).find('.lfb_qtfield').attr('min'); 7886 max = $(this).find('.lfb_qtfield').attr('max'); 7887 } else if ($(this).is('[data-type="slider"]')) { 7888 quantityA = parseFloat($(this).slider('value')); 7889 min = $(this).attr('data-min'); 7890 max = $(this).attr('data-max'); 7891 } else if ($(this).is('input[type=number][data-valueasqt="1"]')) { 7892 quantityA = parseFloat($(this).val()); 7893 min = $(this).attr('min'); 7894 if ($(this).is('[max]')) { 7895 max = $(this).attr('max'); 7896 } else { 7897 max = 99999999999999999; 7898 } 7899 } 7900 7901 if ($(this).is('[data-usecalculationqt]') && !$(this).is('.lfb_changed') && (typeof(fromItemID) == 'undefined' || $(this).attr('data-itemid') != fromItemID)) { 7902 //quantityA = lfb_executeCalculation($(this).attr('data-calculationqt'), formID, $(this).attr('data-itemid')); 7903 quantityA = lfb_executeCalculation(getItemCalculation(form, $(this).attr('data-itemid'), 'calculationQt'), formID, $(this).attr('data-itemid')); 7904 7905 if (isNaN(quantityA)) { 7906 quantityA = 0; 7907 } 7908 if (quantityA > max) { 7909 quantityA = max; 7910 } 7911 if (quantityA < min) { 7912 quantityA = min; 7913 } 7914 7915 if ($(this).find('.icon_quantity').length > 0) { 7916 $(this).find('.icon_quantity').html(quantityA); 7917 if ($(this).find('.lfb_sliderQt').length > 0) { 7918 $(this).find('.lfb_sliderQt').slider('value', parseFloat(quantityA)); 7919 } 7920 $(this).find('.quantityBtns').addClass('lfb-hidden'); 7921 7922 } else if ($(this).find('.lfb_qtfield').length > 0) { 7923 $(this).find('.lfb_qtfield').val(quantityA); 7924 } else if ($(this).is('[data-type="slider"]')) { 7925 $(this).slider('value', parseFloat(quantityA)); 7926 } else if ($(this).is('input[type="number"]')) { 7927 $(this).val(quantityA); 7928 } 7929 } 7930 7931 if ($(this).is('[data-distanceqt]')) { 7932 lfb_executeCalculation(getItemCalculation(form, $(this).attr('data-itemid'), 'distanceQt'), formID, $(this).attr('data-itemid')); 7933 7934 // lfb_executeCalculation($(this).attr('data-distanceqt'), formID, $(this).attr('data-itemid')); 7935 if ($(this).is('[data-distance]')) { 7936 quantityA = parseFloat($(this).attr('data-distance')).toFixed(2); 7937 } 7938 if (quantityA < min) { 7939 quantityA = min; 7940 } else if (quantityA > max) { 7941 quantityA = max; 7942 } 7943 if ($(this).find('.lfb_qtfield').length > 0) { 7944 $(this).find('.lfb_qtfield').val(quantityA); 7945 } else if ($(this).find('.lfb_sliderQt').length > 0) { 7946 $(this).find('.lfb_sliderQt').slider('value', quantityA); 7947 $(this).find('.icon_quantity').html(quantityA); 7948 } else if ($(this).find('.quantityBtns').length > 0) { 7949 $(this).find('.icon_quantity').html(quantityA); 7950 } else if ($(this).is('[data-type="slider"]')) { 7951 $(this).slider('value', quantityA); 7952 } 7953 7954 if ($(this).is('[data-usecalculation]')) { 7955 // $(this).data('price', lfb_executeCalculation($(this).attr('data-calculation'), formID, $(this).attr('data-itemid'))); 7956 $(this).data('price', lfb_executeCalculation(getItemCalculation(form, $(this).attr('data-itemid'), 'calculation'), formID, $(this).attr('data-itemid'))); 7957 7958 } 7959 } 7960 7961 7962 $(this).attr('data-resqt', quantityA); 7963 if ($(this).is('[data-price]')) { 7964 if ($(this).data('operation') == '-') { 7965 $(this).data('resprice', 0 - parseFloat($(this).data('price')) * parseFloat(quantityA)); 7966 if ($(this).is('[data-singleprice="true"]')) { 7967 form.priceSingle -= parseFloat($(this).data('price')) * parseFloat(quantityA); 7968 } else { 7969 form.price -= parseFloat($(this).data('price')) * parseFloat(quantityA); 7970 } 7971 } else if ($(this).data('operation') == 'x') { 7972 for (var i = 0; i < parseFloat(quantityA); i++) { 7973 if (i == 0) { 7974 form.price = form.price; 7975 $(this).data('resprice', form.price); 7976 } else { 7977 if ($(this).is('[data-singleprice="true"]')) { 7978 if ($(this).is('[data-addtototal!="no"]')) { 7979 form.priceSingle += ((singlePricePreviousStep * parseFloat($(this).data('price'))) / 100); 7980 } 7981 $(this).data('resprice', (singlePricePreviousStep * parseFloat($(this).data('price'))) / 100); 7982 } else { 7983 if ($(this).is('[data-addtototal!="no"]')) { 7984 form.price += ((pricePreviousStep * parseFloat($(this).data('price'))) / 100); 7985 } 7986 $(this).data('resprice', (form.price * parseFloat($(this).data('price'))) / 100); 7987 } 7988 } 7989 } 7990 } else if ($(this).data('operation') == '/') { 7991 for (var i = 0; i < parseFloat(quantityA); i++) { 7992 $(this).data('resprice', 0 - (form.price * parseFloat($(this).data('price'))) / 100); 7993 if ($(this).is('[data-singleprice="true"]')) { 7994 if ($(this).is('[data-addtototal!="no"]')) { 7995 form.priceSingle = form.price - (form.price * parseFloat($(this).data('price'))) / 100; 7996 } 7997 } else { 7998 if ($(this).is('[data-addtototal!="no"]')) { 7999 form.price = form.price - (form.price * parseFloat($(this).data('price'))) / 100; 8000 } 8001 } 8002 } 8003 } else { 8004 var reducIndex = -2; 8005 if ($(this).data('reduc') && $(this).data('reducqt').length > 0) { 8006 var self = this; 8007 var reducsTab = $(this).data('reducqt'); 8008 reducsTab = reducsTab.split("*"); 8009 var valuesTab = new Array(); 8010 var minQtReduc = 0; 8011 jQuery.each(reducsTab, function(i) { 8012 var reduc = reducsTab[i].split('|'); 8013 valuesTab.push(reduc[1]); 8014 if (parseFloat(reduc[0]) <= parseFloat(quantityA)) { 8015 reducIndex = i; 8016 } 8017 if (parseFloat(reduc[0]) < minQtReduc || minQtReduc == 0) { 8018 minQtReduc = parseFloat(reduc[0]); 8019 } 8020 8021 }); 8022 }
8023 if (reducIndex >= 0) { 8024 var calculatedPrice = parseFloat(valuesTab[reducIndex]) * parseFloat(quantityA); 8025 if ($(this).attr('data-price') == "0") { 8026 calculatedPrice = parseFloat(valuesTab[reducIndex]) * (parseFloat(quantityA) - minQtReduc); 8027 } 8028 $(this).data('resprice', calculatedPrice); 8029 if ($(this).is('[data-singleprice="true"]')) { 8030 8031 if ($(this).is('[data-addtototal!="no"]')) { 8032 form.priceSingle += parseFloat(calculatedPrice); 8033 } 8034 } else { 8035 if ($(this).is('[data-addtototal!="no"]')) { 8036 form.price += parseFloat(calculatedPrice); 8037 } 8038 } 8039 8040 if (form.currencyPosition == 'left') { 8041 if ($(this).is('[data-showprice="1"]')) { 8042 if ($(this).data('operation') == "+") { 8043 $(this).attr('title', $(this).data('originaltitle') + ': ' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8044 8045 8046 $(this).attr('data-original-label', $(this).data('originallabel') + ': ' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8047 8048 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': ' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8049 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8050 8051 } 8052 lfb_updateLabelItem($(this), formID); 8053 } else if ($(this).data('operation') == "-") { 8054 $(this).attr('title', $(this).data('originaltitle') + ': -' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8055 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8056 8057 } 8058 $(this).attr('data-original-label', $(this).data('originallabel') + ': -' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8059 8060 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': -' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8061 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8062 8063 } 8064 lfb_updateLabelItem($(this), formID); 8065 } else if ($(this).data('operation') == "x") { 8066 $(this).attr('title', $(this).data('originaltitle') + ': +' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8067 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8068 8069 } 8070 $(this).attr('data-original-label', $(this).data('originallabel') + ': +' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8071 8072 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': +' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8073 if (form.disableTipMobile == 0 || !lfb_is_touch_device()
8073) { 8074 8075 } 8076 8077 lfb_updateLabelItem($(this), formID); 8078 } else { 8079 $(this).attr('title', $(this).data('originaltitle') + ': -' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8080 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8081 8082 } 8083 $(this).attr('data-original-label', $(this).data('originallabel') + ': -' + form.currency + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8084 8085 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': -' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8086 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8087 8088 } 8089 lfb_updateLabelItem($(this), formID); 8090 } 8091 } else { 8092 $(this).attr('data-original-label', $(this).data('originallabel')); 8093 8094 if ($(this).is('[data-tooltiptext]')) { 8095 $(this).attr('data-bs-original-title', $(this).attr('data-tooltiptext')); 8096 } else { 8097 $(this).attr('data-bs-original-title', $(this).data('originaltitle')); 8098 8099 } 8100 } 8101 if ($(this).find('.quantityBtns').is('.o
8101pen') && form.imgTitlesStyle == '') { 8102 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8103 $(this).tooltip('show'); 8104 } 8105 } 8106 } else { 8107 if ($(this).is('[data-showprice="1"]')) { 8108 if ($(this).attr('data-operation') == "+") { 8109 $(this).attr('title', $(this).data('originaltitle') + ': ' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8110 $(this).attr('data-original-label', $(this).data('originallabel') + ': ' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8111 8112 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': ' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8113 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8114 8115 } 8116 lfb_updateLabelItem($(this), formID); 8117 } else if ($(this).attr('data-operation') == "-") { 8118 $(this).attr('title', $(this).data('originaltitle') + ': -' + (lfb_formatPrice(valuesTab[reducIndex], formID))); 8119 $(this).attr('data-original-label', $(this).data('originallabel') + ': -' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8120 8121 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': -' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8122 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8123 8124 } 8125 lfb_updateLabelItem($(this), formID); 8126 } else if ($(this).attr('data-operation') == "x") { 8127 $(this).attr('data-original-label', $(this).data('originallabel') + ': +' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8128 8129 $(this).attr('title', $(this).data('originaltitle') + ': +' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8130 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8131 8132 } 8133 $(this).attr('data-original-label', $(this).data('originallabel') + ': +' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8134 8135 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': +' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8136 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8137 8138 } 8139 lfb_updateLabelItem($(this), formID); 8140 } else { 8141 $(this).attr('data-original-label', $(this).data('originallabel') + ': -' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + form.currency); 8142 8143 $(this).attr('title', $(this).data('originaltitle') + ': --' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8144 if (form.disableTipMobile == 0 || !lfb_is_touch_device()
8144) { 8145 8146 } 8147 $(this).attr('data-bs-original-title', $(this).data('originaltitle') + ': -' + (lfb_formatPrice(valuesTab[reducIndex], formID)) + '%'); 8148 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8149 8150 } 8151 lfb_updateLabelItem($(this), formID); 8152 8153 } 8154 } else { 8155 $(this).attr('data-original-label', $(this).data('originallabel')); 8156 8157 if ($(this).is('[data-tooltiptext]')) { 8158 $(this).attr('data-bs-original-title', $(this).attr('data-tooltiptext')); 8159 8160 } else { 8161 $(this).attr('data-bs-original-title', $(this).data('originaltitle')); 8162 8163 } 8164 } 8165 if ($(this).find('.quantityBtns').is('.o
8165pen') && form.imgTitlesStyle == '') { 8166 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8167 $(this).tooltip('show'); 8168 } 8169 } 8170 } 8171 } else { 8172 $(this).data('resprice', parseFloat($(this).data('price')) * parseFloat(quantityA)); 8173 form.price = parseFloat(form.price); 8174 form.priceSingle = parseFloat(form.priceSingle); 8175 if ($(this).is('[data-singleprice="true"]')) { 8176 if ($(this).is('[data-addtototal!="no"]')) { 8177 form.priceSingle += parseFloat($(this).data('price')) * parseFloat(quantityA); 8178 } 8179 } else { 8180 if ($(this).is('[data-addtototal!="no"]')) { 8181 form.price += parseFloat($(this).data('price')) * parseFloat(quantityA); 8182 } 8183 } 8184 8185 lfb_updateItemTitleNoReduc($(this), form); 8186 if ($(this).find('.quantityBtns').is('.o
8186pen') && form.imgTitlesStyle == '') { 8187 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8188 $(this).tooltip('show'); 8189 } 8190 } 8191 8192 } 8193 } 8194 } else { 8195 $(this).data('resprice', '0'); 8196 } 8197 8198 8199 } else { 8200 $(this).data('resqt', '0'); 8201 if ($(this).data('price')) { 8202 if ($(this).data('operation') == '-') { 8203 $(this).data('resprice', 0 - parseFloat($(this).data('price'))); 8204 if ($(this).is('[data-singleprice="true"]')) { 8205 if ($(this).is('[data-addtototal!="no"]')) { 8206 form.priceSingle -= parseFloat($(this).data('price')); 8207 } 8208 } else { 8209 if ($(this).is('[data-addtototal!="no"]')) { 8210 form.price -= parseFloat($(this).data('price')); 8211 } 8212 } 8213 } else if ($(this).data('operation') == 'x') { 8214 if ($(this).is('[data-singleprice="true"]')) { 8215 $(this).data('resprice', (form.priceSingle * parseFloat($(this).data('price'))) / 100); 8216 if ($(this).is('[data-addtototal!="no"]')) { 8217 form.priceSingle = form.priceSingle + (form.priceSingle * parseFloat($(this).data('price'))) / 100; 8218 } 8219 } else { 8220 $(this).data('resprice', (form.price * parseFloat($(this).data('price'))) / 100); 8221 if ($(this).is('[data-addtototal!="no"]')) { 8222 form.price = form.price + (form.price * parseFloat($(this).data('price'))) / 100; 8223 } 8224 } 8225 } else if ($(this).attr('data-operation') == '/') { 8226 if ($(this).is('[data-singleprice="true"]')) { 8227 $(this).data('resprice', 0 - (form.priceSingle * parseFloat($(this).data('price'))) / 100); 8228 if ($(this).is('[data-addtototal!="no"]')) { 8229 form.priceSingle = form.priceSingle - (form.priceSingle * parseFloat($(this).data('price'))) / 100; 8230 } 8231 } else { 8232 $(this).data('resprice', 0 - (form.price * parseFloat($(this).data('price'))) / 100); 8233 if ($(this).is('[data-addtototal!="no"]')) { 8234 form.price = form.price - (form.price * parseFloat($(this).data('price'))) / 100; 8235 } 8236 } 8237 } else { 8238 $(this).data('resprice', $(this).data('price')); 8239 if ($(this).is('[data-singleprice="true"]')) { 8240 if ($(this).is('[data-addtototal!="no"]')) { 8241 form.priceSingle += parseFloat($(this).data('price')); 8242 } 8243 } else { 8244 if ($(this).is('[data-addtototal!="no"]')) { 8245 form.price = parseFloat(form.price) + parseFloat($(this).data('price')); 8246 } 8247 } 8248 8249 8250 } 8251 8252 lfb_updateItemTitleNoReduc($(this), form); 8253 } else { 8254 $(this).data('resprice', '0'); 8255 } 8256 } 8257 8258 8259 } 8260 } 8261 8262 if ($(this).is('[data-usecalculationvar]') && !$(this).is('[data-usecalculationvar="0"]')) {
8263 // lfb_updateVariable(form, $(this).attr('data-usecalculationvar'), $(this).attr('data-calculationvar'), $(this).attr('data-itemid')); 8264 lfb_updateVariable(form, $(this).attr('data-usecalculationvar'), getItemCalculation(form, $(this).attr('data-itemid'), 'variableCalculation'), $(this).attr('data-itemid')); 8265 8266 } 8267 8268 8269 } 8270 8271 8272 if ($(this).is('input[type!="checkbox"][data-usecalculationvar]') && !$(this).is('[data-usecalculationvar="0"]')) { 8273 // lfb_updateVariable(form, $(this).attr('data-usecalculationvar'), $(this).attr('data-calculationvar'), $(this).attr('data-itemid')); 8274 lfb_updateVariable(form, $(this).attr('data-usecalculationvar'), getItemCalculation(form, $(this).attr('data-itemid'), 'variableCalculation'), $(this).attr('data-itemid')); 8275 8276 } 8277 8278 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').trigger('priceUpdated', [$(this).attr('data-itemid')]); 8279 lfb_updateItemData(form, $(this).attr('data-itemid')); 8280 8281 }); 8282 } 8283 pricePreviousStep = form.price; 8284 singlePricePreviousStep = form.priceSingle; 8285 } 8286 if (form.reduction > 0) { 8287 if (form.reductionType && form.reductionType == '%') { 8288 if (form.priceSingle > 0) { 8289 form.reductionResult = (form.priceSingle * form.reduction) / 100; 8290 } else { 8291 form.reductionResult = (form.price * form.reduction) / 100; 8292 } 8293 } else { 8294 form.reductionResult = form.reduction; 8295 } 8296 form.reductionResult = parseFloat(form.reductionResult); 8297 if (form.priceSingle == 0) { 8298 form.price -= form.reductionResult; 8299 } else { 8300 form.priceSingle -= form.reductionResult; 8301 } 8302 8303 } 8304 8305 lfb_updateVAT(formID); 8306 8307 if (!form.price || form.price < 0) { 8308 form.price = 0; 8309 } 8310 if (!hasSinglePrice || !form.priceSingle || form.priceSingle < 0) { 8311 form.priceSingle = 0; 8312 } 8313 var pattern = /^\d+(\.\d{2})?$/; 8314 if (!pattern.test(form.price)) { 8315 form.price = parseFloat(form.price).toFixed(2); 8316 } 8317 try { 8318 if (!pattern.test(form.priceSingle)) { 8319 form.priceSingle = parseFloat(form.priceSingle).toFixed(2); 8320 } 8321 } catch (e) {} 8322 var formatedSinglePrice = form.currency + '' + lfb_formatPrice(parseFloat(form.priceSingle), formID); 8323 var formatedPrice = form.currency + '' + lfb_formatPrice(parseFloat(form.price), formID); 8324 var labelA = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-rangelabelbetween'); 8325 var labelB = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-rangelabeland'); 8326 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-totalrange]') && parseFloat(form.price) > 0) { 8327 if (!$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').is('.lfb_notNull')) { 8328 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').addClass('lfb_notNull'); 8329 } 8330 var range = parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-totalrange')); 8331 var rangeMin = (parseFloat(form.price) - range / 2); 8332 var rangeMax = parseFloat(form.price) + range / 2; 8333 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-rangemode="percent"]')) { 8334 rangeMin = parseFloat(form.price) - ((parseFloat(form.price) * range) / 100); 8335 rangeMax = parseFloat(form.price) + ((parseFloat(form.price) * range) / 100); 8336 } 8337 if (rangeMin < 0) { 8338 rangeMin = 0; 8339 } 8340 8341 formatedPrice = labelA + '<br/><strong>' + form.currency + '' + lfb_formatPrice(rangeMin, formID) + '</strong><br/>' + labelB + '<br/><strong>' + form.currency + '' + lfb_formatPrice(rangeMax, formID) + '</strong>'; 8342 } else { 8343 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').removeClass('lfb_notNull'); 8344 } 8345 if (form.currencyPosition != 'left') { 8346 formatedPrice = lfb_formatPrice(form.price, formID) + '' + form.currency; 8347 formatedSinglePrice = lfb_formatPrice(form.priceSingle, formID) + '' + form.currency; 8348 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-totalrange]') && parseFloat(form.price) > 0) { 8349 if (!$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').is('.lfb_notNull')) { 8350 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').addClass('lfb_notNull'); 8351 } 8352 var range = parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-totalrange')); 8353 var rangeMin = (parseFloat(form.price) - range / 2); 8354 var rangeMax = parseFloat(form.price) + range / 2; 8355 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-rangemode="percent"]')) { 8356 rangeMin = parseFloat(form.price) - ((parseFloat(form.price) * range) / 100); 8357 rangeMax = parseFloat(form.price) + ((parseFloat(form.price) * range) / 100); 8358 } 8359 if (rangeMin < 0) { 8360 rangeMin = 0; 8361 } 8362 formatedPrice = labelA + '<br/><strong>' + lfb_formatPrice(rangeMin, formID) + form.currency + '</strong><br/>' + labelB + '<br/><strong>' + lfb_formatPrice(rangeMax, formID) + form.currency + '</strong>'; 8363 } else { 8364 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').removeClass('lfb_notNull'); 8365 } 8366 } 8367 if (form.showTotalBottom == 1) { 8368 if (hasSinglePrice && form.priceSingle > 0) { 8369 if (form.price < 0) { 8370 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom').removeClass('lfb_priceSingle'); 8371 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom>span.lfb_subPrice').remove(); 8372 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom>br').remove(); 8373 8374 } else { 8375 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom').addClass('lfb_priceSingle'); 8376 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom').each(function() { 8377 if ($(this).find('.lfb_subPrice').length == 0) { 8378 $(this).find('>span:eq(0)').after('<br/><span class="lfb_subPrice">+ ' + formatedPrice + '</span>'); 8379 8380 } 8381 }); 8382 } 8383 } else { 8384 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom').removeClass('lfb_priceSingle'); 8385 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom>span.lfb_subPrice').remove(); 8386 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom>br').remove(); 8387 } 8388 8389 8390 if (hasSinglePrice && form.priceSingle > 0) { 8391 if (form.price <= 0) { 8392 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span:first-child').html(formatedSinglePrice); 8393 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span.lfb_subPrice').hide(); 8394 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span:eq(2)').hide(); 8395 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom .lfb_subTxtBottom').hide(); 8396 } else { 8397 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span.lfb_subPrice').show(); 8398 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span:eq(2)').show(); 8399 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span:first-child').html(formatedSinglePrice); 8400 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span.lfb_subPrice').html('+ ' + formatedPrice); 8401 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom .lfb_subTxtBottom').show(); 8402 } 8403 8404 } else { 8405 if (form.price <= 0) { 8406 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom .lfb_subTxtBottom').hide(); 8407 } else { 8408 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom .lfb_subTxtBottom').show(); 8409 } 8410 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_totalBottom> span:first-child').html(formatedPrice); 8411 8412 } 8413 } 8414 if (form.showSteps == 0) { 8415 if (hasSinglePrice && form.priceSingle > 0) { 8416 if (form.price < 0) { 8417 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').removeClass('lfb_priceSingle'); 8418 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price>span.lfb_subPrice').remove(); 8419 8420 } else { 8421 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').addClass('lfb_priceSingle'); 8422 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span.lfb_subPrice').length == 0) { 8423 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price>span:eq(0)').after('<span class="lfb_subPrice">+ ' + formatedPrice + '</span>'); 8424 8425 } 8426 } 8427 } else { 8428 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').removeClass('lfb_priceSingle'); 8429 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price>span.lfb_subPrice').remove(); 8430 } 8431 8432 8433 if (hasSinglePrice && form.priceSingle > 0) { 8434 if (form.price <= 0) { 8435 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').css('top', '6px'); 8436 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').html(formatedSinglePrice); 8437 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span.lfb_subPrice').hide(); 8438 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:eq(2)').hide(); 8439 } else { 8440 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').css('top', '-5px'); 8441 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span.lfb_subPrice').show(); 8442 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:eq(2)').show(); 8443 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').html(formatedSinglePrice); 8444 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span.lfb_subPrice').html('+ ' + formatedPrice); 8445 } 8446 8447 } else { 8448 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-isSubs="true"]')) { 8449 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').css('position', 'relative').css('top', '6px'); 8450 } else { 8451 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').css('position', 'relative').css('top', '0px'); 8452 } 8453 if (form.price > 0) { 8454 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').css('position', 'relative').css('top', '0px'); 8455 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:eq(1)').show(); 8456 } else { 8457 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:eq(1)').hide(); 8458 } 8459 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').html(formatedPrice); 8460 8461 } 8462 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').length > 0) { 8463 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price> span:first-child').html().length > 8) { 8464 if (parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').css('font-size')) >= 16) { 8465 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').css('font-size', '16px'); 8466 } 8467 } else { 8468 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').css('font-size', '18px'); 8469 } 8470 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price > span:first-child').html().length > 9) { 8471 if (parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').css('font-size')) >= 14) { 8472 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').css('font-size', '14px'); 8473 } 8474 } 8475 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price > span:first-child').html().length > 10) { 8476 if (parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').css('font-size')) >= 11) { 8477 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').css('font-size', '11px'); 8478 } 8479 } 8480 } 8481 var formPrice = form.price; 8482 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-isSubs="true"]') && form.progressBarPriceType == 'single') { 8483 formPrice = form.priceSingle; 8484 } 8485 var percent = (formPrice * 100) / form.priceMax; 8486 8487 if (form.showInitialPrice == 1) { 8488 percent = ((formPrice - parseFloat(form.initialPrice)) * 100) / form.priceMax; 8489 } 8490 if (percent > 100) { 8491 percent = 100; 8492 } 8493 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar').
8493css('width', percent + '%'); 8494 if ($('body').is('.rtl')) { 8495 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').animate({ 8496 right: percent + '%' 8497 }, 70); 8498 } else { 8499 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .genPrice .progress .progress-bar-price').animate({ 8500 left: percent + '%' 8501 }, 70); 8502 } 8503 } 8504 8505 var summaryPrice = form.currency + '' + lfb_formatPrice(parseFloat(form.price).toFixed(2), formID); 8506 var summaryPriceSingle = form.currency + '' + lfb_formatPrice(parseFloat(form.priceSingle).toFixed(2), formID); 8507 if (form.currencyPosition != 'left') { 8508 summaryPrice = lfb_formatPrice(parseFloat(form.price).toFixed(2), formID) + '' + form.currency; 8509 summaryPriceSingle = lfb_formatPrice(parseFloat(form.priceSingle).toFixed(2), formID) + '' + form.currency; 8510 } 8511 8512 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table #lfb_summaryTotal>span:eq(0)').html(summaryPrice); 8513 8514 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-totalrange]') && parseFloat(form.price) > 0) { 8515 var labelA = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-rangelabelbetween'); 8516 var labelB = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-rangelabeland'); 8517 var range = parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-totalrange')); 8518 var rangeMin = (parseFloat(form.price) - range / 2); 8519 var rangeMax = parseFloat(form.price) + range / 2; 8520 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-rangemode="percent"]')) { 8521 rangeMin = parseFloat(form.price) - ((parseFloat(form.price) * range) / 100); 8522 rangeMax = parseFloat(form.price) + ((parseFloat(form.price) * range) / 100); 8523 } 8524 if (rangeMin < 0) { 8525 rangeMin = 0; 8526 } 8527 8528 formatedPrice = labelA + '<br/><strong>' + form.currency + '' + lfb_formatPrice(rangeMin, formID) + '</strong><br/>' + labelB + '<br/><strong>' + form.currency + '' + lfb_formatPrice(rangeMax, formID) + '</strong>'; 8529 8530 if (form.currencyPosition != 'left') { 8531 var range = parseInt($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-totalrange')); 8532 formatedPrice = labelA + '<br/><strong>' + lfb_formatPrice(rangeMin, formID) + form.currency + '</strong><br/>' + labelB + '<br/><strong>' + lfb_formatPrice(rangeMax, formID) + form.currency + '</strong>'; 8533 } 8534 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table #lfb_summaryTotal>span:eq(0)').html(formatedPrice.replace(/<br\/>/g, ' ')); 8535 8536 } 8537 lfb_updateSummary(formID); 8538 if (hasSinglePrice && form.priceSingle > 0) { 8539 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(0)').html(formatedSinglePrice); 8540 if (form.price <= 0) { 8541 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').css('display', 'none'); 8542 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(2)').css('display', 'none'); 8543 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table #lfb_summaryTotal>span:eq(0)').html('<strong>' + summaryPriceSingle + '</strong>'); 8544 8545 } else { 8546 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(2)').css('display', 'inline-block'); 8547 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').html('+' + formatedPrice + form.subscriptionText); 8548 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').css('display', 'block'); 8549 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_summary table #lfb_summaryTotal>span:eq(0)').html('<strong>' + summaryPriceSingle + '</strong> <br/>+' + summaryPrice); 8550 8551 } 8552 } else if (form.priceSingle == 0 && form.price == 0) { 8553 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').css('display', 'none'); 8554 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(2)').css('display', 'none'); 8555 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(0)').html(formatedPrice); 8556 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').html(form.subscriptionText); 8557 8558 } else if (form.priceSingle == 0 && form.price > 0) { 8559 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(0)').html(formatedPrice); 8560 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').html(form.subscriptionText); 8561 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(2)').css('display', 'inline-block'); 8562 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').css('display', 'inline-block'); 8563 } else { 8564 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(2)').css('display', 'inline-block'); 8565 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(1)').css('display', 'inline-block'); 8566 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice span:eq(0)').html(formatedPrice); 8567 } 8568 8569 lfb_updateShowSteps(formID); 8570 lfb_updateShowItems(formID); 8571 lfb_updateLayerImages(formID); 8572 lfb_updateStep(formID); 8573 lfb_updateRichTextValues(formID); 8574 } 8575 8576 8577 function lfb_updateItemTitleNoReduc($item, form) { 8578 var formID = form.formID; 8579 if (form.currencyPosition == 'left') { 8580 if ($item.is('[data-showprice="1"]')) { 8581 if ($item.data('operation') == "+") { 8582 $item.attr('title', $item.data('originaltitle') + ': ' + form.currency + (lfb_formatPrice($item.data('price'), formID))); 8583 $item.attr('data-original-label', $item.data('originallabel') + ': ' + form.currency + (lfb_formatPrice($item.data('price'), formID))); 8584 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': ' + form.currency + (lfb_formatPrice($item.data('price'), formID))); 8585 8586 if (form.disableTipMobile == 0 || !lfb_is_touch_device()
8586) { 8587 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8588 8589 8590 } 8591 } 8592 lfb_updateLabelItem($item, formID); 8593 } else if ($item.data('operation') == "-") { 8594 $item.attr('data-original-label', $item.data('originallabel') + ': -' + form.currency + (lfb_formatPrice($item.data('price'), formID))); 8595 $item.attr('title', $item.data('originaltitle') + ': -' + form.currency + (lfb_formatPrice($item.data('price'), formID))); 8596 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8597 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') {} 8598 } 8599 8600 $item.attr('data-original-label', $item.data('originallabel') + ': -' + form.currency + (lfb_formatPrice($item.data('price'), formID))); 8601 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': -' + form.currency + (lfb_formatPrice($item.data('price'), formID))); 8602 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8603 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') {} 8604 } 8605 lfb_updateLabelItem($item, formID); 8606 } else if ($item.data('operation') == "x") { 8607 8608 $item.attr('title', $item.data('originaltitle') + ': +' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8609 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8610 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8611 8612 } 8613 } 8614 $item.attr('data-original-label', $item.data('originallabel') + ': +' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8615 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': +' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8616 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8617 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8618 8619 } 8620 } 8621 lfb_updateLabelItem($item, formID); 8622 } else { 8623 $item.attr('title', $item.data('originaltitle') + ': -' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8624 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8625 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8626 8627 } 8628 } 8629 $item.attr('data-original-label', $item.data('originallabel') + ': -' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8630 8631 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': -' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8632 8633 8634 8635 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8636 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8637 8638 } 8639 } 8640 lfb_updateLabelItem($item, formID); 8641 } 8642 } else { 8643 if ($item.is('[data-tooltiptext]')) { 8644 $item.attr('data-bs-original-title', $(this).attr('data-tooltiptext')); 8645 8646 } else { 8647 $item.attr('data-bs-original-title', $item.data('originaltitle')); 8648 8649 } 8650 } 8651 } else { 8652 if ($item.is('[data-showprice="1"]')) { 8653 if ($item.attr('data-operation') == "+") { 8654 $item.attr('title', $item.data('originaltitle') + ': ' + (lfb_formatPrice($item.data('price'), formID)) + form.currency); 8655 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': ' + (lfb_formatPrice($item.data('price'), formID)) + form.currency); 8656 if (form.disableTipMobile == 0 || !lfb_is_touch_device()
8656) { 8657 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8658 8659 } 8660 } 8661 lfb_updateLabelItem($item, formID); 8662 } else if ($item.attr('data-operation') == "-") { 8663 $item.attr('title', $item.data('originaltitle') + ': -' + (lfb_formatPrice($item.data('price'), formID))); 8664 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8665 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8666 8667 } 8668 } 8669 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': -' + (lfb_formatPrice($item.data('price'), formID)) + form.currency); 8670 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8671 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8672 8673 } 8674 } 8675 lfb_updateLabelItem($item, formID); 8676 } else if ($item.attr('data-operation') == "x") { 8677 $item.attr('title', $item.data('originaltitle') + ': +' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8678 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8679 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8680 8681 8682 } 8683 } 8684 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': +' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8685 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8686 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8687 8688 } 8689 } 8690 lfb_updateLabelItem($item, formID); 8691 } else { 8692 $item.attr('title', $item.data('originaltitle') + ': -' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8693 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8694 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8695 8696 } 8697 } 8698 $item.attr('data-bs-original-title', $item.data('originaltitle') + ': -' + (lfb_formatPrice($item.data('price'), formID)) + '%'); 8699 if (form.disableTipMobile == 0 || !lfb_is_touch_device()) { 8700 if (!$item.is('[data-type="slider"]') && !$item.is('.lfb_button') && form.imgTitlesStyle == '') { 8701 8702 } 8703 } 8704 lfb_updateLabelItem($item, formID); 8705 } 8706 } else { 8707 if ($item.is('[data-tooltiptext]')) { 8708 $item.attr('data-bs-original-title', $(this).attr('data-tooltiptext')); 8709 8710 } else { 8711 $item.attr('data-bs-original-title', $item.data('originaltitle')); 8712 8713 } 8714 } 8715 } 8716 if ($item.parent().children('.lfb_imgTitle').length > 0 && $item.is('[data-bs-original-title]')) { 8717 $item.parent().children('.lfb_imgTitle').html($item.attr('data-bs-original-title')); 8718 } 8719 8720 } 8721 8722 function lfb_isDecimal(n) { 8723 if (n == "") 8724 return false; 8725 8726 var strCheck = "0123456789"; 8727 var i; 8728 8729 for (i in n) { 8730 if (strCheck.indexOf(n[i]) == -1) 8731 return false; 8732 } 8733 return true; 8734 } 8735 8736 8737 function lfb_changeContentSlide(dir, formID) { 8738 var index = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_genContent').find('.lfb_genContentSlide.active').index(); 8739 if (dir == 'left') { 8740 if (index > 0) { 8741 index--; 8742 } else { 8743 index = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_genContent').find('.lfb_genContentSlide').length; 8744 } 8745 } else { 8746 if (index < $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_genContent').find('.lfb_genContentSlide').length - 1) { 8747 index++; 8748 } else { 8749 index = 0; 8750 } 8751 } 8752 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_genContent').find('.lfb_genContentSlide.active').fadeOut(500, function() { 8753 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_genContent').find('.lfb_genContentSlide.active').removeClass('active'); 8754 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_genContent').find('.lfb_genContentSlide').eq(index).delay(200).fadeIn(500, function() { 8755 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"]').find('.lfb_genContent').find('.lfb_genContentSlide').eq(index).delay(250).addClass('active'); 8756 }); 8757 }); 8758 } 8759 8760 function lfb_toggleField(fieldID, formID) { 8761 var form = lfb_getForm(formID); 8762 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #field_' + fieldID + '_cb').is(':checked')) { 8763 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #field_' + fieldID).addClass('opened'); 8764 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #field_' + fieldID).slideDown(250); 8765 } else { 8766 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #field_' + fieldID).removeClass('opened'); 8767 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #field_' + fieldID).slideUp(250); 8768 } 8769 setTimeout(function() { 8770 var titleHeight = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_stepTitle').height(); 8771 var heightP = $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid=' + form.step + '] .lfb_genContent').outerHeight() + parseInt($(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').css('padding-bottom')) + 102 + titleHeight;
8772 if (form.step == 'final') { 8773 heightP -= 80; 8774 } 8775 8776 var animSpeed = 300; 8777 if (form.animationsSpeed == 0) { 8778 animSpeed = 0; 8779 } 8780 $(' #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel').animate({ minHeight: heightP }, animSpeed); 8781 }, 300); 8782 } 8783 8784 function lfb_finalStep(formID) { 8785 var form = lfb_getForm(formID); 8786 form.step++; 8787 if (form.enablePdfDownload == 1) { 8788 var win = window.open(form.homeUrl + '/index.php?EPFormsBuilder=downloadMyOrder', '_blank'); 8789 if (typeof(win) !== 'null' && win != null) { 8790 win.focus(); 8791 setTimeout(function() { 8792 win.close(); 8793 }, 400); 8794 } 8795 } 8796 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').trigger('formSent'); 8797 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_loader').delay(800).fadeOut(form.animationsSpeed * 2); 8798 if (form.redirectionDelay == 0) { 8799 form.redirectionDelay = 1; 8800 } 8801 setTimeout(function() { 8802 var redirUrl = lfb_getRedirectionURL(formID); 8803 if (redirUrl != "" && redirUrl != "#" && redirUrl != " ") { 8804 if (form.urlVariables != '') { 8805 if (redirUrl.indexOf('?') > -1) { 8806 form.urlVariables.replace('?', '&'); 8807 } 8808 } 8809 document.location.href = redirUrl + form.urlVariables; 8810 } 8811 8812 }, form.redirectionDelay * 1000); 8813 8814 } 8815 8816 8817 function lfb_updateStep(formID) { 8818 var form = lfb_getForm(formID); 8819 if (form.showSteps == 1) { 8820 8821 var realPlannedSteps = new Array(); 8822 var noHideBtn = false; 8823 jQuery.each(lfb_plannedSteps, function() { 8824 if (!noHideBtn && !$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"]').is('.lfb_disabled') && 8825 ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"] .lfb_item:not(.lfb-hidden)').length > 0 || 8826 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"] .lfb_distanceError').length > 0)) { 8827 realPlannedSteps.push(this); 8828 } 8829 }); 8830 var disp_step = 0; 8831 jQuery.each(realPlannedSteps, function(i, v) { 8832 if (parseInt(v) == parseInt(form.step)) { 8833 disp_step = i; 8834 } 8835 }); 8836 disp_step++; 8837 if (disp_step == 0) { 8838 disp_step = 1; 8839 } 8840 if (form.step == 'final') { 8841 disp_step = realPlannedSteps.length + 1; 8842 } 8843 var totalStep = realPlannedSteps.length + 1; 8844 if (disp_step > totalStep) { 8845 disp_step = totalStep; 8846 } 8847 var percent = ((disp_step) * 100) / totalStep; 8848 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .genPrice .progress .progress-bar-price> span:first-child').html((disp_step) + '/' + totalStep); 8849 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .genPrice .progress .progress-bar').css('width', percent + '%'); 8850 } else if (form.showSteps == 3) { 8851 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_stepper *:not(#lfb_stepperBar)').remove(); 8852 var noHideBtn = false; 8853 var realPlannedSteps = new Array(); 8854 jQuery.each(lfb_plannedSteps, function() { 8855 if (!noHideBtn && !$('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"]').is('.lfb_disabled') && 8856 ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"] .lfb_item:not(.lfb-hidden)').length > 0 || 8857 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"] .lfb_distanceError').length > 0)) { 8858 realPlannedSteps.push(this); 8859 8860 8861 } 8862 }); 8863 var chkCurrentStep = false;
8864 var currentStepID = parseInt($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide.lfb_activeStep').attr('data-stepid')); 8865 jQuery.each(realPlannedSteps, function(i) { 8866 8867 var stepTitle = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + this + '"] .lfb_stepTitle').html(); 8868 var point = $('<a href="javascript:" class="lfb_stepperPoint" data-stepid="' + this + '" title="' + stepTitle + '"></a>'); 8869 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_stepper').append(point); 8870 8871 8872 point.tooltip({ 8873 html: true, 8874 container: '#lfb_form[data-form="' + formID + '"]', 8875 placement: 'bottom' 8876 }); 8877 8878 if (chkCurrentStep) { 8879 point.addClass('lfb_disabledPoint'); 8880 } else if (parseInt(this) == currentStepID) { 8881 point.addClass('lfb_currentPoint'); 8882 chkCurrentStep = true; 8883 } else { 8884 point.on('click', function() { 8885 var stepID = parseInt($(this).attr('data-stepid')); 8886 lfb_returnToStep(stepID, formID); 8887 }); 8888 } 8889 8890 var posX = (100 / realPlannedSteps.length) * (i); 8891 if ((posX == 100 || posX == 0) && realPlannedSteps.length == 1) { 8892 posX = 50; 8893 } else { 8894 posX += (100 / realPlannedSteps.length) / 2; 8895 } 8896 point.css({ 8897 left: posX + '%' 8898 }); 8899 if (parseInt(this) == currentStepID) { 8900 8901 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_stepper #lfb_stepperBar').css({ 8902 width: posX + '%' 8903 }); 8904 } 8905 }); 8906 if (form.step == 'final') { 8907 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_stepper #lfb_stepperBar').css({ 8908 width: '100%' 8909 }); 8910 } 8911 } 8912 } 8913 8914 function lfb_initPanelResize(formID) { 8915 var form = lfb_getForm(formID); 8916 $(window).resize(function() { 8917 lfb_resize(form); 8918 }); 8919 } 8920 8921 function lfb_resizeAll() { 8922 $(window).trigger('resize'); 8923 } 8924 8925 function lfb_resize(form) { 8926 var titleHeight = $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_stepTitle').height(); 8927 var heightP = $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_genContent').outerHeight() + parseInt($(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel').css('padding-bottom')) + 102 + titleHeight; 8928 if (form.step == 'final') { 8929 heightP -= 80; 8930 } 8931 var animSpeed = 300; 8932 if (form.animationsSpeed == 0) { 8933 animSpeed = 0; 8934 } 8935 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel').animate({ minHeight: heightP }, animSpeed); 8936 if (form.useSignature == 1) { 8937 $('#lfb_form[data-form="' + form.formID + '"] #lfb_signature canvas').attr('width', $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_signature').width()); 8938 } 8939 } 8940 8941 function lfb_rgb2hex(rgb) { 8942 if (rgb.indexOf('rgb') > -1) { 8943 try { 8944 rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/); 8945 8946 function hex(x) { 8947 return ("0" + parseInt(x).toString(16)).slice(-2); 8948 } 8949 return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); 8950 } catch (e) { 8951 return rgb; 8952 } 8953 } else { 8954 return rgb; 8955 } 8956 } 8957 8958 function lfb_formatPriceWithCurrency(price, formID) { 8959 var form = lfb_getForm(formID); 8960 price = lfb_formatPrice(price, formID); 8961 if (form.currencyPosition == 'left') { 8962 price = form.currency + price; 8963 } else { 8964 price += form.currency; 8965 } 8966 return price; 8967 } 8968 8969 function lfb_formatPrice(price, formID, forceDecimals) { 8970 if (!price) { 8971 price = 0; 8972 } 8973 if (typeof(forceDecimals) == 'undefined') { 8974 var forceDecimals = false;
8975 } 8976 var formatedPrice = price.toString(); 8977 if (formatedPrice.indexOf('.') > -1) { 8978 formatedPrice = parseFloat(price).toFixed(2).toString(); 8979 } 8980 var form = lfb_getForm(formID); 8981 if (form.summary_noDecimals == '1') { 8982 formatedPrice = Math.round(formatedPrice).toString(); 8983 } 8984 var decSep = form.decimalsSeparator; 8985 var thousSep = form.thousandsSeparator; 8986 var priceNoDecimals = formatedPrice; 8987 var millionSep = form.millionSeparator; 8988 var billionSep = form.billionsSeparator; 8989 var decimals = ""; 8990 if (formatedPrice.indexOf('.') > -1) { 8991 priceNoDecimals = formatedPrice.substr(0, formatedPrice.indexOf('.')); 8992 decimals = formatedPrice.substr(formatedPrice.indexOf('.') + 1, 2); 8993 formatedPrice = formatedPrice.replace('.', form.decimalsSeparator); 8994 if (decimals.toString().length == 1) { 8995 decimals = decimals.toString() + '0'; 8996 } 8997 if (priceNoDecimals.length > 9) { 8998 formatedPrice = priceNoDecimals.substr(0, priceNoDecimals.length - 9) + billionSep + priceNoDecimals.substr(priceNoDecimals.length - 9, 3) + millionSep + priceNoDecimals.substr(priceNoDecimals.length - 6, 3) + thousSep + priceNoDecimals.substr(priceNoDecimals.length - 3, priceNoDecimals.length) + form.decimalsSeparator + decimals; 8999 } else if (priceNoDecimals.length > 6) { 9000 formatedPrice = priceNoDecimals.substr(0, priceNoDecimals.length - 6) + millionSep + priceNoDecimals.substr(priceNoDecimals.length - 6, 3) + thousSep + priceNoDecimals.substr(priceNoDecimals.length - 3, priceNoDecimals.length) + form.decimalsSeparator + decimals; 9001 } else if (priceNoDecimals.length > 3) { 9002 formatedPrice = priceNoDecimals.substr(0, priceNoDecimals.length - 3) + thousSep + priceNoDecimals.substr(priceNoDecimals.length - 3, priceNoDecimals.length) + form.decimalsSeparator + decimals; 9003 } 9004 } else { 9005 if (priceNoDecimals.length > 9) { 9006 formatedPrice = formatedPrice = priceNoDecimals.substr(0, priceNoDecimals.length - 9) + billionSep + priceNoDecimals.substr(priceNoDecimals.length - 9, 3) + millionSep + priceNoDecimals.substr(priceNoDecimals.length - 6, 3) + thousSep + priceNoDecimals.substr(priceNoDecimals.length - 3, priceNoDecimals.length); 9007 } else if (priceNoDecimals.length > 6) { 9008 formatedPrice = priceNoDecimals.substr(0, priceNoDecimals.length - 6) + millionSep + priceNoDecimals.substr(priceNoDecimals.length - 6, 3) + thousSep + priceNoDecimals.substr(priceNoDecimals.length - 3, priceNoDecimals.length); 9009 } else if (priceNoDecimals.length > 3) { 9010 formatedPrice = priceNoDecimals.substr(0, priceNoDecimals.length - 3) + thousSep + priceNoDecimals.substr(priceNoDecimals.length - 3, priceNoDecimals.length); 9011 } 9012 if (forceDecimals) { 9013 formatedPrice += decSep + '00'; 9014 } 9015 } 9016 return formatedPrice; 9017 9018 } 9019 9020 function lfb_applyCouponCode(formID) { 9021 var form = lfb_getForm(formID); 9022 var code = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_couponField').val(); 9023 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_couponField').closest('.form-group').removeClass('has-error'); 9024 if (code.length < 3) { 9025 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_couponField').closest('.form-group').addClass('has-error'); 9026 } else { 9027 jQuery.ajax({ 9028 url: form.ajaxurl, 9029 type: 'post', 9030 data: { 9031 action: 'lfb_applyCouponCode', 9032 formID: formID, 9033 code: code 9034 }, 9035 success: function(rep) { 9036 setTimeout(function() { 9037 if (rep == '0' || rep == '') { 9038 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_couponField').closest('.form-group').addClass('has-error'); 9039 } else { 9040 9041 if ($('#lfb_form[data-form="' + formID + '"] #lfb_couponContainer').length > 0) { 9042 $('#lfb_form[data-form="' + formID + '"] #lfb_couponContainer').slideUp(); 9043 } 9044 var reduction = rep; 9045 if (rep.indexOf('%') > 0) { 9046 reduction = rep.substr(0, rep.length - 1); 9047 form.reductionType = '%'; 9048 } 9049 form.discountCode = code; 9050 form.reduction = parseFloat(reduction); 9051 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #finalSlide .lfb_genContent').animate({ opacity: 0 }, form.animationsSpeed); 9052 setTimeout(function() { 9053 lfb_updatePrice(formID); 9054 lfb_changeStep('final', formID); 9055 }, form.animationsSpeed + 100); 9056 } 9057 }, 200); 9058 } 9059 }); 9060 } 9061 } 9062 9063 function lfb_getRedirectionURL(formID) { 9064 var form = lfb_getForm(formID); 9065 var rep = form.close_url; 9066 if (form.useRedirectionConditions == 1) { 9067 jQuery.each(form.redirections, function() { 9068 var conditions = this.conditions.replace(/'/g, '"'); 9069 conditions = conditions.replace(/\\"/g, '"'); 9070 conditions = JSON.parse(conditions); 9071 var errors = lfb_checkConditions(conditions, formID, 'final'); 9072 var error = errors.error; 9073 var errorOR = errors.errorOR; 9074 9075 if ((this.conditionsOperator == 'OR' && !errorOR) || (this.conditionsOperator != 'OR' && !error)) { 9076 rep = this.url; 9077 } 9078 9079 }); 9080 } 9081 return rep; 9082 } 9083 9084 function lfb_formatQuantity(value) { 9085 return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); 9086 } 9087 9088 function lfb_isSelectionMode(formID) { 9089 if (formID > 0) { 9090 return $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').is('.lfb_tldSelection'); 9091 } else { 9092 return $('#lfb_form.lfb_bootstraped[data-form]').is('.lfb_tldSelection'); 9093 } 9094 9095 } 9096 9097 function lfb_startFormIntro(formID) {
9098 if (!lfb_isSelectionMode(formID)) { 9099 lfb_openGenerator(formID); 9100 } 9101 } 9102 9103 function lfb_initRichTextValues(formID) { 9104 var form = lfb_getForm(formID); 9105 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_richtext[data-itemid]:not(.lfb_shortcode)').each(function() { 9106 var i = 0; 9107 var elementsToReplace = new Array(); 9108 var _stepID = parseInt($(this).closest('.lfb_genSlide').attr('data-stepid')); 9109 if (form.richtextsContent[$(this).attr('data-itemid').toString()] !== undefined) { 9110 var content = form.richtextsContent[$(this).attr('data-itemid').toString()]; 9111 while ((i = content.indexOf('[variable-', i + 1)) != -1) { 9112 var variableID = content.substr(i + 10, content.indexOf(']', i) - (i + 10)); 9113 var value = '<span class="lfb_richVariable" data-varvariableid="' + variableID + '"></span>'; 9114 9115 elementsToReplace.push({ 9116 oldValue: content.substr(i, (content.indexOf(']', i) + 1) - (i)), 9117 newValue: value 9118 }); 9119 } 9120 9121 9122 i = 0; 9123 while ((i = content.indexOf('item-', i + 1)) != -1) { 9124 var itemID = content.substr(i + 5, content.indexOf('_', i) - (i + 5)); 9125 var action = content.substr(content.indexOf('_', i) + 1, (content.indexOf(']', i) - 1) - (content.indexOf('_', i))); 9126 var value = '<span class="lfb_richVariable" data-varitemid="' + itemID + '" data-action="' + action + '"></span>'; 9127 9128 elementsToReplace.push({ 9129 oldValue: content.substr(i - 1, (content.indexOf(']', i) + 1) - (i - 1)), 9130 newValue: value 9131 }); 9132 } 9133 9134 9135 if (content.indexOf('dateDifference-') > -1) { 9136 while ((i = content.indexOf('dateDifference-', i + 1)) != -1) { 9137 var startDateAdPosEnd = content.indexOf('_', i + 15) + 1; 9138 var startDate = content.substr(i + 15, content.indexOf('_', i) - (i + 15)); 9139 var endDate = content.substr(startDateAdPosEnd, content.indexOf(']', startDateAdPosEnd) - (startDateAdPosEnd)); 9140 9141 var itemID = startDate; 9142 var action = 'dateDifference'; 9143 var value = '<span class="lfb_richVariable" data-varitemid="' + itemID + '" data-action="' + action + '" data-enddateid="' + endDate + '"></span>'; 9144 9145 elementsToReplace.push({ 9146 oldValue: content.substr(i - 1, (content.indexOf(']', i) + 1) - (i - 1)), 9147 newValue: value 9148 }); 9149 } 9150 } 9151 9152 if (content.indexOf('distance_') > -1) { 9153 $target.attr('data-usedistance', 'true'); 9154 while ((i = content.indexOf('distance_', i + 1)) != -1) { 9155 9156 var distanceType = 'km'; 9157 9158 var departAdPosEnd = content.indexOf('-', i + 9) + 1; 9159 var departAdress = content.substr(i + 9, content.indexOf('-', i) - (i + 9)); 9160 9161 var departCityPosEnd = content.indexOf('-', departAdPosEnd) + 1; 9162 var departCity = content.substr(departAdPosEnd, content.indexOf('-', departAdPosEnd) - (departAdPosEnd)); 9163 9164 var departZipPosEnd = content.indexOf('-', departCityPosEnd) + 1; 9165 var departZip = content.substr(departCityPosEnd, content.indexOf('-', departCityPosEnd) - (departCityPosEnd)); 9166 9167 var departCountryPosEnd = content.indexOf('_', departZipPosEnd) + 1; 9168 var departCountry = content.substr(departZipPosEnd, content.indexOf('_', departZipPosEnd) - (departZipPosEnd)); 9169 9170 var arrivalAdPosEnd = content.indexOf('-', departCountryPosEnd) + 1; 9171 var arrivalAdress = content.substr(departCountryPosEnd, content.indexOf('-', departCountryPosEnd) - (departCountryPosEnd)
9171); 9172 9173 var arrivalCityPosEnd = content.indexOf('-', arrivalAdPosEnd) + 1; 9174 var arrivalCity = content.substr(arrivalAdPosEnd, content.indexOf('-', arrivalAdPosEnd) - (arrivalAdPosEnd)); 9175 9176 var arrivalZipPosEnd = content.indexOf('-', arrivalCityPosEnd) + 1; 9177 var arrivalZip = content.substr(arrivalCityPosEnd, content.indexOf('-', arrivalCityPosEnd) - (arrivalCityPosEnd)); 9178 9179 var arrivalCountryPosEnd = content.indexOf('_', arrivalZipPosEnd) + 1; 9180 var arrivalCountry = content.substr(arrivalZipPosEnd, content.indexOf('_', arrivalZipPosEnd) - (arrivalZipPosEnd)); 9181 9182 distanceType = content.substr(arrivalCountryPosEnd, content.indexOf(']', arrivalCountryPosEnd) - (arrivalCountryPosEnd)); 9183 9184 var action = 'distance'; 9185 var value = '<span class="lfb_richVariable" data-action="' + action + '" data-distancetype="' + distanceType + '" data-departadress="' + departAdress + '" data-departcity="' + departCity + '" data-departzip="' + departZip + '" data-departcountry="' + departCountry + '" data-arrivaladress="' + arrivalAdress + '" data-arrivalcity="' + arrivalCity + '" data-arrivalzip="' + arrivalZip + '" data-arrivalcountry="' + arrivalCountry + '" ></span>'; 9186 9187 elementsToReplace.push({ 9188 oldValue: content.substr(i - 1, (content.indexOf(']', i) + 1) - (i - 1)), 9189 newValue: value 9190 }); 9191 } 9192 9193 9194 9195 } 9196 9197 var todayDate = new Date(); 9198 var month = todayDate.getMonth() + 1; 9199 if (month < 10) { 9200 month = '0' + month; 9201 } 9202 var today = todayDate.getFullYear().toString() + month.toString() + todayDate.getDate().toString(); 9203 var dateFormat = lfb_forms[0].dateFormat.toUpperCase(); 9204 dateFormat = dateFormat.replace(/\\\//g, "/"); 9205 dateFormat = dateFormat.replace(/d /g, "DD "); 9206 dateFormat = dateFormat.replace(/yyyy/g, "YYYY"); 9207 content = content.replace(/\[currentDate\]/g, moment(todayDate).format(dateFormat)); 9208 content = content.replace(/\[total\]/g, '<span class="lfb_richVariable" data-action="total"></span>'); 9209 content = content.replace(/\[total_quantity\]/g, '<span class="lfb_richVariable" data-action="total_quantity"></span>'); 9210 9211 jQuery.each(elementsToReplace, function() { 9212 content = content.replace(this.oldValue, this.newValue); 9213 }); 9214 $(this).html(content); 9215 } 9216 9217 }); 9218 9219 } 9220 9221 function lfb_updateRichTextValues(formID) { 9222 var form = lfb_getForm(formID); 9223 var todayDate = new Date(); 9224 var month = todayDate.getMonth() + 1; 9225 if (month < 10) { 9226 month = '0' + month; 9227 } 9228 var today = todayDate.getFullYear().toString() + month.toString() + todayDate.getDate().toString(); 9229 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_richtext[data-itemid]:not(.lfb_shortcode) .lfb_richVariable[data-varvariableid]').each(function() { 9230 var variableID = $(this).attr('data-varvariableid'); 9231 var variable = lfb_getVariableByID(form, variableID); 9232 var value = 0; 9233 if (variable) { 9234 if (variable.type == 'float') { 9235 value = lfb_formatPrice(parseFloat(variable.value), formID); 9236 } else { 9237 value = variable.value; 9238 } 9239 9240 } 9241 9242 $(this).html(value); 9243 }); 9244 var lastAndCurrentSteps = JSON.parse(JSON.stringify(lfb_lastSteps)); 9245 if (form.step != 'final' && jQuery.inArray(parseInt(form.step), lastAndCurrentSteps) == -1) { 9246 lastAndCurrentSteps.push(parseInt(form.step)); 9247 } else if (form.step == 'final') { 9248 lastAndCurrentSteps.push('final'); 9249 } 9250 9251 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_richtext[data-itemid]:not(.lfb_shortcode) .lfb_richVariable:not([data-varvariableid])').each(function() { 9252 var i = 0; 9253 var _stepID = parseInt($(this).closest('.lfb_genSlide').attr('data-stepid')); 9254 var targetID = $(this).closest('.lfb_richtext').attr('data-itemid'); 9255 9256 var itemID = $(this).attr('data-varitemid'); 9257 var action = $(this).attr('data-action'); 9258 var value = 0; 9259 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]'); 9260 9261 var itemStepID = $item.closest('.lfb_genSlide').attr('data-stepid'); 9262 if (itemStepID != 'final') { 9263 itemStepID = parseInt(itemStepID); 9264 } 9265 9266 if (action == 'price') { 9267 value = 0; 9268 if (jQuery.inArray(itemStepID, lastAndCurrentSteps) > -1) { 9269 if (itemID == 'total') { 9270 value = form.price; 9271 } else { 9272 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('.checked') || 9273 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is(':checked') || 9274 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('select') || 9275 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('[data-type="slider"]')) { 9276 value = parseFloat($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').data('resprice')); 9277 if (isNaN(value)) { 9278 value = 0; 9279 } 9280 } 9281 } 9282 value = lfb_formatPrice(parseFloat(value), formID, true); 9283 if (form.currencyPosition == 'left') { 9284 value = form.currency + value; 9285 } else { 9286 value += form.currency; 9287 } 9288 } 9289 } 9290 if (action == 'title' || action == 'label') { 9291 if (jQuery.inArray(itemStepID, lastAndCurrentSteps) > -1 && !$item.is('.lfb_disabled')) { 9292 9293 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('.checked') || 9294 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is(':checked') || 9295 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('select') || 9296 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('[type="text"]') || 9297 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('[type="number"]') || 9298 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('textarea') || 9299 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('.lfb_colorPreview') || 9300 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('lfb_layeredImage') || 9301 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('[data-type="slider"]') || 9302 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('.lfb_dropzone') || 9303 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('[data-type="slider"]')) { 9304 value = $item.attr('data-originallabel'); 9305 9306 } else { 9307 value = ''; 9308 9309 } 9310 } else { 9311 value = ''; 9312 } 9313 } 9314 if (action == 'quantity') { 9315 if (jQuery.inArray(itemStepID, lastAndCurrentSteps) > -1) { 9316 if ($item.is('input') || $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('.checked') || 9317 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is(':checked')) { 9318 if ($item.is('input')) { 9319 value = $item.val(); 9320 } else if ($item.find('.icon_quantity').length > 0) { 9321 value = parseFloat($item.find('.icon_quantity').html()); 9322 } else { 9323 value = $item.find('.lfb_qtfield').val(); 9324 } 9325 if (isNaN(value)) { 9326 value = 0; 9327 } 9328 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('[data-type="slider"]')) { 9329 value = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').slider('value'); 9330 } 9331 value = lfb_formatPrice(parseFloat(value), formID); 9332 } 9333 } 9334 if (action == 'image') { 9335 if (jQuery.inArray(itemStepID, lastAndCurrentSteps) > -1 && !$item.is('.lfb_disabled') && $item.is('.checked')) { 9336 value = '<img src="' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"] img').attr('src') + '" alt=""/>'; 9337 } else { 9338 value = ''; 9339 } 9340 } 9341 if (action == 'value') { 9342 if (jQuery.inArray(itemStepID, lastAndCurrentSteps) > -1 && !$item.is('.lfb_disabled')) { 9343 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').is('select')) { 9344 value = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').val(); 9345 } else { 9346 value = ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + itemID + '"]').val()); 9347 9348 } 9349 } else { 9350 value = ''; 9351 } 9352 } 9353 if (action == 'date') { 9354 if (jQuery.inArray(itemStepID, lastAndCurrentSteps) > -1 && $item.is('.lfb_datepicker') && $item.datetimepicker("getDate") != null) { 9355 value = moment.utc($item.datetimepicker("getDate")).format('YYYY-MM-DD'); 9356 } else { 9357 value = "null"; 9358 } 9359 } 9360 if (action == 'dateDifference') { 9361 var startDate = itemID; 9362 var endDate = $(this).attr('data-enddateid'); 9363 9364 if (startDate == 'currentDate') { 9365 startDate = todayDate; 9366 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + startDate + '"]').length > 0 && 9367 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + startDate + '"]').val().length > 0) { 9368 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + startDate + '"]'); 9369 startDate = $item.datetimepicker("getDate"); 9370 } else { 9371 startDate = todayDate; 9372 } 9373 if (endDate == 'currentDate') { 9374 endDate = today; 9375 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + endDate + '"]').length > 0 && 9376 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + endDate + '"]').val().length > 0) { 9377 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + endDate + '"]'); 9378 endDate = $item.datetimepicker("getDate"); 9379 } else { 9380 endDate = todayDate; 9381 } 9382 9383 9384 var timeDiff = Math.abs(endDate.getTime() - startDate.getTime());
9385 var result = Math.ceil(timeDiff / (1000 * 3600 * 24)); 9386 if (result < 0) { 9387 result = 0; 9388 } 9389 value = result; 9390 } 9391 if (action == 'distance') { 9392 var departAdress = $(this).attr('data-departadress'); 9393 var departCity = $(this).attr('data-departcity'); 9394 var departZip = $(this).attr('data-departzip'); 9395 var departCountry = $(this).attr('data-departcountry'); 9396 var arrivalAdress = $(this).attr('data-arrivaladress'); 9397 var arrivalCity = $(this).attr('data-arrivalcity'); 9398 var arrivalZip = $(this).attr('data-arrivalzip'); 9399 var arrivalCountry = $(this).attr('data-arrivalcountry'); 9400 var distanceType = $(this).attr('data-distancetype'); 9401 9402 if (departAdress != "") { 9403 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departAdress + '"]').length > 0) { 9404 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departAdress + '"]'); 9405 departAdress = $item.val(); 9406 } else { 9407 departAdress = 0; 9408 } 9409 } 9410 if (departCity != "") { 9411 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCity + '"]').length > 0) { 9412 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCity + '"]'); 9413 departCity = $item.val(); 9414 } else { 9415 departCity = 0; 9416 } 9417 } 9418 if (departZip != "") { 9419 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departZip + '"]').length > 0) { 9420 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departZip + '"]'); 9421 departZip = $item.val(); 9422 } else { 9423 departZip = 0; 9424 } 9425 } 9426 if (departCountry != "") { 9427 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCountry + '"]').length > 0) { 9428 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCountry + '"]'); 9429 departCountry = $item.val(); 9430 } else { 9431 departCountry = 0; 9432 } 9433 } 9434 if (arrivalAdress != "") { 9435 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalAdress + '"]').length > 0) { 9436 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalAdress + '"]'); 9437 arrivalAdress = $item.val(); 9438 } else { 9439 arrivalAdress = 0; 9440 } 9441 } 9442 if (arrivalCity != "") { 9443 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCity + '"]').length > 0) { 9444 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCity + '"]'); 9445 arrivalCity = $item.val(); 9446 } else { 9447 arrivalCity = 0; 9448 } 9449 } 9450 if (arrivalZip != "") { 9451 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalZip + '"]').length > 0) { 9452 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalZip + '"]'); 9453 arrivalZip = $item.val(); 9454 } else { 9455 arrivalZip = 0; 9456 } 9457 } 9458 if (arrivalCountry != "") { 9459 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCountry + '"]').length > 0) { 9460 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCountry + '"]'); 9461 arrivalCountry = $item.val(); 9462 } else { 9463 arrivalCountry = 0; 9464 } 9465 } 9466 if ($target.closest('.lfb_genSlide').find('.lfb_distanceError').length > 0) { 9467 lfb_removeDistanceError(targetID, formID); 9468 } 9469 var distanceCode = content.substr(i - 1, (content.indexOf(']', i) + 1) - (i - 1)); 9470 var distance = 0; 9471 if ($target.attr('data-distance') != "") { 9472 distance = parseFloat($target.attr('data-distance')); 9473 } 9474 if (departAdress == "" && departCity == "" && departCountry == "" && arrivalAdress == "" && arrivalCity == "" && arrivalCountry == "" && departZip == "" && arrivalZip == "") { 9475 lfb_showDistanceError(targetID, formID); 9476 } else { 9477 if (form.gmap_key == "") { 9478 lfb_showDistanceError(targetID, formID); 9479 console.log("invalid gmap api key"); 9480 } else { 9481 var depart = departAdress + ' ' + departZip + ' ' + departCity + ' ' + departCountry; 9482 var arrival = arrivalAdress + ' ' + arrivalZip + ' ' + arrivalCity + ' ' + arrivalCountry; 9483 if ($target.attr('data-departure') != depart || arrival != $target.attr('data-arrival')) { 9484 $target.attr('data-departure', depart); 9485 $target.attr('data-arrival', arrival); 9486 lfb_getDistanceCalc(distanceCode, formID, targetID, depart, arrival, distanceType); 9487 } 9488 } 9489 } 9490 value = distance; 9491 } 9492 if (action == 'total') { 9493 value = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_finalPrice').html(); 9494 } else if (action == 'total_quantity') { 9495 value = lfb_getTotalQuantities(formID, _stepID, targetID); 9496 } 9497 $(this).html(value); 9498 }); 9499 } 9500 9501 function lfb_saveForLater(formID) { 9502 var form = lfb_getForm(formID); 9503 if (form.step != '0') { 9504 9505 if (localStorage.getItem('lfb_savedFormID') !== null && parseInt(localStorage.getItem('lfb_savedFormID')) == formID && localStorage.getItem('lfb_savedForm') !== null) { 9506 localStorage.removeItem('lfb_savedFormID'); 9507 localStorage.removeItem('lfb_formsession'); 9508 localStorage.removeItem('lfb_savedForm'); 9509 localStorage.removeItem('lfb_savedFormPastSteps'); 9510 localStorage.removeItem('lfb_savedFormStep'); 9511 localStorage.removeItem('lfb_savedFormTime'); 9512 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fa,.fas,.fab').attr('class', 'fas ' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-originalicon')); 9513 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext') != '') { 9514 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm span:not(.fa):not(.fas):not(.fab)').html($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext')); 9515 } 9516 } else { 9517 var selection = lfb_getFormContent(formID, true)[2]; 9518 localStorage.setItem('lfb_savedFormID', formID); 9519 localStorage.setItem('lfb_formsession', $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').attr('data-formsession')); 9520 localStorage.setItem('lfb_savedForm', JSON.stringify(selection)); 9521 localStorage.setItem('lfb_savedFormPastSteps', JSON.stringify(lfb_lastSteps)); 9522 localStorage.setItem('lfb_savedFormStep', form.step); 9523 localStorage.setItem('lfb_savedFormTime', Date.now()); 9524 9525 var defaultIconClass = ''; 9526 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fa,.fab,.fas').length > 0) { 9527 defaultIconClass = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fa,.fas,.fab').attr('class'); 9528 9529 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fa,.fas,.fab').attr('class', 'fas fa-check'); 9530 } 9531 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').removeClass('btn-default').addClass('btn-primary'); 9532 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext') != '') { 9533 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm span:not(.fa):not(.fas):not(.fab)').html($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-deltext')); 9534 } 9535 setTimeout(function() { 9536 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fas,.fa,.fab').length > 0) { 9537 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fas,.fa,.fab').attr('class', 'fas fa-redo'); 9538 } 9539 9540 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').removeClass('btn-primary').addClass('btn-default'); 9541 }, 1500); 9542 } 9543 } 9544 } 9545 9546 function lfb_getStoredSelectionItemID(selection, itemID) { 9547 var rep = false;
9548 9549 jQuery.each(selection, function() { 9550 if (this.itemid == itemID) { 9551 rep = this; 9552 } 9553 }); 9554 9555 return rep; 9556 } 9557 9558 function lfb_loadStoredForm(formID) { 9559 var form = lfb_getForm(formID); 9560 var dateS = new Date(parseInt(form.lastS)); 9561 9562 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').length > 0) { 9563 if (localStorage.getItem("lfb_savedFormID") !== null && parseInt(localStorage.getItem("lfb_savedFormID")) == formID && localStorage.getItem("lfb_savedForm") !== null) { 9564 9565 var dateSave = new Date(parseInt(localStorage.getItem("lfb_savedFormTime"))); 9566 if (dateSave > dateS) { 9567 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fas,.fa,.fab').attr('class', 'fas fa-redo'); 9568 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext') != '') { 9569 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm span:not(.fas):not(.fa):not(.fab)').html($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-deltext')); 9570 } 9571 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').attr('data-formsession', localStorage.getItem('lfb_formsession')); 9572 var selection = JSON.parse(localStorage.getItem("lfb_savedForm")); 9573 var pastSteps = JSON.parse(localStorage.getItem("lfb_savedFormPastSteps")); 9574 var currentStep = (localStorage.getItem("lfb_savedFormStep")); 9575 if (jQuery.inArray(currentStep, pastSteps) == -1) { 9576 pastSteps.push(currentStep); 9577 } 9578 9579 if (pastSteps.length > 0) { 9580 form.autoStart = true; 9581 jQuery.each(pastSteps, function() { 9582 var stepID = this.toString(); 9583 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-stepid="' + stepID + '"] [data-itemid]').each(function() { 9584 var $item = $(this); 9585 var storedItem = lfb_getStoredSelectionItemID(selection, parseInt($item.attr('data-itemid'))); 9586 if ($item.is('.lfb_selectable')) { 9587 if (storedItem != false) { 9588 if ($item.find('.icon_quantity').length > 0) { 9589 $item.find('.icon_quantity').html(storedItem.quantity); 9590 if ($item.find('.lfb_sliderQt').length > 0) { 9591 $item.find('.lfb_sliderQt').slider('value', parseInt(storedItem.quantity)); 9592 } 9593 9594 } else if ($item.find('.lfb_qtfield').length > 0) { 9595 $item.find('.lfb_qtfield').val(parseInt(storedItem.quantity)); 9596 } else if ($item.is('[data-type="slider"]')) { 9597 $item.slider('value', parseInt(storedItem.quantity)); 9598 } 9599 if (!$item.is('.checked')) { 9600 lfb_itemClick($(this), false, formID); 9601 } 9602 } else if ($item.is('.checked')) { 9603 lfb_itemClick($(this), false, formID); 9604 } 9605 } else if ($item.is('.lfb_button')) { 9606 if (storedItem != false) { 9607 if (!$item.is('.checked')) { 9608 lfb_itemClick($(this), false, formID); 9609 } 9610 } else if ($item.is('.checked')) { 9611 lfb_itemClick($(this), false, formID); 9612 } 9613 } else if ($item.is('[data-toggle="switch"]')) { 9614 if (storedItem != false) { 9615 if (!$item.is(':checked')) { 9616 $item.trigger('click'); 9617 } 9618 } else if ($item.is('.checked')) { 9619 lfb_itemClick($(this), false, formID); 9620 } 9621 } else if ($item.is('.lfb_colorPreview')) { 9622 if (storedItem != false) { 9623 $item.closest('.lfb_itemBloc').find('.lfb_colorpicker').val(storedItem.value); 9624 } 9625 } else if ($item.is('.lfb_datepicker')) { 9626 if (storedItem != false) { 9627 $item.val(storedItem.value); 9628 } 9629 } else if ($item.is('.lfb_dropzone')) { 9630 if (storedItem != false) { 9631 var dropzoneField = Dropzone.forElement('#' + $item.attr('id')); 9632 var fileName = storedItem.value; 9633 fileName = fileName.replace('- <span class="lfb_file">', ''); 9634 fileName = fileName.replace(' ', ''); 9635 fileName = fileName.replace('</span>', ''); 9636 fileName = fileName.replace('<br/>', ''); 9637 var preloadedFile = { 9638 name: fileName, 9639 size: 12345, 9640 accepted: true, 9641 kind: 'image' 9642 }; 9643 dropzoneField.emit("addedfile", preloadedFile); 9644 dropzoneField.files.push(preloadedFile); 9645 dropzoneField.createThumbnailFromUrl(preloadedFile, form.imgPreview, function() { 9646 dropzoneField.emit("complete", preloadedFile); 9647 }, "anonymous"); 9648 } 9649 } else if ($item.is('[data-type="numberfield"]')) { 9650 if (storedItem != false) { 9651 if ($item.is('[data-valueasqt="1"]')) { 9652 $item.val(storedItem.quantity); 9653 } else { 9654 $item.val(storedItem.value); 9655 } 9656 } 9657 } else if ($item.is('select')) { 9658 if (storedItem != false) { 9659 $item.val(storedItem.value); 9660 } 9661 } else if ($item.is('[data-type="slider"]')) { 9662 if (storedItem != false) { 9663 $item.slider('value', parseInt(storedItem.quantity)); 9664 } 9665 } else if ($item.is('textarea')) { 9666 if (storedItem != false) { 9667 $item.val(storedItem.value); 9668 } 9669 } else if ($item.is('input[type="text"]')) { 9670 if (storedItem != false) { 9671 $item.val(storedItem.value); 9672 } 9673 } 9674 }); 9675 if (stepID != currentStep) { 9676 lfb_lastSteps.push(parseInt(stepID)); 9677 } else { 9678 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] [data-stepid="' + stepID + '"] .lfb_errorMsg').hide(); 9679 if (form.intro_enabled == '1') { 9680 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #startInfos > p').slideDown(); 9681 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnFloatingSummary').css({ 9682 display: 'inline-block' 9683 }); 9684 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').css({ 9685 display: 'inline-block' 9686 }); 9687 9688 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_btnStart').parent().fadeOut(form.animationsSpeed, function() { 9689 if (form.showSteps != '2') { 9690 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"]').find('.genPrice,#lfb_stepper').fadeIn(form.animationsSpeed); 9691 } 9692 $(' #lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel').fadeIn(form.animationsSpeed + form.animationsSpeed / 2, function() { 9693 lfb_changeStep(currentStep, formID); 9694 }); 9695 }); 9696 } else { 9697 lfb_changeStep(currentStep, formID); 9698 } 9699 } 9700 }); 9701 } 9702 setTimeout(function() { 9703 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide.lfb_activeStep').css('opacity', 1); 9704 }, 2000); 9705 } else { 9706 9707 localStorage.removeItem('lfb_formsession'); 9708 localStorage.removeItem('lfb_savedFormID'); 9709 localStorage.removeItem('lfb_savedForm'); 9710 localStorage.removeItem('lfb_savedFormPastSteps'); 9711 localStorage.removeItem('lfb_savedFormStep'); 9712 localStorage.removeItem('lfb_savedFormTime'); 9713 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fa').attr('class', 'fa ' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-originalicon')); 9714 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fab').attr('class', 'fab ' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-originalicon')); 9715 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fas').attr('class', 'fas ' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-originalicon')); 9716 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext') != '') { 9717 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm span:not(.fas):not(.fab):not(.fa)').html($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext')); 9718 } 9719 } 9720 } else { 9721 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fa').attr('class', 'fa ' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-originalicon')); 9722 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fab').attr('class', 'fab ' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-originalicon')); 9723 9724 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').children('.fas').attr('class', 'fas ' + $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-originalicon')); 9725 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext') != '') { 9726 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm span:not(.fas):not(.fab):not(.fa)').html($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_btnSaveForm').attr('data-defaulttext')); 9727 } 9728 } 9729 } 9730 } 9731 9732 function lfb_getCalendarByID(calendarID) { 9733 var rep = false;
9734 jQuery.each(lfb_calendars, function() { 9735 if (this.id == calendarID) { 9736 rep = this; 9737 } 9738 }); 9739 return rep; 9740 } 9741 9742 function lfb_getDisabledHours(calendarID, day, eventDuration, eventDurationType) { 9743 var disabledHours = new Array(); 9744 var calendar = lfb_getCalendarByID(calendarID); 9745 if (calendar != false) { 9746 9747 var enabledMins = $('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').is('[data-disableminutes="0"]'); 9748 var maxEvents = parseInt($('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').attr('data-maxevents')); 9749 if (isNaN(maxEvents) || maxEvents == 0) { 9750 maxEvents = 1; 9751 } 9752 9753 var durationToSub = eventDurationType; 9754 if (eventDurationType == 'mins') { 9755 durationToSub = 'minutes'; 9756 } 9757 9758 var selDate = new Date(day); 9759 var daysWeek = new Array(); 9760 if ($('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').attr('data-daysweek').indexOf(',') > -1) { 9761 daysWeek = $('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').attr('data-daysweek').split(','); 9762 } 9763 if (selDate.getDay() != '' && ($('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').attr('data-daysweek') == selDate.getDay() || daysWeek.indexOf(selDate.getDay()) > -1)) { 9764 for (var i = 0; i < 24; i++) { 9765 disabledHours.push(parseInt(i)); 9766 } 9767 9768 } else { 9769 if ($('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"][data-hoursdisabled]').attr('data-hoursdisabled') != '') { 9770 var hoursDisabledData = $('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').attr('data-hoursdisabled'); 9771 if (hoursDisabledData.indexOf(',') > -1) { 9772 jQuery.each(hoursDisabledData.split(','), function() { 9773 var hour = parseInt(this); 9774 disabledHours.push(hour); 9775 if (eventDurationType == 'hours') { 9776 for (var i = 0; i < parseInt(eventDuration); i++) { 9777 if (jQuery.inArray(hour - i, disabledHours) == -1) { 9778 disabledHours.push(hour - i); 9779 } 9780 } 9781 } else if (eventDurationType == 'mins') { 9782 for (var i = 0; i <= Math.floor(eventDuration / 60); i++) { 9783 if (jQuery.inArray(hour - i, disabledHours) == -1) { 9784 disabledHours.push(hour - i); 9785 } 9786 } 9787 } 9788 }); 9789 } else { 9790 disabledHours.push(parseInt(hoursDisabledData)); 9791 } 9792 } 9793 9794 var nbEventsHours = []; 9795 for (var i = 0; i < 24; i++) { 9796 nbEventsHours[i] = 0; 9797 } 9798 9799 jQuery.each(calendar.events, function() { 9800 var startDate = moment(this.startDate); 9801 startDate = startDate.subtract(parseInt(eventDuration), durationToSub); 9802 startDate = startDate.add(5, 'minute'); 9803 9804 for (var i = 0; i < 24; i++) { 9805 var formatedI = i; 9806 if (i < 10) { 9807 formatedI = '0' + i; 9808 } 9809 var currentDate = moment(day + ' ' + formatedI + ':00'); 9810 if (((!enabledMins && currentDate.isSameOrAfter(startDate, 'hour')) || (enabledMins && currentDate.isAfter(startDate, 'hour'))) && currentDate.isBefore(moment(this.endDate), 'hour')) { 9811 nbEventsHours[i]++; 9812 if (nbEventsHours[i] >= maxEvents) { 9813 if (jQuery.inArray(i, disabledHours) == -1) { 9814 disabledHours.push(parseInt(i)); 9815 } 9816 } 9817 } 9818 } 9819 }); 9820 } 9821 } 9822 return disabledHours; 9823 } 9824 9825 function lfb_getDisabledMinutes(calendarID, day, hour, eventDuration, eventDurationType) { 9826 var disabledMinutes = new Array(); 9827 var calendar = lfb_getCalendarByID(calendarID); 9828 9829 if (calendar != false) { 9830 9831 var maxEvents = parseInt($('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').attr('data-maxevents')); 9832 if (isNaN(maxEvents) || maxEvents == 0) { 9833 maxEvents = 1; 9834 } 9835 9836 var disabledHours = lfb_getDisabledHours(calendarID, day, eventDuration, eventDurationType); 9837 9838 var durationToSub = eventDurationType; 9839 if (eventDurationType == 'mins') { 9840 durationToSub = 'minutes'; 9841 } 9842 var hoursDisabledData = $('#lfb_form .lfb_datepicker[data-calendarid="' + calendar.id + '"]').attr('data-hoursdisabled'); 9843 if (hoursDisabledData.indexOf(',') > -1) { 9844 jQuery.each(hoursDisabledData.split(','), function() { 9845 var hourD = parseInt(this); 9846 var maxTime = moment(new Date(day + ' ' + hourD + ':00')).subtract(parseInt(eventDuration), durationToSub).add(1, 'minute').format('YYYY-MM-DD HH:mm'); 9847 for (var i = 0; i <= 11; i++) { 9848 if (moment(new Date(day + ' ' + hour + ':' + (i * 5))).isAfter(moment(new Date(maxTime))) && moment(new Date(day + ' ' + hour + ':' + (i * 5))).isBefore(moment(new Date(moment(new Date(day + ' ' + hourD + ':00')))))) { 9849 if (jQuery.inArray(i * 5, disabledMinutes) == -1) { 9850 disabledMinutes.push(parseInt(i * 5)); 9851 } 9852 } 9853 } 9854 }); 9855 } 9856 if (jQuery.inArray(parseInt(hour), disabledHours) > -1) { 9857 for (var i = 0; i <= 11; i++) { 9858 if (jQuery.inArray(i * 5, disabledMinutes) == -1) { 9859 disabledMinutes.push(parseInt(i * 5)); 9860 } 9861 } 9862 } 9863 9864 var nbEventsMins = []; 9865 for (var i = 0; i <= 11; i++) { 9866 nbEventsMins[parseInt(i * 5)] = 0; 9867 } 9868 9869 jQuery.each(calendar.events, function() { 9870 var startDate = moment(this.startDate); 9871 startDate = startDate.subtract(parseInt(eventDuration), durationToSub); 9872 startDate = startDate.add(5, 'minute'); 9873 9874 9875 var formatedHour = parseInt(hour); 9876 if (formatedHour < 10) { 9877 formatedHour = '0' + formatedHour; 9878 } 9879 var currentDate = moment(day + ' ' + formatedHour + ':00'); 9880 9881 if (currentDate.isAfter(startDate, 'hour') && currentDate.isBefore(moment(this.endDate), 'hour')) { 9882 for (var i = 0; i <= 11; i++) { 9883 nbEventsMins[parseInt(i * 5)]++; 9884 if (nbEventsMins[parseInt(i * 5)] >= maxEvents) { 9885 if (jQuery.inArray(i * 5, disabledMinutes) == -1) { 9886 disabledMinutes.push(parseInt(i * 5)); 9887 } 9888 } 9889 } 9890 } else if (currentDate.isSame(startDate, 'hour')) { 9891 for (var i = 0; i <= 11; i++) { 9892 if (startDate.isSame(moment(this.endDate), 'hour')) { 9893 9894 if (i * 5 >= startDate.format('mm') && i * 5 < moment(this.endDate).format('mm')) { 9895 nbEventsMins[parseInt(i * 5)]++; 9896 if (nbEventsMins[parseInt(i * 5)] >= maxEvents) { 9897 if (jQuery.inArray(i * 5, disabledMinutes) == -1) { 9898 disabledMinutes.push(parseInt(i * 5)); 9899 } 9900 } 9901 } 9902 } else { 9903 if (i * 5 >= startDate.format('mm')) { 9904 nbEventsMins[parseInt(i * 5)]++; 9905 if (nbEventsMins[parseInt(i * 5)] >= maxEvents) { 9906 if (jQuery.inArray(i * 5, disabledMinutes) == -1) { 9907 disabledMinutes.push(parseInt(i * 5)); 9908 } 9909 } 9910 } 9911 } 9912 9913 } 9914 } else if (currentDate.isSame(moment(this.endDate), 'hour')) { 9915 for (var i = 0; i <= 11; i++) { 9916 if (i * 5 < moment(this.endDate).format('mm')) { 9917 nbEventsMins[parseInt(i * 5)]++; 9918 if (nbEventsMins[parseInt(i * 5)] >= maxEvents) { 9919 if (jQuery.inArray(i * 5, disabledMinutes) == -1) { 9920 disabledMinutes.push(parseInt(i * 5)); 9921 } 9922 } 9923 } 9924 } 9925 9926 } 9927 9928 }); 9929 } 9930 return disabledMinutes; 9931 } 9932 9933 function lfb_setAnimImmediate(e, formID) { 9934 var form = lfb_getForm(formID); 9935 form.animationsSpeed = 0; 9936 } 9937 9938 function lfb_getCalendarEventsAtDate(calendar, date) { 9939 var rep = 0; 9940 jQuery.each(calendar.events, function() { 9941 var startDate = moment.utc(this.startDate); 9942 var endDate = moment.utc(this.endDate); 9943 if (date.isSameOrAfter(startDate) && (this.fullDay || date.isSameOrBefore(endDate))) { 9944 rep++; 9945 } 9946 }); 9947 return rep; 9948 } 9949 9950 function lfb_getBusyDates(formID, calendarsIDs) { 9951 var form = lfb_getForm(formID); 9952 jQuery.ajax({ 9953 url: form.ajaxurl, 9954 type: 'post', 9955 data: { 9956 action: 'lfb_getBusyDates', 9957 formID: formID, 9958 calendarsIDs: calendarsIDs 9959 }, 9960 success: function(rep) { 9961 rep = rep.trim(); 9962 rep = JSON.parse(rep, true); 9963 lfb_calendars = rep.calendars; 9964 jQuery.each(rep.calendars, function() { 9965 9966 var _calendar = this; 9967 $('#lfb_form .lfb_datepicker[data-calendarid="' + this.id + '"]').each(function() { 9968 var _datepicker = $(this); 9969 9970 var disabledDates = new Array(); 9971 jQuery.each(_calendar.events, function() { 9972 if (this.fullDay == 1) { 9973 var startDate = moment.utc(this.startDate); 9974 var endDate = moment.utc(this.endDate); 9975 endDate.subtract(1,'minutes'); 9976 var startDateSt = startDate.format('YYYY-MM-DD'); 9977 if (lfb_getCalendarEventsAtDate(_calendar, startDate) >= _datepicker.attr('data-maxevents')) { 9978 disabledDates.push(startDateSt); 9979 } 9980 9981 for (var i = 1; i <= endDate.diff(startDate, 'days'); i++) { 9982 var date = startDate.add(i, 'days'); 9983 if (lfb_getCalendarEventsAtDate(_calendar, date) >= _datepicker.attr('data-maxevents')) { 9984 disabledDates.push(date.format('YYYY-MM-DD')); 9985 } 9986 } 9987 } else { 9988 var startDate = moment.utc(this.startDate); 9989 9990 var durationToSub = _datepicker.attr('data-eventdurationtype'); 9991 if (_datepicker.attr('data-eventdurationtype') == 'mins') { 9992 durationToSub = 'minutes'; 9993 } 9994 this.startDate = startDate.format('YYYY-MM-DD HH:mm'); 9995 9996 var endDate = moment.utc(this.endDate); 9997 var startDateSt = startDate.format('YYYY-MM-DD'); 9998 9999 if (endDate.diff(startDate, 'hours') > 24) { 10000 10001 var startI = 1; 10002 if (startDate.format('m') == 0) { 10003 startI = 0; 10004 } 10005 for (var i = startI; i <= endDate.diff(startDate, 'days'); i++) { 10006 var date = startDate.clone().add(i, 'days'); 10007 if (lfb_getCalendarEventsAtDate(_calendar, date) >= _datepicker.attr('data-maxevents')) { 10008 disabledDates.push(date.format('YYYY-MM-DD')); 10009 } 10010 } 10011 } 10012 } 10013 }); 10014 _datepicker.datetimepicker('setDatesDisabled', disabledDates); 10015 }); 10016 10017 }); 10018 } 10019 }); 10020 } 10021 10022 function lfb_showWinStripePayment(form) { 10023 10024 var isOK = lfb_checkStepItemsValid('final', form.formID); 10025
10026 if (form.legalNoticeEnable == 1) { 10027 if (!$('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_legalCheckbox').is(':checked')) { 10028 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_legalCheckbox').closest('.form-group').addClass('has-error'); 10029 isOK = false; 10030 } 10031 } 10032 10033 if (isOK) { 10034 lfb_checkCaptcha(form, function() { 10035 var activatePaypal = true; 10036 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-activatePaypal="true"]:not(:checked):not(.checked)').each(function() { 10037 var cStepID = $(this).closest('.lfb_genSlide').attr('data-stepid'); 10038 if (cStepID != 'final') { 10039 cStepID = parseInt(cStepID); 10040 } 10041 if (jQuery.inArray(cStepID, lfb_lastSteps) == -1) {} else { 10042 activatePaypal = false; 10043 } 10044 }); 10045 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('[data-dontactivatepaypal="true"].checked,[data-dontactivatepaypal="true"]:checked').length > 0) { 10046 activatePaypal = false; 10047 } 10048 if (!activatePaypal || (form.price == 0 && form.priceSingle == 0)) { 10049 lfb_order(form.formID); 10050 } else { 10051 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-info="amount"]').html($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_finalPrice').html()); 10052 10053 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10054 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="loading"]').show(); 10055 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal .modal-footer').hide(); 10056 lfb_stripe = Stripe(form.stripePubKey); 10057 10058 var singleTotal = parseFloat(form.price); 10059 var subTotal = 0; 10060 10061 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-isSubs="true"]')) { 10062 singleTotal = parseFloat(form.priceSingle); 10063 subTotal = parseFloat(form.price); 10064 } 10065 10066 if (form.payMode == 'percent') { 10067 singleTotal = parseFloat(singleTotal) * (parseFloat(form.percentToPay) / 100); 10068 var amountToShow = '<span>' + lfb_formatPriceWithCurrency(singleTotal, form.formID) + '</span>'; 10069 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-info="amount"]').html(amountToShow); 10070 10071 } else if (form.payMode == 'fixed') { 10072 singleTotal = parseFloat(form.fixedToPay); 10073 var amountToShow = '<span>' + lfb_formatPriceWithCurrency(singleTotal, form.formID) + '</span>'; 10074 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-info="amount"]').html(amountToShow); 10075 } 10076 10077 if (form.stripeToken == '' || (typeof(form.stripeAmountSingle) != 'undefined' && form.stripeAmountSingle != singleTotal) || (typeof(form.stripeAmountSingle) != 'undefined' && form.stripeAmountSub != subTotal)) { 10078 10079 jQuery.ajax({ 10080 url: form.ajaxurl, 10081 type: 'post', 10082 data: { 10083 action: 'lfb_getStripePaymentIntent', 10084 singleTotal: singleTotal, 10085 subTotal: subTotal, 10086 formID: form.formID, 10087 customerInfos: lfb_getContactInformations(form.formID, true) 10088 }, 10089 success: function(rep) { 10090 rep = JSON.parse(rep); 10091 form.stripeToken = rep.token; 10092 form.stripeCustomerID = rep.customerID; 10093 form.stripeAmountSingle = singleTotal; 10094 form.stripeAmountSub = subTotal; 10095 10096 var elements = lfb_stripe.elements(); 10097 form.cardElement = elements.create('cardNumber'); 10098 form.cardElement.mount('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-element'); 10099 10100 form.cardExp = elements.create('cardExpiry'); 10101 form.cardExp.mount('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_expiration-element'); 10102 10103 form.cardExp.addEventListener('change', function(event) { 10104 if (event.error) { 10105 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(event.error.message); 10106 } else { 10107 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(''); 10108 } 10109 }); 10110 10111 form.cardCvc = elements.create('cardCvc'); 10112 form.cardCvc.mount('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_cvc-element'); 10113 10114 form.cardCvc.addEventListener('change', function(event) { 10115 if (event.error) { 10116 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(event.error.message); 10117 } else { 10118 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(''); 10119 } 10120 }); 10121 10122 form.cardElement.addEventListener('change', function(event) { 10123 if (event.error) { 10124 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(event.error.message); 10125 } else { 10126 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(''); 10127 } 10128 }); 10129 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10130 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="form"]').show(); 10131 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal .modal-footer').slideDown(); 10132 10133 } 10134 }); 10135 } else { 10136 var elements = lfb_stripe.elements(); 10137 form.cardElement = elements.create('cardNumber'); 10138 form.cardElement.mount('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-element'); 10139 form.cardElement.addEventListener('change', function(event) { 10140 if (event.error) { 10141 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(event.error.message); 10142 } else { 10143 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(''); 10144 } 10145 }); 10146 10147 form.cardExp = elements.create('cardExpiry'); 10148 form.cardExp.mount('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_expiration-element'); 10149 10150 form.cardExp.addEventListener('change', function(event) { 10151 if (event.error) { 10152 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(event.error.message); 10153 } else { 10154 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(''); 10155 } 10156 }); 10157 10158 form.cardCvc = elements.create('cardCvc'); 10159 form.cardCvc.mount('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_cvc-element'); 10160 10161 form.cardCvc.addEventListener('change', function(event) { 10162 if (event.error) { 10163 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(event.error.message); 10164 } else { 10165 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripe_card-error').html(''); 10166 } 10167 }); 10168 10169 var singleTotal = parseFloat(form.price); 10170 var subTotal = 0; 10171 10172 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('[data-isSubs="true"]')) { 10173 singleTotal = parseFloat(form.priceSingle); 10174 subTotal = parseFloat(form.price); 10175 } 10176 if (form.payMode == 'percent') { 10177 singleTotal = parseFloat(singleTotal) * (parseFloat(form.percentToPay) / 100); 10178 var amountToShow = '<span>' + lfb_formatPriceWithCurrency(singleTotal, form.formID) + '</span>'; 10179 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-info="amount"]').html(amountToShow); 10180 10181 } else if (form.payMode == 'fixed') { 10182 singleTotal = parseFloat(form.fixedToPay); 10183 var amountToShow = '<span>' + lfb_formatPriceWithCurrency(singleTotal, form.formID) + '</span>'; 10184 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-info="amount"]').html(amountToShow); 10185 } 10186 10187 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10188 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="form"]').show(); 10189 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal .modal-footer').slideDown(); 10190 } 10191 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal a[data-action="pay"]').unbind('click'); 10192 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal a[data-action="pay"]').on('click', function() { 10193 var error = false;
10194 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal .has-error').removeClass('has-error'); 10195 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal [name="ownerName"]').val().length < 3) { 10196 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal [name="ownerName"]').closest('.form-group').addClass('has-error'); 10197 error = true; 10198 } 10199 if (!error) { 10200 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10201 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="loading"]').show(); 10202 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal .modal-footer').hide(); 10203 10204 lfb_stripe.createPaymentMethod({type: 'card', card: form.cardElement}).then(function(result) { 10205 if (result.error) { 10206 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-info="error"]').html(result.error.message); 10207 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10208 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="fail"]').show(); 10209 } else { 10210 form.stripeSrc = result.paymentMethod.id; 10211 10212 if (subTotal > 0) { 10213 jQuery.ajax({ 10214 url: form.ajaxurl, 10215 type: 'post', 10216 data: { 10217 action: 'lfb_processStripeSubscription', 10218 formID: form.formID, 10219 stripeSrc: form.stripeSrc, 10220 customerID: form.stripeCustomerID, 10221 singleTotal: singleTotal, 10222 subTotal: subTotal 10223 }, 10224 success: function(rep) { 10225 console.log('DEBUG - Raw AJAX response:', rep); 10226 rep = rep.trim(); 10227 console.log('DEBUG - Trimmed response:', rep); 10228 10229 // Vérifier les erreurs Stripe 10230 if (rep.indexOf('stripeError:') > -1) { 10231 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-info="error"]').html(rep.replace('stripeError:', '')); 10232 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10233 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="fail"]').show(); 10234 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal .modal-footer').show(); 10235 return; 10236 } 10237 10238 if (rep == 1) { 10239 10240 if (singleTotal > 0) { 10241 lfb_stripe.handleCardPayment( 10242 form.stripeToken, form.cardElement, { 10243 payment_method_data: { 10244 billing_details: { name: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal [name="ownerName"]').val() } 10245 } 10246 } 10247 ).then(function(result) { 10248 if (result.error) { 10249 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-info="error"]').html(result.error); 10250 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10251 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="fail"]').show(); 10252 } else { 10253 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('hide'); 10254 form.stripePaid = true; 10255 lfb_order(form.formID); 10256 } 10257 }); 10258 } else { 10259 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('hide'); 10260 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('hide'); 10261 form.stripePaid = true; 10262 lfb_order(form.formID); 10263 } 10264 10265 } else if (rep.indexOf('pi_') > -1) { 10266 console.log('DEBUG - rep value:', rep); 10267 console.log('DEBUG - stripeSrc value:', form.stripeSrc); 10268 lfb_stripe.confirmCardPayment(rep, { 10269 payment_method: form.stripeSrc 10270 }).then(function(result) { 10271 if (result.error) { 10272 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-info="error"]').html(result.error.message); 10273 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10274 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="fail"]').show(); 10275 } else { 10276 if (singleTotal > 0) { 10277 lfb_stripe.handleCardPayment( 10278 form.stripeToken, form.cardElement, { 10279 payment_method_data: { 10280 billing_details: { name: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal [name="ownerName"]').val() } 10281 } 10282 } 10283 ).then(function(result) { 10284 if (result.error) { 10285 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-info="error"]').html(result.error); 10286 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10287 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="fail"]').show(); 10288 } else { 10289 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('hide'); 10290 10291 form.stripePaid = true; 10292 lfb_order(form.formID); 10293 } 10294 }); 10295 } else { 10296 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('hide'); 10297 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('hide'); 10298 form.stripePaid = true; 10299 lfb_order(form.formID); 10300 } 10301 } 10302 10303 }); 10304 } 10305 } 10306 }); 10307 } else { 10308 lfb_stripe.handleCardPayment( 10309 form.stripeToken, form.cardElement, { 10310 payment_method_data: { 10311 billing_details: { name: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_stripeModal [name="ownerName"]').val() } 10312 } 10313 } 10314 ).then(function(result) { 10315 if (result.error) { 10316 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] [data-info="error"]').html(result.error); 10317 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel]').hide(); 10318 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal [data-panel="fail"]').show(); 10319 } else { 10320 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('hide'); 10321 form.stripePaid = true; 10322 lfb_order(form.formID); 10323 } 10324 }); 10325 } 10326 10327 10328 } 10329 }); 10330 10331 10332 } 10333 }); 10334 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').find('#lfb_stripeModal').modal('show'); 10335 } 10336 }); 10337 10338 } 10339 } 10340 10341 function lfb_checkCaptcha(form, callback) { 10342 if (form.useCaptcha == 1 && form.recaptcha3Key != '') { 10343 grecaptcha.ready(function() { 10344 grecaptcha.execute(form.recaptcha3Key, { action: 'sending_form' }).then(function(token) { 10345 form.captcha = token; 10346 callback(form); 10347 }).catch(function(error) { 10348 console.log("Erreur lors de l'exécution de reCAPTCHA: ", error); 10349 callback(form); 10350 }); 10351 }); 10352 } else { 10353 callback(form); 10354 } 10355 } 10356
10357 function lfb_updateVariable(form, variableID, calculation, targetID) { 10358 for (var i = 0; i < form.variables.length; i++) { 10359 if (form.variables[i].id == variableID) { 10360 var variable = form.variables[i]; 10361 variable.value = lfb_executeCalculation(calculation, form.formID, targetID); 10362 if (variable.type == 'integer') { 10363 variable.value = Math.round(variable.value); 10364 } else if (variable.type == 'float') { 10365 variable.value = variable.value; 10366 } 10367 break; 10368 } 10369 } 10370 } 10371 10372 function lfb_getVariableByID(form, variableID) { 10373 var rep = false; 10374 for (var i = 0; i < form.variables.length; i++) { 10375 if (form.variables[i].id == variableID) { 10376 rep = form.variables[i]; 10377 break; 10378 } 10379 } 10380 return rep; 10381 } 10382 10383 function lfb_initVerificationCodeModal(form){ 10384 const formID = form.formID; 10385 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_verification-char').on('input', function(){ 10386 if($(this).val().length == 1){ 10387 if($(this).next().length > 0){ 10388 $(this).next().focus(); 10389 } else { 10390 lfb_checkVerificationCode(form); 10391 } 10392 } 10393 }); 10394 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_verification-char').on('keydown', function(e){ 10395 if(e.which == 8){ 10396 $(this).prev().focus(); 10397 } 10398 }); 10399 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').first().on('paste', function(e) { 10400 e.preventDefault(); 10401 var pastedText = (e.originalEvent.clipboardData || window.clipboardData).getData('text'); 10402 var verificationInputs = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char'); 10403 10404 for (var i = 0; i < Math.min(pastedText.length, verificationInputs.length); i++) { 10405 $(verificationInputs[i]).val(pastedText[i]); 10406 } 10407 10408 if (pastedText.length > 0) { 10409 $(verificationInputs[Math.min(pastedText.length, verificationInputs.length) - 1]).focus(); 10410 } 10411 lfb_checkVerificationCode(form); 10412 }); 10413 } 10414 10415 function lfb_checkVerificationCode(form){ 10416 10417 var verificationCode = ''; 10418 10419 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').each(function(){ 10420 verificationCode += $(this).val(); 10421 }); 10422 10423 $.ajax({ 10424 url: form.ajaxurl, 10425 type: 'post', 10426 data: { 10427 action: 'lfb_checkVerificationCode', 10428 formID: form.formID, 10429 code: verificationCode, 10430 email: form.emailProposed 10431 }, 10432 success: function(rep){ 10433 rep = JSON.parse(rep); 10434 if(rep.success){ 10435 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_verificationModal').modal('hide'); 10436 form.verifiedEmail = form.emailProposed; 10437 lfb_nextStep(form.formID); 10438 } else { 10439 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').val(''); 10440 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').first().focus(); 10441 } 10442 } 10443 }); 10444 } 10445 10446 function lfb_checkUserEmail(form) { 10447 var rep = true; 10448 var formID = form.formID; 10449 10450 if (form.verifyEmail == 1 && typeof(form.stripePaid) == 'undefined' && (typeof(form.verifiedEmail) == 'undefined' || !form.verifiedEmail) && $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"]').length > 0) 10451 { 10452 rep = false;
10453 var emailField = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"]').last(); 10454 var targetEmail = emailField.val(); 10455 10456 form.emailProposed = targetEmail; 10457 $.ajax({ 10458 url: form.ajaxurl, 10459 type: 'post', 10460 data: { 10461 action: 'lfb_sendVerificationCode', 10462 formID: formID, 10463 email: targetEmail 10464 }, 10465 success: function(rep){ 10466 rep = JSON.parse(rep); 10467 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal').modal('show'); 10468 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').val(''); 10469 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').first().focus(); 10470 10471 if(rep.success){ 10472 } else { 10473 alert(rep.message); 10474 } 10475 } 10476 }); 10477 10478 } 10479 10480 /* if (form.enableCustomerAccount == 1 && typeof(form.stripePaid) == 'undefined' && (typeof(form.verifiedEmail) == 'undefined' || !form.verifiedEmail) && $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"]').length > 0) { 10481 rep = false; 10482 var emailField = $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"]').last(); 10483 10484 if (typeof(form.emailProposed) == 'undefined' || form.emailProposed != emailField.val()) { 10485 form.emailProposed = emailField.val(); 10486 jQuery.ajax({ 10487 url: form.ajaxurl, 10488 type: 'post', 10489 data: { 10490 action: 'lfb_checkEmailCustomer', 10491 formID: form.formID, 10492 email: form.emailProposed 10493 }, 10494 success: function(rep) { 10495 if (rep.trim() == 1) { 10496 if ($('#lfb_customerPasswordField').length == 0) { 10497 var passCt = $('<div id="lfb_forgotPassCt" class="form-group has-error" ></div>'); 10498 passCt.hide(); 10499 passCt.append('<div class="input-group" ><span class="input-group-addon"><span class="fa fa-lock" ></span></span><input type="password" id="lfb_forgotPassField" class="form-control" /></div>'); 10500 passCt.append('<div class="lfb_forgotPassLinkCt"><a href="javascript:" id="lfb_forgotPassLink">' + form.txtCustomersDataForgotPassLink + '</a></div>'); 10501 10502 emailField.closest('.form-group').after(passCt); 10503 $('#lfb_forgotPassLink').on('click', function() { 10504 if (lfb_checkEmail(emailField.val())) { 10505 emailField.attr('disabled', 'disabled'); 10506 jQuery.ajax({ 10507 url: form.ajaxurl, 10508 type: 'post', 10509 data: { 10510 action: 'lfb_forgotPassManD', 10511 email: form.emailProposed 10512 }, 10513 success: function(rep) { 10514 $('#lfb_passModal').modal('show'); 10515 } 10516 }); 10517 } 10518 }); 10519 $('#lfb_form[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').slideDown(); 10520 10521 if (form.disableScroll != 1) { 10522 setTimeout(function() { 10523 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen')) { 10524 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 10525 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10526 }, form.animationsSpeed * 2); 10527 } else { 10528 $('body,html').animate({ 10529 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10530 }, form.animationsSpeed * 2); 10531 } 10532 10533 }, 350); 10534 } 10535 10536 } else { 10537 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassField').val(''); 10538 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassField').closest('.form-group').addClass('has-error'); 10539 10540 if (form.disableScroll != 1) { 10541 setTimeout(function() { 10542 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen')) { 10543 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 10544 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10545 }, form.animationsSpeed * 2); 10546 } else { 10547 $('body,html').animate({ 10548 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10549 }, form.animationsSpeed * 2); 10550 } 10551 10552 }, 350); 10553 } 10554 10555 } 10556 } else { 10557 form.verifiedEmail = form.emailProposed; 10558 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').removeClass('lfb_open').slide
10558Up(); 10559 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"]').last().attr('disabled', 'disabled'); 10560 if (form.step == 'final') { 10561 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_paymentMethodBtns').length == 0) { 10562 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_btnNextContainer').css('display') != 'none') { 10563 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_btnOrder').trigger('click'); 10564 } else { 10565 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_btnOrderPaypal, #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_btnPayStripe,#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #btnOrderRazorpay').trigger('click'); 10566 } 10567 } 10568 } else { 10569 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_btn-next').trigger('click'); 10570 } 10571 } 10572 } 10573 }); 10574 10575 } else if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassField').length > 0) { 10576 var pass = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassField').val(); 10577 if (pass.length > 3) { 10578 jQuery.ajax({ 10579 url: form.ajaxurl, 10580 type: 'post', 10581 data: { 10582 action: 'lfb_verificationPass', 10583 formID: formID, 10584 pass: pass 10585 }, 10586 success: function(rep) { 10587 if (rep.trim() == 1) { 10588 form.verifiedEmail = form.emailProposed; 10589 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').removeClass('lfb_open').slideUp(); 10590 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"]').last().attr('disabled', 'disabled'); 10591 if (form.step == 'final') { 10592 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_paymentMethodBtns').length == 0) { 10593 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_btnNextContainer').css('display') != 'none') { 10594 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_btnOrder').trigger('click'); 10595 } else { 10596 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_btnOrderPaypal, #lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_btnPayStripe,#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #btnOrderRazorpay').trigger('click'); 10597 } 10598 } 10599 } else { 10600 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] .lfb_btn-next').trigger('click'); 10601 } 10602 } else { 10603 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassField').closest('.form-group').addClass('has-error'); 10604 10605 if (form.disableScroll != 1) { 10606 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen')) { 10607 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 10608 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10609 }, form.animationsSpeed * 2); 10610 } else { 10611 $('body,html').animate({ 10612 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10613 }, form.animationsSpeed * 2); 10614 } 10615 } 10616 } 10617 } 10618 }); 10619 } else { 10620 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').addClass('has-error'); 10621 10622 if (form.disableScroll != 1) { 10623 setTimeout(function() { 10624 if ($('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').is('.lfb_fullscreen')) { 10625 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"]').animate({ 10626 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10627 }, form.animationsSpeed * 2); 10628 } else { 10629 $('body,html').animate({ 10630 scrollTop: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] .lfb_genSlide[data-stepid="' + form.step + '"] #lfb_forgotPassCt').offset().top - (120 + parseInt(lfb_getScrollTopMargin(form))) 10631 }, form.animationsSpeed * 2); 10632 } 10633 10634 }, 350); 10635 } 10636 10637 } 10638 10639 } 10640 } 10641 10642 10643 if(rep && form.enableCustomerAccount == 0 && (typeof(form.verifiedEmail) == 'undefined' || !form.verifiedEmail)){ 10644 if($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"][data-cid="1"]').length > 0){ 10645 10646 const targetEmail = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide[data-stepid="' + form.step + '"] [data-fieldtype="email"][data-required="true"][data-cid="1"]').val(); 10647 if(targetEmail.length > 0){ 10648 if(lfb_checkEmail(targetEmail)){ 10649 rep = false;
10650 form.emailProposed = targetEmail; 10651 $.ajax({ 10652 url: form.ajaxurl, 10653 type: 'post', 10654 data: { 10655 action: 'lfb_sendVerificationCode', 10656 formID: formID, 10657 email: targetEmail 10658 }, 10659 success: function(rep){ 10660 rep = JSON.parse(rep); 10661 if(rep.success){ 10662 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal').modal('show'); 10663 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').val(''); 10664 $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_verificationModal .lfb_verification-code-inputs .lfb_verification-char').first().focus(); 10665 } else { 10666 console.log(rep); 10667 } 10668 } 10669 }); 10670 } 10671 10672 10673 } 10674 } 10675 }*/ 10676 10677 return rep; 10678 } 10679 10680 10681 function lfb_decodeCalculation(value) { 10682 var chars = new Array(); 10683 chars[0] = 9; 10684 chars[1] = 3; 10685 chars[2] = 5; 10686 chars[3] = 8; 10687 chars[4] = 2; 10688 chars[5] = 6; 10689 chars[6] = 4; 10690 chars[7] = 1; 10691 chars[8] = 0; 10692 chars[9] = 7; 10693 10694 var result = ""; 10695 for (var i = 0; i < value.length; i++) { 10696 if (chars.indexOf(parseInt(value[i])) > -1) { 10697 result += chars[parseInt(value[i])]; 10698 } else { 10699 result += value[i]; 10700 } 10701 } 10702 return result; 10703 } 10704 10705 function lfb_downloadAsPDF(formID) { 10706 var form = lfb_getForm(formID); 10707 var $summaryClone = lfb_cloneSummary(false, formID); 10708 var summaryData = $summaryClone.html(); 10709 $summaryClone.remove(); 10710 10711 10712 var contentForm = lfb_getFormContent(formID); 10713 var content = contentForm[0]; 10714 content = content.replace(/<br\/>/g, '[n]'); 10715 var totalTxt = contentForm[1]; 10716 var items = contentForm[2]; 10717 10718 var infosCt = lfb_getContactInformations(formID); 10719 email = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] .emailField').val(); 10720 if (lfb_checkEmail(infosCt['email'])) { 10721 email = infosCt['email']; 10722 } 10723 10724 var informations = ''; 10725 $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #finalSlide').find('.lfb_item input:not([type="checkbox"])[data-itemid],.lfb_item textarea[data-itemid],.lfb_item select[data-itemid]').each(function() { 10726 if ($(this).closest('#lfb_paypalForm').length == 0) { 10727 if ($(this).is('.lfb_disabled')) {} else { 10728 if ($(this).is('#lfb_couponField')) {} else if ($(this).is('#lfb_captchaField')) {} else { 10729 var dbpoints = ':'; 10730 if ($(this).closest('.lfb_item').find('label').html().lastIndexOf(':') == $(this).closest('.lfb_item').find('label').html().length - 1) { 10731 dbpoints = ''; 10732 } 10733 if ($('body').is('.rtl')) { 10734 informations += '<p><b><span class="lfb_value">' + $(this).val() + '</span></b>' + dbpoints + ' ' + $(this).closest('.lfb_item').find('label').html() + '</p>'; 10735 } else { 10736 informations += '<p>' + $(this).closest('.lfb_item').find('label').html() + ' ' + dbpoints + ' <b><span class="lfb_value">' + $(this).val() + '</span></b></p>'; 10737 } 10738 10739 } 10740 } 10741 } 10742 }); 10743 10744 jQuery.ajax({ 10745 url: form.ajaxurl, 10746 type: 'post', 10747 data: { 10748 action: 'lfb_downloadOrderPDF', 10749 formID: form.formID, 10750 informations: informations, 10751 email: email, 10752 customerInfos: lfb_getContactInformations(form.formID, true), 10753 summary: summaryData, 10754 totalTxt: totalTxt, 10755 formSession: $('#lfb_form.lfb_bootstraped[data-form="' + form.formID + '"] #lfb_formSession').val(), 10756 items: items, 10757 useRtl: $('body').is('.rtl'), 10758 variables: JSON.stringify(form.variables) 10759 }, 10760 success: function(rep) { 10761 10762 var win = window.open(form.homeUrl + '/index.php?EPFormsBuilder=downloadMyOrder', '_blank'); 10763 if (typeof(win) !== 'null' && win != null) { 10764 win.focus(); 10765 setTimeout(function() { 10766 win.close(); 10767 }, 300); 10768 } 10769 } 10770 }); 10771 } 10772 10773 function lfb_updateVAT(formID) { 10774 var form = lfb_getForm(formID); 10775 form.vatPrice = 0; 10776 if (form.useVAT == 1) { 10777 if (form.singlePrice > 0) { 10778 form.vatPrice = (form.singlePrice * form.vatAmount) / 100; 10779 form.singlePrice = form.singlePrice + form.vatPrice; 10780 } else { 10781 form.vatPrice = (form.price * form.vatAmount) / 100; 10782 form.price = form.price + form.vatPrice; 10783 } 10784 10785 } 10786 } 10787 10788 function lfb_updateGmapItinerary($mapItem, formID) { 10789 var itinerary = $mapItem.attr('data-itinerary'); 10790 var directionRenderer = $mapItem.data('directionRenderer'); 10791 var map = $mapItem.data('gmap'); 10792 var init = false;
10793 if (!$mapItem.is('.lfb_gmapInit')) { 10794 init = true; 10795 $mapItem.addClass('lfb_gmapInit'); 10796 } 10797 10798 var i = 1; 10799 var departAdPosEnd = itinerary.indexOf('-', i + 9) + 1; 10800 var departAdress = itinerary.substr(i + 9, itinerary.indexOf('-', i) - (i + 9)); 10801 10802 var departCityPosEnd = itinerary.indexOf('-', departAdPosEnd) + 1; 10803 var departCity = itinerary.substr(departAdPosEnd, itinerary.indexOf('-', departAdPosEnd) - (departAdPosEnd)); 10804 10805 var departZipPosEnd = itinerary.indexOf('-', departCityPosEnd) + 1; 10806 var departZip = itinerary.substr(departCityPosEnd, itinerary.indexOf('-', departCityPosEnd) - (departCityPosEnd)); 10807 10808 var departCountryPosEnd = itinerary.indexOf('_', departZipPosEnd) + 1; 10809 var departCountry = itinerary.substr(departZipPosEnd, itinerary.indexOf('_', departZipPosEnd) - (departZipPosEnd)); 10810 10811 var arrivalAdPosEnd = itinerary.indexOf('-', departCountryPosEnd) + 1; 10812 var arrivalAdress = itinerary.substr(departCountryPosEnd, itinerary.indexOf('-', departCountryPosEnd) - (departCountryPosEnd)); 10813 10814 var arrivalCityPosEnd = itinerary.indexOf('-', arrivalAdPosEnd) + 1; 10815 var arrivalCity = itinerary.substr(arrivalAdPosEnd, itinerary.indexOf('-', arrivalAdPosEnd) - (arrivalAdPosEnd)); 10816 10817 var arrivalZipPosEnd = itinerary.indexOf('-', arrivalCityPosEnd) + 1; 10818 var arrivalZip = itinerary.substr(arrivalCityPosEnd, itinerary.indexOf('-', arrivalCityPosEnd) - (arrivalCityPosEnd)); 10819 10820 var arrivalCountryPosEnd = itinerary.indexOf('_', arrivalZipPosEnd) + 1; 10821 var arrivalCountry = itinerary.substr(arrivalZipPosEnd, itinerary.indexOf('_', arrivalZipPosEnd) - (arrivalZipPosEnd)
10821); 10822 10823 if (departAdress != "") { 10824 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departAdress + '"]').length > 0) { 10825 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departAdress + '"]'); 10826 departAdress = $item.val(); 10827 if (init) { 10828 $item.on('focusout change', function() { 10829 lfb_updateGmapItinerary($mapItem, formID); 10830 }); 10831 } 10832 } else { 10833 departAdress = 0; 10834 } 10835 } 10836 if (departCity != "") { 10837 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCity + '"]').length > 0) { 10838 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCity + '"]'); 10839 departCity = $item.val(); 10840 if (init) { 10841 $item.on('focusout change', function() { 10842 lfb_updateGmapItinerary($mapItem, formID); 10843 }); 10844 } 10845 } else { 10846 departCity = 0; 10847 } 10848 } 10849 if (departZip != "") { 10850 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departZip + '"]').length > 0) { 10851 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departZip + '"]'); 10852 departZip = $item.val(); 10853 if (init) { 10854 $item.on('focusout change', function() { 10855 lfb_updateGmapItinerary($mapItem, formID); 10856 }); 10857 } 10858 } else { 10859 departZip = 0; 10860 } 10861 } 10862 if (departCountry != "") { 10863 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCountry + '"]').length > 0) { 10864 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + departCountry + '"]'); 10865 departCountry = $item.val(); 10866 if (init) { 10867 $item.on('focusout change', function() { 10868 lfb_updateGmapItinerary($mapItem, formID); 10869 }); 10870 } 10871 } else { 10872 departCountry = 0; 10873 } 10874 } 10875 if (arrivalAdress != "") { 10876 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalAdress + '"]').length > 0) { 10877 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalAdress + '"]'); 10878 arrivalAdress = $item.val(); 10879 if (init) { 10880 $item.on('focusout change', function() { 10881 lfb_updateGmapItinerary($mapItem, formID); 10882 }); 10883 } 10884 } else { 10885 arrivalAdress = 0; 10886 } 10887 } 10888 if (arrivalCity != "") { 10889 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCity + '"]').length > 0) { 10890 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCity + '"]'); 10891 arrivalCity = $item.val(); 10892 if (init) { 10893 $item.on('focusout change', function() { 10894 lfb_updateGmapItinerary($mapItem, formID); 10895 }); 10896 } 10897 } else { 10898 arrivalCity = 0; 10899 } 10900 } 10901 if (arrivalZip != "") { 10902 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalZip + '"]').length > 0) { 10903 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalZip + '"]'); 10904 arrivalZip = $item.val(); 10905 if (init) { 10906 $item.on('focusout change', function() { 10907 lfb_updateGmapItinerary($mapItem, formID); 10908 }); 10909 } 10910 } else { 10911 arrivalZip = 0; 10912 } 10913 } 10914 if (arrivalCountry != "") { 10915 if ($('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCountry + '"]').length > 0) { 10916 var $item = $('#lfb_form.lfb_bootstraped[data-form="' + formID + '"] #lfb_mainPanel .lfb_genSlide [data-itemid="' + arrivalCountry + '"]'); 10917 arrivalCountry = $item.val(); 10918 if (init) { 10919 $item.on('focusout change', function() { 10920 lfb_updateGmapItinerary($mapItem, formID); 10921 }); 10922 } 10923 } else { 10924 arrivalCountry = 0; 10925 } 10926 } 10927 var depart = departAdress + ' ' + departZip + ' ' + departCity + ' ' + departCountry; 10928 var arrival = arrivalAdress + ' ' + arrivalZip + ' ' + arrivalCity + ' ' + arrivalCountry; 10929 10930 if (depart.replaceAll(' ', '').length > 2 && arrival.replaceAll(' ', '').length > 2) { 10931 10932 new google.maps.DirectionsService().route({ 10933 origin: { 10934 query: depart, 10935 }, 10936 destination: { 10937 query: arrival, 10938 }, 10939 travelMode: google.maps.TravelMode.DRIVING, 10940 }, 10941 (response, status) => { 10942 if (status === "OK") { 10943 directionRenderer.setDirections(response); 10944 10945 } 10946 } 10947 ); 10948 } 10949 } 10950 10951 function lfb_getMapStyle(mapStyle) { 10952 var rep = lfb_mapStyles[0]; 10953 for (var i = 0; i < lfb_mapStyles.length; i++) { 10954 if (lfb_mapStyles[i].name == mapStyle) { 10955 rep = lfb_mapStyles[i].styles; 10956 break; 10957 } 10958 } 10959 return rep; 10960 } 10961 10962 function lfb_getScrollTopMargin(form) { 10963 if ($(window).width() <= 480) { 10964 return form.scrollTopMarginMobile; 10965 } else { 10966 return form.scrollTopMargin; 10967 } 10968 } 10969 10970})(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.