4chan-x/src/Quotelinks/QuoteYou.coffee
Zixaphir 91cedb3b89 Merge branch 'v3' of git://github.com/MayhemYDG/4chan-x into v3
Conflicts:
	CHANGELOG.md
	html/General/Settings-section-Rice.html
	img/changelog/3.9.0/0.png
	package.json
	src/Images/AutoGIF.coffee
	src/Images/RevealSpoilers.coffee
	src/Miscellaneous/ExpandComment.coffee
	src/Miscellaneous/IDColor.coffee
	src/Monitoring/Unread.coffee
	src/Posting/QuickReply.coffee
	src/Quotelinks/QuoteInline.coffee
	src/Quotelinks/QuotePreview.coffee
	src/Quotelinks/QuoteYou.coffee
	src/Quotelinks/Quotify.coffee
2013-10-13 13:53:38 -07:00

65 lines
1.9 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
# \u00A0 is nbsp
@text = '\u00A0(You)'
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 QuoteYou.text
$.addClass quotelink, '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