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: ->
return unless g.VIEW is 'thread' and Conf['Reply Pruning']
@active = not (Conf['Quote Threading'] and Conf['Thread Quotes'])
@container = $.frag()
@summary = $.el 'span',
@ -14,7 +12,7 @@ ReplyPruning =
@inputs.enabled.checked = !@inputs.enabled.checked
$.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',
title: 'Maximum number of replies to show.'
,
@ -25,6 +23,7 @@ ReplyPruning =
enabled: label.firstElementChild
replies: el.lastElementChild
@setEnabled.call @inputs.enabled
$.on @inputs.enabled, 'change', @setEnabled
$.on @inputs.replies, 'change', $.cb.value
@ -63,11 +62,10 @@ ReplyPruning =
(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.
# Also don't hide posts if we open the thread by a link to the OP.
if (
ReplyPruning.active 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

View File

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

View File

@ -409,6 +409,11 @@ Config =
true
'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':
'Quick Reply': [