Fix post menus in stubs.
Also removed some old arguments, fixed some semantics, added Get.threadFromNode, and used it.
This commit is contained in:
parent
6769610899
commit
3581a235e7
@ -166,7 +166,7 @@ PostHiding =
|
||||
className: 'stub'
|
||||
$.add post.nodes.stub, a
|
||||
if Conf['Menu']
|
||||
$.add post.nodes.stub, [$.tn(' '), Menu.makeButton post]
|
||||
$.add post.nodes.stub, [$.tn(' '), Menu.makeButton()]
|
||||
$.prepend post.nodes.root, post.nodes.stub
|
||||
|
||||
show: (post, showRecursively=Conf['Recursive Hiding']) ->
|
||||
|
||||
@ -151,7 +151,7 @@ ThreadHiding =
|
||||
className: 'stub'
|
||||
$.add thread.stub, a
|
||||
if Conf['Menu']
|
||||
$.add thread.stub, [$.tn(' '), Menu.makeButton OP]
|
||||
$.add thread.stub, [$.tn(' '), Menu.makeButton()]
|
||||
$.prepend threadRoot, thread.stub
|
||||
|
||||
show: (thread) ->
|
||||
|
||||
@ -10,6 +10,8 @@ Get =
|
||||
"/#{thread.board}/ - #{excerpt}"
|
||||
threadFromRoot: (root) ->
|
||||
g.threads["#{g.BOARD}.#{root.id[1..]}"]
|
||||
threadFromNode: (node) ->
|
||||
Get.threadFromRoot $.x 'ancestor::div[@class="thread"]', node
|
||||
postFromRoot: (root) ->
|
||||
link = $ 'a[title="Highlight this post"]', root
|
||||
boardID = link.pathname.split('/')[1]
|
||||
@ -17,10 +19,10 @@ Get =
|
||||
index = root.dataset.clone
|
||||
post = g.posts["#{boardID}.#{postID}"]
|
||||
if index then post.clones[index] else post
|
||||
postFromNode: (root) ->
|
||||
Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', root
|
||||
contextFromNode: (quotelink) ->
|
||||
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink
|
||||
postFromNode: (node) ->
|
||||
Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', node
|
||||
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 '/'
|
||||
|
||||
@ -10,10 +10,10 @@ Menu =
|
||||
node: ->
|
||||
if @isClone
|
||||
button = $ '.menu-button', @nodes.info
|
||||
else
|
||||
button = Menu.makeButton @
|
||||
$.add @nodes.info, [$.tn('\u00A0'), button]
|
||||
$.on button, 'click', Menu.toggle
|
||||
$.on button, 'click', Menu.toggle
|
||||
return
|
||||
button = Menu.makeButton()
|
||||
$.add @nodes.info, [$.tn('\u00A0'), button]
|
||||
|
||||
makeButton: do ->
|
||||
a = null
|
||||
@ -22,7 +22,15 @@ Menu =
|
||||
className: 'menu-button'
|
||||
innerHTML: '[<i></i>]'
|
||||
href: 'javascript:;'
|
||||
a.cloneNode true
|
||||
button = a.cloneNode true
|
||||
$.on button, 'click', Menu.toggle
|
||||
button
|
||||
|
||||
toggle: (e) ->
|
||||
Menu.menu.toggle e, @, Get.postFromNode @
|
||||
try
|
||||
# Posts, inlined posts, hidden replies.
|
||||
post = Get.postFromNode @
|
||||
catch
|
||||
# Hidden threads.
|
||||
post = Get.threadFromNode(@).OP
|
||||
Menu.menu.toggle e, @, post
|
||||
|
||||
@ -23,7 +23,7 @@ ExpandThread =
|
||||
text.join(' ') + '.'
|
||||
|
||||
cbToggle: ->
|
||||
ExpandThread.toggle Get.threadFromRoot @parentNode
|
||||
ExpandThread.toggle Get.threadFromNode @
|
||||
|
||||
toggle: (thread) ->
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
|
||||
@ -340,7 +340,7 @@ QR =
|
||||
$.addClass QR.nodes.el, 'dump'
|
||||
QR.cooldown.auto = true
|
||||
{com, thread} = QR.nodes
|
||||
thread.value = Get.contextFromNode(@).thread unless com.value
|
||||
thread.value = Get.threadFromNode @ unless com.value
|
||||
|
||||
caretPos = com.selectionStart
|
||||
# Replace selection for text.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user