diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2144cd125..f9917766e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
- 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 keybindings for index modes, `Ctrl+{1,2,3}` by default.
diff --git a/src/General/Build.coffee b/src/General/Build.coffee
index 51e2fd9c4..5cb9d1dca 100644
--- a/src/General/Build.coffee
+++ b/src/General/Build.coffee
@@ -300,6 +300,8 @@ Build =
src = "#{staticPath}nofile.png"
$.addClass thumb, 'no-file'
thumb.style.backgroundImage = "url(#{src})"
+ if Conf['Open threads in a new tab']
+ thumb.target = '_blank'
for quotelink in $$ '.quotelink', root.lastElementChild
$.replace quotelink, [quotelink.childNodes...]
diff --git a/src/General/Config.coffee b/src/General/Config.coffee
index 5345dd84f..45c8bc544 100644
--- a/src/General/Config.coffee
+++ b/src/General/Config.coffee
@@ -143,6 +143,7 @@ Config =
'Index Sort': 'bump'
'Index Size': 'small'
'Threads per Page': 0
+ 'Open threads in a new tab': false
'Show Replies': true
'Anchor Hidden Threads': true
'Refreshed Navigation': false
diff --git a/src/General/Index.coffee b/src/General/Index.coffee
index 7faf94004..87662808e 100644
--- a/src/General/Index.coffee
+++ b/src/General/Index.coffee
@@ -31,6 +31,10 @@ Index =
$.on threadsNumInput, 'change', $.cb.value
$.on threadsNumInput, 'change', @cb.threadsNum
+ targetEntry =
+ el: $.el 'label',
+ innerHTML: ' Open threads in a new tab'
+ title: 'Catalog-only setting.'
repliesEntry =
el: $.el 'label',
innerHTML: ' Show replies'
@@ -42,12 +46,14 @@ Index =
el: $.el 'label',
innerHTML: ' Refreshed navigation'
title: 'Refresh index when navigating through pages.'
- for label in [repliesEntry, anchorEntry, refNavEntry]
+ for label in [targetEntry, repliesEntry, anchorEntry, refNavEntry]
input = label.el.firstChild
{name} = input
input.checked = Conf[name]
$.on input, 'change', $.cb.checked
switch name
+ when 'Open threads in a new tab'
+ $.on input, 'change', @cb.target
when 'Show Replies'
$.on input, 'change', @cb.replies
when 'Anchor Hidden Threads'
@@ -58,7 +64,7 @@ Index =
el: $.el 'span',
textContent: 'Index Navigation'
order: 90
- subEntries: [threadNumEntry, repliesEntry, anchorEntry, refNavEntry]
+ subEntries: [threadNumEntry, targetEntry, repliesEntry, anchorEntry, refNavEntry]
$.addClass doc, 'index-loading'
@update()
@@ -261,6 +267,14 @@ Index =
return unless Conf['Index Mode'] is 'paged'
Index.buildPagelist()
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: ->
Index.buildThreads()
Index.sort()
@@ -529,7 +543,7 @@ Index =
# XXX When browsers support CSS3 attr(), use it instead.
size = if Conf['Index Size'] is 'small' then 150 else 250
for node in nodes
- thumb = $ '.thumb', node
+ thumb = node.firstElementChild
{width, height} = thumb.dataset
continue unless width
ratio = size / Math.max width, height