Baitussalam Ambulance Services
Baitussalam Ambulance Services, a project of the non-profit
(function($){
// $('#project').val('85');
$.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('