Revert "Revert "Remove scroll lock while focus is on captcha.""

This reverts commit 6e56b085cdc95d6b3df474b6df37eeda848a7d5c.

Revert "Revert "Fix captcha centering (broken by 46fd6744da2d4e8e3a2e3916ad6fd4483edc5ddf).""

This reverts commit dd8b3fc0e9c1b2d883a3650c26738c87432b2ad6.
This commit is contained in:
ccd0 2015-11-15 23:58:01 -08:00
parent 7b00c00de3
commit 2f4b81ee7c
3 changed files with 11 additions and 20 deletions

View File

@ -241,9 +241,6 @@ Captcha.v2 =
if $ 'iframe[src^="https://www.google.com/recaptcha/api2/frame"]', node
new MutationObserver(@fixBubble.bind(@, node)).observe node,
attributes: true
# Prevent Recaptcha from keeping focus when popup dismissed.
if overlay = $ 'div[style*="position: fixed;"]', node
$.on overlay, 'click', -> $('#qr iframe')?.blur()
fixBubble: (node) ->
{bottom, right, width} = node.getBoundingClientRect()

View File

@ -153,28 +153,12 @@ QR =
unless QR.inBubble()
QR.hasFocus = d.activeElement and QR.nodes.el.contains(d.activeElement)
QR.nodes.el.classList.toggle 'focus', QR.hasFocus
# XXX Stop unwanted scrolling due to captcha.
if QR.captcha.isEnabled and QR.captcha is Captcha.v2 and !QR.captcha.noscript
if QR.inCaptcha()
QR.scrollY = window.scrollY
$.on d, 'scroll', QR.scrollLock
else
$.off d, 'scroll', QR.scrollLock
inBubble: ->
bubbles = $$ 'iframe[src^="https://www.google.com/recaptcha/api2/frame"]'
d.activeElement in bubbles or bubbles.some (el) ->
getComputedStyle(el).visibility isnt 'hidden' and el.getBoundingClientRect().bottom > 0
inCaptcha: ->
(d.activeElement?.nodeName is 'IFRAME' and QR.nodes.el.contains(d.activeElement)) or (QR.hasFocus and QR.inBubble())
scrollLock: ->
if QR.inCaptcha()
window.scroll window.scrollX, QR.scrollY
else
$.off d, 'scroll', QR.scrollLock
hide: ->
d.activeElement.blur()
$.addClass QR.nodes.el, 'autohide'

View File

@ -1322,8 +1322,18 @@ input.field.tripped:not(:hover):not(:focus) {
#qr .captcha-root {
position: relative;
}
#qr .captcha-container > div > div {
#qr .captcha-container > div {
margin: auto;
width: 304px;
}
/* scrollable with scroll bar hidden; prevents scroll on space press */
:root.blink #qr .captcha-container > div {
overflow: hidden;
}
:root.blink #qr .captcha-container > div > div:first-of-type {
overflow-y: scroll;
overflow-x: hidden;
padding-right: 15px;
}
#qr .captcha-counter {
display: block;