podemos-info/participa2

View on GitHub
decidim-module-crowdfundings/app/assets/javascripts/decidim/crowdfundings/contributions.js

Summary

Maintainability
A
0 mins
Test Coverage

$(document).ready(function () {
  var amountSelector = $("input[name='amount_selector']"),
      amountInput = $('#contribution_amount');

  if (amountSelector.length && amountInput.length) {
    amountSelector.change(function() {
      var amount;

      if ($(this).is(":checked")) {
        amount = $(this).val();
        if (amount !== 'other') {
          amountInput.parent().hide();
          amountInput.val(amount);
        } else {
          amountInput.parent().show();
          amountInput.focus();
        }
      }
    });

    amountSelector.change();
  }
});