Fix captcha not refocusing when QR is autohidden and first try is wrong. #635

This commit is contained in:
ccd0 2015-11-25 19:13:15 -08:00
parent d0dadd2110
commit ba1f466e8f
3 changed files with 9 additions and 3 deletions

View File

@ -95,7 +95,9 @@ Captcha.v1 =
setup: (focus, force) ->
return unless @isEnabled and (force or @needed())
@create()
@nodes.input.focus() if focus
if focus
$.addClass QR.nodes.el, 'focus'
@nodes.input.focus()
afterSetup: ->
return unless challenge = $.id 'recaptcha_challenge_field_holder'

View File

@ -73,7 +73,11 @@ Captcha.v2 =
setup: (focus, force) ->
return unless @isEnabled and (@needed() or force)
@nodes.counter.focus() if focus
if focus
$.addClass QR.nodes.el, 'focus'
@nodes.counter.focus()
if @timeouts.destroy
clearTimeout @timeouts.destroy
delete @timeouts.destroy

View File

@ -769,7 +769,7 @@ QR =
QR.cooldown.addDelay post, seconds
else # stop auto-posting
QR.cooldown.auto = false
QR.captcha.setup(QR.cooldown.auto and d.activeElement is QR.nodes.status)
QR.captcha.setup(QR.cooldown.auto and d.activeElement in [QR.nodes.status, d.body])
QR.cooldown.auto = false if QR.captcha.isEnabled and !QR.captcha.captchas.length
QR.status()
QR.error err