1$ = jQuery; 2 3let flag = true; 4 5if ( 6 jQuery("form.woocommerce-checkout").length > 0 && 7 !jQuery("form.woocommerce-checkout").hasClass("wc-roundoff") 8) { 9 jQuery("form.woocommerce-checkout").addClass("wc-roundoff"); 10} 11dispaly_socialshare_links(jQuery); 12jQuery(window).on("load", function () { 13 if ( 14 wcOrderScript.donationToOrder.is_checkout && 15 wcOrderScript.donationToOrder.is_roundOff == "yes" 16 ) { 17 jQuery(".wc-block-components-checkout-place-order-button").on( 18 "click", 19 function (e) { 20 if (flag) { 21 e.stopPropagation(); 22 add_popup_before_order(); 23 } 24 }, 25 ); 26 } 27}); 28 29jQuery(window).on("load", function () { 30 jQuery(".flip-clock").each(function () { 31 var clockElement = jQuery(this); 32 var clock; 33 var startTimeStr = jQuery(this).data("start-time"); 34 var endTimeStr = jQuery(this).data("end-time"); 35 var endTimeArr = endTimeStr.split(":"); // Split the time string into hours and minutes 36 var startTimeArr = startTimeStr.split(":"); // Split the start time string into hours and minutes 37 var now = new Date(); 38 39 // Set the start and end times to today with the provided hours and minutes 40 var startTime = new Date( 41 now.getFullYear(), 42 now.getMonth(), 43 now.getDate(), 44 parseInt(startTimeArr[0]), 45 parseInt(startTimeArr[1]), 46 0, 47 ); 48 var endTime = new Date( 49 now.getFullYear(), 50 now.getMonth(), 51 now.getDate(), 52 parseInt(endTimeArr[0]), 53 parseInt(endTimeArr[1]), 54 0, 55 ); 56 57 // If the end time is before the current time, set it to tomorrow with the same hours and minutes 58 if (endTime.getTime() < now.getTime()) { 59 endTime.setDate(endTime.getDate() + 1); 60 } 61 62 var diff = endTime.getTime() / 1000 - now.getTime() / 1000; 63 diff = Math.max(diff, 0); 64 clockElement.addClass("non-clickable"); 65 clock = jQuery(this).FlipClock(diff, { 66 clockFace: "HourlyCounter", 67 countdown: true, 68 }); 69 console.log("startTime"); 70 console.log(startTime); 71 console.log("endTime"); 72 console.log(endTime); 73 74 // Check the remaining time and start time every second 75 var interval = setInterval(function () { 76 now = new Date(); 77 var remainingTime = clock.getTime().time; 78 79 if (remainingTime <= 0) { 80 clearInterval(interval); 81 console.log("Reloading page"); 82 location.reload(); // Reload the page 83 } 84 }, 1000); 85 86 // To forcefully set the remaining time to the clock instance 87 clock.setTime(diff); 88 clock.start(); 89 }); 90 91 // Initialize Pomodoro clock instances 92 jQuery(".pomodoro-clock-container").each(function () { 93 var container = this; 94 var timerLabel = jQuery(container).find(".timer-label"); 95 var startTimeStr = jQuery(this).data("start-time"); 96 var endTimeStr = jQuery(this).data("end-time"); 97 98 var startTimeParts = startTimeStr.split(":"); 99 var endTimeParts = endTimeStr.split(":"); 100 101 var now = new Date(); 102 var start = new Date( 103 now.getFullYear(), 104 now.getMonth(), 105 now.getDate(), 106 startTimeParts[0], 107 startTimeParts[1], 108 0, 109 ); 110 var end = new Date( 111 now.getFullYear(), 112 now.getMonth(), 113 now.getDate(), 114 endTimeParts[0], 115 endTimeParts[1], 116 0, 117 ); 118 119 if (end < start) { 120 end.setDate(end.getDate() + 1); 121 } 122 123 var duration = (end - start) / 1000; 124 var elapsedTime = (now - start) / 1000; 125 var remainingTime = duration - elapsedTime; 126 127 var storedRemainingTime = localStorage.getItem("remainingTime"); 128 var lastSaved = localStorage.getItem("lastSaved"); 129 if (storedRemainingTime && lastSaved) { 130 var elapsedSinceLastSave = 131 (now.getTime() - new Date(lastSaved).getTime()) / 1000; 132 remainingTime = Math.max(0, storedRemainingTime - elapsedSinceLastSave); 133 } 134 135 var totalSecondsInDay = 24 * 60 * 60; 136 remainingTime = remainingTime % totalSecondsInDay; 137 138 var bar = new ProgressBar.Circle(container, { 139 color: "#EFBBBE", 140 trailColor: "#BF5252", 141 trailWidth: 5, 142 duration: remainingTime * 1000, 143 easing: "linear", 144 strokeWidth: 5, 145 from: { color: "#EFBBBE", width: 5 }, 146 to: { color: "#EFBBBE", width: 5 }, 147 step: function (state, circle) {
148 var elapsed = (1.0 - circle.value()) * duration; 149 var remaining = Math.max(duration - elapsed, 0); 150 timerLabel.text(formatDuration(remaining)); 151 circle.path.setAttribute("stroke", state.color); 152 circle.path.setAttribute("stroke-width", state.width); 153 }, 154 }); 155 156 function updateProgressBar() { 157 bar.set(remainingTime / duration); 158 if (remainingTime <= 0) { 159 clearInterval(progressInterval); 160 } 161 } 162 163 var progressInterval = setInterval(updateProgressBar, 1100); 164 165 var interval = setInterval(function () { 166 now = new Date(); 167 elapsedTime = (now - start) / 1000; 168 remainingTime = Math.max(duration - elapsedTime, 0); 169 remainingTime = remainingTime % totalSecondsInDay; 170 timerLabel.text(formatDuration(remainingTime)); 171 172 localStorage.setItem("remainingTime", remainingTime); 173 localStorage.setItem("lastSaved", new Date().toISOString()); 174 175 if (remainingTime <= 1) { 176 clearInterval(interval); 177 location.reload(); 178 } 179 }, 1000); 180 181 jQuery(window).on("beforeunload", function () { 182 now = new Date(); 183 elapsedTime = (now - start) / 1000; 184 remainingTime = Math.max(duration - elapsedTime, 0); 185 remainingTime = remainingTime % totalSecondsInDay; 186 localStorage.setItem("remainingTime", remainingTime); 187 localStorage.setItem("lastSaved", new Date().toISOString()); 188 }); 189 }); 190 191 jQuery("<style>") 192 .prop("type", "text/css") 193 .html( 194 "\ 195 .flip-clock-wrapper .flip-clock-days {\ 196 display: none;\ 197 }\ 198 ", 199 ) 200 .appendTo("head"); 201}); 202 203function formatTime(date) { 204 var hours = date.getHours(); 205 var minutes = date.getMinutes(); 206 return ( 207 (hours < 10 ? "0" : "") + hours + ":" + (minutes < 10 ? "0" : "") + minutes 208 ); 209} 210 211function formatDuration(seconds) { 212 var hours = Math.floor(seconds / 3600); 213 seconds %= 3600; 214 var minutes = Math.floor(seconds / 60); 215 var sec = Math.floor(seconds % 60); 216 return ( 217 (hours < 10 ? "0" : "") + 218 hours + 219 ":" + 220 (minutes < 10 ? "0" : "") + 221 minutes + 222 ":" + 223 (sec < 10 ? "0" : "") + 224 sec 225 ); 226} 227//WC Donation Tabs Frontend 228jQuery(document).on( 229 "click", 230 ".wc-donation-tabs-wrap ul.tab-nav > li", 231 function (event) { 232 event.preventDefault(); 233 jQuery(this).siblings().removeClass("active"); 234 jQuery(this).addClass("active"); 235 var content = jQuery(this).data("tab"); 236 jQuery(".wc-donation-tab-content").removeClass("active"); 237 jQuery(`.wc-donation-tab-content.${content}`).addClass("active"); 238 }, 239); 240 241function add_popup_before_order() { 242 jQuery.ajax({ 243 url: wcOrderScript.donationToOrder.ajaxUrl, 244 type: "POST", 245 dataType: "json", 246 data: { 247 action: "add_popup_before_order", 248 nonce: wcOrderScript.donationToOrder.nonce, 249 }, 250 beforeSend: function () { 251 //if loader needs to add put here 252 }, 253 success: function (response) { 254 if (response["status"] == "success") { 255 jQuery(".wc-donation-popup") 256 .find("#wc-donation-price-" + response["campaign_id"]) 257 .val(response["donation"]); 258 var text = jQuery(".wc-donation-popup").find(".donation_text").text(); 259 var res = text.replace("%amount%", response["donation"]); 260 jQuery(".wc-donation-popup").find(".donation_text").text(res); 261 jQuery(".wc-donation-popup:not(.cart-campaign-popup)").addClass( 262 "wc-popup-show", 263 ); 264 } else { 265 flag = false; 266 jQuery(".wc-block-components-checkout-place-order-button").trigger( 267 "click", 268 ); 269 jQuery("form.woocommerce-checkout").submit(); 270 } 271 }, 272 }); 273} 274 275if ( 276 wcOrderScript.donationToOrder.is_checkout && 277 !wcOrderScript.donationToOrder.is_order_pay 278) { 279 /* when click on place order*/ 280 jQuery(document).on("click", "#place_order", function (e) { 281 //console.log( wcOrderScript.donationToOrder.is_checkout ); 282 if ( 283 wcOrderScript.donationToOrder.is_checkout && 284 wcOrderScript.donationToOrder.is_roundOff == "yes" 285 ) { 286 e.preventDefault(); 287 //debugger; 288 add_popup_before_order(); 289 } 290 }); 291} 292 293function NumbersOnly(myfield, e, dec) { 294 /*if ( isNaN(removeCommas(myfield.value)) && myfield.value != "-") { 295 return false;
296 }*/ 297 // console.log(min); 298 // console.log(max); 299 300 // var priceEl = document.getElementById('wc-donation-price-' + id); 301 var allowNegativeNumber = false; 302 var key; 303 var keychar; 304 305 if (window.event) key = window.event.keyCode; 306 else if (e) key = e.which; 307 else return true; 308 keychar = String.fromCharCode(key); 309 var srcEl = e.srcElement ? e.srcElement : e.target; 310 311 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 312 313 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 314 // } 315 // control keys 316 if (key == null || key == 0 || key == 9 || key == 13 || key == 27) { 317 return true; 318 } 319 320 // if ( min != '' && max != '' ) { 321 // if ( ( parseFloat(myfield.value) >= min) && ( parseFloat(myfield.value) <= max) ) { 322 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 323 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 324 // } 325 // return true; 326 // } else { 327 // myfield.value = ''; 328 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 329 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 330 // } 331 // return false; 332 // } 333 // } 334 335 // numbers 336 if ("0123456789".indexOf(keychar) > -1) return true; 337 // decimal point jump 338 else if (dec && keychar == ".") { 339 //myfield.form.elements[dec].focus(); 340 return srcEl.value.indexOf(".") == -1; 341 } else if (dec && keychar == ",") { 342 return srcEl.value.indexOf(",") == -1; 343 } 344 345 //allow negative numbers 346 else if (allowNegativeNumber && keychar == "-") { 347 return srcEl.value.length == 0 || srcEl.value == "0.00"; 348 } else return false; 349} 350 351jQuery(document).on("focusout", ".grab-donation", function () { 352 var This = jQuery(this); 353 var min = This.data("min"); 354 var max = This.data("max"); 355 var id = This.data("campaign_id"); 356 var rand_id = This.data("rand_id"); 357 var priceEl = document.getElementById( 358 "wc-donation-price-" + id + "_" + rand_id, 359 ); 360 var val = This.val(); 361 362 if (max <= 0 && max != "any") { 363 max = val; 364 } 365 366 if ((min == "any" && max == "any") || (val >= min && val <= max)) { 367 var procFees = jQuery("#processing-fees-" + id + "_" + rand_id).val(); 368 if (wcOrderScript.donationToOrder.fees_type == "percentage") { 369 var donation_card_fee = val * (procFees / 100); 370 } else { 371 var donation_card_fee = procFees; 372 } 373 374 var donation_summary_total = 375 parseFloat(val) + parseFloat(donation_card_fee); 376 377 if (donation_summary_total > 0 && donation_summary_total != "") { 378 jQuery( 379 "#wc-donation-summary-" + 380 id + 381 "_" + 382 rand_id + 383 " .wc-donation-currency-symbol", 384 ).attr("style", "display: inline-block !important"); 385 jQuery( 386 "#wc-donation-summary-" + 387 id + 388 "_" + 389 rand_id + 390 " .wc-donation-charge .wc-donation-amt", 391 ).text(parseFloat(val).toFixed(2)); 392 jQuery( 393 "#wc-donation-summary-" + 394 id + 395 "_" + 396 rand_id + 397 " .wc-donation-fee-summary .wc-donation-amt", 398 ).text(parseFloat(donation_card_fee).toFixed(2)); 399 jQuery( 400 "#wc-donation-summary-" + 401 id + 402 "_" + 403 rand_id + 404 " .wc-donation-summary-total .wc-donation-amt", 405 ).text(parseFloat(donation_summary_total).toFixed(2)); 406 } else { 407 jQuery( 408 "#wc-donation-summary-" + 409 id + 410 "_" + 411 rand_id + 412 " .wc-donation-currency-symbol", 413 ).attr("style", "display: inline-block !important"); 414 jQuery( 415 "#wc-donation-summary-" + 416 id + 417 "_" + 418 rand_id + 419 " .wc-donation-charge .wc-donation-amt", 420 ).text(parseFloat(0).toFixed(2)); 421 jQuery( 422 "#wc-donation-summary-" + 423 id + 424 "_" + 425 rand_id + 426 " .wc-donation-fee-summary .wc-donation-amt", 427 ).text(parseFloat(0).toFixed(2)); 428 jQuery( 429 "#wc-donation-summary-" + 430 id + 431 "_" + 432 rand_id + 433 " .wc-donation-summary-total .wc-donation-amt", 434 ).text(parseFloat(0).toFixed(2)); 435 } 436 priceEl.value = val; 437 } else { 438 priceEl.value = ""; 439 This.val(""); 440 } 441}); 442 443jQuery(document).on("click", ".wc-close", function () { 444 jQuery(this).parents(".wc-donation-popup").removeClass("wc-popup-show"); 445 if (jQuery("body").hasClass("stopScroll")) { 446 jQuery("body").removeClass("stopScroll"); 447 } 448}); 449 450function addDonationToOrder( 451 type, 452 amount, 453 min_amount, 454 max_amount, 455 campaign_id, 456 is_recurring, 457 new_period, 458 new_length, 459 new_interval, 460 tracker, 461 donation_type, 462 cause, 463 fees, 464 gift_aid = "", 465 tribute = "", 466 tribute_message = "", 467 e_card_email, 468 cc_processing_fee, 469 _this, 470 wps_sfw_sub_number, 471 wps_sfw_sub_interval, 472 wps_sfw_sub_exp_number, 473 wps_sfw_sub_exp_interval, 474 selectedLabel, 475) { 476 let skip = false;
477 478 if (type === "roundoff-skip") { 479 flag = false; 480 jQuery(".wc-block-components-checkout-place-order-button").trigger("click"); 481 jQuery("form.woocommerce-checkout").submit(); 482 return true; 483 } 484 485 if (amount != 0 && amount != null && amount > 0) { 486 jQuery.ajax({ 487 url: wcOrderScript.donationToOrder.ajaxUrl, 488 type: "POST", 489 dataType: "json", 490 data: { 491 action: wcOrderScript.donationToOrder.action, 492 nonce: wcOrderScript.donationToOrder.nonce, 493 campaign_id: campaign_id, 494 amount: amount, 495 selectedLabel: selectedLabel, 496 cause: cause, 497 fees: fees, 498 type: type, 499 tribute: tribute, 500 tribute_message: tribute_message, 501 e_card_email: e_card_email, 502 gift_aid: gift_aid, 503 is_recurring: is_recurring, 504 new_period: new_period, 505 new_length: new_length, 506 new_interval: new_interval, 507 cc_processing_fee: cc_processing_fee, 508 wps_sfw_subscription_number: wps_sfw_sub_number, 509 wps_sfw_subscription_interval: wps_sfw_sub_interval, 510 wps_sfw_subscription_expiry_number: wps_sfw_sub_exp_number, 511 wps_sfw_subscription_expiry_interval: wps_sfw_sub_exp_interval, 512 }, 513 beforeSend: function () { 514 jQuery(_this) 515 .parents(".wc_donation_on_cart") 516 .append( 517 '<div class="wc-donation-loader-css"><div class="wc-donation-blur-effect"></div><div class="wc-donation-loader" style="display:block;"></div></div>', 518 ); 519 jQuery(_this) 520 .parents(".widget_wc-donation-widget") 521 .append( 522 '<div class="wc-donation-loader-css"><div class="wc-donation-blur-effect"></div><div class="wc-donation-loader" style="display:block;"></div></div>', 523 ); 524 }, 525 success: function (response) { 526 if (response["response"] == "success") { 527 jQuery(`input[value="${campaign_id}"]`) 528 .closest(".wc_donation_on_cart") 529 .find("div.wc-donation-loader-css") 530 .remove(); 531 jQuery(`input[value="${campaign_id}"]`) 532 .closest(".widget_wc-donation-widget") 533 .find("div.wc-donation-loader-css") 534 .remove(); 535 jQuery("[name='update_cart']").prop("disabled", false); 536 jQuery("[name='update_cart']").trigger("click"); 537 538 if (type === "roundoff") { 539 jQuery(".wc-donation-popup").removeClass("wc-popup-show"); 540 } 541 542 jQuery("body").trigger("update_checkout"); 543 if ( 544 typeof wc !== "undefined" && 545 typeof wc.blocksCheckout !== "undefined" 546 ) { 547 flag = false; 548 const { extensionCartUpdate } = wc.blocksCheckout; 549 extensionCartUpdate({ 550 namespace: "dfw", 551 data: {}, 552 }); 553 } 554 555 if (jQuery("#wc-donation-woocommerce-notices-wrapper").length) { 556 jQuery("#wc-donation-woocommerce-notices-wrapper").show(); 557 document 558 .getElementById("wc-donation-woocommerce-notices-wrapper") 559 .scrollIntoView({ behavior: "smooth" }); 560 } 561 if (response["cart_url"] != "") { 562 window.location.href = response["cart_url"]; 563 } 564 565 if (response["checkoutUrl"] != "") { 566 window.location.href = response["checkoutUrl"]; 567 } 568 569 jQuery("body").trigger("wc_donation_checkout_event"); 570 } 571 if ("failed" === response["response"]) { 572 jQuery(`input[value="${campaign_id}"]`) 573 .closest(".wc_donation_on_cart") 574 .find("div.wc-donation-loader-css") 575 .remove(); 576 jQuery(`input[value="${campaign_id}"]`) 577 .closest(".widget_wc-donation-widget") 578 .find("div.wc-donation-loader-css") 579 .remove(); 580 581 if ( 582 !jQuery(`input[value="${campaign_id}"]`) 583 .siblings("div") 584 .hasClass("cc-require-message") 585 ) { 586 var messageElement = jQuery( 587 '<div class="cc-require-message">' + response.message + "</div>", 588 ); 589 jQuery(`input[value="${campaign_id}"]`) 590 .siblings("button") 591 .after(messageElement); 592 } 593 } 594 if ("error" === response["response"]) { 595 location.reload(); // This will reload the page when "OK" is clicked 596 } 597 }, 598 }); 599 setTimeout(function () { 600 jQuery(".cc-require-message").remove(); 601 }, 7000); 602 } else { 603 var text = wcOrderScript.donationToOrder.other_amount_placeholder; 604 text = text.replace("%min%", min_amount); 605 text = text.replace("%max%", max_amount); 606 if (donation_type == "both" || donation_type == "predefined") { 607 if (tracker == 1) { 608 alert(`${text}`); 609 } else { 610 alert(`Please select amount`); 611 } 612 } else { 613 alert(`${text}`); 614 } 615 return true; 616 } 617} 618 619jQuery(document).on( 620 "click", 621 ".wc-donation-f-submit-donation, #wc-donation-round-f-submit-donation, #wc-donation-round-f-submit-skip-donation", 622 function (e) { 623 e.preventDefault(); 624 var _this = jQuery(this); 625 var parents = jQuery(this).parents(".wc-donation-in-action"); 626 var type = jQuery(this).data("type"); 627 var campaign_id = jQuery(this).siblings(".wc_donation_camp").val(); 628 var rand_id = jQuery(this).siblings(".wp_rand").val(); 629 var is_recurring = false;
630 var new_period = "day"; 631 var new_length = "1"; 632 var new_interval = "1"; 633 var min_amount = 0; 634 var max_amount = 0; 635 var donation_type = jQuery(parents).data("donation-type"); 636 var tracker = jQuery(parents).find(".wc-opened").length; 637 var subscription_data = []; 638 var tracker2 = jQuery(parents).find( 639 ".wc-donation-f-donation-other-value", 640 ).length; 641 var selectBox = jQuery(parents).find("select.wc-label-select"); 642 selectedLabel = ""; 643 if (selectBox.length && selectBox.find("option:selected").val()) { 644 selectedLabel = selectBox.find("option:selected").text().trim(); 645 } 646 647 // If no valid selection from <select>, try radio buttons 648 if (!selectedLabel) { 649 var selectedRadio = jQuery(parents).find( 650 'input[name="wc_label_price"]:checked', 651 ); 652 if (selectedRadio.length) { 653 selectedLabel = selectedRadio.closest("label").text().trim(); 654 } 655 } 656 if (jQuery(this).data("min-value")) { 657 min_amount = jQuery(this).data("min-value"); 658 } 659 660 if (jQuery(this).data("max-value")) { 661 max_amount = jQuery(this).data("max-value"); 662 } 663 664 if ( 665 jQuery(parents).find(".donation-is-recurring").length > 0 && 666 jQuery(parents).find(".donation-is-recurring").is(":checked") 667 ) { 668 is_recurring = jQuery(parents).find(".donation-is-recurring").val(); 669 new_period = jQuery(parents).find("._subscription_period").val(); 670 new_length = jQuery(parents).find("#_subscription_length").val(); 671 new_interval = jQuery(parents) 672 .find("#_subscription_period_interval") 673 .val(); 674 } else { 675 is_recurring = "no"; 676 } 677 678 //alert(campaign_id); 679 if (type == "roundoff" || type == "roundoff-skip") { 680 jQuery(".wc-donation-popup").removeClass("wc-popup-show"); 681 var amount = jQuery(".roundoff-donation-price").val(); 682 } else { 683 var id = ".donate_" + campaign_id + "_" + rand_id; 684 //alert(id); 685 var amount = jQuery(id).val(); 686 } 687 var causeID = ".donate_cause_" + campaign_id + "_" + rand_id; 688 var cause = jQuery(causeID).val(); 689 var feeCheck = ".donate_fees_" + campaign_id + "_" + rand_id; 690 691 var fees = jQuery(feeCheck).val(); 692 693 var cc_processing_fee = ""; 694 if (jQuery(feeCheck).data("require") !== "") { 695 if ( 696 false == 697 jQuery("#processing-fees-" + campaign_id + "_" + rand_id).prop( 698 "checked", 699 ) 700 ) { 701 var cc_processing_fee = "require"; 702 } 703 } 704 705 var gift_aid = ""; 706 707 if ( 708 jQuery(`#wc_donation_gift_aid_checkbox_${campaign_id}_${rand_id}`) 709 .length > 0 && 710 jQuery(`#wc_donation_gift_aid_checkbox_${campaign_id}_${rand_id}`).is( 711 ":checked", 712 ) 713 ) { 714 gift_aid = "yes"; 715 } 716 717 var tribute = ""; 718 var tribute_message = ""; 719 720 if ( 721 jQuery(`#_hidden_tribute_${campaign_id}_${rand_id}`).length > 0 && 722 jQuery("input[name='wc_donation_tribute_checkbox']:checked").length && 723 jQuery(`#_hidden_tribute_${campaign_id}_${rand_id}`).val() != "" 724 ) { 725 tribute = jQuery(`#_hidden_tribute_${campaign_id}_${rand_id}`).val(); 726 } 727 728 if ( 729 jQuery(`#wc_donation_trubte_message_${campaign_id}_${rand_id}`).length > 730 0 && 731 jQuery("input[name='wc_donation_tribute_checkbox']:checked").length && 732 jQuery(`#wc_donation_trubte_message_${campaign_id}_${rand_id}`).val() != 733 "" 734 ) { 735 tribute_message = jQuery( 736 `#wc_donation_trubte_message_${campaign_id}_${rand_id}`, 737 ).val(); 738 } 739 var e_card_email = ""; 740 if ( 741 jQuery(`#wc_donation_e_card_email_${campaign_id}`).length > 0 && 742 jQuery(`#wc_donation_e_card_email_${campaign_id}`).val() != "" 743 ) { 744 e_card_email = jQuery(`#wc_donation_e_card_email_${campaign_id}`).val(); 745 } 746 var wps_sfw_sub_number = ""; 747 var wps_sfw_sub_interval = ""; 748 var wps_sfw_sub_exp_number = ""; 749 var wps_sfw_sub_exp_interval = ""; 750 751 if (jQuery(".wc_donation_subscription_table").length) { 752 var wps_sfw_sub_number = jQuery(".wc_donation_subscription_table") 753 .find(".wps_sfw_subscription_number") 754 .val(); 755 var wps_sfw_sub_interval = jQuery(".wc_donation_subscription_table") 756 .find(".wps_sfw_subscription_interval") 757 .val(); 758 var wps_sfw_sub_exp_number = jQuery(".wc_donation_subscription_table") 759 .find(".wps_sfw_subscription_expiry_number") 760 .val(); 761 var wps_sfw_sub_exp_interval = jQuery(".wc_donation_subscription_table") 762 .find(".wps_sfw_subscription_expiry_interval") 763 .val(); 764 } 765 766 addDonationToOrder( 767 type, 768 amount, 769 min_amount, 770 max_amount, 771 campaign_id, 772 is_recurring, 773 new_period, 774 new_length, 775 new_interval, 776 tracker, 777 donation_type, 778 cause, 779 fees, 780 gift_aid, 781 tribute, 782 tribute_message, 783 e_card_email, 784 cc_processing_fee, 785 _this, 786 wps_sfw_sub_number, 787 wps_sfw_sub_interval, 788 wps_sfw_sub_exp_number, 789 wps_sfw_sub_exp_interval, 790 selectedLabel, 791 ); 792 }, 793); 794 795jQuery(document).on( 796 "click",
797 'label.wc-label-button input[type="radio"][name="wc_label_price"], label.wc-label-button input[type="radio"][name="wc_label_cause"]', 798 function () { 799 if (jQuery(this).is(":checked")) { 800 //alert('I clicked'); 801 jQuery(this) 802 .parent(".wc-label-button") 803 .siblings() 804 .removeClass("wc-active"); 805 jQuery(this).parent(".wc-label-button").addClass("wc-active"); 806 } 807 }, 808); 809 810jQuery(document).on( 811 "click", 812 'label.wc-label-radio input[type="radio"][name="wc_donation_tribute_checkbox"]', 813 function () { 814 //debugger; 815 if (jQuery(this).is(":checked")) { 816 jQuery(this) 817 .parent() 818 .siblings(".wc_donation_trubte_name") 819 .prop("type", "text"); 820 jQuery(this) 821 .parent() 822 .siblings(".wc_donation_trubte_message") 823 .prop("type", "text"); 824 } 825 }, 826); 827 828jQuery(document).on( 829 "copy paste keyup click", 830 ".wc_donation_trubte_name", 831 function () { 832 var tribute_name = jQuery(this).val(); 833 var tribute_check_value = jQuery(this) 834 .siblings("label.wc-label-radio") 835 .find('input[name="wc_donation_tribute_checkbox"]:checked') 836 .val(); 837 if ( 838 jQuery.trim(tribute_name) != "" && 839 jQuery.trim(tribute_check_value) != "" 840 ) { 841 jQuery(this) 842 .siblings('input[name="tribute"]') 843 .val(`${tribute_check_value} ${tribute_name}`); 844 } else { 845 jQuery(this).siblings('input[name="tribute"]').val(""); 846 } 847 }, 848); 849 850jQuery(document).on( 851 "change", 852 ".wc-label-radio input.donation-processing-fees", 853 function () { 854 var id = jQuery(this).data("id"); 855 var campid = jQuery(this).data("camp"); 856 var procFees = jQuery(this).val(); 857 var wcdonationprice = jQuery("#wc-donation-price-" + campid).val(); 858 if (wcOrderScript.donationToOrder.fees_type == "percentage") { 859 var donation_card_fee = wcdonationprice * (procFees / 100); 860 } else { 861 var donation_card_fee = procFees; 862 } 863 var donation_summary_total = 864 parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 865 866 if (donation_summary_total > 0 && donation_summary_total != "") { 867 jQuery( 868 "#wc-donation-summary-" + campid + " .wc-donation-currency-symbol", 869 ).attr("style", "display: inline-block !important"); 870 jQuery( 871 "#wc-donation-summary-" + 872 campid + 873 " .wc-donation-charge .wc-donation-amt", 874 ).text(parseFloat(wcdonationprice).toFixed(2)); 875 jQuery( 876 "#wc-donation-summary-" + 877 campid + 878 " .wc-donation-fee-summary .wc-donation-amt", 879 ).text(parseFloat(donation_card_fee).toFixed(2)); 880 jQuery( 881 "#wc-donation-summary-" + 882 campid + 883 " .wc-donation-summary-total .wc-donation-amt", 884 ).text(parseFloat(donation_summary_total).toFixed(2)); 885 } 886 if (jQuery(this).is(":checked")) { 887 jQuery("#wc-donation-summary-" + campid).show(); 888 jQuery("#wc-donation-" + id).val(procFees); 889 } else { 890 jQuery("#wc-donation-summary-" + campid).hide(); 891 jQuery("#wc-donation-" + id).val(undefined); 892 } 893 }, 894); 895jQuery(document).on("click", "ul.causes-dropdown .init", function () { 896 jQuery(this).parent().children("li:not(.init)").toggle(); 897 jQuery(this).parent().toggleClass("active"); 898 if (jQuery(this).parent().hasClass("active")) { 899 if (jQuery(this).parents(".wc-donation-container").length) { 900 var i = 75 * jQuery(this).parent().children("li:not(.init)").length; 901 jQuery(this).parents(".wc-donation-cause").css("margin-bottom", `${i}px`); 902 } 903 } else { 904 jQuery(this).parents(".wc-donation-cause").css("margin-bottom", `0px`); 905 } 906}); 907 908jQuery(document).on("click", "ul.causes-dropdown li:not(.init)", function () { 909 var allOptions = jQuery(this).parent().children("li:not(.init)"); 910 var id = jQuery(this).data("id"); 911 var causeName = jQuery(this).data("name"); 912 jQuery("#wc-donation-" + id).val(causeName); 913 allOptions.removeClass("selected"); 914 jQuery(this).addClass("selected"); 915 jQuery(this).parent().removeClass("active"); 916 jQuery(this).parent().children(".init").html(jQuery(this).html()); 917 allOptions.toggle(); 918}); 919 920jQuery(document.body).mousedown(function (event) { 921 var target = jQuery(event.target); 922 if ( 923 jQuery("ul.causes-dropdown").hasClass("active") && 924 !target.parents().andSelf().is("ul.causes-dropdown") 925 ) { 926 // Clicked outside 927 jQuery("ul.causes-dropdown").removeClass("active"); 928 jQuery("ul.causes-dropdown").children("li:not(.init)").toggle(); 929 } 930}); 931 932// jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){ 933// if(jQuery(this).is('checked')){ 934// var id = jQuery(this).data('id'); 935// jQuery('#wc-donation-' + id).val(jQuery(this).val()); 936// } 937// else{ 938// jQuery('#wc-donation-' + id).val(''); 939// } 940// }); 941 942jQuery(document).on( 943 "change copy paste click", 944 ".wc-label-button input, .wc-label-radio input, .wc-label-select", 945 function () { 946 var id = jQuery(this).data("id"); 947 948 jQuery("#wc-donation-price-" + id).val(jQuery(this).val()); 949 if (jQuery(this).val() == "wc-donation-other-amount") { 950 jQuery("#wc-donation-f-donation-other-value-" + id).show(); 951 jQuery("#wc-donation-f-donation-other-value-" + id).addClass("wc-opened"); 952 // jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').show(); 953 jQuery(".other-price-wrapper-" + id).show(); 954 jQuery(".other-price-wrapper-" + id) 955 .siblings(".wc-donation-tooltip") 956 .show(); 957 } else { 958 jQuery("#wc-donation-f-donation-other-value-" + id).hide(); 959 jQuery("#wc-donation-f-donation-other-value-" + id).removeClass( 960 "wc-opened", 961 ); 962 // jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').hide(); 963 jQuery(".other-price-wrapper-" + id) 964 .siblings(".wc-donation-tooltip") 965 .hide(); 966 jQuery(".other-price-wrapper-" + id).hide(); 967 } 968 var procFees = jQuery("#processing-fees-" + id).val(); 969 var wcdonationprice = jQuery("#wc-donation-price-" + id).val(); 970 if (wcOrderScript.donationToOrder.fees_type == "percentage") { 971 var donation_card_fee = wcdonationprice * (procFees / 100); 972 } else { 973 var donation_card_fee = procFees; 974 } 975 var donation_summary_total = 976 parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 977 if (donation_summary_total > 0 && donation_summary_total != "") { 978 jQuery( 979 "#wc-donation-summary-" + id + " .wc-donation-currency-symbol", 980 ).attr("style", "display: inline-block !important"); 981 jQuery( 982 "#wc-donation-summary-" + id + " .wc-donation-charge .wc-donation-amt", 983 ).text(parseFloat(wcdonationprice).toFixed(2)); 984 jQuery( 985 "#wc-donation-summary-" + 986 id + 987 " .wc-donation-fee-summary .wc-donation-amt", 988 ).text(parseFloat(donation_card_fee).toFixed(2)); 989 jQuery( 990 "#wc-donation-summary-" + 991 id + 992 " .wc-donation-summary-total .wc-donation-amt", 993 ).text(parseFloat(donation_summary_total).toFixed(2)); 994 } 995 }, 996); 997 998jQuery(document).on("change", "._subscription_period", function () { 999 var $this = jQuery(this); 1000 var subscription_field = $this 1001 .parents(".wc-donation-in-action") 1002 .find('select[name="_subscription_length"]'); 1003 var period = $this.val(); 1004 1005 jQuery.ajax({ 1006 url: wcOrderScript.donationToOrder.ajaxUrl, 1007 type: "POST", 1008 dataType: "json", 1009 data: {
1010 action: "wc_donation_get_sub_length_by_sub_period", 1011 period: period, 1012 nonce: wcOrderScript.donationToOrder.nonce, 1013 }, 1014 beforeSend: function () { 1015 jQuery(subscription_field).css({ 1016 "pointer-events": "none", 1017 opacity: "0.5", 1018 }); 1019 }, 1020 success: function (response) { 1021 if (response.range != "") { 1022 jQuery(subscription_field).html(""); 1023 jQuery.each(response.range, function (index, val) { 1024 jQuery(subscription_field).append( 1025 '<option value="' + index + '">' + val + "</option>", 1026 ); 1027 }); 1028 1029 jQuery(subscription_field).removeAttr("style"); 1030 } 1031 }, 1032 }); 1033}); 1034 1035jQuery(function (jQuery) { 1036 jQuery(".donor-lists .give-grid__item").slice(0, 12).css("display", "flex"); 1037 jQuery(".anonymous-donor-lists .give-grid__item") 1038 .slice(0, 12) 1039 .css("display", "flex"); 1040 jQuery(".global-donor-lists .give-grid__item") 1041 .slice(0, 12) 1042 .css("display", "flex"); 1043 jQuery(".leaderboard-donor-lists .give-grid__item") 1044 .slice(0, 12) 1045 .css("display", "flex"); 1046 jQuery(".give-donor__load_more").on("click", function (e) { 1047 e.preventDefault(); 1048 jQuery(this) 1049 .siblings(".give-grid") 1050 .find(".give-grid__item:hidden") 1051 .slice(0, 4) 1052 .css("display", "flex"); 1053 if ( 1054 jQuery(this).siblings(".give-grid").find(".give-grid__item:hidden") 1055 .length == 0 1056 ) { 1057 jQuery(this).fadeOut(700); 1058 } 1059 }); 1060 1061 jQuery('input[name="wc_donation_tribute_checkbox"]').click(function () { 1062 var $radio = jQuery(this); 1063 if ($radio.data("waschecked") == true) { 1064 $radio.prop("checked", false); 1065 jQuery(".wc_donation_trubte_name").prop("type", "hidden"); 1066 jQuery(".wc_donation_trubte_message").prop("type", "hidden"); 1067 $radio.data("waschecked", false); 1068 } else { 1069 $radio.data("waschecked", true); 1070 } 1071 $radio 1072 .siblings('input[name="wc_donation_tribute_checkbox"]') 1073 .data("waschecked", false); 1074 }); 1075}); 1076 1077function dispaly_socialshare_links($) { 1078 jQuery(document).ready(function () { 1079 // Show the popup when the button is clicked 1080 jQuery(document).on("click", "#wc-donation-social-share", function () { 1081 jQuery("#social-share-popup") 1082 .css({ 1083 display: "flex", 1084 "justify-content": "center", 1085 "align-items": "center", 1086 overflow: "hidden", 1087 }) 1088 .show(); 1089 }); 1090 1091 // Hide the popup when the close button is clicked 1092 jQuery(".close").click(function () { 1093 jQuery("#social-share-popup").hide(); 1094 }); 1095 1096 // Hide the popup when clicking outside of the popup content 1097 jQuery(window).click(function (event) { 1098 if (jQuery(event.target).is("#social-share-popup")) { 1099 jQuery("#social-share-popup").hide(); 1100 } 1101 }); 1102 1103 // Copy link to clipboard 1104 jQuery("#copy-link").click(function (e) { 1105 e.preventDefault(); 1106 const url = jQuery(this).data("url"); 1107 const tempInput = jQuery("<input>"); 1108 jQuery("body").append(tempInput); 1109 tempInput.val(url).select(); 1110 document.execCommand("copy"); 1111 tempInput.remove(); 1112 alert("Link copied to clipboard!"); 1113 }); 1114 1115 // Trigger print dialog with custom content 1116 jQuery("#print-poster").click(function (e) { 1117 e.preventDefault(); 1118 1119 // Create a new window 1120 var printWindow = window.open("", "_blank"); 1121 1122 // Get the content to print 1123 var printContents = document.getElementById("print-section").innerHTML; 1124 1125 // Write the content into the new window 1126 printWindow.document.write("<html><head><title>Print Poster</title>"); 1127 printWindow.document.write("</head><body>"); 1128 printWindow.document.write(printContents); 1129 printWindow.document.write("</body></html>"); 1130 1131 // Close the document to trigger the print dialog 1132 printWindow.document.close(); 1133 1134 // Wait for the content to be fully loaded 1135 printWindow.onload = function () { 1136 printWindow.print(); 1137 printWindow.close(); 1138 }; 1139 }); 1140 }); 1141} 1142 1143document.addEventListener("DOMContentLoaded", function () { 1144 if (jQuery(".donation-is-recurring").length) { 1145 const recurringCheckbox = document.querySelector(".donation-is-recurring"); 1146 const donationSubscriptionDiv = document.querySelector( 1147 ".donation_subscription", 1148 ); 1149 1150 // Function to toggle visibility based on checkbox state 1151 function toggleSubscriptionVisibility() { 1152 if (recurringCheckbox.checked) { 1153 donationSubscriptionDiv.style.display = "block"; 1154 } else { 1155 donationSubscriptionDiv.style.display = "none"; 1156 } 1157 } 1158 1159 // Run on page load in case checkbox is already checked 1160 toggleSubscriptionVisibility(); 1161 1162 // Add event listener for changes to the checkbox 1163 recurringCheckbox.addEventListener("change", toggleSubscriptionVisibility); 1164 } 1165}); 1166 1167document.addEventListener("DOMContentLoaded", function () { 1168 if (jQuery(".donation-is-recurring").length) { 1169 const recurringCheckbox = document.querySelector(".donation-is-recurring"); 1170 const subscriptionOptions = document.querySelectorAll( 1171 ".subscription-options", 1172 ); 1173 1174 // Function to toggle visibility based on checkbox state 1175 function toggleSubscriptionOptions() { 1176 const display = recurringCheckbox.checked ? "table-row" : "none"; 1177 subscriptionOptions.forEach((row) => { 1178 row.style.display = display; 1179 }); 1180 } 1181 1182 // Run on page load to set initial state 1183 toggleSubscriptionOptions(); 1184 1185 // Add event listener for changes to the checkbox 1186 recurringCheckbox.addEventListener("change", toggleSubscriptionOptions); 1187 } 1188}); 1189 1190jQuery(document).ready(function ($) { 1191 var allowSubmit = true; // Flag to control AJAX submission 1192 1193 jQuery("#wc-donation-f-submit-donation").on("click", function (e) { 1194 var subscriptionNumber = parseInt( 1195 jQuery("#wps_sfw_subscription_number").val(), 1196 10, 1197 ); 1198 var expiryNumber = parseInt( 1199 jQuery("#wps_sfw_subscription_expiry_number").val(), 1200 10, 1201 ); 1202 if (jQuery("#wps_sfw_subscription_number").length) { 1203 // Check if the checkbox is checked and subscription number is empty 1204 if (jQuery(".donation-is-recurring").is(":checked")) { 1205 if (isNaN(subscriptionNumber) || subscriptionNumber === "") { 1206 alert("Please enter the number of subscriptions per interval."); 1207 allowSubmit = false;
1208 e.preventDefault(); // Prevent form submission 1209 return; // Exit the function to avoid further checks 1210 } 1211 } 1212 // Validate if number is positive 1213 if (subscriptionNumber < 1 || expiryNumber < 1) { 1214 alert("Interval cannot be negative."); 1215 allowSubmit = false; 1216 e.preventDefault(); // Prevent form submission 1217 return; // Exit the function to avoid further checks 1218 } 1219 // Check if the subscription number is greater than the expiry number 1220 if (subscriptionNumber > expiryNumber) { 1221 alert( 1222 "Subscriptions Per Interval must not be greater than Subscriptions Expiry Interval.", 1223 ); 1224 allowSubmit = false; // Set flag to false to prevent AJAX 1225 e.preventDefault(); // Prevent form submission 1226 } else { 1227 allowSubmit = true; // Allow AJAX if condition is met 1228 } 1229 } 1230 }); 1231 1232 // Intercept AJAX request if necessary 1233 jQuery(document).ajaxSend(function (event, jqxhr, settings) { 1234 if (!allowSubmit) { 1235 jqxhr.abort(); // Abort the AJAX request 1236 jQuery(".wc-donation-loader-css").hide(); // Hide loader if any 1237 } 1238 }); 1239}); 1240 1241jQuery(document).ready(function ($) { 1242 jQuery("#wps_sfw_subscription_interval").on("change", function () { 1243 var selectedInterval = jQuery(this).val(); 1244 1245 // Clear the Expiry Interval options 1246 jQuery("#wps_sfw_subscription_expiry_interval").empty(); 1247 1248 // Add the selected interval as the only option in Expiry Interval 1249 jQuery("#wps_sfw_subscription_expiry_interval").append( 1250 '<option value="' + 1251 selectedInterval + 1252 '">' + 1253 selectedInterval.charAt(0).toUpperCase() + 1254 selectedInterval.slice(1) + 1255 "(s)</option>", 1256 ); 1257 }); 1258 1259 // Trigger the change event on page load to set the initial state 1260 jQuery("#wps_sfw_subscription_interval").trigger("change"); 1261});
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.