keep fitted image w/in FORM
This commit is contained in:
parent
7ddba9163b
commit
7362b5e297
14
4chan_x.js
14
4chan_x.js
@ -1944,17 +1944,23 @@
|
|||||||
return imgExpand.resize(img);
|
return imgExpand.resize(img);
|
||||||
},
|
},
|
||||||
foo: function() {
|
foo: function() {
|
||||||
imgExpand.formRight = $('form[name=delform]').getBoundingClientRect().right;
|
var borderLeftWidth, borderRightWidth, crap, formWidth, left, paddingLeft, paddingRight, table, td, _ref2;
|
||||||
|
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;
|
||||||
imgExpand.maxHeight = d.body.clientHeight;
|
imgExpand.maxHeight = d.body.clientHeight;
|
||||||
return imgExpand.type = $('#imageType').value;
|
return imgExpand.type = $('#imageType').value;
|
||||||
},
|
},
|
||||||
resize: function(img) {
|
resize: function(img) {
|
||||||
var formRight, imgHeight, imgWidth, maxHeight, maxWidth, ratio, type, _, _ref2;
|
var imgHeight, imgWidth, maxHeight, maxWidth, ratio, type, _, _ref2;
|
||||||
formRight = imgExpand.formRight, maxHeight = imgExpand.maxHeight, type = imgExpand.type;
|
maxWidth = imgExpand.maxWidth, 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];
|
_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);
|
imgWidth = Number(imgWidth);
|
||||||
imgHeight = Number(imgHeight);
|
imgHeight = Number(imgHeight);
|
||||||
maxWidth = formRight - img.getBoundingClientRect().left;
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'full':
|
case 'full':
|
||||||
return img.removeAttribute('style');
|
return img.removeAttribute('style');
|
||||||
|
|||||||
@ -1474,21 +1474,27 @@ imgExpand =
|
|||||||
imgExpand.resize img
|
imgExpand.resize img
|
||||||
|
|
||||||
foo: ->
|
foo: ->
|
||||||
imgExpand.formRight = $('form[name=delform]').getBoundingClientRect().right
|
formWidth = $('form[name=delform]').getBoundingClientRect().width
|
||||||
|
td = $('td.reply')
|
||||||
|
table = td.parentNode.parentNode.parentNode
|
||||||
|
left = td.getBoundingClientRect().left - table.getBoundingClientRect().left
|
||||||
|
|
||||||
|
#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.maxHeight = d.body.clientHeight
|
imgExpand.maxHeight = d.body.clientHeight
|
||||||
imgExpand.type = $('#imageType').value
|
imgExpand.type = $('#imageType').value
|
||||||
|
|
||||||
resize: (img) ->
|
resize: (img) ->
|
||||||
{formRight, maxHeight, type} = imgExpand
|
{maxWidth, maxHeight, type} = imgExpand
|
||||||
[_, imgWidth, imgHeight] = $
|
[_, imgWidth, imgHeight] = $
|
||||||
.x("preceding::span[@class][1]/text()[2]", img)
|
.x("preceding::span[@class][1]/text()[2]", img)
|
||||||
.textContent.match(/(\d+)x(\d+)/)
|
.textContent.match(/(\d+)x(\d+)/)
|
||||||
imgWidth = Number imgWidth
|
imgWidth = Number imgWidth
|
||||||
imgHeight = Number imgHeight
|
imgHeight = Number imgHeight
|
||||||
|
|
||||||
# from image's left bound to form's right bound
|
|
||||||
maxWidth = formRight - img.getBoundingClientRect().left
|
|
||||||
|
|
||||||
switch type
|
switch type
|
||||||
when 'full'
|
when 'full'
|
||||||
img.removeAttribute 'style'
|
img.removeAttribute 'style'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user