From c4d44be3ac03d2d1dacf78de6f76ac5b520271d6 Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Thu, 22 Sep 2016 10:39:02 -0400
Subject: [PATCH] Check for grecaptcha at all uses.

---
 themes/bootstrap3/js/common.js | 8 +++++---
 themes/bootstrap3/js/record.js | 4 +++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/themes/bootstrap3/js/common.js b/themes/bootstrap3/js/common.js
index 0380d9ea3b8..dc573cab6c0 100644
--- a/themes/bootstrap3/js/common.js
+++ b/themes/bootstrap3/js/common.js
@@ -163,9 +163,11 @@ function phoneNumberFormHandler(numID, regionCode) {
 
 // Setup captchas after Google script loads
 function recaptchaOnLoad() {
-  var captchas = $('.g-recaptcha:empty');
-  for (var i = 0; i < captchas.length; i++) {
-    captchas[i].dataset.captchaId = grecaptcha.render(captchas[i], captchas[i].dataset);
+  if (grecaptcha) {
+    var captchas = $('.g-recaptcha:empty');
+    for (var i = 0; i < captchas.length; i++) {
+      captchas[i].dataset.captchaId = grecaptcha.render(captchas[i], captchas[i].dataset);
+    }
   }
 }
 
diff --git a/themes/bootstrap3/js/record.js b/themes/bootstrap3/js/record.js
index 2089fdaec96..786bc8937d6 100644
--- a/themes/bootstrap3/js/record.js
+++ b/themes/bootstrap3/js/record.js
@@ -113,7 +113,9 @@ function registerAjaxCommentRecord() {
       refreshCommentList($tab, id, recordSource);
       $(form).find('textarea[name="comment"]').val('');
       $(form).find('input[type="submit"]').button('loading');
-      grecaptcha.reset($(form).find('.g-recaptcha').data('captchaId'));
+      if (grecaptcha) {
+        grecaptcha.reset($(form).find('.g-recaptcha').data('captchaId'));
+      }
     })
     .fail(function addCommentFail(response, textStatus) {
       if (textStatus === 'abort' || typeof response.responseJSON === 'undefined') { return; }
-- 
GitLab