var currency = $("input[name='currency']");
var frequency = $("input[name='frequency']");
var submit = $("#donate");
- var modal = $("#modal-monthly-suggestions");
var form = $("#donation-form");
// Adjust form to default currency
// Update all amounts
$(".amount").html(value);
-
- // Update suggestions
- $(".monthly-amount-suggestion").each(function (i, element) {
- var factor = $(element).data("factor");
- if (!factor)
- return;
-
- var suggested_amount = Math.floor(value / factor);
-
- // Update value
- $(element).data("amount", suggested_amount);
-
- // Update text on button
- $(element).find(".suggested-amount").html(suggested_amount);
- });
- }
- });
-
- submit.click(function (event) {
- if (frequency.val() == "one-time" && amount.val() > 10) {
- event.preventDefault();
-
- modal.modal("show");
}
});
// Disable all submit buttons after the form has been submitted
form.one("submit", function() {
submit.prop("disabled", true);
- $(".monthly-amount-suggestion").prop("disabled", true);
- });
-
- $(".monthly-amount-suggestion").click(function (event) {
- // Set frequency to monthly
- $("input[name='frequency-selector']").prop("checked", false);
- $("input[name='frequency-selector'][value='monthly']").prop("checked", true);
- frequency.val("monthly");
-
- // Set amount
- var value = $(this).data("amount");
- amount.val(value);
- amount.change();
-
- // Hide the modal
- modal.modal("hide");
});
// Update everything depending on type