Consolidate code to add/remove catalog classes from posts.

This commit is contained in:
ccd0 2016-09-28 21:13:21 -07:00
parent dec107eefb
commit a9bde55965
4 changed files with 12 additions and 11 deletions

View File

@ -175,8 +175,7 @@ Build =
$.rmAll root
if thread.nodes.placeholder
thread.nodes.placeholder = null
$.rmClass thread.OP.nodes.root, 'catalog-postContainer'
$.rmClass thread.OP.nodes.post, 'catalog-post'
thread.OP.setCatalogOP false
else
thread.nodes.root = root = $.el 'div',
className: 'thread'

View File

@ -781,8 +781,7 @@ Index =
if thread.nodes.placeholder
$.replace thread.nodes.placeholder, thread.OP.nodes.root
thread.nodes.placeholder = null
$.rmClass thread.OP.nodes.root, 'catalog-postContainer'
$.rmClass thread.OP.nodes.post, 'catalog-post'
thread.OP.setCatalogOP false
if (file = thread.OP.file) and (thumb = thread.OP.file.thumb) and thumb.dataset.src
thumb.src = thumb.dataset.src
# XXX https://bugzilla.mozilla.org/show_bug.cgi?id=1021289
@ -802,8 +801,7 @@ Index =
thread.nodes.placeholder = $.el 'div'
$.replace thread.OP.nodes.root, thread.nodes.placeholder
$.add thread.catalogView.nodes.root, thread.OP.nodes.root
$.addClass thread.OP.nodes.root, 'catalog-postContainer'
$.addClass thread.OP.nodes.post, 'catalog-post'
thread.OP.setCatalogOP true
nodes.push thread.catalogView.nodes.root
$.add Index.root, nodes
if doc.contains Index.root

View File

@ -29,11 +29,11 @@ Post.Clone = class extends Post
$.rmClass @nodes.post, 'highlight' # keybind navigation, ID highlighting
# Remove catalog stuff.
$.rmClass @nodes.root, 'catalog-postContainer'
$.rmClass @nodes.post, 'catalog-post'
$.rm $('.catalog-link', @nodes.post)
$.rm $('.catalog-stats', @nodes.post)
$.rm $('.catalog-replies', @nodes.post)
unless @isReply
@setCatalogOP false
$.rm $('.catalog-link', @nodes.post)
$.rm $('.catalog-stats', @nodes.post)
$.rm $('.catalog-replies', @nodes.post)
@parseQuotes()
@quotes = [@origin.quotes...]

View File

@ -258,3 +258,7 @@ class Post
for clone in @clones[index..]
clone.nodes.root.dataset.clone = index++
return
setCatalogOP: (isCatalogOP) ->
@nodes.root.classList.toggle 'catalog-postContainer', isCatalogOP
@nodes.post.classList.toggle 'catalog-post', isCatalogOP