From e69d6b2e7ce5eb88401f1c124607275867094b5e Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 7 Apr 2014 13:30:12 -0700 Subject: [PATCH] gallery thumbnail shouldn't clone contracted image/video --- builds/4chan-X.user.js | 22 ++++++++++++---------- builds/crx/script.js | 22 ++++++++++++---------- src/Images/Gallery.coffee | 20 +++++++++++--------- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 01344da69..0c74a9a09 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -7346,18 +7346,20 @@ return nodes.total.textContent = --i; }, generateThumb: function(file) { - var double, post, thumb, title; + var post, thumb, thumbImg, title; post = Get.postFromNode(file); title = ($('.fileText a', file)).textContent; - thumb = post.file.thumb.parentNode.cloneNode(true); - if (double = $('img + img', thumb)) { - $.rm(double); - } - thumb.className = 'gal-thumb'; - thumb.title = title; - thumb.dataset.id = Gallery.images.length; - thumb.dataset.post = $('a[title="Highlight this post"]', post.nodes.info).href; - thumb.firstElementChild.style.cssText = ''; + thumb = $.el('a', { + className: 'gal-thumb', + href: post.file.URL, + target: '_blank' + }, title = title, { + 'data-id': Gallery.images.length, + 'data-post': $('a[title="Highlight this post"]', post.nodes.info).href + }); + thumbImg = post.file.thumb.cloneNode(false); + thumbImg.style.cssText = ''; + $.add(thumb, thumbImg); $.on(thumb, 'click', Gallery.cb.open); Gallery.images.push(thumb); return $.add(Gallery.nodes.thumbs, thumb); diff --git a/builds/crx/script.js b/builds/crx/script.js index 2e3d3a4aa..f3029b67a 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -7365,18 +7365,20 @@ return nodes.total.textContent = --i; }, generateThumb: function(file) { - var double, post, thumb, title; + var post, thumb, thumbImg, title; post = Get.postFromNode(file); title = ($('.fileText a', file)).textContent; - thumb = post.file.thumb.parentNode.cloneNode(true); - if (double = $('img + img', thumb)) { - $.rm(double); - } - thumb.className = 'gal-thumb'; - thumb.title = title; - thumb.dataset.id = Gallery.images.length; - thumb.dataset.post = $('a[title="Highlight this post"]', post.nodes.info).href; - thumb.firstElementChild.style.cssText = ''; + thumb = $.el('a', { + className: 'gal-thumb', + href: post.file.URL, + target: '_blank' + }, title = title, { + 'data-id': Gallery.images.length, + 'data-post': $('a[title="Highlight this post"]', post.nodes.info).href + }); + thumbImg = post.file.thumb.cloneNode(false); + thumbImg.style.cssText = ''; + $.add(thumb, thumbImg); $.on(thumb, 'click', Gallery.cb.open); Gallery.images.push(thumb); return $.add(Gallery.nodes.thumbs, thumb); diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index 03215608c..e2c031b6c 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -106,16 +106,18 @@ Gallery = generateThumb: (file) -> post = Get.postFromNode file title = ($ '.fileText a', file).textContent - thumb = post.file.thumb.parentNode.cloneNode true - if double = $ 'img + img', thumb - $.rm double - - thumb.className = 'gal-thumb' - thumb.title = title - thumb.dataset.id = Gallery.images.length - thumb.dataset.post = $('a[title="Highlight this post"]', post.nodes.info).href - thumb.firstElementChild.style.cssText = '' + thumb = $.el 'a', + className: 'gal-thumb' + href: post.file.URL + target: '_blank' + title = title + 'data-id': Gallery.images.length + 'data-post': $('a[title="Highlight this post"]', post.nodes.info).href + thumbImg = post.file.thumb.cloneNode false + thumbImg.style.cssText = '' + $.add thumb, thumbImg + $.on thumb, 'click', Gallery.cb.open Gallery.images.push thumb