Fix some bugs with forwardlink indication, and extend it to inlined quotes. #361
This commit is contained in:
parent
77142c23db
commit
6b167d42b9
@ -21,8 +21,6 @@ Get =
|
||||
if index then post.clones[index] else post
|
||||
postFromNode: (root) ->
|
||||
Get.postFromRoot $.x '(ancestor::div[contains(@class,"postContainer")][1]|following::div[contains(@class,"postContainer")][1])', root
|
||||
contextFromNode: (node) ->
|
||||
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', node
|
||||
postDataFromLink: (link) ->
|
||||
if link.hostname is 'boards.4chan.org'
|
||||
path = link.pathname.split /\/+/
|
||||
|
||||
@ -14,7 +14,7 @@ QuoteCT =
|
||||
# Stop there if it's a clone of a post in the same thread.
|
||||
return if @isClone and @thread is @context.thread
|
||||
|
||||
{board, thread} = if @isClone then @context else @
|
||||
{board, thread} = @context
|
||||
for quotelink in @nodes.quotelinks
|
||||
{boardID, threadID} = Get.postDataFromLink quotelink
|
||||
continue unless threadID # deadlink
|
||||
|
||||
@ -34,12 +34,13 @@ QuoteInline =
|
||||
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
|
||||
e.preventDefault()
|
||||
{boardID, threadID, postID} = Get.postDataFromLink @
|
||||
context = Get.contextFromNode @
|
||||
quoter = Get.postFromNode @
|
||||
{context} = quoter
|
||||
if $.hasClass @, 'inlined'
|
||||
QuoteInline.rm @, boardID, threadID, postID, context
|
||||
else
|
||||
return if $.x "ancestor::div[@id='pc#{postID}']", @
|
||||
QuoteInline.add @, boardID, threadID, postID, context
|
||||
QuoteInline.add @, boardID, threadID, postID, context, quoter
|
||||
@classList.toggle 'inlined'
|
||||
|
||||
findRoot: (quotelink, isBacklink) ->
|
||||
@ -48,7 +49,7 @@ QuoteInline =
|
||||
else
|
||||
$.x 'ancestor-or-self::*[parent::blockquote][1]', quotelink
|
||||
|
||||
add: (quotelink, boardID, threadID, postID, context) ->
|
||||
add: (quotelink, boardID, threadID, postID, context, quoter) ->
|
||||
isBacklink = $.hasClass quotelink, 'backlink'
|
||||
inline = $.el 'div',
|
||||
id: "i#{postID}"
|
||||
@ -59,7 +60,7 @@ QuoteInline =
|
||||
qroot = $.x 'ancestor::*[contains(@class,"postContainer")][1]', root
|
||||
|
||||
$.addClass qroot, 'hasInline'
|
||||
new Fetcher boardID, threadID, postID, inline, context
|
||||
new Fetcher boardID, threadID, postID, inline, quoter
|
||||
|
||||
return unless (post = g.posts["#{boardID}.#{postID}"]) and
|
||||
context.thread is post.thread
|
||||
|
||||
@ -24,7 +24,7 @@ QuoteOP =
|
||||
while quotelink = quotelinks[i++]
|
||||
quotelink.textContent = quotelink.textContent.replace QuoteOP.text, ''
|
||||
|
||||
{fullID} = (if @isClone then @context else @).thread
|
||||
{fullID} = @context.thread
|
||||
# add (OP) to quotes quoting this context's OP.
|
||||
|
||||
return unless fullID in quotes
|
||||
|
||||
@ -24,7 +24,7 @@ QuotePreview =
|
||||
className: 'dialog'
|
||||
|
||||
$.add Header.hover, qp
|
||||
new Fetcher boardID, threadID, postID, qp, Get.contextFromNode @
|
||||
new Fetcher boardID, threadID, postID, qp, Get.postFromNode(@)
|
||||
|
||||
UI.hover
|
||||
root: @
|
||||
@ -33,20 +33,12 @@ QuotePreview =
|
||||
endEvents: 'mouseout click'
|
||||
cb: QuotePreview.mouseout
|
||||
|
||||
return unless origin = g.posts["#{boardID}.#{postID}"]
|
||||
|
||||
if Conf['Quote Highlighting']
|
||||
if Conf['Quote Highlighting'] and (origin = g.posts["#{boardID}.#{postID}"])
|
||||
posts = [origin].concat origin.clones
|
||||
# Remove the clone that's in the qp from the array.
|
||||
posts.pop()
|
||||
for post in posts
|
||||
$.addClass post.nodes.post, 'qphl'
|
||||
|
||||
quoterID = $.x('ancestor::*[@id][1]', @).id.match(/\d+$/)[0]
|
||||
clone = Get.postFromRoot qp.firstChild
|
||||
for quote in clone.nodes.quotelinks.concat [clone.nodes.backlinks...]
|
||||
if quote.hash[2..] is quoterID
|
||||
$.addClass quote, 'forwardlink'
|
||||
return
|
||||
|
||||
mouseout: ->
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Fetcher
|
||||
constructor: (@boardID, @threadID, @postID, @root, @context) ->
|
||||
constructor: (@boardID, @threadID, @postID, @root, @quoter) ->
|
||||
if post = g.posts["#{@boardID}.#{@postID}"]
|
||||
@insert post
|
||||
return
|
||||
@ -14,7 +14,7 @@ class Fetcher
|
||||
insert: (post) ->
|
||||
# Stop here if the container has been removed while loading.
|
||||
return unless @root.parentNode
|
||||
clone = post.addClone @context, ($.hasClass @root, 'dialog')
|
||||
clone = post.addClone @quoter.context, ($.hasClass @root, 'dialog')
|
||||
Main.callbackNodes Clone, [clone]
|
||||
|
||||
# Get rid of the side arrows/stubs.
|
||||
@ -22,6 +22,12 @@ class Fetcher
|
||||
$.rmAll nodes.root
|
||||
$.add nodes.root, nodes.post
|
||||
|
||||
# Indicate links to the containing post.
|
||||
quoterURL = "/#{@quoter.board}/thread/#{@quoter.thread}#p#{@quoter}"
|
||||
for quote in clone.nodes.quotelinks.concat [clone.nodes.backlinks...]
|
||||
if quote.pathname + quote.hash is quoterURL
|
||||
$.addClass quote, 'forwardlink'
|
||||
|
||||
$.rmAll @root
|
||||
$.add @root, nodes.root
|
||||
$.event 'PostsInserted'
|
||||
|
||||
@ -26,8 +26,9 @@ class Post
|
||||
@normalizedOriginal = root2
|
||||
<% } %>
|
||||
|
||||
@ID = +root.id[2..]
|
||||
@fullID = "#{@board}.#{@ID}"
|
||||
@ID = +root.id[2..]
|
||||
@fullID = "#{@board}.#{@ID}"
|
||||
@context = @
|
||||
|
||||
post = $ '.post', root
|
||||
info = $ '.postInfo', post
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user