From 03e37241ab3dba5bc97db72637fc94ead42a722c Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 17 May 2011 02:14:28 -0700 Subject: [PATCH] resize listener --- 4chan_x.js | 11 ++++++++++- script.coffee | 9 +++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index f732486f6..a2a3f9d83 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -2122,7 +2122,8 @@ init: function() { g.callbacks.push(imgExpand.cb.node); imgExpand.dialog(); - return $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"); + $.bind(window, 'resize', imgExpand.resize); + return imgExpand.resize(); }, cb: { node: function(root) { @@ -2225,6 +2226,14 @@ $.bind($('input', controls), 'click', imgExpand.cb.all); delform = $('form[name=delform]'); return $.prepend(delform, controls); + }, + resize: function(e) { + var style; + if (style = $('style[media=chan]', d.head)) { + $.rm(style); + } + style = $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"); + return style.media = 'chan'; } }; NAMESPACE = 'AEOS.4chan_x.'; diff --git a/script.coffee b/script.coffee index fb9930f76..f95a1f6f2 100644 --- a/script.coffee +++ b/script.coffee @@ -1637,8 +1637,8 @@ imgExpand = init: -> g.callbacks.push imgExpand.cb.node imgExpand.dialog() - #FIXME add a resize listener - $.addStyle "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }" + $.bind window, 'resize', imgExpand.resize + imgExpand.resize() cb: node: (root) -> @@ -1711,6 +1711,11 @@ imgExpand = delform = $ 'form[name=delform]' $.prepend delform, controls + resize: (e) -> + $.rm style if style = $ 'style[media=chan]', d.head + style = $.addStyle "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }" + style.media = 'chan' + #main NAMESPACE = 'AEOS.4chan_x.' g =