Mirror most of Index Navigation menu settings in main settings panel. #186

This commit is contained in:
ccd0 2016-10-04 01:35:15 -07:00
parent 2540f23ac7
commit fa1aaa224c
3 changed files with 44 additions and 37 deletions

View File

@ -46,35 +46,37 @@ Index =
Header.addShortcut 'index-refresh', @button, 590 Header.addShortcut 'index-refresh', @button, 590
# Header "Index Navigation" submenu # Header "Index Navigation" submenu
repliesEntry = el: UI.checkbox 'Show Replies', 'Show replies' entries = []
hoverEntry = el: UI.checkbox 'Catalog Hover Expand', 'Catalog hover expand' inputs = {}
sortEntry = el: UI.checkbox 'Per-Board Sort Type', 'Per-board sort type', (typeof Conf['Index Sort'] is 'object') for name, arr of Config.Index when arr instanceof Array
pinEntry = el: UI.checkbox 'Pin Watched Threads', 'Pin watched threads' label = UI.checkbox name, "#{name[0]}#{name[1..].toLowerCase()}"
anchorEntry = el: UI.checkbox 'Anchor Hidden Threads', 'Anchor hidden threads' label.title = arr[1]
refNavEntry = el: UI.checkbox 'Refreshed Navigation', 'Refreshed navigation' entries.push {el: label}
hoverEntry.el.title = 'Expand the comment and show more details when you hover over a thread in the catalog.' input = label.firstChild
sortEntry.el.title = 'Set the sorting order of each board independently.'
pinEntry.el.title = 'Move watched threads to the start of the index.'
anchorEntry.el.title = 'Move hidden threads to the end of the index.'
refNavEntry.el.title = 'Refresh index when navigating through pages.'
for label in [repliesEntry, hoverEntry, pinEntry, anchorEntry, refNavEntry]
input = label.el.firstChild
{name} = input
$.on input, 'change', $.cb.checked $.on input, 'change', $.cb.checked
switch name inputs[name] = input
when 'Show Replies' $.on inputs['Show Replies'], 'change', @cb.replies
$.on input, 'change', @cb.replies $.on inputs['Catalog Hover Expand'], 'change', @cb.hover
when 'Catalog Hover Expand' $.on inputs['Pin Watched Threads'], 'change', @cb.resort
$.on input, 'change', @cb.hover $.on inputs['Anchor Hidden Threads'], 'change', @cb.resort
when 'Pin Watched Threads', 'Anchor Hidden Threads'
$.on input, 'change', @cb.resort watchSettings = (e) ->
$.on sortEntry.el.firstChild, 'change', @cb.perBoardSort if (input = inputs[e.target.name])
input.checked = e.target.checked
$.event 'change', null, input
$.on d, 'OpenSettings', ->
$.on $.id('fourchanx-settings'), 'change', watchSettings
sortEntry = UI.checkbox 'Per-Board Sort Type', 'Per-board sort type', (typeof Conf['Index Sort'] is 'object')
sortEntry.title = 'Set the sorting order of each board independently.'
$.on sortEntry.firstChild, 'change', @cb.perBoardSort
entries.splice 2, 0, {el: sortEntry}
Header.menu.addEntry Header.menu.addEntry
el: $.el 'span', el: $.el 'span',
textContent: 'Index Navigation' textContent: 'Index Navigation'
order: 100 order: 100
subEntries: [repliesEntry, hoverEntry, sortEntry, pinEntry, anchorEntry, refNavEntry] subEntries: entries
# Navigation links at top of index # Navigation links at top of index
@navLinks = $.el 'div', className: 'navLinks json-index' @navLinks = $.el 'div', className: 'navLinks json-index'

View File

@ -135,19 +135,16 @@ Settings =
items = {} items = {}
inputs = {} inputs = {}
for key, obj of Config.main addCheckboxes = (root, obj) ->
fs = $.el 'fieldset', containers = [root]
<%= html('<legend>${key}</legend>') %> for key, arr of obj when arr instanceof Array
containers = [fs]
for key, arr of obj
description = arr[1] description = arr[1]
div = $.el 'div', div = $.el 'div',
<%= html('<label><input type="checkbox" name="${key}">${key}</label><span class="description">: ${description}</span>') %> <%= html('<label><input type="checkbox" name="${key}">${key}</label><span class="description">: ${description}</span>') %>
div.hidden = true if $.engine isnt 'gecko' and key is 'Remember QR Size' # XXX not supported div.dataset.name = key
input = $ 'input', div input = $ 'input', div
$.on input, 'change', -> $.on input, 'change', $.cb.checked
@parentNode.parentNode.dataset.checked = @checked $.on input, 'change', -> @parentNode.parentNode.dataset.checked = @checked
$.cb.checked.call @
items[key] = Conf[key] items[key] = Conf[key]
inputs[key] = input inputs[key] = input
level = arr[2] or 0 level = arr[2] or 0
@ -158,7 +155,15 @@ Settings =
else if containers.length > level+1 else if containers.length > level+1
containers.splice level+1, containers.length - (level+1) containers.splice level+1, containers.length - (level+1)
$.add containers[level], div $.add containers[level], div
for key, obj of Config.main
fs = $.el 'fieldset',
<%= html('<legend>${key}</legend>') %>
addCheckboxes fs, obj
$.add section, fs $.add section, fs
addCheckboxes $('div[data-name="JSON Index"] > .suboption-list', section), Config.Index
if $.engine isnt 'gecko'
$('div[data-name="Remember QR Size"]', section).hidden = true # XXX not supported
$.get items, (items) -> $.get items, (items) ->
for key, val of items for key, val of items

View File

@ -736,11 +736,11 @@ Config =
'Index Mode': 'paged' 'Index Mode': 'paged'
'Previous Index Mode': 'paged' 'Previous Index Mode': 'paged'
'Index Size': 'small' 'Index Size': 'small'
'Show Replies': true 'Show Replies': [true, 'Show replies in the index, and also in the catalog if "Catalog hover expand" is checked.']
'Catalog Hover Expand': true 'Catalog Hover Expand': [true, 'Expand the comment and show more details when you hover over a thread in the catalog.']
'Pin Watched Threads': false 'Pin Watched Threads': [false, 'Move watched threads to the start of the index.']
'Anchor Hidden Threads': true 'Anchor Hidden Threads': [true, 'Move hidden threads to the end of the index.']
'Refreshed Navigation': false 'Refreshed Navigation': [false, 'Refresh index when navigating through pages.']
Header: Header:
'Fixed Header': true 'Fixed Header': true