mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-29 03:35:25 +08:00
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:
parent
97f406d0a8
commit
059530620b
3 changed files with 5 additions and 11 deletions
|
@ -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() {
|
||||
|
|
|
@ -46,3 +46,7 @@ $.ajaxSetup({
|
|||
}
|
||||
});
|
||||
|
||||
$(document).on('click', 'a[rel*=external]', function(e) {
|
||||
e.preventDefault();
|
||||
window.open(this.href, '_blank', 'noopener');
|
||||
});
|
||||
|
|
7
app/javascript/packs/tiny_mce.js
vendored
7
app/javascript/packs/tiny_mce.js
vendored
|
@ -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');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue