better maxwidth algorithm

This commit is contained in:
James Campos 2011-04-30 14:02:21 -07:00
parent 06ae1b66bf
commit 1be9058429
2 changed files with 20 additions and 12 deletions

View File

@ -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');

View File

@ -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'