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 and post hiding changes:
- `Thread Hiding` and `Reply Hiding` settings are merged into one: `Post Hiding`. - The posts' menu now has a label entry listing the reasons why a post got hidden or highlighted.
- `Thread Hiding Link` and `Reply Hiding Link` settings are merged into one: `Post Hiding Link`. - `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* ### 3.18.1 - *2014-02-20*

View File

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

View File

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

View File

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

View File

@ -232,6 +232,6 @@ Get =
thread = g.threads["#{boardID}.#{threadID}"] or thread = g.threads["#{boardID}.#{threadID}"] or
new Thread threadID, board new Thread threadID, board
post = new Post Build.post(o, true), thread, board, {isArchived: true} 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] Main.callbackNodes Post, [post]
Get.insert post, root, context Get.insert post, root, context

View File

@ -38,15 +38,11 @@ Index =
repliesEntry = repliesEntry =
el: $.el 'label', el: $.el 'label',
innerHTML: '<input type=checkbox name="Show Replies"> Show replies' 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 = refNavEntry =
el: $.el 'label', el: $.el 'label',
innerHTML: '<input type=checkbox name="Refreshed Navigation"> Refreshed navigation' innerHTML: '<input type=checkbox name="Refreshed Navigation"> Refreshed navigation'
title: 'Refresh index when navigating through pages.' title: 'Refresh index when navigating through pages.'
for label in [targetEntry, repliesEntry, anchorEntry, refNavEntry] for label in [targetEntry, repliesEntry, refNavEntry]
input = label.el.firstChild input = label.el.firstChild
{name} = input {name} = input
input.checked = Conf[name] input.checked = Conf[name]
@ -56,15 +52,13 @@ Index =
$.on input, 'change', @cb.target $.on input, 'change', @cb.target
when 'Show Replies' when 'Show Replies'
$.on input, 'change', @cb.replies $.on input, 'change', @cb.replies
when 'Anchor Hidden Threads'
$.on input, 'change', @cb.sort
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'header' type: 'header'
el: $.el 'span', el: $.el 'span',
textContent: 'Index Navigation' textContent: 'Index Navigation'
order: 90 order: 90
subEntries: [threadNumEntry, targetEntry, repliesEntry, anchorEntry, refNavEntry] subEntries: [threadNumEntry, targetEntry, repliesEntry, refNavEntry]
$.addClass doc, 'index-loading' $.addClass doc, 'index-loading'
@update() @update()
@ -124,24 +118,7 @@ Index =
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'post' type: 'post'
el: $.el 'a', href: 'javascript:;' el: $.el 'a', href: 'javascript:;'
order: 5 order: 19
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
open: ({thread}) -> open: ({thread}) ->
return false if Conf['Index Mode'] isnt 'catalog' return false if Conf['Index Mode'] isnt 'catalog'
@el.textContent = if thread.isPinned @el.textContent = if thread.isPinned
@ -573,9 +550,7 @@ Index =
Main.handleErrors errors if errors Main.handleErrors errors if errors
Main.callbackNodes Post, posts Main.callbackNodes Post, posts
buildCatalogViews: -> buildCatalogViews: ->
threads = Index.sortedNodes threads = Index.sortedNodes.map (threadRoot) -> Get.threadFromRoot threadRoot
.map (threadRoot) -> Get.threadFromRoot threadRoot
.filter (thread) -> !thread.isHidden isnt Index.showHiddenThreads
catalogThreads = [] catalogThreads = []
for thread in threads when !thread.catalogView for thread in threads when !thread.catalogView
catalogThreads.push new CatalogThread Build.catalogThread(thread), thread 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 sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> b.replies - a.replies).map (data) -> data.no
when 'filecount' when 'filecount'
sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> b.images - a.images).map (data) -> data.no sortedThreadIDs = [Index.liveThreadData...].sort((a, b) -> b.images - a.images).map (data) -> data.no
Index.sortedNodes = sortedThreadIDs.map (threadID) -> Index.sortedNodes = sortedThreadIDs
Index.nodes[Index.liveThreadIDs.indexOf threadID] .map (threadID) -> Index.nodes[Index.liveThreadIDs.indexOf threadID]
.filter (threadRoot) -> Get.threadFromRoot(threadRoot).isHidden is Index.showHiddenThreads
if Index.isSearching if Index.isSearching
Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes
# Sticky threads # Sticky threads
Index.sortOnTop (thread) -> thread.isSticky Index.sortOnTop (thread) -> thread.isSticky
# Highlighted threads # Highlighted threads
Index.sortOnTop (thread) -> thread.isOnTop or thread.isPinned Index.sortOnTop (thread) -> thread.isOnTop or thread.isPinned
# Non-hidden threads
Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads']
sortOnTop: (match) -> sortOnTop: (match) ->
offset = 0 offset = 0
for threadRoot, i in Index.sortedNodes when match Get.threadFromRoot threadRoot 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 @labels.push label unless label in @labels
return if @isHidden return if @isHidden
@isHidden = true @isHidden = true
for quotelink in Get.allQuotelinksLinkingTo @
$.addClass quotelink, 'filtered'
if !@isReply if !@isReply
@thread.hide makeStub @thread.hide()
return return
if hideRecursively if hideRecursively
@ -172,18 +174,18 @@ class Post
Recursive.apply 'hide', @, label, makeStub, true Recursive.apply 'hide', @, label, makeStub, true
Recursive.add 'hide', @, label, makeStub, true Recursive.add 'hide', @, label, makeStub, true
for quotelink in Get.allQuotelinksLinkingTo @
$.addClass quotelink, 'filtered'
unless makeStub unless makeStub
@nodes.root.hidden = true @nodes.root.hidden = true
return return
a = PostHiding.makeButton false @nodes.post.hidden = true
$.add a, $.tn " #{@getNameBlock()}" @nodes.post.previousElementSibling.hidden = true
@nodes.stub = $.el 'div', @nodes.stub = $.el 'div',
className: 'stub' className: 'stub'
$.add @nodes.stub, a $.add @nodes.stub, [
PostHiding.makeButton false
$.tn " #{@getNameBlock()}"
]
$.add @nodes.stub, Menu.makeButton() if Conf['Menu'] $.add @nodes.stub, Menu.makeButton() if Conf['Menu']
$.prepend @nodes.root, @nodes.stub $.prepend @nodes.root, @nodes.stub
show: (showRecursively=Conf['Recursive Hiding']) -> show: (showRecursively=Conf['Recursive Hiding']) ->
@ -192,6 +194,8 @@ class Post
@labels = @labels.filter (label) -> @labels = @labels.filter (label) ->
# This is lame. # This is lame.
!/^(Manually hidden|Recursively hidden|Hidden by)/.test label !/^(Manually hidden|Recursively hidden|Hidden by)/.test label
for quotelink in Get.allQuotelinksLinkingTo @
$.rmClass quotelink, 'filtered'
if !@isReply if !@isReply
@thread.show() @thread.show()
return return
@ -200,14 +204,13 @@ class Post
Recursive.apply 'show', @, true Recursive.apply 'show', @, true
Recursive.rm 'hide', @ Recursive.rm 'hide', @
for quotelink in Get.allQuotelinksLinkingTo @ unless @nodes.stub
$.rmClass quotelink, 'filtered'
if @nodes.stub
$.rm @nodes.stub
delete @nodes.stub
else
@nodes.root.hidden = false @nodes.root.hidden = false
return
@nodes.post.hidden = false
@nodes.post.previousElementSibling.hidden = false
$.rm @nodes.stub
delete @nodes.stub
highlight: (label, highlight, top) -> highlight: (label, highlight, top) ->
@labels.push label @labels.push label
unless highlight in @highlights unless highlight in @highlights

View File

@ -62,35 +62,16 @@ class Thread
@isPinned = false @isPinned = false
$.rmClass @catalogView.nodes.root, 'pinned' if @catalogView $.rmClass @catalogView.nodes.root, 'pinned' if @catalogView
hide: (makeStub=Conf['Stubs']) -> hide: ->
return if @isHidden return if @isHidden
@isHidden = true @isHidden = true
root = @OP.nodes.root.parentNode if button = $ '.hide-post-button', @OP.nodes.root
Index.updateHideLabel() $.replace button, PostHiding.makeButton false
$.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
show: -> show: ->
return if !@isHidden return if !@isHidden
@isHidden = false @isHidden = false
if @stub if button = $ '.show-post-button', @OP.nodes.root
$.rm @stub $.replace button, PostHiding.makeButton true
delete @stub
@OP.nodes.root.parentNode.hidden = false
Index.updateHideLabel()
$.rm @catalogView.nodes.root if @catalogView
kill: -> kill: ->
@isDead = true @isDead = true

View File

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