Add Auto-GIF.
This commit is contained in:
parent
6c9d745a84
commit
f6d1e76c39
@ -74,7 +74,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(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,
|
__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; };
|
__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.']
|
'Stubs': [true, 'Make stubs of hidden threads / replies.']
|
||||||
},
|
},
|
||||||
Imaging: {
|
Imaging: {
|
||||||
'Image Auto-Gif': [false, 'Animate GIF thumbnails.'],
|
'Auto-GIF': [false, 'Animate GIF thumbnails.'],
|
||||||
'Image Expansion': [true, 'Expand images.'],
|
'Image Expansion': [true, 'Expand images.'],
|
||||||
'Expand From Position': [true, 'Expand all images only from current position to thread end.'],
|
'Expand From Position': [true, 'Expand all images only from current position to thread end.'],
|
||||||
'Image Hover': [false, 'Show full image on mouseover.'],
|
'Image Hover': [false, 'Show full image on mouseover.'],
|
||||||
@ -992,6 +992,13 @@
|
|||||||
$.log(err, 'Reveal Spoilers');
|
$.log(err, 'Reveal Spoilers');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (Conf['Auto-GIF']) {
|
||||||
|
try {
|
||||||
|
AutoGIF.init();
|
||||||
|
} catch (err) {
|
||||||
|
$.log(err, 'Auto-GIF');
|
||||||
|
}
|
||||||
|
}
|
||||||
return $.ready(Main.initFeaturesReady);
|
return $.ready(Main.initFeaturesReady);
|
||||||
},
|
},
|
||||||
initFeaturesReady: function() {
|
initFeaturesReady: function() {
|
||||||
@ -2104,18 +2111,48 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
var style, thumb, _ref;
|
var thumb, _ref;
|
||||||
if (this.isClone || !((_ref = this.file) != null ? _ref.isSpoiler : void 0)) {
|
if (this.isClone || !((_ref = this.file) != null ? _ref.isSpoiler : void 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
thumb = this.file.thumb;
|
thumb = this.file.thumb;
|
||||||
thumb.removeAttribute('style');
|
thumb.removeAttribute('style');
|
||||||
style = thumb.style;
|
|
||||||
style.maxHeight = style.maxWidth = this.isReply ? '125px' : '250px';
|
|
||||||
return thumb.src = this.file.thumbURL;
|
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();
|
Main.init();
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
@ -18,7 +18,7 @@ Config =
|
|||||||
'Thread Hiding': [true, 'Hide entire threads.']
|
'Thread Hiding': [true, 'Hide entire threads.']
|
||||||
'Stubs': [true, 'Make stubs of hidden threads / replies.']
|
'Stubs': [true, 'Make stubs of hidden threads / replies.']
|
||||||
Imaging:
|
Imaging:
|
||||||
'Image Auto-Gif': [false, 'Animate GIF thumbnails.']
|
'Auto-GIF': [false, 'Animate GIF thumbnails.']
|
||||||
'Image Expansion': [true, 'Expand images.']
|
'Image Expansion': [true, 'Expand images.']
|
||||||
'Expand From Position': [true, 'Expand all images only from current position to thread end.']
|
'Expand From Position': [true, 'Expand all images only from current position to thread end.']
|
||||||
'Image Hover': [false, 'Show full image on mouseover.']
|
'Image Hover': [false, 'Show full image on mouseover.']
|
||||||
@ -797,6 +797,13 @@ Main =
|
|||||||
# XXX handle error
|
# XXX handle error
|
||||||
$.log err, 'Reveal Spoilers'
|
$.log err, 'Reveal Spoilers'
|
||||||
|
|
||||||
|
if Conf['Auto-GIF']
|
||||||
|
try
|
||||||
|
AutoGIF.init()
|
||||||
|
catch err
|
||||||
|
# XXX handle error
|
||||||
|
$.log err, 'Auto-GIF'
|
||||||
|
|
||||||
$.ready Main.initFeaturesReady
|
$.ready Main.initFeaturesReady
|
||||||
initFeaturesReady: ->
|
initFeaturesReady: ->
|
||||||
if d.title is '4chan - 404 Not Found'
|
if d.title is '4chan - 404 Not Found'
|
||||||
@ -1791,12 +1798,30 @@ RevealSpoilers =
|
|||||||
node: ->
|
node: ->
|
||||||
return if @isClone or !@file?.isSpoiler
|
return if @isClone or !@file?.isSpoiler
|
||||||
{thumb} = @file
|
{thumb} = @file
|
||||||
# revealed spoilers do not have height/width set, this fixes auto-gifs dimensions.
|
|
||||||
thumb.removeAttribute 'style'
|
thumb.removeAttribute 'style'
|
||||||
{style} = thumb
|
|
||||||
style.maxHeight = style.maxWidth = if @isReply then '125px' else '250px'
|
|
||||||
thumb.src = @file.thumbURL
|
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()
|
Main.init()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user