Implement delegated event handling for rel='external' [SCI-8737] (#6050)

* Replace tinymce target='_blank' with rel='external' [SCI-8737]

* Add noopener to rel='external' links
This commit is contained in:
ivanscinote 2023-08-24 11:12:11 +02:00 committed by GitHub
parent 97f406d0a8
commit 059530620b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 11 deletions

View file

@ -12,7 +12,7 @@ var selectedRow = null;
function initEditMyModuleDescription() {
var viewObject = $('#my_module_description_view');
viewObject.on('click', function(e) {
if ($(e.target).hasClass('record-info-link')) return;
if ($(e.target).hasClass('record-info-link') || e.target.tagName === 'A') return;
TinyMCE.init(
'#my_module_description_textarea',
{
@ -22,9 +22,6 @@ function initEditMyModuleDescription() {
assignableMyModuleId: $('#my_module_description_textarea').data('object-id')
}
);
}).on('click', 'a', function(e) {
if ($(this).hasClass('record-info-link')) return;
e.stopPropagation();
});
setTimeout(function() {

View file

@ -46,3 +46,7 @@ $.ajaxSetup({
}
});
$(document).on('click', 'a[rel*=external]', function(e) {
e.preventDefault();
window.open(this.href, '_blank', 'noopener');
});

View file

@ -247,7 +247,6 @@ window.TinyMCE = (() => {
object_resizing: true,
elementpath: false,
quickbars_insert_toolbar: false,
default_link_target: '_blank',
toolbar_mode: 'sliding',
color_default_background: 'yellow',
link_default_target: 'external',
@ -503,9 +502,3 @@ $(document).on('turbolinks:before-visit', (e) => {
}
return true;
});
// Open rel="external" links in new tabs
$('a[rel*=external]').on('click', function(e) {
e.preventDefault();
window.open(this.href, '_blank', 'noopener');
});