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`); 274 } 275 } else { 276 alert(`${text}`); 277 } 278 return true; 279 } 280 281} 282 283jQuery( document ).on("click", ".wc-donation-f-submit-donation, #wc-donation-round-f-submit-donation, #wc-donation-round-f-submit-skip-donation", function (e) { 284 e.preventDefault(); 285 var parents = jQuery(this).parents('.wc-donation-in-action'); 286 var type = jQuery(this).data('type'); 287 var campaign_id = jQuery(this).siblings('.wc_donation_camp').val(); 288 var rand_id = jQuery(this).siblings('.wp_rand').val(); 289 var is_recurring = false;
290 var new_period = 'day'; 291 var new_length = '1'; 292 var new_interval = '1'; 293 var min_amount = 0; 294 var max_amount = 0; 295 var donation_type = jQuery(parents).data('donation-type'); 296 var tracker = jQuery(parents).find('.wc-opened').length; 297 298 var tracker2 = jQuery(parents).find('.wc-donation-f-donation-other-value').length; 299 300 if ( jQuery(this).data('min-value') ) { 301 min_amount = jQuery(this).data('min-value'); 302 } 303 304 if ( jQuery(this).data('max-value') ) { 305 max_amount = jQuery(this).data('max-value'); 306 } 307 308 if ( jQuery(parents).find('.donation-is-recurring').length > 0 && jQuery(parents).find('.donation-is-recurring').is(':checked') ) { 309 is_recurring = jQuery(parents).find('.donation-is-recurring').val(); 310 new_period = jQuery(parents).find('._subscription_period').val(); 311 new_length = jQuery(parents).find('#_subscription_length').val(); 312 new_interval = jQuery(parents).find('#_subscription_period_interval').val(); 313 } else { 314 is_recurring = 'no'; 315 } 316 317 //alert(campaign_id); 318 if ( type == 'roundoff' || type == 'roundoff-skip' ) { 319 jQuery(".wc-donation-popup").removeClass("wc-popup-show"); 320 var amount = jQuery('.roundoff-donation-price').val(); 321 } else { 322 var id = '.donate_' + campaign_id + '_' + rand_id; 323 //alert(id); 324 var amount = jQuery(id).val(); 325 } 326 var causeID = '.donate_cause_' + campaign_id + '_' + rand_id; 327 var cause = jQuery(causeID).val(); 328 var feeCheck = '.donate_fees_' + campaign_id + '_' + rand_id; 329 330 var fees = jQuery(feeCheck).val(); 331 332 var gift_aid = ''; 333 334 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') ) { 335 gift_aid = 'yes'; 336 } 337 338 var tribute = ''; 339 var tribute_message = ''; 340 341 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() != '' ) { 342 tribute = jQuery( `#_hidden_tribute_${campaign_id}_${rand_id}` ).val(); 343 } 344 345 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() != '' ) { 346 tribute_message = jQuery( `#wc_donation_trubte_message_${campaign_id}_${rand_id}` ).val(); 347 } 348 349 350 351 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 ); 352 } 353); 354 355jQuery(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() { 356 357 if ( jQuery(this).is(':checked') ) { 358 //alert('I clicked'); 359 jQuery(this).parent('.wc-label-button').siblings().removeClass('wc-active'); 360 jQuery(this).parent('.wc-label-button').addClass('wc-active'); 361 } 362}); 363 364jQuery(document).on('click', 'label.wc-label-radio input[type="radio"][name="wc_donation_tribute_checkbox"]', function() { 365 //debugger; 366 if ( jQuery(this).is(':checked') ) { 367 jQuery(this).parent().siblings('.wc_donation_trubte_name').prop('type', 'text'); 368 jQuery(this).parent().siblings('.wc_donation_trubte_message').prop('type', 'text'); 369 } 370}); 371 372jQuery(document).on('copy paste keyup click', '.wc_donation_trubte_name', function() { 373 var tribute_name = jQuery(this).val(); 374 var tribute_check_value = jQuery(this).siblings('label.wc-label-radio').find('input[name="wc_donation_tribute_checkbox"]:checked').val(); 375 if ( jQuery.trim( tribute_name ) != '' && jQuery.trim( tribute_check_value ) != '' ) { 376 jQuery(this).siblings('input[name="tribute"]').val( `${tribute_check_value} ${tribute_name}` ); 377 } else { 378 jQuery(this).siblings('input[name="tribute"]').val(''); 379 } 380}); 381 382jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){ 383 var id = jQuery(this).data('id'); 384 var campid = jQuery(this).data('camp'); 385 var procFees = jQuery(this).val(); 386 var wcdonationprice = jQuery('#wc-donation-price-'+campid).val(); 387 if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) { 388 var donation_card_fee = wcdonationprice*(procFees/100); 389 } else { 390 var donation_card_fee = procFees; 391 } 392 var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 393 394 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 395 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 396 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2)); 397 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 398 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 399 } 400 if ( jQuery(this).is(':checked') ) { 401 jQuery('#wc-donation-summary-'+campid).show(); 402 jQuery('#wc-donation-' + id).val(procFees); 403 } 404 else { 405 jQuery('#wc-donation-summary-'+campid).hide(); 406 jQuery('#wc-donation-' + id).val(undefined); 407 } 408}); 409jQuery(document).on("click", "ul.causes-dropdown .init", function() { 410 jQuery(this).parent().children('li:not(.init)').toggle(); 411 jQuery(this).parent().toggleClass('active'); 412}); 413 414jQuery(document).on("click", "ul.causes-dropdown li:not(.init)", function() { 415 var allOptions = jQuery(this).parent().children('li:not(.init)'); 416 var id = jQuery(this).data('id'); 417 var causeName = jQuery(this).data('name'); 418 jQuery('#wc-donation-' + id).val(causeName); 419 allOptions.removeClass('selected'); 420 jQuery(this).addClass('selected'); 421 jQuery(this).parent().removeClass('active'); 422 jQuery(this).parent().children('.init').html(jQuery(this).html()); 423 allOptions.toggle(); 424}); 425 426$(document.body).mousedown(function(event) { 427 var target = $(event.target); 428 if ( $('ul.causes-dropdown').hasClass('active') && !target.parents().andSelf().is('ul.causes-dropdown')) { // Clicked outside 429 $('ul.causes-dropdown').removeClass( 'active' ); 430 $('ul.causes-dropdown').children('li:not(.init)').toggle(); 431 } 432}); 433 434// jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){ 435// if(jQuery(this).is('checked')){ 436// var id = jQuery(this).data('id'); 437// jQuery('#wc-donation-' + id).val(jQuery(this).val()); 438// } 439// else{ 440// jQuery('#wc-donation-' + id).val(''); 441// } 442// }); 443 444jQuery(document).on('change copy paste click', '.wc-label-button input, .wc-label-radio input, .wc-label-select', function(){ 445 446 var id = jQuery(this).data('id'); 447 448 jQuery('#wc-donation-price-' + id).val(jQuery(this).val()); 449 if ( jQuery(this).val() == 'wc-donation-other-amount' ) { 450 jQuery("#wc-donation-f-donation-other-value-" + id).show(); 451 jQuery("#wc-donation-f-donation-other-value-" + id).addClass('wc-opened'); 452 // jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').show(); 453 jQuery(".other-price-wrapper-" + id).show(); 454 jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').show(); 455 } else { 456 jQuery("#wc-donation-f-donation-other-value-" + id).hide(); 457 jQuery("#wc-donation-f-donation-other-value-" + id).removeClass('wc-opened'); 458 // jQuery("#wc-donation-f-donation-other-value-" + id).siblings('.wc-donation-tooltip').hide(); 459 jQuery(".other-price-wrapper-" + id).siblings('.wc-donation-tooltip').hide(); 460 jQuery(".other-price-wrapper-" + id).hide(); 461 } 462 var procFees = jQuery('#processing-fees-'+id).val(); 463 var wcdonationprice = jQuery('#wc-donation-price-' + id).val(); 464 if ( wcOrderScript.donationToOrder.fees_type == 'percentage' ) { 465 var donation_card_fee = wcdonationprice*(procFees/100); 466 } else { 467 var donation_card_fee = procFees; 468 } 469 var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 470 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 471 jQuery('#wc-donation-summary-' + id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 472 jQuery('#wc-donation-summary-' + id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2)); 473 jQuery('#wc-donation-summary-' + id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 474 jQuery('#wc-donation-summary-' + id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 475 } 476}); 477 478jQuery(document).on('change', '._subscription_period', function(){ 479 480 var $this = jQuery(this); 481 var subscription_field = $this.parents('.wc-donation-in-action').find('select[name="_subscription_length"]'); 482 var period = $this.val(); 483 484 jQuery.ajax({ 485 url: wcOrderScript.donationToOrder.ajaxUrl, 486 type: "POST", 487 dataType: "json", 488 data: {
489 action: 'wc_donation_get_sub_length_by_sub_period', 490 period: period, 491 nonce: wcOrderScript.donationToOrder.nonce 492 }, 493 beforeSend: function () { 494 jQuery(subscription_field).css({'pointer-events': 'none', 'opacity': '0.5'}); 495 }, 496 success: function (response) { 497 498 if ( response.range != '' ) { 499 jQuery(subscription_field).html(''); 500 jQuery.each(response.range, function(index, val) { 501 jQuery(subscription_field).append('<option value="'+ index +'">'+ val +'</option>'); 502 } ); 503 504 jQuery(subscription_field).removeAttr('style'); 505 } 506 } 507 }); 508 509}); 510 511jQuery(function(jQuery){ 512 513 jQuery(".donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 514 jQuery(".anonymous-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 515 jQuery(".global-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 516 jQuery(".leaderboard-donor-lists .give-grid__item").slice(0, 12).css('display', 'flex'); 517 jQuery(".give-donor__load_more").on('click', function (e) { 518 e.preventDefault(); 519 jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").slice(0, 4).css('display', 'flex'); 520 if (jQuery(this).siblings('.give-grid').find(".give-grid__item:hidden").length == 0) { 521 jQuery(this).fadeOut(700); 522 } 523 }); 524 525 jQuery('input[name="wc_donation_tribute_checkbox"]').click(function(){ 526 var $radio = $(this); 527 if ($radio.data('waschecked') == true) { 528 $radio.prop('checked', false); 529 jQuery(".wc_donation_trubte_name").prop('type', 'hidden'); 530 jQuery(".wc_donation_trubte_message").prop('type', 'hidden'); 531 $radio.data('waschecked', false); 532 } else { 533 $radio.data('waschecked', true); 534 } 535 $radio.siblings('input[name="wc_donation_tribute_checkbox"]').data('waschecked', false); 536 }); 537});
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.