Support selecting images in the image captcha with the space bar in addition to the enter key.

This commit is contained in:
ccd0 2015-06-05 15:09:19 -07:00
parent d7b84817b0
commit 905f6173c1

View File

@ -53,10 +53,14 @@ Captcha.fixes =
if x < 0 if x < 0
return unless $('.rc-controls').contains d.activeElement return unless $('.rc-controls').contains d.activeElement
x = if d.activeElement is verify then 11 else 9 x = if d.activeElement is verify then 11 else 9
return unless dx = {38: 9, 40: 3, 37: 11, 39: 1, 73: 9, 75: 3, 74: 11, 76: 1}[e.keyCode] # Up, Down, Left, Right, I, K, J, L if e.keyCode is 32 and x < 9 # space on image
x = (x + dx) % 12 @images[x].click()
if x is 10 e.preventDefault()
x = if dx is 11 then 9 else 11 e.stopPropagation()
(@images[x] or {9: reload, 11: verify}[x]).focus() else if dx = {38: 9, 40: 3, 37: 11, 39: 1, 73: 9, 75: 3, 74: 11, 76: 1}[e.keyCode] # Up, Down, Left, Right, I, K, J, L
e.preventDefault() x = (x + dx) % 12
e.stopPropagation() if x is 10
x = if dx is 11 then 9 else 11
(@images[x] or {9: reload, 11: verify}[x]).focus()
e.preventDefault()
e.stopPropagation()