diff --git a/4chan_x.js b/4chan_x.js index 166e73ab2..1b776d594 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1997,23 +1997,28 @@ return imgExpand.resize(img); }, foo: function() { - var borderLeftWidth, borderRightWidth, crap, formWidth, left, paddingLeft, paddingRight, table, td, _ref2; + var crap, formWidth, left, table, td; formWidth = $('form[name=delform]').getBoundingClientRect().width; td = $('td.reply'); table = td.parentNode.parentNode.parentNode; left = td.getBoundingClientRect().left - table.getBoundingClientRect().left; - _ref2 = getComputedStyle(td), paddingLeft = _ref2.paddingLeft, paddingRight = _ref2.paddingRight, borderLeftWidth = _ref2.borderLeftWidth, borderRightWidth = _ref2.borderRightWidth; - crap = parseInt(paddingLeft) + parseInt(paddingRight) + parseInt(borderLeftWidth) + parseInt(borderRightWidth); - imgExpand.maxWidth = formWidth - left - crap; + crap = td.getBoundingClientRect().width - parseInt(getComputedStyle(td).width); + imgExpand.maxWidthOP = formWidth; + imgExpand.maxWidthReply = formWidth - left - crap; imgExpand.maxHeight = d.body.clientHeight; return imgExpand.type = $('#imageType').value; }, resize: function(img) { - var imgHeight, imgWidth, maxHeight, maxWidth, ratio, type, _, _ref2; - maxWidth = imgExpand.maxWidth, maxHeight = imgExpand.maxHeight, type = imgExpand.type; + var imgHeight, imgWidth, maxHeight, maxWidth, maxWidthOP, maxWidthReply, ratio, type, _, _ref2; + maxWidthOP = imgExpand.maxWidthOP, maxWidthReply = imgExpand.maxWidthReply, maxHeight = imgExpand.maxHeight, type = imgExpand.type; _ref2 = $.x("preceding::span[@class][1]/text()[2]", img).textContent.match(/(\d+)x(\d+)/), _ = _ref2[0], imgWidth = _ref2[1], imgHeight = _ref2[2]; imgWidth = Number(imgWidth); imgHeight = Number(imgHeight); + if (img.parentNode.parentNode.nodeName === 'TD') { + maxWidth = maxWidthReply; + } else { + maxWidth = maxWidthOP; + } switch (type) { case 'full': return img.removeAttribute('style'); diff --git a/script.coffee b/script.coffee index 22d6068a1..b495c1536 100644 --- a/script.coffee +++ b/script.coffee @@ -1521,23 +1521,26 @@ imgExpand = td = $('td.reply') table = td.parentNode.parentNode.parentNode left = td.getBoundingClientRect().left - table.getBoundingClientRect().left + crap = td.getBoundingClientRect().width - parseInt(getComputedStyle(td).width) - #XXX not sure I'm doing this right -_-; - {paddingLeft, paddingRight, borderLeftWidth, borderRightWidth} = getComputedStyle(td) - crap = parseInt(paddingLeft) + parseInt(paddingRight) + parseInt(borderLeftWidth) + parseInt(borderRightWidth) - - imgExpand.maxWidth = formWidth - left - crap + imgExpand.maxWidthOP = formWidth + imgExpand.maxWidthReply = formWidth - left - crap imgExpand.maxHeight = d.body.clientHeight imgExpand.type = $('#imageType').value resize: (img) -> - {maxWidth, maxHeight, type} = imgExpand + {maxWidthOP, maxWidthReply, maxHeight, type} = imgExpand [_, imgWidth, imgHeight] = $ .x("preceding::span[@class][1]/text()[2]", img) .textContent.match(/(\d+)x(\d+)/) imgWidth = Number imgWidth imgHeight = Number imgHeight + if img.parentNode.parentNode.nodeName == 'TD' + maxWidth = maxWidthReply + else + maxWidth = maxWidthOP + switch type when 'full' img.removeAttribute 'style'