Add Auto-GIF.
This commit is contained in:
parent
6c9d745a84
commit
f6d1e76c39
@ -74,7 +74,7 @@
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var $, $$, Board, Build, Clone, Conf, Config, FileInfo, Get, Main, Post, QuoteBacklink, QuoteInline, QuotePreview, Quotify, Redirect, RevealSpoilers, Sauce, Thread, Time, UI, d, g,
|
||||
var $, $$, AutoGIF, Board, Build, Clone, Conf, Config, FileInfo, Get, Main, Post, QuoteBacklink, QuoteInline, QuotePreview, Quotify, Redirect, RevealSpoilers, Sauce, Thread, Time, UI, d, g,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
'Stubs': [true, 'Make stubs of hidden threads / replies.']
|
||||
},
|
||||
Imaging: {
|
||||
'Image Auto-Gif': [false, 'Animate GIF thumbnails.'],
|
||||
'Auto-GIF': [false, 'Animate GIF thumbnails.'],
|
||||
'Image Expansion': [true, 'Expand images.'],
|
||||
'Expand From Position': [true, 'Expand all images only from current position to thread end.'],
|
||||
'Image Hover': [false, 'Show full image on mouseover.'],
|
||||
@ -992,6 +992,13 @@
|
||||
$.log(err, 'Reveal Spoilers');
|
||||
}
|
||||
}
|
||||
if (Conf['Auto-GIF']) {
|
||||
try {
|
||||
AutoGIF.init();
|
||||
} catch (err) {
|
||||
$.log(err, 'Auto-GIF');
|
||||
}
|
||||
}
|
||||
return $.ready(Main.initFeaturesReady);
|
||||
},
|
||||
initFeaturesReady: function() {
|
||||
@ -2104,18 +2111,48 @@
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var style, thumb, _ref;
|
||||
var thumb, _ref;
|
||||
if (this.isClone || !((_ref = this.file) != null ? _ref.isSpoiler : void 0)) {
|
||||
return;
|
||||
}
|
||||
thumb = this.file.thumb;
|
||||
thumb.removeAttribute('style');
|
||||
style = thumb.style;
|
||||
style.maxHeight = style.maxWidth = this.isReply ? '125px' : '250px';
|
||||
return thumb.src = this.file.thumbURL;
|
||||
}
|
||||
};
|
||||
|
||||
AutoGIF = {
|
||||
init: function() {
|
||||
var _ref;
|
||||
if ((_ref = g.BOARD.ID) === 'gif' || _ref === 'wsg') {
|
||||
return;
|
||||
}
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Auto-GIF',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
node: function() {
|
||||
var URL, gif, style, thumb, _ref, _ref1;
|
||||
if (this.isClone || !((_ref = this.file) != null ? _ref.isImage : void 0)) {
|
||||
return;
|
||||
}
|
||||
_ref1 = this.file, thumb = _ref1.thumb, URL = _ref1.URL;
|
||||
if (!(/gif$/.test(URL) && !/spoiler/.test(thumb.src))) {
|
||||
return;
|
||||
}
|
||||
if (this.file.isSpoiler) {
|
||||
style = thumb.style;
|
||||
style.maxHeight = style.maxWidth = this.isReply ? '125px' : '250px';
|
||||
}
|
||||
gif = $.el('img');
|
||||
$.on(gif, 'load', function() {
|
||||
return thumb.src = URL;
|
||||
});
|
||||
return gif.src = URL;
|
||||
}
|
||||
};
|
||||
|
||||
Main.init();
|
||||
|
||||
}).call(this);
|
||||
|
||||
@ -18,7 +18,7 @@ Config =
|
||||
'Thread Hiding': [true, 'Hide entire threads.']
|
||||
'Stubs': [true, 'Make stubs of hidden threads / replies.']
|
||||
Imaging:
|
||||
'Image Auto-Gif': [false, 'Animate GIF thumbnails.']
|
||||
'Auto-GIF': [false, 'Animate GIF thumbnails.']
|
||||
'Image Expansion': [true, 'Expand images.']
|
||||
'Expand From Position': [true, 'Expand all images only from current position to thread end.']
|
||||
'Image Hover': [false, 'Show full image on mouseover.']
|
||||
@ -797,6 +797,13 @@ Main =
|
||||
# XXX handle error
|
||||
$.log err, 'Reveal Spoilers'
|
||||
|
||||
if Conf['Auto-GIF']
|
||||
try
|
||||
AutoGIF.init()
|
||||
catch err
|
||||
# XXX handle error
|
||||
$.log err, 'Auto-GIF'
|
||||
|
||||
$.ready Main.initFeaturesReady
|
||||
initFeaturesReady: ->
|
||||
if d.title is '4chan - 404 Not Found'
|
||||
@ -1791,12 +1798,30 @@ RevealSpoilers =
|
||||
node: ->
|
||||
return if @isClone or !@file?.isSpoiler
|
||||
{thumb} = @file
|
||||
# revealed spoilers do not have height/width set, this fixes auto-gifs dimensions.
|
||||
thumb.removeAttribute 'style'
|
||||
{style} = thumb
|
||||
style.maxHeight = style.maxWidth = if @isReply then '125px' else '250px'
|
||||
thumb.src = @file.thumbURL
|
||||
|
||||
AutoGIF =
|
||||
init: ->
|
||||
return if g.BOARD.ID in ['gif', 'wsg']
|
||||
Post::callbacks.push
|
||||
name: 'Auto-GIF'
|
||||
cb: @node
|
||||
node: ->
|
||||
# XXX return if @hidden?
|
||||
return if @isClone or !@file?.isImage
|
||||
{thumb, URL} = @file
|
||||
return unless /gif$/.test(URL) and !/spoiler/.test thumb.src
|
||||
if @file.isSpoiler
|
||||
# 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'
|
||||
gif = $.el 'img'
|
||||
$.on gif, 'load', ->
|
||||
# Replace the thumbnail once the GIF has finished loading.
|
||||
thumb.src = URL
|
||||
gif.src = URL
|
||||
|
||||
|
||||
|
||||
Main.init()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user