Force stub menu to work

This commit is contained in:
Zixaphir 2013-08-09 18:52:49 -07:00
parent da2a99c0ca
commit 22f4dd698a
8 changed files with 237 additions and 166 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -109,11 +109,12 @@ PostHiding =
PostHiding.hide post, makeStub, replies
else if replies
Recursive.apply PostHiding.hide, post, makeStub, true
Recursive.add PostHiding.hide, post, makeStub, true
Recursive.add PostHiding.hide, post, makeStub, true
else
return
PostHiding.saveHiddenState post, true, thisPost, makeStub, replies
$.event 'CloseMenu'
show: ->
parent = @parentNode
thisPost = $('input[name=thisPost]', parent).checked
@ -123,12 +124,13 @@ PostHiding =
PostHiding.show post, replies
else if replies
Recursive.apply PostHiding.show, post, true
Recursive.rm PostHiding.hide, post, true
Recursive.rm PostHiding.hide, post, true
else
return
if data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
PostHiding.saveHiddenState post, !(thisPost and replies), !thisPost, data.makeStub, !replies
$.event 'CloseMenu'
hideStub: ->
{post} = PostHiding.menu
post.nodes.root.hidden = true
@ -159,10 +161,8 @@ PostHiding =
toggle: ->
post = Get.postFromNode @
if post.isHidden
PostHiding.show post
else
PostHiding.hide post
PostHiding[(if post.isHidden then 'show' else 'hide')] post
PostHiding.saveHiddenState post, post.isHidden
hide: (post, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) ->
@ -171,7 +171,7 @@ PostHiding =
if hideRecursively
Recursive.apply PostHiding.hide, post, makeStub, true
Recursive.add PostHiding.hide, post, makeStub, true
Recursive.add PostHiding.hide, post, makeStub, true
for quotelink in Get.allQuotelinksLinkingTo post
$.addClass quotelink, 'filtered'
@ -185,13 +185,14 @@ PostHiding =
if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', post.nodes.info).textContent
post.info.name
$.add a, $.tn " #{postInfo}"
post.nodes.stub = $.el 'div',
className: 'stub'
$.add post.nodes.stub, a
if Conf['Menu']
$.add post.nodes.stub, [$.tn(' '), Menu.makeButton post]
$.add post.nodes.stub, unless Conf['Menu']
a
else
[a, $.tn(' '), button = Menu.makeButton post]
$.prepend post.nodes.root, post.nodes.stub
show: (post, showRecursively=Conf['Recursive Hiding']) ->

View File

@ -59,10 +59,16 @@ ThreadHiding =
init: ->
return if g.VIEW isnt 'index' or !Conf['Menu'] or !Conf['Thread Hiding Link']
div = $.el 'div',
hide = $.el 'div',
className: 'hide-thread-link'
textContent: 'Hide thread'
show = $.el 'a',
className: 'show-thread-link'
textContent: 'Show thread'
href: 'javascript:;'
$.on show, 'click', ThreadHiding.menu.show
apply = $.el 'a',
textContent: 'Apply'
href: 'javascript:;'
@ -78,7 +84,7 @@ ThreadHiding =
$.event 'AddMenuEntry',
type: 'post'
el: div
el: hide
order: 20
open: ({thread, isReply}) ->
if isReply or thread.isHidden
@ -87,6 +93,16 @@ ThreadHiding =
true
subEntries: [el: apply; el: makeStub]
$.event 'AddMenuEntry',
type: 'post'
el: show
order: 20
open: ({thread, isReply}) ->
if isReply or !thread.isHidden
return false
ThreadHiding.menu.thread = thread
true
$.event 'AddMenuEntry',
type: 'post'
el: hideStubLink
@ -102,6 +118,13 @@ ThreadHiding =
ThreadHiding.hide thread, makeStub
ThreadHiding.saveHiddenState thread, makeStub
$.event 'CloseMenu'
show: ->
{thread} = ThreadHiding.menu
ThreadHiding.show thread
ThreadHiding.saveHiddenState thread
$.event 'CloseMenu'
hideStub: ->
{thread} = ThreadHiding.menu
ThreadHiding.hide thread, false
@ -150,24 +173,28 @@ ThreadHiding =
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr>
return
numReplies = 0
if span = $ '.summary', threadRoot
numReplies = +span.textContent.match /\d+/
numReplies += $$('.opContainer ~ .replyContainer', threadRoot).length
numReplies = if numReplies is 1 then '1 reply' else "#{numReplies} replies"
numReplies = (
if span = $ '.summary', threadRoot
+span.textContent.match /\d+/
else
0
) +
$$('.opContainer ~ .replyContainer', threadRoot).length
numReplies = if numReplies is 1 then '1 reply' else "#{numReplies or 'no'} replies"
opInfo =
if Conf['Anonymize']
'Anonymous'
else
$('.nameBlock', OP.nodes.info).textContent
OP.info.name
a = ThreadHiding.makeButton thread, 'show'
$.add a, $.tn " #{opInfo} (#{numReplies})"
thread.stub = $.el 'div',
className: 'stub'
$.add thread.stub, a
if Conf['Menu']
$.add thread.stub, [$.tn(' '), Menu.makeButton OP]
$.add thread.stub, unless Conf['Menu']
a
else
[a, $.tn(' '), button = Menu.makeButton OP]
$.prepend threadRoot, thread.stub
show: (thread) ->

View File

@ -18,7 +18,7 @@ Get =
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
Get.postFromRoot $.x '(ancestor::div[contains(@class,"postContainer")]|following::div[contains(@class,"postContainer")])[1]', root
contextFromNode: (quotelink) ->
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink
postDataFromLink: (link) ->

View File

@ -1168,6 +1168,7 @@ a.useremail:last-of-type {
.fit-width-replies .stub {
display: block;
text-align: right;
clear: both;
}
/* Element Replacing: */
/* Checkboxes */

View File

@ -1,4 +1,9 @@
Menu =
Menu = do ->
a = $.el 'a',
className: 'menu-button brackets-wrap'
innerHTML: '<span class=drop-marker></span>'
href: 'javascript:;'
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu']
@ -11,18 +16,15 @@ Menu =
if @isClone
button = $ '.menu-button', @nodes.info
else
button = Menu.makeButton @
button = a.cloneNode true
$.add @nodes.info, [$.tn('\u00A0'), button]
$.on button, 'click', Menu.toggle
makeButton: do ->
a = null
->
a or= $.el 'a',
className: 'menu-button brackets-wrap'
innerHTML: '<span class=drop-marker></span>'
href: 'javascript:;'
a.cloneNode true
makeButton: ->
el = a.cloneNode true
$.on el, 'click', Menu.toggle
el
toggle: (e) ->
Menu.menu.toggle e, @, Get.postFromNode @

View File

@ -33,7 +33,7 @@ QuoteYou =
cb:
seek: (type) ->
return unlses Conf['Mark Quotes of You'] and Conf['Quick Reply']
return unless Conf['Mark Quotes of You']
$.rmClass $('.highlight'), 'highlight'
unless QuoteYou.lastRead