From f2260ca2ac3dc7060a33eee77f7ccace21e8f6fe Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 21 Dec 2014 18:17:53 -0800 Subject: [PATCH] Destroy captcha when QR is hidden. --- src/Miscellaneous/Keybinds.coffee | 1 - src/Posting/Captcha.v2.coffee | 2 +- src/Posting/QR.coffee | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 6f93f2c67..50d484f37 100755 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -47,7 +47,6 @@ Keybinds = $('.close', notification).click() else if QR.nodes and !QR.nodes.el.hidden if Conf['Persistent QR'] - QR.captcha.destroy() QR.hide() else QR.close() diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 98726a8db..dde05b672 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -37,7 +37,7 @@ Captcha.v2 = captchaCount < @postsCount onNewPost: -> - @setup() + @setup() unless $.hasClass(QR.nodes.el, 'autohide') and !$.hasClass(QR.nodes.el, 'focus') onPostChange: -> @setup() if @postsCount is 0 diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index baa89cba6..0a1150f19 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -133,12 +133,12 @@ QR = focus: -> $.queueTask -> return unless QR.nodes - if d.activeElement and QR.nodes.el.contains d.activeElement - QR.captcha.setup() if $.hasClass(QR.nodes.el, 'autohide') and !$.hasClass(QR.nodes.el, 'focus') - $.addClass QR.nodes.el, 'focus' - else - $.rmClass QR.nodes.el, 'focus' + focus = d.activeElement and QR.nodes.el.contains d.activeElement + if $.hasClass(QR.nodes.el, 'autohide') and focus isnt $.hasClass(QR.nodes.el, 'focus') + QR.captcha[if focus then 'setup' else 'destroy']() + $[if focus then 'addClass' else 'rmClass'] QR.nodes.el, 'focus' hide: -> + QR.captcha.destroy() d.activeElement.blur() $.addClass QR.nodes.el, 'autohide' QR.nodes.autohide.checked = true @@ -560,7 +560,7 @@ QR = QR.cooldown.init() QR.captcha.init() $.add d.body, dialog - QR.captcha.setup() + QR.captcha.setup() unless Conf['Persistent QR'] and Conf['Auto Hide QR'] # Create a custom event when the QR dialog is first initialized. # Use it to extend the QR's functionalities, or for XTRM RICE.