4chan-x/src/Quotelinks/QuotePreview.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.7 KiB
CoffeeScript
Executable File

QuotePreview =
init: ->
return if g.VIEW is 'catalog' or !Conf['Quote Previewing']
if Conf['Comment Expansion']
ExpandComment.callbacks.push @node
Post.callbacks.push
name: 'Quote Previewing'
cb: @node
node: ->
for link in @nodes.quotelinks.concat [@nodes.backlinks...]
$.on link, 'mouseover', QuotePreview.mouseover
return
mouseover: (e) ->
return if $.hasClass @, 'inlined'
{boardID, threadID, postID} = Get.postDataFromLink @
qp = $.el 'div',
id: 'qp'
className: 'dialog'
$.add Header.hover, qp
Get.postClone boardID, threadID, postID, qp, Get.contextFromNode @
UI.hover
root: @
el: qp
latestEvent: e
endEvents: 'mouseout click'
cb: QuotePreview.mouseout
asapTest: -> qp.firstElementChild
return unless origin = g.posts["#{boardID}.#{postID}"]
if Conf['Quote Highlighting']
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: ->
# Stop if it only contains text.
return unless root = @el.firstElementChild
clone = Get.postFromRoot root
post = clone.origin
post.rmClone root.dataset.clone
return unless Conf['Quote Highlighting']
for post in [post].concat post.clones
$.rmClass post.nodes.post, 'qphl'
return