From 6b3ae4e3c538de2c892882637b3bff8ffec17987 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sat, 8 Feb 2020 12:54:33 +0100 Subject: [PATCH] Add more places to open user and group links in new tabs --- tildes/static/js/behaviors/group-links-new-tabs.js | 11 +++++++++++ tildes/static/js/behaviors/user-links-new-tabs.js | 11 +++++++++++ tildes/tildes/templates/home.jinja2 | 2 +- tildes/tildes/templates/macros/comments.jinja2 | 12 ++++++++++-- tildes/tildes/templates/macros/messages.jinja2 | 12 ++++++++++-- tildes/tildes/templates/macros/topics.jinja2 | 12 ++++++++++-- tildes/tildes/templates/topic.jinja2 | 12 ++++++++++-- 7 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 tildes/static/js/behaviors/group-links-new-tabs.js create mode 100644 tildes/static/js/behaviors/user-links-new-tabs.js diff --git a/tildes/static/js/behaviors/group-links-new-tabs.js b/tildes/static/js/behaviors/group-links-new-tabs.js new file mode 100644 index 0000000..1042804 --- /dev/null +++ b/tildes/static/js/behaviors/group-links-new-tabs.js @@ -0,0 +1,11 @@ +// Copyright (c) 2020 Tildes contributors +// SPDX-License-Identifier: AGPL-3.0-or-later + +$.onmount("[data-js-group-links-new-tabs]", function() { + // Open links to groups on Tildes in new tabs + $(this) + .find(".link-group") + .each(function() { + $(this).attr("target", "_blank"); + }); +}); diff --git a/tildes/static/js/behaviors/user-links-new-tabs.js b/tildes/static/js/behaviors/user-links-new-tabs.js new file mode 100644 index 0000000..9dd0de2 --- /dev/null +++ b/tildes/static/js/behaviors/user-links-new-tabs.js @@ -0,0 +1,11 @@ +// Copyright (c) 2020 Tildes contributors +// SPDX-License-Identifier: AGPL-3.0-or-later + +$.onmount("[data-js-user-links-new-tabs]", function() { + // Open links to users on Tildes in new tabs + $(this) + .find(".link-user") + .each(function() { + $(this).attr("target", "_blank"); + }); +}); diff --git a/tildes/tildes/templates/home.jinja2 b/tildes/tildes/templates/home.jinja2 index d10144e..77fa1c9 100644 --- a/tildes/tildes/templates/home.jinja2 +++ b/tildes/tildes/templates/home.jinja2 @@ -56,7 +56,7 @@ diff --git a/tildes/tildes/templates/macros/comments.jinja2 b/tildes/tildes/templates/macros/comments.jinja2 index bd8cea0..0d8e30b 100644 --- a/tildes/tildes/templates/macros/comments.jinja2 +++ b/tildes/tildes/templates/macros/comments.jinja2 @@ -133,9 +133,17 @@ {% endif %}
{% if comment.is_removed %}

This comment has been removed and is not visible to other users

diff --git a/tildes/tildes/templates/macros/messages.jinja2 b/tildes/tildes/templates/macros/messages.jinja2 index d07cfe2..46c3043 100644 --- a/tildes/tildes/templates/macros/messages.jinja2 +++ b/tildes/tildes/templates/macros/messages.jinja2 @@ -17,8 +17,16 @@
{{ message.rendered_html|safe }}
diff --git a/tildes/tildes/templates/macros/topics.jinja2 b/tildes/tildes/templates/macros/topics.jinja2 index 73ff559..97303b0 100644 --- a/tildes/tildes/templates/macros/topics.jinja2 +++ b/tildes/tildes/templates/macros/topics.jinja2 @@ -138,8 +138,16 @@ {% if is_expandable %}
{{ excerpt }} diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index 8f1dd71..b3cf537 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -65,8 +65,16 @@ {% if request.has_permission('view_content', topic) %} {% if topic.is_text_type %}
{{ topic.rendered_html|safe }}
{% elif topic.is_link_type %}