4chan-x/src/Images/RevealSpoilers.coffee
ccd0 6ad0064f41 Suppress post thumbnails from loading until they are actually inserted into the index.
Hopefully a temporary way of doing this until we get filtering working on JSON
so we don't have to build the posts at all.
2015-03-28 18:27:09 -07:00

20 lines
619 B
CoffeeScript
Executable File

RevealSpoilers =
init: ->
return unless g.VIEW in ['index', 'thread'] and Conf['Reveal Spoiler Thumbnails']
Post.callbacks.push
name: 'Reveal Spoiler Thumbnails'
cb: @node
node: ->
return unless not @isClone and @file and @file.thumb and @file.isSpoiler
{thumb} = @file
# Remove old width and height.
thumb.removeAttribute 'style'
# Enforce thumbnail size if thumbnail is replaced.
thumb.style.maxHeight = thumb.style.maxWidth = if @isReply then '125px' else '250px'
if thumb.src
thumb.src = @file.thumbURL
else
thumb.dataset.src = @file.thumbURL