From bb7a8e008d373621ae9ced3e3b68ac1fad7336ca Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 17 Apr 2015 20:09:44 -0700 Subject: [PATCH] Resize report window as needed instead of opening it huge at beginning. --- src/Menu/ReportLink.coffee | 3 +-- src/Miscellaneous/Report.coffee | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/Menu/ReportLink.coffee b/src/Menu/ReportLink.coffee index 6942ee0ee..23621a317 100755 --- a/src/Menu/ReportLink.coffee +++ b/src/Menu/ReportLink.coffee @@ -20,6 +20,5 @@ ReportLink = report: -> {url} = ReportLink id = Date.now() - height = if d.cookie.indexOf('pass_enabled=1') >= 0 then 200 else 675 - set = "toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=685,height=#{height}" + set = "toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=685,height=200" window.open url, id, set diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index 5a3284565..7c76af437 100755 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -1,18 +1,34 @@ Report = init: -> - return unless Conf['Archive Report'] and /\bmode=report\b/.test(location.search) - return unless match = location.search.match /\bno=(\d+)/ - postID = +match[1] - Redirect.init() - if @archive = Redirect.to 'report', {boardID: g.BOARD.ID, postID} - $.ready @ready + 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 + Report.archive() if Conf['Archive Report'] + + resize: -> + return unless bubble = $ '.gc-bubbleDefault' + dy = bubble.getBoundingClientRect().bottom - doc.clientHeight + window.resizeBy 0, dy if dy > 0 + + archive: -> + Redirect.init() + return unless url = Redirect.to 'report', {boardID: g.BOARD.ID, postID: Report.postID} + if (message = $ 'h3') and /Report submitted!/.test(message.textContent) $.globalEval 'self.close = function(){};' - location.replace Report.archive + window.resizeTo 685, 320 + location.replace url return link = $.el 'a', - href: Report.archive + href: url textContent: 'Report to fgts' + $.on link, 'click', (e) -> + unless e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 + window.resizeTo 685, 320 $.add d.body, [$.tn(' ['), link, $.tn(']')]