From 049fe3b118c76dae4af4bba5e665ea9b14305e20 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 25 Sep 2016 00:19:15 -0700 Subject: [PATCH] Make original parent node of thumbnail post.file.thumbLink. --- src/Images/Gallery.coffee | 4 ++-- src/Images/ImageExpand.coffee | 12 ++++++------ src/Images/Volume.coffee | 2 +- src/classes/Post.Clone.coffee | 3 ++- src/classes/Post.coffee | 3 ++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index 8d8f5262b..ffaa98226 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -25,7 +25,7 @@ Gallery = Gallery.nodes.total.textContent = Gallery.images.length unless Conf['Image Expansion'] - $.on @file.thumb.parentNode, 'click', Gallery.cb.image + $.on @file.thumbLink, 'click', Gallery.cb.image build: (image) -> {cb} = Gallery @@ -88,7 +88,7 @@ Gallery = Gallery.generateThumb post # If no image to open is given, pick image we have scrolled to. if !image and Gallery.fullIDs[post.fullID] - candidate = post.file.thumb.parentNode + candidate = post.file.thumbLink if Header.getTopOf(candidate) + candidate.getBoundingClientRect().height >= 0 image = candidate $.addClass doc, 'gallery-open' diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 888e08e83..c7a0501f4 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -20,7 +20,7 @@ ImageExpand = node: -> return unless @file and (@file.isImage or @file.isVideo) - $.on @file.thumb.parentNode, 'click', ImageExpand.cb.toggle + $.on @file.thumbLink, 'click', ImageExpand.cb.toggle if @isClone if @file.isExpanding @@ -122,8 +122,8 @@ ImageExpand = $.rmClass post.nodes.root, 'expanded-image' $.rmClass file.thumb, 'expanding' $.rm file.videoControls - file.thumb.parentNode.href = file.url - file.thumb.parentNode.target = '_blank' + file.thumbLink.href = file.url + file.thumbLink.target = '_blank' for x in ['isExpanding', 'isExpanded', 'videoControls', 'wasPlaying', 'scrollIntoView'] delete file[x] @@ -158,7 +158,7 @@ ImageExpand = expand: (post, src) -> # Do not expand images of hidden/filtered replies, or already expanded pictures. {file} = post - {thumb, isVideo} = file + {thumb, thumbLink, isVideo} = file return if post.isHidden or file.isExpanding or file.isExpanded $.addClass thumb, 'expanding' @@ -187,8 +187,8 @@ ImageExpand = $.add file.text, file.videoControls # disable link to file so native controls can work - thumb.parentNode.removeAttribute 'href' - thumb.parentNode.removeAttribute 'target' + thumbLink.removeAttribute 'href' + thumbLink.removeAttribute 'target' el.loop = true Volume.setup el diff --git a/src/Images/Volume.coffee b/src/Images/Volume.coffee index c13831a15..ef5a7a498 100644 --- a/src/Images/Volume.coffee +++ b/src/Images/Volume.coffee @@ -62,7 +62,7 @@ Volume = node: -> return unless @board.ID in ['gif', 'wsg'] and @file?.isVideo $.on @file.thumb, 'wheel', Volume.wheel.bind(Header.hover) - $.on $('a', @file.text), 'wheel', Volume.wheel.bind(@file.thumb.parentNode) + $.on $('a', @file.text), 'wheel', Volume.wheel.bind(@file.thumbLink) catalogNode: -> {file} = @thread.OP diff --git a/src/classes/Post.Clone.coffee b/src/classes/Post.Clone.coffee index 2b9b2b1ab..7ba89f1c7 100644 --- a/src/classes/Post.Clone.coffee +++ b/src/classes/Post.Clone.coffee @@ -44,7 +44,8 @@ Post.Clone = class extends Post {fileRoot} = @nodes @file.text = fileRoot.firstElementChild @file.link = $ '.fileText > a, .fileText-original', fileRoot - @file.thumb = $ '.fileThumb > [data-md5]', fileRoot + @file.thumb = $ 'a.fileThumb > [data-md5]', fileRoot + @file.thumbLink = @file.thumb.parentNode @file.fullImage = $ '.full-image', fileRoot @file.videoControls = $ '.video-controls', @file.text diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index 80d8956bb..59b3d9dd3 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -182,9 +182,10 @@ class Post unit = ['B', 'KB', 'MB', 'GB'].indexOf @file.size.match(/\w+$/)[0] size *= 1024 while unit-- > 0 @file.sizeInBytes = size - if (thumb = $ '.fileThumb > [data-md5]', fileRoot) + if (thumb = $ 'a.fileThumb > [data-md5]', fileRoot) $.extend @file, thumb: thumb + thumbLink: thumb.parentNode thumbURL: if m = link.href.match(/\d+(?=\.\w+$)/) then "#{location.protocol}//i.4cdn.org/#{@board}/#{m[0]}s.jpg" MD5: thumb.dataset.md5 isSpoiler: $.hasClass thumb.parentNode, 'imgspoiler'