1$ = jQuery; 2 3if ( jQuery("form.woocommerce-checkout").length > 0 && !( jQuery("form.woocommerce-checkout").hasClass('wc-roundoff') ) ) { 4 jQuery("form.woocommerce-checkout").addClass('wc-roundoff'); 5} 6 7function add_popup_before_order () { 8 jQuery.ajax({ 9 url: wcOrderScript.donationToOrder.ajaxUrl, 10 type: "POST", 11 dataType: "json", 12 data: { 13 action: 'add_popup_before_order', 14 nonce: wcOrderScript.donationToOrder.nonce 15 }, 16 beforeSend: function () { 17 //if loader needs to add put here 18 }, 19 success: function (response) { 20 if (response['status']=='success') { 21 jQuery(".wc-donation-popup").find("#wc-donation-price-" + response['campaign_id']).val(response['donation']); 22 var text = jQuery(".wc-donation-popup").find(".donation_text").text(); 23 var res = text.replace("%amount%", response['donation']); 24 jQuery(".wc-donation-popup").find(".donation_text").text(res); 25 jQuery(".wc-donation-popup").addClass('wc-popup-show'); 26 } else { 27 jQuery("form.woocommerce-checkout").submit(); 28 } 29 } 30 }); 31} 32 33/* when click on place order*/ 34jQuery( document ).on( 35 "click", 36 "#place_order", 37 function (e) { 38 if ( wcOrderScript.donationToOrder.is_roundOff == 'yes' ) { 39 e.preventDefault(); 40 //debugger; 41 add_popup_before_order(); 42 } 43 } 44); 45 46function NumbersOnly(myfield, e, dec) { 47 /*if ( isNaN(removeCommas(myfield.value)) && myfield.value != "-") { 48 return false; 49 }*/ 50 // console.log(min); 51 // console.log(max); 52 53 // var priceEl = document.getElementById('wc-donation-price-' + id); 54 var allowNegativeNumber = false; 55 var key; 56 var keychar; 57 58 if (window.event) 59 key = window.event.keyCode; 60 else if (e) 61 key = e.which; 62 else 63 return true; 64 keychar = String.fromCharCode(key); 65 var srcEl = e.srcElement ? e.srcElement : e.target; 66 67 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 68 69 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 70 // } 71 // control keys 72 if ((key == null) || (key == 0) || (key == 9) || (key == 13) || (key == 27) ) { 73 return true; 74 } 75 76 // if ( min != '' && max != '' ) { 77 // if ( ( parseFloat(myfield.value) >= min) && ( parseFloat(myfield.value) <= max) ) { 78 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 79 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 80 // } 81 // return true; 82 // } else { 83 // myfield.value = ''; 84 // if (typeof(priceEl) != 'undefined' && priceEl != null) { 85 // priceEl.value = isFinite(parseFloat(myfield.value)) ? parseFloat(myfield.value) : ''; 86 // } 87 // return false; 88 // } 89 // } 90 91 // numbers 92 if ((("0123456789").indexOf(keychar) > -1) ) 93 return true; 94 95 // decimal point jump 96 else if (dec && (keychar == ".")) { 97 //myfield.form.elements[dec].focus(); 98 return srcEl.value.indexOf(".") == -1; 99 } 100 101 else if (dec && (keychar == ",")) { 102 return srcEl.value.indexOf(",") == -1; 103 } 104 105 //allow negative numbers 106 else if (allowNegativeNumber && (keychar == "-")) { 107 return (srcEl.value.length == 0 || srcEl.value == "0.00") 108 } 109 else 110 return false; 111} 112 113jQuery(document).on('focusout', '.grab-donation', function() { 114 var This = jQuery(this); 115 var min = This.data('min'); 116 var max = This.data('max'); 117 var id = This.data('campaign_id'); 118 var rand_id = This.data('rand_id'); 119 var priceEl = document.getElementById('wc-donation-price-' + id + '_' + rand_id); 120 var val = This.val(); 121 122 if ( val >= min && val <= max ) { 123 var procFees = jQuery('#processing-fees-' + id + '_' + rand_id).val(); 124 var donation_card_fee = val*(procFees/100); 125 var donation_summary_total = parseFloat(val) + parseFloat(donation_card_fee); 126 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 127 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 128 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(val).toFixed(2)); 129 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 130 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 131 } else { 132 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 133 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(0).toFixed(2)); 134 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(0).toFixed(2)); 135 jQuery('#wc-donation-summary-' + id + '_' + rand_id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(0).toFixed(2)); 136 } 137 priceEl.value = val; 138 } else { 139 priceEl.value = ''; 140 This.val(''); 141 } 142}); 143 144jQuery(document).on("click", ".wc-close", function(){ 145 jQuery(this).parents(".wc-donation-popup").removeClass("wc-popup-show"); 146}); 147 148 149function addDonationToOrder(type, amount, min_amount, max_amount, campaign_id, is_recurring, new_period, new_length, new_interval, tracker, donation_type, cause, fees) { 150 151 let skip = false;
152 153 if ( type === 'roundoff-skip' ) { 154 jQuery("form.woocommerce-checkout").submit(); 155 return true; 156 } 157 158 if ( (amount != 0 && amount != null && amount > 0) ) { 159 jQuery.ajax( 160 { 161 url: wcOrderScript.donationToOrder.ajaxUrl, 162 type: "POST", 163 dataType: "json", 164 data: { 165 action: wcOrderScript.donationToOrder.action, 166 nonce: wcOrderScript.donationToOrder.nonce, 167 campaign_id: campaign_id, 168 amount: amount, 169 cause: cause, 170 fees: fees, 171 type: type, 172 is_recurring: is_recurring, 173 new_period: new_period, 174 new_length: new_length, 175 new_interval: new_interval 176 }, 177 beforeSend: function() { 178 179 }, 180 success: function (response) { 181 if (response['response'] == 'success') { 182 jQuery( "[name='update_cart']" ).prop( "disabled", false ); 183 jQuery( "[name='update_cart']" ).trigger( "click" ); 184 if (type==='roundoff') { 185 jQuery(".wc-donation-popup").removeClass("wc-popup-show"); 186 } 187 188 jQuery('body').trigger('update_checkout'); 189 190 if ( response['checkoutUrl'] != '' ) { 191 window.location.href = response['checkoutUrl']; 192 } 193 194 } 195 } 196 } 197 ); 198 } else { 199 var text = wcOrderScript.donationToOrder.other_amount_placeholder; 200 text = text.replace("%min%", min_amount); 201 text = text.replace("%max%", max_amount); 202 if ( donation_type == 'both' || donation_type == 'predefined' ) { 203 if ( tracker == 1 ) { 204 alert(`${text}`); 205 } else { 206 alert(`Please select amount`); 207 } 208 } else { 209 alert(`${text}`); 210 } 211 return true; 212 } 213 214} 215 216jQuery( document ).on("click", ".wc-donation-f-submit-donation, #wc-donation-round-f-submit-donation, #wc-donation-round-f-submit-skip-donation", function (e) { 217 e.preventDefault(); 218 var parents = jQuery(this).parents('.wc-donation-in-action'); 219 var type = jQuery(this).data('type'); 220 var campaign_id = jQuery(this).siblings('.wc_donation_camp').val(); 221 var rand_id = jQuery(this).siblings('.wp_rand').val(); 222 var is_recurring = false; 223 var new_period = 'day'; 224 var new_length = '1'; 225 var new_interval = '1'; 226 var min_amount = 0; 227 var max_amount = 0; 228 var donation_type = jQuery(parents).data('donation-type'); 229 var tracker = jQuery(parents).find('.wc-opened').length; 230 231 var tracker2 = jQuery(parents).find('.wc-donation-f-donation-other-value').length; 232 233 if ( jQuery(this).data('min-value') ) { 234 min_amount = jQuery(this).data('min-value'); 235 } 236 237 if ( jQuery(this).data('max-value') ) { 238 max_amount = jQuery(this).data('max-value'); 239 } 240 241 if ( jQuery(parents).find('.donation-is-recurring').length > 0 && jQuery(parents).find('.donation-is-recurring').is(':checked') ) { 242 is_recurring = jQuery(parents).find('.donation-is-recurring').val(); 243 new_period = jQuery(parents).find('._subscription_period').val(); 244 new_length = jQuery(parents).find('#_subscription_length').val(); 245 new_interval = jQuery(parents).find('#_subscription_period_interval').val(); 246 } else { 247 is_recurring = 'no'; 248 } 249 250 //alert(campaign_id); 251 if ( type == 'roundoff' || type == 'roundoff-skip' ) { 252 jQuery(".wc-donation-popup").removeClass("wc-popup-show"); 253 var amount = jQuery('.roundoff-donation-price').val(); 254 } else { 255 var id = '.donate_' + campaign_id + '_' + rand_id; 256 //alert(id); 257 var amount = jQuery(id).val(); 258 } 259 var causeID = '.donate_cause_' + campaign_id + '_' + rand_id; 260 var cause = jQuery(causeID).val(); 261 var feeCheck = '.donate_fees_' + campaign_id + '_' + rand_id; 262 263 var fees = jQuery(feeCheck).val(); 264 addDonationToOrder(type, amount, min_amount, max_amount, campaign_id, is_recurring, new_period, new_length, new_interval, tracker, donation_type, cause, fees); 265 } 266); 267 268jQuery(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() { 269 270 if ( jQuery(this).is(':checked') ) { 271 //alert('I clicked'); 272 jQuery(this).parent('.wc-label-button').siblings().removeClass('wc-active'); 273 jQuery(this).parent('.wc-label-button').addClass('wc-active'); 274 } 275}); 276 277jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){ 278 var id = jQuery(this).data('id'); 279 var campid = jQuery(this).data('camp'); 280 var procFees = jQuery(this).val(); 281 var wcdonationprice = jQuery('#wc-donation-price-'+campid).val(); 282 var donation_card_fee = wcdonationprice*(procFees/100); 283 var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 284 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 285 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 286 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2)); 287 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 288 jQuery('#wc-donation-summary-' + campid + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 289 } 290 if ( jQuery(this).is(':checked') ) { 291 jQuery('#wc-donation-summary-'+campid).show(); 292 jQuery('#wc-donation-' + id).val(procFees); 293 } 294 else { 295 jQuery('#wc-donation-summary-'+campid).hide(); 296 jQuery('#wc-donation-' + id).val(undefined); 297 } 298}); 299jQuery(document).on("click", "ul.causes-dropdown .init", function() { 300 jQuery(this).closest("ul").children('li:not(.init)').toggle(); 301 jQuery(this).closest("ul").toggleClass('active'); 302}); 303 304jQuery(document).on("click", "ul.causes-dropdown li:not(.init)", function() { 305 var allOptions = jQuery("ul.causes-dropdown").children('li:not(.init)'); 306 var id = jQuery(this).data('id'); 307 var causeName = jQuery(this).data('name'); 308 jQuery('#wc-donation-' + id).val(causeName); 309 allOptions.removeClass('selected'); 310 jQuery(this).addClass('selected'); 311 jQuery("ul.causes-dropdown").removeClass('active'); 312 jQuery("ul.causes-dropdown").children('.init').html(jQuery(this).html()); 313 allOptions.toggle(); 314}); 315// jQuery(document).on('change', '.wc-label-radio input.donation-processing-fees', function(){ 316// if(jQuery(this).is('checked')){ 317// var id = jQuery(this).data('id'); 318// jQuery('#wc-donation-' + id).val(jQuery(this).val()); 319// } 320// else{ 321// jQuery('#wc-donation-' + id).val(''); 322// } 323// }); 324 325jQuery(document).on('change copy paste click', '.wc-label-button input, .wc-label-radio input, .wc-label-select', function(){ 326 327 var id = jQuery(this).data('id'); 328 329 jQuery('#wc-donation-price-' + id).val(jQuery(this).val()); 330 if ( jQuery(this).val() == 'wc-donation-other-amount' ) { 331 jQuery("#wc-donation-f-donation-other-value-" + id).show(); 332 jQuery("#wc-donation-f-donation-other-value-" + id).addClass('wc-opened'); 333 } else { 334 jQuery("#wc-donation-f-donation-other-value-" + id).hide(); 335 jQuery("#wc-donation-f-donation-other-value-" + id).removeClass('wc-opened'); 336 } 337 var procFees = jQuery('#processing-fees-'+id).val(); 338 var wcdonationprice = jQuery('#wc-donation-price-' + id).val(); 339 var donation_card_fee = wcdonationprice*(procFees/100); 340 var donation_summary_total = parseFloat(wcdonationprice) + parseFloat(donation_card_fee); 341 if ( donation_summary_total > 0 && donation_summary_total != '' ) { 342 jQuery('#wc-donation-summary-' + id + ' .wc-donation-currency-symbol').attr('style', 'display: inline-block !important'); 343 jQuery('#wc-donation-summary-' + id + ' .wc-donation-charge .wc-donation-amt').text(parseFloat(wcdonationprice).toFixed(2)); 344 jQuery('#wc-donation-summary-' + id + ' .wc-donation-fee-summary .wc-donation-amt').text(parseFloat(donation_card_fee).toFixed(2)); 345 jQuery('#wc-donation-summary-' + id + ' .wc-donation-summary-total .wc-donation-amt').text(parseFloat(donation_summary_total).toFixed(2)); 346 } 347}); 348 349jQuery(document).on('change', '._subscription_period', function(){ 350 351 var $this = jQuery(this); 352 var period = $this.val(); 353 354 jQuery.ajax({ 355 url: wcOrderScript.donationToOrder.ajaxUrl, 356 type: "POST", 357 dataType: "json", 358 data: {
359 action: 'wc_donation_get_sub_length_by_sub_period', 360 period: period 361 }, 362 success: function (response) { 363 364 if ( response.range != '' ) { 365 jQuery('#_subscription_length').html(''); 366 jQuery.each(response.range, function(index, val) { 367 jQuery('#_subscription_length').append('<option value="'+ index +'">'+ val +'</option>'); 368 } ); 369 } 370 } 371 }); 372 373});
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.