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
......@@ -3,20 +3,21 @@
"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 = {
attach: function (context) {
var $preview = $(context).find('.node.preview').once('node-preview');
var $preview = $(context).find('.node').once('node-preview');
if ($preview.length) {
$preview.on('click.preview', 'a', function (e) {
$preview.on('click.preview', 'a:not([href^=#])', function (e) {
e.preventDefault();
});
}
},
detach: function (context, settings, trigger) {
if (trigger === 'unload') {
var $preview = $(context).find('.node.preview').removeOnce('node-preview');
var $preview = $(context).find('.node').removeOnce('node-preview');
if ($preview.length) {
$preview.off('click.preview');
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment