PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11.3
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / assets / js / security / charitable-hcaptcha.js

charitable-hcaptcha.js in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11.3, at assets/js/security/charitable-hcaptcha.js

62 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var charitable_hcaptcha_onload = function() {
2 ( function( $ ) {
3 var $captcha = $( '.charitable-hcaptcha' ),
4 input = $captcha.parent().find( '[name=hcaptcha_token]' )[0],
5 form = input.form,
6 captcha_id,
7 helper;
8
9 /**
10 * For donation form submissions, execute hcaptcha as part of the
11 * validation process, before firing off the rest of the donation
12 * form processing.
13 */
14 var donation_form_handler = function() {
15 var helper;
16
17 captcha_id = hcaptcha.render( $captcha.attr( 'id' ), {
18 'size': 'invisible',
19 'callback': function( token ) {
20 input.setAttribute( 'value', token );
21 helper.remove_pending_process_by_name( 'hcaptcha' );
22 }
23 } );
24
25 $( 'body' ).on( 'charitable:form:validate', function( event, target ) {
26 helper = target;
27
28 if ( helper.errors.length === 0 ) {
29 helper.add_pending_process( 'hcaptcha' );
30 hcaptcha.execute( captcha_id );
31 }
32 } );
33 }
34
35 /**
36 * For regular form submissions (not the donation form), execute hcaptcha
37 * when the form is submitted.
38 */
39 var default_form_handler = function() {
40 captcha_id = hcaptcha.render( $captcha.attr( 'id' ), {
41 'size': 'invisible',
42 'callback': function( token ) {
43 input.setAttribute( 'value', token );
44 form.submit();
45 }
46 } );
47
48 form.onsubmit = function() {
49 hcaptcha.execute( captcha_id );
50 return false;
51 }
52 }
53
54 if ( form.classList.contains( 'charitable-donation-form' ) ) {
55 donation_form_handler();
56 } else {
57 default_form_handler();
58 }
59 })( jQuery );
60 }
61
62