From 44e28961fdd11d3ded0a002937e09c4dd76c0438 Mon Sep 17 00:00:00 2001 From: Mayhem Date: Wed, 29 Jan 2014 15:22:46 +0100 Subject: [PATCH] Add Auto-GIF support in the catalog. --- CHANGELOG.md | 1 + src/Images/AutoGIF.coffee | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eab556a9b..773f836d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@
  • Filter (hiding, highlighting)
  • Thread Hiding
  • Linkify +
  • Auto-GIF
  • Image Hover - Support for the official catalog will be removed in the future, once the catalog mode for the index is deemed satisfactory. diff --git a/src/Images/AutoGIF.coffee b/src/Images/AutoGIF.coffee index 71ccc7d8e..a80481407 100644 --- a/src/Images/AutoGIF.coffee +++ b/src/Images/AutoGIF.coffee @@ -5,6 +5,9 @@ AutoGIF = Post.callbacks.push name: 'Auto-GIF' cb: @node + CatalogThread.callbacks.push + name: 'Auto-GIF' + cb: @catalogNode node: -> return if @isClone or @isHidden or @thread.isHidden or !@file?.isImage {thumb, URL} = @file @@ -13,8 +16,17 @@ AutoGIF = # Revealed spoilers do not have height/width set, this fixes auto-gifs dimensions. {style} = thumb 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' $.on gif, 'load', -> # Replace the thumbnail once the GIF has finished loading. thumb.src = URL gif.src = URL +