From 823ddb9d468249214e9f73057283a1e9368d177a Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 21 Sep 2016 03:44:03 -0700 Subject: [PATCH] Change quote markers from textContent to styleable spans. --- src/Quotelinks/QuoteBacklink.coffee | 3 ++- src/Quotelinks/QuoteCT.coffee | 8 +++++--- src/Quotelinks/QuoteOP.coffee | 8 +++++--- src/Quotelinks/QuoteYou.coffee | 6 ++++-- src/Quotelinks/Quotify.coffee | 8 +++++--- src/classes/Post.coffee | 10 ++++++++-- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index 1250ac728..995cc568d 100644 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -26,7 +26,8 @@ QuoteBacklink = a = $.el 'a', href: Build.postURL @board.ID, @thread.ID, @ID className: if @isHidden then 'filtered backlink' else 'backlink' - textContent: Conf['backlink'].replace(/%(?:id|%)/g, (x) => {'%id': @ID, '%%': '%'}[x]) + (if markYours then '\u00A0(You)' else '') + textContent: Conf['backlink'].replace(/%(?:id|%)/g, (x) => {'%id': @ID, '%%': '%'}[x]) + $.add a, QuoteYou.mark.cloneNode(true) if markYours for quote in @quotes containers = [QuoteBacklink.getContainer quote] if (post = g.posts[quote]) and post.nodes.backlinkContainer diff --git a/src/Quotelinks/QuoteCT.coffee b/src/Quotelinks/QuoteCT.coffee index 97563787c..fa7104ccf 100644 --- a/src/Quotelinks/QuoteCT.coffee +++ b/src/Quotelinks/QuoteCT.coffee @@ -6,7 +6,9 @@ QuoteCT = ExpandComment.callbacks.push @node # \u00A0 is nbsp - @text = '\u00A0(Cross-thread)' + @mark = $.el 'span', + textContent: '\u00A0(Cross-thread)' + className: 'qmark-ct' Callbacks.Post.push name: 'Mark Cross-thread Quotes' cb: @node @@ -19,7 +21,7 @@ QuoteCT = {boardID, threadID} = Get.postDataFromLink quotelink continue unless threadID # deadlink if @isClone - quotelink.textContent = quotelink.textContent.replace QuoteCT.text, '' + $.rm $('.qmark-ct', quotelink) if boardID is board.ID and threadID isnt thread.ID - $.add quotelink, $.tn QuoteCT.text + $.add quotelink, QuoteCT.mark.cloneNode(true) return diff --git a/src/Quotelinks/QuoteOP.coffee b/src/Quotelinks/QuoteOP.coffee index 7a4a02612..d7464083a 100644 --- a/src/Quotelinks/QuoteOP.coffee +++ b/src/Quotelinks/QuoteOP.coffee @@ -6,7 +6,9 @@ QuoteOP = ExpandComment.callbacks.push @node # \u00A0 is nbsp - @text = '\u00A0(OP)' + @mark = $.el 'span', + textContent: '\u00A0(OP)' + className: 'qmark-op' Callbacks.Post.push name: 'Mark OP Quotes' cb: @node @@ -22,7 +24,7 @@ QuoteOP = if @isClone and @thread.fullID in quotes i = 0 while quotelink = quotelinks[i++] - quotelink.textContent = quotelink.textContent.replace QuoteOP.text, '' + $.rm $('.qmark-op', quotelink) {fullID} = @context.thread # add (OP) to quotes quoting this context's OP. @@ -32,5 +34,5 @@ QuoteOP = while quotelink = quotelinks[i++] {boardID, postID} = Get.postDataFromLink quotelink if "#{boardID}.#{postID}" is fullID - $.add quotelink, $.tn QuoteOP.text + $.add quotelink, QuoteOP.mark.cloneNode(true) return diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index 7041382b4..c6d9ad9c3 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -22,7 +22,9 @@ QuoteYou = ExpandComment.callbacks.push @node # \u00A0 is nbsp - @text = '\u00A0(You)' + @mark = $.el 'span', + textContent: '\u00A0(You)' + className: 'qmark-you' Callbacks.Post.push name: 'Mark Quotes of You' cb: @node @@ -37,7 +39,7 @@ QuoteYou = return unless @quotes.length for quotelink in @nodes.quotelinks when QuoteYou.db.get Get.postDataFromLink quotelink - $.add quotelink, $.tn QuoteYou.text if Conf['Mark Quotes of You'] + $.add quotelink, QuoteYou.mark.cloneNode(true) if Conf['Mark Quotes of You'] $.addClass quotelink, 'you' $.addClass @nodes.root, 'quotesYou' return diff --git a/src/Quotelinks/Quotify.coffee b/src/Quotelinks/Quotify.coffee index 604550fc5..2be194673 100644 --- a/src/Quotelinks/Quotify.coffee +++ b/src/Quotelinks/Quotify.coffee @@ -65,7 +65,8 @@ Quotify = a = $.el 'a', href: Build.postURL boardID, post.thread.ID, postID className: 'quotelink deadlink' - textContent: "#{quote}\u00A0(Dead)" + textContent: quote + $.add a, Post.deadMark.cloneNode(true) $.extend a.dataset, {boardID, threadID: post.thread.ID, postID} else @@ -76,7 +77,8 @@ Quotify = a = $.el 'a', href: redirect or 'javascript:;' className: 'deadlink' - textContent: "#{quote}\u00A0(Dead)" + textContent: quote + $.add a, Post.deadMark.cloneNode(true) if fetchable # Make it function as a normal quote if we can fetch the post. $.addClass a, 'quotelink' @@ -85,7 +87,7 @@ Quotify = @quotes.push quoteID unless quoteID in @quotes unless a - deadlink.textContent = "#{quote}\u00A0(Dead)" + $.add deadlink, Post.deadMark.cloneNode(true) return $.replace deadlink, a diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index 9aebf6937..ccfb665d4 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -186,6 +186,12 @@ class Post MD5: thumb.dataset.md5 isSpoiler: $.hasClass thumb.parentNode, 'imgspoiler' + @deadMark = + # \u00A0 is nbsp + $.el 'span', + textContent: '\u00A0(Dead)' + className: 'qmark-dead' + kill: (file) -> if file return if @isDead or @file.isDead @@ -211,7 +217,7 @@ class Post # Get quotelinks/backlinks to this post # and paint them (Dead). for quotelink in Get.allQuotelinksLinkingTo @ when not $.hasClass quotelink, 'deadlink' - quotelink.textContent = quotelink.textContent + '\u00A0(Dead)' + $.add quotelink, Post.deadMark.cloneNode(true) $.addClass quotelink, 'deadlink' return @@ -232,7 +238,7 @@ class Post clone.resurrect() for quotelink in Get.allQuotelinksLinkingTo @ when $.hasClass quotelink, 'deadlink' - quotelink.textContent = quotelink.textContent.replace '\u00A0(Dead)', '' + $.rm $('.qmark-dead', quotelink) $.rmClass quotelink, 'deadlink' return