Suppress post thumbnails from loading until they are actually inserted into the index.
Hopefully a temporary way of doing this until we get filtering working on JSON so we don't have to build the posts at all.
This commit is contained in:
parent
897bdac327
commit
6ad0064f41
@ -26,7 +26,7 @@ Build =
|
||||
"#p#{postID}"
|
||||
else
|
||||
"/#{boardID}/thread/#{threadID}#p#{postID}"
|
||||
postFromObject: (data, boardID) ->
|
||||
postFromObject: (data, boardID, suppressThumb) ->
|
||||
o =
|
||||
# id
|
||||
postID: data.no
|
||||
@ -70,8 +70,8 @@ Build =
|
||||
isSpoiler: !!data.spoiler
|
||||
isDeleted: false
|
||||
tag: data.tag
|
||||
Build.post o
|
||||
post: (o) ->
|
||||
Build.post o, suppressThumb
|
||||
post: (o, suppressThumb) ->
|
||||
###
|
||||
This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS).
|
||||
@license: https://github.com/4chan/4chan-JS/blob/master/LICENSE
|
||||
@ -115,6 +115,7 @@ Build =
|
||||
shortFilename = Build.shortFilename file.name
|
||||
fileSize = $.bytesToString file.size
|
||||
fileDims = if file.url[-4..] is '.pdf' then 'PDF' else "#{file.width}x#{file.height}"
|
||||
fileThumb = if file.isSpoiler then Build.spoilerThumb boardID else file.turl
|
||||
|
||||
fileBlock = <%= importHTML('Build/File') %>
|
||||
|
||||
@ -166,7 +167,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.
|
||||
|
||||
@ -647,6 +647,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
|
||||
@ -661,7 +665,7 @@ Index =
|
||||
if Index.search
|
||||
Index.searchInput.dataset.searching = 1
|
||||
else
|
||||
# XXX https://github.com/greasemonkey/greasemonkey/issues/1571
|
||||
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=1021289
|
||||
Index.searchInput.removeAttribute 'data-searching'
|
||||
|
||||
onSearchInput: ->
|
||||
|
||||
@ -18,8 +18,8 @@
|
||||
(${fileSize}, ${fileDims})
|
||||
</div>
|
||||
<a class="fileThumb?{file.isSpoiler}{ imgspoiler}{}" href="${file.url}" target="_blank">
|
||||
<img
|
||||
src="${file.isSpoiler ? Build.spoilerThumb(boardID) : file.turl}"
|
||||
<img
|
||||
?{suppressThumb}{ data-src="${fileThumb}"}{ src="${fileThumb}"}
|
||||
alt="${fileSize}"
|
||||
data-md5="${file.MD5}"
|
||||
style="height: ${file.isSpoiler ? 100 : file.theight}px; width: ${file.isSpoiler ? 100 : file.twidth}px;"
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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: ->
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user