Browse Source

Use data attribute for open text links in new tabs setting

merge-requests/14/head
Ivan Fonseca 7 years ago
parent
commit
24807a07a9
No known key found for this signature in database GPG Key ID: 95A9C856EC788689
  1. 2
      tildes/static/js/behaviors/external-links-new-tabs.js
  2. 6
      tildes/tildes/templates/macros/comments.jinja2

2
tildes/static/js/behaviors/comment-text.js → tildes/static/js/behaviors/external-links-new-tabs.js

@ -1,4 +1,4 @@
$.onmount('[data-js-comment-text]', function() {
$.onmount('[data-js-external-links-new-tabs]', function() {
// Make all links in comment open in new tab
$(this).find('a[href^="http"]').attr('target', '_blank');
});

6
tildes/tildes/templates/macros/comments.jinja2

@ -94,7 +94,11 @@
</ul>
{% endif %}
<div class="comment-text" data-js-comment-text>
<div class="comment-text"
{% if request.user and request.user.open_new_tab_text %}
data-js-external-links-new-tabs
{% endif %}
>
{% if comment.is_removed and 'admin' in request.effective_principals %}
<p class="text-warning">Comment removed</p>
{% endif %}

Loading…
Cancel
Save