Captcha should steal focus from submit button or body only.

This commit is contained in:
ccd0 2015-11-17 20:10:19 -08:00
parent f0d76d8ef7
commit d6e16c8eac
3 changed files with 5 additions and 5 deletions

View File

@ -95,7 +95,7 @@ Captcha.v1 =
setup: (focus, force) -> setup: (focus, force) ->
return unless @isEnabled and (force or @needed()) return unless @isEnabled and (force or @needed())
@create() @create()
@nodes.input.focus() if focus @nodes.input.focus() if focus and d.activeElement in [QR.nodes.status, d.body]
afterSetup: -> afterSetup: ->
return unless challenge = $.id 'recaptcha_challenge_field_holder' return unless challenge = $.id 'recaptcha_challenge_field_holder'

View File

@ -73,7 +73,7 @@ Captcha.v2 =
setup: (focus, force) -> setup: (focus, force) ->
return unless @isEnabled and (@needed() or force) return unless @isEnabled and (@needed() or force)
@nodes.counter.focus() if focus and not QR.inBubble() @nodes.counter.focus() if focus and d.activeElement in [QR.nodes.status, d.body]
if @timeouts.destroy if @timeouts.destroy
clearTimeout @timeouts.destroy clearTimeout @timeouts.destroy
delete @timeouts.destroy delete @timeouts.destroy
@ -213,7 +213,7 @@ Captcha.v2 =
@captchas = @captchas[i..] @captchas = @captchas[i..]
@count() @count()
$.set 'captchas', @captchas $.set 'captchas', @captchas
@setup(d.activeElement is QR.nodes.status) @setup true
count: -> count: ->
@nodes.counter.textContent = "Captchas: #{@captchas.length}" @nodes.counter.textContent = "Captchas: #{@captchas.length}"

View File

@ -773,7 +773,7 @@ QR =
QR.cooldown.addMute seconds QR.cooldown.addMute seconds
else else
QR.cooldown.addDelay post, seconds QR.cooldown.addDelay post, seconds
QR.captcha.setup (d.activeElement is QR.nodes.status) QR.captcha.setup true
else # stop auto-posting else # stop auto-posting
QR.cooldown.auto = false QR.cooldown.auto = false
QR.status() QR.status()
@ -815,7 +815,7 @@ QR =
QR.close() QR.close()
else else
post.rm() post.rm()
QR.captcha.setup(d.activeElement is QR.nodes.status) QR.captcha.setup true
QR.cooldown.add threadID, postID QR.cooldown.add threadID, postID