Last active
December 30, 2016 09:08
-
-
Save isaiahbaca/5ea528e818e67287d00a4a94c6517787 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log('atpay2'); | |
| jQuery(document).ready(function($) { | |
| //@Pay scripts | |
| $(document).ready(function() { | |
| atpay.config({ | |
| organization_sid: "org_Fi66n7j5BaKX8WpdzezEPQ" | |
| }); | |
| var $form = jQuery("#ProcessForm"); | |
| var should_submit = false; | |
| $form.submit(function () { | |
| if (should_submit) | |
| return true; | |
| if ($("#opt-in").is(':checked')) { | |
| $("#responsive_payment_typecc_numbername").attr('data-atpay', 'card_number'); | |
| $("#responsive_payment_typecc_cvvname").attr('data-atpay', 'cvc'); | |
| $("#responsive_payment_typecc_exp_date_MONTH").attr('data-atpay', 'exp_month'); | |
| $("#responsive_payment_typecc_exp_date_YEAR").attr('data-atpay', 'exp_year'); | |
| $("#donor_email_addressname").attr('data-atpay', 'email'); | |
| $("#billing_first_namename").attr('data-atpay', 'first_name'); | |
| $("#billing_last_namename").attr('data-atpay', 'last_name'); | |
| $("#billing_addr_zipname").attr('data-atpay', 'zip'); | |
| $("#billing_addr_street1name").attr('data-atpay', 'street'); | |
| $("#billing_addr_cityname").attr('data-atpay', 'city'); | |
| $("#billing_addr_state").attr('data-atpay', 'state'); | |
| atpay.register("#ProcessForm",function(response){ | |
| should_submit = true; | |
| $form.submit(); //will now submit normally because should_submit is true. | |
| }); | |
| }else{ | |
| return true; | |
| } | |
| return false; | |
| }); | |
| }); | |
| if (jQuery(window).width() < 767) { | |
| $("#two_click").click(function(e) { | |
| //e.preventDefault(); | |
| markup = $("#thanks"); | |
| $.featherlight(markup); | |
| }); | |
| $(function() { | |
| $(document).ready(function() { | |
| $('#billing_addr_city_row').hide(); | |
| $('#billing_addr_state_row').hide(); | |
| }); | |
| // OnKeyDown Function | |
| $("#billing_addr_zipname").keyup(function() { | |
| var zip_in = $(this); | |
| var zip_box = $('#billing_addr_zip_row'); | |
| if (zip_in.val().length < 5) { | |
| zip_box.removeClass('error success'); | |
| //$('.zip-error').show(); | |
| } else if (zip_in.val().length > 5) { | |
| zip_box.addClass('error').removeClass('success'); | |
| $('.zip-error').show(); | |
| } else if ((zip_in.val().length == 5)) { | |
| // Make HTTP Request | |
| $.ajax({ | |
| url: "https://api.zippopotam.us/us/" + zip_in.val(), | |
| cache: false, | |
| dataType: "json", | |
| type: "GET", | |
| success: function(result, success) { | |
| // Make the city and state boxes visible | |
| //$('#billing_addr_city_row').slideDown(); | |
| //$('#billing_addr_state_row').slideDown(); | |
| //$('#billing_addr_country_row').slideDown(); | |
| $('.zip-error').hide(); | |
| // US Zip Code Records Officially Map to only 1 Primary Location | |
| places = result['places'][0]; | |
| $("#billing_addr_cityname").val(places['place name']); | |
| $("#billing_addr_state").val(places['state abbreviation']); | |
| zip_box.addClass('success').removeClass('error'); | |
| }, | |
| error: function(result, success) { | |
| zip_box.removeClass('success').addClass('error'); | |
| $('#billing_addr_city_row').slideDown(); | |
| $('#billing_addr_state_row').slideDown(); | |
| $('#billing_addr_country_row').slideDown(); | |
| } | |
| }); | |
| } | |
| }); | |
| }); | |
| //Custom script | |
| $(document).ready(function() { | |
| //$('input[name=level_standardexpanded]').prop('checked', false); | |
| $('.don-standard-levels').prepend($('h2:contains("Amount of gift")')); | |
| $('.donation-level-user-entered').prepend('<i class="fa fa-usd" aria-hidden="true"></i>'); | |
| $('#content .donation-level-user-entered input').attr('placeholder', 'Enter your Amount'); | |
| $('.type-of-gift-header').parent().parent().attr('id', 'gift_frequency'); | |
| $('.external-payment .payment-type-option label a').html('PayPal'); | |
| $('.payment-type-element-container').addClass('clearfix'); | |
| $('.don-standard-levels h2').text('Choose Donation Amount'); | |
| $('#gift_frequency h2').text('Choose a Frequency'); | |
| $('.section-header-container:contains("Billing Information")').text('Personal Info'); | |
| $('#donor_email_opt_in_Row h2').text('Credit/Debit Info'); | |
| $('#responsive_payment_typecc_cvv_row .FormLabelText').text('CVV'); | |
| $('#quickgive').hide(); | |
| $('#billing_addr_zip_row').insertBefore($('#billing_addr_city_row')); | |
| $('#donor_email_address_row').insertBefore($('#billing_addr_city_row')); | |
| $('#donor_email_address_row').after('<div class="zip-error">Please enter a valid zip code</div>'); | |
| jQuery('div.donation-level-amount-container').each(function() { | |
| var $elm = jQuery(this), | |
| amount = $elm.text().split('.'); | |
| if (amount.length == 2) { | |
| $elm.text(amount[0]); | |
| } | |
| }); | |
| $('.payment-type-option').change(function() { | |
| if ($('#responsive_payment_typepay_typeradioach').is(':checked')) { | |
| $('.full_mobile').hide(); | |
| } | |
| if ($('#responsive_payment_typepay_typeradiopaypal').is(':checked')) { | |
| $('.full_mobile').hide(); | |
| } | |
| if ($('#responsive_payment_typepay_typeradiocredit').is(':checked')) { | |
| $('.full_mobile').show(); | |
| } | |
| }); | |
| if ($("#pledge-radio-one").length) { | |
| $('.giving-frequency').change(function() { | |
| if ($('#onetime').is(':checked')) { | |
| $('#pledge-radio-one').removeClass('active'); | |
| $('#one-time-donation').addClass('active'); | |
| $('.frequency').text('/One-time'); | |
| $('#quickgive').show(); | |
| } else if ($('#monthlySustainingDonation').is(':checked')) { | |
| $('#pledge-radio-one').addClass('active'); | |
| $('#one-time-donation').removeClass('active'); | |
| $('#quickgive').hide(); | |
| } | |
| }); | |
| $('#onetime').click(function() { | |
| $('#quickgive').show(); | |
| }); | |
| $('#billing_first_namename').click(function() { | |
| jQuery('#quickgive').hide(); | |
| }); | |
| } else { | |
| $('.donation-level-input-container').change(function() { | |
| $('#quickgive').show(); | |
| }); | |
| $('.enter-amount input[type=text]').focus(function() { | |
| $('#quickgive').show(); | |
| }); | |
| if ($('input[name=level_standardexpanded]').is(':checked')) { | |
| $('#quickgive').show(); | |
| $('.donation-review-amount').text($('input[name=level_standardexpanded]:checked').parent('.donation-level-label-input-container').siblings('label').children('.donation-level-amount-container').text()); | |
| $('#two_click_amount').text($('input[name=level_standardexpanded]:checked').parent('.donation-level-label-input-container').siblings('label').children('.donation-level-amount-container').text().replace('$', '')); | |
| } | |
| } | |
| if ($('input[name=level_standardexpanded]').is(':checked')) { | |
| var checkedInputError = $('input[name=level_standardexpanded]:checked').val(); | |
| console.log('Input value on error: ' + checkedInputError); | |
| $('input[name=level_standardexpanded]:checked').parent().parent().addClass("active"); | |
| } | |
| $('.donation-level-input-container').change(function() { | |
| $('input[name=level_standardexpanded]:not(:checked)').parent().parent().removeClass("active"); | |
| $('input[name=level_standardexpanded]:checked').parent().parent().addClass("active"); | |
| var stringInput = $('.donation-level-user-entered input[type=text]').val(); | |
| var userInput = parseFloat(stringInput) || 0; | |
| var checkedInput = $('input[name=level_standardexpanded]:checked').parent('.donation-level-label-input-container').siblings('label').children('.donation-level-amount-container').text(); | |
| var checkedInputQG = $('input[name=level_standardexpanded]:checked').parent('.donation-level-label-input-container').siblings('label').children('.donation-level-amount-container').text().replace('$', ''); | |
| if ($("#pledge-radio-one").length) { | |
| if ($('.enter-amount input[name=level_standardexpanded]').is(':checked')) { | |
| userInput = userInput || 0; | |
| console.log(userInput); | |
| console.log(typeof userInput); | |
| $('.donation-review-amount').text('$' + userInput); | |
| $('.donation-level-user-entered input[type=text]').keyup(function() { | |
| $('#two_click_amount').html($('.donation-level-user-entered input[type=text]').val()); | |
| }); | |
| } else { | |
| $('.donation-review-amount').text(checkedInput); | |
| $('#two_click_amount').text(checkedInputQG); | |
| } | |
| } else { | |
| if ($('.enter-amount input[name=level_standardexpanded]').is(':checked')) { | |
| console.log(userInput); | |
| console.log(typeof userInput); | |
| $('.donation-review-amount').text('$' + userInput); | |
| $('.donation-level-user-entered input[type=text]').keyup(function() { | |
| $('#two_click_amount').html($('.donation-level-user-entered input[type=text]').val()); | |
| }); | |
| userInput = userInput || 0; | |
| } else { | |
| $('.donation-review-amount').text(checkedInput); | |
| $('#two_click_amount').text(checkedInputQG); | |
| } | |
| } | |
| var donateAmount = $('#two_click_amount').text(); | |
| var refID = $('#source_codehidden').val(); | |
| params = { | |
| amount: parseFloat(donateAmount), | |
| ref_id: refID | |
| } | |
| atpay.offer(params, function(response) { | |
| $("#two_click_href").attr('href', response.offer.button.mail_to); | |
| }) | |
| }); | |
| $('.lamepay').click(function(e) { | |
| e.preventDefault(); | |
| $('#quickgive').hide(); | |
| }); | |
| }); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment