From 032374911c1cefc77e8155581029861a08db7013 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Wed, 20 Jul 2011 20:14:25 +0200 Subject: [PATCH] Simpler imgExpand.resize(). --- 4chan_x.user.js | 10 +++------- script.coffee | 9 ++++----- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 491ff86c1..580a8c652 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2506,7 +2506,8 @@ g.callbacks.push(imgExpand.node); imgExpand.dialog(); $.bind(window, 'resize', imgExpand.resize); - return imgExpand.resize(); + imgExpand.style = $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"); + return imgExpand.style.className = 'height'; }, node: function(root) { var a, thumb; @@ -2616,12 +2617,7 @@ return $.prepend(delform, controls); }, resize: function(e) { - var style; - if (style = $('style.height', d.head)) { - $.rm(style); - } - style = $.addStyle("body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"); - return style.className = 'height'; + return imgExpand.style.innerHTML = "body.fitheight img[md5] + img { max-height: " + d.body.clientHeight + "px }"; } }; firstRun = { diff --git a/script.coffee b/script.coffee index 47b37fa4f..e5245a5f7 100644 --- a/script.coffee +++ b/script.coffee @@ -1884,7 +1884,8 @@ imgExpand = g.callbacks.push imgExpand.node imgExpand.dialog() $.bind window, 'resize', imgExpand.resize - imgExpand.resize() + imgExpand.style = $.addStyle "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }" + imgExpand.style.className = 'height' node: (root) -> return unless thumb = $ 'img[md5]', root @@ -1956,15 +1957,13 @@ imgExpand = imgExpand.cb.typeChange.call select $.bind select, 'change', $.cb.value $.bind select, 'change', imgExpand.cb.typeChange - $.bind $('input', controls), 'click', imgExpand.cb.all + $.bind $('input', controls), 'click', imgExpand.cb.all delform = $ 'form[name=delform]' $.prepend delform, controls resize: (e) -> - $.rm style if style = $ 'style.height', d.head - style = $.addStyle "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }" - style.className = 'height' + imgExpand.style.innerHTML = "body.fitheight img[md5] + img { max-height: #{d.body.clientHeight}px }" firstRun = init: ->