diff --git a/4chan_x.js b/4chan_x.js index 859db9eba..5a1c68b7c 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -674,14 +674,13 @@ } }, img: function(thread, all) { - var image; + var root, thumb; if (all) { return $("#imageExpand").click(); } else { - if (!(image = $('td.replyhl span.filesize ~ a[target]', thread))) { - image = $('span.filesize ~ a[target]', thread); - } - return imageToggle(image); + root = $('td.replyhl', thread) || thread; + thumb = $('img[md5]', root); + return imgExpand.toggle(thumb); } }, qr: function(thread, quote) { @@ -1898,25 +1897,26 @@ return _results; } }, - toggle: function(a) { + toggle: function(img) { var ch, cw, imageType, thumb; - thumb = a.firstChild; + thumb = img.parentNode.firstChild; cw = d.body.clientWidth; ch = d.body.clientHeight; imageType = $("#imageType").value; if (thumb.style.display) { - return imgExpand.contract(a); + return imgExpand.contract(thumb); } else { - return imgExpand.expand(thumb, cw, ch, imageType, a); + return imgExpand.expand(thumb, cw, ch, imageType); } }, contract: function(thumb) { $.show(thumb); return $.remove(thumb.nextSibling); }, - expand: function(thumb, cw, ch, imageType, a) { - var img; + expand: function(thumb, cw, ch, imageType) { + var a, img; $.hide(thumb); + a = thumb.parentNode; img = $.el('img', { src: a.href }); diff --git a/script.coffee b/script.coffee index 5bf89e040..bf2a5e07f 100644 --- a/script.coffee +++ b/script.coffee @@ -490,9 +490,9 @@ keybinds = if all $("#imageExpand").click() else - unless image = $ 'td.replyhl span.filesize ~ a[target]', thread - image = $ 'span.filesize ~ a[target]', thread - imageToggle image + root = $('td.replyhl', thread) or thread + thumb = $ 'img[md5]', root + imgExpand.toggle thumb qr: (thread, quote) -> unless qrLink = $ 'td.replyhl span[id] a:not(:first-child)', thread @@ -1434,22 +1434,23 @@ imgExpand = for img in $$ 'img[md5] + img' imgExpand.resize cw, ch, imageType, img - toggle: (a) -> - thumb = a.firstChild + toggle: (img) -> + thumb = img.parentNode.firstChild cw = d.body.clientWidth ch = d.body.clientHeight imageType = $("#imageType").value if thumb.style.display - imgExpand.contract a + imgExpand.contract thumb else - imgExpand.expand thumb, cw, ch, imageType, a + imgExpand.expand thumb, cw, ch, imageType contract: (thumb) -> $.show thumb $.remove thumb.nextSibling - expand: (thumb, cw, ch, imageType, a) -> + expand: (thumb, cw, ch, imageType) -> $.hide thumb + a = thumb.parentNode img = $.el 'img', src: a.href a.appendChild img