From 3b04eb6e2a307fc9a47c3314818e6a472b49f24a Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 11 Mar 2014 12:48:23 -0700 Subject: [PATCH] Reflow Navigate.node, allow navigation from backlinks and their hashes Conflicts: builds/4chan-X.user.js builds/crx/script.js src/General/Navigate.coffee src/Quotelinks/QuoteBacklink.coffee --- src/General/Navigate.coffee | 31 ++++++++++++++++++++--------- src/Quotelinks/QuoteBacklink.coffee | 9 ++++++++- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 2f323083c..d75489276 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -23,16 +23,29 @@ Navigate = $.on replyLink, 'click', Navigate.navigate post: -> # Allows us to navigate via JSON from thread to thread by hashes and quote highlights. - if Conf['Quote Hash Navigation'] - for hashlink in $$ '.hashlink', @nodes.comment - {boardID, threadID, postID} = Get.postDataFromLink hashlink - if boardID isnt g.BOARD.ID or (threadID isnt g.THREADID) - $.on hashlink, 'click', Navigate.navigate - # We don't need to reload the thread inside the thread - return if g.VIEW is 'thread' and @thread.ID is g.THREADID - postlink = $ 'a[title="Link to this post"]', @nodes.info - $.on postlink, 'click', Navigate.navigate + unless g.VIEW is 'thread' and @thread.ID is g.THREADID + $.on $('a[title="Link to this post"]', @nodes.info), 'click', Navigate.navigate + + return unless (linktype = if Conf['Quote Inlining'] and Conf['Quote Hash Navigation'] + '.hashlink' + else if !Conf['Quote Inlining'] + '.quotelink' + else + null + ) + + Navigate.quoteLink $$ linktype, @nodes.comment + + quoteLink: (links) -> + for link in links + Navigate.singleQuoteLink link + return + + singleQuoteLink: (link) -> + {boardID, threadID} = Get.postDataFromLink link + if g.VIEW is 'index' or boardID isnt g.BOARD.ID or threadID isnt g.THREADID + $.on link, 'click', Navigate.navigate clean: -> # Garbage collection diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index c033482b1..025d93577 100755 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -42,7 +42,14 @@ QuoteBacklink = $.on link, 'mouseover', QuotePreview.mouseover if Conf['Quote Inlining'] $.on link, 'click', QuoteInline.toggle - nodes.push QuoteInline.qiQuote link, $.hasClass link, 'filtered' if Conf['Quote Hash Navigation'] + if Conf['Quote Hash Navigation'] + hash = QuoteInline.qiQuote link, $.hasClass link, 'filtered' + nodes.push hash + if Conf['JSON Navigation'] + if hash + Navigate.singleQuoteLink hash + else unless Conf['Quote Inlining'] + Navigate.singleQuoteLink link $.add container, nodes return secondNode: ->