-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdonate.html
1461 lines (1282 loc) · 61.4 KB
/
donate.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{% extends "./wrapper.html" %}
{% load actionkit_tags %}
{% block body_extra_classes %}{% if page.payment_processor_information.is_quickdonate %}actionkit-donate-qd {% endif %}{{ block.super }}{% endblock %}
{% block content %}
<form id="act" name="act" class="{{ templateset.custom_fields.donation_steps }}" method="POST" action="/act/" accept-charset="utf-8">
<input type="hidden" name="page" value="{{ page.name }}">
<input type="hidden" name="orig_akid" value="{{ akid }}">
<div class="ak-grid-row">
<div class="ak-grid-col ak-grid-col-12-of-12">
<h2>{{ page.title }}</h2>
</div>
</div>
<div class="ak-grid-row">
<div class="ak-grid-col ak-grid-col-4-of-12">
{% if page.custom_fields.featured_image %}
<img class="ak-featured-img" src="{{page.custom_fields.featured_image}}">
{% endif %}
<div>{% include "./progress_meter.html" %}</div>
{% include_tmpl form.ask_text %}
</div>
<div class="ak-grid-col ak-grid-col-8-of-12">
<div class="ak-field-box">
<!--Add .ak-donate-three-step for three-step-->
<div class="ak-donate-menu ak-donate-three-step-visible">
<label class="ak-donate-step ak-donate-step-1">
<span>Amount</span>
<input type="radio" id="ak-donate-step-1" name="ak-donate-step" value="1" checked="checked">
<div class="ak-step-number">1</div>
</label>
<label class="ak-donate-step ak-donate-step-2">
<span>Name</span>
<input type="radio" id="ak-donate-step-2" name="ak-donate-step" value="2">
<div class="ak-step-number">2</div>
</label>
<label class="ak-donate-step ak-donate-step-3">
<span>Finish</span>
<input type="radio" id="ak-donate-step-3" name="ak-donate-step" value="3">
<div class="ak-step-number">3</div>
</label>
</div>
<div id="ak-donation-details" class="xak-errs-below">
<div id="ak-product-list" class="ak-donate-area-step-1 ak-errs-below">
{% if has_products %}
<table class="ak-margin-bottom-1">
<thead>
<tr>
<th class="ak-product-details-header ak-small-header">Product</th>
<th class="ak-product-amount-header ak-small-header">Price</th>
<th class="ak-product-quantity-header ak-small-header">Quantity</th>
<th class="ak-product-quantity-header ak-small-header">Total</th>
</tr>
</thead>
<tbody>
{% for product in products %}
<tr>
<td class="ak-product-details">
<div class="ak-product-name">{{ product.name }}</div>
{% if product.desc %}<div class="ak-product-description">{{ product.desc }}</div>{% endif %}
</td>
<td class="ak-product-amount">
<span id="product_{{ product.id }}_price" data-price="{{ product.price }}">
{% if product.price == 0 %}
FREE!
{% else %}
<span class="ak-currency-sym">{{ page.currency_sym }}</span>{{ product.price|commify }}
{% endif %}
</span>
</td>
<td class="ak-product-quantity">
{% if product.max == 1 %}
<input type="checkbox" value="1" name="product_{{ product.id }}" id="product_{{ product.id }}" data-product="{{ product.id }}" class="ak_product_inputs">
{% else %}
<input type="number" min="0" max="{{ product.max }}" onvalidate="return validate_product_count(this)" name="product_{{ product.id }}" id="product_{{ product.id }}" size="2" data-product="{{ product.id }}" class="ak_product_inputs">
{% endif %}
</td>
<td class="ak-product-subtotal">
<span class="ak-currency-sym">{{ page.currency_sym }}</span><span class="ak_product_subtotal_{{ product.id }}"></span>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<p class="ak-donation-subtotal ak-align-right">
<label class="ak-small-header">Product Total</label>
<strong><span class="ak-currency-sym">{{ page.currency_sym }}</span></strong>
<span id="ak-donation-subtotal-amount"></span>
</label>
</p>
{% endif %}
</div><!--product-list-->
<div id="ak-candidate-list" class="ak-donate-area-step-1 ak-errs-below">
{% if has_candidates %}
<table>
<thead>
<tr>
<th id="ak-candidate-details-header">Candidate</th>
<th> </th>
<th id="ak-candidate-amount-header">Donation</th>
</tr>
</thead>
<tbody>
{% for candidate in candidates %}
<tr>
<td class="ak-candidate-details">
{% if candidate.portrait_url %}
<img class="ak-candidate-portrait" src="{{ candidate.portrait_url }}">
{% endif %}
</td>
<td class="ak-candidate-name">
<div>{{ candidate.name }}</div>
<p>{{ candidate.desc|safe }}</p>
</td>
<td class="ak-candidate-amount ak-align-right">
<span class="ak-currency-sym">{{ page.currency_sym }}</span><input type="text" name="candidate_{{ candidate.id }}" id="candidate_{{ candidate.id }}" size="2" class="ak_candidate_inputs">
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% if has_products %}
<h4 class="ak-donate-area-step-1">Donation (Optional)</h4>
{% endif %}
<div id="ak-amount-list" class="ak-err-above ak-donate-area-step-1">
{% if show_currency_select %}
{% comment %}
Only English currency names are currently available from
ActionKit.
When translating your templatesets, you could partly or
entirely translate the list and include that as plain
HTML here, or remove the ' - {{currency.name}}' so only
the ISO abbreviation shows.
{% endcomment %}
<div class="ak-currency">
<label>
<select name="currency">
{% for code in "USD,GBP,CAD,AUD,EUR"|split:"," %}
{% with currency_info|get:code as currency %}
<option value="{{code}}">{{code}} - {{currency.name}}</option>
{% endwith %}
{% endfor %}
<option value="" disabled>──────────</option>
{% for code, currency in currency_info.items %}
<option value="{{code}}">{{code}} - {{currency.name}}</option>
{% endfor %}
</select>
</label>
</div>
{% elif page.derived.use_account_switcher %}
<div id="ak-multi-currency">
<label class="ak-label-above ak-margin-none" for="amount">Secure Donation:</label>
<span class="ak-currencies">
{% for currency, account_name in page.derived.currency_accounts %}
<span class="ak-currency">
<input type="radio" {% if forloop.first %}checked{% endif %} name="payment_account" id="id_currency_{{currency}}" value="{{account_name}}">
<label for="id_currency_{{currency}}">{{currency}}</label>
</span>
{% endfor %}
</span>
</div>
{% endif %}
<div class="ak-amount-wrapper">
{% for row in amounts|columns:3 %}
<ul class="ak-unstyled">
{% for amount in row %}
{% if amount == "other" %}
<li id="ak-other-amount-container">
<noscript><input type="radio" value="" class="ak-amount-radio-button" name="amount"></noscript>
<label for="ak-other-amount-field" class="ak-btn">
<span class="ak-currency-sym">{{ page.currency_sym }}</span> <input type="text" id="ak-other-amount-field" name="amount_other" size="3" >
</label>
</li>
{% else %}
<li>
<label for="id_amount_{{amount}}" class="ak-btn">
<span class="ak-currency-sym"></span><input type="radio" id="id_amount_{{amount}}" value="{{ amount }}" class="ak-amount-radio-button" name="amount" {% if not args.amount_other and amount == default_amount %}checked{% endif %}>{{ page.currency_sym }}{{ amount|commify }}
</label>
</li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
</div>
</div>
<div id="ak-donation-total-div"></div>
<script type="text/ak-template" for="ak-donation-total-div">
[% if (has_products || has_candidates) { %]
<p class="ak-donation-total ak-donate-area-step-1">
<label for="amount">
Total Amount
</label>
<span class="ak-currency-sym">{{ page.currency_sym }}</span><span class="ak-donation-total-amount"></span>
</p>
[% }
setTimeout(update_total, 0);
%]
</script>
{% if not has_products %}
{% if allow_monthly %}
<div id="ak-recurring-type" class="ak-donate-area-step-1">
<span>
<input type="radio" name="donation_type" id="id_donation_type_single" value="single" checked>
<label for="id_donation_type_single"> One-Time</label>
</span>
<span>
<input type="radio" name="donation_type" id="id_donation_type_recurring" value="recurring">
<label for="id_donation_type_recurring"> Monthly</label>
</span>
</div>
{% else %}
<div id="ak-recurring-type"></div>
<input type="hidden" name="donation_type" value="single">
{% endif %}
{% endif %}
<div id="ak-donation-contact" class="ak-styled-fields ak-donate-area-step-2 ak-errs-below ak-margin-top-1">
<ul id="ak-errors"></ul>
<div style="display: none"><div id="known_user">
Not <span id="known_user_name"></span>? <a href="?" onclick="return actionkit.forms.logOut()">Click here.</a>
</div></div>
<div id="unknown_user"></div>
<h4 class="{% if not has_shippable_products %}ak-donate-three-step-hidden{% endif %}">Billing Address</h4>
<div class="ak-labels-overlaid ak-errs-below test2">
{% if page.accept_ach %}
<div>
<label for="id_first_name">First Name</label>
<input id="id_first_name" type="text" name="first_name">
<input type="hidden" name="required" value="first_name">
</div>
<div>
<label for="id_last_name">Last Name</label>
<input id="id_last_name" type="text" name="last_name">
<input type="hidden" name="required" value="last_name">
</div>
{% else %}
<div>
<label for="id_name">Name</label>
<input id="id_name" type="text" name="name">
</div>
{% endif %}
<div>
<label class="required" for="id_email">Email</label>
<input id="id_email" type="text" name="email">
</div>
{% if has_shippable_products %}
<div>
<label for="id_address1">Billing address line 1</label>
<input id="id_address1" type="text" name="address1">
</div>
<div>
<label for="id_address2">Billing address line 2 (optional)</label>
<input id="id_address2" type="text" name="address2">
</div>
{% else %}
<div>
<label for="id_address1">Billing address</label>
<input id="id_address1" type="text" name="address1">
</div>
<div>
<label for="id_address2">Billing address line 2 (optional)</label>
<input id="id_address2" type="text" name="address2">
</div>
{% endif %}
<div>
<label for="id_city">City</label>
<input id="id_city" type="text" name="city">
</div>
<div class="ak-errs-below">
<div class="ak-us-billing-fields">
<input type="hidden" name="required" value="state">
<label for="id_state">State</label>
{% include "./state_select.html" %}
</div>
<div class="ak-us-billing-fields">
<input type="hidden" name="required" value="zip">
<label for="id_zip">Zip</label>
<input id="id_zip" type="text" name="zip" maxlength="5" size="5">
</div>
</div>
{% if page.allow_international %}
<div class="ak-errs-below" class="ak-intl-billing-fields">
<div>
<label for="id_region">Region</label>
<input id="id_region" type="text" name="region" size="20">
</div>
<div>
<label for="id_postal">Postal Code</label>
<input id="id_postal" type="text" name="postal" size="10">
</div>
</div>
<div>
<label for="id_country">Country</label>
{% include "./country_select.html" %}
</div>
{% include "./privacy.html" %}
{% else %}
<input type="hidden" name="country" value="United States">
{% endif %}
</div> <!-- labels overlaid (billing address) -->
{% if has_candidates %}
<p class="ak-label-above" id="ak-occ-emp-why">
For political donations, we're required to ask for your employer and occupation:
</p>
<div class="ak-labels-overlaid ak-errs-below">
<div>
<label for="action_employer">Employer</label>
<input id="action_employer" type="text" name="action_employer" size="20">
<input type="hidden" name="required" value="action_employer">
</div>
<div>
<label for="action_occupation">Occupation</label>
<input id="action_occupation" type="text" name="action_occupation" size="20">
<input type="hidden" name="required" value="action_occupation">
</div>
</div>
{% endif %}
{% if has_shippable_products %}
<div id="ak-shipping-address">
<h4>Shipping Address</h4>
{% with "shipping_" as input_name_prefix %}
<div class="ak-margin-1">
<label for="ak-shipping-same" class="ak-small">
<input id="ak-shipping-same" type="checkbox" name="shipping_same" value="1" checked>
Ship to billing address
</label>
</div>
<div id="ak-shipping-fields" class="ak-labels-overlaid ak-errs-below" style="display: none">
<div>
<label for="id_shipping_address1">Shipping address line 1</label>
<input id="id_shipping_address1" type="text" name="shipping_address1">
</div>
<div>
<label for="id_shipping_address2">Shipping address line 2 (optional)</label>
<input id="id_shipping_address2" type="text" name="shipping_address2">
</div>
<div>
<label for="id_shipping_city">Shipping city</label>
<input id="id_shipping_city" type="text" name="shipping_city">
</div>
<div class="ak-us-shipping-fields">
<div>
<label for="id_shipping_state">Shipping state</label>
{% include "./state_select.html" %}
</div>
<div>
<label for="id_shipping_zip">Shipping ZIP</label>
<input id="id_shipping_zip" type="text" name="shipping_zip" maxlength="5" size="5">
</div>
</div>
{% if page.allow_international %}
<div class="ak-intl-shipping-fields">
<div>
<label for="id_shipping_region">Shipping region</label>
<input id="id_shipping_region" type="text" name="shipping_region" size="20">
</div>
<div>
<label for="id_shipping_postal">Shipping postal Code</label>
<input id="id_shipping_postal" type="text" name="shipping_postal" size="10">
</div>
</div>
<div>
<label for="id_shipping_country">Shipping country</label>
{% include "./country_select.html" %}
</div>
{% endif %}
</div> <!-- labels overlaid -->
{% endwith %}
</div> <!-- shipping address -->
{% endif %}
</div> <!-- donation contact -->
<div class="ak-labels-above ak-styled-fields ak-donate-area-step-3 ak-errs-below">
<h4>Payment Information</h4>
{% if page.accept_ach %}
<div id="ak-accept-ach-payement">
<div id="ak-fieldbox-payment_method">
<input type="radio" id="ak_payment_method_cc" name="payment_method" value="cc" checked>
<label for="ak_payment_method_cc">Credit Card</label>
<br>
<input type="radio" id="ak_payment_method_ach" name="payment_method" value="ach">
<label for="ak_payment_method_ach">US Bank Transfer</label>
</div>
{% endif %}
<div class="cc_payment_options">
<div id="ak-fieldbox-card_num" class="">
<label for="ak-card_num">Credit Card #</label>
<input type="hidden" name="required" value="card_num" id="ak-card_num-required">
<div id="ak-card_num-hosted" class="hosted-field"></div>
<input id="ak-card_num" type="text" name="card_num">
</div>
<div class="ak-err-below">
<div id="ak-fieldbox-exp_date">
<input type="hidden" name="required" value="exp_date_month" id="ak-exp_date_month-required">
<label for="ak-exp_date_month">Expiration Date</label>
<div id="ak-exp_date-hosted" class="hosted-field"></div>
<select id="ak-exp_date_month" type="text" name="exp_date_month">
<option value="">MM</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<input type="hidden" name="required" value="exp_date_year" id="ak-exp_date_year-required">
<select id="ak-exp_date_year" type="text" name="exp_date_year">
<option value="">YYYY</option>
{% for year in exp_years %}
<option value="{{ year.two }}">{{ year.four }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="ak-err-below">
<div id="ak-fieldbox-card_code">
<input type="hidden" name="required" value="card_code" id="ak-card_code-required">
<label for="ak-card_code">Verification Code</label>
<div id="ak-card_code-hosted" class="hosted-field"></div>
<input id="ak-card_code" type="text" name="card_code" size="4">
</div>
</div>
</div>
{% if page.accept_ach %}
<div class="ach_payment_options">
<div id="ak-fieldbox-ach_method">
<hr>
<h4>US Bank Transfer</h4>
<input type="radio" id="ak_ach_method_account_number" name="ach_method" value="account_number" checked>
<label for="ak_ach_method_account_number">Account Number</label>
<br>
<input type="radio" id="ak_ach_method_bank_login" name="ach_method" value="bank_login">
<label for="ak_ach_method_bank_login">Bank Login</label>
</div>
<div class="account_number_options">
<div class="ak-err-below">
<div id="ak-fieldbox-routing_number">
<label for="ak-routing_number">Routing Number</label>
<input id="ak-routing_number" type="text" name="routing_number" size="9">
</div>
</div>
<div class="ak-err-below">
<div id="ak-fieldbox-bank_account">
<label for="ak-bank_account">Bank Account</label>
<input id="ak-bank_account" type="text" name="bank_account" size="17">
</div>
</div>
<div class="ak-err-below">
<div id="ak-fieldbox-account_type">
<label for="ak-account_type">Account Type</label>
<select id="ak-account_type" type="text" name="account_type">
<option value="checking">checking</option>
<option value="savings">savings</option>
</select>
</div>
</div>
</div>
<div class="ak-err-below">
<div id="ak-fieldbox-ownership_type">
<label for="ak-ownership_type">Ownership Type</label>
<select id="ak-ownership_type" type="text" name="ownership_type">
<option value="personal">personal</option>
<option value="business">business</option>
</select>
</div>
</div>
<div class="ak-err-below">
<div id="ak-fieldbox-business_name">
<label for="ak-business_name">Business Name</label>
<input id="ak-business_name" type="text" name="business_name">
</div>
</div>
<div id="ak-fieldbox-mandate">
<div id="ak-mandate">By clicking "Donate", I authorize Braintree, a service of PayPal, on behalf of <span id="ak-client-name">{% filter ak_text:"org_name" %}{% client_name %}{% endfilter %}</span> (i) to verify my bank account information using bank information and consumer reports and (ii) to debit my bank account.</div>
</div>
</div>
</div>
{% endif %}
</div><!--ak-styled-fields-->
<button class="ak-donate-three-step-visible" id="ak-continue-button">Continue</button>
{% if page.payment_processor_information.init_submit_disabled %}
{% comment %}
For pages that use Braintree, the submit button will be enabled by javascript.
{% endcomment %}
<button disabled="true" type="submit" class="ak-submit-button ak-donate-area-step-3">Donate <span class="ak-currency-sym">{{ page.currency_sym }}</span><span class="ak-donation-total-amount"></span></button>
<noscript>
<p>
<b>JavaScript is required</b> so this page
can securely submit your donation.
</p>
</noscript>
{% else %}
<button type="submit" class="ak-submit-button ak-donate-area-step-3">Donate <span class="ak-currency-sym">{{ page.currency_sym }}</span><span class="ak-donation-total-amount"></span></button>
{% endif %}
{% if show_paypal %}
<div class="ak-payment-options ak-margin-bottom-1 ak-donate-area-step-2">
<input type="hidden" name="paypal" value="0" id="ak-pay-by-paypal">
Or check out with
<button type="submit" id="ak-paypal-button" class="ak-inline ak-paypal-button"><img src="/media/modern/paypal-logo-1.svg"></button>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</form>
{% endblock %}
{% block script_additions %}
<script language="javascript">
//<!--
function clear_radio_buttons() {
$('input.ak-amount-radio-button').prop('checked', false);
}
function clear_other() {
$('#ak-other-amount-field').val("");
}
function product_info(id) {
var product_element = $("#product_" + id),
quantity = 0,
price = parseFloat($("#product_" + id + "_price").data("price"));
if (product_element.is(':checkbox')) {
if (product_element.is(':checked')) {
quantity = 1;
}
} else if (product_element.val() != "") {
quantity = parseInt(product_element.val());
}
return {
'id': id,
'price': price,
'quantity': quantity,
'subtotal': (price * quantity)
}
}
function update_total() {
var total = 0.0;
product_infos().forEach(function(info) {
total += info.subtotal;
});
$('.ak_candidate_inputs').each(function (i) {
// check that amount is a valid amount
var amount = this.value;
if (amount.length == 0 || ! /^[\d,]*(\.\d{1,2})?$/.test(amount)) {
return;
}
total += parseFloat(amount.replace(',', ''));
});
// look for checked off donation amounts
var amount_checked = $('input:radio[name=amount]:checked').val();
if (amount_checked) {
total += parseFloat(amount_checked);
} else {
// or other amounts
var other = $('#ak-other-amount-field').val();
if (typeof other !== "undefined" &&
other.length && /^[\d,]*(\.\d{1,2})?$/.test(other))
total += parseFloat(other.replace(',', ''));
}
var new_total = total == 0 ? "" : "" + total.toFixed(2);
$('.ak-donation-total-amount').html(new_total);
return total;
}
$(function() {
$('.ak_product_inputs').on('change blur', update_total);
$('.ak_candidate_inputs').on('change blur', update_total);
$('.ak-amount-radio-button').on('change blur', update_total)
.on('click', clear_other)
.on('click', update_total);
$('#ak-other-amount-field').on('change blur', update_total)
.on('click keyup', clear_radio_buttons)
.on('click', update_total);
$('input[type=radio][name=payment_method]').change(function() {
if (this.value == 'ach') {
$('.ach_payment_options').show();
$('.cc_payment_options').hide();
} else {
$('.ach_payment_options').hide();
$('.cc_payment_options').show();
}
});
$('input[type=radio][name=ach_method]').change(function() {
if (this.value == 'account_number') {
$('.account_number_options').show();
} else {
$('.account_number_options').hide();
}
});
$('#ak-ownership_type').change(function() {
if (this.value == 'business') {
$('#ak-fieldbox-business_name').show();
} else {
$('#ak-fieldbox-business_name').hide();
}
});
});
/* Amount buttons */
function highlight_selected_amount_button() {
$('label.ak-radio-checked').removeClass('ak-radio-checked');
$(this).closest('label').addClass('ak-radio-checked');
}
$(function() {
$('input[name="amount"]').on(
'click', highlight_selected_amount_button);
$('input[name="amount_other"]').on(
'click change', highlight_selected_amount_button);
// Make sure label is highlighted if an amount is pre-selected
highlight_selected_amount_button.call(
$('input[name="amount"]:checked').get(0) //||
//$('input[name="amount_other"]').get(0)
);
});
/* Currency symbols */
function redraw_currency_symbol() {
var id = $('input[id^=id_currency_]:checked, option[id^=id_currency_]:selected').attr('id');
var iso_code_match = /([A-Z][A-Z][A-Z])$/.exec(id);
if ( ! iso_code_match ) {
return
}
var iso_code = iso_code_match[1];
var currency_sym = actionkit.utils.currencySymbols[iso_code];
$('.ak-currency-sym').text( currency_sym || '' );
}
$(function() {
$('input[id^=id_currency_], select[name="currency"], select[name="payment_account"]').on('change', redraw_currency_symbol);
redraw_currency_symbol();
});
var address_fields = [
'address1', 'address2', 'city', 'state', 'zip'
{% if page.allow_international %}, 'postal', 'region', 'country'{% endif %}
];
{% if page.allow_international %}
function country_change() {
if ( $('#id_country').val() == 'United States' ) {
$('.ak-us-billing-fields').show();
$('.ak-intl-billing-fields').hide();
} else {
$('.ak-us-billing-fields').hide();
$('.ak-intl-billing-fields').show();
}
sync_to_shipping();
}
function shipping_country_change() {
if ( $('#id_shipping_country').val() == 'United States' ) {
$('.ak-us-shipping-fields').show();
$('.ak-intl-shipping-fields').hide();
} else {
$('.ak-us-shipping-fields').hide();
$('.ak-intl-shipping-fields').show();
}
}
$( function () {
$('#id_country').on('change blur', country_change);
$('#id_shipping_country').on('change blur', shipping_country_change);
country_change();
shipping_country_change();
} );
{% endif %}
function toggle_shipping() {
if ( $('#ak-shipping-same').prop("checked") ) {
sync_to_shipping();
$('#ak-shipping-fields').slideUp();
if($('.ak-shipping-required').length)
$('.ak-shipping-required').remove();
} else {
clear_shipping();
$('#ak-shipping-fields').slideDown();
$('#ak-shipping-fields').append(
"<input type='hidden' name='required' value='shipping_address1' class='ak-shipping-required'>");
$('#ak-shipping-fields').append(
"<input type='hidden' name='required' value='shipping_city' class='ak-shipping-required'>");
$('#ak-shipping-fields').append(
"<input type='hidden' name='required' value='shipping_state' class='ak-shipping-required'>");
$('#ak-shipping-fields').append(
"<input type='hidden' name='required' value='shipping_zip' class='ak-shipping-required'>");
}
}
function clear_shipping(e) {
var i, field, ship_field;
for (i in address_fields) {
field = address_fields[i];
ship_field = $('#id_shipping_' + field);
ship_field.val("").change().prop("readonly", false);
}
{% if page.allow_international %}
shipping_country_change();
{% endif %}
}
function sync_to_shipping(e) {
if ( ! $('#ak-shipping-same').prop("checked") ) {
return;
}
var i, field, ship_field, bill_value;
for (i in address_fields) {
field = address_fields[i];
ship_field = $('#id_shipping_' + field);
bill_value = $('#id_' + field).val();
ship_field.val(bill_value).change().prop("readonly", true);
}
{% if page.allow_international %}
shipping_country_change();
{% endif %}
}
$( function () {
$('#ak-shipping-same').on('change', toggle_shipping);
toggle_shipping();
$('#id_address1, #id_address2, #id_city, #id_state, #id_zip, ' +
'#id_region, #id_postal').on('change blur', sync_to_shipping);
} );
var three_step_initialized = 0;
function three_step_reveal() {
var current_step = $('input[name="ak-donate-step"]:checked').val();
if ( current_step != "2" && current_step != "3" ) {
current_step = "1"
}
var speed = three_step_initialized ? 1 : 400;
if ( current_step == "1" ) {
$('.ak-donate-area-step-2, .ak-donate-area-step-3').hide();
$('.ak-donate-area-step-1, #ak-continue-button').fadeIn( speed );
} else if ( current_step == "2" ) {
$('.ak-donate-area-step-1, .ak-donate-area-step-3').hide();
$('.ak-donate-area-step-2, #ak-continue-button').fadeIn( speed,
focus_field_if_blank( $('#id_name') )
);
} else if ( current_step == "3" ) {
$('.ak-donate-area-step-1, .ak-donate-area-step-2, #ak-continue-button').hide();
$('.ak-donate-area-step-3').fadeIn( speed,
focus_field_if_blank( $('#ak-card_num') )
);
}
}
function focus_field_if_blank ( field_elt ) {
return ( function () {
if ( ! field_elt.val() ) {
field_elt.focus()
}
} )
}
var step_has_errors = false;
function three_step_advance() {
// trigger validation on the step we're leaving
var current_step = $('input[name="ak-donate-step"]:checked').val();
validate_step(current_step);
if (!step_has_errors) {
$('input[name="ak-donate-step"]:checked').closest('label').
next('label').find('input[type="radio"]').prop('checked', true);
three_step_reveal();
}
}
function three_step_goto(next) {
// trigger validation on the step we're leaving
var current_step = $('input[name="ak-donate-step"]:checked').val();
// skip validation if we're going backwards
if (current_step < next) {
validate_step(current_step);
}
// can't skip over a step unless it's already been completed
if ( (! step_has_errors) && (current_step == 1) && (next == 3) ) {
validate_step(2);
if ( step_has_errors ) {
$('#ak-donate-step-2').prop('checked', true);
three_step_reveal();
return;
}
}
// allow the user to go back even if there are errors
if (current_step > next || !step_has_errors) {
$('#ak-donate-step-' + next).prop('checked', true);
three_step_reveal();
}
}
function validate_product_count ( field ) {
var product_count = field.value;
if (product_count == "" || product_count == "0") {
return true
}
product_count = parseInt( product_count );
var product_max = parseInt( $(field).attr('max') );
if ( product_max && product_count > product_max ) {
var err_msg = actionkit.forms.errorMessage('product:max');
err_msg = err_msg.replace("{0}", product_max);
return err_msg
}
return true
}
/* used to limit AK built-in validation to particular fields by step */
var doing_step_validation = false;
var validate_fields = [];
function validate_step(step) {
step_has_errors = false;
if (step == "1") {
validate_fields = ["amount"];
} else if (step == "2") {
validate_fields = ["email", "first_name", "last_name", "name",
"address1", "address2", "city", "state", "zip",
"country", "region", "postal",
"shipping_address1", "shipping_address2",
"shipping_city", "shipping_state",
"shipping_zip", "shipping_country",
"shipping_region", "shipping_postal",
"privacy"
{% if has_candidates %},"action_employer", "action_occupation"{% endif %}];
} else {
validate_fields = ["card_num", "card_code",
"exp_date_year", "exp_date_month", "exp_date"];
}
doing_step_validation = true;
actionkit.forms.validate();
doing_step_validation = false;
if (step == "1") {
step_has_errors = step_1_validation();
}
if (step == "2" && !step_has_errors) {
step_has_errors = step_2_validation();
}
if (step == "3" && !step_has_errors) {
step_has_errors = step_3_validation();
}
}
function do_validate_credit_card() {
if (actionkit.donations && actionkit.donations.skip_cc_validation) {
return false;
}
return true;
}
function step_3_validation() {
var step_has_errors = false;
if (!actionkit.errors) {
actionkit.errors = {};
}
var payment_method = actionkit.form["payment_method"] && actionkit.form["payment_method"].value;
if (payment_method == 'ach') {
if ($('#ak-ownership_type').val() == 'business') {
if (!$('#ak-business_name').val()) {
actionkit.errors['business_name:missing'] = actionkit.forms.errorMessage('business_name:missing');
step_has_errors = true;
}
}
var ach_method = actionkit.form["ach_method"] && actionkit.form["ach_method"].value;
if (ach_method != 'bank_login') {
var bank_account = $('#ak-bank_account').val();
if (!bank_account) {
actionkit.errors['bank_account:missing'] = actionkit.forms.errorMessage('bank_account:missing');
step_has_errors = true;
} else if (!valid_bank_account_number(bank_account)) {
actionkit.errors['bank_account:invalid'] = actionkit.forms.errorMessage('bank_account:invalid');
step_has_errors = true;
}
var routing_number = $('#ak-routing_number').val();
if (!routing_number) {
actionkit.errors['routing_number:missing'] = actionkit.forms.errorMessage('routing_number:missing');
step_has_errors = true;
} else if (!valid_bank_routing_number(routing_number)) {
actionkit.errors['routing_number:invalid'] = actionkit.forms.errorMessage('routing_number:invalid');
step_has_errors = true;
}
}
} else {
if (!do_validate_credit_card()) {
return step_has_errors;
}
if (!valid_credit_card($('#ak-card_num').val())) {
actionkit.errors['card_num:invalid'] = actionkit.forms.errorMessage('card_num:invalid');
step_has_errors = true;
}
if (!valid_credit_card_code($('#ak-card_code').val())) {
actionkit.errors['card_code:invalid'] = actionkit.forms.errorMessage('card_code:invalid');
step_has_errors = true;
}
}
if (step_has_errors) {
actionkit.forms.onValidationErrors(actionkit.errors);
}
return step_has_errors;
}