From 8734faf4c2fcfefdca93243544c706f924105713 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 23 Nov 2015 23:39:04 -0800 Subject: [PATCH] Fix captcha going below bottom of page due to delay in iframe loading. --- src/Posting/Captcha.v2.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 1e0e8c75b..14a45faf8 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -135,15 +135,19 @@ Captcha.v2 = setupIFrame: (iframe) -> Captcha.replace.iframe iframe $.addClass QR.nodes.el, 'captcha-open' - if QR.nodes.el.getBoundingClientRect().bottom > doc.clientHeight - QR.nodes.el.style.top = null - QR.nodes.el.style.bottom = '0px' + @fixQRPosition() + $.on iframe, 'load', @fixQRPosition iframe.focus() if d.activeElement is @nodes.counter # XXX Stop Recaptcha from changing focus from iframe -> body -> iframe on submit. $.global -> f = document.querySelector('#qr iframe') f.focus = f.blur = -> + fixQRPosition: -> + if QR.nodes.el.getBoundingClientRect().bottom > doc.clientHeight + QR.nodes.el.style.top = null + QR.nodes.el.style.bottom = '0px' + setupTextArea: (textarea) -> $.one textarea, 'input', => @save true