PageSourceSearch

https://www.actionagainsthunger.org/app/mu-plugins/gravityformsrecaptcha/js/frontend.js?ver=2.2.2

js actionagainsthunger.org collected 2026-10-02 02:54:07 UTC 15,192 bytes, 316 lines download raw bytes

vendor: 4,231 bytes, lines 1-12
1/******/ (function() { // webpackBootstrap
2/*!****************************!*\
3  !*** ./js/src/frontend.js ***!
4  \****************************/
5function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
6function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
7function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
8function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
9/* global gform, gforms_recaptcha_recaptcha_strings, grecaptcha */
10(function (gform, grecaptcha, strings) {
11  var initScore = function initScore() {
12    var isInitialized = false;
13    document.addEventListener('gform/post_render', function (event) {
14      // Abort if already initialized.
15      if (isInitialized) {
16        return;
17      }
18      isInitialized = true;
19
20      // Executing on AJAX validation.
21      gform.utils.addAsyncFilter('gform/ajax/pre_ajax_validation', /*#__PURE__*/function () {
22        var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(data) {
23          return _regenerator().w(function (_context) {
24            while (1) switch (_context.n) {
25              case 0:
26                _context.n = 1;
27                return execute(data.form);
28              case 1:
29                return _context.a(2, data);
30            }
31          }, _callee);
32        }));
33        return function (_x) {
34          return _ref.apply(this, arguments);
35        };
36      }());
37
38      // Executing recaptcha on form submission or Next button click.
39      gform.utils.addAsyncFilter('gform/submission/pre_submission', /*#__PURE__*/function () {
40        var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(data) {
41          var recaptchaRequired;
42          return _regenerator().w(function (_context2) {
43            while (1) switch (_context2.n) {
44              case 0:
45                recaptchaRequired = data.submissionType === gform.submission.SUBMISSION_TYPE_SUBMIT || data.submissionType === gform.submission.SUBMISSION_TYPE_NEXT;
46                if (!(recaptchaRequired && !data.abort)) {
47                  _context2.n = 1;
48                  break;
49                }
50                _context2.n = 1;
51                return execute(data.form);
52              case 1:
53                return _context2.a(2, data);
54            }
55          }, _callee2);
56        }));
57        return function (_x2) {
58          return _ref2.apply(this, arguments);
59        };
60      }());
61    });
62    maybeDisableBadge();
63  };
64  var initCheckbox = function initCheckbox() {
65    document.addEventListener('gform/post_render', function (event) {
66      renderCheckboxes(event.detail.formId);
67    });
68    document.addEventListener('gfcf/conversational/navigate/next', function (event) {
69      if (!event.detail.target.classList.contains('gfield--type-recaptcha_checkbox')) {
70        return;
71      }
72      var container = event.detail.target.querySelector('.g-recaptcha');
73      renderCheckbox(container);
74    });
75    gform.addAction('gform_post_conditional_logic_field_action', function (formId, action, targetId, defaultValues, isInit) {
76      if (action !== 'show') {
77        return;
78      }
79      var field = gform.utils.getNode(targetId, document, true);
80      if (!field || !field.classList.contains('gfield--type-recaptcha_checkbox')) {
81        return;
82      }
83      var container = field.querySelector('.g-recaptcha');
84      renderCheckbox(container, isInit);
85    });
86    gform.utils.addAsyncFilter('gform/ajax/post_ajax_submission', function (data) {
87      var _data$submissionResul;
88      if (!((_data$submissionResul = data.submissionResult) !== null && _data$submissionResul !== void 0 && (_data$submissionResul = _data$submissionResul.data) !== null && _data$submissionResul !== void 0 && _data$submissionResul.recaptcha_checkbox_response)) {
89        return data;
90      }
91      var input = gform.utils.getNode('input.gfield_recaptcha_response', data.form, true);
92      if (input) {
93        input.value = data.submissionResult.data.recaptcha_checkbox_response;
94      }
95      return data;
96    });
97  };
98
99  /**
100   * @function execute
101   * @description Execute standard or enterprise reCAPTCHA depending on the connection type.
102   *
103   * @since 2.2.0
104   *
105   * @param {HTMLFormElement} form The form element.
106   *
107   * @returns {Promise<void>}
108   */
109  var execute = /*#__PURE__*/function () {
110    var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(form) {
111      return _regenerator().w(function (_context3) {
112        while (1) switch (_context3.n) {
113          case 0:
114            if (form) {
115              _context3.n = 1;
116              break;
117            }
118            return _context3.a(2);
119          case 1:
120            if (!((strings === null || strings === void 0 ? void 0 : strings.key_type) === 'CHECKBOX')) {
121              _context3.n = 2;
122              break;
123            }
124            return _context3.a(2);
125          case 2:
126            if (!(strings.connection_type === 'enterprise')) {
127              _context3.n = 4;
128              break;
129            }
130            _context3.n = 3;
131            return executeEnterpriseRecaptcha(form);
132          case 3:
133            _context3.n = 5;
134            break;
135          case 4:
136            _context3.n = 5;
137            return executeRecaptcha(form);
138          case 5:
139            return _context3.a(2);
140        }
141      }, _callee3);
142    }));
143    return function execute(_x3) {
144      return _ref3.apply(this, arguments);
145    };
146  }();
147
148  /**
149   * @function executeRecaptcha
150   * @description Execute standard reCAPTCHA, setting the token to the hidden input field.
151   *
152   * @since 2.2.0
153   *
154   * @param {HTMLFormElement} form The form element.
155   *
156   * @returns {Promise<void>}
157   */
158  var executeRecaptcha = /*#__PURE__*/function () {
159    var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(form) {
160      var dataInput, token;
161      return _regenerator().w(function (_context4) {
162        while (1) switch (_context4.n) {
163          case 0:
164            dataInput = form.querySelector('.ginput_recaptchav3 .gfield_recaptcha_response'); // If reCAPTCHA fields can't be found, or recaptcha response is already set, don't execute reCAPTCHA.
165            if (!(!dataInput || dataInput.value.length)) {
166              _context4.n = 1;
167              break;
168            }
169            return _context4.a(2);
170          case 1:
171            _context4.n = 2;
172            return grecaptcha.execute(strings.site_key, {
173              action: 'submit'
174            });
175          case 2:
176            token = _context4.v;
177            if (token.length && typeof token === 'string') {
178              dataInput.value = token;
179            }
180          case 3:
181            return _context4.a(2);
182        }
183      }, _callee4);
184    }));
185    return function executeRecaptcha(_x4) {
186      return _ref4.apply(this, arguments);
187    };
188  }();
189
190  /**
191   * @function executeEnterpriseRecaptcha
192   * @description Execute enterprise reCAPTCHA, setting the token to the hidden input field.
193   *
194   * @since 2.2.0
195   *
196   * @param {HTMLFormElement} form The form element.
197   *
198   * @returns {Promise<void>}
199   */
200  var executeEnterpriseRecaptcha = /*#__PURE__*/function () {
201    var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(form) {
202      var dataInput, token, _t;
203      return _regenerator().w(function (_context5) {
204        while (1) switch (_context5.p = _context5.n) {
205          case 0:
206            dataInput = form.querySelector('.ginput_recaptchav3 .gfield_recaptcha_response'); // If reCAPTCHA fields can't be found, or recaptcha response is already set, don't execute reCAPTCHA.
207            if (!(!dataInput || dataInput.value.length)) {
208              _context5.n = 1;
209              break;
210            }
211            return _context5.a(2);
212          case 1:
213            _context5.p = 1;
214            _context5.n = 2;
215            return grecaptcha.enterprise.execute(strings.site_key, {
216              action: 'submit'
217            });
218          case 2:
219            token = _context5.v;
220            if (token.length && typeof token === 'string') {
221              dataInput.value = token;
222            }
223            _context5.n = 4;
224            break;
225          case 3:
226            _context5.p = 3;
227            _t = _context5.v;
228            return _context5.a(2);
229          case 4:
230            return _context5.a(2);
231        }
232      }, _callee5, null, [[1, 3]]);
233    }));
234    return function executeEnterpriseRecaptcha(_x5) {
235      return _ref5.apply(this, arguments);
236    };
237  }();
238  maybeDisableBadge = function maybeDisableBadge() {
239    if (strings.connection_type === 'enterprise') {
240      grecaptcha.enterprise.ready(function () {
241        hideBadge();
242      });
243    } else {
244      grecaptcha.ready(function () {
245        hideBadge();
246      });
247    }
248  };
249  hideBadge = function hideBadge() {
250    if (strings.disable_badge) {
251      var badge = document.querySelector('.grecaptcha-badge');
252      if (badge) {
253        badge.style.visibility = 'hidden';
254      }
255    }
256  };
257  var renderCheckboxes = function renderCheckboxes() {
258    var formId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
259    var prefix = formId ? "#gform_".concat(formId) : '.gform_wrapper';
260    var containers = document.querySelectorAll("".concat(prefix, " .ginput_container_recaptcha_checkbox .g-recaptcha"));
261    if (!containers) {
262      return;
263    }
264    containers.forEach(renderCheckbox);
265  };
266  var renderCheckbox = function renderCheckbox(container) {
267    var _grecaptcha$enterpris;
268    var isLogicInit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
269    if (!(grecaptcha !== null && grecaptcha !== void 0 && (_grecaptcha$enterpris = grecaptcha.enterprise) !== null && _grecaptcha$enterpris !== void 0 && _grecaptcha$enterpris.render) || !container || container.dataset.initialized === 'true' || container.dataset.widgetid || !isLogicInit && isContainerHiddenByParent(container)) {
270      return;
271    }
272
273    // If the iframe is present on the container, something else has already rendered it.
274    if (container.querySelector('iframe')) {
275      container.dataset.initialized = 'true';
276      return;
277    }
278    var widgetId = grecaptcha.enterprise.render(container);
279    if (!Number.isInteger(widgetId)) {
280      return;
281    }
282    container.dataset.initialized = 'true';
283    container.dataset.widgetid = widgetId;
284  };
285  var isContainerHiddenByParent = function isContainerHiddenByParent(container) {
286    // Walk up the DOM from the container to the document root.
287    var node = container.parentElement;
288    while (node) {
289      try {
290        var style = getComputedStyle(node);
291        if ((style === null || style === void 0 ? void 0 : style.display) === 'none') {
292          return true;
293        }
294      } catch (e) {
295        // Some environments may throw for detached nodes; ignore and continue.
296      }
297      node = node.parentElement;
298    }
299    return false;
300  };
301  window.gform = gform;
302  window.gform.recaptchaV3 = {
303    execute: execute
304  };
305
306  // Google requires a simple global function name for the onload callback. It looks like they call using array syntax: i.e. window['gravityformsrecaptchaRenderCheckboxes']();
307  window.gravityformsrecaptchaRenderCheckboxes = renderCheckboxes;
308  if ((strings === null || strings === void 0 ? void 0 : strings.key_type) === 'CHECKBOX') {
309    initCheckbox();
310  } else {
311    initScore();
312  }
313})(window.gform || {}, window.grecaptcha || {}, gforms_recaptcha_recaptcha_strings);
314/******/ })()
315;
316//# sourceMappingURL=frontend.js.map

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.