4chan-x/src/Quotelinks/QuoteYou.coffee
Zixaphir ec32e54ef5 Merge branch 'v3' of git://github.com/MayhemYDG/4chan-x into v3
Conflicts:
	css/style.css
	src/General/Config.coffee
	src/General/meta/manifest.json
	src/Posting/QuickReply.coffee
2013-08-17 21:00:31 -07:00

62 lines
1.8 KiB
CoffeeScript
Executable File

QuoteYou =
init: ->
return unless g.VIEW isnt 'catalog' and Conf['Mark Quotes of You'] and Conf['Quick Reply']
if Conf['Highlight Own Posts']
$.addClass doc, 'highlight-own'
if Conf['Highlight Posts Quoting You']
$.addClass doc, 'highlight-you'
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
Post::callbacks.push
name: 'Mark Quotes of You'
cb: @node
node: ->
return if @isClone
if @info.yours
$.addClass @nodes.root, 'yourPost'
# Stop there if there's no quotes in that post.
return unless @quotes.length
for quotelink in @nodes.quotelinks when QR.db.get Get.postDataFromLink quotelink
$.add quotelink, $.tn '\u00A0(You)'
$.addClass @nodes.root, 'quotesYou'
return
cb:
seek: (type) ->
return unless Conf['Mark Quotes of You'] and Conf['Quick Reply']
$.rmClass highlight, 'highlight' if highlight = $ '.highlight'
unless QuoteYou.lastRead
unless post = QuoteYou.lastRead = $ '.quotesYou'
new Notice 'warning', 'No posts are currently quoting you, loser.', 20
return
return if QuoteYou.cb.scroll post
else
post = QuoteYou.lastRead
str = "#{type}::div[contains(@class,'quotesYou')]"
while post = (result = $.X(str, post)).snapshotItem(if type is 'preceding' then result.snapshotLength - 1 else 0)
return if QuoteYou.cb.scroll post
posts = $$ '.quotesYou'
QuoteYou.cb.scroll posts[if type is 'following' then 0 else posts.length - 1]
scroll: (post) ->
if Get.postFromRoot(post).isHidden
return false
else
QuoteYou.lastRead = post
window.location = "##{post.id}"
Header.scrollToPost post
$.addClass $('.post', post), 'highlight'
return true