Revert "Revert "Suppress post thumbnails from loading until they are actually inserted into the index.""

This reverts commit 6b9059182fdf97001f013efc57150ff3dc14d80a.
This commit is contained in:
ccd0 2016-01-22 19:49:57 -08:00
parent 2ba6e4f9c3
commit f14e850af0
6 changed files with 24 additions and 9 deletions

View File

@ -88,10 +88,11 @@ Build =
.replace(/<[^>]*>/g, '')
o.info.comment = Build.unescape html
postFromObject: (data, boardID) ->
Build.post Build.parseJSON data, boardID
postFromObject: (data, boardID, suppressThumb) ->
o = Build.parseJSON data, boardID
Build.post o, suppressThumb
post: (o) ->
post: (o, suppressThumb) ->
{postID, threadID, boardID, file} = o
{subject, email, name, tripcode, capcode, uniqueID, flagCode, flag, dateUTC, dateText, commentHTML} = o.info
{staticPath, gifIcon} = Build
@ -177,7 +178,7 @@ Build =
root
excerptThread: (board, data, OP) ->
nodes = [if OP then OP.nodes.root else Build.postFromObject data, board.ID]
nodes = [if OP then OP.nodes.root else Build.postFromObject data, board.ID, true]
if data.omitted_posts or !Conf['Show Replies'] and data.replies
[posts, files] = if Conf['Show Replies']
# XXX data.omitted_images is not accurate.

View File

@ -650,6 +650,10 @@ Index =
buildStructure: (nodes) ->
for node in nodes
if thumb = $ 'img[data-src]', node
thumb.src = thumb.dataset.src
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=1021289
thumb.removeAttribute 'data-src'
$.add Index.root, [node, $.el 'hr']
$.event 'PostsInserted' if doc.contains Index.root
ThreadHiding.onIndexBuild nodes

View File

@ -15,8 +15,8 @@
(${file.size}, ${file.dimensions || "PDF"})
</div>
<a class="fileThumb?{file.isSpoiler}{ imgspoiler}{}" href="${fileURL}" target="_blank">
<img
src="${fileThumb}"
<img
?{suppressThumb}{ data-src="${fileThumb}"}{ src="${fileThumb}"}
alt="${file.size}"
data-md5="${file.MD5}"
style="height: ${file.isSpoiler ? 100 : file.theight}px; width: ${file.isSpoiler ? 100 : file.twidth}px;"

View File

@ -65,6 +65,11 @@ class Clone extends Post
@file.thumb.muted = true if @file.videoThumb
if @file.thumb?.dataset.src
@file.thumb.src = @file.thumb.dataset.src
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=1021289
@file.thumb.removeAttribute 'data-src'
# Contract thumbnails in quote preview
ImageExpand.contract @ if @file.thumb and contractThumb

View File

@ -38,7 +38,7 @@ ImageLoader =
preload: 'none'
loop: true
muted: true
poster: thumb.src
poster: thumb.src or thumb.dataset.src
textContent: thumb.alt
className: thumb.className
video.setAttribute 'muted', 'muted'
@ -55,7 +55,7 @@ ImageLoader =
{isImage, isVideo, thumb, url} = file
return if file.isPrefetched or !(isImage or isVideo) or post.isHidden or post.thread.isHidden
type = if (match = url.match(/\.([^.]+)$/)[1].toUpperCase()) is 'JPEG' then 'JPG' else match
replace = Conf["Replace #{type}"] and !/spoiler/.test thumb.src
replace = Conf["Replace #{type}"] and !/spoiler/.test(thumb.src or thumb.dataset.src)
return unless replace or Conf['prefetch']
return unless [post, post.clones...].some (clone) -> doc.contains clone.nodes.root
file.isPrefetched = true
@ -72,6 +72,8 @@ ImageLoader =
$.on el, 'load', ->
clone.file.thumb.src = url for clone in post.clones
thumb.src = url
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=1021289
thumb.removeAttribute 'data-src'
el.src = url
toggle: ->

View File

@ -13,4 +13,7 @@ RevealSpoilers =
thumb.removeAttribute 'style'
# Enforce thumbnail size if thumbnail is replaced.
thumb.style.maxHeight = thumb.style.maxWidth = if @isReply then '125px' else '250px'
thumb.src = @file.thumbURL
if thumb.src
thumb.src = @file.thumbURL
else
thumb.dataset.src = @file.thumbURL