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