Resize report window to accomodate no-script fallback captcha.

This commit is contained in:
ccd0 2015-05-03 21:43:39 -07:00
parent be171ab6d1
commit 68d43b3b79

View File

@ -1,19 +1,29 @@
Report = Report =
css: '''
:root:not(.js-enabled) #g-recaptcha {
height: auto;
}
'''
init: -> init: ->
return unless /\bmode=report\b/.test(location.search) and match = location.search.match /\bno=(\d+)/ return unless /\bmode=report\b/.test(location.search) and match = location.search.match /\bno=(\d+)/
@postID = +match[1] @postID = +match[1]
$.ready @ready $.ready @ready
ready: -> ready: ->
new MutationObserver(Report.resize).observe d.body, $.addStyle Report.css
childList: true if $.hasClass doc, 'js-enabled'
attributes: true new MutationObserver(-> Report.fit '.gc-bubbleDefault').observe d.body,
subtree: true childList: true
attributes: true
subtree: true
else
Report.fit '.rules'
Report.archive() if Conf['Archive Report'] Report.archive() if Conf['Archive Report']
resize: -> fit: (selector) ->
return unless bubble = $ '.gc-bubbleDefault' return unless el = $ selector
dy = bubble.getBoundingClientRect().bottom - doc.clientHeight dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8
window.resizeBy 0, dy if dy > 0 window.resizeBy 0, dy if dy > 0
archive: -> archive: ->