1(function ($) { 2 function DonationPopUpHandler() { 3 let checkRTL = false; 4 if ($('body.rtl').length) { 5 checkRTL = true; 6 } 7 if($(window).width() < 1024){ 8 $('.bottom .want-to-contribute').remove() 9 } 10 // stop form on enter 11 $(document).on('keypress keydown keyup', '.step-2 form', function (e) { 12 if (e.which == 13) { 13 e.preventDefault(); 14 } 15 }); 16 /* Close popup btn */ 17 // $('.donation-pop-up .top .close').on('click keypress', function (e) { 18 // if (e.type === 'click' || (e.type === 'keypress' && e.which === 13)) { 19 // $('a.dialog-close-button.dialog-lightbox-close-button')[0].click(); 20 // } 21 // }); 22 function collectUTMs() { 23 const sp = new URLSearchParams(window.location.search); 24 const keys = ['utm_source','utm_medium','utm_campaign','utm_term','utm_content']; 25 const utm = {}; 26 keys.forEach(k => { 27 const v = sp.get(k); 28 if (v) utm[k] = v; 29 }); 30 return utm; 31 } 32 33 function isIsraelReceipt() { 34 return $('.form-content .receipt .item.active').attr('data') === 'Israel'; 35 } 36 37 function normalizeIsraeliId(value) { 38 return String(value || '').replace(/\D/g, ''); 39 } 40 41 function isValidIsraeliId(value) { 42 const id = normalizeIsraeliId(value); 43 44 // Israeli ID must be exactly 9 digits. 45 // User must type leading zeros manually. 46 if (!/^\d{9}$/.test(id)) { 47 return false; 48 } 49 50 // Prevent fake all-zero ID. 51 if (id === '000000000') { 52 return false; 53 } 54 55 let sum = 0; 56 57 for (let i = 0; i < 9; i++) { 58 let num = Number(id.charAt(i)) * ((i % 2) + 1); 59 60 if (num > 9) { 61 num -= 9; 62 } 63 64 sum += num; 65 } 66 67 return sum % 10 === 0; 68 } 69 70 function getDonorIdValue() { 71 return $('.donation-pop-up input[name="donor-id"]').val() || ''; 72 } 73 74 function showDonorIdError(message) { 75 const $input = $('.donation-pop-up input[name="donor-id"]'); 76 const $wrapper = $input.closest('.wpcf7-form-control-wrap'); 77 const $box = $input.closest('.id-box-wrapper'); 78 79 $wrapper.addClass('error-item').removeClass('valid-item'); 80 $input.addClass('wpcf7-not-valid').attr('aria-invalid', 'true'); 81 82 $box.find('.id-error-msg').text(message).show(); 83 } 84 85 function clearDonorIdError() { 86 const $input = $('.donation-pop-up input[name="donor-id"]'); 87 const $wrapper = $input.closest('.wpcf7-form-control-wrap'); 88 const $box = $input.closest('.id-box-wrapper'); 89 90 $wrapper.removeClass('error-item valid-item'); 91 $input.removeClass('wpcf7-not-valid').attr('aria-invalid', 'false'); 92 93 $box.find('.id-error-msg').hide(); 94 } 95 96 function markDonorIdValid() { 97 const $input = $('.donation-pop-up input[name="donor-id"]'); 98 const $wrapper = $input.closest('.wpcf7-form-control-wrap'); 99 const $box = $input.closest('.id-box-wrapper'); 100 101 $wrapper.removeClass('error-item').addClass('valid-item'); 102 $input.removeClass('wpcf7-not-valid').attr('aria-invalid', 'false'); 103 104 $box.find('.id-error-msg').hide(); 105 } 106 107 function validateDonorIdBeforePayment() { 108 const $donorInput = $('.donation-pop-up input[name="donor-id"]'); 109 110 // If donor-id field does not exist in the form, skip this validation. 111 if (!$donorInput.length) { 112 return true; 113 } 114 115 const donorId = normalizeIsraeliId($donorInput.val()); 116 117 // ID is optional now. 118 // If empty â allow user to continue. 119 if (!donorId) { 120 clearDonorIdError(); 121 return true; 122 } 123 124 // If user entered ID for Israel receipt â validate it. 125 if (isIsraelReceipt() && !isValidIsraeliId(donorId)) { 126 showDonorIdError($('body').hasClass('rtl') ? 'תע××ת ×××ת ×× ×ª×§×× ×' : 'Invalid Israeli ID'); 127 return false;
128 } 129 130 $donorInput.val(donorId); 131 markDonorIdValid(); 132 133 return true; 134 } 135 136 function updateDonorIdFieldByReceipt() { 137 const $input = $('.donation-pop-up input[name="donor-id"]'); 138 const $box = $('.donation-pop-up .id-box-wrapper'); 139 const $asterisk = $box.find('.req-asterisk'); 140 141 if (!$input.length) { 142 return; 143 } 144 145 clearDonorIdError(); 146 147 if (isIsraelReceipt()) { 148 $asterisk.hide(); 149 150 $input.attr({ 151 placeholder: $('body').hasClass('rtl') ? 'תע××ת ×××ת' : 'Israeli ID', 152 inputmode: 'numeric', 153 maxlength: '9' 154 }); 155 } else { 156 $asterisk.hide(); 157 158 $input.attr({ 159 placeholder: $('body').hasClass('rtl') ? 'תע××ת ×××ת' : 'Israeli ID', 160 }); 161 162 $input.removeAttr('inputmode maxlength'); 163 } 164 } 165 166 function getSafeFormObject(formObject) { 167 return formObject.filter(function (input) { 168 return input.name !== 'donor-id'; 169 }); 170 } 171 172 $(document).on('input', '.donation-pop-up input[name="donor-id"]', function () { 173 const cleanedValue = normalizeIsraeliId($(this).val()); 174 175 $(this).val(cleanedValue); 176 177 if (!isIsraelReceipt()) { 178 clearDonorIdError(); 179 return; 180 } 181 182 if (cleanedValue.length === 9 && isValidIsraeliId(cleanedValue)) { 183 markDonorIdValid(); 184 } else { 185 const $wrapper = $(this).closest('.wpcf7-form-control-wrap'); 186 const $box = $(this).closest('.id-box-wrapper'); 187 188 $wrapper.removeClass('valid-item'); 189 $box.find('.id-error-msg').hide(); 190 } 191 }); 192 193 $(document).on('click keypress', '.donation-pop-up .top .close', function (e) { 194 e.preventDefault(); 195 console.log('Event triggered:', e.type); 196 if (e.type === 'click' || (e.type === 'keypress' && e.which === 13)) { 197 const closeButton = document.querySelector('.dialog-close-button.dialog-lightbox-close-button'); 198 if (closeButton) { 199 console.log('Close button found, triggering click...'); 200 closeButton.click(); 201 } else { 202 console.error('Close button not found in document.'); 203 } 204 } 205 }); 206 207 // checkbox 208 $('.donation-pop-up .want-to-contribute .checkbox').on('keypress', function (e) { 209 if (e.type === 'click' || (e.type === 'keypress' && e.which === 13)) { 210 $(this).find('input')[0].click(); 211 } 212 }); 213 214 /* The amount of the donation */ 215 $('.form-content .row-item .amounts .item').on('click keypress', function (e) { 216 $('.amounts-title').removeClass('error') 217 if (e.type === 'click' || (e.type === 'keypress' && e.which === 13)) { 218 $('.form-content .row-item .amounts .item').removeClass('active'); 219 let amount = $(this).attr('data'); 220 if ($(this).attr('data') == "other") { 221 amount = $(this).find('input').val(); 222 } 223 $('.donation-amount.text span.amount').text(amount); // add to my contribution 224 $('.total-donation.text span.amount').text(amount); // add to my contribution 225 226 $(this).addClass('active'); 227 228 if ($('.form-content .row-item .type .item.active').attr('data') == 'direct') { 229 $('.form-content .row-item .amounts').parent().removeClass('status-active'); 230 $('.form-content .row-item .type').closest('.row-item').addClass('status-active'); 231 $('.formula.status .amount').text(amount); 232 $('.formula.status .months').text($('.form-content .row-item .time select').val()); 233 let total = amount * $('.form-content .row-item .time select').val(); 234 $('.formula.status .total').text(total); 235 $('.total-donation.text span.amount').text(total); 236 } else { 237 $('.form-content .row-item .amounts').parent().addClass('status-active'); 238 $('.formula.status .amount').text(amount); 239 $('.formula.status .total').text(amount); 240 $('.total-donation.text span.amount').text(amount); 241 } 242 243 // currency type 244 let currency_text = 'âª'; 245 if ($('.row-item .currency .item.selected').length > 0) { 246 if ($('.row-item .currency .item.selected').attr('data') == 'shekel') { 247 currency_text = 'âª'; 248 } else if ($('.row-item .currency .item.selected').attr('data') == 'dollar') { 249 currency_text = '$'; 250 } else { 251 currency_text = '£'; 252 } 253 } else { 254 currency_text = 'âª'; 255 } 256 257 $('.donation-amount.text span.currency-text').text(currency_text); 258 $('.total-donation.text span.currency-text').text(currency_text); 259 // if selected other 260 if ($(this).attr('data') == 'other') { 261 $('.form-content .row-item .amounts .another-amount input').focus(); 262 } 263 } 264 }); 265 266 /* Another amount */ 267 $(".form-content .row-item .amounts .another-amount input").on("input", function () { 268 // Print entered value in a div box 269 let amount = $(this).val(); 270 $('.formula .amount').text(amount); 271 $('.formula.status .months').text($('.form-content .row-item .time select').val()); 272 let total = amount * $('.form-content .row-item .time select').val(); 273 if ($('.form-content .row-item .type .item').attr('data') == 'one-time') { // if one time 274 total = amount; 275 } 276 $('.formula.status .total').text(total); 277 $('.total-donation.text span.amount').text(total); 278 $('.donation-amount.text span.amount').text(amount); 279 }); 280 281 const numericInput = document.getElementById('numeric-input'); 282 283 numericInput.addEventListener('input', function (event) { 284 const value = event.target.value; 285 const sanitizedValue = value.replace(/[.,]/g, ''); 286 287 numericInput.value = sanitizedValue; 288 }); 289 290 $('.form-content .row-item .time select').on('change', function () { 291 time_select() 292 }); 293 function time_select() { 294 let amount = $('.form-content .row-item .amounts .item.active').attr('data'); 295 if ($('.form-content .row-item .amounts .item.active').attr('data') == "other") { 296 amount = $('.form-content .row-item .amounts .item.active input').val(); 297 } 298 let time = $('.form-content .row-item .time select').val(); 299 if(time == '999999'){ 300 $('.my-contribution .total-donation').css('display', 'none'); 301 $('.form-content .status-active .status').css('display', 'none'); 302 } 303 $('.formula.status .amount').text(amount); 304 $('.formula.status .months').text(time); 305 let total = amount * time; 306 $('.formula.status .total').text(total); 307 $('.total-donation.text span.amount').text(total); 308 } 309 $('.select .select-styled').click(function (e) { 310 if(!$(this).hasClass('active')){ 311 $(this).addClass('active').next('ul.select-options').addClass('active'); 312 } else { 313 $(this).removeClass('active').next('ul.select-options').removeClass('active'); 314 } 315 }); 316 317 $('.select-options li').click(function () { 318 319 $('div.select-styled').text($(this).text()).removeClass('active'); 320 $('.select-hidden').val($(this).attr('rel')); 321 time_select(); 322 $(this).parent().find('li.is-selected').removeClass('is-selected'); 323 $(this).parent().find('li[rel="' + $(this).attr('rel') + '"]').addClass('is-selected'); 324 $(this).parent().removeClass('active'); 325 }); 326 // type of payment 327 $('.form-content .row-item .type .item').on('click keypress', function (e) { 328 $('.type-title').removeClass('error') 329 if (e.type === 'click' || (e.type === 'keypress' && e.which === 13)) { 330 $('.form-content .row-item .type .item').removeClass('active'); 331 $(this).addClass('active'); 332 let amount = 0; 333 if ($('.form-content .row-item .amounts .another-amount.active').length > 0) { 334 amount = $('.form-content .row-item .amounts .item.active input').val(); 335 } else { 336 amount = $('.form-content .row-item .amounts .item.active').attr('data'); 337 } 338 if ($('.form-content .row-item .amounts .item.active').length > 0 && $(this).attr('data') == 'one-time') { 339 $('.form-content .row-item .amounts').parent().addClass('status-active'); 340 // total 341 $('.formula.status .total').text(amount); 342 $('.total-donation.text span.amount').text(amount); 343 344 } else { 345 $('.form-content .row-item .amounts').parent().removeClass('status-active'); 346 } 347 if ($(this).attr('data') == 'direct') { 348 $(this).closest('.flex-box').addClass('direct'); 349 } else { 350 $(this).closest('.flex-box').removeClass('direct'); 351 } 352 if ($('.form-content .row-item .amounts .item.active').length > 0 && $(this).attr('data') == 'direct') { 353 $(this).closest('.row-item').addClass('status-active'); 354 // total 355 $('.donation-amount.text span.amount').text(amount); 356 $('.formula .amount').text(amount); 357 let total = amount * $('.form-content .row-item .time select').val(); 358 $('.db-mobile .months').text($('.form-content .row-item .time select').val()); 359 $('.formula.status .total').text(total); 360 $('.total-donation.text span.amount').text(total); 361 } else { 362 $(this).closest('.row-item').removeClass('status-active'); 363 } 364 365 $('.type-of-donation.text span').text($(this).text()); 366 } 367 }); 368 369 $('.form-content .currency .item').click(function () { 370 $('.form-content .currency .item').removeClass('selected'); 371 $(this).addClass('selected'); 372 if ($(this).attr('data') == 'shekel') { 373 $('.currency-text').text('âª') 374 } else if ($(this).attr('data') == 'dollar') { 375 $('.currency-text').text('$') 376 } else { 377 $('.currency-text').text('£') 378 } 379 $('.form-content .amounts').removeClass('shekel'); 380 $('.form-content .amounts').removeClass('dollar'); 381 $('.form-content .amounts').removeClass('pound'); 382 $('.form-content .amounts').addClass($(this).attr('data')); 383 }); 384 385 $('.form-content .receipt .item').on('click keypress', function (e) { 386 if (e.type === 'click' || (e.type === 'keypress' && e.which === 13)) { 387 $('.form-content .receipt .item').removeClass('active'); 388 $(this).addClass('active'); 389 let currency = $(this).attr('data-currency'); 390 console.log(currency) 391 $(".currency .item[data='" + currency + "']").click(); 392 $('.type-of-receipt.text span').text($(this).text()); 393 394 updateDonorIdFieldByReceipt(); 395 396 if($('body').hasClass('rtl')){ 397 if (currency == 'shekel') { // disable currency selection 398 $('.currency .item').removeClass('not-active'); 399 $(".currency .item[data='dollar']").addClass('not-active'); 400 $(".currency .item[data='pound']").addClass('not-active'); 401 } else if (currency == 'dollar') { 402 $('.currency .item').removeClass('not-active'); 403 $(".currency .item[data='shekel']").addClass('not-active'); 404 $(".currency .item[data='pound']").addClass('not-active'); 405 } else { 406 $('.currency .item').removeClass('not-active'); 407 $(".currency .item[data='shekel']").addClass('not-active'); 408 $(".currency .item[data='dollar']").addClass('not-active'); 409 } 410 } else { 411 if (currency == 'dollar') { 412 $('.currency .item').removeClass('not-active'); 413 $(".currency .item[data='shekel']").addClass('not-active'); 414 $(".currency .item[data='pound']").addClass('not-active'); 415 } else if(currency == 'pound') { 416 $('.currency .item').removeClass('not-active'); 417 $(".currency .item[data='shekel']").addClass('not-active'); 418 $(".currency .item[data='dollar']").addClass('not-active'); 419 } else { 420 $('.currency .item').removeClass('not-active'); 421 } 422 } 423 424 } 425 }); 426 427 updateDonorIdFieldByReceipt(); 428 429 /* Select project */ 430 $('.donation-projects .project').click(function () { 431 if ($('.donation-projects .project.active button').length > 0) { 432 let text_not_active = $('.donation-projects .project.active button').attr('data'); 433 $('.donation-projects .project.active button').text(text_not_active); 434 $('.donation-projects .project.active button').removeClass('active'); 435 } 436 $('.donation-projects .project').removeClass('active') 437 $(this).addClass('active'); 438 $(this).find('button').text($(this).find('button').attr('data-active')); 439 // add to form 440 $(".step-2.form-box .wpcf7-form-control-wrap[data-name='project'] input").val($(this).find('.title').text()); 441 442 $(".step-2.form-box .selected-project").addClass('active'); 443 $(".step-3.form-box .selected-project").addClass('active'); 444 $(".step-2.form-box .selected-project .name").text($(this).find('.title').text()); 445 $(".step-3.form-box .selected-project .name").text($(this).find('.title').text()); 446 }); 447 448 function slickify() { 449 // project slider 450 $('.donation-projects .projects').slick({ 451 slidesToShow: 1, 452 slidesToScroll: 1, 453 dots: true, 454 infinite: true, 455 rtl: checkRTL, 456 // autoplay: true, 457 // autoplaySpeed: 3000, 458 centerMode: true, 459 variableWidth: true, 460 responsive: [{ 461 breakpoint: 1024, 462 settings: "unslick" 463 }] 464 }); 465 } 466 467 $(window).resize(function () { 468 slickify(); 469 }); 470 471 // button prev step 472 $('.donation-pop-up .bottom .prev-btn').click(function () { 473 // if user select project 474 $('.scroll-content').scrollTop(0); 475 if ($('.donation-pop-up.current-step-2').length > 0) { 476 $('.step-1-form-content').removeClass('hidden'); 477 $('.donation-pop-up').addClass('current-step-1'); 478 $('.donation-pop-up').removeClass('current-step-2'); 479 $('.donation-projects').removeClass('active'); 480
480 } 481 if ($('.donation-pop-up.current-step-3').length > 0) { 482 $('.donation-pop-up').removeClass('current-step-3'); 483 $('.donation-pop-up').addClass('current-step-2'); 484 } 485 486 //scroll to top 487 setTimeout(() => { 488 console.log($(".dialog-message")) 489 $(".dialog-message").animate({ 490 scrollTop: 0 491 }, 0); 492 $(".dialog-widget-content").animate({ 493 scrollTop: 0 494 }, 0); 495 }, 50); 496 let form = $('.donation-pop-up'); 497 }); 498 // click to previos steps 499 $(document).on('click', '.current-step-2 .steps .step:nth-child(1), .current-step-3 .steps .step:nth-child(1)',function(){ 500 501 $('.step-1-form-content').removeClass('hidden'); 502 $('.donation-pop-up').addClass('current-step-1'); 503 $('.donation-pop-up').removeClass('current-step-2'); 504 $('.donation-pop-up').removeClass('current-step-3'); 505 $('.donation-pop-up').addClass('step-2-passed') 506 $('.donation-projects').removeClass('active'); 507 //scroll to top 508 setTimeout(() => { 509 console.log($(".dialog-message")) 510 $(".dialog-message").animate({ 511 scrollTop: 0 512 }, 0); 513 $(".dialog-widget-content").animate({ 514 scrollTop: 0 515 }, 0); 516 }, 50); 517 }) 518 $(document).on('click', '.step-2-passed .steps .step:nth-child(2), .current-step-3 .steps .step:nth-child(2) ' , function(){ 519 $('.donation-pop-up').removeClass('current-step-1'); 520 $('.donation-pop-up').removeClass('current-step-3'); 521 $('.donation-pop-up').addClass('current-step-2'); 522 //scroll to top 523 setTimeout(() => { 524 console.log($(".dialog-message")) 525 $(".dialog-message").animate({ 526 scrollTop: 0 527 }, 0); 528 $(".dialog-widget-content").animate({ 529 scrollTop: 0 530 }, 0); 531 }, 50); 532 }) 533 $(document).on('click', '.current-step-3 .steps .step:nth-child(2), .current-step-3 .steps .step:nth-child(1)' , function(){ 534 $('.donation-pop-up').addClass('step-3-passed') 535 }) 536 $(document).on('click', '.step-3-passed .steps .step:nth-child(3)' , function(){ 537 $('.donation-pop-up').removeClass('current-step-1'); 538 $('.donation-pop-up').removeClass('current-step-2'); 539 $('.donation-pop-up').addClass('current-step-3'); 540 }) 541 // button next step 542 $('.donation-pop-up .bottom .next-btn').click(function () { 543 //scroll to top 544 let amount = $('.form-content .row-item .amounts .item.active').attr('data'); 545 if(amount === undefined) { 546 amount = ''; 547 } 548 if ($('.form-content .row-item .amounts .item.active').attr('data') == "other") { 549 amount = $('.form-content .row-item .amounts .item.active').find('input').val(); 550 } 551 552 if ( $('.form-content .row-item .type .item.active').length === 0 || !amount ) { 553 if( !amount ){ 554 $('.amounts-title').addClass('error') 555 } 556 if($('.form-content .row-item .type .item.active').length === 0){ 557 $('.type-title').addClass('error') 558 } 559 } else { 560 setTimeout(() => { 561 console.log($(".dialog-message")) 562 $(".dialog-message").animate({ 563 scrollTop: 0 564 }, 0); 565 $(".dialog-widget-content").animate({ 566 scrollTop: 0 567 }, 0); 568 }, 50); 569 $('.scroll-content').scrollTop(0); 570 let form = $('.donation-pop-up'); 571 // step to donation-projects 572 if($('.form-content .row-item .amounts .item.active').length > 0){ 573 $('.amounts-title').removeClass('error') 574 } 575 if($('.form-content .row-item .type .item.active').length > 0){ 576 $('.type-title').removeClass('error') 577 } 578 579 if (form.hasClass('current-step-1') && $('.want-to-contribute input').prop('checked') && !$('.donation-projects').hasClass('active')) { 580 581 if ($('.projects.slick-initialized.slick-slider.slick-dotted').length > 0) { 582 $('.step-1-form-content').addClass('hidden'); 583 $('.donation-projects').addClass('active'); 584 } else { 585 $('.step-1-form-content').addClass('hidden'); 586 $('.donation-projects').addClass('active'); 587 slickify(); 588 } 589 form.addClass('projects-active'); 590 591 return; 592 } 593 // add data to form 594 if (form.hasClass('current-step-1')) { 595 let amount = 0; 596 if ($('.form-content .row-item .amounts .another-amount.active').length > 0) { 597 amount = $('.form-content .row-item .amounts .item.active input').val(); 598 } else { 599 amount = $('.form-content .row-item .amounts .item.active').attr('data'); 600 } 601 // type of payment 602 let payment_type = $('.form-content .row-item .type .item.active').attr('data'); 603 // month count 604 let month_count = $('.form-content .row-item .time select').val(); 605 let _text = 'Monthly Donation'; 606 if (payment_type == 'one-time') { 607 month_count = 1; 608 _text = "One-time donation"; 609 } 610 // type-of-receipt 611 let type_of_receipt = $('.form-content .receipt .item.active').attr('data'); 612 // currency 613 let currency = $('.row-item .currency .item.selected').attr('data'); 614 615 $(".step-2.form-box .wpcf7-form-control-wrap[data-name='amount-of-payment']
615input").val(amount); 616 $(".step-2.form-box .wpcf7-form-control-wrap[data-name='number-of-payments'] input").val(month_count); 617 $(".step-2.form-box .wpcf7-form-control-wrap[data-name='payment-type'] input").val(_text); 618 $(".step-2.form-box .wpcf7-form-control-wrap[data-name='type-of-receipt'] input").val(type_of_receipt); 619 $(".step-2.form-box .wpcf7-form-control-wrap[data-name='currency'] input").val(currency); 620 } 621 // second step 622 if (form.hasClass('current-step-1') && $('.want-to-contribute input').prop('checked') && $('.donation-projects').hasClass('active')) { 623 $('.donation-projects').removeClass('active') 624 $('.donation-pop-up').removeClass('current-step-1'); 625 $('.donation-pop-up').addClass('current-step-2'); 626 form.removeClass('projects-active') 627 return; 628 } 629 630 // second step 631 if (form.hasClass('current-step-1') > 0 && !$('.want-to-contribute input').prop('checked')) { 632 $('.donation-pop-up').removeClass('current-step-1'); 633 $('.donation-pop-up').addClass('current-step-2'); 634 return; 635 } 636 637 //third step 638 if (form.hasClass('current-step-2')) { 639 640 var form_inputs_val = true; 641 $('.contact-form .f-box.validate .wpcf7-validates-as-required').each(function () { 642 if ($(this).attr('name') === 'donor-id') { 643 return; 644 } 645 646 if ($(this).val() == '') { 647 form_inputs_val = false; 648 } 649 }); 650 if (!form_inputs_val) { 651 // simulate form click 652 $('.step-2.form-box .contact-form .wpcf7-submit')[0].click(); 653 } else { 654 if (!validateDonorIdBeforePayment()) { 655 return; 656 } 657 // get donation amount 658 let amount = ""; 659 if ($('.form-content .row-item .amounts .item.active').attr('data') == 'other') { 660 amount = $('.form-content .row-item .amounts .item.active input').val(); 661 } else { 662 amount = $('.form-content .row-item .amounts .item.active').attr('data'); 663 } 664 // type of payment 665 let payment_type = $('.form-content .row-item .type .item.active').attr('data'); 666 // month count 667 let month_count = $('.form-content .row-item .time select').val(); 668 // type of receipt 669 let type_of_receipt = $('.form-content .receipt .item.active').attr('data'); 670 console.log(type_of_receipt) 671 // currency 672 let currency = $('.row-item .currency .item.selected').attr('data'); 673 // user fieds 674 let first_name = $(".donation-pop-up input[name*='first-name']").val(); 675 let last_name = $(".donation-pop-up input[name*='last-name']").val(); 676 let phone = $(".donation-pop-up input[name*='tel']").val(); 677 let email = $(".donation-pop-up input[name*='your-email']").val(); 678 let project = $('.donation-projects .projects .active .title').text(); 679 680 let form_object = $(".donation-pop-up form").serializeArray(); 681 682 // Put the object into storage 683 localStorage.setItem('formObject', JSON.stringify(getSafeFormObject(form_object))); 684 685 form_object.forEach(function(input) { 686 var $inputField = jQuery('#donation_popup_form form [name="' + input.name + '"]'); 687 if ($inputField.length > 0) { 688 $inputField.val(input.value); // УÑÑанавливаем знаÑение 689 } else { 690 console.log('Ðоле Ñ Ð¸Ð¼ÐµÐ½ÐµÐ¼ ' + input.name + ' не найдено'); 691 } 692 }); 693 694 if (type_of_receipt == 'Israel') { 695 let data = { 696 action: 'get_iframe', 697 payment_type: payment_type, 698 amount: amount, 699 month_count: month_count, 700 currency: currency, 701 first_name: first_name, 702 last_name: last_name, 703 phone: phone, 704 donor_id: normalizeIsraeliId(getDonorIdValue()), 705 email: email, 706 form_object: getSafeFormObject(form_object), 707 project: project, 708 security: ajax_object.nonce, 709 utm: collectUTMs() // <-- ÐÐÐÐÐ: пÑокидÑваем UTM 710 }; 711 712 $.ajax({ 713 url: ajax_object.ajaxurl, 714 type: 'POST', 715 dataType: 'json', 716 data: { 717 action: 'get_fresh_donation_nonce' 718 }, 719 success: function (nonceResponse) { 720 721 if ( 722 !nonceResponse || 723 nonceResponse.success !== true || 724 !nonceResponse.data || 725 !nonceResponse.data.nonce 726 ) { 727 console.error('Failed to get fresh donation nonce'); 728 alert('Unable to start payment. Please try again.'); 729 return; 730 } 731 732 // Replace the stale nonce from the cached page 733 data.security = nonceResponse.data.nonce; 734 735 $.ajax({ 736 url: ajax_object.ajaxurl, 737 data: data, 738 type: 'POST', 739 740 success: function (result) { 741
742 // Do not advance to payment if no Cardcom iframe was returned 743 if ( 744 !result || 745 typeof result !== 'string' || 746 result.indexOf('iframe') === -1 747 ) { 748 console.error('Invalid payment iframe response'); 749 alert('Unable to load the payment form. Please try again.'); 750 return; 751 } 752 753 $('.step-3 .payment-box .content-box').empty(); 754 $('.step-3 .payment-box .content-box').append(result); 755 756 $('.donation-pop-up') 757 .removeClass('current-step-2') 758 .addClass('current-step-3'); 759 }, 760 761 error: function (xhr) { 762 console.error('Payment iframe request failed', xhr.status); 763 alert('Unable to load the payment form. Please try again.'); 764 } 765 }); 766 }, 767 768 error: function (xhr) { 769 console.error('Fresh nonce request failed', xhr.status); 770 alert('Unable to start payment. Please try again.'); 771 } 772 }); 773 } 774 else if (type_of_receipt == 'England' || type_of_receipt == 'United-States') { 775 776 var recurring = false; 777 if (payment_type == 'direct') { 778 recurring = true; 779 } 780 781 var address = $('.contact-form .f-box input[name=street]').val(); 782 var addressLine2 = $('.contact-form .f-box input[name=house-number]').val(); 783 var zipCode = $('.contact-form .f-box input[name=postal-code]').val(); 784 var city = $('.contact-form .f-box input[name=city]').val(); 785 786 // creating src 787 var src = ''; 788 var currency_g = ''; 789 if (type_of_receipt == 'England') { 790 src = "https://donorbox.org/embed/manna-uk-2"; 791 currency_g = 'GBP'; 792 } else { 793 src = "https://donorbox.org/embed/american-friends-of-meir-panim"; 794 currency_g = 'USD'; 795 } 796 var newSrc = src + 797 "?amount=" + encodeURIComponent(amount) + 798 "&recurring=" + encodeURIComponent(recurring) + 799 "&first_name=" + encodeURIComponent(first_name) + 800 "&last_name=" + encodeURIComponent(last_name) + 801 "&email=" + encodeURIComponent(email) + 802 "&phone=" + encodeURIComponent(phone) + 803 "&address=" + encodeURIComponent(address) + 804 "&address_line_2=" + encodeURIComponent(addressLine2) + 805 "&zip_code=" + encodeURIComponent(zipCode) + 806 "&city=" + encodeURIComponent(city); 807 console.log(newSrc); 808 $('.step-3 .payment-box .content-box').empty(); 809 $('.donation-pop-up').removeClass('current-step-2'); 810 $('.donation-pop-up').addClass('current-step-3'); 811 $('.step-3 .payment-box .content-box').append('<iframe src="' + newSrc + '" name="donorbox" allowpaymentrequest="allowpaymentrequest" seamless="seamless" frameborder="0" scrolling="no" height="900px" width="100%" style="max-width: 500px; min-width: 250px; max-height:none!important"></iframe>'); 812 813 814 // Retrieve the active payment type 815 var paymentTypeElement = document.querySelector('.form-content .row-item .type .item.active'); 816 var paymentType = paymentTypeElement.getAttribute('data'); 817 818 // Map the payment type to the corresponding item name 819 var paymentTypeMapping = { 820 "one-time": "One-time Payment", 821 "direct": "Subscription" 822 }; 823 var itemName = paymentTypeMapping[paymentType]; 824 825 } 826 } 827 return; 828 } 829 } 830 }); 831 832 // paypal save new payment 833 $(document).on('click', 'a.paypal-btn', function (e) { 834 e.preventDefault(); 835 let pp_link = $(this).attr('href'); 836 // get donation amount 837 let amount = ""; 838 if ($('.form-content .row-item .amounts .item.active').attr('data') == 'other') { 839 amount = $('.form-content .row-item .amounts .item.active input').val(); 840 } else { 841 amount = $('.form-content .row-item .amounts .item.active').attr('data'); 842 } 843 // type of payment 844 let payment_type = $('.form-content .row-item .type .item.active').attr('data'); 845 // month count 846 let month_count = $('.form-content .row-item .time select').val(); 847 // currency 848 let currency = $('.row-item .currency .item.selected').attr('data'); 849 // user fieds 850 let first_name = $(".donation-pop-up input[name*='first-name']").val(); 851 let last_name = $(".donation-pop-up input[name*='last-name']").val(); 852 let phone = $(".donation-pop-up input[name*='tel']").val(); 853 let email = $(".donation-pop-up input[name*='your-email']").val(); 854 let project = $('.donation-projects .projects .active .title').text(); 855 856 let form_object = $(".donation-pop-up form").serializeArray(); 857 let safe_form_object = getSafeFormObject(form_object); 858 859 let data = { 860 'action': 'new_paypal_payment', 861 'payment_type': payment_type, 862 'amount': amount, 863 'month_count': month_count, 864 'currency': currency, 865 'first_name': first_name, 866 'last_name': last_name, 867 'phone': phone, 868 'email': email, 869 'form_object': safe_form_object, 870 'project': project, 871 'security': ajax_object.nonce, 872 'utm': collectUTMs() 873 }; 874 875 $.ajax({ 876 url: ajax_object.ajaxurl, // AJAX handler 877 data: data, 878 type: 'POST', 879 beforeSend: function (xhr) {}, 880 success: function (result) { 881 window.location.href = pp_link; 882 } 883 }); 884 }); 885 886 // custom form validation 887 $(".contact-form form").validate({ 888 highlight: function (element, errorClass, validClass) { 889 $(element) 890 .parents(".wpcf7-form-control-wrap") 891 .addClass("error-item")
892 .removeClass("valid-item"); 893 }, 894 895 unhighlight: function (element, errorClass, validClass) { 896 setTimeout(function () { 897 const $element = $(element); 898 const $wrap = $element.parents(".wpcf7-form-control-wrap"); 899 900 if ($element.attr('name') === 'donor-id') { 901 const donorId = normalizeIsraeliId($element.val()); 902 903 if ( 904 isIsraelReceipt() && 905 donorId.length === 9 && 906 isValidIsraeliId(donorId) 907 ) { 908 markDonorIdValid(); 909 } else { 910 $wrap.removeClass("valid-item error-item"); 911 $element.removeClass('wpcf7-not-valid').attr('aria-invalid', 'false'); 912 $element.closest('.id-box-wrapper').find('.id-error-msg').hide(); 913 } 914 915 return; 916 } 917 918 var valid = $element.hasClass('wpcf7-not-valid'); 919 920 if (valid) { 921 $wrap.removeClass("valid-item"); 922 } else { 923 $wrap.addClass("valid-item").removeClass("error-item"); 924 } 925 }, 700); 926 } 927 }); 928 929 document.addEventListener('wpcf7invalid', function (event) { 930 setTimeout(function () { 931 $('.wpcf7-form-control').each(function () { 932 var parent = $(this).parents('.wpcf7-form-control-wrap'); 933 934 if ($(this).hasClass('wpcf7-not-valid') && $(this).hasClass('wpcf7-validates-as-required')) { 935 parent.removeClass("valid-item"); 936 } 937 }); 938 }, 100); 939 }, false); 940 941 // bit ajax 942 $(document).on('click', 'a.meshulam-btn', function (e) { 943 e.preventDefault(); 944 // user fieds 945 var psp = "Bit - meshulam"; 946 if($(this).hasClass('google-btn')){ 947 psp = "Google Pay - meshulam"; 948 } 949 $("#donation_popup_form form .wpcf7-form-control-wrap[data-name='PSP'] input").val(psp); 950 $('#donation_popup_form form .wpcf7-submit')[0].click(); 951 952 let first_name = $(".donation-pop-up input[name*='first-name']").val(); 953 let last_name = $(".donation-pop-up input[name*='last-name']").val(); 954 let phone = $(".donation-pop-up input[name*='tel']").val(); 955 let email = $(".donation-pop-up input[name*='your-email']").val(); 956 let project = $('.donation-projects .projects .active .title').text(); 957 let amount = ""; 958 if ($('.form-content .row-item .amounts .item.active').attr('data') == 'other') { 959 amount = $('.form-content .row-item .amounts .item.active input').val(); 960 } else { 961 amount = $('.form-content .row-item .amounts .item.active').attr('data'); 962 } 963 let pageCodeType = $(this).attr('data'); 964 965 let data = { 966 'action': 'meshulam_iframe', 967 'amount': amount, 968 'first_name': first_name, 969 'last_name': last_name, 970 'phone': phone, 971 'email': email, 972 'project': project, 973 'pageCodeType': pageCodeType, 974 'security': ajax_object.nonce, 975 'utm': collectUTMs() 976 }; 977 978 $.ajax({ 979 url: ajax_object.ajaxurl, // AJAX handler 980 data: data, 981 type: 'POST', 982 beforeSend: function (xhr) { 983 $('.payment-box').addClass('active'); 984 $('.payment-box').append('<div class="lds-ellipsis"><div></div><div></div><div></div><div></div></div>') 985 }, 986 success: function (response) { 987 $('iframe#meshulam').remove(); 988 $('.payment-box').removeClass('active'); 989 $('.lds-ellipsis').remove(); 990 var responseData = JSON.parse(response); 991 console.log(responseData.status) 992 if (responseData.status === 1) { 993 var url = responseData.data.url; 994 $('.payment-box .buttons-wrapper').after('<iframe src="' + url + '" id="meshulam" allow="payment" width="100%" height="576"/>'); 995 } else { 996 997 $('.payment-box .buttons-wrapper').after('<p class="error">' + responseData.err.message + '</p>'); 998 } 999 }, 1000 error: function (xhr, status, error) { 1001 alert('AJAX Error: ' + error); 1002 } 1003 }); 1004 }); 1005 } 1006 $(window).on("elementor/frontend/init", function () { 1007 elementorFrontend.hooks.addAction( 1008 "frontend/element_ready/donation-pop-up.default", 1009 DonationPopUpHandler 1010 ); 1011 }); 1012 1013 $('.select select').each(function () { 1014 var $this = $(this), 1015 numberOfOptions = $(this).children('option').length; 1016 1017 $this.addClass('select-hidden'); 1018 $this.wrap('<div class="select-wraper"></div>'); 1019 $this.after('<div class="select-styled"></div>'); 1020 1021 var $styledSelect = $this.next('div.select-styled'); 1022 $styledSelect.text($this.children('option').eq(0).text()); 1023 1024 var $list = $('<ul />', { 1025 'class': 'select-options' 1026 }).insertAfter($styledSelect); 1027 1028 for (var i = 0; i < numberOfOptions; i++) { 1029 $('<li />', { 1030 text: $this.children('option').eq(i).text(), 1031 rel: $this.children('option').eq(i).val() 1032 }).appendTo($list); 1033 if ($this.children('option').eq(i).is(':selected')) { 1034 $('li[rel="' + $this.children('option').eq(i).val() + '"]').addClass('is-selected') 1035 } 1036 } 1037 }); 1038 1039 window.addEventListener('message', function (event) { 1040 if (event.data === 'closeIframe') { 1041 var iframe = window.parent.document.getElementById('meshulam'); // ÐамениÑе на Ð²Ð°Ñ ID айÑÑейма 1042 iframe.parentNode.removeChild(iframe); 1043 console.log(iframe) 1044 } 1045 }); 1046})(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.