Add Auto-GIF support in the catalog.

This commit is contained in:
Mayhem 2014-01-29 15:22:46 +01:00
parent 10dfa74be0
commit 44e28961fd
2 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,7 @@
<li> Filter (hiding, highlighting) <li> Filter (hiding, highlighting)
<li> Thread Hiding <li> Thread Hiding
<li> Linkify <li> Linkify
<li> Auto-GIF
<li> Image Hover <li> Image Hover
</ul> </ul>
- Support for the official catalog will be removed in the future, once the catalog mode for the index is deemed satisfactory. - Support for the official catalog will be removed in the future, once the catalog mode for the index is deemed satisfactory.

View File

@ -5,6 +5,9 @@ AutoGIF =
Post.callbacks.push Post.callbacks.push
name: 'Auto-GIF' name: 'Auto-GIF'
cb: @node cb: @node
CatalogThread.callbacks.push
name: 'Auto-GIF'
cb: @catalogNode
node: -> node: ->
return if @isClone or @isHidden or @thread.isHidden or !@file?.isImage return if @isClone or @isHidden or @thread.isHidden or !@file?.isImage
{thumb, URL} = @file {thumb, URL} = @file
@ -13,8 +16,17 @@ AutoGIF =
# Revealed spoilers do not have height/width set, this fixes auto-gifs dimensions. # Revealed spoilers do not have height/width set, this fixes auto-gifs dimensions.
{style} = thumb {style} = thumb
style.maxHeight = style.maxWidth = if @isReply then '125px' else '250px' style.maxHeight = style.maxWidth = if @isReply then '125px' else '250px'
AutoGIF.replaceThumbnail thumb, URL
catalogNode: ->
{OP} = @thread
return unless OP.file?.isImage
{URL} = OP.file
return unless /gif$/.test URL
AutoGIF.replaceThumbnail @nodes.thumb, URL
replaceThumbnail: (thumb, URL) ->
gif = $.el 'img' gif = $.el 'img'
$.on gif, 'load', -> $.on gif, 'load', ->
# Replace the thumbnail once the GIF has finished loading. # Replace the thumbnail once the GIF has finished loading.
thumb.src = URL thumb.src = URL
gif.src = URL gif.src = URL