Make the hidden label an integral part of the index.

This commit is contained in:
Mayhem 2014-02-01 20:42:59 +01:00
parent aeb1147bb3
commit b9e8ff0b19
3 changed files with 8 additions and 16 deletions

View File

@ -2,3 +2,4 @@
[<time id="index-last-refresh" title="Last index refresh">...</time>]&nbsp;
<input type="search" id="index-search" class="field" placeholder="Search">
<a id="index-search-clear" class="fa fa-times-circle" href="javascript:;"></a>
<span id="hidden-label" hidden> &mdash; <span id="hidden-count"></span></span>

View File

@ -157,7 +157,7 @@ ThreadHiding =
return if thread.isHidden
threadRoot = thread.OP.nodes.root.parentNode
thread.isHidden = true
Index.updateHideToggle()
Index.updateHideLabel()
unless makeStub
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr>
@ -172,4 +172,4 @@ ThreadHiding =
threadRoot = thread.OP.nodes.root.parentNode
threadRoot.nextElementSibling.hidden =
threadRoot.hidden = thread.isHidden = false
Index.updateHideToggle()
Index.updateHideLabel()

View File

@ -96,6 +96,7 @@ Index =
className: 'navLinks'
innerHTML: <%= importHTML('General/Index-navlinks') %>
@searchInput = $ '#index-search', @navLinks
@hideLabel = $ '#hidden-label', @navLinks
@currentPage = @getCurrentPage()
$.on window, 'popstate', @cb.popstate
$.on @pagelist, 'click', @cb.pageNav
@ -249,28 +250,18 @@ Index =
$.before a, strong
$.add strong, a
updateHideToggle: ->
updateHideLabel: ->
hiddenCount = 0
for threadID, thread of g.BOARD.threads when thread.isHidden
hiddenCount++ if thread.ID in Index.liveThreadIDs
unless hiddenCount
Index.removeHideToggle()
Index.hideLabel.hidden = true
return
unless Index.toggler
Index.addHideToggle()
Index.hideLabel.hidden = false
$('#hidden-count', Index.navLinks).textContent = if hiddenCount is 1
'1 hidden thread'
else
"#{hiddenCount} hidden threads"
addHideToggle: ->
Index.toggler = $.el 'span',
id: 'hidden-label'
innerHTML: ' &mdash; <span id="hidden-count"></span>'
$.add Index.navLinks, Index.toggler
removeHideToggle: ->
return unless Index.toggler
$.rm Index.toggler
delete Index.toggler
update: (pageNum) ->
return unless navigator.onLine
@ -390,7 +381,7 @@ Index =
$.nodes Index.nodes
Main.callbackNodes Thread, threads
Main.callbackNodes Post, posts
Index.updateHideToggle()
Index.updateHideLabel()
$.event 'IndexRefresh'
buildReplies: (threadRoots) ->
posts = []