From 74036987201021624d973d5ec43a38353e735e38 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 30 Oct 2015 23:21:33 -0700 Subject: [PATCH] Implement 'Open Threads in New Tab'. #149 --- src/General/Config.coffee | 4 ++++ src/General/Main.coffee | 1 + src/Miscellaneous/ThreadLinks.coffee | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 src/Miscellaneous/ThreadLinks.coffee diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 03f44a8ba..fccc6c8dd 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -15,6 +15,10 @@ Config = 'Show a notice at the top of the page when the index is refreshed.' 1 ] + 'Open Threads in New Tab': [ + false + 'Make links to threads in the index / <%= meta.name %> catalog open in a new tab.' + ] 'External Catalog': [ false 'Link to external catalog instead of the internal one.' diff --git a/src/General/Main.coffee b/src/General/Main.coffee index c5102b5bb..9af731eca 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -379,6 +379,7 @@ Main = ['Color User IDs', IDColor] ['Highlight by User ID', IDHighlight] ['Custom CSS', CustomCSS] + ['Thread Links', ThreadLinks] ['Linkify', Linkify] ['Reveal Spoilers', RemoveSpoilers] ['Resurrect Quotes', Quotify] diff --git a/src/Miscellaneous/ThreadLinks.coffee b/src/Miscellaneous/ThreadLinks.coffee new file mode 100644 index 000000000..61f69564b --- /dev/null +++ b/src/Miscellaneous/ThreadLinks.coffee @@ -0,0 +1,20 @@ +ThreadLinks = + init: -> + return unless g.VIEW is 'index' and Conf['Open Threads in New Tab'] + + Post.callbacks.push + name: 'Thread Links' + cb: @node + CatalogThread.callbacks.push + name: 'Thread Links' + cb: @catalogNode + + node: -> + return if @isReply or @isClone + ThreadLinks.process $('.replylink', @nodes.info) + + catalogNode: -> + ThreadLinks.process @nodes.thumb.parentNode + + process: (link) -> + link.target = '_blank'