Skip to content
Snippets Groups Projects
Commit 2df1b2a2 authored by catch's avatar catch
Browse files

Issue #1440662 by marthinal, sun, nod_, bdone: Fixed Prevent links in node...

Issue #1440662 by marthinal, sun, nod_, bdone: Fixed Prevent links in node preview from being clicked.
parent 99f1870e
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -3,20 +3,21 @@ ...@@ -3,20 +3,21 @@
"use strict"; "use strict";
/** /**
* Disabling all links in node previews to prevent users from leaving the page. * Disabling all links (except local fragment identifiers such as href="#frag")
* in node previews to prevent users from leaving the page.
*/ */
Drupal.behaviors.nodePreviewDestroyLinks = { Drupal.behaviors.nodePreviewDestroyLinks = {
attach: function (context) { attach: function (context) {
var $preview = $(context).find('.node.preview').once('node-preview'); var $preview = $(context).find('.node').once('node-preview');
if ($preview.length) { if ($preview.length) {
$preview.on('click.preview', 'a', function (e) { $preview.on('click.preview', 'a:not([href^=#])', function (e) {
e.preventDefault(); e.preventDefault();
}); });
} }
}, },
detach: function (context, settings, trigger) { detach: function (context, settings, trigger) {
if (trigger === 'unload') { if (trigger === 'unload') {
var $preview = $(context).find('.node.preview').removeOnce('node-preview'); var $preview = $(context).find('.node').removeOnce('node-preview');
if ($preview.length) { if ($preview.length) {
$preview.off('click.preview'); $preview.off('click.preview');
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment