Merge from Appchan X: src/Quotelinks

deferred: QuoteBacklinks.coffee, QuoteMarkers.coffee, and related changes (including change in QuoteInline.qiQuote)
This commit is contained in:
ccd0 2015-02-01 15:42:37 -08:00
parent f89904f4e4
commit 742184d2c0
5 changed files with 29 additions and 18 deletions

View File

@ -26,8 +26,10 @@ QuoteInline =
return
qiQuote: (link, hidden) ->
name = "hashlink"
name += " filtered" if hidden
$.el 'a',
className: "hashlink#{if hidden then ' filtered' else ''}"
className: name
textContent: '#'
href: link.href
@ -39,7 +41,7 @@ QuoteInline =
if $.hasClass @, 'inlined'
QuoteInline.rm @, boardID, threadID, postID, context
else
return if $.x "ancestor::div[@id='p#{postID}']", @
return if $.x "ancestor::div[@id='pc#{postID}']", @
QuoteInline.add @, boardID, threadID, postID, context
@classList.toggle 'inlined'

View File

@ -1,6 +1,6 @@
QuotePreview =
init: ->
return if g.VIEW not in ['index', 'thread'] or !Conf['Quote Previewing']
return unless g.VIEW in ['index', 'thread'] and Conf['Quote Previewing']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node

View File

@ -1,6 +1,7 @@
QuoteStrikeThrough =
init: ->
return if g.VIEW not in ['index', 'thread'] or !Conf['Reply Hiding Buttons'] and !(Conf['Menu'] and Conf['Reply Hiding Link']) and !Conf['Filter']
return unless g.VIEW in ['index', 'thread'] and
(Conf['Reply Hiding Buttons'] or (Conf['Menu'] and Conf['Reply Hiding Link']) or Conf['Filter'])
Post.callbacks.push
name: 'Strike-through Quotes'

View File

@ -15,11 +15,10 @@ QuoteThreading =
hidden: true
$.extend @threadNewLink, <%= html('<a href="javascript:;">Thread New Posts</a>') %>
$.on $('input', @controls), 'change', ->
QuoteThreading.rethread @checked
$.on @threadNewLink.firstElementChild, 'click', ->
QuoteThreading.threadNewLink.hidden = true
QuoteThreading.rethread true
@input = $('input', @controls)
$.on @input, 'change', @cb.thread
$.on @threadNewLink.firstElementChild, 'click', @cb.click
Header.menu.addEntry @entry =
el: @controls
@ -45,10 +44,10 @@ QuoteThreading =
node: ->
return if @isFetchedQuote or @isClone or !@isReply
{thread} = QuoteThreading
parents = for quote in @quotes
parent = g.posts[quote]
continue if !parent or parent.isFetchedQuote or !parent.isReply or parent.ID >= @ID
parent
parents = (parent for quote in @quotes when (parent = g.posts[quote]) and
not parent.isFetchedQuote and parent.isReply and parent.ID < @ID
)
if parents.length is 1
QuoteThreading.parent[@fullID] = parents[0]
@ -65,9 +64,10 @@ QuoteThreading =
!QuoteThreading.inserted[post.fullID]
descendants = QuoteThreading.descendants post
if !Unread.posts.has(parent.ID) and descendants.some((x) -> Unread.posts.has(x.ID))
QuoteThreading.threadNewLink.hidden = false
return false
if !Unread.posts.has(parent.ID)
if (do -> return true for x in descendants when Unread.posts.has x.ID)
QuoteThreading.threadNewLink.hidden = false
return false
{order} = Unread
children = (QuoteThreading.children[parent.fullID] or= [])
@ -107,7 +107,7 @@ QuoteThreading =
posts.forEach QuoteThreading.insert
else
nodes = []
Unread.order = new RandomAccessList
Unread.order = new RandomAccessList()
QuoteThreading.inserted = {}
posts.forEach (post) ->
return if post.isFetchedQuote
@ -125,3 +125,9 @@ QuoteThreading =
Unread.setLine true
Unread.read()
Unread.update()
cb:
thread: -> QuoteThreading.rethread QuoteThreading.input.checked
click: ->
QuoteThreading.threadNewLink.hidden = true
QuoteThreading.rethread true

View File

@ -74,7 +74,9 @@ Quotify =
@quotes.push quoteID unless quoteID in @quotes
return deadlink.textContent = "#{quote}\u00A0(Dead)" unless a
unless a
deadlink.textContent = "#{quote}\u00A0(Dead)"
return
$.replace deadlink, a
if $.hasClass a, 'quotelink'