fix image stuff

This commit is contained in:
James Campos 2011-04-19 23:48:33 -07:00
parent 80defac720
commit 8977f055cc
2 changed files with 20 additions and 19 deletions

View File

@ -674,14 +674,13 @@
} }
}, },
img: function(thread, all) { img: function(thread, all) {
var image; var root, thumb;
if (all) { if (all) {
return $("#imageExpand").click(); return $("#imageExpand").click();
} else { } else {
if (!(image = $('td.replyhl span.filesize ~ a[target]', thread))) { root = $('td.replyhl', thread) || thread;
image = $('span.filesize ~ a[target]', thread); thumb = $('img[md5]', root);
} return imgExpand.toggle(thumb);
return imageToggle(image);
} }
}, },
qr: function(thread, quote) { qr: function(thread, quote) {
@ -1898,25 +1897,26 @@
return _results; return _results;
} }
}, },
toggle: function(a) { toggle: function(img) {
var ch, cw, imageType, thumb; var ch, cw, imageType, thumb;
thumb = a.firstChild; thumb = img.parentNode.firstChild;
cw = d.body.clientWidth; cw = d.body.clientWidth;
ch = d.body.clientHeight; ch = d.body.clientHeight;
imageType = $("#imageType").value; imageType = $("#imageType").value;
if (thumb.style.display) { if (thumb.style.display) {
return imgExpand.contract(a); return imgExpand.contract(thumb);
} else { } else {
return imgExpand.expand(thumb, cw, ch, imageType, a); return imgExpand.expand(thumb, cw, ch, imageType);
} }
}, },
contract: function(thumb) { contract: function(thumb) {
$.show(thumb); $.show(thumb);
return $.remove(thumb.nextSibling); return $.remove(thumb.nextSibling);
}, },
expand: function(thumb, cw, ch, imageType, a) { expand: function(thumb, cw, ch, imageType) {
var img; var a, img;
$.hide(thumb); $.hide(thumb);
a = thumb.parentNode;
img = $.el('img', { img = $.el('img', {
src: a.href src: a.href
}); });

View File

@ -490,9 +490,9 @@ keybinds =
if all if all
$("#imageExpand").click() $("#imageExpand").click()
else else
unless image = $ 'td.replyhl span.filesize ~ a[target]', thread root = $('td.replyhl', thread) or thread
image = $ 'span.filesize ~ a[target]', thread thumb = $ 'img[md5]', root
imageToggle image imgExpand.toggle thumb
qr: (thread, quote) -> qr: (thread, quote) ->
unless qrLink = $ 'td.replyhl span[id] a:not(:first-child)', thread unless qrLink = $ 'td.replyhl span[id] a:not(:first-child)', thread
@ -1434,22 +1434,23 @@ imgExpand =
for img in $$ 'img[md5] + img' for img in $$ 'img[md5] + img'
imgExpand.resize cw, ch, imageType, img imgExpand.resize cw, ch, imageType, img
toggle: (a) -> toggle: (img) ->
thumb = a.firstChild thumb = img.parentNode.firstChild
cw = d.body.clientWidth cw = d.body.clientWidth
ch = d.body.clientHeight ch = d.body.clientHeight
imageType = $("#imageType").value imageType = $("#imageType").value
if thumb.style.display if thumb.style.display
imgExpand.contract a imgExpand.contract thumb
else else
imgExpand.expand thumb, cw, ch, imageType, a imgExpand.expand thumb, cw, ch, imageType
contract: (thumb) -> contract: (thumb) ->
$.show thumb $.show thumb
$.remove thumb.nextSibling $.remove thumb.nextSibling
expand: (thumb, cw, ch, imageType, a) -> expand: (thumb, cw, ch, imageType) ->
$.hide thumb $.hide thumb
a = thumb.parentNode
img = $.el 'img', img = $.el 'img',
src: a.href src: a.href
a.appendChild img a.appendChild img