Sha256: 74a944ab0be7e4b6c493ac07d8934f5386a855b407bb96f9ba2acc80e3cd86d9

Contents?: true

Size: 894 Bytes

Versions: 1

Compression:

Stored size: 894 Bytes

Contents

jQuery.fn.extend {
  reloadCaptcha: ->
    this[0].empty()
    grecaptcha.render this[0],
      sitekey: decko.recaptchaKey
}

loadCaptcha = (form)->
  if $('.g-recaptcha')[0]
    # if there is already a recaptcha on the page then we don't have to
    # load the recaptcha script
    addCaptcha(this)
  else
    initCaptcha(this)

initCaptcha = (form)->
  recapDiv = $("<div class='g-recaptcha' data-sitekey='#{decko.recaptchaKey}'>" +
    "</div>")
  $(form).children().last().after recapDiv
  recapUri = "https://www.google.com/recaptcha/api.js"

  # renders the first element with "g-recaptcha" class when loaded
  $.getScript recapUri

# call this if the recaptcha script is already initialized (via initCaptcha)
addCaptcha = (form)->
  recapDiv = $('<div class="g-recaptcha"></div>')
  $(form).children().last().after recapDiv
  grecaptcha.render recapDiv,
    sitekey: decko.recaptchaKey

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-1.97.0 mod/machines/lib/javascript/decko_recaptcha.js.coffee