Add hidden threads count on the index.
This commit is contained in:
parent
c5490f6aec
commit
0092c53783
@ -24,7 +24,29 @@ ThreadHiding =
|
|||||||
else unless root.contains thread.stub
|
else unless root.contains thread.stub
|
||||||
# When we come back to a page, the stub is already there.
|
# When we come back to a page, the stub is already there.
|
||||||
ThreadHiding.makeStub thread, root
|
ThreadHiding.makeStub thread, root
|
||||||
|
ThreadHiding.updateToggle()
|
||||||
|
updateToggle: ->
|
||||||
|
hiddenCount = 0
|
||||||
|
for threadID, thread of g.BOARD.threads when thread.isHidden
|
||||||
|
hiddenCount++ if thread.ID in Index.liveThreadIDs
|
||||||
|
unless hiddenCount
|
||||||
|
ThreadHiding.removeToggle()
|
||||||
return
|
return
|
||||||
|
unless ThreadHiding.toggler
|
||||||
|
ThreadHiding.addToggle()
|
||||||
|
$('#hidden-count', Index.navLinks).textContent = if hiddenCount is 1
|
||||||
|
'1 hidden thread'
|
||||||
|
else
|
||||||
|
"#{hiddenCount} hidden threads"
|
||||||
|
addToggle: ->
|
||||||
|
ThreadHiding.toggler = $.el 'span',
|
||||||
|
id: 'hidden-label'
|
||||||
|
innerHTML: ' — <span id="hidden-count"></span>'
|
||||||
|
$.add Index.navLinks, ThreadHiding.toggler
|
||||||
|
removeToggle: ->
|
||||||
|
return unless ThreadHiding.toggler
|
||||||
|
$.rm ThreadHiding.toggler
|
||||||
|
delete ThreadHiding.toggler
|
||||||
|
|
||||||
syncCatalog: ->
|
syncCatalog: ->
|
||||||
# Sync hidden threads from the catalog into the index.
|
# Sync hidden threads from the catalog into the index.
|
||||||
@ -157,6 +179,7 @@ ThreadHiding =
|
|||||||
return if thread.isHidden
|
return if thread.isHidden
|
||||||
threadRoot = thread.OP.nodes.root.parentNode
|
threadRoot = thread.OP.nodes.root.parentNode
|
||||||
thread.isHidden = true
|
thread.isHidden = true
|
||||||
|
ThreadHiding.updateToggle()
|
||||||
|
|
||||||
unless makeStub
|
unless makeStub
|
||||||
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr>
|
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr>
|
||||||
@ -171,3 +194,4 @@ ThreadHiding =
|
|||||||
threadRoot = thread.OP.nodes.root.parentNode
|
threadRoot = thread.OP.nodes.root.parentNode
|
||||||
threadRoot.nextElementSibling.hidden =
|
threadRoot.nextElementSibling.hidden =
|
||||||
threadRoot.hidden = thread.isHidden = false
|
threadRoot.hidden = thread.isHidden = false
|
||||||
|
ThreadHiding.updateToggle()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user