From 68d43b3b79b1569ee72d597087a92e3bb128e918 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 3 May 2015 21:43:39 -0700 Subject: [PATCH] Resize report window to accomodate no-script fallback captcha. --- src/Miscellaneous/Report.coffee | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index b4d8b0793..861906c53 100755 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -1,19 +1,29 @@ Report = + css: ''' + :root:not(.js-enabled) #g-recaptcha { + height: auto; + } + ''' + init: -> return unless /\bmode=report\b/.test(location.search) and match = location.search.match /\bno=(\d+)/ @postID = +match[1] $.ready @ready ready: -> - new MutationObserver(Report.resize).observe d.body, - childList: true - attributes: true - subtree: true + $.addStyle Report.css + if $.hasClass doc, 'js-enabled' + new MutationObserver(-> Report.fit '.gc-bubbleDefault').observe d.body, + childList: true + attributes: true + subtree: true + else + Report.fit '.rules' Report.archive() if Conf['Archive Report'] - resize: -> - return unless bubble = $ '.gc-bubbleDefault' - dy = bubble.getBoundingClientRect().bottom - doc.clientHeight + fit: (selector) -> + return unless el = $ selector + dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8 window.resizeBy 0, dy if dy > 0 archive: ->