Nicer membership form.
[wolnelektury.git] / src / club / static / club / form.js
diff --git a/src/club/static/club/form.js b/src/club/static/club/form.js
new file mode 100644 (file)
index 0000000..6be8220
--- /dev/null
@@ -0,0 +1,20 @@
+$(function() {
+
+    function update_methods() {
+        $("#payment-form .payment-method").addClass("disabled");
+        $("#payment-form .payment-method input").prop("disabled", true);
+        var plan = $("#payment-form .plan:checked");
+        if (plan.length) {
+            $.each(
+                $("#payment-form .plan:checked").attr('data-methods').trim().split(" "),
+                function(i, slug) {
+                    $("#payment-method-" + slug).removeClass("disabled");
+                    $("#payment-method-" + slug + " input").prop("disabled", false);
+                }
+            );
+        }
+    }
+    update_methods();
+    $("#payment-form .plan").change(update_methods);
+    
+});