]> git.ipfire.org Git - ipfire.org.git/commitdiff
donate: Fix endless loop when selecting monthly donations
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Nov 2018 14:42:27 +0000 (14:42 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Nov 2018 14:42:27 +0000 (14:42 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/donate.html

index de05c13d180e95f04d20f7b1cea9073128fe05b2..ffae8b0b9a1e5b35de38286ffc72e664306f1c82 100644 (file)
                                                        <div class="col-12">
                                                                <h6>Frequency</h6>
 
+                                                               <input type="hidden" name="frequency" value="{{ frequency }}">
+
                                                                <div class="custom-control custom-radio custom-control-inline">
-                                                                       <input class="custom-control-input" type="radio" name="frequency" id="frequency-one-time"
+                                                                       <input class="custom-control-input" type="radio" name="frequency-selector" id="frequency-one-time"
                                                                                value="one-time" {% if frequency == "one-time" %}checked{% end %}>
                                                                        <label class="custom-control-label" for="frequency-one-time">{{ _("One Time") }}</label>
                                                                </div>
 
                                                                <div class="custom-control custom-radio custom-control-inline">
-                                                                       <input class="custom-control-input" type="radio" name="frequency" id="frequency-monthly"
+                                                                       <input class="custom-control-input" type="radio" name="frequency-selector" id="frequency-monthly"
                                                                                value="monthly" {% if frequency == "monthly" %}checked{% end %}>
                                                                        <label class="custom-control-label" for="frequency-monthly">{{ _("Monthly") }}</label>
                                                                </div>
 {% block javascript %}
        <script type="text/javascript">
                $(document).ready(function() {
-                       var amount   = $("input[name='amount']");
-                       var currency = $("input[name='currency']");
-                       var submit   = $("#donate");
-                       var modal    = $("#modal-monthly-suggestions");
+                       var amount    = $("input[name='amount']");
+                       var currency  = $("input[name='currency']");
+                       var frequency = $("input[name='frequency']");
+                       var submit    = $("#donate");
+                       var modal     = $("#modal-monthly-suggestions");
 
                        // Adjust form to default currency
                        if (currency.val() == "EUR") {
                                }
                        });
 
-                       // Copy amount when clicking on a radio button
+                       // Copy amount when clicking on a radio buttons
                        $("input[name='amount-selector']").on("change", function() {
                                var value = $(this).val();
                                if (value) {
                                }
                        });
 
+                       // Copy frequency when clicking on a radio buttons
+                       $("input[name='frequency-selector']").on("change", function() {
+                               var value = $(this).val();
+                               if (value) {
+                                       frequency.val(value);
+                               }
+                       });
+
                        amount.on("change keyup mouseup", function() {
                                var value = $(this).val();
 
                        });
 
                        submit.click(function (event) {
-                               var frequency = $("input[name='frequency']").val();
-
-                               if (frequency == "one-time" && amount.val() > 10) {
+                               if (frequency.val() == "one-time" && amount.val() > 10) {
                                        event.preventDefault();
 
                                        modal.modal("show");
 
                        $(".monthly-amount-suggestion").click(function (event) {
                                // Set frequency to monthly
-                               $("input[name='frequency']").prop("checked", false);
-                               $("input[name='frequency'][value='monthly']").prop("checked", true);
+                               $("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");