From e54a42edebb614100d3a0a375896a9b906544e97 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 24 Sep 2016 23:42:20 -0700 Subject: [PATCH] Have Post object track whether it is being used as a catalog OP. --- src/General/Index.coffee | 14 ++------------ src/classes/Post.Clone.coffee | 3 +-- src/classes/Post.coffee | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index d6a6dc23b..8d6aba467 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -700,7 +700,8 @@ Index = if Conf['Index Mode'] is 'catalog' nodes = Index.buildCatalogViews threads Index.sizeCatalogViews nodes - Index.moveComments threads + for thread in threads + thread.OP.setCatalogOP (Conf['Index Mode'] is 'catalog') if Conf['Index Mode'] is 'catalog' $.add Index.root, nodes if doc.contains Index.root @@ -715,17 +716,6 @@ 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 - {fileRoot, info, comment} = thread.OP.nodes - unless node.contains comment - comment.className = if isCatalog then 'comment' else 'postMessage' - $.prepend node, fileRoot if fileRoot - $.add node, [info, comment] - return - buildStructure: (threads) -> for thread in threads if (file = thread.OP.file) and (thumb = thread.OP.file.thumb) and thumb.dataset.src diff --git a/src/classes/Post.Clone.coffee b/src/classes/Post.Clone.coffee index a6052db4b..2b9b2b1ab 100644 --- a/src/classes/Post.Clone.coffee +++ b/src/classes/Post.Clone.coffee @@ -12,8 +12,7 @@ Post.Clone = class extends Post else (node) -> node.cloneNode true root = cloneNode nodes.root - # Handle case where comment has been moved into catalog thread - if nodes.comment.parentNode isnt nodes.post + if @origin.isCatalogOP $.prepend $('.post', root), cloneNode(nodes.fileRoot) if nodes.fileRoot $.add $('.post', root), [cloneNode(nodes.info), cloneNode(nodes.comment)] Post.Clone.prefix or= 0 diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index fc9fe2cee..2d08945f0 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -36,8 +36,9 @@ class Post @parseQuotes() @parseFile() - @isDead = false - @isHidden = false + @isDead = false + @isHidden = false + @isCatalogOP = false @clones = [] <% if (readJSON('/.tests_enabled')) { %> @@ -257,3 +258,12 @@ class Post for clone in @clones[index..] clone.nodes.root.dataset.clone = index++ return + + setCatalogOP: (isCatalogOP) -> + return if @isCatalogOP is isCatalogOP + @isCatalogOP = isCatalogOP + node = if isCatalogOP then @thread.catalogView.nodes.root else @nodes.post + {fileRoot, info, comment} = @nodes + comment.className = if isCatalogOP then 'comment' else 'postMessage' + $.prepend node, fileRoot if fileRoot + $.add node, [info, comment]