Skip to content

Node.js based forum software built for the modern web

closes #1376

psychobunny10716c37d32b
diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.json
index 72cfc9bd02..ee6936147c 100644
--- a/public/language/en_GB/user.json
+++ b/public/language/en_GB/user.json
@@ -65,5 +65,8 @@
"topics_per_page": "Topics per Page",
"posts_per_page": "Posts per Page",
- "notification_sounds" : "Play a sound when you receive a notification."
+ "notification_sounds" : "Play a sound when you receive a notification.",
+
+ "browsing": "Browsing Settings",
+ "open_links_in_new_tab": "Open outgoing links in new tab?"
}
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js
index d3f68e8fab..28781a865e 100644
--- a/public/src/ajaxify.js
+++ b/public/src/ajaxify.js
@@ -261,6 +261,9 @@ var ajaxify = ajaxify || {};
if (config.useOutgoingLinksPage) {
ajaxify.go('outgoing?url=' + encodeURIComponent(this.href));
e.preventDefault();
+ } else if (config.openOutgoingLinksInNewTab) {
+ window.open(this.href, '_blank');
+ e.preventDefault();
}
}
}
diff --git a/src/controllers/api.js b/src/controllers/api.js
index 03fdfa46c5..648a5a70c6 100644
--- a/src/controllers/api.js
+++ b/src/controllers/api.js
@@ -62,6 +62,7 @@ apiController.getConfig = function(req, res, next) {
config.postsPerPage = settings.postsPerPage;
config.notificationSounds = settings.notificationSounds;
config.defaultLang = settings.language || config.defaultLang;
+ config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
if (res.locals.isAPI) {
res.json(200, config);
diff --git a/src/user/settings.js b/src/user/settings.js
index 781b1934f5..73b51c241d 100644
--- a/src/user/settings.js
+++ b/src/user/settings.js
@@ -25,6 +25,7 @@ module.exports = function(User) {
settings = data.settings;
settings.showemail = settings.showemail ? parseInt(settings.showemail, 10) !== 0 : false;
+ settings.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab ? parseInt(settings.openOutgoingLinksInNewTab, 10) !== 0 : false;
settings.dailyDigestFreq = settings.dailyDigestFreq || 'daily';
settings.usePagination = settings.usePagination ? parseInt(settings.usePagination, 10) === 1 : parseInt(meta.config.usePagination, 10) === 1;
settings.topicsPerPage = settings.topicsPerPage ? parseInt(settings.topicsPerPage, 10) : parseInt(meta.config.topicsPerPage, 10) || 20;
@@ -72,6 +73,7 @@ module.exports = function(User) {
plugins.fireHook('action:user.saveSettings', {uid: uid, settings: data});
db.setObject('user:' + uid + ':settings', {
showemail: data.showemail,
+ openOutgoingLinksInNewTab: data.openOutgoingLinksInNewTab,
dailyDigestFreq: data.dailyDigestFreq || 'daily',
usePagination: data.usePagination,
topicsPerPage: data.topicsPerPage,