Move comment from index post to catalog post. Make quote previewing and embedding work in catalog.
This commit is contained in:
parent
9bd1fb7648
commit
e45eaea49f
@ -8,4 +8,3 @@
|
||||
<span class="catalog-icons"></span>
|
||||
</div>
|
||||
?{thread.OP.info.subject}{<div class="subject">${thread.OP.info.subject}</div>}
|
||||
<div class="comment">&{comment}</div>
|
||||
|
||||
@ -18,7 +18,7 @@ Get =
|
||||
index = root.dataset.clone
|
||||
if index then post.clones[index] else post
|
||||
postFromNode: (root) ->
|
||||
Get.postFromRoot $.x '(ancestor::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root
|
||||
Get.postFromRoot $.x '(ancestor::div[contains(@class,"postContainer") or contains(@class,"catalog-thread")][1]|following::div[contains(@class,"postContainer")][1])', root
|
||||
postDataFromLink: (link) ->
|
||||
if link.hostname is 'boards.4chan.org'
|
||||
path = link.pathname.split /\/+/
|
||||
|
||||
@ -702,6 +702,8 @@ Index =
|
||||
if Conf['Index Mode'] is 'catalog'
|
||||
nodes = Index.buildCatalogViews()
|
||||
Index.sizeCatalogViews nodes
|
||||
Index.moveComments threads
|
||||
if Conf['Index Mode'] is 'catalog'
|
||||
$.add Index.root, nodes
|
||||
if doc.contains Index.root
|
||||
$.event 'PostsInserted'
|
||||
@ -715,6 +717,16 @@ Index =
|
||||
offset = nodesPerPage * (pageNum - 1)
|
||||
Index.sortedThreads[offset ... offset + nodesPerPage]
|
||||
|
||||
moveComments: (threads) ->
|
||||
isCatalog = (Conf['Index Mode'] is 'catalog')
|
||||
for thread in threads
|
||||
node = if isCatalog then thread.catalogView.nodes.root else thread.OP.nodes.post
|
||||
{comment} = thread.OP.nodes
|
||||
unless node.contains comment
|
||||
comment.className = if isCatalog then 'comment' else 'postMessage'
|
||||
$.add node, comment
|
||||
return
|
||||
|
||||
buildStructure: (threads) ->
|
||||
for thread in threads
|
||||
if (file = thread.OP.file) and (thumb = thread.OP.file.thumb) and thumb.dataset.src
|
||||
|
||||
@ -4,7 +4,7 @@ Embedding =
|
||||
@types = {}
|
||||
@types[type.key] = type for type in @ordered_types
|
||||
|
||||
if Conf['Floating Embeds']
|
||||
if Conf['Embedding']
|
||||
@dialog = UI.dialog 'embedding', 'top: 50px; right: 0px;',
|
||||
<%= readHTML('Embed.html') %>
|
||||
@media = $ '#media-embed', @dialog
|
||||
@ -21,7 +21,7 @@ Embedding =
|
||||
i = 0
|
||||
items = $$ '.embedder', post.nodes.comment
|
||||
while el = items[i++]
|
||||
$.on el, 'click', Embedding.cb.toggle
|
||||
$.on el, 'click', Embedding.cb.click
|
||||
Embedding.cb.toggle.call el if $.hasClass el, 'embedded'
|
||||
return
|
||||
|
||||
@ -49,16 +49,20 @@ Embedding =
|
||||
embed = $.el 'a',
|
||||
className: 'embedder'
|
||||
href: 'javascript:;'
|
||||
textContent: '(embed)'
|
||||
,
|
||||
<%= html('(<span>un</span>embed)') %>
|
||||
|
||||
embed.dataset[name] = value for name, value of {key, uid, options, href}
|
||||
|
||||
$.on embed, 'click', Embedding.cb.toggle
|
||||
$.on embed, 'click', Embedding.cb.click
|
||||
$.after link, [$.tn(' '), embed]
|
||||
|
||||
if Conf['Auto-embed'] and !Conf['Floating Embeds'] and !post.isFetchedQuote
|
||||
$.asap (-> doc.contains embed), ->
|
||||
Embedding.cb.toggle.call embed
|
||||
autoEmbed = ->
|
||||
if doc.contains(embed) and not $.hasClass(doc, 'catalog-mode')
|
||||
$.off d, 'PostsInserted', autoEmbed
|
||||
Embedding.cb.toggle.call embed
|
||||
$.on d, 'PostsInserted', autoEmbed
|
||||
|
||||
ready: ->
|
||||
$.addClass Embedding.dialog, 'empty'
|
||||
@ -110,25 +114,26 @@ Embedding =
|
||||
return
|
||||
|
||||
cb:
|
||||
toggle: (e) ->
|
||||
e?.preventDefault()
|
||||
if Conf['Floating Embeds']
|
||||
click: (e) ->
|
||||
e.preventDefault()
|
||||
if Conf['Floating Embeds'] or $.hasClass(doc, 'catalog-mode')
|
||||
return unless div = Embedding.media.firstChild
|
||||
$.replace div, Embedding.cb.embed @
|
||||
Embedding.lastEmbed = Get.postFromNode(@).nodes.root
|
||||
$.rmClass Embedding.dialog, 'empty'
|
||||
return
|
||||
else
|
||||
Embedding.cb.toggle.call @
|
||||
|
||||
toggle: ->
|
||||
if $.hasClass @, "embedded"
|
||||
$.rm @nextElementSibling
|
||||
@textContent = '(embed)'
|
||||
else
|
||||
$.after @, Embedding.cb.embed @
|
||||
@textContent = '(unembed)'
|
||||
$.toggleClass @, 'embedded'
|
||||
|
||||
embed: (a) ->
|
||||
# We create an element to embed
|
||||
container = $.el 'div'
|
||||
container = $.el 'div', {className: 'media-embed'}
|
||||
$.add container, el = (type = Embedding.types[a.dataset.key]).el a
|
||||
|
||||
# Set style values.
|
||||
|
||||
@ -9,10 +9,6 @@ Linkify =
|
||||
name: 'Linkify'
|
||||
cb: @node
|
||||
|
||||
Callbacks.CatalogThread.push
|
||||
name: 'Linkify'
|
||||
cb: @catalogNode
|
||||
|
||||
Embedding.init()
|
||||
|
||||
node: ->
|
||||
@ -25,10 +21,6 @@ Linkify =
|
||||
Embedding.process link, @ for link in links
|
||||
return
|
||||
|
||||
catalogNode: ->
|
||||
return unless Linkify.regString.test @thread.OP.info.comment
|
||||
Linkify.process @nodes.comment
|
||||
|
||||
process: (node) ->
|
||||
test = /[^\s"]+/g
|
||||
space = /[\s"]/
|
||||
|
||||
@ -7,9 +7,6 @@ AntiAutoplay =
|
||||
Callbacks.Post.push
|
||||
name: 'Disable Autoplaying Sounds'
|
||||
cb: @node
|
||||
Callbacks.CatalogThread.push
|
||||
name: 'Disable Autoplaying Sounds'
|
||||
cb: @node
|
||||
$.ready => @process d.body
|
||||
|
||||
stop: (audio) ->
|
||||
@ -21,7 +18,7 @@ AntiAutoplay =
|
||||
$.addClass audio, 'controls-added'
|
||||
|
||||
node: ->
|
||||
AntiAutoplay.process @nodes.root
|
||||
AntiAutoplay.process @nodes.comment
|
||||
|
||||
process: (root) ->
|
||||
for iframe in $$ 'iframe[src*="youtube"][src*="autoplay=1"]', root
|
||||
|
||||
@ -24,9 +24,6 @@ CatalogLinks =
|
||||
Callbacks.Post.push
|
||||
name: 'Catalog Link Rewrite'
|
||||
cb: @node
|
||||
Callbacks.CatalogThread.push
|
||||
name: 'Catalog Link Rewrite'
|
||||
cb: @node
|
||||
|
||||
if Conf['Catalog Links']
|
||||
CatalogLinks.el = el = UI.checkbox 'Header catalog links', 'Catalog Links'
|
||||
|
||||
@ -42,9 +42,6 @@ Fourchan =
|
||||
Callbacks.Post.push
|
||||
name: 'Parse /sci/ math'
|
||||
cb: @math
|
||||
Callbacks.CatalogThread.push
|
||||
name: 'Parse /sci/ math'
|
||||
cb: @math
|
||||
|
||||
# Disable 4chan's ID highlighting (replaced by IDHighlight) and reported post hiding.
|
||||
Main.ready ->
|
||||
|
||||
@ -9,10 +9,6 @@ RemoveSpoilers =
|
||||
name: 'Reveal Spoilers'
|
||||
cb: @node
|
||||
|
||||
Callbacks.CatalogThread.push
|
||||
name: 'Reveal Spoilers'
|
||||
cb: @node
|
||||
|
||||
if g.VIEW is 'archive'
|
||||
$.ready -> RemoveSpoilers.unspoiler $.id 'arc-list'
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ QuoteInline =
|
||||
|
||||
{boardID, threadID, postID} = Get.postDataFromLink @
|
||||
return if Conf['Inline Cross-thread Quotes Only'] and g.VIEW is 'thread' and g.posts["#{boardID}.#{postID}"]?.nodes.root.offsetParent # exists and not hidden
|
||||
return if $.hasClass(doc, 'catalog-mode')
|
||||
|
||||
e.preventDefault()
|
||||
quoter = Get.postFromNode @
|
||||
|
||||
@ -11,5 +11,4 @@ class CatalogThread
|
||||
postCount: $ '.post-count', root
|
||||
fileCount: $ '.file-count', root
|
||||
pageCount: $ '.page-count', root
|
||||
comment: $ '.comment', root
|
||||
@thread.catalogView = @
|
||||
|
||||
@ -785,6 +785,7 @@ div[data-checked="false"] > .suboption-list {
|
||||
align-self: stretch;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
margin: 0;
|
||||
}
|
||||
/* /tg/ dice rolls */
|
||||
.board_tg .catalog-thread > .comment > b {
|
||||
@ -980,7 +981,7 @@ span.hide-announcement {
|
||||
.quotelink.deadlink:not(.forwardlink) {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
.inlined {
|
||||
:root:not(.catalog-mode) .inlined {
|
||||
opacity: .5;
|
||||
}
|
||||
#qp input, .forwarded {
|
||||
@ -1006,6 +1007,9 @@ span.hide-announcement {
|
||||
display: table;
|
||||
margin: 2px 0;
|
||||
}
|
||||
:root.catalog-mode .inline {
|
||||
display: none;
|
||||
}
|
||||
.inline .post {
|
||||
border: 0 !important;
|
||||
background-color: transparent !important;
|
||||
@ -1845,6 +1849,11 @@ a:only-of-type > .remove {
|
||||
}
|
||||
|
||||
/* Embedding */
|
||||
.embedder:not(.embedded) > span,
|
||||
:root.catalog-mode .embedder > span,
|
||||
:root.catalog-mode .board .media-embed {
|
||||
display: none;
|
||||
}
|
||||
#embedding {
|
||||
padding: 1px 4px 1px 4px;
|
||||
position: fixed;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user