From c72d5b4c9749efe7ada366d2ea0dad96e4703cac Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 17 Apr 2015 20:40:01 -0700 Subject: [PATCH] Fix focusing on image in Firefox. --- src/General/Main.coffee | 4 +++- src/Posting/Captcha.v2.coffee | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 727fe80f5..1e9547730 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -2,7 +2,9 @@ Main = init: -> if location.hostname is 'www.google.com' type = if location.pathname is '/recaptcha/api/fallback' then 'noscript' else 'v2' - return $.ready -> Captcha[type].initFrame() + return $.ready -> + doc = d.documentElement + Captcha[type].initFrame() g.threads = new SimpleDict() g.posts = new SimpleDict() diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 0c7cf19ba..8dc9c78fb 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -47,7 +47,11 @@ Captcha.v2 = for img in images img.tabIndex = 0 if focus - images[0].focus() + # XXX Image is not focusable at first in Firefox; to be refactored when I figure out why. + $.asap -> + images[0].focus() + d.activeElement is images[0] or not doc.contains images[0] + , -> fixImages() new MutationObserver(fixImages).observe d.body, {childList: true, subtree: true}