Add Prune by Default option (default: false): Turn Reply Pruning on by default in all threads, except when navigating to a post that would be hidden. #1115

This commit is contained in:
ccd0 2016-11-07 12:19:54 -08:00
parent 2fd909e7b7
commit 67d22a15e9
3 changed files with 14 additions and 9 deletions

View File

@ -2,8 +2,6 @@ ReplyPruning =
init: -> init: ->
return unless g.VIEW is 'thread' and Conf['Reply Pruning'] return unless g.VIEW is 'thread' and Conf['Reply Pruning']
@active = not (Conf['Quote Threading'] and Conf['Thread Quotes'])
@container = $.frag() @container = $.frag()
@summary = $.el 'span', @summary = $.el 'span',
@ -14,7 +12,7 @@ ReplyPruning =
@inputs.enabled.checked = !@inputs.enabled.checked @inputs.enabled.checked = !@inputs.enabled.checked
$.event 'change', null, @inputs.enabled $.event 'change', null, @inputs.enabled
label = UI.checkbox 'Prune Replies', 'Show Last', @active label = UI.checkbox 'Prune Replies', 'Show Last', Conf['Prune by Default']
el = $.el 'span', el = $.el 'span',
title: 'Maximum number of replies to show.' title: 'Maximum number of replies to show.'
, ,
@ -25,6 +23,7 @@ ReplyPruning =
enabled: label.firstElementChild enabled: label.firstElementChild
replies: el.lastElementChild replies: el.lastElementChild
@setEnabled.call @inputs.enabled
$.on @inputs.enabled, 'change', @setEnabled $.on @inputs.enabled, 'change', @setEnabled
$.on @inputs.replies, 'change', $.cb.value $.on @inputs.replies, 'change', $.cb.value
@ -63,11 +62,10 @@ ReplyPruning =
(ReplyPruning.totalFiles++ if post.file) (ReplyPruning.totalFiles++ if post.file)
# If we're linked to a post that we would hide, don't hide the posts in the first place. # If we're linked to a post that we would hide, don't hide the posts in the first place.
# Also don't hide posts if we open the thread by a link to the OP.
if ( if (
ReplyPruning.active and ReplyPruning.active and
/^#p\d+$/.test(location.hash) and /^#p\d+$/.test(location.hash) and
0 <= @posts.keys.indexOf(location.hash[2..]) < 1 + Math.max(ReplyPruning.total - +Conf["Max Replies"], 0) 1 <= @posts.keys.indexOf(location.hash[2..]) < 1 + Math.max(ReplyPruning.total - +Conf["Max Replies"], 0)
) )
ReplyPruning.active = ReplyPruning.inputs.enabled.checked = false ReplyPruning.active = ReplyPruning.inputs.enabled.checked = false

View File

@ -39,10 +39,12 @@ QuoteThreading =
inserted: {} inserted: {}
setEnabled: -> setEnabled: ->
other = ReplyPruning.inputs?.enabled if @checked
if @checked and other?.checked $.set 'Prune by Default', false
other.checked = false other = ReplyPruning.inputs?.enabled
$.event 'change', null, other if other?.checked
other.checked = false
$.event 'change', null, other
$.cb.checked.call @ $.cb.checked.call @
setThread: -> setThread: ->

View File

@ -409,6 +409,11 @@ Config =
true true
'Hide old replies in long threads. Number of replies shown can be set from header menu.' 'Hide old replies in long threads. Number of replies shown can be set from header menu.'
] ]
'Prune by Default': [
false
'Turn Reply Pruning on by default in all threads, except when navigating to a post that would be hidden.'
1
]
'Posting and Captchas': 'Posting and Captchas':
'Quick Reply': [ 'Quick Reply': [