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

8.0.x
catch 2012-12-19 17:26:18 +00:00
parent 99f1870e85
commit 2df1b2a2a9
1 changed files with 5 additions and 4 deletions

View File

@ -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');
}