Clothing Bank

Clothing Bank

At (function($){ // $('#project').val('25'); $.fn.extend({ rotaterator: function(options) { var defaults = { fadeSpeed: 100, pauseSpeed: 1000 , child:null }; var options = $.extend(defaults, options); return this.each(function() { var o =options; var obj = $(this); var items = $(obj.children(), obj); items.each(function() {$(this).hide();}) if(!o.child){var next = $(obj).children(':first'); }else{var next = o.child; } $(next).fadeIn(o.fadeSpeed, function() { $(next).delay(o.pauseSpeed).fadeOut(o.fadeSpeed, function() { var next = $(this).next(); if (next.length == 0){ next = $(obj).children(':first'); } $(obj).rotaterator({child : next, fadeSpeed : o.fadeSpeed, pauseSpeed : o.pauseSpeed}); }) }); }); } }); })(jQuery); function store(data) { if (data === undefined) { data = { project: $('#project').val(), // payment_type: $('input[name="payment_type"]').val(), amount: $('#amount').val(), donation_type: $('#donation_type').val(), donation_type_name: $('#donation_type option:selected').text(), }; } axios.post('https://dev.baitussalam.org/carts', data) .then(function(response) { var id = response.data.cartItem.id; clickedItem = response.data.cartItem; if (typeof cartItems[id] !== 'undefined') { cartItems[id].amount = parseFloat(cartItems[id].amount) + parseFloat(response.data.cartItem.amount); cartTotal = parseFloat(cartTotal) + parseFloat(response.data.cartItem.amount); } else { // $set(cartItems, id, response.data.cartItem); cartItems.push(response.data.cartItem); cartCount = parseInt(cartCount) + 1; cartTotal = parseInt(cartTotal) + parseFloat(response.data.cartItem.amount); } settingCart(cartCount, cartItems, cartTotal); $('#modal-cart').modal('show'); // root.isAddingToCart = false; }) .catch(function(error) { console.log(error); alert('Something goes wrong'); // root.isAddingToCart = false; }); } $(document).ready(function (e) { $('#form-quick-donate').on('submit', function(e){ e.preventDefault(); store(); }); $('#donation_type').on('change', function(){ if($(this).children("option:selected").data('fixed') == 1) { $('#amount').val($(this).children("option:selected").data('amount')); $('#amount').attr('readonly', true); } else { $('#amount').val(''); $('#amount').attr('readonly', false); } }); var $donation_form = $("#paypal_donate_form_onetime_recurring"); //toggle custom amount var $custom_other_amount = $donation_form.find("#custom_other_amount"); $custom_other_amount.hide(); $donation_form.find("select[name='amount']").change(function () { var $this = $(this); if ($this.val() == 'other') { $custom_other_amount.show().append('

$
'); } else { $custom_other_amount.children(".input-group").remove(); $custom_other_amount.hide(); } }); //toggle donation_type_choice var $donation_type_choice = $donation_form.find("#donation_type_choice"); $donation_type_choice.hide(); $("input[name='payment_type']").change(function () { if (this.value == 'recurring') { $donation_type_choice.show(); } else { $donation_type_choice.hide(); } }); // submit form on click $donation_form.on('submit', function (e) { $("#paypal_donate_form-onetime").submit(); var item_name = $donation_form.find("select[name='item_name'] option:selected").val(); var currency_code = $donation_form.find("select[name='currency_code'] option:selected").val(); var amount = $donation_form.find("select[name='amount'] option:selected").val(); var t3 = $donation_form.find("input[name='t3']:checked").val(); if (amount == 'other') { amount = $donation_form.find("#input_other_amount").val(); } // submit proper form now if ($("input[name='payment_type']:checked", $donation_form).val() == 'recurring') { var recurring_form = $('#paypal_donate_form-recurring'); recurring_form.find("input[name='item_name']").val(item_name); recurring_form.find("input[name='currency_code']").val(currency_code); recurring_form.find("input[name='a3']").val(amount); recurring_form.find("input[name='t3']").val(t3); recurring_form.find("input[type='submit']").trigger('click'); } else if ($("input[name='payment_type']:checked", $donation_form).val() == 'one_time') { var onetime_form = $('#paypal_donate_form-onetime'); onetime_form.find("input[name='item_name']").val(item_name); onetime_form.find("input[name='currency_code']").val(currency_code); onetime_form.find("input[name='amount']").val(amount); onetime_form.find("input[type='submit']").trigger('click'); } return false; }); $('#rotate').rotaterator({fadeSpeed:500, pauseSpeed:2500}); });