Hide threads like we hide them in the catalog.

This commit is contained in:
Mayhem 2014-02-19 04:25:26 +01:00
parent 0e3f90fe4f
commit 0ea3c733a4
9 changed files with 83 additions and 109 deletions

View File

@ -1,6 +1,12 @@
- The posts' menu now has a label entry listing the reasons why a post got hidden or highlighted.
- `Thread Hiding` and `Reply Hiding` settings are merged into one: `Post Hiding`.
- `Thread Hiding Link` and `Reply Hiding Link` settings are merged into one: `Post Hiding Link`.
- Thread and post hiding changes:
- The posts' menu now has a label entry listing the reasons why a post got hidden or highlighted.
- `Thread Hiding` and `Reply Hiding` settings are merged into one: `Post Hiding`.
- `Thread Hiding Link` and `Reply Hiding Link` settings are merged into one: `Post Hiding Link`.
- Hiding a thread removes it from the index in `Paged` or `All threads` modes.
<ul>
<li> Hidden threads can be seen by clicking the `[Show]` button the the top of the index.
<li> The `Anchor Hidden Threads` setting has been removed.
</ul>
### 3.18.1 - *2014-02-20*

View File

@ -368,7 +368,6 @@ a[href="javascript:;"] {
:root.index-loading .navLinks,
:root.index-loading .board,
:root.index-loading .pagelist,
:root:not(.catalog-mode) #hidden-toggle,
:root:not(.catalog-mode) #index-size {
display: none;
}
@ -710,15 +709,12 @@ a.hide-announcement {
.hide-post-button,
.show-post-button {
font-size: 14px;
line-height: 12px; /* Prevent the floating effect from affecting the thumbnail too */
}
.opContainer > .show-post-button,
.hide-post-button {
float: left;
margin-right: 3px;
margin-bottom: -1em; /* Prevent the floating effect from affecting the thumbnail too */
}
.thread[hidden] + hr,
.stub ~ * {
display: none !important;
}
.stub input {
display: inline-block;

View File

@ -35,11 +35,12 @@ PostHiding =
@hide 'Manually hidden', data.makeStub, data.hideRecursively
return unless Conf['Post Hiding']
a = PostHiding.makeButton true
if @isReply
a = PostHiding.makeButton true
a.hidden = true if @isHidden
$.replace $('.sideArrows', @nodes.root), a
else
$.prepend @nodes.root, a
$.prepend @nodes.root, PostHiding.makeButton !@isHidden
makeButton: (hide) ->
a = (if hide then PostHiding.hideButton else PostHiding.showButton).cloneNode true
@ -57,6 +58,10 @@ PostHiding =
else
post.hide 'Manually hidden'
PostHiding.saveHiddenState post
return if post.isReply
Index.updateHideLabel()
Index.sort()
Index.buildIndex()
saveHiddenState: (post, val) ->
data =
@ -66,7 +71,7 @@ PostHiding =
if post.isHidden or val and !val.thisPost
data.val = val or {}
PostHiding.db.set data
else
else if PostHiding.db.get data # unhiding a filtered post f.e.
PostHiding.db.delete data
menu:
@ -83,22 +88,18 @@ PostHiding =
true
thisPost =
el: $.el 'label', innerHTML: '<input type=checkbox name=thisPost checked> This post'
open: (post) -> post.isReply
replies =
el: $.el 'label', innerHTML: "<input type=checkbox name=replies checked=#{Conf['Recursive Hiding']}> Hide replies"
open: (post) -> post.isReply
makeStub =
el: $.el 'label', innerHTML: "<input type=checkbox name=makeStub checked=#{Conf['Stubs']}> Make stub"
$.event 'AddMenuEntry',
type: 'post'
el: $.el 'div', className: 'hide-post-link'
el: $.el 'div',
textContent: 'Hide post'
className: 'hide-post-link'
order: 20
open: (post) ->
if !post.isReply and g.VIEW isnt 'index' or Conf['Index Mode'] is 'catalog' and g.VIEW is 'index' or post.isClone or post.isHidden
return false
@el.textContent = if post.isReply then 'Hide reply' else 'Hide thread'
true
open: (post) -> !(post.isHidden or !post.isReply or post.isClone)
subEntries: [apply, thisPost, replies, makeStub]
# Show
@ -115,7 +116,7 @@ PostHiding =
@el.firstChild.checked = post.isHidden
true
replies =
el: $.el 'label', innerHTML: "<input type=checkbox name=replies> Unhide replies"
el: $.el 'label', innerHTML: '<input type=checkbox name=replies> Unhide replies'
open: (post) ->
data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
@el.firstChild.checked = if 'hideRecursively' of data then data.hideRecursively else Conf['Recursive Hiding']
@ -123,36 +124,49 @@ PostHiding =
$.event 'AddMenuEntry',
type: 'post'
el: $.el 'div', className: 'show-post-link'
el: $.el 'div',
textContent: 'Unhide post'
className: 'show-post-link'
order: 20
open: (post) ->
if !post.isReply or post.isClone or !post.isHidden
if !post.isHidden or !post.isReply or post.isClone
return false
unless PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
return false
@el.textContent = if post.isReply then 'Unhide reply' else 'Unhide thread'
true
subEntries: [apply, thisPost, replies]
return if g.VIEW isnt 'index'
$.event 'AddMenuEntry',
type: 'post'
el: $.el 'a', href: 'javascript:;'
order: 20
open: (post) ->
@el.textContent = if post.isHidden
'Unhide thread'
else
'Hide thread'
$.off @el, 'click', @cb if @cb
@cb = ->
$.event 'CloseMenu'
PostHiding.toggle post
$.on @el, 'click', @cb
true
hide: (post) ->
parent = @parentNode
thisPost = $('input[name=thisPost]', parent).checked if post.isReply
replies = $('input[name=replies]', parent).checked if post.isReply
thisPost = $('input[name=thisPost]', parent).checked
replies = $('input[name=replies]', parent).checked
makeStub = $('input[name=makeStub]', parent).checked
label = 'Manually hidden'
if !post.isReply
post.hide label, makeStub
else if thisPost
if thisPost
post.hide label, makeStub, replies
else if replies
Recursive.apply 'hide', post, label, makeStub, true
Recursive.add 'hide', post, label, makeStub, true
else
return
val = if post.isReply
{thisPost, hideRecursively: replies, makeStub}
else
{makeStub}
PostHiding.saveHiddenState post, val
PostHiding.saveHiddenState post, {thisPost, hideRecursively: replies, makeStub}
$.event 'CloseMenu'
show: (post) ->
parent = @parentNode

View File

@ -18,7 +18,7 @@ Config =
'Anonymize': [false, 'Make everyone Anonymous.']
'Filter': [true, 'Self-moderation placebo.']
'Post Hiding': [true, 'Add buttons to hide threads and replies.']
'Stubs': [true, 'Show stubs of hidden threads / replies.']
'Stubs': [true, 'Show stubs of hidden threads and replies.']
'Recursive Hiding': [true, 'Hide replies of hidden posts, recursively.']
'Images':
'Auto-GIF': [false, 'Animate GIF thumbnails (disabled on /gif/, /wsg/).']
@ -141,7 +141,6 @@ Config =
'Threads per Page': 0
'Open threads in a new tab': false
'Show Replies': true
'Anchor Hidden Threads': true
'Refreshed Navigation': false
Header:
'Header auto-hide': false

View File

@ -232,6 +232,6 @@ Get =
thread = g.threads["#{boardID}.#{threadID}"] or
new Thread threadID, board
post = new Post Build.post(o, true), thread, board, {isArchived: true}
$('.page-num', post.nodes.info).hidden = true
$('.page-num', post.nodes.info).hidden = true unless post.isReply
Main.callbackNodes Post, [post]
Get.insert post, root, context

View File

@ -38,15 +38,11 @@ Index =
repliesEntry =
el: $.el 'label',
innerHTML: '<input type=checkbox name="Show Replies"> Show replies'
anchorEntry =
el: $.el 'label',
innerHTML: '<input type=checkbox name="Anchor Hidden Threads"> Anchor hidden threads'
title: 'Move hidden threads at the end of the index.'
refNavEntry =
el: $.el 'label',
innerHTML: '<input type=checkbox name="Refreshed Navigation"> Refreshed navigation'
title: 'Refresh index when navigating through pages.'
for label in [targetEntry, repliesEntry, anchorEntry, refNavEntry]
for label in [targetEntry, repliesEntry, refNavEntry]
input = label.el.firstChild
{name} = input
input.checked = Conf[name]
@ -56,15 +52,13 @@ Index =
$.on input, 'change', @cb.target
when 'Show Replies'
$.on input, 'change', @cb.replies
when 'Anchor Hidden Threads'
$.on input, 'change', @cb.sort
$.event 'AddMenuEntry',
type: 'header'
el: $.el 'span',
textContent: 'Index Navigation'
order: 90
subEntries: [threadNumEntry, targetEntry, repliesEntry, anchorEntry, refNavEntry]
subEntries: [threadNumEntry, targetEntry, repliesEntry, refNavEntry]
$.addClass doc, 'index-loading'
@update()
@ -124,24 +118,7 @@ Index =
$.event 'AddMenuEntry',
type: 'post'
el: $.el 'a', href: 'javascript:;'
order: 5
open: (post) ->
return false if Conf['Index Mode'] isnt 'catalog'
@el.textContent = if post.isHidden
'Unhide thread'
else
'Hide thread'
$.off @el, 'click', @cb if @cb
@cb = ->
$.event 'CloseMenu'
PostHiding.toggle post
$.on @el, 'click', @cb
true
$.event 'AddMenuEntry',
type: 'post'
el: $.el 'a', href: 'javascript:;'
order: 6
order: 19
open: ({thread}) ->
return false if Conf['Index Mode'] isnt 'catalog'
@el.textContent = if thread.isPinned
@ -573,9 +550,7 @@ Index =
Main.handleErrors errors if errors
Main.callbackNodes Post, posts
buildCatalogViews: ->
threads = Index.sortedNodes
.map (threadRoot) -> Get.threadFromRoot threadRoot
.filter (thread) -> !thread.isHidden isnt Index.showHiddenThreads
threads = Index.sortedNodes.map (threadRoot) -> Get.threadFromRoot threadRoot
catalogThreads = []
for thread in threads when !thread.catalogView
catalogThreads.push new CatalogThread Build.catalogThread(thread), thread
@ -608,16 +583,15 @@ Index =
sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> b.replies - a.replies).map (data) -> data.no
when 'filecount'
sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> b.images - a.images).map (data) -> data.no
Index.sortedNodes = sortedThreadIDs.map (threadID) ->
Index.nodes[Index.liveThreadIDs.indexOf threadID]
Index.sortedNodes = sortedThreadIDs
.map (threadID) -> Index.nodes[Index.liveThreadIDs.indexOf threadID]
.filter (threadRoot) -> Get.threadFromRoot(threadRoot).isHidden is Index.showHiddenThreads
if Index.isSearching
Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes
# Sticky threads
Index.sortOnTop (thread) -> thread.isSticky
# Highlighted threads
Index.sortOnTop (thread) -> thread.isOnTop or thread.isPinned
# Non-hidden threads
Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads']
sortOnTop: (match) ->
offset = 0
for threadRoot, i in Index.sortedNodes when match Get.threadFromRoot threadRoot

View File

@ -163,8 +163,10 @@ class Post
@labels.push label unless label in @labels
return if @isHidden
@isHidden = true
for quotelink in Get.allQuotelinksLinkingTo @
$.addClass quotelink, 'filtered'
if !@isReply
@thread.hide makeStub
@thread.hide()
return
if hideRecursively
@ -172,18 +174,18 @@ class Post
Recursive.apply 'hide', @, label, makeStub, true
Recursive.add 'hide', @, label, makeStub, true
for quotelink in Get.allQuotelinksLinkingTo @
$.addClass quotelink, 'filtered'
unless makeStub
@nodes.root.hidden = true
return
a = PostHiding.makeButton false
$.add a, $.tn " #{@getNameBlock()}"
@nodes.post.hidden = true
@nodes.post.previousElementSibling.hidden = true
@nodes.stub = $.el 'div',
className: 'stub'
$.add @nodes.stub, a
$.add @nodes.stub, [
PostHiding.makeButton false
$.tn " #{@getNameBlock()}"
]
$.add @nodes.stub, Menu.makeButton() if Conf['Menu']
$.prepend @nodes.root, @nodes.stub
show: (showRecursively=Conf['Recursive Hiding']) ->
@ -192,6 +194,8 @@ class Post
@labels = @labels.filter (label) ->
# This is lame.
!/^(Manually hidden|Recursively hidden|Hidden by)/.test label
for quotelink in Get.allQuotelinksLinkingTo @
$.rmClass quotelink, 'filtered'
if !@isReply
@thread.show()
return
@ -200,14 +204,13 @@ class Post
Recursive.apply 'show', @, true
Recursive.rm 'hide', @
for quotelink in Get.allQuotelinksLinkingTo @
$.rmClass quotelink, 'filtered'
if @nodes.stub
$.rm @nodes.stub
delete @nodes.stub
else
unless @nodes.stub
@nodes.root.hidden = false
return
@nodes.post.hidden = false
@nodes.post.previousElementSibling.hidden = false
$.rm @nodes.stub
delete @nodes.stub
highlight: (label, highlight, top) ->
@labels.push label
unless highlight in @highlights

View File

@ -62,35 +62,16 @@ class Thread
@isPinned = false
$.rmClass @catalogView.nodes.root, 'pinned' if @catalogView
hide: (makeStub=Conf['Stubs']) ->
hide: ->
return if @isHidden
@isHidden = true
root = @OP.nodes.root.parentNode
Index.updateHideLabel()
$.rm @catalogView.nodes.root if @catalogView
unless makeStub
root.hidden = true
return
@stub = $.el 'div',
className: 'stub'
{replies} = Index.liveThreadData[Index.liveThreadIDs.indexOf @ID]
$.add @stub, [
PostHiding.makeButton false
$.tn " #{@OP.getNameBlock()} (#{replies} repl#{if replies is 1 then 'y' else 'ies'})"
]
$.add @stub, Menu.makeButton() if Conf['Menu']
$.prepend root, @stub
if button = $ '.hide-post-button', @OP.nodes.root
$.replace button, PostHiding.makeButton false
show: ->
return if !@isHidden
@isHidden = false
if @stub
$.rm @stub
delete @stub
@OP.nodes.root.parentNode.hidden = false
Index.updateHideLabel()
$.rm @catalogView.nodes.root if @catalogView
if button = $ '.show-post-button', @OP.nodes.root
$.replace button, PostHiding.makeButton true
kill: ->
@isDead = true

View File

@ -6,7 +6,8 @@ Labels =
type: 'post'
el: $.el 'div', textContent: 'Labels'
order: 60
open: ({labels}, addSubEntry) ->
open: (post, addSubEntry) ->
{labels} = post.origin or post
return false unless labels.length
@subEntries.length = 0
for label in labels