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
This commit is contained in:
Zixaphir 2014-03-11 12:48:23 -07:00 committed by ccd0
parent 635fbaa377
commit 3b04eb6e2a
2 changed files with 30 additions and 10 deletions

View File

@ -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

View File

@ -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: ->