1$ = jQuery; 2 3let flag = true; 4 5if ( jQuery("form.woocommerce-checkout").length > 0 && !( jQuery("form.woocommerce-checkout").hasClass('wc-roundoff') ) ) { 6 jQuery("form.woocommerce-checkout").addClass('wc-roundoff'); 7} 8 9jQuery(window).on('load', function(){ 10 if ( wcOrderScript.donationToOrder.is_checkout && wcOrderScript.donationToOrder.is_roundOff == 'yes' ) { 11 jQuery( '.wc-block-components-checkout-place-order-button' ).on('click', function (e) { 12 if ( flag ) { 13 e.stopPropagation(); 14 add_popup_before_order(); 15 } 16 }); 17 } 18}); 19 20//WC Donation Tabs Frontend 21jQuery(document).on('click', '.wc-donation-tabs-wrap ul.tab-nav > li', function(event) { 22 event.preventDefault(); 23 jQuery(this).siblings().removeClass('active'); 24 jQuery(this).addClass('active'); 25 var content = jQuery(this).data('tab'); 26 jQuery('.wc-donation-tab-content').removeClass('active'); 27 jQuery(`.wc-donation-tab-content.${content}`).addClass('active'); 28}); 29 30function add_popup_before_order () { 31 jQuery.ajax({ 32 url: wcOrderScript.donationToOrder.ajaxUrl, 33 type: "POST", 34 dataType: "json", 35 data: { 36 action: 'add_popup_before_order', 37 nonce: wcOrderScript.donationToOrder.nonce 38 }, 39 beforeSend: function () { 40 //if loader needs to add put here 41 }, 42 success: function (response) { 43 if (response['status']=='success') { 44 jQuery(".wc-donation-popup").find("#wc-donation-price-" + response['campaign_id']).val(response['donation']); 45 var text = jQuery(".wc-donation-popup").find(".donation_text").text(); 46 var res = text.replace("%amount%", response['donation']); 47 jQuery(".wc-donation-popup").find(".donation_text").text(res); 48 jQuery(".wc-donation-popup:not(.cart-campaign-popup)").addClass('wc-popup-show'); 49 } else { 50 flag = false; 51 jQuery( '.wc-block-components-checkout-place-order-button' ).trigger('click'); 52 jQuery("form.woocommerce-checkout").submit(); 53 } 54 } 55 }); 56} 57 58if ( wcOrderScript.donationToOrder.is_checkout && ! wcOrderScript.donationToOrder.is_order_pay ) { 59 /* when click on place order*/ 60 jQuery( document ).on( 61 "click", 62 "#place_order", 63 function (e) { 64 //console.log( wcOrderScript.donationToOrder.is_checkout ); 65 if ( wcOrderScript.donationToOrder.is_checkout && wcOrderScript.donationToOrder.is_roundOff == 'yes' ) { 66 e.preventDefault(); 67 //debugger; 68 add_popup_before_order(); 69 } 70 } 71 ); 72} 73 74function NumbersOnly(myfield, e, dec) { 75 /*if ( isNaN(removeCommas(myfield.value)) && myfield.value != "-") { 76 return false; 77 }*/ 78 // console.log(min); 79 // console.log(max); 80 81 // var priceEl = document.getElementById('wc-donation-price-' + id); 82 var allowNegativeNumber = false; 83 var key; 84 var keychar; 85 86 if (window.event) 87 key = window.event.keyCode; 88 else if (e) 89 key = e.which; 90 else 91 return true; 92 keychar = String.fromCharCode(key); 93 var srcEl = e.srcElement ? e.srcElement : e.target; 94 95 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 96 97 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 98 // } 99 // control keys 100 if ((key == null) || (key == 0) || (key == 9) || (key == 13) || (key == 27) ) { 101 return true; 102 } 103 104 // if ( min != '' && max != '' ) { 105 // if ( ( parseFloat(myfield.value) >= min) && ( parseFloat(myfield.value) <= max) ) { 106 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 107 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 108 // } 109 // return true; 110 // } else { 111 // myfield.value = ''; 112 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 113 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 114 // } 115 // return false; 116 // } 117 // } 118 119 // numbers 120 if ((("0123456789").indexOf(keychar) > -1) ) 121 return true; 122 123 // decimal point jump 124 else if (dec && (keychar == ".")) { 125 //myfield.form.elements[dec].focus(); 126 return srcEl.value.indexOf(".") == -1; 127 } 128 129 else if (dec && (keychar == ",")) { 130 return srcEl.value.indexOf(",") == -1; 131 } 132 133 //allow negative numbers 134 else if (allowNegativeNumber && (keychar == "-")) { 135 return (srcEl.value.length == 0 || srcEl.value == "0.00") 136 } 137 else 138 return false;
139} 140 141jQuery(document).on('focusout', '.grab-donation', function() { 142 var This = jQuery(this); 143 var min = This.data('min'); 144 var max = This.data('max'); 145 var id = This.data('campaign_id'); 146 var rand_id = This.data('rand_id'); 147 var priceEl = document.getElementById('wc-donation-price-' + id + '_' + rand_id); 148 var val = This.val(); 149 150 if ( max <= 0 && max != 'any' ) { 151 max = val; 152 } 153 154 if ( (min == 'any' && max == 'any') || (val >= min && val <= max) ) { 155 var procFees = jQuery('#processing-fees-' + id + '_' + rand_id).val(); 156 if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) { 157 var donation_card_fee = val*(procFees/100); 158 } else { 159 var donation_card_fee = procFees; 160 } 161 162 var donation_summary_total = parseFloat(val) + parseFloat(donation_card_fee); 163 164 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 165 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 166 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(val).toFixed(2)); 167 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 168 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 169 } else { 170 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 171 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(0).toFixed(2)); 172 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(0).toFixed(2)); 173 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(0).toFixed(2)); 174 } 175 priceEl.value = val; 176 } else { 177 priceEl.value = ''; 178 This.val(''); 179 } 180}); 181 182jQuery(document).on("click", ".wc-close", function(){ 183 jQuery(this).parents(".wc-donation-popup").removeClass("wc-popup-show"); 184 if ( jQuery('body').hasClass('stopScroll') ) { 185 jQuery('body').removeClass('stopScroll'); 186 } 187}); 188 189 190function addDonationToOrder(type, amount, min_amount, max_amount, campaign_id, is_recurring, new_period, new_length, new_interval, tracker, donation_type, cause, fees, gift_aid='', tribute='', tribute_message='' ) { 191 192 let skip = false; 193 194 if ( type === 'roundoff-skip' ) { 195 flag = false; 196 jQuery( '.wc-block-components-checkout-place-order-button' ).trigger('click'); 197 jQuery("form.woocommerce-checkout").submit(); 198 return true; 199 } 200 201 var isblock = jQuery('.entry-content').find('.wp-block-woocommerce-cart'); 202 203 if ( (amount != 0 && amount != null && amount > 0) ) { 204 jQuery.ajax( 205 { 206 url: wcOrderScript.donationToOrder.ajaxUrl, 207 type: "POST", 208 dataType: "json", 209 data: { 210 action: wcOrderScript.donationToOrder.action, 211 nonce: wcOrderScript.donationToOrder.nonce, 212 campaign_id: campaign_id, 213 amount: amount, 214 cause: cause, 215 fees: fees, 216 type: type, 217 tribute: tribute, 218 tribute_message: tribute_message, 219 gift_aid: gift_aid, 220 is_recurring: is_recurring, 221 new_period: new_period, 222 new_length: new_length, 223 new_interval: new_interval 224 }, 225 beforeSend: function() { 226 227 }, 228 success: function (response) { 229 if (response['response'] == 'success') { 230 jQuery( "[name='update_cart']" ).prop( "disabled", false ); 231 jQuery( "[name='update_cart']" ).trigger( "click" ); 232 233 if (type==='roundoff') { 234 jQuery(".wc-donation-popup").removeClass("wc-popup-show"); 235 } 236 237 jQuery('body').trigger('update_checkout'); 238 if ( typeof wc !== 'undefined') { 239 flag = false; 240 const { extensionCartUpdate } = wc.blocksCheckout; 241 extensionCartUpdate({ 242 namespace: 'dfw', 243 data: {}, 244 }); 245 } 246 247 if( jQuery("#wc-donation-woocommerce-notices-wrapper").length ) { 248 jQuery("#wc-donation-woocommerce-notices-wrapper").show(); 249 document 250 .getElementById("wc-donation-woocommerce-notices-wrapper") 251 .scrollIntoView({ behavior: "smooth" }); 252 } 253 if( response['cart_url'] != '' ) { 254 window.location.href = response['cart_url']; 255 } 256 257 if ( response['checkoutUrl'] != '' ) { 258 window.location.href = response['checkoutUrl']; 259 } 260 261 } 262 } 263 } 264 ); 265 } else { 266 var text = wcOrderScript.donationToOrder.other_amount_placeholder; 267 text = text.replace("%min%", min_amount); 268 text = text.replace("%max%", max_amount); 269 if ( donation_type == 'both' || donation_type == 'predefined' ) { 270 if ( tracker == 1 ) { 271 alert(`${text}`); 272 } else { 273 //alert(`Please select amount`);//old code 274 alert('Please enter valid amount to proceed'); 275 } 276 } else { 277 alert(`${text}`); 278 } 279 return true; 280 } 281 282} 283 284jQuery( document ).on("click", ".wc-donation-f-submit-donation, #wc-donation-round-f-submit-donation, #wc-donation-round-f-submit-skip-donation", function (e) { 285 e.preventDefault(); 286 var parents = jQuery(this).parents('.wc-donation-in-action'); 287 var type = jQuery(this).data('type'); 288 var campaign_id = jQuery(this).siblings('.wc_donation_camp').val(); 289 var rand_id = jQuery(this).siblings('.wp_rand').val(); 290 var is_recurring = false;
291 var new_period = 'day'; 292 var new_length = '1'; 293 var new_interval = '1'; 294 var min_amount = 0; 295 var max_amount = 0; 296 var donation_type = jQuery(parents).data('donation-type'); 297 var tracker = jQuery(parents).find('.wc-opened').length; 298 299 var tracker2 = jQuery(parents).find('.wc-donation-f-donation-other-value').length; 300 301 if ( jQuery(this).data('min-value') ) { 302 min_amount = jQuery(this).data('min-value'); 303 } 304 305 if ( jQuery(this).data('max-value') ) { 306 max_amount = jQuery(this).data('max-value'); 307 } 308 309 if ( jQuery(parents).find('.donation-is-recurring').length > 0 && jQuery(parents).find('.donation-is-recurring').is(':checked') ) { 310 is_recurring = jQuery(parents).find('.donation-is-recurring').val(); 311 new_period = jQuery(parents).find('._subscription_period').val(); 312 new_length = jQuery(parents).find('#_subscription_length').val(); 313 new_interval = jQuery(parents).find('#_subscription_period_interval').val(); 314 } else { 315 is_recurring = 'no'; 316 } 317 318 //alert(campaign_id); 319 if ( type == 'roundoff' || type == 'roundoff-skip' ) { 320 jQuery(".wc-donation-popup").removeClass("wc-popup-show"); 321 var amount = jQuery('.roundoff-donation-price').val(); 322 } else { 323 var id = '.donate_' + campaign_id + '_' + rand_id; 324 //alert(id); 325 var amount = jQuery(id).val(); 326 } 327 var causeID = '.donate_cause_' + campaign_id + '_' + rand_id; 328 var cause = jQuery(causeID).val(); 329 var feeCheck = '.donate_fees_' + campaign_id + '_' + rand_id; 330 331 var fees = jQuery(feeCheck).val(); 332 333 var gift_aid = ''; 334 335 if ( jQuery( `#wc_donation_gift_aid_checkbox_${campaign_id}_${rand_id}` ).length > 0 && jQuery( `#wc_donation_gift_aid_checkbox_${campaign_id}_${rand_id}` ).is(':checked') ) { 336 gift_aid = 'yes'; 337 } 338 339 var tribute = ''; 340 var tribute_message = ''; 341 342 if ( jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).length > 0 && jQuery("input[name='wc_donation_tribute_checkbox']:checked").length && jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).val() != '' ) { 343 tribute = jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).val(); 344 } 345 346 if( jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).length > 0 && jQuery("input[name='wc_donation_tribute_checkbox']:checked").length && jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).val() != '' ) { 347 tribute_message = jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).val(); 348 } 349 350 351 352 addDonationToOrder(type, amount, min_amount, max_amount, campaign_id, is_recurring, new_period, new_length, new_interval, tracker, donation_type, cause, fees, gift_aid, tribute, tribute_message ); 353 } 354); 355 356jQuery(document).on('click', 'label.wc-label-button input[type="radio"][name="wc_label_price"], label.wc-label-button input[type="radio"][name="wc_label_cause"]', function() { 357 358 if ( jQuery(this).is(':checked') ) { 359 //alert('I clicked'); 360 jQuery(this).parent('.wc-label-button').siblings().removeClass('wc-active'); 361 jQuery(this).parent('.wc-label-button').addClass('wc-active'); 362 } 363}); 364 365jQuery(document).on('click', 'label.wc-label-radio input[type="radio"][name="wc_donation_tribute_checkbox"]', function() { 366 //debugger; 367 if ( jQuery(this).is(':checked') ) { 368 jQuery(this).parent().siblings('.wc_donation_trubte_name').prop('type', 'text'); 369 jQuery(this).parent().siblings('.wc_donation_trubte_message').prop('type', 'text'); 370 } 371}); 372 373jQuery(document).on('copy paste keyup click', '.wc_donation_trubte_name', function() { 374 var tribute_name = jQuery(this).val(); 375 var tribute_check_value = jQuery(this).siblings('label.wc-label-radio').find('input[name="wc_donation_tribute_checkbox"]:checked').val(); 376 if ( jQuery.trim( tribute_name ) != '' && jQuery.trim( tribute_check_value ) != '' ) { 377 jQuery(this).siblings('input[name="tribute"]').val( `${tribute_check_value} ${tribute_name}` ); 378 } else { 379 jQuery(this).siblings('input[name="tribute"]').val(''); 380 } 381}); 382 383jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){ 384 var id = jQuery(this).data('id'); 385 var campid = jQuery(this).data('camp'); 386 var procFees = jQuery(this).val(); 387 var wcdonationprice = jQuery('#wc-donation-price-'+campid).val(); 388 if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) { 389 var donation_card_fee = wcdonationprice*(procFees/100); 390 } else { 391 var donation_card_fee = procFees; 392 } 393 var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 394 395 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 396 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 397 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2)); 398 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 399 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 400 } 401 if ( jQuery(this).is(':checked') ) { 402 jQuery('#wc-donation-summary-'+campid).show(); 403 jQuery('#wc-donation-' + id).val(procFees); 404 } 405 else { 406 jQuery('#wc-donation-summary-'+campid).hide(); 407 jQuery('#wc-donation-' + id).val(undefined); 408 } 409}); 410jQuery(document).on("click", "ul.causes-dropdown .init", function() { 411 jQuery(this).parent().children('li:not(.init)').toggle(); 412 jQuery(this).parent().toggleClass('active'); 413}); 414 415jQuery(document).on("click", "ul.causes-dropdown li:not(.init)", function() { 416 var allOptions = jQuery(this).parent().children('li:not(.init)'); 417 var id = jQuery(this).data('id'); 418 var causeName = jQuery(this).data('name'); 419 jQuery('#wc-donation-' + id).val(causeName); 420 allOptions.removeClass('selected'); 421 jQuery(this).addClass('selected'); 422 jQuery(this).parent().removeClass('active'); 423 jQuery(this).parent().children('.init').html(jQuery(this).html()); 424 allOptions.toggle(); 425}); 426 427$(document.body).mousedown(function(event) { 428 var target = $(event.target); 429 if ( $('ul.causes-dropdown').hasClass('active') && !target.parents().andSelf().is('ul.causes-dropdown')) { // Clicked outside 430 $('ul.causes-dropdown').removeClass( 'active' ); 431 $('ul.causes-dropdown').children('li:not(.init)').toggle(); 432 } 433}); 434 435// jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){ 436// if(jQuery(this).is('checked')){ 437// var id = jQuery(this).data('id'); 438// jQuery('#wc-donation-' + id).val(jQuery(this).val()); 439// } 440// else{ 441// jQuery('#wc-donation-' + id).val(''); 442// } 443// }); 444 445jQuery(document).on('change copy paste click', '.wc-label-button input, .wc-label-radio input, .wc-label-select', function(){ 446 447 var id = jQuery(this).data('id'); 448 449 jQuery('#wc-donation-price-' + id).val(jQuery(this).val()); 450 if ( jQuery(this).val() == 'wc-donation-other-amount' ) { 451 jQuery("#wc-donation-f-donation-other-value-" + id).show(); 452 jQuery("#wc-donation-f-donation-other-value-" + id).addClass('wc-opened'); 453 // jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').show(); 454 jQuery(".other-price-wrapper-" + id).show(); 455 jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').show(); 456 } else { 457 jQuery("#wc-donation-f-donation-other-value-" + id).hide(); 458 jQuery("#wc-donation-f-donation-other-value-" + id).removeClass('wc-opened'); 459 // jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').hide(); 460 jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').hide(); 461 jQuery(".other-price-wrapper-" + id).hide(); 462 } 463 var procFees = jQuery('#processing-fees-'+id).val(); 464 var wcdonationprice = jQuery('#wc-donation-price-' + id).val(); 465 if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) { 466 var donation_card_fee = wcdonationprice*(procFees/100); 467 } else { 468 var donation_card_fee = procFees; 469 } 470 var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 471 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 472 jQuery('#wc-donation-summary-' + id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 473 jQuery('#wc-donation-summary-' + id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2)); 474 jQuery('#wc-donation-summary-' + id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 475 jQuery('#wc-donation-summary-' + id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 476 } 477}); 478 479jQuery(document).on('change', '._subscription_period', function(){ 480 481 var $this = jQuery(this); 482 var subscription_field = $this.parents('.wc-donation-in-action').find('select[name="_subscription_length"]'); 483 var period = $this.val(); 484 485 jQuery.ajax({ 486 url: wcOrderScript.donationToOrder.ajaxUrl, 487 type: "POST", 488 dataType: "json", 489 data: {
490 action: 'wc_donation_get_sub_length_by_sub_period', 491 period: period, 492 nonce: wcOrderScript.donationToOrder.nonce 493 }, 494 beforeSend: function () { 495 jQuery(subscription_field).css({'pointer-events': 'none', 'opacity': '0.5'}); 496 }, 497 success: function (response) { 498 499 if ( response.range != '' ) { 500 jQuery(subscription_field).html(''); 501 jQuery.each(response.range, function(index, val) { 502 jQuery(subscription_field).append('<option value="'+ index +'">'+ val +'</option>'); 503 } ); 504 505 jQuery(subscription_field).removeAttr('style'); 506 } 507 } 508 }); 509 510}); 511 512jQuery(function(jQuery){ 513 514 jQuery(".donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 515 jQuery(".anonymous-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 516 jQuery(".global-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 517 jQuery(".leaderboard-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 518 jQuery(".give-donor__load_more").on('click', function (e) { 519 e.preventDefault(); 520 jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").slice(0, 4).css('display', 'flex'); 521 if (jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").length == 0) { 522 jQuery(this).fadeOut(700); 523 } 524 }); 525 526 jQuery('input[name="wc_donation_tribute_checkbox"]').click(function(){ 527 var $radio = $(this); 528 if ($radio.data('waschecked') == true) { 529 $radio.prop('checked', false); 530 jQuery(".wc_donation_trubte_name").prop('type', 'hidden'); 531 jQuery(".wc_donation_trubte_message").prop('type', 'hidden'); 532 $radio.data('waschecked', false); 533 } else { 534 $radio.data('waschecked', true); 535 } 536 $radio.siblings('input[name="wc_donation_tribute_checkbox"]').data('waschecked', false); 537 }); 538});
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.