Add Open threads in a new tab setting.

This commit is contained in:
Mayhem 2014-02-13 15:43:15 +01:00
parent e2f26cfa66
commit 740e408798
4 changed files with 21 additions and 3 deletions

View File

@ -1,4 +1,5 @@
- Added `Image Size` setting for the catalog. - Added `Image Size` setting for the catalog.
- Added `Open threads in a new tab` setting for the catalog.
- Added a keybind to cycle through index sort types, `Ctrl+x` by default. - Added a keybind to cycle through index sort types, `Ctrl+x` by default.
- Added keybindings for index modes, `Ctrl+{1,2,3}` by default. - Added keybindings for index modes, `Ctrl+{1,2,3}` by default.

View File

@ -300,6 +300,8 @@ Build =
src = "#{staticPath}nofile.png" src = "#{staticPath}nofile.png"
$.addClass thumb, 'no-file' $.addClass thumb, 'no-file'
thumb.style.backgroundImage = "url(#{src})" thumb.style.backgroundImage = "url(#{src})"
if Conf['Open threads in a new tab']
thumb.target = '_blank'
for quotelink in $$ '.quotelink', root.lastElementChild for quotelink in $$ '.quotelink', root.lastElementChild
$.replace quotelink, [quotelink.childNodes...] $.replace quotelink, [quotelink.childNodes...]

View File

@ -143,6 +143,7 @@ Config =
'Index Sort': 'bump' 'Index Sort': 'bump'
'Index Size': 'small' 'Index Size': 'small'
'Threads per Page': 0 'Threads per Page': 0
'Open threads in a new tab': false
'Show Replies': true 'Show Replies': true
'Anchor Hidden Threads': true 'Anchor Hidden Threads': true
'Refreshed Navigation': false 'Refreshed Navigation': false

View File

@ -31,6 +31,10 @@ Index =
$.on threadsNumInput, 'change', $.cb.value $.on threadsNumInput, 'change', $.cb.value
$.on threadsNumInput, 'change', @cb.threadsNum $.on threadsNumInput, 'change', @cb.threadsNum
targetEntry =
el: $.el 'label',
innerHTML: '<input type=checkbox name="Open threads in a new tab"> Open threads in a new tab'
title: 'Catalog-only setting.'
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'
@ -42,12 +46,14 @@ Index =
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 [repliesEntry, anchorEntry, refNavEntry] for label in [targetEntry, repliesEntry, anchorEntry, refNavEntry]
input = label.el.firstChild input = label.el.firstChild
{name} = input {name} = input
input.checked = Conf[name] input.checked = Conf[name]
$.on input, 'change', $.cb.checked $.on input, 'change', $.cb.checked
switch name switch name
when 'Open threads in a new tab'
$.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' when 'Anchor Hidden Threads'
@ -58,7 +64,7 @@ Index =
el: $.el 'span', el: $.el 'span',
textContent: 'Index Navigation' textContent: 'Index Navigation'
order: 90 order: 90
subEntries: [threadNumEntry, repliesEntry, anchorEntry, refNavEntry] subEntries: [threadNumEntry, targetEntry, repliesEntry, anchorEntry, refNavEntry]
$.addClass doc, 'index-loading' $.addClass doc, 'index-loading'
@update() @update()
@ -261,6 +267,14 @@ Index =
return unless Conf['Index Mode'] is 'paged' return unless Conf['Index Mode'] is 'paged'
Index.buildPagelist() Index.buildPagelist()
Index.buildIndex() Index.buildIndex()
target: ->
for threadID, thread of g.BOARD.threads when thread.catalogView
{thumb} = thread.catalogView.nodes
if Conf['Open threads in a new tab']
thumb.target = '_blank'
else
thumb.removeAttribute 'target'
return
replies: -> replies: ->
Index.buildThreads() Index.buildThreads()
Index.sort() Index.sort()
@ -529,7 +543,7 @@ Index =
# XXX When browsers support CSS3 attr(), use it instead. # XXX When browsers support CSS3 attr(), use it instead.
size = if Conf['Index Size'] is 'small' then 150 else 250 size = if Conf['Index Size'] is 'small' then 150 else 250
for node in nodes for node in nodes
thumb = $ '.thumb', node thumb = node.firstElementChild
{width, height} = thumb.dataset {width, height} = thumb.dataset
continue unless width continue unless width
ratio = size / Math.max width, height ratio = size / Math.max width, height