PageSourceSearch

https://animaltrainingacademy.com/wp-content/mu-plugins/rainmaker/…anti-spam-recaptcha-client.js?ver=3.8.4.0.1

js animaltrainingacademy.com collected 2026-10-04 00:04:46 UTC 3,560 bytes, 150 lines download raw bytes

1/**
2 * Rainmaker - Anti-Spam.
3 *
4 * @package \Rainmaker\AntiSpam
5 * @author  Rainmaker Digital
6 * @license GPL-2.0+
7 * @link    https://www.rainmakerdigital.com/
8 */
9
10/**
11 * RainmakerAntiSpamReCAPTCHAClient
12 *
13 * Helper module to manage reCAPTCHA validation on client side.
14 *
15 * @type {{init, verify}}
16 */
17var RainmakerAntiSpamRecaptchaClient = ( function( $ ) {
18    // noinspection JSValidateTypes
19
20	/**
21	 * Form selector.
22	 */
23    var formSelector = window.RainmakerAntiSpamRecaptchaClientData.formSelector,
24
25    /**
26     * Submit button selector.
27     */
28    submitSelector = window.RainmakerAntiSpamRecaptchaClientData.submitSelector,
29
30    /**
31     * Checkout form.
32     *
33     * @type {*|jQuery|HTMLElement}
34     */
35    $form = $( formSelector ),
36
37	$reCaptchaField = $( '.rainmaker-antispam-recaptcha' ),
38
39    /**
40     * Internal status for submit button.
41     *
42     * @type {boolean}
43     */
44    enabledSubmit = false,
45
46    resizeRecaptcha = function() {
47        $( '.g-recaptcha' ).each( function() {
48            var $widget = $( this ),
49                width   = $widget.parent().width(),
50                scale   = width < 304 ? width / 304 : 1;
51
52            $widget.css({
53                'transform'              : 'scale(' + scale + ')',
54                '-webkit-transform'      : 'scale(' + scale + ')',
55                'transform-origin'       : '0 0',
56                '-webkit-transform-origin': '0 0'
57            });
58        } );
59    },
60
61    init = function() {
62    	if ( ! $reCaptchaField.length ) {
63    		return;
64	    }
65
66        if ( $form.find( submitSelector ).length ) {
67            disableSubmit();
68        }
69
70        $( document.body ).on( 'updated_checkout', enableOrDisableSubmit );
71
72        $( window ).on( 'resize', resizeRecaptcha );
73        resizeRecaptcha();
74    },
75
76    /**
77     * Disable submit button while reCAPTCHA is not solved.
78     */
79    disableSubmit = function() {
80        $form.find( submitSelector ).attr( 'disabled', 'disabled' );
81
82	    enabledSubmit = false;
83    },
84
85    /**
86     * Enable submit button after reCAPTCHA is solved.
87     */
88    enableSubmit = function() {
89	    $form.find( submitSelector ).removeAttr( 'disabled' );
90
91	    enabledSubmit = true;
92    },
93
94    /**
95     * Enable or disable button depending on internal state.
96     */
97    enableOrDisableSubmit = function() {
98        if ( enabledSubmit ) {
99	        enableSubmit();
100	        return;
101        }
102
103        disableSubmit();
104    },
105
106    /**
107     * Disable submit button after reCAPTCHA session expires.
108     */
109    expired = function() {
110      disableSubmit();
111    },
112
113    /**
114     * Enable submit button once reCAPTCHA ins solved.
115     */
116    verify = function() {
117        // noinspection JSUnresolvedVariable
118        if ( ! window.grecaptcha.getResponse() ) {
119            return;
120        }
121
122	   enableSubmit();
123    };
124
125    return {
126        init: init,
127        verify: verify,
128        expired: expired,
129    };
130} )( window.jQuery ),
131
132/**
133 * Function used as callback when reCAPTCHA response changes.
134 *
135 * We can't just use `RainmakerAntiSpamReCAPTCHA.verify` because the reCAPTCHA
136 * JS API wouldn't trigger object functions ¯\_(ツ)_/¯.
137 *
138 * @private
139 */
140_RainmakerAntiSpamReCAPTCHA_verify = RainmakerAntiSpamRecaptchaClient.verify; // jshint ignore:line
141
142/**
143 * Function used as callback when reCAPTCHA verification expires.
144 *
145 * @private
146 */
147_RainmakerAntiSpamReCAPTCHA_expired = RainmakerAntiSpamRecaptchaClient.expired; // jshint ignore:line
148
149// Initialize client-side validation.
150window.jQuery( RainmakerAntiSpamRecaptchaClient.init );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.